0

我正在尝试使用 XSLT 按作者姓名对参考书目进行排序。然而,作者的姓氏以 xml 结构出现在不同的位置,具体取决于它是什么类型的文本(书籍、期刊等)。

这是数据:

<biblStruct type="book" xml:id="Swanson2002">
<monogr>
  <title>Universities, academics and the Great Schism</title>
  <author>
    <forename>R. N</forename>
    <surname>Swanson</surname>
  </author>
  <imprint>
    <pubPlace>Cambridge</pubPlace>
    <biblScope type="vol">12</biblScope>
    <publisher>Cambridge Univ Pr</publisher>
    <date>2002</date>
    <note type="accessed">2012-07-06 18:34:53</note>
    <note type="url">http://books.google.com/books?hl=en&amp;lr=&amp;id=9AUE425_1xYC&amp;oi=fnd&amp;pg=PR8&amp;dq=Swanson,+Univiersities+Plaoul&amp;ots=EdkhHvSExW&amp;sig=tFOJKFi2myNWhkR_Rl4XE-cQcSc</note>
  </imprint>
</monogr>
<note type="tags">
  <note type="tag">Petrus Plaoul</note>
</note>
 <idno type="ISBN">0521522269</idno>
</biblStruct>
<biblStruct type="journalArticle" xml:id="Maier1958">
<analytic>
  <title>Zu einigen Sentenzenkommentaren des XIV Jahrunderts</title>
  <author>
    <forename>A.</forename>
    <surname>Maier</surname>
  </author>
</analytic>
<monogr>
  <title>Archivum franciscanum historicum</title>
  <imprint>
    <biblScope type="vol">51</biblScope>
    <biblScope type="pp">405-409</biblScope>
    <date>1958</date>
  </imprint>
</monogr>
<note type="tags">
  <note type="tag">Hard Copy Obtained</note>
</note>
</biblStruct>
<biblStruct type="bookSection" xml:id="Kaluza1995">
<analytic>
  <title>Les débuts de l'Albertisme tardif (Paris et Cologne)</title>
  <author>
    <forename>Zenon</forename>
    <surname>Kaluza</surname>
  </author>
</analytic>
<monogr>
  <title>Albertus Magnus und der Albertismus</title>
  <imprint>
    <pubPlace>Leiden</pubPlace>
    <biblScope type="pp">207-295</biblScope>
    <publisher>Brill</publisher>
    <date>1995</date>
  </imprint>
</monogr>
</biblStruct>

这是我的 XSLT 模板

 <xsl:template match="tei:listBibl">
    <xsl:for-each select="./tei:biblStruct">
        <xsl:sort select="./tei:monogr/tei:author/tei:surname"/>
    </xsl:for-each/>
 </xsl:template/>

目前这只对条目进行排序@type=monogr

我也试过这个,但它不起作用:

<xsl:sort select="./tei:monogr/tei:author/tei:surname or     ./tei:analytic/tei:author/tei:surname"/>
4

1 回答 1

3

It looks to me as if either

<xsl:sort select=".//author/surname"/>

or

<xsl:sort select="./*/author/surname"/>

would do the job

You don't want to use an "or" operator, which always returns a boolean result, but if necessary you could use the "union" operator (|):

<xsl:sort select="monogr/author/surname | analytic/author/surname"/> 

which in 2.0 can be shortened to

<xsl:sort select="(monogr|analytic)/author/surname"/> 
于 2012-11-03T20:09:13.150 回答