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

RE: counting nodes question

Subject: RE: counting nodes question
From: "Philip Vallone" <philip.vallone@xxxxxxxxxxx>
Date: Sun, 26 Nov 2006 09:02:14 -0500
RE:  counting nodes question
J,

Thanks for the help. I apologize for not explaining better, however you
nailed it. Your suggestion work perfect. My mistake was not the counting,
but rather using "&gt;" instead of ">" - Basic XSLT 101. 

As for why I am using position:absolute; well I had to figure out how to get
the following desired results in HTML:

NOTE: TEXT xxxxxxxxx
	Xxxxxxxxxxxxxx
	xxxxxxxxxxTEXT

CAUTION: TEXTXXXXXXX
	   XXXXXXXXXXX
         xXXXXXXTEXT

It works as advertised, however if you know of a better way, let me know. My
colleague and I messed with that for two days. Once we figured out the HTML
output, XSL-FO was another story. Both of which are working.

Any thoughts or suggestion?

Regards

Phil


-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@xxxxxxxx] 
Sent: Sunday, November 26, 2006 8:09 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  counting nodes question

Philip Vallone wrote:
> I have a "NOTE" element that lets the author add notes and automatically
> counts the Note number. I am trying to figure out when there is only one
> note element, it doesn't use the <xsl:number>. I tried xsl:if, xsl:choose
> and xsl:when. I keep getting hung up on determining if the count is
greater
>> 1.

I don't completely understand your requirement, so I assume
you want to print a number only if there are two or more NOTE
elements. Using the count() function shoudl do the trick, for
example the following (changed some stuff to match the source
XML you provided):

  <xsl:template match="Para">
    <xsl:for-each select="NOTE">
      <xsl:text>NOTE: </xsl:text>
      <xsl:if test="count(../NOTE) &gt; 1">
        <xsl:number level="single" format="1" count="NOTE"/>
        <xsl:text> </xsl:text>
      </xsl:if>
      <span style="width:100%; font-weight:bold; padding-left:70px; ">
       <xsl:apply-templates/>
      </span>
      <br/>
    </xsl:for-each>
  </xsl:template>

BTW both your resulting HTML and CSS are somewhat odd, for example the
position:absolute" for the prefix, and using HTML spans followed by a br
instead of a proper paragraph.

J.Pietschmann

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.