XSLT 1.0 中的输出上下文节点(完整路径)?
出于调试目的,从模板内输出上下文节点的完整路径会很方便,是否有未缩写的 xpath 或函数来报告此情况?
示例模板:
<xsl:template match="@first">
<tr>
<td>
<xsl:value-of select="??WHAT TO PUT IN HERE??"/>
</td>
</tr>
</xsl:template>
示例(节略)输入文档:
<people>
<person>
<name first="alan">
...
模板的输出类似于:
people / person / name / @first
或类似的内容。
For debugging purposes it would be handy to output the full path of the context node from within a template, is there unabbreviated xpath or function to report this ?
Example Template:
<xsl:template match="@first">
<tr>
<td>
<xsl:value-of select="??WHAT TO PUT IN HERE??"/>
</td>
</tr>
</xsl:template>
Example (Abridged) input document:
<people>
<person>
<name first="alan">
...
The output from the template would be something like:
people / person / name / @first
Or something similar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此转换为所需节点生成 XPath 表达式:
应用于以下 XML 文档时:
生成所需的正确结果:
This transformation produces an XPath expression for the wanted node:
when applied on the following XML document:
the wanted, correct result is produced:
这是一个样式表(具有可疑值),它打印文档中每个元素和属性的路径:
当应用于此输入时:
产生:
Here's a stylesheet (of dubious value) that prints the path to every element and attribute in a document:
When applied to this input:
Produces: