xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r124560 - in xmlbeans/trunk: external/lib src/newstore2/org/apache/xmlbeans/impl/newstore2 src/typeimpl/org/apache/xmlbeans/impl/schema src/typeimpl/org/apache/xmlbeans/impl/validator src/typeimpl/org/apache/xmlbeans/impl/values src/typestore/org/apache/xmlbeans/impl/values src/xmlcomp/org/apache/xmlbeans/impl/tool src/xmlpublic/org/apache/xmlbeans
Date Fri, 07 Jan 2005 19:07:37 GMT
Author: radup
Date: Fri Jan  7 11:07:35 2005
New Revision: 124560

URL: http://svn.apache.org/viewcvs?view=rev&rev=124560
Log:
Three new features:
- XmlObject.substitute() method to simplify working with substitution groups
- "-noVDoc" command-line option for scomp to skip validation of <xs:documentation> contents
- uniform access to the getSourceName() method in Schema Object Model

Modified:
   xmlbeans/trunk/external/lib/oldxbean.jar
   xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java
   xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java
   xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java
   xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java
   xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
   xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java
   xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java

Modified: xmlbeans/trunk/external/lib/oldxbean.jar
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/external/lib/oldxbean.jar?view=diff&rev=124560&p1=xmlbeans/trunk/external/lib/oldxbean.jar&r1=124559&p2=xmlbeans/trunk/external/lib/oldxbean.jar&r2=124560
==============================================================================
Binary files. No diff available.

Modified: xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java&r1=124559&p2=xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java	(original)
+++ xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Cur.java	Fri Jan  7 11:07:35
2005
@@ -2492,6 +2492,87 @@
         setAttrValueAsQName( Locale._xsiType, typeName );
     }
 
