RE: [xsl] XPath question

Subject: RE: [xsl] XPath question
From: "Andy J. Cupp" <acupp@xxxxxxxxxxxxxxx>
Date: Mon, 3 Feb 2003 16:44:59 -0600
	I don't think you can combine 2 axes (such as parent and preceding-sibling) in just one xpath statement.  I think you will need 2 steps.  First, make the parent the context node, and then refer to the parent's preceding-sibling, like this:

<xsl:for-each select="parent::node()">
	<!--Inside this for-each, the parent is now the context node-->
	<xsl:variable name="elementCount" select="count(preceding-sibling::node())"/>

Hope this helps,

-----Original Message-----
From: cknell@xxxxxxxxxx [mailto:cknell@xxxxxxxxxx]
Sent: Monday, February 03, 2003 4:22 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] XPath question

Every time I think I have a good grasp on XPath, it slips between my fingers. Consider the following XML:

  <item title="Vegetables">
    <item title="tubers">
      <item title="potatoes">
  <item title="Fruits">
    <item title="Apples>
      <item>Granny Smith</item>

I have an HTML application for which I must flatten out the hierachy of this XML document, yet still maintain a link to the parent element for each child element. To this end I have decided to number each element according to its position in the hierarachy and use a "dot-delimitted" format for each element's id (i.01.03.11). I have struggled in vain today to come up with an XPath expression which would tell me how many elements are on the preceding-sibling axis of the parent of a given node. Can anyone straighten me out on this?

Charles Knell
cknell@xxxxxxxxxx - email

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread