如何在 XSL 中查明属性是否存在。
最佳答案
只需使用:
<xsl:template match="someElement/@someAttrName">
<!-- Whatever specific work when someElement has @someAttrName -->
</xsl:template>
<xsl:template match="someElement[not(@someAttrName)]">
<!-- Whatever specific work when someElement has no @someAttrName -->
</xsl:template>
请注意:在编写良好的 XSLT 代码中,条件指令的数量(例如 <xsl:choose>
、 <xsl:when>
、 <xsl:otherwise>
、 <xsl:if>
……等)接近于零。在此解决方案中,它是 0。
关于xml - 如何查明属性是否存在于 XSL 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4918837/