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

testing for numbers of nodes

Subject: testing for numbers of nodes
From: Charles Muller <cmuller-lst@xxxxxxxxxxxxxxx>
Date: Sat, 10 May 2008 19:59:03 +0900
 testing for numbers of nodes
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>

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.