From: Jose Rojas [mailto:email@example.com]
Sent: 29 December 2009 07:14
Subject: [saxon] Parsing with Saxon and line numbers
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!
Hotmail: Trusted email with powerful SPAM protection. Sign up now.