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

Re: Manipulating elements depending on the existence o

Subject: Re: Manipulating elements depending on the existence of sub-elements
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 11 Mar 2008 16:26:45 -0400
Re:  Manipulating elements depending on the existence o
Adil,

At 03:39 PM 3/11/2008, you wrote:
My only remaining issue is that the position() count is inaccurate for
the problematic "Item" (as it is contained in 2 "Item" elements rather
than one, so the count will be 1, 2, 3, 1, 2, 3 instead of 1, 2, 3, 4,
5, 6) but I'm guessing there isn't much I can do about this in XSL?
(since position()'s value *is* technically accurate, and I'm actually
trying to manipulate it)

Two things about this. Many beginners guess incorrectly that position() refers to the position of a node in the source tree. It doesn't: it only refers to the position of the current node (that is, the node being processed) within the current node list (the list of nodes being processed), wherever these may happen to be in the source and however they are being sorted.


This often corresponds to the position of a node in the tree, since the order of nodes within node lists frequently corresponds to document order. But not necessarily. As a consequence, position() is probably less useful for numbering things than is often supposed. Incorrect assumptions about what it does lead inevitably to bugs.

More generally, XSLT offers quite comprehensive methods for numbering things, especially given the xsl:number instruction, which is highly configurable. Given a clear specification of what you want to count, it's usually possible to count it.

If nothing can be done about it in XSL I can probably add a count in
.net prior to bulk loading.

Something can almost certainly be done about it in XSL; the question is whether it's worth the trouble compared to alternatives.


It might well be easy: if you presented a specification, the list would probably oblige with a way to do what you're asking.

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
======================================================================

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-2011 All Rights Reserved.