[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] grouping question
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>. I think I 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? I realize now that I've never had to more than one level deep for this type of project before. Thanks, David (djbpitt@xxxxxxxx)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|