xsl-list
[Top] [All Lists]

Re: [xsl] Sorting a TEI <biblStruct> bibliography by <surname>

2014-07-20 07:43:02
 1. I don't think I ever got Charles Muller's original post. When was
    it sent?

 2. Charles -- I presume you are using XSLT 2.0, since there is no
    prefix for the TEI namespace in your XPaths, and because the main
    element is listed as "TEI", not "TEI.2". But aloways a good idea
    to post to the list exactly what version of XSLT and even what
    processor you are using.

 3. As Martin says, we'll need to see what the error message is. Your
    code works for me. (Or at least, doesn't generate error msgs. :-)

 4. Presuming your <monogr>, <series>, or <analytic> elements have
    <surname>s that have content somewhere inside 'em, I don't see
    anything wrong with your code off the top of my head. 

 5. That said, I generally prefer to apply templates than use
    for-each. Presuming you have multiple <listBibl> elements and need
    to keep them separately sorted (which you current code will do),
    I'd use something like

  <!-- Bibliographical renderings -->
  <xsl:template match="TEI//listBibl">
    <xsl:apply-templates select="biblStruct">
      <xsl:sort select="(
        analytic/author/persName/surname,
        monogr/author/persName/surname,
        series/author/persName/surname,
        analytic/editor/persName/surname,
        monogr/editor/persName/surname,
        series/editor/persName/surname
        )[1]"/>
    </xsl:apply-templates>
  </xsl:template>  
  <xsl:template match="biblStruct">
    <p style="text-indent:-10mm;margin-left:10mm">
      <xsl:if test="@n">
        <span style="font-weight:bold;margin-left:2mm">
          <xsl:value-of select="concat( @n, '-&#x09;' )"/>
        </span>
      </xsl:if>
      <xsl:apply-templates/>
    </p>
  </xsl:template>
   Note that I've been much more precise in *which* surname to use for
   sorting, because in my bibliographies <surname> might appear inside
   something other than <author> or <editor> (it is used, e.g., in
   explanatory <note>s). I've also combined the "@n" and hard-coded
   text into one <xsl:value> just because.

 6. Hope this helps! If it doesn't, probably a good idea to post the
    entire stylesheet and a chunk of sample input wiht several
    <biblStruct>s, and the error message. (And which version of XSLT
    and which processor.)

My code for handling <biblStruct> has been working fine for a
number of years, but I just recently tried to add the sort by
<surname>. The relevant part of the code looks like this (including
my most recent attempt at sorting, which generates error messages):


  <!-- Bibliographical renderings -->
<xsl:template match="TEI//listBibl">
  <xsl:for-each select="biblStruct">
    <xsl:sort select="*//surname"/>
   <p style="text-indent:-10mm;margin-left:10mm">
    <xsl:if test="@n">
     <span style="font-weight:bold;margin-left:2mm">
      <xsl:value-of select="@n"/>
      <xsl:text>-&#x09;</xsl:text>
     </span>
    </xsl:if>
      <xsl:apply-templates/>
   </p>
  </xsl:for-each>
</xsl:template>

Which errors exactly do you get?
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>