Advertisement

07.06.2008 at 08:07PM PDT, ID: 23542369 | Points: 500
[x]
Attachment Details

Getting the position of a node into a variable

Asked by azaram in Extensible Stylesheet Language Transformation (XSLT), Extensible Markup Language (XML)

Tags:

Hi Guys,

I need to determine the position of a node in a document so that I can read out it's sibilings that follow it.
More specifically, I'm implementing breadcrumbs (eg such as home --> Internet Plans--> Cable --> Monthly), but I need to start the breadcrumbs at a specific parent beign the root. I want to start the breadcrumbs at "Internet Plans".
So I'd like to determine the position of "Internet Plans" in /document/parent so I can then loop through the parents with a <xsl:for-each select="/document/parent/document[position() >= 1]">
However, I can't seem to get the position of the desired node in any way that I've tried.

for example, the following don't work:

<xsl:variable name="breadcrumb_start" select="/document/parent/document[name="Internet Plans"]/position()>

<xsl:variable name="breadcrumb_start" select="position(/document/parent/document[name="Internet Plans"])>

Thanks!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
<document>
  <parent>
    <document>
      <name>Home</name>
    </document>
    <document>
      <name>Internet Plans</name>
    </document>
    <document>
      <name>Wireless</name>
    </document>
  </parent>
</document>
[+][-]07.07.2008 at 01:47AM PDT, ID: 21943437

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628