You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2006/04/23 10:11:20 UTC

svn commit: r396241 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/reader/ codegen/ codegen/src/org/apache/axis2/schema/template/ codegen/src/org/apache/axis2/wsdl/codegen/ codegen/test-resources/xsd/ codegen/tes...

Author: ajith
Date: Sun Apr 23 01:11:18 2006
New Revision: 396241

URL: http://svn.apache.org/viewcvs?rev=396241&view=rev
Log:
1. Added a test to check the minoccurs=0 case for ADB
2. Fixed the xmlbeans/CodeGenerationUtility.java to process the imported schemas properly. Thanks Dims for pointing out the proper way.(I had an alternate solution where the XMLBeans schemaCompiler was invoked directly but it is highly unrecommended and registering the custom entity resolver seemed the correct solution)
3. Added a minor fix to the ADBBeanTemplate.xsl as pointed out by Chuck. Thanks chuck for the pointer and the patch


Added:
    webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple-minoccurs0.xsd
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/schema/populate/other/PopulateMinOccurs0Test.java
Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java
    webservices/axis2/trunk/java/modules/codegen/maven.xml
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
    webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java?rev=396241&r1=396240&r2=396241&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java Sun Apr 23 01:11:18 2006
@@ -42,6 +42,7 @@
  * 3. OMElementkey - OMElement value
  * 4. QName name/String name  - ADBBean value
  * 5. QName name/String name  - Java bean
+ * 5. QName name/String name  - Datahandler
  *
  * As for the attributes, these are the possible combinations in the
  * array
@@ -58,7 +59,7 @@
  * in effect this is one huge state machine that has only a few states and delegates
  * things down to the child parsers whenever possible
  * <p/>
