得到行号/行号。这可以实现 [英] getting line numbers/row numbers .Can this be achieved

查看:102
本文介绍了得到行号/行号。这可以实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过以下xml实现此输出:



 grankids儿子
行1 1 2
行:2女儿:3
行:3 daughterinlaw:1
行:4父亲:James
行:5年龄:4
行:6孩子:
行:7只狗:斗牛犬

解决方案



这是否有某种系统?我没有看到任何。
例如在您的XML中,您有两个子元素,但只有第一个在文本输出中使用。
在文本输出中,您有一个较大的行,但是有在XML中没有这样的东西。
行的顺序是什么? (任意,如在XML中,还有别的东西)?

可以使用函数"position()"。在XPATH中,它将返回当前正在其上下文中处理的节点的位置。这有点复杂,但大部分时间它都像你期望的那样工作。因此,如果您可以按照输出中的方式排序XML中的元素(甚至可能使用某些XSLT排序),那么您可以使用position()来确定行的编号。

谢谢,

Is it possible to achieve this output from the xml below:

       grankids son
row 1  1         2
row:2  daughter:3
row:3  daughterinlaw:1
row:4  father:James
row:5  age:4
row:6  child:a
row:7  dog:bulldog

解决方案

Hi,

Is there some kind of system in this? I don't see any.
For example in your XML you have two child elements, but only the first one is used in the text output.
In the text output you have a dauther row, but there's no such thing in the XML.
What is the ordering of the rows? (arbitrary, as in the XML, something else)?

It is possible to use the function "position()" in the XPATH which will return the position of the node currently being processed in its context. It's a bit complicated, but most of the time it works as you would expect. So ifyou can order the elements in the XML (maybe even using some XSLT ordering) the way you want them in the output, then you can use the position() to determine the number of the row.

Thanks,


这篇关于得到行号/行号。这可以实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