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

RE: Finding the path to a node

Subject: RE: Finding the path to a node
From: cknell@xxxxxxxxxx
Date: Fri, 11 May 2007 09:27:41 -0400
RE:  Finding the path to a node
  <xsl:template match="/">
    <xsl:apply-templates select="pages//page[@id='4']" />
  </xsl:template>

  <xsl:template match="page">
    <xsl:value-of select="ancestor::page[position() = last()]/@id" />
  </xsl:template>
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Kai Weber <weber@xxxxxxxxxxxxx>
Sent:     Fri, 11 May 2007 15:04:24 +0200
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   Finding the path to a node

Hello,

First I would like to thank this list. So far all my
problems with XSLT could be solved with your help. Thank you!

I have a new one: I have to find the "root"-node of a node
(not the document root, but a certain root).

Let's say I want to find the root-page-node for page-node with id 4.
Result should be page-node with id 1. A list of nodes 1,2,3 is
acceptable, too.

<pages>
<page id="1">
 <page id="2">
  <page id="3">
   <page id="4">
   </page>
  </page>
 </page>
</page>
<page id="5" />
<page id="6" />
</pages>

I tried with, but this is a loop and wrong...

<xsl:apply-templates select="//page[@id='4']/ancestor:node()" />

Regards, Kai

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.