You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Maitreyee Pasad <pa...@gst.com> on 2000/10/19 16:55:23 UTC

Redirect the Parser to my own DTD

I have seen lot of people ask similar questions but I am not sure I
understand clearly.

I am developing a web server where the user sends messages in XML. I
have my own
DTD that their XML should conform too. But it is possible that when the
user sends an
XML message they refernce their own (possibly incorrect) DTD.

I want to make sure that I ask the SAXParser to look at my own DTD.

How do use the Entity Resolver for that?
I don't require them to specifically provide a publicID for the DTD
and the systemID may point to their own DTD.

So in the example code in the API docs:

 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;

 public class MyResolver implements EntityResolver {
   public InputSource resolveEntity (String publicId, String systemId)
   {
     if (systemId.equals("http://www.myhost.com/today")) {
              // return a special input source
       MyReader reader = new MyReader();
       return new InputSource(reader);
     } else {
              // use the default behaviour
       return null;
     }
   }
 }

I can't really know what the systemId would be.

Help!

Thanks.

Maitreyee