Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-513

JAXP 1.2 - schemaSource can't contain InputStreams

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 2.2.0
    • None
    • None
    • Operating System: Windows XP
      Platform: PC
    • 14455

    Description

      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.");
      }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            vojtech.habarta@seznam.cz Vojtech Habarta
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: