RE: ordering and iteration problem
> > I was just wondering why this "design > > pattern" was typically described using "document('')//node()" when > > "//node()" seemed to be more correct. > > Because in a typical scenario, the stylesheet author knows how many nodes > there are in the stylesheet, but has no idea how many there will be in the > source document. > > Mike Kay > Software AG It is also worth noting that a huge number of additional nodes can be easily added to the stylesheet. An example can be found at http://www.vbxml.com/snippetcentral/main.asp?view=viewsnippet&lang=xsl&id=v20010324001431 In case the stylesheet is like this: <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:Shakespeare="Shakespeare"> <Shakespeare:Hamlet> <!-- Hamlet goes here --> </Shakespeare:Hamlet> <!-- the rest of the stylesheet --> </xsl:stylesheet> where the included text is the xml version of "Hamlet" from Jon Bosak's site http://www.stoa.org/bard/ In this case if the st variable holds the stylesheet: <xsl:variable name="st" select="document('')"/> then the following expression: count($st//node() | $st//@* | $st//namespace::*) evaluates to 32032 While such a technique is definitely ugly it is still the only means to prevent imperfect XSLT processors from crashing under deep recursive processing. Dimitre Novatchev. __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ 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