I want to use Xerces1.3 to validate a DOM using a DTD. The syntax is: parser.setFeature("http://xml.org/sax/features/validation", true); It seems I have to have access to internet.But how about if I can't get access to internet? Is there any parser can do validation without having access to internet?

JP Moresmau

Yes, you need to have access to the Internet if your DTD references a URL on the NET. The alternative is to provide your parser with a custom EntityResolver (a class that implements the EntityResolver interface) using the parser.setEntityResolver(EntityResolver) method. In this class, define a method : public InputSource resolveEntity (String publicId, String systemId) throws SAXException, IOException and return an InputSource pointing to a local DTD. The parser will use that DTD to validate your document. Have a look at the Javadoc API documentation for more details.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact