我怎么知道xslt中根节点和当前节点之间的特定节点总数?

编程入门 行业动态 更新时间:2024-10-26 18:25:13
本文介绍了我怎么知道xslt中根节点和当前节点之间的特定节点总数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hi All, I want to count the total number of specific nodes between root node and current node. for Example: <pre lang="text"><w:body xmlns:w="#unknown"> <!-- root Node --> <w:p /> <w:rect> <w:p>some text1</w:p> </w:rect> <w:p /> <w:rect> <w:p>some text2</w:p> </w:rect> <w:p /> <w:p /> <w:p /> <w:rect> <w:p>some text5</w:p> <!-- This is current node now --> </w:rect> <w:p /> <w:p /> <w:p /> <w:p /> </w:body>

这是我的情况.在这里,假设一些文本是我的当前节点.所以,现在我想获取当前节点的parent :: w:p(假设此节点名称为"targetNode").之后,我想计算从根节点到targetNode的w:p级别相同的总数. 我想要的输出是:5 请引导我解决此问题...

This is my scenario.Here, Assume some text is my current node.So, Now i want to get the parent::w:p of the current node (Assume this node name as "targetNode"). After that i want to calculate total number of the same level of w:p from root node to targetNode. My wanted output is :5 Please Guide me to get out of this issue...

推荐答案

count(祖先:: w:p [1]/preceding-sibling :: w:p + 1)(第一个祖先w:p本身). count(ancestor::w:p[1]/preceding-sibling::w:p + 1)(the first ancestor w:p itself).

更多推荐

我怎么知道xslt中根节点和当前节点之间的特定节点总数?

本文发布于:2023-11-25 15:49:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630366.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   总数   我怎么   xslt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!