我正在尝试使用xslt文件使用if语句处理xml文件,但是当报告显示我的canos看到行时,只有信息和总行 XML:
<root>
<info org=\"101" date=\"18.11.2013\" type=\"detailReport\">
<row № = \"1\" Name=\"Paul\" sum=\"10\">
<row № = \"2\" Name=\"John\" sum=\"20\">
<row № = \"3\" Name=\"Lisa\" sum=\"30\">
<total sum=\"60\">
</root>
XSLT:
<xsl:template match="root">
<xsl:apply-templates select="info"/>
<xsl:if test="type='detailReport'">
<xsl:apply-templates select="row"/>
</xsl:if>
<xsl:apply-templates select ="total"/>
</xsl:template>
我该如何解决?
答案 0 :(得分:0)
使用“@”符号表示属性 - 即。,
<xsl:if test="@type = 'detailReport'">
但实际上这并不是你想要做的。相反,请匹配您要操作的row
元素,具体为:
<xsl:template match="root">
<xsl:apply-templates select="info"/>
<xsl:apply-templates select="row[@type='detailReport']"/>
<xsl:apply-templates select ="total"/>
</xsl:template>