xsl-list
[Top] [All Lists]

Re: Get Absolute XPath

2004-06-21 12:55:32
Hi All,
    I am able to achieve this using following code

  <xsl:template name="getAbsoluteXPath">
    <xsl:param name="id"/>
    <xsl:variable name="doc" select="document('c:\abc.xml')"/>
    <xsl:for-each select="$doc//*[(_at_)id = $id]">
      <xsl:for-each select="(ancestor-or-self::*)">/*[<xsl:value-of
select="1+count(preceding-sibling::*)"/>]</xsl:for-each>
    </xsl:for-each>
  </xsl:template>

But in this case I have to pass the ID of element. Is there any other better
way? Thanks.

Sameer.


----- Original Message ----- 
From: "Samooo" <samooo_vc(_at_)hotmail(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, June 21, 2004 12:22 PM
Subject: [xsl] Get Absolute XPath


I am able to get the absolute XPath of an element in rendered chunk of
XML.
The following template works fine.

  <xsl:template name="getAbsoluteXPath">
    <xsl:for-each select="ancestor-or-self::*">/*[<xsl:value-of
select="1+count(preceding-sibling::*)"/> </xsl:for-each>
  </xsl:template>

But now I want to get the absolute XPath of an element w.r.t. the whole
document. I have this document in say variable curDoc.
<xsl:variable name="curDoc" select="document('c:\abc.xml')"/>

But am not redering the whole document. I am rendering only a part of this
document. When I call this GetAbsoluteXPath template, I can get correct
XPath related to rendered chunk using above template code. But now I want
to
get teh XPath of an element inside the whole document. Please advice. I am
not able to explain this properly but I hope my question is clear. Thanks.

Sameer.

--+------------------------------------------------------------------
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>