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

Re: position()

Subject: Re: position()
From: Dan Morrison <dman@xxxxxxxx>
Date: Sun, 16 Apr 2000 21:11:11 +1200
Re: position()
Dave Pawson wrote:
> 
> I'm using position() function in two places.
> 
> Once in the root template in a for-each loop.
> Once in a template
> 
> The 'number' I'm getting back is different in each case.
> In the former case I get 1 to 7,
> in the latter case I get 2 6 10 14 18 22 26
> 

That's fascinating.

Yes, I can see how that would happen :-) It's funny.

For-each works on an ordered set, but templates get applied willy-nilly.
Generally in some sort of tree traversal, but how that happens is not
restricted. A parser applying-templates is likely to encounter many
nodes in the source document and deal with them as they occur. 

This means that if any position count at all is kept, it may hold the
count of _total_templates_applied_so_far_ and not
_nodes_of_a_certain_type_processed_ 
Your results in the second case give a glimpse into what the parser was
doing in between the last two 'sections'.

Unfortunately, I can't see a useful way of using position() in this way.
I'm sort of surprised you'd get any result at all. 
It's all about context. You're asking for a postion in an unsorted,
non-homogenous list.

I'd guess you have to rework your structure to only use for-each. Try
making more advanced select queries (such as within the apply-templates
call that starts this off) and look at call-template to get things done.

This is such an odd quirk It ought to be put in a FAQ somewhere. It
seems legal to me, but a very odd side-effect. Which Parser was it?

Note, This is just my analysis of a possible cause. The truth may be
even stranger.

.dan.

:=====================:====================:
: Dan Morrison        : The Web Limited    :
:  http://here.is/dan :  http://web.co.nz  :
:  dman@xxxxxxxx      :  danm@xxxxxxxxx    :
:  04 384 1472        :  04 495 8250       :
:  025 207 1140       :                    :
:.....................:....................:
: If ignorance is bliss, why aren't more people happy?
:.........................................:


 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.