所以这就是我的 XML 的样子。这非常简单,当然只是想为每个链接布置一堆指向其他 XML 文件的链接,每个链接具有不同的名称/标题:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="index.xsl"?>
<playToc>
<play>a_and_c.xml</play>
<play>all_well.xml</play>
<play>as_you.xml</play>
<play>com_err.xml</play>
<play>coriolan.xml</play>
<play>cymbelin.xml</play>
<name>Title 1</name>
<name>Title 2</name>
<name>Title 3</name>
<name>Title 4</name>
<name>Title 5</name>
<name>Title 6</name>
</playToc>
很简单,对吧?这是我的 XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="playToc">
<html>
<body style="text-align:center;">
<xsl:apply-templates select="play"></xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="play">
<xsl:variable name="URL">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:variable name="TITLE">
<xsl:value-of select="../name"/>
</xsl:variable>
<a href="{$URL}"><xsl:value-of select="$TITLE"/></a>
<br />
</xsl:template>
</xsl:stylesheet>
这是输出:
Title 1
Title 1
Title 1
Title 1
Title 1
Title 1
当我希望这是输出时,当然:
Title 1
Title 2
Title 3
Title 4
Title 5
Title 6
任何帮助都会很棒!非常感谢!