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

RE: Fwd: complex XPATH test

Subject: RE: Fwd: complex XPATH test
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 17 Jul 2001 16:04:26 -0400
xpath test node
Nate,

Nice go at it.

At 02:58 PM 7/17/01, you wrote:
...
For starters, there has to be a better way of returning the position of a
node within a node set than what I used here (the for-each block).  Anyone
have any ideas?  I tried
<xsl:variable name="currPos"
select="$containing-block/descendant::node()[.=current()]/position()"/>
knowing it wouldn't work (from previous posts to the list, etc.) and I
wasn't disappointed.

The name of the function, position(), is somewhat misleading here, as it really has nothing to do with the position of a node in a node set, but rather of the context node within the current node list.


Closer would be (count(preceding-sibling::node()) + 1), if you only want to count nodes within a given level. Unfortunately, I think this problem is a bit tougher. What you want is more like (count($containing-block/descendent::node()[ ... ]) with a predicate that will filter out the ones before the current node. Still tricky to write, still slow.


  So the question I have is:  How do you return the
position of a node in a node set given the node and the node set, so that
the position can be used in a comparison or a variable?
Second, why is it that ".=$curr" tests the value of each against each other,
rather than a 'node id' or something?  Wouldn't it make sense for that to
actually check that the nodes are equivalent since if I wanted to check
their string values I could do "string(.)=string($curr)" but I can't do the
reverse. (ie. "node(.)=node($curr)" or something).  I'm I overlooking
something here?

A true node identity test would be very useful for this as for similar problems. That's just not the way = works in XSLT 1.0.


Solutions to similar problems have approached it by using, e.g., generate-id() to do node comparisons for identity. I can imagine creative uses of <xsl:number> that could be used to calculate priority etc., but still slow and klugey.

Where are the mathematicians?

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.