>Sorry for not mentioning this earlier, but I'm using the transformation as part of a Java code and not executing it externally.
There's an equivalent of the Saxon -l flag in the Java API: use setAttribute(LINE_NUMBERING) on the TransformerFactory. See http://www.saxonica.com/documentatio...formation.html
But again this is Saxon-specific.
>Let me try attacking this from a different angle: is there a way to uniquely identify the original XML element and use it in the output? In that case I can do some post-processing to get the location of the original node.
You might be better off preprocessing - put a SAX filter in the pipeline, and use it to add a lineNumber attribute to every element, which is then available to the XSLT code. This approach would work with any JAXP processor.
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference