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

grouping question

Subject: grouping question
From: "Birnbaum, David J" <djbpitt@xxxxxxxx>
Date: Thu, 25 Nov 2010 16:56:45 -0500
 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)

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.