Dim*_*hev 27
只需使用:
<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>
Run Code Online (Sandbox Code Playgroud)
别注:在一个精心编写的XSLT代码的条件指令数(如<xsl:choose>,<xsl:when>,<xsl:otherwise>,<xsl:if>,...等)接近于零.在这个解决方案中它是 0.
Ars*_*yan 19
<xsl:choose>
<xsl:when test="element/@attribute">
do one thing
</xsl:when>
<xsl:otherwise>
do something else
</xsl:otherwise>
</xsl:choose>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29455 次 |
| 最近记录: |