+    void setSubstitution ( QName name, SchemaType type )
+    {
+        setSubstitution( name, type, true );
+    }
+    
+    void setSubstitution ( QName name, SchemaType type, boolean complain )
+    {
+        assert name != null;
+        assert type != null;
+        assert isUserNode();
+
+        TypeStoreUser user = peekUser();
+
+        if (user != null && user.get_schema_type() == type && name.equals(getName()))
+            return;
+
+        if (isRoot())
+        {
+            // If this is the root node, we can't set its name, so the whole
+            // operation is aborted
+            return;
+        }
+
+        // Gotta get the parent user to make sure this type is ok here
+
+        TypeStoreUser parentUser = _xobj.ensureParent().getUser();
+
+        // One may only set the type of an attribute to its 'natural' type because
+        // attributes cannot take advantage of the xsiType attribute.
+
+        if (isAttr())
+        {
+            if (complain)
+            {
+                throw
+                    new IllegalArgumentException(
+                        "Can't use substitution with attributes");
+            }
+
+            return;
+        }
+
+        assert isElem();
+
+        // First check to see if this type can be here sans xsi:type.
+        // If so, make sure there is no xsi:type
+
+        if (parentUser.get_element_type( name, null ) == type)
+        {
+            setName( name );
+            removeAttr( Locale._xsiType );
+            return;
+        }
+
+        // If the desired type has no name, then it cannot be
+        // referenced via xsi:type
+
+        QName typeName = type.getName();
+
+        if (typeName == null)
+        {
+            if (complain)
+                throw new IllegalArgumentException( "Can't set xsi:type on element, type
is un-named" );
+            else
+                return;
+        }
+
+        // See if setting xsiType would result in the target type
+        
+        if (parentUser.get_element_type( name, typeName ) != type)
+        {
+            if (complain)
+                throw new IllegalArgumentException( "Can't set xsi:type on element, invalid
type" );
+            else
+                return;
+        }
+
+        setName( name );
+        setAttrValueAsQName( Locale._xsiType, typeName );
+    }
+
     TypeStoreUser peekUser ( )
     {
         assert isUserNode();

Modified: xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java&r1=124559&p2=xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java	(original)
+++ xmlbeans/trunk/src/newstore2/org/apache/xmlbeans/impl/newstore2/Xobj.java	Fri Jan  7 11:07:35
2005
@@ -1715,6 +1715,24 @@
         return getUser();
     }
 
+    public TypeStoreUser substitute ( QName name, SchemaType type )
+    {
+        _locale.enter();
+
+        try
+        {
+            Cur c = tempCur();
+            c.setSubstitution( name, type, false );
+            c.release();
+        }
+        finally
+        {
+            _locale.exit();
+        }
+
+        return getUser();
+    }
+
     public QName get_xsi_type ( )
     {
         return getXsiTypeName();

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java
Fri Jan  7 11:07:35 2005
@@ -38,6 +38,17 @@
     private String[] _documentationAsXml;
     private DocumentationDocument.Documentation[] _documentation;
     private Attribute[] _attributes;
+    private String _filename;
+
+    public void setFilename(String filename)
+    {
+        _filename = filename;
+    }
+
+    public String getSourceName()
+    {
+        return _filename;
+    }
 
     public XmlObject[] getApplicationInformation()
     {

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
Fri Jan  7 11:07:35 2005
@@ -32,6 +32,7 @@
     private boolean _chameleon;
     private boolean _redefinition;
     private SchemaAnnotation _annotation;
+    private String _filename;
 
     public SchemaAttributeGroupImpl(SchemaContainer container)
     {
@@ -69,6 +70,12 @@
 
     public int getComponentType()
         { return SchemaComponent.ATTRIBUTE_GROUP; }
+
+    public void setFilename(String filename)
+        { _filename = filename; }
+
+    public String getSourceName()
+        { return _filename; }
 
     public QName getName()
         { return _name; }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
Fri Jan  7 11:07:35 2005
@@ -39,6 +39,7 @@
     private Map _nsMap = Collections.EMPTY_MAP;
     private String _parseTNS;
     private boolean _chameleon;
+    private String _filename;
 
     // Lazily computed paths
     private volatile XPath _selectorPath;
@@ -47,6 +48,13 @@
     public SchemaIdentityConstraintImpl(SchemaContainer c) {
         _container = c;
     }
+
+    public void setFilename(String filename)
+        { _filename = filename; }
+
+    public String getSourceName()
+        { return _filename; }
+
 
     public String getSelector() {
         return _selector;

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
Fri Jan  7 11:07:35 2005
@@ -32,6 +32,8 @@
     private boolean _chameleon;
     private boolean _redefinition;
     private SchemaAnnotation _annotation;
+    private String _filename;
+
 
     public SchemaModelGroupImpl(SchemaContainer container)
     {
@@ -69,6 +71,12 @@
 
     public int getComponentType()
         { return SchemaComponent.MODEL_GROUP; }
+
+    public void setFilename(String filename)
+        { _filename = filename; }
+
+    public String getSourceName()
+        { return _filename; }
 
     public QName getName()
         { return _name; }

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java	Fri Jan
 7 11:07:35 2005
@@ -856,15 +856,30 @@
         }
         else
         {
-            if (!_typedWildcardElements.contains(eltName) || wildcardTypeLoader == null)
+            if (wildcardTypeLoader == null)
                 return BuiltinSchemaTypeSystem.ST_NO_TYPE;
 
-            SchemaGlobalElement elt = wildcardTypeLoader.findElement(eltName);
-            if (elt == null)
-                return BuiltinSchemaTypeSystem.ST_NO_TYPE;
-            // According to http://www.w3.org/TR/xmlschema-1/#key-lva,
-            // the line above should return ST_ANY_TYPE.
-            type = elt.getType();
+            if (_typedWildcardElements.contains(eltName))
+            {
+                SchemaGlobalElement elt = wildcardTypeLoader.findElement(eltName);
+                if (elt == null)
+                    return BuiltinSchemaTypeSystem.ST_NO_TYPE;
+                // According to http://www.w3.org/TR/xmlschema-1/#key-lva,
+                // the line above should return ST_ANY_TYPE.
+                type = elt.getType();
+            }
+            else
+            {
+                // Substitution groups
+                SchemaGlobalElement elt = wildcardTypeLoader.findElement(eltName);
+                SchemaGlobalElement head = elt.substitutionGroup();
+                if (head == null)
+                    return BuiltinSchemaTypeSystem.ST_NO_TYPE;
+                prop = (SchemaProperty)_propertyModelByElementName.get(head.getName());
+                if (prop == null)
+                    return BuiltinSchemaTypeSystem.ST_NO_TYPE;
+                type = elt.getType();
+            }
         }
 
         if (xsiType != null && wildcardTypeLoader != null)

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=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Fri Jan  7 11:07:35 2005
@@ -81,7 +81,7 @@
 {
     public static final int DATA_BABE = 0xDA7ABABE;
     public static final int MAJOR_VERSION = 2;  // must match == to be compatible
-    public static final int MINOR_VERSION = 20; // must be <= to be compatible
+    public static final int MINOR_VERSION = 21; // must be <= to be compatible
     public static final int RELEASE_NUMBER = 0; // should be compatible even if < or >
 
     public static final int FILETYPE_SCHEMAINDEX = 1;
@@ -2269,6 +2269,8 @@
             try
             {
                 impl.init(name, readString(), readShort() == 1, atLeast(2, 15, 0) ? readShort()
== 1 : false, GroupDocument.Factory.parse( readString() ).getGroup(), readAnnotation(container),
null);
+                if (atLeast(2, 21, 0))
+                    impl.setFilename(readString());
                 return impl;
             }
             catch (SchemaTypeLoaderException e)
@@ -2315,6 +2317,9 @@
                 }
                 impl.setNSMap(nsMappings);
 
+                if (atLeast(2, 21, 0))
+                    impl.setFilename(readString());
+
                 return impl;
             }
             catch (SchemaTypeLoaderException e)
@@ -2341,6 +2346,8 @@
             try
             {
                 impl.init( name, readString(), readShort() == 1, atLeast(2, 15, 0) ? readShort()
== 1 : false, AttributeGroupDocument.Factory.parse( readString() ).getAttributeGroup(), readAnnotation(container),
null);
+                if (atLeast(2, 21, 0))
+                    impl.setFilename(readString());
                 return impl;
             }
             catch (SchemaTypeLoaderException e)
@@ -2852,7 +2859,7 @@
                 writeString(prefix);
                 writeString(uri);
             }
-
+            writeString(idc.getSourceName());
         }
 
         SchemaParticle[] readParticleArray()
@@ -3093,6 +3100,7 @@
             writeShort(impl.isRedefinition() ? 1 : 0); // new for version 2.15
             writeString(impl.getParseObject().xmlText(new XmlOptions().setSaveOuter()));
             writeAnnotation(impl.getAnnotation());
+            writeString(impl.getSourceName());
         }
 
         void writeAttributeGroupData(SchemaAttributeGroup grp)
@@ -3104,6 +3112,7 @@
             writeShort(impl.isRedefinition() ? 1 : 0); // new for version 2.15
             writeString(impl.getParseObject().xmlText(new XmlOptions().setSaveOuter()));
             writeAnnotation(impl.getAnnotation());
+            writeString(impl.getSourceName());
         }
 
         XmlValueRef readXmlValueObject()

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=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java	Fri Jan
 7 11:07:35 2005
@@ -964,6 +964,7 @@
         }
 
         state.addIdConstraint(ic);
