Nodenet Problem Set Javadocs

nodenet
Class DTDResolver

java.lang.Object
  extended bynodenet.DTDResolver
All Implemented Interfaces:
org.xml.sax.EntityResolver

public class DTDResolver
extends java.lang.Object
implements org.xml.sax.EntityResolver

This class allows us to validate against a DTD that is found on the classpath. This is important because otherwise we would need to deploy the DTD on our website and parsers would look it up there, or the DTD woud have to be placed in a specific location in the filesystem where we could find it. In the first case the program would break on computers not currently connected to the internet, and in the latter case would impose an unacceptable configuration burden on students and the professors who guide them.

The Apache Crimson parser on which the default jvm's rely seems to have some quirks. One is that the value of sys must be a valid URI (as per the java.net.URI class with a known scheme) Since this is entirely irrelevant for the classloader, the KLUDGE constant must be prepended to the sys string, otherwise crimson will throw exceptions before invoking this EntityResolver. This appears to violate the spec in the javadoc but I can't do anything about it. If Java switches to Xerces2 this may not be neccesary.

Version:
$Id: DTDResolver.java,v 1.4 2004/01/15 18:38:38 gus Exp $
Author:
Patrick G. Heck, gus.heck@olin.edu

Field Summary
static java.lang.String KLUDGE
          A dummy string to prepend to the system DTD entity to workaround a bug in the crimson parser.
 
Constructor Summary
DTDResolver()
          Creates a new instance of DTDResolver
 
Method Summary
 org.xml.sax.InputSource resolveEntity(java.lang.String pub, java.lang.String sys)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KLUDGE

public static final java.lang.String KLUDGE
A dummy string to prepend to the system DTD entity to workaround a bug in the crimson parser. It is also used to workaround a problem with InputSource which refuses to use any system resource unless systemId is set to a valid URI.

See Also:
Constant Field Values
Constructor Detail

DTDResolver

public DTDResolver()
Creates a new instance of DTDResolver

Method Detail

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String pub,
                                             java.lang.String sys)
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver

Nodenet Problem Set Javadocs