Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2005, 02:55 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with XSL

i have following XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<tree>
<tree-node id="123" parent="" expand="true">
<item-data>
<label>2</label>
</item-data>
</tree-node>
<tree-node id="565" parent="123" expand="true">
<item-data>
<label>1</label>
</item-data>
</tree-node>
</tree>

In my XSLT i have a following entry

<xsl:template match="item-data/*">
  <span class="nodeName"><a href=""><xsl:value-of select="label"/></a>
  </span>
</xsl:template>

I would like to know how do i extract the attribute "id" value of tree-node and supply that in the "a href". it should be somethign like this.

  <span class="nodeName"><a href="123">2</a></span>
  <span class="nodeName"><a href="565">1</a></span>

Please provide pointers.

Thanks,
Sandeep
 
Old May 13th, 2005, 03:57 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<a href="{../@id}">

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 13th, 2005, 04:22 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. I tried using this way as you suggested what i get is blank value instead of proper attribute value.

    <xsl:template match="item-data/*">

        <span class="nodeName">
           <a href="table.jsp?a={../@id}" target="mainFrame"> <xsl:value-of select="label"/></a>
        </span>
    </xsl:template>

Please suggest.

 
Old May 13th, 2005, 04:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sorry, I missed that your context node was not the item-data but the child of item-data, so you need to go up to the grandparent - ../../@id

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 13th, 2005, 04:28 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

And of course select="label" isn't going to select anything, because you're already on the <label> element.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 13th, 2005, 04:31 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot. I too tried the same meanwhile :). It works now.






Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL for-each/when problem Grofit XSLT 11 March 27th, 2008 10:26 AM
xsl:if problem lscjtw XSLT 2 July 26th, 2007 11:29 AM
XSL problem cheez XSLT 1 September 14th, 2006 01:20 AM
Help with xsl:when problem sundar_revathi XSLT 2 November 9th, 2004 07:39 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.