xsl-list
[Top] [All Lists]

[xsl] position of the parents node -> XSLT1.1

2006-05-09 05:13:09
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>