我有这个XML文件(省略了不相关的节点)我需要排序。 排序应该在有作者的时候在作者身上。 如果同一作者写了更多的书,他/她的书应该按标题排序。如果作者缺少排序,应该在标题的第一个字上。 希望的顺序是:莱西,明娜 - 新的先进教学方法 - Tekniska museet - Wrede,伊娃:Arton kvadrat - Wrede,Eva:Femton kvadrat。XSL对来自多个节点的内容进行排序
作者可以使用MarcEntry标记100或MarcEntry tag110,但不能同时使用两者。有没有作者的记录。所有记录都有一个标题= MarcEntry标签245
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="gallring2.xsl"?>
<report>
<catalog>
<marc>
<marcEntry tag="100" label="Personal Author" ind="1 ">Wrede, Eva</marcEntry>
<marcEntry tag="245" label="Title" ind="10">Arton kvadrat</marcEntry>
</marc>
<call>
<item>
<itemID>3058000817845</itemID>
</item>
</call>
</catalog>
<catalog>
<marc>
<marcEntry tag="100" label="Personal Author" ind="1 ">Wrede, Eva</marcEntry>
<marcEntry tag="245" label="Title" ind="10">Femton kvadrat</marcEntry>
</marc>
<call>
<item>
<itemID>30580008156593</itemID>
</item>
</call>
</catalog>
<catalog>
<marc>
<marcEntry tag="110" label="Corporate Author" ind="2 ">Tekniska museet</marcEntry>
<marcEntry tag="245" label="Title" ind="10">35 mer eller mindre märkliga föremål i Tekniska museets samlingar</marcEntry>
</marc>
<call>
<item>
<itemID>30580008290806</itemID>
</item>
</call>
</catalog>
<catalog>
<marc>
<marcEntry tag="100" label="Personal Author" ind="1 ">Lacey, Minna</marcEntry>
<marcEntry tag="245" label="Title" ind="10">365 experiment för nyfikna barn</marcEntry>
</marc>
<call>
<item>
<itemID>30580009824363</itemID>
</item>
</call>
</catalog>
<catalog>
<marc>
<marcEntry tag="245" label="Title" ind="10">New advanced teaching methods.</marcEntry>
</marc>
<call>
<item>
<itemID>30580008182334</itemID>
</item>
</call>
</catalog>
</report>
我想这在我的样式表
<xsl:sort select="../../marc/marcEntry[@tag='100' or @tag='110']"/>
但只是给了我的错误,只会一直中途,有它的工作。
关于如何继续的任何建议? XSLT 2.0和扩展不是一个选项。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<catalog>
<xsl:for-each select="report/catalog/call/item">
<xsl:sort select="../../marc/marcEntry[@tag='100']"/>
<xsl:sort select="../../marc/marcEntry[@tag='245']"/>
<itemline>
<Author><xsl:value-of select="substring(../../marc/marcEntry[@tag='100' or @tag='110'],1,30)"/></Author>
<Title><xsl:value-of select="substring(../../marc/marcEntry[@tag='245'],1,30)"/></Title>
<itemID><xsl:value-of select="itemID"/></itemID>
</itemline>
</xsl:for-each>
</catalog>
</xsl:template>
</xsl:stylesheet>
表达'的 '是有效的。你使用它时会得到什么错误? –