Xml XSLT将项与类匹配
我正在做一个相当简单的XSLT模板,似乎有些地方出错了 我试图循环遍历HTML表中的每个元素,如果它有一个特定的类,那么它应该打印一些东西,如果没有,它应该打印其他东西 HTML的摘录。我想将A与类“instructionRow”匹配 小提琴: 谢谢Xml XSLT将项与类匹配,xml,xslt,xslt-2.0,Xml,Xslt,Xslt 2.0,我正在做一个相当简单的XSLT模板,似乎有些地方出错了 我试图循环遍历HTML表中的每个元素,如果它有一个特定的类,那么它应该打印一些东西,如果没有,它应该打印其他东西 HTML的摘录。我想将A与类“instructionRow”匹配 小提琴: 谢谢 <xsl:for-each select="table/tbody/tr"> (它不检查文档中的当前tr,而是检查文档中的每个tr) 为了测试循环迭代的每个tr/@class <xsl:styleshee
<xsl:for-each select="table/tbody/tr">
(它不检查文档中的当前tr
,而是检查文档中的每个tr
)
为了测试循环迭代的每个tr/@class
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<order timestamp="{current-dateTime()}">
<xsl:for-each select="table/tbody/tr">
<xsl:choose>
<xsl:when test="//tr[contains(@class, 'instructionRow')]">
Instruction
</xsl:when>
<xsl:otherwise>
Not Instruction
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</order>
</xsl:template>
</xsl:stylesheet>
Not Instruction
Instruction
<xsl:for-each select="table/tbody/tr">
<xsl:when test="//tr[contains(@class, 'instructionRow')]">
<xsl:when test="contains(@class, 'instructionRow')">