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

[XSL] Counting Child Nodes?

Subject: [XSL] Counting Child Nodes?
From: Alice Ju-Hsuan Wei <ajwei@xxxxxxxxxxx>
Date: Fri, 19 Oct 2007 10:11:50 -0400
 [XSL] Counting Child Nodes?
Hi,

I am making attempts to make the output of the transformed XML to be able to display different images based on the nodes and string length. Below is the XSLT:

XSLT:


<xsl:template match="book"> <xsl:variable name="rendition"> <xsl:value-of select="./@rendition"/> </xsl:variable> <div> <p> <xsl:choose>

<xsl:when test="$rendition!=''">
<div>
<xsl:attribute name="class">
<xsl:value-of select="$rendition"/>
</xsl:attribute>
<xsl:if test="string-length(child::text())&lt;'25'">
<xsl:attribute name="style"> background-image:url('<xsl:value-of
select="./@rendition"/>.png') </xsl:attribute>
</xsl:if>
<xsl:if test="string-length('25 ' &lt; child::text() &lt; '50')">
<xsl:attribute name="style"> background-image:url('<xsl:value-of
select="./@rendition"/>_med.png') </xsl:attribute>
</xsl:if>
<xsl:if test="count(child::p) &gt; 1">
<xsl:attribute name="style"> background-image:url('<xsl:value-of
select="./@rendition"/>_large.png') </xsl:attribute>
</xsl:if>


                           <p>
                               <xsl:call-template name="rend"/>
                               <xsl:apply-templates/>
                           </p>
                       </div>
                   </xsl:when>
                   <xsl:otherwise>
                       <!--Don't display anything-->
                   </xsl:otherwise>
               </xsl:choose>
           </p>
       </div>
   </xsl:template>

XML:

<book topic="Technology" 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>


I want to use the code displayed above (XML) to display the file name with the name of xslt_large, and now in the HTML source it does not display that, even though the code above has two <p> tags. Can anyone please help me out?

Anything is appreciated.

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