Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can I force a parser to use fixed DTD for validation?

843834Jul 29 2001 — edited May 2 2007
How do I force a SAX parser to use a fixed DTD (and ignore any DOCTYPE decl. in the xml doc) ??
I have been searching Java forums, apache website, the web, and SAX APIs for a way to do this but without luck. The usage is that I want to validate with a DTD located on the server, and wish to set my parser to always use that DTD, rather than requiring the user to declare a DOCTYPE declaration in the xml doc. The only solution I've seen so far is to actually search for a DOCTYPE decl in the xml, and replace it if it's there, with our own. This seems like a "hack" to me...

I've played around with EntityResolver and peeked at DTDHandler but those don't seem to work or be the right approach.
Any help would be appreciated!
Thanks
Stephen Boniface
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2007
Added on Jul 29 2001
16 comments
968 views