At 11:11 AM 2/18/2004, Syd wrote:
>Ah, but now I see the light. (It's amazing how actually doing the
>work illuminates what perhaps should have been obvious.) My solution
>forces the label to be in its own <html:p> element, whereas Wendell's
>permitted it to be the first text in the first <html:p>, which will
>likely look look a lot better in most cases.

... and that's the only reason I did it, since that was the requirement as
given. :->

The question whether to give a speaker label its own line or to interpolate
it into the first paragraph is one of those design decisions that we like
to think lives only at its own level (what looks best?), but which often
bleeds into others (what's easiest and most robust to code?) despite our
best efforts. You're right: when the Justices are allowed to rule in verse,
the code gets more baroque; if content models are really loose and shaggy,
"baroque" may seem a generous way to describe it.

Smart templating, however, can help. Saying you do face the possibility
that the Justices will sing, you could do:

  <xsl:template match="sp/p">
   <p class="{local-name()}">
      <xsl:apply-templates select="id(../@who)" mode="inline-speaker">
      <!-- Syd notes you might just want to select="../speaker" -->
       <xsl:with-param name="here" select="."/>

  <xsl:template match="*" mode="inline-speaker">
    <xsl:param name="here" select="."/>
   <xsl:if test="not($here/preceding-sibling::*)">
     <xsl:text>: </xsl:text>

... in this case, both the appearance of the speaker and the conditional
that wraps it are encapsulated in a template that can be applied from other
contexts. Then to get the speaker to appear in the first line of the
Justice's aria:

(for lines in a single level of linegroups)
  <xsl:template match="sp/lg/l">
   <p class="line">
      <xsl:if test="not(preceding-sibling::l)">
      <!-- note we need an extra conditional wrapper here because we want
           the label only on the first line in the first line group, not on
           every line in it -->
       <xsl:apply-templates select="id(../parent::sp/@who)"
         <xsl:with-param name="here" select="parent::lg"/>

...and for plain lines, just change "sp/p" to "sp/p | sp/l" in the first
template given ... since it already does the job.


Wendell Piez                            mailto:[log in to unmask]
Mulberry Technologies, Inc.      
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
   Mulberry Technologies: A Consultancy Specializing in SGML and XML