xsl-list
[Top] [All Lists]

RE: [xsl]Counting Child Nodes?

2007-10-21 07:40:31
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>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>