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

Re: [xsl] Sorting a TEI list of biblFull with the date as descendant of the author element


Subject: Re: [xsl] Sorting a TEI list of biblFull with the date as descendant of the author element
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 3 Apr 2014 16:10:00 +0100

I haven't looked at it closely, but I think you are sorting the dates as
character strings, in which case it is quite proper that "-3" collates before
"-4".

Despite the extraordinary amount of space given in the type hierarchy to types
such as xs:gYear and xs:gYearMonth, they don't seem much use to you here
because you can't compare a gYear to a gYearMonth.

So your best bet might be to use two sort keys, something like

<xsl:sort select="substring(@when, 1, 5)" data-type="number"/>
<xsl:sort select="@when" data-type="text"/>


Michael Kay
Saxonica


On 1 Apr 2014, at 00:40, chiara@xxxxxxxxxxx wrote:

> Thanks,
> now my sorting works. Just a short question. I managed to do the sorting in
the root element. I have dates that are B.C. and A.D. and rightly I obtain the
B.C. first and then the A.D. The B.C. are from the earliest to the oldest, and
this is wrong. Should I do something in order that <date when=-0004-03>4-3
B.C.</date> comes before <date when=-0003>3 B.C.</date>?
> Thanks again.
> Chiara Salvagni
>
> Date: Fri, 28 Mar 2014 10:26:13 -0400
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> From: Wendell Piez <wapiez@xxxxxxxxxxxxxxx>
> Subject: Re: [xsl] Sorting a TEI list of biblFull with the date as
descendant
> of the author element
> Message-ID:
<CAAO_-xxrthcVXHXxzuXdJNAj3yWZeuyFLiERGkUNA0BWqZY+qw@xxxxxxxxxxxxxx>
>
> Chiara,
>
> As I understand it, your question, "do I need to sort, the biblFull or
> the titleStmt?", is one we can't answer. This is part of your
> requirements specification.
>
> Sort the biblFull elements if you want your bibliography presented in
> order of the date given in its entries. Sort the titleStmt if you
> expect your biblFull to have more than one titleStmt (will this ever
> happen?), and you want their titles sorted by their author dates when
> the bibliography is given (in document order).
>
> I think you probably want your bibliography sorted, no?
>
> Wouldn't this be something like (in your template matching the root):
>
> <xsl:apply-templates select=3D"div[@type=3D'bibliography']/biblFull">
> <xsl:sort select=3D"descendant::author/date/@when"/>
> (etc.)
>
> BTW, the <xsl:value-of select=3D"div[@bibliography]"/> will do nothing
> useful, probably nothing at all: it generates a node containing the
> string value of a div child (of the matched node, i.e. the root) with
> a @bibliography attribute. Such a div is nowhere to be found, as a
> child of the root or otherwise.
>
> In general, I think you'll find it is easier to solve this problem if
> you reduce it to a smaller one. Rather than adding code that might
> (you hope) do what you want, delete everything that doesn't solve this
> particular problem (i.e. the order of presentation), solve it, then
> build the code back up by adding what else you need.
>
> Cheers, Wendell
>
> On Fri, Mar 28, 2014 at 9:57 AM,  <chiara@xxxxxxxxxxx> wrote:
>> I am using Oxygen and XSLT 2.0.
>> My TEI/XML file is a succession of biblFull elements, which needs to be s=
> orted via the attribute of the date element descendant of the author
elemen=
> t. I should add that there are more then one element with the same author
n=
> ame and attribute n and with the same date and attributes.
>> I think I realise that I need to sort select with the attribute of the da=
> te element, but at the moment I am struggling to figure out which element
I=
> need to sort, the biblFull or the titleStmt?
>> <text>
>>       <body>
>>           <div type=3D"bibliography">
>>               <biblFull>
>>                   <titleStmt>
>>                       <title xml:id=3D"b56">La Pr=C3=A9paration =C3=89v=
> ang=C3=A9lique/Preparatio Evangelica</title>
>>                       <author n=3D"Eusebius">Eusebius Theologus et Scri=
> ptor Ecclesiasticus<date when=3D"0004">A.D. 4</date></author>
>>                       <editor>=C3=89duard des Places, s.j.</editor>
>>                   </titleStmt>
>>                   <publicationStmt>
>>                       <publisher>Les =C3=89dition du Cerf</publisher>
>>                       <pubPlace>Paris</pubPlace>
>>                       <address><addrLine>29, Bd de Latour Mauburg</addr=
> Line></address>
>>                       <date>1980</date>
>>                       <availability><p>Copyright 1980, Les =C3=89dition=
> du Cerf</p></availability>
>>                   </publicationStmt>
>>                   <seriesStmt>
>>                       <title>Sources Chr=C3=A9tiennes</title>
>>                       <biblScope>n.266</biblScope>
>>                   </seriesStmt>
>>               </biblFull>
>> I only managed to create a sort with this XSLT, but I do not sort the ent=
> ire biblFull, only the date and the author
>> <xsl:template match=3D"/">
>>       <html>
>>           <head>
>>
>>               <link rel=3D"stylesheet" type=3D"text/css" href=3D"finale=
> .css"/>
>>           </head>
>>           <body bgcolor=3D"azure">
>>               <div id=3D"centeredmenu">
>>               <ul>
>>                   <li>
>>                       <a href=3D"Odyssey finale.html" target=3D"_self">=
> Home</a>
>>                   </li>
>>                   <li>
>>                       <a href=3D"Bibliography secondary sources.html" t=
> arget=3D"_self">Indirect
>>                           Tradition Bibliography</a>
>>                   </li>
>>                   <li>
>>                       <a href=3D"scholialista.html" target=3D"_self">Sc=
> holia</a>
>>                   </li>
>>                   <li>
>>                       <a href=3D"ManuscriptsBookI.html" target=3D"_self=
> ">Manuscripts Book I</a>
>>                   </li>
>>                   <li>
>>                       <a href=3D"#GeneralIntroduction">General Introduc=
> tion</a>
>>                   </li>
>>                   <li>
>>                       <a href=3D"#Dowmnloads">Downloads</a>
>>                   </li>
>>                   <li>
>>                       <a href=3D"#Contacts">Contacts</a>
>>                   </li>
>>               </ul>
>>                   </div>
>>               <p>
>>                   <xsl:value-of select=3D"div[@bibliography]"/>
>>                   <xsl:apply-templates select=3D"descendant::author[@n]=
> ">
>>
>>                       <xsl:sort select=3D"descendant::date[@when,@cert,=
> @intant,@notAfter,@notBefore]"/>
>>                       <xsl:sort select=3D"descendant::author[substring-=
> after(@n, '#')]"/>
>>                       <xsl:sort select=3D"@when,@cert,@intant,@notAfter=
> ,@notBefore"/>
>>                       <xsl:sort select=3D" substring-after(@n, '#')"/>
>>
>>                  </xsl:apply-templates>
>>                   <xsl:apply-templates/>
>>               </p>
>>
>>               <div class=3D"single">
>>                   <iframe src=3D"single authors.html" name=3D"single" h=
> eight=3D"600" width=3D"500"
>>                       />
>>               </div>
>>           </body>
>>       </html>
>>   </xsl:template>
>> The last thing I tried to do is to sort inside a biblFull, but I did not =
> manage to achieve anything.
>> <xsl:template match=3D"biblFull">
>>       <table border=3D"0">
>>           <xsl:for-each select=3D"descendant::titleStmt">
>>               <xsl:apply-templates select=3D"descendant::title[@xml:id]=
> "/>
>>               <xsl:apply-templates select=3D"descendant::title[@sameAs]=
> "/>
>>               <xsl:apply-templates select=3D"descendant::author[@n]">
>>                   <xsl:sort select=3D"descendant::date[substring-after(=
> @when, '#')]"/>
>>                   <xsl:sort select=3D"descendant::date[substring-after(=
> @cert, '#')]"/>
>>                   <xsl:sort select=3D"descendant::date[substring-after(=
> @instant, '#')]"/>
>>                   <xsl:sort select=3D"descendant::date[substring-after(=
> @notAfter, '#')]"/>
>>                   <xsl:sort select=3D"descendant::date[substring-after(=
> @notBefore, '#')]"/>
>>               </xsl:apply-templates>
>>               <xsl:apply-templates select=3D"descendant::editor"/>
>>               </xsl:for-each>
>>           <xsl:for-each select=3D"publicationStmt">
>>                   <xsl:apply-templates select=3D"publisher"/>
>>                   <xsl:apply-templates select=3D"pubPlace"/>
>>                   <xsl:apply-templates select=3D"address"/>
>>                   <xsl:apply-templates select=3D"date"/>
>>                   <xsl:apply-templates select=3D"availability"/>
>>               </xsl:for-each>
>>           <xsl:for-each select=3D"seriesStmt">
>>               <xsl:apply-templates select=3D"title"/>
>>               <xsl:apply-templates select=3D"biblScope"/>
>>           </xsl:for-each>
>>       </table>
>>   </xsl:template>
>> Thanks.
>> Chiara Salvagni
>>
>
> --=20
> Wendell Piez | http://www.wendellpiez.com
> XML | XSLT | electronic publishing
> Eat Your Vegetables
> _____oo_________o_o___ooooo____ooooooo_^
>
> ------------------------------


Current Thread
Keywords