+        ic.setFilename(findFilename(parseIC));
 
         return state.findIdConstraint(ic.getName(), targetNamespace, null);
 
@@ -981,6 +982,7 @@
         SchemaModelGroupImpl result = new SchemaModelGroupImpl(c);
         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(c, namedGroup);
         result.init(QNameHelper.forLNS(name, targetNamespace), targetNamespace, chameleon,
redefinition, namedGroup, ann, getUserData(namedGroup));
+        result.setFilename(findFilename(namedGroup));
         return result;
     }
 
@@ -996,6 +998,7 @@
         SchemaAttributeGroupImpl result = new SchemaAttributeGroupImpl(c);
         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(c, attrGroup);
         result.init(QNameHelper.forLNS(name, targetNamespace), targetNamespace, chameleon,
redefinition, attrGroup, ann, getUserData(attrGroup));
+        result.setFilename(findFilename(attrGroup));
         return result;
     }
 

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java	Fri Jan
 7 11:07:35 2005
@@ -80,6 +80,7 @@
     {
         options = XmlOptions.maskNull(options);
         _errorListener = (Collection) options.get(XmlOptions.ERROR_LISTENER);
+        _treatLaxAsSkip = options.hasOption(XmlOptions.VALIDATE_TREAT_LAX_AS_SKIP);
 
         if (_errorListener == null)
             _errorListener = defaultErrorListener;
@@ -327,7 +328,8 @@
 
                 int wildcardProcess = currentParticle.getWildcardProcess();
 
-                if (wildcardProcess == SchemaParticle.SKIP)
+                if (wildcardProcess == SchemaParticle.SKIP ||
+                    wildcardProcess == SchemaParticle.LAX && _treatLaxAsSkip)
                 {
                     _eatContent = 1;
                     return;
@@ -667,6 +669,7 @@
         }
 
         int wildcardProcess = state._attrModel.getWildcardProcess();
+
         _wildcardAttribute = state._attrModel;
 
         if (wildcardProcess == SchemaAttributeModel.NONE)
@@ -691,7 +694,8 @@
             return;
         }
 
