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

Re: generate full xpath name to an attribute? (it work

Subject: Re: generate full xpath name to an attribute? (it works! - thank you)
From: Ray Tayek <rtayek@xxxxxxxxx>
Date: Fri, 04 Apr 2003 02:12:28 -0800
ray tayek
At 09:39 AM 4/4/03 +0100, you wrote:
yes, i got the following to work:

         <xsl:template name="foo">
 ...
                         <xsl:text>@</xsl:text>
  ...

That's __still__ not right: you need /@ not @

yes, i added that so:


<xsl:template name="getPath">
<xsl:for-each select="ancestor-or-self::*">
<xsl:text>/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:if test="name() = 'Node'">
<xsl:variable name="thisPosition" select="count(preceding-sibling::*)"/>
<xsl:value-of select="concat('[', $thisPosition + 1, ']')"/>
</xsl:if>
<xsl:if test="name() = 'Connection'">
<xsl:variable name="thisPosition" select="count(preceding-sibling::*)"/>
<xsl:value-of select="concat('[', $thisPosition + 1, ']')"/>
</xsl:if>
</xsl:for-each>
<xsl:text>/@</xsl:text>
<xsl:value-of select="name()"/>
</xsl:template>


and using it like:

<xsl:template match="Point">
<td>
<xsl:for-each select="@*">
<xsl:variable name="path">
<xsl:call-template name="getPath"/> <!-- call the getpath function and save the result -->
</xsl:variable>
<xsl:element name="label">
<xsl:attribute name="for"><xsl:value-of select="name()"/></xsl:attribute>
<xsl:value-of select="name()"/>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="size">4</xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="name()"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="$path"/></xsl:attribute> <!-- use the result here! -->
<xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
</xsl:element>
<xsl:value-of select="$path"/>
</xsl:for-each>
</td>
</xsl:template>


works like a charm :)

thanks for all your assistance people!

---
ray tayek http://tayek.com/ actively seeking mentoring or telecommuting work
vice chair orange county java users group http://www.ocjug.org/
hate spam? http://samspade.org/ssw/


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.