Subject: Re: [xsl] counting nodes question From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Sun, 26 Nov 2006 14:08:42 +0100 |
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 greater1.
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) > 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] counting nodes question, Philip Vallone | Thread | RE: [xsl] counting nodes question, Philip Vallone |
Re: [xsl] xalan:nodeset, J.Pietschmann | Date | Re: [xsl] xalan:nodeset, Joe Fawcett |
Month |