[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSLT 2.0: Saxon et. al.: Tracking XML source line

Subject: RE: XSLT 2.0: Saxon et. al.: Tracking XML source line numbers
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 18 Jul 2007 08:47:06 +0100
RE:  XSLT 2.0: Saxon et. al.: Tracking XML source line
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.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Justin Johansson [mailto:procode@xxxxxxxxxx] 
> Sent: 18 July 2007 05:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSLT 2.0: Saxon et. al.: Tracking XML source 
> line numbers
> 
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.