Wanting a performance boost and wanting to use DOM are pretty well incompatible objectives, quite apart from the issue with line numbers.
 
My recommendation, without knowing very much about your requirements, would be to try and write the whole application in XSLT. Your assertion that your pre-processing "cannot be done in XSLT" is almost certainly wrong.
 
There may be DOM implementations that allow line numbers to be retained, but I don't know of one.
 

Regards,

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

Regards,

 


From: Jose Rojas [mailto:ricosrealm@hotmail.com]
Sent: 29 December 2009 07:14
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Parsing with Saxon and line numbers

Hello,

I'm currently using Saxon-B to perform XSLT processing.  I'm extending my application to do some document validation and need access to line numbers as helpful display output.  I'm not using Saxon-B right now to parse documents, using Xalan2 :(, but have read that I may have performance boosts if I use various SAXON optimized trees.

I do need a DOM tree since my application uses the API and holds the document in memory for complex pre-processing that can't be done in XSLT.  As well my application merges various XML documents together so I need to be able to track original source files and line numbers for each DOM node that is created.

Since DOM DocumentBuilders don't typically hold line numbers where the nodes where created, how can I use a Saxon to make this happen?

I was thinking that the a possible approach is to embed the line number as a special internalized attribute to each node and use a preprocessing xslt to load the XML and apply the line numbers (and filename as necessary) as these attributes.  How would I do this and how would I generate an efficient DOM tree as a result?  I need to not stray from the actual org.w3c.dom api (no NodeInfo, NodeWrapper).

Thanks for the help!
Jose



Hotmail: Trusted email with powerful SPAM protection. Sign up now.