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

Re: Omnimark vs. XSL (Saxon) Challenge

Subject: Re: Omnimark vs. XSL (Saxon) Challenge
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 17 Mar 2004 16:57:17 -0500
xsl for each x times
At 05:00 AM 3/17/2004, Michael Müller-Hillebrand wrote:
I use this set of nodes just for the sake of looping a certain number of times. In Jeni Tennison's book "XSLT and XPath On The Edge" it is called "The Piez Method". You are right, I don't need two variables (just an old habit...).

Will I ever live it down? But yes ... and Mike knows the provenance of the technique. :->


Jeni called it that because she was tickled (she said) by how counter-intuitively obvious it was as a way of avoiding more cumbersome methods, and wanted to give me credit for its small measure of tricky (if not diabolical) inventiveness (my words not hers: her word might have been "sweet"). But everyone who uses it (including me, when I do) should really be ashamed of themselves. At best, it's a shortcut and should be avoided except in very constrained circumstances. Such as: you don't need to iterate many times in any case, and a node set guaranteed to be large enough is readily available. One rule of thumb: if you need to go parse something to get enough nodes, it's not worth it. Another: don't ever look at set X and suppose that you need to iterate count(X) times -- just iterate over the set X that you would have counted. That is, it's silly to do this:

<xsl:for-each select="$bignodeset[position() &lt;= count($nodeset)">
  ...
</xsl:for-each>

when you could simply do

<xsl:for-each select="$nodeset">
  ...
</xsl:for-each>

Believe it or not, I've seen it done the hard way.

All in all, I can think of other ways I'd rather go down in history. If only I'd first figured out positional grouping using keys!

Cheers,
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.