You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jon Stevens <jo...@latchkey.com> on 2000/11/21 06:06:35 UTC
(solution) Re: XSL help
on 11/20/2000 8:15 PM, "Jon Stevens" <jo...@latchkey.com> wrote:
> foo.xml:
> <document baseImagesDirectory="..">
> <body>
> <img src="foo.gif">
> </body>
> </document>
>
> my.xsl:
> <xsl:template match="document">
> <xsl:apply-templates select="body/*"/>
> </xsl:template>
>
> <xsl:template match="img">
> <img src="{$baseImagesDirectory}/{@src}"/>
> </xsl:template>
Ok, here is the solution to pass the variable "image-path" all over the
kingdom:
foo.xml:
<document images="..">
<body>
<img src="foo.gif">
</body>
</document>
my.xsl:
<xsl:template match="document">
<xsl:apply-templates select="body/*">
<xsl:with-param name="image-path" select="@images"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="body/*">
<xsl:param name="image-path"/>
<xsl:apply-templates>
<xsl:with-param name="image-path" select="$image-path"/>
</xsl:apple-templates>
</xsl:template>
<xsl:template match="img">
<xsl:param name="image-path"/>
<img src="{$image-path}/{@src}"/>
</xsl:template>
many thanks to "steve" who helped me in private email. essentially, the
problem was that i didn't have a template match for "body/*".
If this is any sort of hint, I think that whomever defines XSL should make
this a bit more intelligent. This is a major PITA. I should at least be able
to define a "global" <xsl:variable> within an <xsl:template> that can then
be used in any another <xsl:template>. That would make life SO much easier.
I could never see a template designer using this XSL stuff. I'm sorry, but
this is way to complicated and convoluted. :-(
thanks,
-jon
--
twice of not very much is still a lot more than not very much