是否有更好的方法来查找 XML 节点是否存在(在 XSLT 中)而不是使用:
<xsl:choose>
<xsl:when test="...........">body node exists</xsl:when>
<xsl:otherwise>body node missing</xsl:otherwise>
</xsl:choose>
最佳答案
xsl:choose
的替代方法
定义更好; xsl:choose
很好地涵盖了条件表达式。 更好需要根据一些标准进行衡量,但没有提供。不过,您可以根据需要评估以下一些替代方案:
XSLT 1.0
<xsl:if test="/path/to/node">node exists</xsl:if>
<xsl:if test="not(/path/to/node)">node missing</xsl:if>
XSLT 2.0
<xsl:value-of select="if (/path/to/node) then 'node exists' else 'node missing'"/>
关于xml - 检查 XSLT 中是否存在 XML 节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37015762/