Re: [xsl] apply template within call template

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

----- Original Message -----
From: "Maneshi Tuli" <maneshi.tuli@xxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, January 10, 2002 6:15 PM
Subject: [xsl] 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