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

[XSL] id() in Ancestor Nodes?

Subject: [XSL] id() in Ancestor Nodes?
From: Alice Ju-Hsuan Wei <ajwei@xxxxxxxxxxx>
Date: Wed, 3 Oct 2007 23:28:33 -0400
 [XSL] id() in Ancestor Nodes?

I am trying to use the id function in XSLT to extract the publication id information from the "attribute" and have the output display the name of the publisher itself as it is. The complete code is as follows:


<title>My Book Collection</title>
<date value="2007-10-03">2007</date>
<title level="monograph" type="main">Technical Book Collection</title>
<publication xml:id="apress">Apress</publication>
<publication xml:id="oreilly">O'Reilly</publication>
<publication xml:id="wrox">Wrox</publication>

               <collection type="xslt">
                   <book publish="wrox" date="2002">
                           <emph>Beginning XSLT</emph>
                          <emph>Essential XML Quick
                   <book publish="oreilly" date="2003">
                           <emph>.NET and XML</emph>

XSLT that is Working but Hard to Manage:

   <xsl:template match="book">
                   <xsl:call-template name="bookpublisher" />

<xsl:template name="bookpublisher">
   <span class="bookpublisher">
       Books Published by
           <xsl:when test="./@publish ='wrox'">Wrox</xsl:when>
           <xsl:when test="./@publish ='oreilly'">Oreilly</xsl:when>
       <xsl:attribute name="class">
           <xsl:value-of select="./@date" />

<xsl:template match="title">

<xsl:template match="emph">

There is no problem with the functionality of the code above, but when there are more id's to insert, I have to keep on adding the names to the "<xsl:when test=""> list. I tried using the id function:

<xsl:template name="bookpublisher">
       <xsl:variable name="name" select="id('@publish')"/>
           <span class="character">
           <xsl:value-of select="$name"/>

The output does not give me anything other than the other information in the <xsl:apply-templates> section. Can anyone please tell me what I have done wrong?

Thanks to those who can help.


Current Thread


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.
First Name
Last Name
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.