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

RE: round-robin template call

Subject: RE: round-robin template call
From: Emmanuel Bégué <eb@xxxxxxxxxx>
Date: Sun, 5 Apr 2009 19:37:39 +0200
RE:  round-robin template call
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

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.