-        if (wildcardProcess == SchemaAttributeModel.SKIP)
+        if (wildcardProcess == SchemaAttributeModel.SKIP ||
+            wildcardProcess == SchemaAttributeModel.LAX && _treatLaxAsSkip)
             return;
 
         attrSchema = _globalTypes.findAttribute( attrName );
@@ -1725,6 +1729,7 @@
     private State              _stateStack;
     private int                _errorState;
     private Collection         _errorListener;
+    private boolean            _treatLaxAsSkip;
     private ValidatorVC        _vc;
     private int                _suspendErrors;
     private IdentityConstraint _constraintEngine;

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java&r1=124559&p2=xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java	(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java	Fri Jan
 7 11:07:35 2005
@@ -500,6 +500,28 @@
         }
     }
 
+    public XmlObject substitute(QName name, SchemaType type)
+    {
+        if (name == null)
+            throw new IllegalArgumentException( "Invalid name (null)" );
+
+        if (type == null)
+            throw new IllegalArgumentException( "Invalid type (null)" );
+
+        if ((_flags & FLAG_STORE) == 0)
+        {
+            throw
+                new IllegalStateException(
+                    "XML Value Objects cannot be used with substitution" );
+        }
+
+        synchronized (monitor())
+        {
+            check_orphaned();
+            return (XmlObject) get_store().substitute( name, type );
+        }
+    }
+
     private int _flags;
     private Object _textsource;
 

Modified: xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java&r1=124559&p2=xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java	(original)
+++ xmlbeans/trunk/src/typestore/org/apache/xmlbeans/impl/values/TypeStore.java	Fri Jan  7
11:07:35 2005
@@ -53,6 +53,8 @@
      */
     TypeStoreUser change_type ( SchemaType sType );
 
