哪些工具链支持将节点集作为参数传递给 XSLT 转换?
这是 上一个问题 我有关于 XSLT 的问题。
回顾一下,我没有意识到如果没有 EXSLT,XSLT 将无法让您动态创建具有字符串值的 xpath 表达式。建议的解决方法之一是
在执行转换之前查询输入文档的 DOM,并将节点集传递到转换中
我使用 Apache Ant 进行转换,并且按照 有关 xslt/style 任务参数的手册
要放入参数中的文本值。最初旨在成为 XSL 表达式。
听起来 Apache Ant 不支持这个。但这让我想知道,这种语义在支持此功能的系统中如何工作?
那么,哪些工具链或系统支持将节点集作为参数从源文档传递到转换中。示例代码的奖励积分。
This is a followup to an answer on a previous question I had about XSLT.
To recap, I didn't realize that without EXSLT, XSLT wouldn't let you dynamically create an xpath expression with string values. One of the suggested workarounds was
to query the input document's DOM before you execute the transform, and pass the node-set into the transform
I was using Apache Ant to do the transformation, and per the manual on the xslt/style task's parameters
Text value to be placed into the parameter. Was originally intended to be an XSL expression.
it sounds like Apache Ant doesn't support this. It got me wondering though, how would this semantics of this work in a system that did support this?
So, what Toolchains or systems support passing a nodeset from the source document into a transformation as a parameter. Bonus points for example code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法在标准 xslt 1.0 中将节点集作为参数传递。
为此,您必须使用 xslt 2.0 解析器。
例如:
http://wiki.apache.org/ant/UsingAntWithXSLT20AndSaxon
You can't pass a nodeset as a parameter in standard xslt 1.0.
To do that you must use an xslt 2.0 parser.
For instance:
http://wiki.apache.org/ant/UsingAntWithXSLT20AndSaxon
我不完全确定我的答案,因为我似乎无法正确理解您的问题,但根据您引用的线程和您的引用,我可以提出以下建议:
build.xml:
< strong>test.xml:
ant-with-param.xsl:
输出:
给定样式表根据传递的变量值从输入文档中获取参数来自构建文件。参数是借助 XPath 表达式从源文档中获取的,并在以后借助
exsl:node-set()
扩展函数使用。默认情况下,ant
使用Xalan
作为 xslt 处理器。其扩展的完整列表可以在项目主页中找到。I'm not completely sure about my answer because it seems that I cannot understand your question properly but basing on the thread you reference and your quotes I can come up with the following suggestion:
build.xml:
test.xml:
ant-with-param.xsl:
Output:
Given stylesheet fetches parameters from the input document basing on the value of the variable passed from the build-file. Parameters are fetched with the help of the XPath expression from the source document and used later with the help of the
exsl:node-set()
extension function. By defaultant
usesXalan
as an xslt processor. Full list of its extensions can be found at the project's home page.