Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > passing xml stream to xalan

Reply
Thread Tools

passing xml stream to xalan

 
 
Sandy
Guest
Posts: n/a
 
      08-12-2005
Hi,

I have some data stored in my internal data structure. I am writing this
data in an xml file and invoking xalan on this file to perform some
transformation.
After the transformation I want to put the data in Database so i m reading
the xml produced by xalan.

But as there are lot of IO operations so the application is very slow.
Is there any way to pass the xml stream (using the string buffer that I am
writing into XML file) directly to xalan

can somebody give me an example code.

Thanks in advance


 
Reply With Quote
 
 
 
 
Nigel Whitaker
Guest
Posts: n/a
 
      08-15-2005
Hello Sandy,

Answering in reverse order:

> But as there are lot of IO operations so the application is very slow.
> Is there any way to pass the xml stream (using the string buffer that I am
> writing into XML file) directly to xalan
>


From the string buffer construct a Reader and use
this in the StreamSource constructor.

StringBuffer sb= ....;
Transformer t= TransformerFactory.newInstance().newTransformer();
t.transform(new StreamSource(new StringReader(sb.toString()), "buffer:sb"),
new StreamResult(new File("output.xml")));

While this avoids disk-io, it does not avoid the parsing/lexical
analysis overhead.

> I have some data stored in my internal data structure. I am writing this
> data in an xml file and invoking xalan on this file to perform some
> transformation.


A more efficient technique could be to generate SAX ContentHandler
events as you traverse your internal data structure. You could
then feed this contentHandler into the SAXSource constructor:

Class DSToXML implements ContentHandler ....;
DSToXML reporter;
t.transform(new SAXSource(reporter), ...);

Hope this gives you a start,

Nigel
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Project Xalan XML/XSLT Processor Is Good, But Its ExtensionNot Work on Netscape/IE RC Java 6 04-22-2005 02:31 PM
ERRor using jboss 4.0 and xercers, xalan ,xslt, to get xml satish mn via JavaKB.com Java 0 11-25-2004 03:14 PM
Upgrade of Xalan 1.2.2 and Xerces 1.4.4 to Xalan 2.6 and Xerces 2.6.2 cvissy XML 0 11-16-2004 07:06 AM
xsl-fo and xml file to test xalan to create fo-file RoyalDutchman XML 0 12-17-2003 11:43 PM
problem with xalan indent from xml to html hongping XML 1 11-02-2003 09:02 PM



Advertisments