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 2006/11/05 01:00:39 UTC

svn commit: r471299 - in /xmlbeans/trunk: build.xml src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java

Author: radup
Date: Sat Nov  4 16:00:38 2006
New Revision: 471299

URL: http://svn.apache.org/viewvc?view=rev&rev=471299
Log:
Improved handling of errors during typesystem loading. 
Fixed bug during type generation of complex types with simpe content.

Modified:
    xmlbeans/trunk/build.xml
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java

Modified: xmlbeans/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/build.xml?view=diff&rev=471299&r1=471298&r2=471299
==============================================================================
--- xmlbeans/trunk/build.xml (original)
+++ xmlbeans/trunk/build.xml Sat Nov  4 16:00:38 2006
@@ -754,7 +754,7 @@
 
     <target name="xsdschema.check">
         <condition property="xsdschema.notRequired">
-            <uptodate property="xsdschema.notRequired" targetfile="build/classes/xsdschema/schema/system/sXMLSCHEMA/index.xsb">
+            <uptodate property="xsdschema.notRequired" targetfile="build/classes/xsdschema">
                 <srcfiles dir="src/xsdschema" includes="**/*.xsd*"/>
             </uptodate>
         </condition>
@@ -778,7 +778,7 @@
          ant "replace" mechanism is too difficult to use to be worth it -->
     <target name="xmlschema.check">
         <condition property="xmlschema.notRequired">
-            <uptodate property="xmlschema.notRequired" targetfile="build/classes/xmlschema/schema/system/sXMLLANG/index.xsb">
+            <uptodate property="xmlschema.notRequired" targetfile="build/classes/xmlschema">
                 <srcfiles dir="src/xmlschema" includes="**/*.xsd*"/>
             </uptodate>
         </condition>
@@ -814,7 +814,7 @@
     <property name="bootstrap.compile.path" refid="bootstrap.compile.path"/>
 
     <target name="configschema.check">
-        <uptodate property="configschema.notRequired" targetfile="build/classes/configschema/schema/system/sXMLCONFIG/index.xsb">
+        <uptodate property="configschema.notRequired" targetfile="build/classes/configschema">
             <srcfiles dir="src/configschema" includes="**/*.xsd"/>
         </uptodate>
     </target>
@@ -835,7 +835,7 @@
     <property name="bootstrap.compile.path" refid="bootstrap.compile.path"/>
 
     <target name="toolschema.check">
-        <uptodate property="toolschema.notRequired" targetfile="build/classes/toolschema/schema/system/sXMLTOOLS/index.xsb">
+        <uptodate property="toolschema.notRequired" targetfile="build/classes/toolschema">
             <srcfiles dir="src/toolschema" includes="**/*.xsd"/>
         </uptodate>
     </target>

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?view=diff&rev=471299&r1=471298&r2=471299
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java Sat Nov  4 16:00:38 2006
@@ -21,13 +21,11 @@
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Iterator;
 
 import javax.xml.namespace.QName;
 import org.apache.xmlbeans.impl.common.NameUtil;
@@ -2437,8 +2435,33 @@
                 // in order to handle the case (for ints or string enums e.g.) where
                 // there is a simple type restriction.  So property getters need to
                 // be implemented "from scratch" for each derived complex type
+                // Moreover, attribute or element properties can be removed via restriction,
+                // but we still need to implement them because this class is supposed to
+                // also implement all the interfaces
+                SchemaType baseType = sType.getBaseType();
+                List extraProperties = null;
+                while (!baseType.isSimpleType() && !baseType.isBuiltinType())
+                {
+                    SchemaProperty[] baseProperties = baseType.getDerivedProperties();
+                    for (int i = 0; i < baseProperties.length; i++)
+                        if (!(baseProperties[i].isAttribute() &&
+                                sType.getAttributeProperty(baseProperties[i].getName()) != null))
+                        {
+                            if (extraProperties == null)
+                                extraProperties = new ArrayList();
+                            extraProperties.add(baseProperties[i]);
+                        }
+                    baseType = baseType.getBaseType();
+                }
 
                 properties = sType.getProperties();
