Subject: Re: [xsl] grouping question From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 25 Nov 2010 23:11:05 +0000 |
Dear XSLT List,
I'm trying to create build a hierarchy from structure that has been encoded with milestone tags. The source xml looks like:
<block ref="282r1"> <hm281><pb folio="282r"/><rubric>blah blah bl<lb/>ah.</rubric></hm281> <hm280><pb folio="257r"/><rubric>blah blah blah</rubric></hm280> <hm282><pb folio="297v"/><rubric>blah blah blah</rubric> <lb/></hm282> </block> <block ref="282r2"> <hm281><rubric>blah blah blah.</rubric> <lb/></hm281> <hm280><rubric>blah<lb/> blah blah.</rubric> <lb/></hm280> <hm282><rubric>blah blah blah</rubric> <lb/></hm282> </block> <!-lots more blocks -->
This is an interlinear collation of three manuscripts, from which I need to generate separate output for each manuscript that restores the original pagination and lineation. Page breaks are encoded with empty<pb/> milestones that record the page number on a @folio attribute. Line breaks are encoded with empty<lb/> milestones; the line number is calculated by counting the number of lines from the most recent page break.
The strategy I've used--which almost works--is to group by<pb> and then process each of those groups by grouping by<lb>:
<xsl:for-each-group select="$root//*[name() eq $currentms]/node()" group-starting-with="pb"> <tr> <th colspan="2"> <xsl:value-of select="@folio"/> </th> </tr> <xsl:for-each-group select="current-group()" group-starting-with="lb"> <tr> <th> <xsl:value-of select="position()"/> </th> <td class="os"> <xsl:apply-templates select="current-group()"/> </td> </tr> </xsl:for-each-group> </xsl:for-each-group>
The only place where this breaks is in the<hm280> line of the second<block> element in the snippet at the top of this message, where it fails to find the<lb> embedded in the<rubric>.
understand why; it is grouping the children of the group delimited by<pb> elements, so the<rubric> is a unit, and it doesn't flatten the hierarchy deeply enough to dig inside it.
This is the only misfire and I can fix it in a few ways (including fiddling with the source xml), but is there a standard strategy for flattening all the way down, grouping by<lb> elements no matter how deeply they're embedded in the group delimited by the<pb> elements?
<xsl:for-each-group select="current-group()" group-starting-with="lb">
<span>blah blah blah</span><span>blah </span></td></tr> <tr><td><span> blah blah.</span><td></tr>
This e-mail has been scanned for all viruses by Star.I realize now that I've never had to more than one level deep for this type of project before.
Thanks,
David (djbpitt@xxxxxxxx)
________________________________________________________________________
________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] grouping question, Birnbaum, David J | Thread | RE: [xsl] grouping question, Birnbaum, David J |
[xsl] grouping question, Birnbaum, David J | Date | RE: [xsl] grouping question, Birnbaum, David J |
Month |