[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Sorting a TEI bibliography by

Subject: Re: [xsl] Sorting a TEI <biblStruct> bibliography by <surname>
From: "Syd Bauman s.bauman@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 20 Jul 2014 12:42:51 -0000

 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="(
  <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;' )"/>
   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?

Current Thread