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

Re: ordering and iteration problem

Subject: Re: ordering and iteration problem
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 01 May 2001 16:32:35 +0100
Re:  ordering and iteration problem
Mark:

At 06:44 PM 5/1/01, you wrote:
I'm curious why one typically initializes "random-nodes" from the
stylesheet document rather than the input document.  It seems to me
that the input document is guaranteed to have enough nodes, while the
XSLT transform document might not if the input document is big enough.

Instead of

<xsl:variable name="random-nodes" select="document('')//node()" />

I tried

<xsl:variable name="random-nodes" select="//node()" />

to get the set of all nodes from the input document.  This seems to
work for me.  I was wondering if there is any reason why this is not
what is typically done.

No reason. One could speculate about how this technique tends to be a 'pull' technique, and that in 'pull' applications stylesheets tend to be largish (XSLT verboseness) but source documents, smallish, whereas the reverse might be the case in a 'push' application. But really, that'd be pushing it: maybe we're just showing off how we know how to use document('').


The only thing to be careful about is to make sure you have *enough* nodes, which is why this iteration workaround (which of course fails without any warning if your node set falls short) is kind of scuzzy compared to a proper solution using recursion.

But as long as you're going to do it, declaring a global variable like yours (I'm assuming you're declaring $random-nodes at the top level, since you don't want to call '//node()' every time you hit a template) is a fine way to go; using a $plenty-of-nodes variable that's already been declared for some other purpose is even better.

(Jeni, what's your perspective?)

Regards,
Wendell

======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.