6

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

Is it possible to retrieve the line number?

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
senthil kumar
  • 119
  • 2
  • 4
  • Do you mean the line number within a single tag? Such as a `` tag (containing only text), and you want to select the nth line of text? If so, [this answer](http://stackoverflow.com/questions/2916532/xslt-line-counter-is-it-that-hard/2916978#2916978) might be what you're looking for. – Eric Oct 03 '11 at 15:44

1 Answers1

5

If you mean the line number of the node in the source document, Saxon provides this using an extension function saxon:line-number(), provided the source document is supplied via an interface (e.g. a SAX parser) that reports line numbers. There's no standard XSLT mechanism for this.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Michael Kay
  • 156,231
  • 11
  • 92
  • 164