这到底是做什么的?
<xsl:if test="./employee/first-name[@id='14']" >
我的意思是,如果 ./employee/first-name[@id]
!= null
或 ""
,还是什么?
编辑
我已经编辑了上面的语句,因此它测试 id=14 的元素名字是否有正文或其正文包含数据,或者如果名字事件没有正文则返回 true?
最佳答案
如果查询<xsl:if test=...>
返回至少一个节点,然后条件计算结果为 true。
您给出的新 XSLT 表达式:
<xsl:if test="./employee/first-name[@id='14']" >
当且仅当存在 first-name
时,才会评估为 true employee
下的节点谁的id
属性等于字符串 '14'
<employee><first-name id="" /></employee> <!-- does NOT match -->
<employee><first-name id="014" /></employee> <!-- does NOT match -->
<employee>
<first-name id="foobar" />
<first-name id="14" /> <!-- DOES match -->
</employee>
关于xslt - 测试 ="element[@attribute]"在 XSLT 中起什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1742353/