- * the possible inputs for this class
+ *
  */
 public class ADBXMLStreamReaderImpl implements ADBXMLStreamReader {
 
@@ -70,7 +71,7 @@
 
     private Map declaredNamespaceMap = new HashMap();
 
-    //states for this pullparser - it can only have three states
+    //states for this pullparser - it can only have four states
     private static final int START_ELEMENT_STATE = 0;
     private static final int END_ELEMENT_STATE = 1;
     private static final int DELEGATED_STATE = 2;

Modified: webservices/axis2/trunk/java/modules/codegen/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/maven.xml?rev=396241&r1=396240&r2=396241&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/maven.xml Sun Apr 23 01:11:18 2006
@@ -43,6 +43,7 @@
         <mkdir dir="${schema.generated.src.dir}"/>
         <mkdir dir="${schema.generated.classes.dir}"/>
         <!-- Run schema compiler with designated schemas -->
+        <ant:echo>Compiling simple_maxOccurs2.xsd</ant:echo>
         <!-- simple max occurs 2 xsd -->
         <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
             <jvmarg line="${maven.junit.jvmargs}"/>
@@ -51,6 +52,7 @@
             <arg file="${schema.source.dir}/simple_maxOccurs2.xsd"/>
             <arg file="${schema.generated.src.dir}"/>
         </java>
+        <ant:echo>Compiling anonymous_complexType.xsd</ant:echo>
         <!-- anon complex type xsd -->
         <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
             <jvmarg line="${maven.junit.jvmargs}"/>
@@ -60,6 +62,7 @@
             <arg file="${schema.generated.src.dir}"/>
         </java>
           <!-- anon choice xsd -->
+        <ant:echo>Compiling simple_choice.xsd</ant:echo>
         <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
             <jvmarg line="${maven.junit.jvmargs}"/>
             <classpath refid="maven.dependency.classpath"/>
@@ -68,6 +71,7 @@
             <arg file="${schema.generated.src.dir}"/>
         </java>
         <!-- simple max occurs xsd -->
+        <ant:echo>Compiling simple_maxOccurs.xsd</ant:echo>
         <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
             <jvmarg line="${maven.junit.jvmargs}"/>
             <classpath refid="maven.dependency.classpath"/>
@@ -77,11 +81,23 @@
         </java>
 
         <!-- simple any type xsd -->
+        <ant:echo>Compiling simple_anytype.xsd</ant:echo>
         <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
             <jvmarg line="${maven.junit.jvmargs}"/>
             <classpath refid="maven.dependency.classpath"/>
             <classpath location="${compiled.classes.dir}"/>
             <arg file="${schema.source.dir}/simple_anytype.xsd"/>
+            <arg file="${schema.generated.src.dir}"/>
+        </java>
+
+
+        <!-- min occurs 0 xsd -->
+        <ant:echo>Compiling simple-minoccurs0.xsd</ant:echo>
+        <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+            <jvmarg line="${maven.junit.jvmargs}"/>
+            <classpath refid="maven.dependency.classpath"/>
+            <classpath location="${compiled.classes.dir}"/>
+            <arg file="${schema.source.dir}/simple-minoccurs0.xsd"/>
             <arg file="${schema.generated.src.dir}"/>
         </java>
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=396241&r1=396240&r2=396241&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Sun Apr 23 01:11:18 2006
@@ -176,6 +176,15 @@
                    if (<xsl:value-of select="$varName"/> == null){
                        <xsl:value-of select="$varName"/> = new <xsl:value-of select="$propertyType"/>{};
                    }
+
+                    <xsl:if test="$choice">
+                           clearAllSettingTrackers();
+                    </xsl:if>
+                    <xsl:if test="$min=0 or $choice">
+                         //update the setting tracker
+                         <xsl:value-of select="$settingTracker"/> = true;
+                    </xsl:if>
+
                    java.util.List list =
                         org.apache.axis2.databinding.utils.ConverterUtil.toList(<xsl:value-of select="$varName"/>);
                    list.add(param);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=396241&r1=396240&r2=396241&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Sun Apr 23 01:11:18 2006
@@ -207,7 +207,15 @@
         if (uri.startsWith("http://")){
             baseURI = uri;
         } else{
-            baseURI = file.getParentFile()!=null?file.getParentFile().toURI().toString():null;
+            if(file.getParentFile() == null){
+               try {
+                    baseURI = new File(".").getCanonicalFile().toURI().toString();
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            } else {
+                baseURI = file.getParentFile().toURI().toString();
+            }
         }
 
 

Added: webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple-minoccurs0.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple-minoccurs0.xsd?rev=396241&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple-minoccurs0.xsd (added)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/simple-minoccurs0.xsd Sun Apr 23 01:11:18 2006
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://test.org">
+	<xs:element name="root">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="A" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
+				<xs:element name="B" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element name="C" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/schema/populate/other/PopulateMinOccurs0Test.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/schema/populate/other/PopulateMinOccurs0Test.java?rev=396241&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/schema/populate/other/PopulateMinOccurs0Test.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/schema/populate/other/PopulateMinOccurs0Test.java Sun Apr 23 01:11:18 2006
@@ -0,0 +1,85 @@
+package org.apache.axis2.schema.populate.other;
+
+import junit.framework.TestCase;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.Method;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.IntrospectionException;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class PopulateMinOccurs0Test extends TestCase {
+
+    private String xmlString1 = "<root xmlns=\"http://test.org\">" +
+            "<A>I am A</A>" +
+            "<B>I am B1</B>" +
+            "<B>I am B2</B>" +
+            "<C>I am B2</C>" +
+            "<C>I am B2</C>" +
+            "</root>";
+
+    private String xmlString2 = "<root xmlns=\"http://test.org\">" +
+            "<A>I am A</A>" +
+            "<C>I am B2</C>" +
+            "<C>I am B2</C>" +
+            "</root>";
+
+    public void testPopulate1() throws Exception{
+        populateAndAssert(xmlString1,2);
+    }
+
+     public void testPopulate2() throws Exception{
+         populateAndAssert(xmlString2,0);
+    }
+
+    private void populateAndAssert(String s,int expectedCount) throws XMLStreamException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IntrospectionException {
+        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(s.getBytes()));
+        Class clazz = Class.forName("org.test.Root");
+        Class innerClazz = clazz.getDeclaredClasses()[0];
+        Method parseMethod = innerClazz.getMethod("parse",new Class[]{XMLStreamReader.class});
+        Object obj = parseMethod.invoke(null,new Object[]{reader});
+
+        assertNotNull(obj);
+
+        Object stringArray = null;
+        BeanInfo beanInfo =  Introspector.getBeanInfo(obj.getClass());
+        PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+        Method readMethod;
+        for (int i = 0; i < propertyDescriptors.length; i++) {
+            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+            if ("b".equals(propertyDescriptor.getDisplayName())){
+                readMethod = propertyDescriptor.getReadMethod();
+                stringArray = readMethod.invoke(obj, null);
+                break;
+            }
+        }
+
+        assertNotNull(stringArray);
+        String[] array = (String[])stringArray;
+        assertEquals(array.length,expectedCount);
+    }
+
+
+
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java?rev=396241&r1=396240&r2=396241&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java (original)
+++ webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java Sun Apr 23 01:11:18 2006
@@ -23,6 +23,9 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -30,9 +33,12 @@
 import java.util.Map;
 import java.util.Vector;
 import java.util.HashMap;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 import org.apache.axis2.namespace.Constants;
 import org.apache.axis2.util.URLProcessor;
+import org.apache.axis2.util.XMLUtils;
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
@@ -47,9 +53,12 @@
 import org.apache.xmlbeans.XmlBeans;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
 import org.w3c.dom.Element;
 import org.w3c.dom.Document;
-import com.ibm.wsdl.util.xml.DOM2Writer;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 import javax.xml.namespace.QName;
 
@@ -92,55 +101,74 @@
                 return new DefaultTypeMapper();
             }
 
-            // todo - improve this code by using the schema compiler from
-            //xmlbeans directly
 
             SchemaTypeSystem sts;
-            Vector xmlObjectsVector = new Vector();
+            List completeSchemaList = new ArrayList();
+            List topLevelSchemaList = new ArrayList();
+
             //create the type mapper
             JavaTypeMapper mapper = new JavaTypeMapper();
             Map nameSpacesMap = cgconfig.getAxisService().getNameSpacesMap();
+
+            //process all the schemas and make a list of all of them for
+            // resolving entities
             for (int i = 0; i < schemas.size(); i++) {
                 XmlSchema schema = (XmlSchema) schemas.get(i);
                 XmlOptions options = new XmlOptions();
                 options.setLoadAdditionalNamespaces(
                         nameSpacesMap); //add the namespaces
                 Document[] allSchemas = schema.getAllSchemas();
-
                 for (int j = 0; j < allSchemas.length; j++) {
                     Document allSchema = allSchemas[j];
-                    ///////////////////////////
-                    //System.out.println(DOM2Writer.nodeToString(allSchema));
-                    ////////////////////////////
-                    xmlObjectsVector.add(
+                    completeSchemaList.add(
                             XmlObject.Factory.parse(
                                     allSchema
                                     , options));
+
                 }
             }
 
+            //make another list of top level schemas for passing into XMLbeans
+            for (int i = 0; i < schemas.size(); i++) {
+                XmlSchema schema = (XmlSchema) schemas.get(i);
+                XmlOptions options = new XmlOptions();
+                options.setLoadAdditionalNamespaces(
+                        nameSpacesMap); //add the namespaces
+                    topLevelSchemaList.add(
+                            XmlObject.Factory.parse(
+                                    getSchemaAsString(schema)
+                                    , options));
+
+                }
+
             // add the third party schemas
             //todo perhaps checking the namespaces would be a good idea to
             //make the generated code work efficiently
             for (int i = 0; i < additionalSchemas.length; i++) {
-                xmlObjectsVector.add(XmlObject.Factory.parse(
+                completeSchemaList.add(XmlObject.Factory.parse(
+                        additionalSchemas[i]
+                        , null));
+                 topLevelSchemaList.add(XmlObject.Factory.parse(
                         additionalSchemas[i]
                         , null));
             }
 
             //compile the type system
-            XmlObject[] objeArray = convertToXMLObjectArray(xmlObjectsVector);
+            Axis2EntityResolver er  = new Axis2EntityResolver();
+            er.setSchemas(convertToSchemaDocumentArray(completeSchemaList));
+            er.setBaseUri(cgconfig.getBaseURI());
+
 
             sts = XmlBeans.compileXmlBeans(
                     //set the STS name to null. it makes the generated class
                     // include a unique (but random) STS name
                     null,
                     null,
-                    objeArray,
+                    convertToSchemaArray(topLevelSchemaList),
                     new Axis2BindingConfig(cgconfig.getUri2PackageNameMap()),
                     XmlBeans.getContextTypeLoader(),
                     new Axis2Filer(cgconfig.getOutputLocation()),
-                    null);
+                    new XmlOptions().setEntityResolver(er));
 
             // prune the generated schema type system and add the list of base64 types
             cgconfig.putProperty(XSLTConstants.BASE_64_PROPERTY_KEY,
@@ -243,11 +271,11 @@
             schemaType = elementProperties[i].getType();
             name = elementProperties[i].getName();
             if (!base64Types.contains(name) && !processedTypes.contains(schemaType.getName())){
-                 processedTypes.add(stype.getName());
+                processedTypes.add(stype.getName());
                 if (schemaType.isPrimitiveType()) {
                     SchemaType primitiveType = schemaType.getPrimitiveType();
                     if (Constants.BASE_64_CONTENT_QNAME.equals(primitiveType.getName())) {
-                            base64Types.add(name);
+                        base64Types.add(name);
                     }
 
                 } else {
@@ -259,9 +287,6 @@
 
     }
 
-    private static XmlObject[] convertToXMLObjectArray(Vector vec) {
-        return (XmlObject[]) vec.toArray(new XmlObject[vec.size()]);
-    }
 
     /**
      * Private class to generate the filer
@@ -339,4 +364,146 @@
         }
     }
 
+    /**
+    *
+     * @param vec
+     * @return
+     */
+    private static SchemaDocument[] convertToSchemaDocumentArray(List vec) {
+        SchemaDocument[] schemaDocuments =
+                (SchemaDocument[]) vec.toArray(new SchemaDocument[vec.size()]);
+        //remove duplicates
+        Vector uniqueSchemas = new Vector(schemaDocuments.length);
+        Vector uniqueSchemaTns = new Vector(schemaDocuments.length);
+        SchemaDocument.Schema s;
+        for (int i = 0; i < schemaDocuments.length; i++) {
+            s = schemaDocuments[i].getSchema();
+            if (!uniqueSchemaTns.contains(s.getTargetNamespace())) {
+                uniqueSchemas.add(schemaDocuments[i]);
+                uniqueSchemaTns.add(s.getTargetNamespace());
+            }else if (s.getTargetNamespace()==null){
+                //add anyway
+                uniqueSchemas.add(schemaDocuments[i]);
+            }
+        }
+        return (SchemaDocument[])
+                uniqueSchemas.toArray(
+                        new SchemaDocument[uniqueSchemas.size()]);
+    }
+
+    /**
+     * Converts a given vector of schemaDocuments to XmlBeans processable
+     * schema objects. One drawback we have here is the non-inclusion of
+     * untargeted namespaces
+     * @param vec
+     * @return
+     */
+    private static SchemaDocument.Schema[] convertToSchemaArray(List vec) {
+        SchemaDocument[] schemaDocuments =
+                (SchemaDocument[]) vec.toArray(new SchemaDocument[vec.size()]);
+        //remove duplicates
+        Vector uniqueSchemas = new Vector(schemaDocuments.length);
+        Vector uniqueSchemaTns = new Vector(schemaDocuments.length);
+        SchemaDocument.Schema s;
+        for (int i = 0; i < schemaDocuments.length; i++) {
+            s = schemaDocuments[i].getSchema();
+            if (!uniqueSchemaTns.contains(s.getTargetNamespace())) {
+                uniqueSchemas.add(s);
+                uniqueSchemaTns.add(s.getTargetNamespace());
+            }else if(s.getTargetNamespace()==null){
+                uniqueSchemas.add(s);
+            }
+        }
+        return (SchemaDocument.Schema[])
+                uniqueSchemas.toArray(
+                        new SchemaDocument.Schema[uniqueSchemas.size()]);
+    }
+
+    /**
+     * Implementation of the entity resolver
+     */
+    private static class Axis2EntityResolver implements EntityResolver {
+        private SchemaDocument[] schemas;
+        private String baseUri;
+
+        public Axis2EntityResolver() {
+        }
+
+        /**
+         * @see EntityResolver#resolveEntity(String, String)
+         * @param publicId  - this is the target namespace
+         * @param systemId  - this is the location (value of schemaLocation)
+         * @return
+         */
+        public InputSource resolveEntity(String publicId, String systemId) throws SAXException,IOException{
+            //System.out.println("Lookup:" + "[ " + publicId + "]" + "[" + systemId + "]");
+            try {
+                for (int i = 0; i < schemas.length; i++) {
+                    SchemaDocument.Schema schema = schemas[i].getSchema();
+                    if (schema.getTargetNamespace() != null &&
+                            publicId != null &&
+                            schema.getTargetNamespace().equals(publicId)) {
+                        try {
+                            return new InputSource(getSchemaAsStream(schemas[i]));
+                        } catch (IOException e) {
+                            throw new RuntimeException(e);
+                        }
+                    }
+                }
+                if(systemId.indexOf(':') == -1) {
+                    File f;
+                    if (baseUri!=null){
+                        f=new File(new URI(baseUri+systemId));
+                    }else{
+                        f = new File(systemId);
+                    }
+                    if(f.exists()) {
+                        try {
+                            return new InputSource(new FileInputStream(f));
+                        } catch (FileNotFoundException e) {
+                            throw new RuntimeException(e);
+                        }
+                    }
+
+                }
+                return XMLUtils.getEmptyInputSource();
+            } catch (URISyntaxException e) {
+               throw new SAXException(e);
+            }catch (Exception e){
+                throw new SAXException(e);
+            }
+        }
+
+        public SchemaDocument[]  getSchemas() {
+            return schemas;
+        }
+
+        public void setSchemas(SchemaDocument[] schemas) {
+            this.schemas = schemas;
+        }
+
+        public String getBaseUri() {
+            return baseUri;
+        }
+
+        public void setBaseUri(String baseUri) {
+            this.baseUri = baseUri;
+        }
+
+        /**
+         * Convert schema into a InputStream
+         *
+         * @param doc
+         */
+        private ByteArrayInputStream getSchemaAsStream(SchemaDocument schema) throws IOException {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            schema.save(baos);
+            baos.flush();
+            return new ByteArrayInputStream(baos.toByteArray());
+
+        }
+    }
 }
+
+
+