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

position() problem with // axis + parent numbering problem

Subject: position() problem with // axis + parent numbering problem
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Tue, 18 Apr 2000 12:31:43 +1200
position() problem with // axis + parent numbering problem
Hi - two questions.

One
---

The position() function isn't returning what I was expecting when combined
with the // axis, and I haven't been able to find what I'm after in the
spec - can someone point out why this isn't working?

I expected the following to produce mutually exclusive sets whose union
includes all <text> nodes in the input document.

<xsl:apply-templates select="//text[1]" />
<xsl:apply-templates select="//text[not(position() = 1)]" />

It appears this is not the case - I've tested this in Saxon and Xalan, so
I'm confident the implementors have it right - I just don't know why.
"[position() = 1]" returns all nodes that are the first children of their
parents, while [1] returns the first node in the context list. I thought
that [1] was the abbreviation for the other. Can someone tell me where
it says otherwise?

How should I put the predicate in the second expression to be the opoosite
of that in the first - ie, all nodes other than the first in the context
list

Two
---

I was trying to get the number of the parent node of the current node taken
across the entire document, and I can't see an easy way to do it. The parent
may not be the real parent, but may be several steps up the tree, although I
do know the element is of type <grouping_element>. The following seems to
work, but is there any way to condense this into a single <xsl:number> element?

      <xsl:variable name="parent_number">
        <xsl:for-each select="ancestor::grouping_element[1]">
          <xsl:number count="grouping_element" level="any" />
        </xsl:for-each>
      </xsl:variable>

Thanks in advance.

-- 
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand


 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.