DTD Validation 2003-01-22 - By Keeney, Thomas
Nevermind. The main reason I wanted to link the DTD at runtime was because I didn't want to specify the complete URI to the DTD file within the XML document. However, I see that you can implement the EntityResolver interface in your Handler to resolve the full URI to the DTD within the code. For example, the EntityResolver can resolve the DTD for: <!DOCTYPE XFDL SYSTEM "survey_response.dtd">
Using this code:
public static final String SURVEY_RESPONSE_DTD = "survey_response.dtd";
public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (systemId.endsWith(SURVEY_RESPONSE_DTD)) { String dtdPath = this.getClass().getClassLoader().getResource(SURVEY_RESPONSE_DTD).getPath(); return new InputSource(dtdPath); } else { // use the default behaviour return null; } }
-----Original Message----- From: Keeney, Thomas [mailto:KeeneyT@(protected)] Sent: Wednesday, January 22, 2003 2:23 PM To: 'xerces-j-user@(protected)' Subject: DTD Validation
Hello,
I'm using the SAXParser with DTD validation enabled in Xerces 2.2.1. Currently I have to include a document type definition in the xml document for validation to work. However, does anyone know of a way that I could validate an XML document WITHOUT a document type definition hardcoded into the XML? I'd like to link the XML document to a DTD at runtime.
Regards,
Tom Keeney -------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|