Bug 6174 - referenced DTD not found when validating a XML document
Summary: referenced DTD not found when validating a XML document
Status: NEW
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: SAX (show other bugs)
Version: 1.4.4
Hardware: PC All
: P3 normal
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-01 10:28 UTC by Erik Schaller
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
see other bugs - URL exception (10.96 KB, text/plain)
2004-04-29 17:33 UTC, Chris Sanscrainte
Details

Note You need to log in before you can comment on or make changes to this bug.
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