我正在使用XSL when子句将一个XML文件转换为另一个XML文件。我在测试时需要使用“存在”功能。在XSL中存在函数When Statement
下面是一个例子源XML:
<People>
<Person personid="1" location="US" fullname="John Doe"/>
<Person personid="2" location="US" fullname="Jane Doe"/>
</People>
<Nicknames>
<Nickname personid="1" nname="Johnny D"/>
</Nicknames>
这里是我的例子XSL:
<xsl:element name="HASNICKNAME">
<xsl:choose>
<!-- If nickname exists in source XML, return true -->
<xsl:when test="boolean exists function"
<xsl:text>TRUE</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>FALSE</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
谁能帮与存在的一部分?
的可能重复[检查是否存在使用XSLT节点(http://stackoverflow.com/questions/4694480/check-if-a-node-exists-using-xslt) – 2011-04-11 21:50:33
或http://stackoverflow.com/questions/767851/xpath-find-if-node-exists或http://stackoverflow.com/questions/4948878/xslt-detecting-if-a-node-exists或任何http://www.google.com/search?q=site%3Astackoverflow.com+xslt+exist+node – 2011-04-11 21:57:24