[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL and infinite loops
> 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 ________________________________________________________________________
|
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
|