问题如下:我的XML包含内容为“x / y”的元素。这表示“部分”的运行数量。例如。在第一个XML中,此元素的值为1/5,第二个为2/5,最后一个为5/5。你明白了。元素本身看起来像
<part>x/y</part>
其中x可能介于1和y之间,y可以是任意数字
我需要找到两个案例的答案:
如何使用XSL(版本1.0)解决这个问题?
<?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="part">
<xsl:variable name="x" select="substring-before(., '/')"/>
<xsl:variable name="y" select="substring-after(., '/')"/>
<xsl:choose>
<xsl:when test="$x = 1">Add</xsl:when>
<xsl:when test="$x = $y">Complete</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('Unexpected values for x,y: ', $x, ',', $y)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>