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

[XSL]Selecting Sibling from the Top of the Tree

Subject: [XSL]Selecting Sibling from the Top of the Tree
From: Alice Ju-Hsuan Wei <ajwei@xxxxxxxxxxx>
Date: Thu, 25 Oct 2007 23:40:55 -0400
 [XSL]Selecting Sibling from the Top of the Tree
Hi,

The XML I have below, I have been successfully using the id function to generate the output to print out "Technology" as the topic of the book. However, I would also like to print out the other one, "Resources" with the display of the result. Since I marked the id only as tech, how can I actually get it to print out the preceding or following sibling, without having to mark all the associated ids that go along with it?


XSLT:


   <xsl:template match="book">
               <div>
           <p>
               <span class="booklist">
        Topic:
                   <xsl:call-template name="print"/>
               </span>
           <xsl:apply-templates/>
</xsl:template>

<xsl:template name="print">

               <xsl:choose>
           <xsl:when test="count(ancestor::subject) &gt; 1 ">
               <xsl:if test="preceding-sibling::subject !=''">
                   [Also Used for:
           <xsl:value-of select="."/>]
               </xsl:if>
               <xsl:if test="following-sibling::subject !=''">
                   [Also Used for: <xsl:value-of select="."/>]
                </xsl:if>
               <xsl:value-of select="id(@topic)"/>
           </xsl:when>
           <xsl:otherwise>
               <xsl:apply-templates select="id(@topic)"/>
           </xsl:otherwise>
       </xsl:choose>
   </xsl:template>


XML:


[---------- The portion is in the header section 6 levels away from the <book>
<topicList>
<subject xml:id="tech">Technology</subject>
<subject xml:id="res">Resource</subject>
<subject xml:id="progr">Programming Language</subject>
</topicList>
--------------]

<body>
<book topic="tech" rendition="xslt" author="Tennison, Jeni" title="Beginning XSLT">


<p>New York: Apress, 2002.</p>
<p>The book serves as an introduction to XSLT based on the examples of a television program set. A resourceful book for those new to the technology.</p>
</book>
</body>


Desired Output:

<div><p><span class="booklist">Topic: Technology Resource Programming Language</span>
<p>Tenison, Jeni.</span> Beginning XSLT. New York: Apress, 2002. </p>
<p>The book serves as an introduction to XSLT based on the examples of a television program set. A resourceful book for those new to the technology.</p>


Thanks to those who can help out.

Alice

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-2011 All Rights Reserved.