我有两个XML文件,我只是为了让不同的章节,并需要显示在输出文件。
源XML
<xml>
<chapter>1 Live animals.</chapter>
<chapter>2 Meat and edible meat offal.</chapter>
<chapter>3 Fish and crustaceans, molluscs and other aquatic invertebrates.</chapter>
<chapter>4 Dairy produce; birds eggs; natural honey; edible products of animal origin, not elsewhere specified or included.</chapter>
<chapter>5 Products of animal origin, not elsewhere specified or included.</chapter>
<chapter>6 Live trees and other plants; bulbs, roots and the like; cut flowers and ornamental foliage.</chapter>
<chapter>7 Edible vegetables and certain roots and tubers.</chapter>
<chapter>8 Edible fruit and nuts; peel of citrus fruit or melons.</chapter>
<chapter>9 Coffee, tea mat, and spices.</chapter>
<chapter>10 Cereals.</chapter>
<chapter>11 Products of the milling industry; malt; starches; inulin; wheat gluten.</chapter>
<chapter>12 Oil seeds and oleaginous fruits; miscellaneous grains, seeds and fruit; industrial or medicinal plants; straw and fodder.</chapter>
</xml>
和
另一个XML [使用文档函数导入的XSLT内部]
<main>
<chunk>1 Live animals.</chunk>
<chunk>2 Meat and edible meat offal.</chunk>
<chunk>3 Fish and crustaceans, molluscs and other aquatic invertebrates.</chunk>
<chunk>4 Dairy produce; birds eggs; natural honey; edible products of animal origin, not elsewhere specified or included.</chunk>
<chunk>5 Products of animal origin, not elsewhere specified or included.</chunk>
<chunk>6 Live trees and other plants; bulbs, roots and the like; cut flowers and ornamental foliage.</chunk>
<chunk>7 Edible vegetables and certain roots and tubers.</chunk>
<chunk>8 Edible fruit and nuts; peel of citrus fruit or melons.</chunk>
<chunk>9 Coffee, tea mat, and spices.</chunk>
<chunk>10 Cereals.</chunk>
<chunk>11 Products of the milling industry; malt; starches; inulin; wheat gluten.</chunk>
<chunk>12 Oil seeds and oleaginous fruits; miscellaneous grains, seeds and fruit; industrial or medicinal plants; straw and fodder.</chunk>
<chunk>13 Example of distint chaptrr fruits; miscellaneous grains</chunk>
</main>
现在,这里,不同的值是<chunk>13 Example of distint chaptrr fruits; miscellaneous grains</chunk>
<chunk>13 Example of distint chaptrr fruits; miscellaneous grains</chunk>
。
我怎样才能得到这个通过XSLT代码,任何样品XSLT代码吗?
这是我的代码,它不工作,截至目前。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates/>
<xsl:for-each select="//chunk">
<xsl:variable name="thisvalue" select="."/>
<xsl:for-each select="document('Main2.xml')/xml/chapter">
<xsl:choose>
<xsl:when test=". = $thisvalue">
</xsl:when>
<xsl:otherwise>
<distint><xsl:value-of select="."/></distint>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>