[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Re: Getting the XPath of a node
Subject: [xsl] Re: Getting the XPath of a node From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Wed, 4 Sep 2002 03:14:49 -0700 (PDT) |
--- Mike Brown <mike at skew dot org> wrote: > Dennis wrote: > > Hi All, > > > > Is there any way to get the XPath of a particular > > element and attribute in match template??? > > > > Say if I have following XML: > > <Person id="12345"> > > <Name>Dennis</Name> > > <Company>Netscape</Company> > > <Address>Mountain View</address> > > <Email>dennis@xxxxxxxxxxxx</Email> > > </Person> > > > > ----The XSL to print XPath--- > > <xsl:template match="Company"> > > //Print the XPath of Company as /Person/Company > > </xsl:template> > > More templates corresponding to each element. > > > > How do I do this...any thoughts??? > > <xsl:for-each select="ancestor::*"> > <xsl:value-of select="concat('/',name())"/> > </xsl:for-each> > <xsl:value-of select="concat('/',name())"/> > > If the current node is an attribute, change that last '/' to '/@' This will produce an XPath expression, which (while covering the node) is not unique and probably returns some other nodes in addition to the current node. An XPath expression, which evaluates to a single node, must include predicates showing the positions of the elements forming the path. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL __________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Getting the XPath of a no, Dimitre Novatchev | Thread | Re: [xsl] Re: Getting the XPath of , Mike Brown |
[xsl] Re: Getting the XPath of a no, Dimitre Novatchev | Date | RE: [xsl] Getting the XPath of a no, Michael Kay |
Month |