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

Re: xsl:number query

Subject: Re: xsl:number query
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 08 Mar 2010 16:55:39 -0500
Re:  xsl:number query
At 2010-03-08 16:48 -0500, Terry Ofner wrote:
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>

You are using count= incorrectly. It is a match pattern. You indicate those items that participate in the counting:


  count="p[@class='bodytext-directionsrevise'] |
         p[@class='bodytext-directionsrule1']"

... or if you are using XSLT 2:

count="p[@class=('bodytext-directionsrevise','bodytext-directionsrule1')]"

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

I'm assuming you mean "count the p elements that have the specified attributes".


BTW, it happens that my XSLT Video lecture on <xsl:number> is the exposed example lecture on YouTube:

http://www.youtube.com/watch?v=PrNjJCh7Ppg&amp;fmt=18

The entire video is 24 hours long. This lecture is about 25 minutes long. The video is sold with a copy of our PDF book (with perpetual updates), and a copy of the hands-on exercises that are walked through by me in the lectures. The overview of the entire video is here:

http://www.youtube.com/watch?v=VTiodiij6gE&amp;fmt=18

I hope this helps.

. . . . . . . . . . Ken

--
XSLT/XQuery training:      after http://XMLPrague.cz 2010-03-15/19
XSLT/XQuery training:         San Carlos, California 2010-04-26/30
Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03
XSLT/XQuery training:                 Ottawa, Canada 2010-05-10/14
XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.