Selecting nodes between empty elements

Here should go questions about transforming XML with XSLT and FOP.
irmng
Posts: 2
Joined: Fri Jun 05, 2009 11:36 am

Selecting nodes between empty elements

Post by irmng »

Hello everyone,

Could anyone help with this little puzzle which I haven't been about to solve.

I've got an XML file with something like this in it:-

<p>
<pb/>
</p>
<p>3 Prayers.</p>
<p>The Senate.</p>
<p>Speaker. 4</p>
<p/>
<p>
<pb/>
</p>

The <pb/> elements are empty but mark page breaks. What I would like to do is work out the word count for each page - ie for the <p> elements between the two <pb/> elements. I haven't been able to work this out - can anyone point me in the right direction?

Many thanks!
Richard
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: Selecting nodes between empty elements

Post by Dan »

You can find a word count stylesheet here:
http://www.biglist.com/lists/xsl-list/a ... 00351.html
You can use it as a starting point.

You should group first the elements you are interested in counting the words for, using xsl:for-each-group, then apply the counting template over each group.

Examples:
http://www.w3.org/TR/xslt20/#grouping-examples
http://www.zvon.org/xxl/XSL-Ref/Tutoria ... tents.html
irmng
Posts: 2
Joined: Fri Jun 05, 2009 11:36 am

Re: Selecting nodes between empty elements

Post by irmng »

Excellent! That should do the trick. Many thanks.

Richard
Post Reply