我有一个需要转换为 html 的 xml,它包含数字及其奇偶校验。我需要创建两列,一列用于偶数,另一列用于添加,但我不能将其放入两列
XML 代码
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="numbers.xsl"?>
<Whole_Numbers>
<Number>
<Value>1</Value>
<Parity>odd</Parity>
</Number>
<Number>
<Value>2</Value>
<Parity>even</Parity>
</Number>
<Number>
<Value>3</Value>
<Parity>odd</Parity>
</Number>
<Number>
<Value>4</Value>
<Parity>even</Parity>
</Number>
</Whole_Numbers>
XSLT -
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Whole Numbers</h2>
<table border="1">
<tr >
<th>Odd Numbers between 1 and 100</th>
<th>Even Numbers between 1 and 100</th>
</tr>
<xsl:for-each select="Whole_Numbers/Number">
<tr>
<xsl:if test="contains(Parity, 'odd')">
<td><xsl:value-of select="Value"/></td>
</xsl:if>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
输出 - 奇数列中只有奇数,如果我包含另一个 td 标签它不起作用