+                if (extraProperties != null)
+                {
+                    for (int i = 0; i < properties.length; i++)
+                        extraProperties.add(properties[i]);
+                    properties = (SchemaProperty[]) extraProperties.
+                        toArray(new SchemaProperty[extraProperties.size()]);
+                }
             }
             else
             {

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?view=diff&rev=471299&r1=471298&r2=471299
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java Sat Nov  4 16:00:38 2006
@@ -180,7 +180,20 @@
         _classloader = indexclass.getClassLoader();
         _linker = SchemaTypeLoaderImpl.build(null, null, _classloader);
         _resourceLoader = new ClassLoaderResourceLoader(_classloader);
-        initFromHeader();
+        try
+        {
+            initFromHeader();
+        }
+        catch (RuntimeException e)
+        {
+            XBeanDebug.logException(e);
+            throw e;
+        }
+        catch (Error e)
+        {
+            XBeanDebug.logException(e);
+            throw e;
+        }
         XBeanDebug.trace(XBeanDebug.TRACE_SCHEMA_LOADING, "Finished loading type system " + _name, -1);
     }
 
@@ -2227,6 +2240,16 @@
             return _resourceLoader.getResourceAsStream(resourcename);
         }
 
+        void checkContainerNotNull(SchemaContainer container, QName name)
+        {
+            if (container == null)
+            {
+                throw new LinkageError("Loading of resource " + _name + '.' + _handle +
+                    "failed, information from " + _name + ".index.xsb is " +
+                    " out of sync (or conflicting index files found)");
+            }
+        }
+
         /**
          * Finishes loading an element after the header has already been loaded.
          */
@@ -2244,7 +2267,7 @@
                 QNameSet transitionRules = readQNameSet();
                 QName name = readQName();
                 SchemaContainer container = getContainer(name.getNamespaceURI());
-                assert container != null;
+                checkContainerNotNull(container, name);
                 SchemaGlobalElementImpl impl = new SchemaGlobalElementImpl(container);
                 impl.setParticleType(particleType);
                 impl.setMinOccurs(minOccurs);
@@ -2303,7 +2326,7 @@
             {
                 QName name = readQName();
                 SchemaContainer container = getContainer(name.getNamespaceURI());
-                assert container != null;
+                checkContainerNotNull(container, name);
                 SchemaGlobalAttributeImpl impl = new SchemaGlobalAttributeImpl(container);
                 loadAttribute(impl, name, container);
                 impl.setFilename(readString());
@@ -2328,7 +2351,7 @@
         {
             QName name = readQName();
             SchemaContainer container = getContainer(name.getNamespaceURI());
-            assert container != null;
+            checkContainerNotNull(container, name);
             SchemaModelGroupImpl impl = new SchemaModelGroupImpl(container);
 
             try
@@ -2361,7 +2384,7 @@
             try {
                 QName name = readQName();
                 SchemaContainer container = getContainer(name.getNamespaceURI());
-                assert container != null;
+                checkContainerNotNull(container, name);
                 SchemaIdentityConstraintImpl impl = new SchemaIdentityConstraintImpl(container);
                 impl.setName(name);
                 impl.setConstraintCategory(readShort());
@@ -2409,7 +2432,7 @@
         {
             QName name = readQName();
             SchemaContainer container = getContainer(name.getNamespaceURI());
-            assert container != null;
+            checkContainerNotNull(container, name);
             SchemaAttributeGroupImpl impl = new SchemaAttributeGroupImpl(container);
 
             try
@@ -2642,7 +2665,7 @@
                 if (impl.getName() != null)
                 {
                     SchemaContainer container = getContainer(impl.getName().getNamespaceURI());
-                    assert container != null;
+                    checkContainerNotNull(container, impl.getName());
                     impl.setContainer(container);
                 }
                 else if (impl.isDocumentType())
@@ -2651,7 +2674,7 @@
                     if (name != null)
                     {
                         SchemaContainer container = getContainer(name.getNamespaceURI());
-                        assert container != null;
+                        checkContainerNotNull(container, name);
                         impl.setContainer(container);
                     }
                 }
@@ -2661,7 +2684,7 @@
                     if (name != null)
                     {
                         SchemaContainer container = getContainer(name.getNamespaceURI());
-                        assert container != null;
+                        checkContainerNotNull(container, name);
                         impl.setContainer(container);
                     }
                 }



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