+    TypeStoreUser substitute ( QName name, SchemaType sType );
+
     /**
      * Tells if this store is an attribute or not
      */

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java&r1=124559&p2=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java	(original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java	Fri Jan 
7 11:07:35 2005
@@ -66,6 +66,7 @@
         System.out.println("    -noupa - do not enforce the unique particle attribution rule");
         System.out.println("    -nopvr - do not enforce the particle valid (restriction)
rule");
         System.out.println("    -noann - ignore annotations");
+        System.out.println("    -novdoc - do not validate contents of <documentation>");
         System.out.println("    -compiler - path to external java compiler");
         System.out.println("    -ms - initial memory for external java compiler (default
'" + CodeGenUtil.DEFAULT_MEM_START + "')");
         System.out.println("    -mx - maximum memory for external java compiler (default
'" + CodeGenUtil.DEFAULT_MEM_MAX + "')");
@@ -107,6 +108,7 @@
         flags.add("noupa");
         flags.add("nopvr");
         flags.add("noann");
+        flags.add("novdoc");
         flags.add("srconly");
         flags.add("debug");
 
@@ -195,6 +197,7 @@
         boolean noUpa = (cl.getOpt("noupa") != null);
         boolean noPvr = (cl.getOpt("nopvr") != null);
         boolean noAnn = (cl.getOpt("noann") != null);
+        boolean noVDoc= (cl.getOpt("novdoc") != null);
         boolean nojavac = (cl.getOpt("srconly") != null);
         boolean debug = (cl.getOpt("debug") != null);
 
@@ -340,6 +343,7 @@
         params.setNoUpa(noUpa);
         params.setNoPvr(noPvr);
         params.setNoAnn(noAnn);
+        params.setNoVDoc(noVDoc);
         params.setDebug(debug);
         params.setErrorListener(err);
         params.setRepackage(repackage);
@@ -383,6 +387,7 @@
         private boolean noUpa;
         private boolean noPvr;
         private boolean noAnn;
+        private boolean noVDoc;
         private boolean debug;
         private boolean incrementalSrcGen;
         private String repackage;
@@ -571,6 +576,16 @@
             this.noAnn = noAnn;
         }
 
+        public boolean isNoVDoc()
+        {
+            return noVDoc;
+        }
+
+        public void setNoVDoc(boolean newNoVDoc)
+        {
+            this.noVDoc = newNoVDoc;
+        }
+
         public boolean isIncrementalSrcGen()
         {
             return incrementalSrcGen;
@@ -694,7 +709,7 @@
 
     private static SchemaTypeSystem loadTypeSystem(String name, File[] xsdFiles, File[] wsdlFiles,
URL[] urlFiles, File[] configFiles,
         File[] javaFiles, ResourceLoader cpResourceLoader,
-        boolean download, boolean noUpa, boolean noPvr, boolean noAnn,
+        boolean download, boolean noUpa, boolean noPvr, boolean noAnn, boolean noVDoc,
         Set mdefNamespaces, File baseDir, Map sourcesToCopyMap,
         Collection outerErrorListener, File schemasDir, EntityResolver entResolver, File[]
classpath)
     {
@@ -729,7 +744,8 @@
                     }
                     else
                     {
-                        addSchema(xsdFiles[i].toString(), (SchemaDocument)schemadoc, errorListener,
scontentlist);
+                        addSchema(xsdFiles[i].toString(), (SchemaDocument)schemadoc,
+                            errorListener, noVDoc, scontentlist);
                     }
                 }
                 catch (XmlException e)
@@ -765,7 +781,7 @@
                             new Object[] { wsdlFiles[i], "wsdl" }, wsdldoc);
                     else
                     {
-                        addWsdlSchemas(wsdlFiles[i].toString(), (org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument)wsdldoc,
errorListener, scontentlist);
+                        addWsdlSchemas(wsdlFiles[i].toString(), (org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument)wsdldoc,
errorListener, noVDoc, scontentlist);
                     }
                 }
                 catch (XmlException e)
@@ -798,12 +814,13 @@
                     boolean isXsd = false;
                     if ((urldoc instanceof org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument))
                     {
-                        addWsdlSchemas(urlFiles[i].toString(), (org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument)urldoc,
errorListener, scontentlist);
+                        addWsdlSchemas(urlFiles[i].toString(), (org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument)urldoc,
errorListener, noVDoc, scontentlist);
                     }
                     else if ((urldoc instanceof SchemaDocument))
                     {
                         isXsd = true;
-                        addSchema(urlFiles[i].toString(), (SchemaDocument)urldoc, errorListener,
scontentlist);
+                        addSchema(urlFiles[i].toString(), (SchemaDocument)urldoc,
+                            errorListener, noVDoc, scontentlist);
                     }
                     else
                     {
@@ -899,20 +916,24 @@
     }
 
     private static void addSchema(String name, SchemaDocument schemadoc,
-          XmlErrorWatcher errorListener, List scontentlist)
+        XmlErrorWatcher errorListener, boolean noVDoc, List scontentlist)
     {
         StscState.addInfo(errorListener, "Loading schema file " + name);
         XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
+        opts.setValidateTreatLaxAsSkip();
         if (schemadoc.validate(opts))
             scontentlist.add((schemadoc).getSchema());
     }
 
