xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkro...@apache.org
Subject svn commit: r125554 - in xmlbeans/trunk: bin src/typeimpl/org/apache/xmlbeans/impl/schema src/xmlcomp/org/apache/xmlbeans/impl/tool src/xmlpublic/org/apache/xmlbeans
Date Tue, 18 Jan 2005 22:26:40 GMT
Author: kkrouse
Date: Tue Jan 18 14:26:38 2005
New Revision: 125554

URL: http://svn.apache.org/viewcvs?view=rev&rev=125554
Log:
intial checkin of partial schema type system support (experimental)

Added:
   xmlbeans/trunk/bin/xsdtree   (contents, props changed)
Modified:
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
   xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java
   xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java

Added: xmlbeans/trunk/bin/xsdtree
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/bin/xsdtree?view=auto&rev=125554
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/bin/xsdtree	Tue Jan 18 14:26:38 2005
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Invokes type hierarchy printer
+
+cp=
+cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar:$XMLBEANS_HOME/build/lib/jsr173_api.jar:$XMLBEANS_HOME/build/lib/resolver.jar
+
+case "`uname`" in
+    CYGWIN*)
+        cp=`cygpath -w -p $cp`
+        ;;
+esac
+
+java -Xmx256m -classpath $cp org.apache.xmlbeans.impl.tool.TypeHierarchyPrinter $*

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
Tue Jan 18 14:26:38 2005
@@ -15,6 +15,7 @@
 
 package org.apache.xmlbeans.impl.schema;
 
+import org.apache.xmlbeans.XmlBeans;
 import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlErrorCodes;
@@ -186,10 +187,10 @@
     /**
      * Please do not invoke this method directly as the signature could change unexpectedly.
      * Use one of
-     * {@link org.apache.xmlbeans.XmlBeans#loadXsd(org.apache.xmlbeans.XmlObject[])},
-     * {@link org.apache.xmlbeans.XmlBeans#compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader,
org.apache.xmlbeans.XmlOptions)},
+     * {@link XmlBeans#loadXsd(XmlObject[])},
+     * {@link XmlBeans#compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)},
      * or
-     * {@link org.apache.xmlbeans.XmlBeans#compileXmlBeans(String, org.apache.xmlbeans.SchemaTypeSystem,
org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.BindingConfig, org.apache.xmlbeans.SchemaTypeLoader,
org.apache.xmlbeans.Filer, org.apache.xmlbeans.XmlOptions)}
+     * {@link XmlBeans#compileXmlBeans(String, SchemaTypeSystem, XmlObject[], BindingConfig,
SchemaTypeLoader, Filer, XmlOptions)}
      */
     public static SchemaTypeSystemImpl compile(String name, SchemaTypeSystem existingSTS,
         XmlObject[] input, BindingConfig config, SchemaTypeLoader linkTo, Filer filer, XmlOptions
options)
@@ -207,7 +208,7 @@
                 else if (input[i] instanceof SchemaDocument && ((SchemaDocument)input[i]).getSchema()
!= null)
                     schemas.add(((SchemaDocument)input[i]).getSchema());
                 else
-                    throw new XmlException("Thread " + Thread.currentThread().getName() +
 ": The " + i + "th supplied input is not a schema or a config document: its type is " + input[i].schemaType());
+                    throw new XmlException("Thread " + Thread.currentThread().getName() +
 ": The " + i + "th supplied input is not a schema document: its type is " + input[i].schemaType());
             }
         }
 
@@ -218,12 +219,13 @@
             (Schema[])schemas.toArray(new Schema[schemas.size()]),
             config, linkTo, options, errorWatcher, filer!=null, null, null, null);
 
-        if (errorWatcher.hasError())
+        // if there is an error and compile didn't recover (stsi==null), throw exception
+        if (errorWatcher.hasError() && stsi == null)
         {
             throw new XmlException(errorWatcher.firstError());
         }
 
-        if (stsi != null && filer != null)
+        if (stsi != null && !stsi.isPartial() && filer != null)
         {
             stsi.save(filer);
             generateTypes(stsi, filer, options);
@@ -314,9 +316,20 @@
             if (sourcesToCopyMap != null)
                 sourcesToCopyMap.putAll(state.sourceCopyMap());
 
-            // if any errors, return null
             if (errorWatcher.hasError())
-                return null;
+            {
+                // EXPERIMENTAL: recovery from compilation errors and partial type system
+                if (state.allowPartial() && state.getRecovered() == errorWatcher.size())
+                {
+                    // if partial type system allowed and all errors were recovered
+                    state.get().sts().setPartial(true);
+                }
+                else
+                {
+                    // if any non-recoverable errors, return null
+                    return null;
+                }
+            }
 
             return state.get().sts();
         }
@@ -410,6 +423,10 @@
      */
     public static boolean generateTypes(SchemaTypeSystem system, Filer filer, XmlOptions
options)
     {
+        // partial type systems not allowed to be saved
+        if (system instanceof SchemaTypeSystemImpl && ((SchemaTypeSystemImpl)system).isPartial())
+            return false;
+        
         boolean success = true;
 
         List types = new ArrayList();

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Tue Jan 18 14:26:38 2005
@@ -946,6 +946,12 @@
 
     SchemaDependencies getDependencies()
     {   return _deps; }
+    
+    // EXPERIMENTAL
+    public boolean isPartial() { return _partial; }
+    
+    // EXPERIMENTAL
+    void setPartial(boolean partial) { _partial = partial; }
 
     static class StringPool
     {
@@ -1209,6 +1215,9 @@
 
     private String _name;
     private String _basePackage;
+    
+    // EXPERIMENTAL: recovery from compilation errors and partial type systems
+    private boolean _partial = false;
 
     // classloader is available for sts's that were compiled and loaded, not dynamic ones
     private ClassLoader _classloader;
@@ -1256,11 +1265,16 @@
 
     public void saveToDirectory(File classDir)
     {
+        if (_partial)
+            return;
         save(new FilerImpl(classDir, null, null, false, false));
     }
 
     public void save(Filer filer)
     {
+        if (_partial)
+            return;
+        
         if (filer == null)
             throw new IllegalArgumentException("filer must not be null");
         _filer = filer;
@@ -1298,6 +1312,8 @@
 
     public void saveGlobalElements(SchemaGlobalElement[] elts)
     {
+        if (_partial)
+            return;
         for (int i = 0; i < elts.length; i++)
         {
             saveGlobalElement(elts[i]);
@@ -1306,6 +1322,8 @@
 
     public void saveGlobalAttributes(SchemaGlobalAttribute[] attrs)
     {
+        if (_partial)
+            return;
         for (int i = 0; i < attrs.length; i++)
         {
             saveGlobalAttribute(attrs[i]);
@@ -1314,6 +1332,8 @@
 
     public void saveModelGroups(SchemaModelGroup[] groups)
     {
+        if (_partial)
+            return;
         for (int i = 0; i < groups.length; i++)
         {
             saveModelGroup(groups[i]);
@@ -1322,6 +1342,8 @@
 
     public void saveAttributeGroups(SchemaAttributeGroup[] groups)
     {
+        if (_partial)
+            return;
         for (int i = 0; i < groups.length; i++)
         {
             saveAttributeGroup(groups[i]);
@@ -1330,6 +1352,8 @@
 
     public void saveIdentityConstraints(SchemaIdentityConstraint[] idcs)
     {
+        if (_partial)
+            return;
         for (int i = 0; i < idcs.length; i++)
         {
             saveIdentityConstraint(idcs[i]);
@@ -1338,6 +1362,8 @@
 
     public void saveGlobalElement(SchemaGlobalElement elt)
     {
+        if (_partial)
+            return;
         String handle = _localHandles.handleForElement(elt);
         XsbReader saver = new XsbReader(handle);
         saver.writeParticleData((SchemaParticle)elt);
@@ -1350,6 +1376,8 @@
 
     public void saveGlobalAttribute(SchemaGlobalAttribute attr)
     {
+        if (_partial)
+            return;
         String handle = _localHandles.handleForAttribute(attr);
         XsbReader saver = new XsbReader(handle);
         saver.writeAttributeData(attr);
@@ -1362,6 +1390,8 @@
 
     public void saveModelGroup(SchemaModelGroup grp)
     {
+        if (_partial)
+            return;
         String handle = _localHandles.handleForModelGroup(grp);
         XsbReader saver = new XsbReader(handle);
         saver.writeModelGroupData(grp);
@@ -1372,6 +1402,8 @@
 
     public void saveAttributeGroup(SchemaAttributeGroup grp)
     {
+        if (_partial)
+            return;
         String handle = _localHandles.handleForAttributeGroup(grp);
         XsbReader saver = new XsbReader(handle);
         saver.writeAttributeGroupData(grp);
@@ -1382,6 +1414,8 @@
 
     public void saveIdentityConstraint(SchemaIdentityConstraint idc)
     {
+        if (_partial)
+            return;
         String handle = _localHandles.handleForIdentityConstraint(idc);
         XsbReader saver = new XsbReader(handle);
         saver.writeIdConstraintData(idc);

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
Tue Jan 18 14:26:38 2005
@@ -381,7 +381,7 @@
             }
             
             if (baseType == null)
-                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase());
+                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase(),
true);
         }
 
         if (baseType == null)
@@ -509,7 +509,7 @@
                 baseType = state.findGlobalType(parseTree.getBase(), sImpl.getChameleonNamespace(),
targetNamespace);
             }
             if (baseType == null)
-                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase());
+                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase(),
true);
         }
 
         // Recursion
@@ -521,7 +521,7 @@
 
         if (baseType != null && (baseType.isSimpleType() || baseType.getContentType()
== SchemaType.SIMPLE_CONTENT))
         {
-            state.error(XmlErrorCodes.SCHEMA_COMPLEX_TYPE$COMPLEX_CONTENT,
+            state.recover(XmlErrorCodes.SCHEMA_COMPLEX_TYPE$COMPLEX_CONTENT,
                 new Object[] { QNameHelper.pretty(baseType.getName()) },
                 parseTree.xgetBase());
             baseType = null; // recovery: no inheritance.
@@ -655,7 +655,7 @@
             }
             if (baseType == null)
             {
-                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase());
+                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase(),
true);
                 // recovery: extends ANY_SIMPLE type
                 baseType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
             }
@@ -667,7 +667,7 @@
         if (baseType.isSimpleType())
         {
             // src-ct.2: complex types with simple content cannot restrict simple types
-            state.error(XmlErrorCodes.COMPLEX_TYPE_PROPERTIES$SIMPLE_TYPE_EXTENSION,
+            state.recover(XmlErrorCodes.COMPLEX_TYPE_PROPERTIES$SIMPLE_TYPE_EXTENSION,
                 new Object[] { QNameHelper.pretty(baseType.getName()) },
                 parseTree);
             // recovery: extends ANY_SIMPLE type
@@ -776,7 +776,7 @@
             }
             if (baseType == null)
             {
-                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase());
+                state.notFoundError(parseTree.getBase(), SchemaType.TYPE, parseTree.xgetBase(),
true);
                 // recovery: extends ANY_SIMPLE type
                 baseType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
             }
@@ -1066,7 +1066,7 @@
                     }
                     if (group == null)
                     {
-                        state.notFoundError(ref, SchemaType.ATTRIBUTE_GROUP, xsdag.xgetRef());
+                        state.notFoundError(ref, SchemaType.ATTRIBUTE_GROUP, xsdag.xgetRef(),
false);
                         continue;
                     }
                     if (state.isProcessing(group))
@@ -1284,7 +1284,7 @@
                 }
                 if (group == null)
                 {
-                    state.notFoundError(ref, SchemaType.MODEL_GROUP, ((Group)parseTree).xgetRef());
+                    state.notFoundError(ref, SchemaType.MODEL_GROUP, ((Group)parseTree).xgetRef(),
false);
                     return null;
                 }
                 if (state.isProcessing(group))

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscResolver.java	Tue Jan
18 14:26:38 2005
@@ -118,7 +118,7 @@
                 sImpl.getChameleonNamespace(), sImpl.getTargetNamespace());
 
             if (substitutionGroup == null)
-                StscState.get().notFoundError(elt.getSubstitutionGroup(), SchemaType.ELEMENT,
elt.xgetSubstitutionGroup());
+                StscState.get().notFoundError(elt.getSubstitutionGroup(), SchemaType.ELEMENT,
elt.xgetSubstitutionGroup(), true);
                 // recovery - ignore substitution group
             else if (! resolveSubstitutionGroup(substitutionGroup) )
                 substitutionGroup = null;
@@ -282,7 +282,7 @@
                 key = state.findIdConstraint(keyName, idcs[i].getChameleonNamespace(), idcs[i].getTargetNamespace());
                 if (key == null)
                 {
-                    state.notFoundError(keyName, SchemaType.IDENTITY_CONSTRAINT, xsdkr);
+                    state.notFoundError(keyName, SchemaType.IDENTITY_CONSTRAINT, xsdkr, true);
                 }
                 else 
                 {

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
Tue Jan 18 14:26:38 2005
@@ -200,7 +200,7 @@
             errorLoc = parseList.xgetItemType();
             if (itemImpl == null)
             {
-                state.notFoundError(itemName, SchemaType.TYPE, parseList.xgetItemType());
+                state.notFoundError(itemName, SchemaType.TYPE, parseList.xgetItemType(),
true);
                 // recovery: treat it as a list of anySimpleType
                 itemImpl = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
             }
@@ -307,7 +307,7 @@
                 SchemaTypeImpl memberImpl = state.findGlobalType(mName, sImpl.getChameleonNamespace(),
sImpl.getTargetNamespace());
                 if (memberImpl == null)
                     // recovery: skip member
-                    state.notFoundError(mName, SchemaType.TYPE, parseUnion.xgetMemberTypes());
+                    state.notFoundError(mName, SchemaType.TYPE, parseUnion.xgetMemberTypes(),
true);
                 else
                     memberImplList.add(memberImpl);
             }
@@ -443,7 +443,7 @@
             }
             if (baseImpl == null)
             {
-                state.notFoundError(baseName, SchemaType.TYPE, parseRestr.xgetBase());
+                state.notFoundError(baseName, SchemaType.TYPE, parseRestr.xgetBase(), true);
                 // recovery: treat it as an extension of anySimpleType
                 baseImpl = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
             }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java	Tue Jan 18
14:26:38 2005
@@ -61,6 +61,10 @@
     private boolean _doingDownloads;
     private byte[] _digest = null;
     private boolean _noDigest = false;
+    
+    // EXPERIMENTAL: recovery from compilation errors and partial type systems
+    private boolean _allowPartial = false;
+    private int _recoveredErrors = 0;
 
     private SchemaTypeLoader _importingLoader;
 
@@ -292,20 +296,26 @@
         { _errorListener = errorListener; }
 
     /**
-     * Passes an error on to the current XmlErrorCodes.
+     * Passes an error on to the current error listener.
      * KHK: remove this
      */
     public void error(String message, int code, XmlObject loc)
         { addError(_errorListener, message, code, loc); }
 
     /**
-     * Passes an error on to the current XmlErrorCodes.
+     * Passes an error on to the current error listener.
      */
     public void error(String code, Object[] args, XmlObject loc)
-    { addError(_errorListener, code, args, loc); }
-
+        { addError(_errorListener, code, args, loc); }
+    
+    /**
+     * Passes a recovered error on to the current error listener.
+     */
+    public void recover(String code, Object[] args, XmlObject loc)
+        { addError(_errorListener, code, args, loc); _recoveredErrors++; }
+    
     /**
-     * Passes an error on to the current XmlErrorCodes.
+     * Passes an error on to the current error listener.
      */
     public void warning(String message, int code, XmlObject loc)
     {
@@ -313,7 +323,7 @@
     }
 
     /**
-     * Passes an error on to the current XmlErrorCodes.
+     * Passes an error on to the current error listener.
      */
     public void warning(String code, Object[] args, XmlObject loc)
     {
@@ -327,13 +337,13 @@
     }
 
     /**
-     * Passes a warning on to the current XmlErrorCodes.
+     * Passes a warning on to the current error listener.
      */
     public void info(String message)
         { addInfo(_errorListener, message); }
 
     /**
-     * Passes a warning on to the current XmlErrorCodes.
+     * Passes a warning on to the current error listener.
      */
     public void info(String code, Object[] args)
         { addInfo(_errorListener, code, args); }
@@ -359,7 +369,7 @@
               location);
         errorListener.add(err);
     }
-
+    
     public static void addError(Collection errorListener, String code, Object[] args, File
location)
     {
         XmlError err =
@@ -497,6 +507,8 @@
             return; // defaults are all false.
         }
 
+        _allowPartial = options.hasOption("COMPILE_PARTIAL_TYPESYSTEM");
+        
         _compatMap = (Map)options.get(XmlOptions.COMPILE_SUBSTITUTE_NAMES);
         _noUpa = options.hasOption(XmlOptions.COMPILE_NO_UPA_RULE) ? true :
                 !"true".equals(System.getProperty("xmlbean.uniqueparticleattribution", "true"));
@@ -513,7 +525,7 @@
 
         if (_entityResolver != null)
             _doingDownloads = true;
-
+        
         if (options.hasOption(XmlOptions.COMPILE_MDEF_NAMESPACES))
         {
             _mdefNamespaces.addAll((Collection)options.get(XmlOptions.COMPILE_MDEF_NAMESPACES));
@@ -559,7 +571,25 @@
     {
         return _noAnn;
     }
-
+    
+    /**
+     * True if a partial SchemaTypeSystem should be produced
+     */
+    // EXPERIMENTAL
+    public boolean allowPartial()
+    {
+        return _allowPartial;
+    }
+    
+    /**
+     * Get count of recovered errors. Not for public.
+     */ 
+    // EXPERIMENTAL
+    public int getRecovered()
+    {
+        return _recoveredErrors;
+    }
+    
     /**
      * Intercepts XML names and translates them
      * through the compat map, if any.
@@ -1220,13 +1250,16 @@
         }
     }
 
-    public void notFoundError(QName itemName, int code, XmlObject loc)
+    public void notFoundError(QName itemName, int code, XmlObject loc, boolean recovered)
     {
         String expected;
         String expectedName = QNameHelper.pretty(itemName);
         String found = null;
         String foundName = null;
         String sourceName = null;
+        
+        if (recovered)
+            _recoveredErrors++;
 
         switch (code)
         {

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java&r1=125553&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java	Tue Jan
18 14:26:38 2005
@@ -643,7 +643,7 @@
             SchemaGlobalElement referenced = state.findGlobalElement(ref, chameleon ? targetNamespace
: null, targetNamespace);
             if (referenced == null)
             {
-                state.notFoundError(ref, SchemaType.ELEMENT, xsdElt.xgetRef());
+                state.notFoundError(ref, SchemaType.ELEMENT, xsdElt.xgetRef(), true);
                 // recovery: ignore this element
                 return null;
             }
@@ -731,7 +731,7 @@
         {
             sType = state.findGlobalType(xsdElt.getType(), chameleon ? targetNamespace :
null, targetNamespace );
             if (sType == null)
-                state.notFoundError(xsdElt.getType(), SchemaType.TYPE, xsdElt.xgetType());
+                state.notFoundError(xsdElt.getType(), SchemaType.TYPE, xsdElt.xgetType(),
true);
         }
 
         boolean simpleTypedef = false;
@@ -1080,7 +1080,7 @@
             SchemaGlobalAttribute referenced = state.findGlobalAttribute(ref, chameleon ?
targetNamespace : null, targetNamespace);
             if (referenced == null)
             {
-                state.notFoundError(ref, SchemaType.ATTRIBUTE, xsdAttr.xgetRef());
+                state.notFoundError(ref, SchemaType.ATTRIBUTE, xsdAttr.xgetRef(), true);
                 // recovery: ignore this element
                 return null;
             }
@@ -1117,7 +1117,7 @@
             {
                 sType = state.findGlobalType(xsdAttr.getType(), chameleon ? targetNamespace
: null, targetNamespace );
                 if (sType == null)
-                    state.notFoundError(xsdAttr.getType(), SchemaType.TYPE, xsdAttr.xgetType());
+                    state.notFoundError(xsdAttr.getType(), SchemaType.TYPE, xsdAttr.xgetType(),
true);
             }
 
             if (qname.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema-instance"))

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java&r1=125553&p2=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java	(original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/InstanceValidator.java	Tue Jan
18 14:26:38 2005
@@ -40,6 +40,7 @@
         System.out.println("    -dl    enable network downloads for imports and includes");
         System.out.println("    -nopvr disable particle valid (restriction) rule");
         System.out.println("    -noupa diable unique particle attributeion rule");
+        System.out.println("    -partial allow partial schema type system");
         System.out.println("    -license prints license information");
     }
 
@@ -54,6 +55,7 @@
         flags.add("dl");
         flags.add("noupa");
         flags.add("nopvr");
+        flags.add("partial");
 
         CommandLine cl = new CommandLine(args, flags, Collections.EMPTY_SET);
 
@@ -96,6 +98,7 @@
         boolean dl = (cl.getOpt("dl") != null);
         boolean nopvr = (cl.getOpt("nopvr") != null);
         boolean noupa = (cl.getOpt("noupa") != null);
+        boolean partial = (cl.getOpt("partial") != null);
         
         File[] schemaFiles = cl.filesEndingWith(".xsd");
         File[] instanceFiles = cl.filesEndingWith(".xml");
@@ -129,6 +132,8 @@
             schemaOptions.setCompileNoPvrRule();
         if (noupa)
             schemaOptions.setCompileNoUpaRule();
+        if (partial)
+            schemaOptions.put("COMPILE_PARTIAL_TYPESYSTEM");
         
         try
         {
@@ -140,10 +145,18 @@
             {
                 e.printStackTrace(System.err);
             }
-            System.out.println("Schema invalid");
+            System.out.println("Schema invalid:" + (partial ? " couldn't recover from errors"
: ""));
             for (Iterator i = compErrors.iterator(); i.hasNext(); )
                 System.out.println(i.next());
             return;
+        }
+        
+        // recovered from errors, print out errors
+        if (partial && !compErrors.isEmpty())
+        {
+            System.out.println("Schema invalid: partial schema type system recovered");
+            for (Iterator i = compErrors.iterator(); i.hasNext(); )
+                System.out.println(i.next());
         }
         
         for (int i = 0; i < instanceFiles.length; i++)

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java?view=diff&rev=125554&p1=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java&r1=125553&p2=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java	(original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/TypeHierarchyPrinter.java	Tue
Jan 18 14:26:38 2005
@@ -42,7 +42,7 @@
     public static void printUsage()
     {
         System.out.println("Prints inheritance hierarchy of types defined in a schema.");
-        System.out.println("Usage: xsdtree [-noanon] [-nopvr] [-noupa] [-license] file1.xsd
file2.xsd ...");
+        System.out.println("Usage: xsdtree [-noanon] [-nopvr] [-noupa] [-partial] [-license]
file1.xsd file2.xsd ...");
     }
 
     public static void main(String[] args) throws Exception
@@ -56,6 +56,7 @@
         flags.add("noanon");
         flags.add("noupr");
         flags.add("noupa");
+        flags.add("partial");
 
         CommandLine cl = new CommandLine(args, flags, Collections.EMPTY_SET);
         if (cl.getOpt("h") != null || cl.getOpt("help") != null || cl.getOpt("usage") !=
null)
@@ -98,6 +99,7 @@
         boolean noanon = (cl.getOpt("noanon") != null);
         boolean nopvr = (cl.getOpt("nopvr") != null);
         boolean noupa = (cl.getOpt("noupa") != null);
+        boolean partial = (cl.getOpt("partial") != null);
         
         File[] schemaFiles = cl.getFiles();
         
@@ -130,6 +132,8 @@
             schemaOptions.setCompileNoPvrRule();
         if (noupa)
             schemaOptions.setCompileNoUpaRule();
+        if (partial)
+            schemaOptions.put("COMPILE_PARTIAL_TYPESYSTEM");
         
         try
         {
@@ -137,12 +141,20 @@
         }
         catch (XmlException e)
         {
-            System.out.println("Schema invalid");
+            System.out.println("Schema invalid:" + (partial ? " couldn't recover from errors"
: ""));
             if (compErrors.isEmpty())
                 System.out.println(e.getMessage());
             else for (Iterator i = compErrors.iterator(); i.hasNext(); )
                 System.out.println(i.next());
             return;
+        }
+        
+        // step 2.5: recovered from errors, print out errors
+        if (partial && !compErrors.isEmpty())
+        {
+            System.out.println("Schema invalid: partial schema type system recovered");
+            for (Iterator i = compErrors.iterator(); i.hasNext(); )
+                System.out.println(i.next());
         }
         
         // step 3: go through all the types, and note their base types and namespaces

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&rev=125554&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java&r1=125553&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java&r2=125554
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java	Tue Jan 18 14:26:38 2005
@@ -586,7 +586,8 @@
      * A randomly generated name will be used if the name is null.</p>
      *
      * <p>The optional {@link BindingConfig} argument is used to control the shape
-     * of the generated code.</p>
+     * of the generated code. A <code>BindingConfig</code> isn't used if <code>Filer</code>
+     * is null.</p>
      *
      * <p>The optional SchemaTypeLoader argument will be
      * consulted for already-compiled schema types which may be linked

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


Mime
View raw message