[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] xsl:number query


Subject: [xsl] xsl:number query
From: Terry Ofner <tdofner@xxxxxxxxx>
Date: Mon, 8 Mar 2010 16:48:54 -0500

I am having trouble getting an accurate count using xsl:number.

Here is a snippet of my input document:

<div class="story">
<p class="test">A</p>
<p class="head-testname">READING COMPREHENSION</p>
<p class="bodytext-directionsrevise">Directions: Read the selection. Then answer the questions that follow.</p>
<p class="head-selectiontitle">Jason and the Golden Fleece</p>
...
<p class="bodytext-directionsrule1">Directions: Read the selection. Then answer the questions that follow.</p>
<p class="head-selectiontitle">Freight</p>
<p class="bodytext-selectionintro">This is an ... Underground Railroad.</p>
<p class="bodytext-subhead">Cast of Characters</p>
</div>


I am attempting to include in the same sequence both <p class="bodytext-directionsrevise"> and <p class="bodytext- directionsrule1">.

Here is the relevant template from my 2.0 stylesheet:

<xsl:template match="p[@class='bodytext-directionsrevise'] | p[@class='bodytext-directionsrule1']">
<narrative>
<xsl:attribute name="name"><xsl:number select="." count="*" from="story"></xsl:number></xsl:attribute>
<xsl:apply-templates/>
</narrative>
</xsl:template>



Apparently, I am counting <p> elements, as indicated by this result snippet:


<story>
<test>A</test>
<head-testname>READING COMPREHENSION</head-testname>
<narrative name="3">Directions: Read the selection. Then answer the questions that follow.</narrative>
...
<narrative name="82">Directions: Read the selection. Then answer the questions that follow.</narrative>


How can I tell xsl:number to count the specified attributes?

Terry


Current Thread