Bug 6174

Summary: referenced DTD not found when validating a XML document
Product: Xerces-J Reporter: Erik Schaller <esc>
Component: SAXAssignee: Xerces-J Developers Mailing List <xerces-j-dev>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 1.4.4   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: see other bugs - URL exception

Description Erik Schaller 2002-02-01 10:28:07 UTC
With the new version 1.4.4 I always encounter an exception when validating a XML 
document.

*Parsing Fatal Error*  Line:    0
  URI:     
  Message: File "signplus.dtd" not found.
org.xml.sax.SAXException: Fatal Error encountered
at 
de.softpro.signplus.client.businessModel.MyErrorHandler.fatalError(SB_XMLHandler
.java:2132)
        at 
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1242)
        at 
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalEntity(De
faultEntityHandler.java:780)
        at 
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalSubset(De
faultEntityHandler.java:571)
        at 
org.apache.xerces.framework.XMLDTDScanner.scanDoctypeDecl(XMLDTDScanner.java:113
9)
        at 
org.apache.xerces.framework.XMLDocumentScanner.scanDoctypeDecl(XMLDocumentScanne
r.java:2145)
        at 
org.apache.xerces.framework.XMLDocumentScanner.access$0(XMLDocumentScanner.java:
2100)
        at 
org.apache.xerces.framework.XMLDocumentScanner$PrologDispatcher.dispatch(XMLDocu
mentScanner.java:831)
        at 
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java
:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)

The XML document reverts to a DTD specification. The system id is NOT fully 
qualified:

<?xml version="1.0" encoding="Cp850"?>
<!DOCTYPE SignPlusEntry SYSTEM "signplus.dtd">
...

The problem only appears when passing the XML file as a stream to the parse 
methode of the XMLReader. When I pass the fully qualified URI of the XML file it 
works fine. It also works fine when I specifiy the fully qualified URI of the 
DTD within the XML file. So I assume that the reference to the DTD file is not 
resolved correctly when passing the InputSource object to the parse method. All 
this worked fine in version 1.4.3.

In the following I have listed parts of the code I use:

  public void readXML (java.io.InputStream xmlContent) {
    InputSource input=new InputSource(xmlContent);

    XMLReader parser = 
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    parser.setContentHandler(new MyContentHandler());
    parser.setErrorHandler(new MyErrorHandler());

    // Turn on validation
    parser.setFeature("http://xml.org/sax/features/validation", true);
    // Turn off namespace awareness
    parser.setFeature("http://xml.org/sax/features/namespaces", false);

    // Parse the document
    parser.parse(input);
Comment 1 Chris Sanscrainte 2004-04-29 17:33:00 UTC
Created attachment 11383 [details]
see other bugs - URL exception