Subject: RE: XSLT 2.0: Saxon et. al.: Tracking XML source line numbers
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 18 Jul 2007 20:18:51 +0100
|
> >and have the SAX filter fabricate the line numbers.
>
> Interesting suggestion, Michael. However wouldn't that
> require the stylesheet generator to be run every time you
> want to run the final XSLT?
Yes (well, at any rate, every time you *compile* the final XSLT). You could
consider using the Saxon facility to save the compiled XSLT on disk.
It's quite a common scenario with XSLT stylesheet generation to generate a
new stylesheet for each run, but I agree it's not the only one.
>
> In my scenario, I have a higher level language called Y which
> is translated into XSLT. This is done once only to produce a
> static stylesheet (i.e. an XSLT file on disk).
I'd suggest generating a stylesheet that's pure XSLT plus added
my:line-number attributes. Then write a SAX filter which you put between the
XML parser and the XSLT processor, and which feeds Saxon the faked line
numbers from these attributes.
You certainly don't need to change a line of Saxon code to achieve this: you
can even do it using pure JAXP interfaces.
Michael Kay
http://www.saxonica.com/
|