Xml and DTD validation

A

asaf.galili

Hello,
I am facing a problem, which I can't find the answer to it.
I have a xml, which I am parsing using xerces.
The problem is with the DTD validation, I want to give the DTD file
path to the parser in my code (hardcoded or using environment
parameter) and not to write the path in the xml file.
is it possible?
Thank you,
Asaf
 
G

George Bina

Hello Asaf,

If your document does not contain a reference to a DTD then you can
provide one if you register an entity resolver implementing the SAX
2.0.2 EntityResolver2 interface
http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ext/EntityResolver2.html

If your document contains a reference to a DTD then you should be able
to get a callback in the entity resolver resolveEntity method and from
there you can return an InputSource with your desired DTD.

Best Regards,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top