atom feed4 messages in org.apache.xerces.generalRE: Parsing big document
FromSent OnAttachments
Amirali PourteymourNov 10, 2000 5:51 am 
Paul BrownNov 10, 2000 6:16 am 
Tung MansfieldNov 10, 2000 6:54 am 
Paul BrownNov 10, 2000 12:40 pm 
Subject:RE: Parsing big document
From:Tung Mansfield (
Date:Nov 10, 2000 6:54:38 am

An alternative is to use XSLT. Apache does provide an XSLT engine called xalan. It is pretty good.

-----Original Message----- From: Paul Brown [] Sent: Friday, November 10, 2000 8:17 AM To: Subject: RE: Parsing big document

Amirali -

I have very big XML document around 20 MB.

Funny, since that's Megginson's example size for a large XML document...

I want to add some elements to this XML file and enconter the following problems during this operation: 1-If I use SAX parser,it could only parse XML and I don't know how can I make new XML file (update an existing )

You need to create SAX event handlers that reproduce the existing document to an output. I am sure that you can find these in the examples for one or more parsers. (Look at or in the examples that ship with Xerces.) For example, let's assume that you have a globally declared output stream called "out":

public void endElement(String s) { out.print("</"); out.print(s); out.print(">"); }

This covers preserving the old content. When you want to insert the new content, you can call the SAX events manually:

public static final AttributeList blankAttList = new AttributeListImpl();

public void addNewEmptyElement(String s) { startElement(s,blankAttList); endElement(s); }

Thus, addNewEmptyElement("x") is equivalent to <x></x> on the output stream.

The hard part is recognizing where you want to insert the elements, and you're just going to have to write that custom. Send me an email off-list, and I'll explain how to implement a finite state automaton to do the work for you.

- Paul