tags:

views:

402

answers:

1

I need to parse a bunch of incoming xml documents, they all have the same DTD. I don't want the Sax Parser to load the DTD every time it has to parse a new xml document. Is there anyway I can load a DTD into the parser and have it reused on subsequent parse calls?

+3  A: 

I'm not sure if your concern is loading the DTD from a remote URL each time you load a document.

If it is, then you can define an EntityResolver and specify a local copy of the DTD. That will provide a reference to the local instance of the DTD each time the SAX parser parses a document.

I don't believe there's a way to pre-load/pre-parse a DTD, unfortunately.

Brian Agnew
I'd like to eliminate any overhead involved in loading any redundant DTD related objects altogether. I will be receiving many xml documents in rapid succession and need to handle them quickly.
anio
I think the only overhead you can eliminate is the remote loading.
Brian Agnew