【发布时间】:2015-12-13 13:16:35
【问题描述】:
大家好,我有一个关于 for each 循环的问题。 我想在任何匹配后添加一个文本序列。目前我只得到文本和整个匹配项。知道为什么吗?
这是我的 XML 文件,例如:
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<country>DE</country>
<country>AUT</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
这是我的 XML 转换:
<?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="/">
<html>
<body>
<xsl:for-each select="catalog/cd">
<xsl:value-of select="country" />
<xsl:text> and </xsl:text>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
这是我的结果和我的问题:
USA and
预期的输出应该是:
USA and DE and AUT
我确信这是一个初学者的错误并且很容易解决,但我不知道如何以简单的方式解决它。提前致谢
【问题讨论】: