Altova Mailing List Archives


[xsl] testing for numbers of nodes

From: Charles Muller <cmuller-lst@--------------->
To:
Date: 5/10/2008 10:59:00 AM
Dear Friends,



I'm trying my hand at XSLT for the first time in few years, trying to 
get a dictionary ready for print-out. I've got just about everything 
working, but I'm having trouble with one point. In the explanatory 
section of each entry, I have this structure:



<headword>The Term</headword>
<sense_area>
<sense>Explanation of meaning #1</sense>
<sense>Explanation of meaning #2</sense>
<sense>Explanation of meaning #3</sense>
</sense_area>

I want this to be in inline paragraph format, not list format, so I have 
used <xsl:number>, so that I can output something like this:



The Term: (I) Explanation of meaning 1. (II) Explanation of meaning 2. 
(III) Explanation of meaning 3.



I did this with:



      <xsl:for-each select="sense_area"><xsl:text> </xsl:text>
       <xsl:for-each select="sense">
       (<xsl:number format="I"/>)<xsl:apply-templates />
       </xsl:for-each>
      </xsl:for-each>

I'm OK up to here with the XSL, but the only problem is, if there is 
only one <sense> I don't want any numbers at all. So I assume that I 
need to do a test, which will turn off numbering if the amount of 
<sense> is not greater than one. So I've tried a few things using 
count(), without success. I've been playing with this for a while now, 
and can't make anything work. The present code I've got (not working) is:



      <xsl:for-each select="sense_area"><xsl:text> </xsl:text>

       <xsl:for-each select="sense">

        <xsl:if test="count(sense) &gt; I">(<xsl:number 
format="I"/>)</xsl:if> <xsl:apply-templates />

       </xsl:for-each>

      </xsl:for-each>



Can someone perhaps see what is wrong with this?



Thank you very much.



Chuck
--

---------------------------
Charles Muller

Toyo Gakuen University
Faculty of Humanities
1660 Hiregasaki, Nagareyama-shi
Chiba 270-0161 JAPAN
Mobile Phone: 090-9310-1787

Web Site: Resources for East Asian Language and Thought
http://www.acmuller.net

<acmuller[at]jj.em-net.ne.jp>

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.