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 bu...@apache.org on 2002/11/11 19:10:58 UTC

DO NOT REPLY [Bug 14455] New: - JAXP 1.2 - schemaSource can't contain InputStreams

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14455>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14455

JAXP 1.2 - schemaSource can't contain InputStreams

           Summary: JAXP 1.2 - schemaSource can't contain InputStreams
           Product: Xerces2-J
           Version: 2.2.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: JAXP
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: vojtech.habarta@seznam.cz


Because of bug 13818 I know Xerces is compatible with JAXP 1.2 although on 
http://xml.apache.org/xerces2-j/index.html is still JAXP 1.1.
But currently schemaSource property can't contain Object array with 
InputStreams. I tried 2.2.0 and also Dev Snapshot 2002-11-08.
XML Reader always parses only first XML document and on second throws 
SAXParseException.

Here is Exception:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema 
document 'null', because 1) could not find the document; 2) the document could 
not be read; 3) the root element of the document is not <xsd:schema>.
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at test.JaxpTest.main(JaxpTest.java:46)


Here is code:

package test;

import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;


public class JaxpTest {

    public static final String JAXP_SCHEMA_LANGUAGE =
        "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    public static final String W3C_XML_SCHEMA =
        "http://www.w3.org/2001/XMLSchema";
    public static final String JAXP_SCHEMA_SOURCE =
        "http://java.sun.com/xml/jaxp/properties/schemaSource";

    private static ErrorHandler errorHandler = new ErrorHandler() {
        public void warning(SAXParseException exception) throws SAXException {
            throw exception;
        }
        public void error(SAXParseException exception) throws SAXException {
            throw exception;
        }
        public void fatalError(SAXParseException exception) throws 
SAXException {
            throw exception;
        }
    };

    public static void main(String[] args) throws Exception {
        Object[] schemaSource = new Object[] {
            JaxpTest.class.getResource("/schema1.xsd").openStream(),
            JaxpTest.class.getResource("/schema2.xsd").openStream(),
        };
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);
        spf.setValidating(true);
        SAXParser parser = spf.newSAXParser();
        parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
        parser.setProperty(JAXP_SCHEMA_SOURCE, schemaSource);
        XMLReader reader = parser.getXMLReader();
        reader.setErrorHandler(errorHandler);
        reader.parse(new InputSource(new FileInputStream("doc1.xml")));
        reader.parse(new InputSource(new FileInputStream("doc2.xml")));
        System.out.println("OK.");
    }

}

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org