[英]Check if XML node exists in XSLT
是否有更好的方法來查找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
定義更好 ; xsl:choose
很好地覆蓋條件表達式。 更好需要根據某些標准進行測量,並且沒有提供任何標准。 不過,這里有一些您可以根據需要評估的替代方案:
<xsl:if test="/path/to/node">node exists</xsl:if>
<xsl:if test="not(/path/to/node)">node missing</xsl:if>
<xsl:value-of select="if (/path/to/node) then 'node exists' else 'node missing'"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.