jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r383794 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java
Date Tue, 07 Mar 2006 06:01:58 GMT
Author: jukka
Date: Mon Mar  6 22:01:56 2006
New Revision: 383794

URL: http://svn.apache.org/viewcvs?rev=383794&view=rev
Log:
JCR-334: Use the DOM3 implementation registry instead of a direct reference to the Xerces
XMLSchemaLoader class, to avoid using the old Xerces 2.4.0 implementation that Maven 1.0.2
incorrectly puts in the class path.

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java?rev=383794&r1=383793&r2=383794&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/nodetype/SchemaConverter.java
Mon Mar  6 22:01:56 2006
@@ -8,12 +8,14 @@
 import org.apache.jackrabbit.core.nodetype.ValueConstraint;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.name.QName;
-import org.apache.xerces.impl.xs.XMLSchemaLoader;
+import org.apache.xerces.dom3.bootstrap.DOMImplementationRegistry;
 import org.apache.xerces.xs.XSAttributeDeclaration;
 import org.apache.xerces.xs.XSAttributeUse;
 import org.apache.xerces.xs.XSComplexTypeDefinition;
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSImplementation;
+import org.apache.xerces.xs.XSLoader;
 import org.apache.xerces.xs.XSModel;
 import org.apache.xerces.xs.XSModelGroup;
 import org.apache.xerces.xs.XSNamedMap;
@@ -23,6 +25,7 @@
 import org.apache.xerces.xs.XSTerm;
 import org.apache.xerces.xs.XSTypeDefinition;
 import org.apache.xerces.xs.XSWildcard;
+
 import javax.jcr.PropertyType;
 import javax.jcr.version.OnParentVersionAction;
 import java.io.File;
@@ -66,22 +69,37 @@
      * convertSchema
      */
     private void convertSchema(File file) throws SchemaConversionException {
-        XMLSchemaLoader loader = new XMLSchemaLoader();
-        String uri = file.toURI().toString();
-        XSModel xsModel = loader.loadURI(uri);
-
-        // Convert top level complex type definitions to node types
-        XSNamedMap map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
-        for (int i = 0; i < map.getLength(); i++) {
-            XSTypeDefinition tDef = (XSTypeDefinition) map.item(i);
-            checkAndConvert(tDef, null, null);
-        }
-        // Convert local (anonymous) complex type defs found in top level element declarations
-        map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
-        for (int i = 0; i < map.getLength(); i++) {
-            XSElementDeclaration eDec = (XSElementDeclaration) map.item(i);
-            XSTypeDefinition tDef = eDec.getTypeDefinition();
-            checkAndConvert(tDef, eDec.getNamespace(), eDec.getName());
+        try {
+            // Find an XMLSchema loader instance
+            DOMImplementationRegistry registry =
+                DOMImplementationRegistry.newInstance();
+            XSImplementation implementation = (XSImplementation)
+                registry.getDOMImplementation("XS-Loader");
+            XSLoader loader = implementation.createXSLoader(null);
+
+            // Load the XML Schema
+            String uri = file.toURI().toString();
+            XSModel xsModel = loader.loadURI(uri);
+
+            // Convert top level complex type definitions to node types
+            XSNamedMap map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
+            for (int i = 0; i < map.getLength(); i++) {
+                XSTypeDefinition tDef = (XSTypeDefinition) map.item(i);
+                checkAndConvert(tDef, null, null);
+            }
+            //  Convert local (anonymous) complex type defs found in top level element declarations
+            map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
+            for (int i = 0; i < map.getLength(); i++) {
+                XSElementDeclaration eDec = (XSElementDeclaration) map.item(i);
+                XSTypeDefinition tDef = eDec.getTypeDefinition();
+                checkAndConvert(tDef, eDec.getNamespace(), eDec.getName());
+            }
+        } catch (ClassNotFoundException e) {
+            throw new SchemaConversionException("XSLoader not found", e);
+        } catch (InstantiationException e) {
+            throw new SchemaConversionException("XSLoader instantiation error", e);
+        } catch (IllegalAccessException e) {
+            throw new SchemaConversionException("XSLoader access error", e);
         }
     }
 



Mime
View raw message