[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: problem passing parameter to apply-templates

Subject: RE: problem passing parameter to apply-templates
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 31 Aug 2005 09:44:24 +0100
apply templates parameter
I haven't studied your code in detail, but a common pitfall in this area is
the situation where the element hierarchy is A/B/C:

template A does xsl:apply-templates with parameters

there is no template for B, so the built in template gets invoked

the built in template for B invokes the template for C

the template for C sees no parameters


This is because (in XSLT 1.0) built-in templates do not pass their
parameters on.

With multiple documents, this problem often occurs because people do
apply-templates on the root (document) node, but write a template rule to
process the top-level element, so the built-in template for the root node
loses the parameters.

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: Paula Estrella [mailto:paula_ile2003@xxxxxxxxxxxx] 
> Sent: 30 August 2005 23:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.