You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ra...@apache.org on 2005/04/06 05:20:38 UTC

svn commit: r160250 - in xmlbeans/trunk/src: typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java xmlpublic/org/apache/xmlbeans/XmlBeans.java

Author: radup
Date: Tue Apr  5 20:20:36 2005
New Revision: 160250

URL: http://svn.apache.org/viewcvs?view=rev&rev=160250
Log:
Fixed a few NPEs.
Made some changes to our URI resolver to better handle references from Schemas inside jar and zip files.

Modified:
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java?view=diff&r1=160249&r2=160250
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaParticleImpl.java Tue Apr  5 20:20:36 2005
@@ -123,6 +123,13 @@
 
     public SchemaParticle[] getParticleChildren()
     {
+        if (_particleChildren == null)
+        {
+            assert _particleType != SchemaParticle.ALL &&
+                _particleType != SchemaParticle.SEQUENCE &&
+                _particleType != SchemaParticle.CHOICE;
+            return null;
+        }
         SchemaParticle[] result = new SchemaParticle[_particleChildren.length];
         System.arraycopy(_particleChildren, 0, result, 0, _particleChildren.length);
         return result;

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?view=diff&r1=160249&r2=160250
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java Tue Apr  5 20:20:36 2005
@@ -974,8 +974,11 @@
                 return "java.util.Calendar";
 
             case SchemaProperty.JAVA_ENUM:
-                SchemaType sType = sProp.javaBasedOnType().getBaseEnumType();
-                return findJavaType(sType).replace('$', '.') + ".Enum";
+                SchemaType sType = sProp.javaBasedOnType();
+                if (sType.getSimpleVariety() == SchemaType.UNION)
+                    sType = sType.getUnionCommonBaseType();
+                assert sType.getBaseEnumType() != null;
+                return findJavaType(sType.getBaseEnumType()).replace('$', '.') + ".Enum";
 
             case SchemaProperty.JAVA_OBJECT:
                 return "java.lang.Object";

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java?view=diff&r1=160249&r2=160250
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java Tue Apr  5 20:20:36 2005
@@ -257,7 +257,7 @@
     }
 
     //workaround for Sun bug # 4723726
-    private static URI resolve(URI base, String child)
+    public static URI resolve(URI base, String child)
         throws URISyntaxException
     {
         URI childUri = new URI(child);
@@ -268,11 +268,26 @@
         // URI is pointing at something nested inside a jar, we seem to have
         // to this ourselves to make sure that the nested jar url gets
         // resolved correctly
-        if (childUri.equals(ruri) &&
+        if (childUri.equals(ruri) && !childUri.isAbsolute() &&
           (base.getScheme().equals("jar") || base.getScheme().equals("zip"))) {
             String r = base.toString();
             int lastslash = r.lastIndexOf('/');
             r = r.substring(0,lastslash) + "/" + childUri;
+            // Sun's implementation of URI doesn't support references to the
+            // parent directory ("/..") in the part after "!/" so we have to
+            // remove these ourselves
+            int slashDotDotIndex = r.lastIndexOf("/..");
+            int exclPointSlashIndex = r.lastIndexOf("!/");
+            while (slashDotDotIndex >= 0 && slashDotDotIndex > exclPointSlashIndex)
+            {
+                int prevSlashIndex = r.lastIndexOf("/", slashDotDotIndex - 1);
+                if (prevSlashIndex >= exclPointSlashIndex)
+                {
+                    String temp = r.substring(slashDotDotIndex + 3);
+                    r = r.substring(0, prevSlashIndex).concat(temp);
+                }
+                slashDotDotIndex = r.lastIndexOf("/..");
+            }
             return URI.create(r);
         }
 

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java?view=diff&r1=160249&r2=160250
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Tue Apr  5 20:20:36 2005
@@ -530,7 +530,7 @@
      */
     public static SchemaTypeSystem compileXsd(XmlObject[] schemas, SchemaTypeLoader typepath, XmlOptions options) throws XmlException
     {
-        return compileXmlBeans(null, null, schemas, null, typepath!=null ? typepath : getContextTypeLoader(), null, options);
+        return compileXmlBeans(null, null, schemas, null, typepath, null, options);
     }
 
     /**
@@ -578,7 +578,7 @@
      */
     public static SchemaTypeSystem compileXsd(SchemaTypeSystem system, XmlObject[] schemas, SchemaTypeLoader typepath, XmlOptions options) throws XmlException
     {
-        return compileXmlBeans(null, system, schemas, null, typepath != null ? typepath : getContextTypeLoader(), null, options);
+        return compileXmlBeans(null, system, schemas, null, typepath, null, options);
     }
 
     /**
@@ -611,7 +611,8 @@
      *
      * <p>The optional SchemaTypeLoader argument will be
      * consulted for already-compiled schema types which may be linked
-     * while processing the given schemas.</p>
+     * while processing the given schemas. If not specified, the context
+     * typeloader (as returned by {@link #getContextTypeLoader}) will be used.</p>
      *
      * <p>The optional {@link Filer} argument is used to create new binary or source
      * files which are the product of the compilation.  If the Filer is null, the
@@ -646,7 +647,7 @@
 
         try
         {
-            return (SchemaTypeSystem)_compilationMethod.invoke(null, new Object[] { name, system, schemas, config, typepath, filer, options });
+            return (SchemaTypeSystem)_compilationMethod.invoke(null, new Object[] { name, system, schemas, config, typepath != null ? typepath : getContextTypeLoader(), filer, options });
         }
         catch (IllegalAccessException e)
         {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org