JDK-4966232 : newSchema(Source) throws Exception for DOMSource & SAXSource
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-12-10
  • Updated: 2012-04-25
  • Resolved: 2003-12-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.0 1.3Fixed
Related Reports
Relates :  
Description
newSchema(Source) throws Exception for DOMSource & SAXSource

Test program and sample schema file attached .
To run the test program , edit 'testDirPath' and 'xmlPath' in Test3.java to point to the directory where sample schema  is saved.

TestProgram - Test3.java
------------------------

import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import org.w3c.dom.Document;

import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.dom.DOMSource;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.DocumentBuilderFactory;

import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;

public class Test3 {
 
    String xmlPath = "";
    String testDirPath = "";
   
   // constructor
    Test3() {
      
    testDirPath = "/home/sa122568/Jaxp/test";
    xmlPath = testDirPath + "/xmlfiles/";
    
   }
// main()
    public static void main(String[] argv) {
        
        Test3 test3 = new Test3();
        test3.checkSchemaFactory01();
        test3.checkSchemaFactory02();
   }
   
// test for W3C XML Schema 1.0 - newSchema(Source schema)
// supports and return a valid Schema instance
// SAXSource - valid schema

  private void checkSchemaFactory01() {   
        try {
	    SchemaFactory sf01 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    InputSource is01 = new InputSource (new FileInputStream(xmlPath + "test.xsd"));
	    SAXSource saxSource01 = new SAXSource (is01);
	    System.out.println("SAXSource created in checkSchemaFactory01()");
	    Schema schema01 = sf01.newSchema(saxSource01);
	    System.out.println(" Schema in checkSchemaFactory01()");
            if (schema01 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory01() passed");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" NullPointerException thrown in Test3/checkSchemaFactory01() - failed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in Test3/checkSchemaFactory01() ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in Test3/checkSchemaFactory01() " + saxe.getMessage());
	} catch (IOException ioe ){ 
	     System.out.println(" Exception thrown in Test3/checkSchemaFactory01() failed"+ioe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in Test3/checkSchemaFactory01() failed"+e.getMessage());
	}
    } 


// test for W3C XML Schema 1.0 - newSchema(Source schema)
// supports and return a valid Schema instance
// DOMSource - valid schema

  private void checkSchemaFactory02() {   
        try {
            Document document02 = null;
	    SchemaFactory sf02 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    DocumentBuilderFactory dbf02 = DocumentBuilderFactory.newInstance();
	    dbf02.setNamespaceAware(true);
	    document02 = dbf02.newDocumentBuilder().parse(new File(xmlPath + "test.xsd"));
	    DOMSource domSource02 = new DOMSource(document02);
	    System.out.println("DOMSource created in checkSchemaFactory02() ");
	    Schema schema02 = sf02.newSchema(domSource02);
	    System.out.println("Schema in checkSchemaFactory02()");
            if (schema02 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory02() passed");
	    }
	
	} catch (NullPointerException npe){
	     System.out.println(" NullPointerException thrown in Test3/checkSchemaFactory02() - failed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in Test3/checkSchemaFactory02() ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in Test3/checkSchemaFactory02() " + saxe.getMessage());
	} catch (IOException ioe ){ 
	     System.out.println(" IOException thrown in Test3/checkSchemaFactory02() failed"+ioe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in Test3/checkSchemaFactory02() failed"+e.getMessage());
	}
    }


}

---------------------------------
verified in Tiger 1.5.0-beta2-b44
###@###.### 2004-03-30
---------------------------------

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3 tiger-beta FIXED IN: 1.3 tiger-beta INTEGRATED IN: 1.3 tiger-b32 tiger-beta VERIFIED IN: tiger-beta2
14-06-2004

EVALUATION Apparently I forgot to implement this. My aplogies. ###@###.### 2003-12-11
11-12-2003