[XSL-LIST Mailing List Archive Home]
RE: [xsl] XSLT 2.0: Saxon et. al.: Tracking XML source line numbers
Subject: RE: [xsl] XSLT 2.0: Saxon et. al.: Tracking XML source line numbers|
From: Justin Johansson <procode@xxxxxxxxxx>
Date: Wed, 18 Jul 2007 19:52:08 +0900
>> C and C++ preprocessors have long had the ability for the
>> programmer to modify the file name and line numbers for which
>> the compiler outputs errors and warnings associated with source code.
>> Apparently some other languages, e.g. Perl, have a similar
>> facility but what about XSLT?
>It would certainly be possible to implement such a mechanism by inserting a
>SAX filter between the XML parser and the XSLT processor, and have the SAX
>filter fabricate the line numbers. In fact, if the stylesheet generator is
>feeding the generated stylesheet to the XSLT processor directly as a SAX
>stream, then it takes full responsility for supplying 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?
I cannot imagine, for example, wanting to have to run a YACC processor on a
grammar file every time I run the compiler that was generated.
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). The static stylesheet will run many times, perhaps
once every time a web page is called up to be rendered in HTML, PDF or
whatever. So I'm beginning to think there are only two viable options :-
1. Use saxon:line-number in the XSLT generator that generates the XSLT from
Y to put line-number attributes on elements in the resultant XSLT.
2. Use saxon:line-number in the XSLT generator that generates the XSLT from
Y to generate a line-number cross-reference file in addition to the
Either way, I would still need to hook the error message processing in the
XSLT processor to do either the line number lookup from the attribute on
the element as in 1 or to consult the cross-reference file as in 2.
I'm savvy enough with Java to make the appropriate mods to Saxon but don't
like the idea of producing a private version of Saxon from SourceForge
sources and being out on a limb.
Freelance XML / XSLT / XQuery Developer