Subject: Re: Using xsl:apply-templates with xsl:with-param From: "Steve Muench" <smuench@xxxxxxxxxxxxx> Date: Mon, 15 May 2000 13:50:41 -0700 |
| How is xsl:with-param supposed to work from within an xsl:apply-templates | element? The recommendation doesn't seem to actually spell it out, other | that saying it is allowed. Consider the following: I think what's happening here is that your: <xsl:template match="/"> <root> <xsl:apply-templates> <xsl:with-param name="param">List</xsl:with-param> </xsl:apply-templates> </root> </xsl:template> tells the XSLT processor to "apply templates" to all children of the current node (in this case, the root "/"), passing a parameter. In your source document, the first child of the root is the <doc> document element, which you don't have a specific template to handle. So, this is getting processed by the built-in template that matches child elements. It's *this* template that gets the parameter passed to it, but does nothing with it. As an education example, try adding the template: <xsl:template match="doc"> <xsl:param name="param">Unset</xsl:param> <doc param="{$param}"> <xsl:apply-templates/> </doc> </xsl:template> To you stylesheet, and you'll see that the resulting document comes out as: <root> <doc param="List"> <chap title="The beginning" cat="Unset"/> </doc> </root> showing that the parameter *does* get successfully passed to the "doc" template, but not recursively on down to the "chapter" template. You could do one of two things, either change your initial: <xsl:apply-templates> <xsl:with-param name="param">List</xsl:with-param> </xsl:apply-templates> To specifically select chapters... <xsl:apply-templates select="doc/chapter"> <xsl:with-param name="param">List</xsl:with-param> </xsl:apply-templates> or, add the "doc" template above that passes the parameter "on down" the line to the chapter template like this: <xsl:template match="doc"> <xsl:param name="param">Unset</xsl:param> <xsl:apply-templates> <xsl:with-param name="param" select="$param"/> </xsl:apply-templates> </xsl:template> ______________________________________________________________ Steve Muench, Lead XML Evangelist & Consulting Product Manager Business Components for Java & XSQL Servlet Development Teams Oracle Rep to the W3C XSL Working Group XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Using xsl:apply-templates with xsl:, Ron Ten-Hove | Thread | Re: Using xsl:apply-templates with , David Carlisle |
RE: How to specify parameters in th, Ciot, Thierry | Date | Re: XSL and entities, Eric van der Vlist |
Month |