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

Re: XSL and infinite loops

Subject: Re: XSL and infinite loops
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 Aug 2004 18:07:28 +0100
for loop in xslt
> Thanks! I'm having trouble picturing a scenario in which for-each --
> by itself -- could cause an infinite loop under XSLT 1.0/XPath
> 1.0. Did you have a specific case in mind? 
> 

Not really, in fact for some definitions of "by itself" then it provably
doesn't loop as all node sets are finite and it just iterates over that
finite set.

I think what I had in mind is that it can be used to avoid certain
simple minded restrictions that you may put on apply-templates to avoud
looping.

apply-templates will only directly cause looping if it is used with a
reverse axis (including self:: axis)
apply-templates select="."


so if you are trying to avoid DOS attacks you could try to restrict the
select attribute so it only uses Xpaths that select descendent children

but then a for-each with select="/" would get you back up the tree with a
potential for looping again.

in a stylesheet that just has:

<xsl:stylesheet...>

<xsl:template match="*">
<xsl:for-each select="/">
  <xsl:apply-templates/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

you will loop but whether you say it is the apply-templates or the
for-each that causes the looping is a matter of taste, if you take
either of them out it doesn't loop any more.



David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.