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

Re: apply template within call template

Subject: Re: apply template within call template
From: "cutlass" <cutlass@xxxxxxxxxxx>
Date: Thu, 10 Jan 2002 18:27:41 -0000
xsl template within template
Hello Maneshi,

----- Original Message -----
From: "Maneshi Tuli" <maneshi.tuli@xxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, January 10, 2002 6:15 PM
Subject:  apply template within call template


>
> Hi
> can i use apply template within call template ,
> or call template within call template.

here is an example XSL file that calls a named template then applies
templates later

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

  <xsl:call-template name="test"/>


</xsl:template>

<xsl:template name="test">
<xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

i think that u are saying that templates that call themselves infinately are
wrong, as the one listed below ( which will not work ! though some
processors will automagically iterate once  )

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="test"/>
</xsl:template>
<xsl:template name="test">
 <xsl:call-template name="test"/>
</xsl:template>

</xsl:stylesheet>

sometimes people confuse recursion with circular references, the above is a
circular reference.

for example x=x+1 could be thought of as recursive, but in actuality it goes
on 'forever'.... which means that the function never bottoms out...
recursion always bottoms out ( c'mon u GEB readers.... ).

in some logic circles ( ah the keyword ) the x=x+1 is a circular reference,
whereas infinity is defined as a symmetrical circular existential being from
the planet grok.

to answer your question, yes u can use apply-templates ( if u use the select
condition be aware of what is the current node context ), and if u are using
a call-template make sure its not a runaway train.

cheers, jim fuller


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.