- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法理解 exsl:node-set 函数的工作原理。
我有一些 XML,我正在扩展并使用它来动态填充 exsl:node-set。假设它目前采用这种格式:
<xsl:variable name="wrap">
<nodes>
<node/>
<node/>
<node/>
</nodes>
</xsl:variable>
<xsl:variable name="wrapNodeSet" select="exsl:node-set($wrap)"/>
这按要求工作并且输出 $wrapNodeSet 显示上面的节点标记。根节点名称使用名称 ($wrapNodeSet/*) 显示为“节点”。
现在我需要将其扩展为具有 2 个节点并动态填充节点集。所以:
<xsl:variable name="wrap">
<nodes tier="a">
<node/>
<node/>
<node/>
</nodes>
<nodes tier="b">
<node/>
<node/>
<node/>
</nodes>
</xsl:variable>
<xsl:variable name="wrapNodeSet" select="exsl:node-set($wrap)/nodes[@tier='b']"/>
输出节点集包括节点元素,但输出根节点的名称现在更改为“节点”。
有人可以解释为什么节点元素仍然输出吗?
最佳答案
<xsl:variable name="wrapNodeSet"
select="exsl:node-set($wrap)/nodes[@tier='b']"/>
这从使用 node-set()
扩展获得的树中选择任何 nodes
元素,(nodes
元素)有一个tier
属性值为 'b'
。
然后:
name($wrapNodeSet/*)
生成包含在 $wrapNodeSet
中的第一个节点的第一个子元素的名称。由于 $wrapNodeSet
只包含一个 nodes
元素,而 nodes
元素只有 node
子元素,第一个这样的子元素是一个 node
元素及其名称,因为任何 node
元素的名称都是 "node"
。
为什么您会在此结果中看到任何意外?
换句话说:
ext:node-set()
在 $wrap
上的应用在这两种情况下都会产生相同的树,但在第二种情况下,您使用不同的、更长的 XPath ext:node-set($wrap)
结果的表达式——因此您从这两个不同的 XPath 表达式的计算中得到不同的结果。
关于xslt - exsl :node-set treat as the root node? 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11291505/
我只是开始XSLT,我尝试在XSLT 1.0中使用str:tokenize()模板。 我检查了:http://www.exslt.org/str/functions/tokenize/index.ht
我有一组节点 and so on... 我现在已经按这种方式排序
我有以下 PHP 代码,但无法正常工作。我没有看到任何错误,但也许我只是瞎了眼。我在 PHP 5.3.1 上运行它。 Hello world Foo
我无法理解 exsl:node-set 函数的工作原理。 我有一些 XML,我正在扩展并使用它来动态填充 exsl:node-set。假设它目前采用这种格式:
在 xslt-stylesheet 中,我使用方法 exsl:node-set 和 set:distinct 从包含结果的变量中访问和过滤唯一节点树片段。我可以将这些节点的值写入我的输出文件,例如:
我正在尝试根据 XML 实例验证 Yang 模型。我发现这个 bash 脚本[1] 可以完成这项工作,但我想使用 Java 重写它。 撒克逊版本 Saxon 9.9.1-5. xsltproc 版本
我是一名优秀的程序员,十分优秀!