SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
| Introduction
| EXSLT Extensions
| Extension attributes (XSLT only)
| Additional serialization parameters
» | Extension functions
| Extension instructions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# saxon:line-number(node)

saxon:line-number() ==> xs:integer

saxon:line-number($node as node()) ==> xs:integer

This function returns the line number of a selected node within the XML document (or external entity) that contains it. If the argument is supplied, it must be a node; if the argument is omitted, the context item is used, in which case the context item must be a node. If line numbers are not maintained for the current document, the function returns -1.

To ensure that line numbers are maintained, use the -l (letter ell) option on the command line.

From release 9.0, the -l option also causes line numbers to be copied from a source document to a result document when the `xsl:copy-of` instruction is applied to a document or element node. For elements created using other instructions, the line number will reflect the position of the instruction in the stylesheet or query that caused the element to be created.

See also saxon:column-number().

Next