我不明白这是怎么回事:
<collection>
<record>
<datafield tag="700" ind1=" " ind2="1">
<subfield code="a">David</subfield>
<subfield code="b">M.</subfield>
<subfield code="g">Moonstone</subfield>
<subfield code="4">070</subfield>
</datafield>
<datafield tag="801" ind1=" " ind2="0">
<subfield code="a">lang</subfield>
<subfield code="b">EN</subfield>
<subfield code="c">20080929</subfield>
</datafield>
</record>
<record>
<datafield tag="700" ind1=" " ind2="1">
<subfield code="a">Samanta</subfield>
<subfield code="b">A.</subfield>
<subfield code="g">Aro</subfield>
<subfield code="4">070</subfield>
</datafield>
<datafield tag="801" ind1=" " ind2="0">
<subfield code="a">lang</subfield>
<subfield code="b">JP</subfield>
<subfield code="c">50789</subfield>
</datafield>
</record>
</collection>
得到这样的东西:
person: David M. (Moonstone)
extra: lang +EN+ - 20080929
person: Samanta A. (Aro)
extra: lang +JP+ - 50789
这是我的 XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:for-each select="collection/record">
<xsl:apply-templates select="datafield[@tag='700']" />
<xsl:apply-templates select="datafield[@tag='801']" />
</xsl:for-each>
</xsl:template>
<xsl:template match="datafield[@tag='700']">
person: <xsl:apply-templates select="subfield[@code='a'] | subfield[@code='b'] | subfield[@code='g'] " />
</xsl:template>
<xsl:template match="datafield[@tag='801']">
extra: <xsl:apply-templates select="subfield[@code='a'] | subfield[@code='b'] | subfield[@code='c'] " /></xsl:template>
<xsl:template match="subfield[@code='a'] | subfield[@code='b'] | subfield[@code='g'] "> (<xsl:value-of select="." />)</xsl:template>
<xsl:template match="subfield[@code='a'] | subfield[@code='b'] | subfield[@code='c'] "><xsl:value-of select="." /> </xsl:template>
</xsl:stylesheet>
这给了我这个:
person: DavidM. (Moonstone)
extra: langEN20080929
person: SamantaA. (Aro)
extra: langJP50789
如何更好地控制位于不同节点的具有不同属性的实际上相同的子字段?我完全对这个 XPath 感到困惑,或者它是什么?