How to get line number in XSLT?

Is it possible to get the line number when we apply XSLT to XML? I need to know the line number when there is a specific template pattern found in XML.

Is it possible to get the line number?

+4
source share
2 answers

If you mean the line number of the node in the source document, Saxon provides this using the saxon:line-number() extension function saxon:line-number() , provided the source document is provided through an interface (such as the SAX parser) that reports line numbers. There is no standard XSLT mechanism for this.

+5
source

Line numbers do not really make sense in xsl, because the structure in the file may differ from the parsed view. A number of questions already cover this, for example, this question

You could use a node position or some kind of identifier to achieve your requirements.

+1
source

All Articles