Subject: RE: [xsl] round-robin template call From: Emmanuel Bégué <eb@xxxxxxxxxx> Date: Sun, 5 Apr 2009 19:37:39 +0200 |
Hello, I'm not sure I understand your requirements, but the context is available to named templates, so you may use information from the source file at the point where the named template is called, as an input for a test in the named template. For example, this XSLT: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <root> <xsl:apply-templates/> </root> </xsl:template> <xsl:template match="*"> <element name="{name()}"> <xsl:call-template name="test"/> <xsl:apply-templates/> </element> </xsl:template> <xsl:template name="test"> <xsl:choose> <!-- is there an element named 'a' as a direct child of the context node? --> <xsl:when test="a"> <case no="1"/> </xsl:when> <xsl:when test="b"> <case no="2"/> </xsl:when> <xsl:otherwise> <case no="other"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> applied to this source document: <root> <a> <b> <c> <a/> </c> </b> </a> </root> outputs this: <root> <element name="root"> <case no="1"/> <element name="a"> <case no="2"/> <element name="b"> <case no="other"/> <element name="c"> <case no="1"/> <element name="a"> <case no="other"/> </element> </element> </element> </element> </element> </root> Also see this for example: www.zvon.org/xxl/XSL-Ref/Tutorials/Named-Templates/nt2.html HTH Regards, EB > -----Original Message----- > From: Aragon Gouveia [mailto:aragon@xxxxxxxxxxx] > Sent: Sunday, April 05, 2009 7:10 PM > > I want to avoid passing parameters during the template call.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] round-robin template call, G. Ken Holman | Thread | Re: [xsl] round-robin template call, Mukul Gandhi |
Re: [xsl] round-robin template call, Mukul Gandhi | Date | Re: [xsl] parametrized return value, himanshu padmanabhi |
Month |