Subject: [xsl] XSLT 2.0: Saxon et. al.: Tracking XML source line numbers From: Justin Johansson <procode@xxxxxxxxxx> Date: Wed, 18 Jul 2007 13:38:59 +0900 |
Hello all, My last question for today, and thanks to all for your patience with, and responses to, this newcomer to your list. Saxon has an XSLT extension function saxon:line-number($node) which returns the line number associated with a node in the XML source tree (though you need to use the -l option to enable line number tracking and perhaps other XSLT processors have a similar such function. However, is there any way that one can achieve the same functionality as C's #line directive with an XSLT processor, even if it an XSLT extension, and tell the processor that line and file numbers for errors and warning associated with particular source node actually relate to another place earlier in chain of pipeline XML/XSLT processing. The background and rationale for this question is as follows: 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. Quoting Visual Studio C++ help <quote> The #line directive lets you modify the line numbers and, optionally, the file name in the compiler output for errors and warnings. #line [ number ["file_name"] | hidden | default ] </quote> Apparently some other languages, e.g. Perl, have a similar facility but what about XSLT? A use case is the YACC processor from the C world. This processor takes as input a BNF-like description of the grammar for particular language, say, cplusplus.y, and produces as output a file, cplusplus.c, which contains C source code for constructing a parser for the given language. When a warning or error occurs in compiling cplusplus.c, the C compiler associates the same with a line number in cplusplus.y instead of cplusplus.c. It would be useful to achieve a similar thing in XSLT to make the debugging of automatically generated stylesheets easier. In response to my post on Jeni Tennison's blog re auto generating XSLT stylesheets, http://www.jenitennison.com/blog/node/13#comments , Jeni rightfully pointed out the problem of debugging such auto generated stylesheets. http://www.jenitennison.com/blog/node/13#comment-4040 Thanks to all in advance for the tips and tricks, Justin Johansson Freelance XML / XSLT / XQuery Developer Australia procode(at)tpg(dot)com(dot)au
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT 2.0: Schema-aware pr, Justin Johansson | Thread | RE: [xsl] XSLT 2.0: Saxon et. al.: , Michael Kay |
Re: [xsl] search for aligned elemen, Rodrigo Segnini | Date | RE: [xsl] XSLT 2.0: Are arguments t, Colin Adams |
Month |