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

line numbering

Subject: line numbering
From: James Cummings <James.Cummings@xxxxxxxxxxxxxx>
Date: Thu, 5 Aug 2004 14:17:21 +0100 (BST)
james cummings oxford
Hi there,

I have some poems marked up something like:

<body>
<div type="poem">
<lg type="stanza">
<l>This is a line of verse</l>
<l>This is a line of verse</l>
<l>This is a line of verse</l>
<l>This is a line of verse</l>
</lg>
<lg type="stanza">
<l>This is a line of verse</l>
<l>This is a line of verse</l>
<l>This is a line of verse</l>
<l>This is a line of verse</l>
</lg>
<p>This is something not counted as a line</p>
<lg type="stanza">
<l>This is a line of verse</l>
<l>This is a line of verse</l>
<l>This is a line of verse</l>
<l>This is a line of verse</l>
</lg>
</div>
<!-- and multiple poem div's like this here... -->
</body>

What I want to end up with is for each line to be 
given an @id in the html output like:
<span id="poem3line10">This is a line of verse <span
class="number">10</span></span>

<xsl:template match="l">
<xsl:variable name="linenumber" select="count(preceding-sibling::l)+1"/>
<span class="line" id="line{$linenumber}"><xsl:apply-templates /></span>
</xsl:template>

But now I need to account for two factors:
a) that the linenumbering needs to take account of 
the existence of the line-groups (lg) and that it 
should only count back within it's own <div> ancestor.
b) that I want to number the lines every 5 lines. 

Is position() a better way to do this than counting the 
preceding-sibilings?

Any (XSLT1 preferred, but XSLT2 acceptable) suggestions/solutions?

-James
---
Dr James Cummings, Oxford Text Archive, University of Oxford
James dot Cummings at oucs dot ox dot ac dot uk 

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.