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

position of the parents node -> XSLT1.1

Subject: position of the parents node -> XSLT1.1
From: news@xxxxxxxxxxx
Date: Tue, 9 May 2006 14:12:46 +0200
parents node
Hello List,

I'm perfomring an XML to XML transformation. Therefore I m using a template
by Michael Kay's book "XSLT 2nd Edition" page 194.

<xsl:template match="@*|node()" mode="copy">
  <xsl:copy>
    <xsl:apply-templates select="@*" mode="copy"/>
    <xsl:apply-templates mode="copy"/>
  </xsl:copy>
</xsl:template>

So far everythings works pretty fine.
But since I'm doing a lille bit more than just copying nodes I need to know
the position if the parents node of the current node in its parent node.

Xpath's like this "parent::position()" dont'nt work. 

The only way I can think of a solution is to pass the position by a
parameter.

<xsl:template match="@*|node()" mode="copy">
  <xsl:param name="parentsPos"/>
  <xsl:copy>
    <xsl:apply-templates select="@*" mode="copy"/>
    <xsl:apply-templates mode="copy">
      <xsl:with-param name="parentsPos" select="position()"/>
    </xsl:apply-template>
  </xsl:copy>
</xsl:template>

But this does'nt look that smart to me. The only parants position I ever
going to know by this is the position of a direct parent of a node.

Is there a better way?

thanks & with best regards,
Jan

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.