You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by William Lee <wl...@sendmail.com> on 2001/02/28 21:15:08 UTC
with-param not working for apply-templates on XalanJ2?
I can't seem to get the with-param working with apply-templates.
However, with-param works with call-template. Can anyone show me why?
I've tried to apply the following style sheets:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<xsl:template match="/">
<xsl:apply-templates>
<xsl:with-param name="str" select="'a string'"/>
</xsl:apply-templates>
<!--
<xsl:call-template name="text">
<xsl:with-param name="str" select="'a string'"/>
</xsl:call-template>
-->
</xsl:template>
<xsl:template name="text" match="text">
<xsl:param name="str"/>
This is <xsl:value-of select="$str"/>
</xsl:template>
</xsl:stylesheet>
with this XML file:
<?xml version="1.0" encoding="UTF-8"?>
<v3.document name="Index">
<foo>
<bar><text /></bar>
<bar><text /></bar>
</foo>
</v3.document>
Note that I have two instances of <text/> in the XML file. Thus what I
would expect the output would be:
This is a string
This is a string
However, I got the following:
This is
This is
With the <xsl:apply-templates> line taken out and use the call template
instead, I got:
This is a string
which is what I expected.
It seems like I can't really use apply-templates and pass in the
parameter. Can anyone tell me what's wrong?
Will
Re: with-param not working for apply-templates on XalanJ2?
Posted by William Lee <wl...@sendmail.com>.
Please ignore this e-mail. I think I've figured it out. It's the result
of not passing in the parameters in the nested element. The str is not
visible when it passes to the <text/> element.
Will
William Lee wrote:
>
> I can't seem to get the with-param working with apply-templates.
> However, with-param works with call-template. Can anyone show me why?
>
> I've tried to apply the following style sheets:
>
> <?xml version='1.0'?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version='1.0'>
>
> <xsl:template match="/">
> <xsl:apply-templates>
> <xsl:with-param name="str" select="'a string'"/>
> </xsl:apply-templates>
> <!--
> <xsl:call-template name="text">
> <xsl:with-param name="str" select="'a string'"/>
> </xsl:call-template>
> -->
> </xsl:template>
>
> <xsl:template name="text" match="text">
> <xsl:param name="str"/>
> This is <xsl:value-of select="$str"/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> with this XML file:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <v3.document name="Index">
> <foo>
> <bar><text /></bar>
> <bar><text /></bar>
> </foo>
> </v3.document>
>
> Note that I have two instances of <text/> in the XML file. Thus what I
> would expect the output would be:
>
> This is a string
> This is a string
>
> However, I got the following:
>
> This is
> This is
>
> With the <xsl:apply-templates> line taken out and use the call template
> instead, I got:
>
> This is a string
>
> which is what I expected.
>
> It seems like I can't really use apply-templates and pass in the
> parameter. Can anyone tell me what's wrong?
>
> Will