You basically need to feed SAX events into a ReceivingContentHandler which in turn pushes events into a TinyBuilder. So it will be something like this:
 
Configuration config = new Configuration();
PipelineConfiguration pipe = config.makePipelineConfiguration();
TinyBuilder builder = new TinyBuilder();
builder.setPipelineConfiguration(pipe);
ReceivingContentHandler rch = new ReceivingContentHandler();
rch.setPipelineConfiguration(pipe);
rch.setReceiver(builder);
 
.. feed SAX events to rch ...
 
NodeInfo doc = builder.getCurrentRoot();
 
I can't be sure this is complete, I may have omitted some detail.
 

Regards,

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



From: Erik Vanherck [mailto:Erik.Vanherck@inventivegroup.com]
Sent: 07 April 2010 13:29
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Constructing a tiny tree from SAX events

Hi,

 

I was looking at TinyTree to buffer an XML in memory which needs to be kept for some time until some other work  completes and then needs to be passed in to Saxon. Using DOM or even going back to serialized bytes would mean a significant overhead, in terms of constructing both representations as well as memory, not to mention the performance hit Saxons transformation would take. Configuration.buildDocument() is exactly what I was looking for from an inputstream but I got one code path which is a SAX handler receiving events and couldn’t figure out what the proper API is to construct a tinytree in a push order. Any hints would be much appreciated.

 

Wih kind regards,

 

Erik Vanherck

Product Delivery Manager

 

Phone: +32 3 821 01 70

Office Fax: +32 3 821 01 71

Erik.Vanherck@inventivegroup.com

www.inventivegroup.com

 



Inventive Designers' Email Disclaimer:
http://www.inventivedesigners.com/email-disclaimer


--
This message has been scanned for viruses and
dangerous content, and is believed to be clean.
--