Page 1 of 1

Selecting nodes between empty elements

Posted: Fri Jun 05, 2009 11:42 am
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

Re: Selecting nodes between empty elements

Posted: Wed Jun 10, 2009 10:37 am
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

Re: Selecting nodes between empty elements

Posted: Wed Jun 10, 2009 12:22 pm
by irmng
Excellent! That should do the trick. Many thanks.

Richard