Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 17th, 2013, 11:57 AM
Authorized User
 
Join Date: Feb 2013
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Saxon --> Understanding parsing and transforming

Hallo everyone,

my company uses Saxon to process their xml-files. I am trying to understand what kind of parsing method they are using:
Code:
System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
...
CharArrayWriter buffer = new CharArrayWriter();
StreamResult resultSource = new StreamResult(buffer);
trans.transform(xmlSource, resultSource);
csv = buffer.toString();
I got an explanation, which I could not really understand. My question was: where can I see that we have parsed the source xml-file before we transform it.
The explanation was:
"The parsing is done "on the fly". So, a DOM-Tree or others was not created before."

Where from the above code is meant?

Other questions:
1. What is the default parser from Saxon?
2. Is my assumtion correct, by calling the method getTransformer, the xml-file is being parsed implizitly?

Thank you very much

Regards,

Ratna
 
Old June 17th, 2013, 12:03 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't said what is in xmlSource, and this is rather critical to your question. It's likely that it's one of the three "standard" kinds of Source defined by JAXP:

StreamSource - in this case Saxon parses the supplied XML stream using the default SAX parser, and builds a tree in Saxon's native format (a TinyTree) ready for use in the transformation.

SAXSource - in this case, if the XmlReader of the SAXSource is initialized, it works the same way as a StreamSource except that the XmlReader supplies the parser that Saxon uses.

DOMSource - in this case a pre-built tree in DOM format is supplied, so Saxon does not need to do any parsing. This is less efficient because Saxon works much faster with its native tree format than with an external DOM.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 17th, 2013, 06:09 PM
Authorized User
 
Join Date: Feb 2013
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hallo Mr. Kay,

yes, indeed the xmlSource is from type StreamSource. So, the Default SAX Parser is used in this case. Just to be sure:
so, there is no "parsing"-method needed for the parsing process? The parsing process is implicitely implemented by calling the method Transformer.transform ?

Thank you.

Regards,

Ratna
 
Old June 17th, 2013, 06:53 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>The parsing process is implicitely implemented by calling the method Transformer.transform ?

Yes.

By the way, let me recommend my book. I think it will help your understanding.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Saxon 9.1.0.3 issue with <xsl:with-param> Chelsea Valentine XSLT 4 March 23rd, 2010 03:03 PM
Chpt 7 >> Pg 245 >>Try It Out #4-5 harrison4411 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 March 2nd, 2006 06:26 PM
Achitecture ? SQL -> XML -> ASP -> PDF or HTML Frm jstrong Classic ASP XML 0 July 9th, 2005 01:18 PM
VB.Net -> Filename -> DTS Package -> tempdB daniel Pro VB.NET 2002/2003 1 October 7th, 2004 01:46 PM
XML Parsing error: require </META> disaacs XSLT 1 August 6th, 2004 01:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.