[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl]Counting Child Nodes?


Subject: RE: [xsl]Counting Child Nodes?
From: Alice Ju-Hsuan Wei <ajwei@xxxxxxxxxxx>
Date: Sun, 21 Oct 2007 10:39:55 -0400

Hi,

Thanks to all of you who helped pitch in to make this code work. Now, this code is basically working, but I don't know why it generates the background image as either _med.png or _large.png, while those with string length smaller than 25 characters still generate the second <xsl:if> statement, by generating the _med.png just the same as the second condition.

Is this another boolean problem I am having? Any suggestions?

Thanks in advance.

Alice

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>

XSLT:

<xsl:choose>

<xsl:when test="$rendition!=''">
<div>
<xsl:attribute name="class">
<xsl:value-of select="$rendition"/>
</xsl:attribute>
<xsl:if test="string-length(child::p)&lt;'25'">
<xsl:attribute name="style"> background-image:url('<xsl:value-of
select="./@rendition"/>.png') </xsl:attribute>
</xsl:if>
<xsl:if test="string-length(child::p)&lt;'75'">
<xsl:if test="string-length(child::p)&gt;'25'">
<xsl:attribute name="style"> background-image:url('<xsl:value-of
select="./@rendition"/>_med.png') </xsl:attribute>
</xsl:if>
</xsl:if>
<xsl:if
test="(count(child::p) &gt; '1') or (string-length(p) &gt; '100') ">
<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>
                       <span>
                           <xsl:call-template name="rend"/>
                           <xsl:apply-templates/>
                       </span>
                   </xsl:otherwise>
               </xsl:choose>


Current Thread
Keywords