1
我有一個xml,我需要轉換爲html,它包含數字和它們的奇偶校驗。我需要創建兩列一個甚至和其他的附加,但我不能把它的兩列XSLT的數字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標籤它不起作用