-    private static void addWsdlSchemas(String name, org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument
wsdldoc,
-                                  XmlErrorWatcher errorListener, List scontentlist)
+    private static void addWsdlSchemas(String name,
+        org.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument wsdldoc,
+        XmlErrorWatcher errorListener, boolean noVDoc, List scontentlist)
     {
         if (wsdlContainsEncoded(wsdldoc))
             StscState.addWarning(errorListener, "The WSDL " + name + " uses SOAP encoding.
SOAP encoding is not compatible with literal XML Schema.", XmlErrorCodes.GENERIC_ERROR, wsdldoc);
         StscState.addInfo(errorListener, "Loading wsdl file " + name);
+        XmlOptions opts = new XmlOptions().setErrorListener(errorListener);
+        opts.setValidateTreatLaxAsSkip();
         XmlObject[] types = wsdldoc.getDefinitions().getTypesArray();
         int count = 0;
         for (int j = 0; j < types.length; j++)
@@ -927,7 +948,7 @@
             for (int k = 0; k < schemas.length; k++)
             {
                 if (schemas[k] instanceof SchemaDocument.Schema &&
-                    schemas[k].validate(new XmlOptions().setErrorListener(errorListener)))
+                    schemas[k].validate(opts))
                 {
                     count++;
                     scontentlist.add(schemas[k]);
@@ -961,6 +982,7 @@
         boolean noUpa = params.isNoUpa();
         boolean noPvr = params.isNoPvr();
         boolean noAnn = params.isNoAnn();
+        boolean noVDoc = params.isNoVDoc();
         boolean incrSrcGen = params.isIncrementalSrcGen();
         Collection outerErrorListener = params.getErrorListener();
 
@@ -1007,7 +1029,7 @@
         // build the in-memory type system
         XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, urlFiles, configFiles,
-            javaFiles, cpResourceLoader, download, noUpa, noPvr, noAnn, mdefNamespaces,
+            javaFiles, cpResourceLoader, download, noUpa, noPvr, noAnn, noVDoc, mdefNamespaces,
             baseDir, sourcesToCopyMap, errorListener, schemasDir, cmdLineEntRes, classpath);
         if (errorListener.hasError())
             result = false;

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java&r1=124559&p2=xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java	(original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java	Fri Jan  7 11:07:35
2005
@@ -138,7 +138,7 @@
 
     public static final int DATA_BABE = 0xDA7ABABE;
     public static final int MAJOR_VERSION = 2;
-    public static final int MINOR_VERSION = 20;
+    public static final int MINOR_VERSION = 21;
 
     public static final int FILETYPE_SCHEMAINDEX = 1;
     public static final int FILETYPE_SCHEMATYPE = 2;
@@ -1043,6 +1043,8 @@
         emit("Model Group Xml: ");
         dumpXml();
         dumpAnnotation();
+        if (atLeast(2, 21, 0))
+            emit("Filename: " + readString());
     }
 
     void dumpAttributeGroupData()
@@ -1055,6 +1057,8 @@
         emit("Attribute Group Xml: ");
         dumpXml();
         dumpAnnotation();
+        if (atLeast(2, 21, 0))
+            emit("Filename: " + readString());
     }
 
     static String alwaysString(int code)

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java&r1=124559&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java	Fri Jan  7 11:07:35
2005
@@ -70,6 +70,11 @@
     QName getName();
 
     /**
+     * The name of the source .xsd in which this component was defined (if known)
+     */
+    String getSourceName();
+
+    /**
      * A lazy reference to a component. Used by SchemaTypeLoaders to
      * avoid loading components until they are actually needed.
      * 

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java&r1=124559&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java	Fri Jan  7
11:07:35 2005
@@ -23,11 +23,6 @@
 public interface SchemaGlobalAttribute extends SchemaLocalAttribute, SchemaComponent
 {
     /**
-     * The name of the source .xsd file within which this attribute was defined
-     */ 
-    String getSourceName();
-
-    /**
      * Used to allow on-demand loading of elements.
      * 
      * @exclude

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java&r1=124559&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java	Fri Jan  7 11:07:35
2005
@@ -25,11 +25,6 @@
 public interface SchemaGlobalElement extends SchemaLocalElement, SchemaComponent
 {
     /**
-     * The name of the source .xsd file within which this attribute was defined
-     */ 
-    String getSourceName();
-
-    /**
      * Set of QNames for elements that are the members of the
      * substitution group for which this element is the head,
      * not including this element.

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java&r1=124559&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java	Fri Jan  7 11:07:35 2005
@@ -417,12 +417,6 @@
      */
     public SchemaTypeSystem getTypeSystem();
 
-    /**
-     * Returns the filename for the XSD file from which this type
-     * was loaded. Intended for use when debugging.
-     */
-    public String getSourceName();
-
     /** True if this type cannot be used directly in instances */
     public boolean isAbstract();
 

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java&r1=124559&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlObject.java	Fri Jan  7 11:07:35 2005
@@ -336,6 +336,25 @@
      */
     XmlObject changeType(SchemaType newType);
 
+    /**
+     * Changes the schema type associated with this data using substitution
+     * groups and returns an XmlObject instance whose schemaType is the
+     * new type and container name is the new name.
+     * <p>
+     * In order for the operation to succeed, several conditions must hold:
+     * - the container of this type must be an element
+     * - a global element with the name <code>newName</code> must exist
+     * and must be in the substition group of the containing element
+     * - the <code>newType</code> type must be consistent with the declared
+     * type of the new element
+     * <p>
+     * If the type change is allowed, then the new XmlObject should
+     * be used rather than the old one. The old XmlObject instance and
+     * any other XmlObject instances in the subtree are permanently
+     * invalidated and should not be used. (They will return
+     * InvalidStateException if you try to use them.)
+     */
+    XmlObject substitute(QName newName, SchemaType newType);
 
     /**
      * True if the value is nil. Note that in order to be nil,

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java?view=diff&rev=124560&p1=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java&r1=124559&p2=xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java&r2=124560
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java	(original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java	Fri Jan  7 11:07:35 2005
@@ -577,6 +577,16 @@
     }
 
     /**
+     * Instructs the validator to skip elements matching an <any>
+     * particle with contentModel="lax". This is useful because,
+     * in certain situations, XmlBeans will find types on the
+     * classpath that the document author did not anticipate.
+     */
+    public XmlOptions setValidateTreatLaxAsSkip() {
+        return set ( VALIDATE_TREAT_LAX_AS_SKIP );
+    }
+
+    /**
      * This option controls whether or not operations on XmlBeans are
      * thread safe.  When not on, all XmlBean operations will be syncronized.
      * This provides for multiple thread the ability to access a single
@@ -699,6 +709,8 @@
     public static final String COMPILE_MDEF_NAMESPACES         = "COMPILE_MDEF_NAMESPACES";
     /** @exclude */
     public static final String VALIDATE_ON_SET                 = "VALIDATE_ON_SET";
+    /** @exclude */
+    public static final String VALIDATE_TREAT_LAX_AS_SKIP      = "VALIDATE_TREAT_LAX_AS_SKIP";
     /** @exclude */
     public static final String UNSYNCHRONIZED                  = "UNSYNCHRONIZED";
     /** @exclude */

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


Mime
View raw message