[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: apply template within call 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|