Subject: RE: [xsl] problem passing parameter to apply-templates From: cknell@xxxxxxxxxx Date: Tue, 30 Aug 2005 18:50:12 -0400 |
The first thing I notice is that your "nodes" parameter is defined in the context of the template matching <item>. This means that once the <item> goes out of scope, the parameter disappears entirely. Your template matching page expects to see the "nodes" parameter, but so far as that template is concerned, there is no "nodes" parameter. If you want the "nodes" parameter to be in-scope for all templates, you will have to declare it outside of any template. I find it convenient to define all parameters before the first template, but as far as the XSLT processing model is concerned, you could place them after the last template or between any two templates. They just can't be *in* any template if you want them to be visible to other templates. The second thing I notice is that although you have a template that matches the <item> node, your source document has no <item> nodes. -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Paula Estrella <paula_ile2003@xxxxxxxxxxxx> Sent: Tue, 30 Aug 2005 19:40:38 -0300 (ART) To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] problem passing parameter to apply-templates Hi all, I'm trying to pass a parameter to a template by using apply-templates (as showed in the stylesheet below) but I don't get the value of the parameter when the template is applied, i.e I should print "blabla" but instead I get nothing (a null value or empty string?). I also read somewhere that this might be a kind of bug of the xslt processor; I'm using the Cocoon framework, which uses xalan to process xslt (I guess v. 1.0) Although I found another (dirty) solution to get what I want, I'd really like to know what's the error here so I can learn from my mistakes ... Thanks in advance, Paula <!-- short version of the stylesheets --> <xsl:template match="page"> <xsl:apply-templates select="title"/><br/> <xsl:apply-templates select="document('../xml/clasif2.xml')/clasif2"> <xsl:with-param name="nodes" select="'blabla'"/> </xsl:apply-templates> </xsl:template> <xsl:template match="item"> <xsl:param name="nodes"/> <xsl:value-of select="$nodes"/> </xsl:template> <!-- xml file to which the above stylesheet is applied --> <page> <title>some title</title> <checked> <xsp:attribute name="data"> 102 </xsp:attribute> </checked> </page> ___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem passing parameter, David Carlisle | Thread | RE: [xsl] problem passing parameter, Paula Estrella |
[xsl] problem passing parameter to, Paula Estrella | Date | RE: [xsl] problem passing parameter, Paula Estrella |
Month |