xslt - 测试 ="element[@attribute]"在 XSLT 中起什么作用?

标签 xslt xpath

这到底是做什么的?

<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/

相关文章:

java - 如何在 Java 中使用 XPath 访问读取 XML 的值

xpath - 根据单元格内容选择表格行中的链接

xpath - 为什么这个XPATH查询不起作用?

c# - Umbraco 在 xslt 中发布日期

xslt - 如何处理 XSLT 中的重复导入?

由 Javascript 加载的 XSL 中的 Javascript

.net - 将 XSL 转换应用于 XElement 的最佳方法是什么?

XSLT 排序子元素后续

xpath - YQL 如何在 XPath 中使用通配符

python - 使用xpath获取图像