xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r165352 - in /xmlbeans/trunk/src: typeimpl/org/apache/xmlbeans/impl/schema/ xmlcomp/org/apache/xmlbeans/impl/tool/ xmlpublic/org/apache/xmlbeans/
Date Fri, 29 Apr 2005 22:53:55 GMT
Author: radup
Date: Fri Apr 29 15:53:53 2005
New Revision: 165352

URL: http://svn.apache.org/viewcvs?rev=165352&view=rev
Log:
Added support for complex types with simple content whose content is declared via an inline
<simpleType>.

Modified:
    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/StscChecker.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties

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?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java Fri Apr
29 15:53:53 2005
@@ -140,6 +140,9 @@
     private int _baseDepth; // how many inheritance steps to AnyType
     private int _derivationType;
 
+    // for complex types with simple content
+    private SchemaType.Ref _contentBasedOnTyperef;
+
     // facets
     private XmlValueRef[] _facetArray;
     private boolean[] _fixedFacetArray;
@@ -522,7 +525,8 @@
         { assertJavaizing(); _isCompiled = f; }
 
     public boolean isSkippedAnonymousType()
-        { return _outerSchemaTypeRef.get().getBaseType() == this; }
+        { return _outerSchemaTypeRef.get().getBaseType() == this ||
+                _outerSchemaTypeRef.get().getContentBasedOnType() == this; }
 
     public String getShortJavaName()
         { return _shortJavaName; }
@@ -1146,6 +1150,12 @@
     public void setBaseDepth(int depth)
         { assertResolving(); _baseDepth = depth; }
 
+    public SchemaType getContentBasedOnType()
+        { return _contentBasedOnTyperef == null ? null : _contentBasedOnTyperef.get(); }
+
+    public void setContentBasedOnTypeRef(SchemaType.Ref typeref)
+        { assertResolving(); _contentBasedOnTyperef = typeref; }
+
     public int getDerivationType()
         { return _derivationType; }
 
@@ -2220,9 +2230,11 @@
             prefix = "I=";
         else if (getOuterType().getSimpleVariety() == SchemaType.UNION)
             prefix = "M=" + getAnonymousUnionMemberOrdinal();
+        else if (getOuterType().getContentBasedOnType() == this)
+             prefix = "S=";
         else
             prefix = "strange=";
-
+        
         return prefix + "|" + getOuterType().toString();
     }
 

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?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
Fri Apr 29 15:53:53 2005
@@ -80,7 +80,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 = 22; // must be <= to be compatible
+    public static final int MINOR_VERSION = 23; // 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;
@@ -2496,6 +2496,9 @@
                     complexVariety = readShort();
                     impl.setComplexTypeVariety(complexVariety);
 
+                    if (atLeast(2, 23, 0))
+                        impl.setContentBasedOnTypeRef(readTypeRef());
+
                     // Attribute Model Table
                     SchemaAttributeModelImpl attrModel = new SchemaAttributeModelImpl();
 
@@ -2756,6 +2759,8 @@
             if (!type.isSimpleType())
             {
                 writeShort(type.getContentType());
+
+                writeType(type.getContentBasedOnType());
 
                 // Attribute Model Table
                 SchemaAttributeModel attrModel = type.getAttributeModel();

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker.java?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker.java Fri Apr 29
15:53:53 2005
@@ -279,7 +279,21 @@
                     {
                         case SchemaType.SIMPLE_CONTENT:
                             // 5.1.1 The {content type} of the {base type definition} must
be a simple type definition of which the {content type} is a ·valid restriction· as defined
in Derivation Valid (Restriction, Simple) (§3.14.6).
-                            // todo: we don't allow the content type to be an "on the side"
simple type, so nothing fancy to check here
+                            SchemaType cType = sType.getContentBasedOnType();
+                            if (cType != baseType)
+                            {
+                                // We have to check that the contentType is legally derived
+                                // from the base simple type in the hierarchy
+                                SchemaType bType = baseType;
+                                while (bType != null && !bType.isSimpleType())
+                                    bType = bType.getContentBasedOnType();
+                                if (bType != null && !bType.isAssignableFrom(cType))
+                                {
+                                    state.error(XmlErrorCodes.COMPLEX_TYPE_RESTRICTION$SC_NOT_DERIVED,
+                                        null, location);
+                                    return false;
+                                }
+                            }
                             break;
                             
                         case SchemaType.MIXED_CONTENT:

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?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
Fri Apr 29 15:53:53 2005
@@ -629,6 +629,7 @@
     static void resolveScRestriction(SchemaTypeImpl sImpl, SimpleRestrictionType parseTree)
     {
         SchemaType baseType;
+        SchemaType contentType = null;
         StscState state = StscState.get();
         String targetNamespace = sImpl.getTargetNamespace();
         boolean chameleon = (sImpl.getChameleonNamespace() != null);
@@ -640,10 +641,7 @@
                 translateAnonymousSimpleType(typedef, targetNamespace, chameleon,
                     sImpl.getElemFormDefault(), sImpl.getAttFormDefault(),
                     anonymousTypes, sImpl);
-            // This effectively disables support for simple types inside...
-            anonymousTypes.clear();
-            state.warning("Nested simple types inside simple content restrictions are unsupported
- ignoring", XmlErrorCodes.ILLEGAL_RESTRICTION, parseTree);
-            // recovery: ignore the nested simple type element.
+            contentType = anonType;
         }
         if (parseTree.getBase() == null)
         {
@@ -680,6 +678,10 @@
 
         // Recursion
         StscResolver.resolveType((SchemaTypeImpl)baseType);
+        if (contentType != null)
+            StscResolver.resolveType((SchemaTypeImpl)contentType);
+        else
+            contentType = baseType;
 
         if (baseType.isSimpleType())
         {
@@ -690,21 +692,9 @@
             // recovery: extends ANY_SIMPLE type
             baseType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
         }
-        // BUGBUG: can restrict mixed content as long as all child elements are optional
-        else if (baseType.getContentType() != SchemaType.SIMPLE_CONTENT)
-        {
-            // src-ct.2: complex types with simple content can only extend simple types
-            state.error(XmlErrorCodes.SCHEMA_COMPLEX_TYPE$SIMPLE_CONTENT,
-                new Object[] { QNameHelper.pretty(baseType.getName()) } ,
-                parseTree);
-            // recovery: extends ANY_SIMPLE type
-            baseType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
-        }
-        else if (baseType.getContentType() == SchemaType.MIXED_CONTENT &&
-            baseType.getContentModel() != null && !baseType.getContentModel().isSkippable())
+        else if (baseType.getContentType() != SchemaType.SIMPLE_CONTENT &&
+                 contentType == null)
         {
-            state.error(XmlErrorCodes.COMPLEX_TYPE_RESTRICTION$SC_AND_MIXED_EMPTIABLE,
-                null, parseTree);
             // recovery: extends ANY_SIMPLE type
             baseType = BuiltinSchemaTypeSystem.ST_ANY_SIMPLE;
         }
@@ -735,26 +725,27 @@
         // now fill in the actual schema type implementation
         sImpl.setBaseTypeRef(baseType.getRef());
         sImpl.setBaseDepth(((SchemaTypeImpl)baseType).getBaseDepth() + 1);
+        sImpl.setContentBasedOnTypeRef(contentType.getRef());
         sImpl.setDerivationType(SchemaType.DT_RESTRICTION);
         sImpl.setAnonymousTypeRefs(makeRefArray(anonymousTypes));
         sImpl.setWildcardSummary(QNameSet.EMPTY, false, wcAttr.typedWildcards, wcAttr.hasWildcards);
         sImpl.setComplexTypeVariety(SchemaType.SIMPLE_CONTENT);
         sImpl.setContentModel(null, attrModel, null, attributePropertyModel, false);
-        sImpl.setSimpleTypeVariety(baseType.getSimpleVariety());
-        sImpl.setPrimitiveTypeRef(baseType.getPrimitiveType() == null ? null : baseType.getPrimitiveType().getRef());
+        sImpl.setSimpleTypeVariety(contentType.getSimpleVariety());
+        sImpl.setPrimitiveTypeRef(contentType.getPrimitiveType() == null ? null : contentType.getPrimitiveType().getRef());
         switch (sImpl.getSimpleVariety())
         {
             case SchemaType.LIST:
-                sImpl.setListItemTypeRef(baseType.getListItemType().getRef());
+                sImpl.setListItemTypeRef(contentType.getListItemType().getRef());
                 break;
 
             case SchemaType.UNION:
-                sImpl.setUnionMemberTypeRefs(makeRefArray(Arrays.asList(baseType.getUnionMemberTypes())));
+                sImpl.setUnionMemberTypeRefs(makeRefArray(Arrays.asList(contentType.getUnionMemberTypes())));
                 break;
         }
 
         // deal with facets
-        StscSimpleTypeResolver.resolveFacets(sImpl, parseTree, (SchemaTypeImpl)baseType);
+        StscSimpleTypeResolver.resolveFacets(sImpl, parseTree, (SchemaTypeImpl) contentType);
 
         // now compute our intrinsic properties
         StscSimpleTypeResolver.resolveFundamentalFacets(sImpl);
@@ -835,6 +826,7 @@
         // now fill in the actual schema type implementation
         sImpl.setBaseTypeRef(baseType.getRef());
         sImpl.setBaseDepth(((SchemaTypeImpl)baseType).getBaseDepth() + 1);
+        sImpl.setContentBasedOnTypeRef(baseType.getRef());
         sImpl.setDerivationType(SchemaType.DT_EXTENSION);
         sImpl.setAnonymousTypeRefs(makeRefArray(anonymousTypes));
         sImpl.setWildcardSummary(QNameSet.EMPTY, false, wcAttr.typedWildcards, wcAttr.hasWildcards);

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?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java Fri Apr 29 15:53:53
2005
@@ -154,7 +154,7 @@
 
     public static final int DATA_BABE = 0xDA7ABABE;
     public static final int MAJOR_VERSION = 2;
-    public static final int MINOR_VERSION = 22;
+    public static final int MINOR_VERSION = 23;
 
     public static final int FILETYPE_SCHEMAINDEX = 1;
     public static final int FILETYPE_SCHEMATYPE = 2;
@@ -891,6 +891,9 @@
         {
             complexVariety = readShort();
             emit("Complex variety: " + complexVarietyString(complexVariety));
+
+            if (atLeast(2, 23, 0))
+                emit("Content based on type: " + readType());
 
             short attrCount = readShort();
             emit("Attribute model (" + attrCount + "):");

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?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/SchemaType.java Fri Apr 29 15:53:53 2005
@@ -458,6 +458,13 @@
 
 
     /**
+     * For complex types with simple content returns the base type for this
+     * type's content. In most cases, this is the same as the base type, but
+     * it can also be an anonymous type.
+     */
+    SchemaType getContentBasedOnType();
+
+    /**
      * Returns a {@link SchemaTypeElementSequencer} object, which can then
      * be used to validate complex content inside this element. This is useful
      * for example for trying out different names and see which one would be

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java Fri Apr 29 15:53:53
2005
@@ -1180,16 +1180,16 @@
     public static final String COMPLEX_TYPE_RESTRICTION$SC_AND_SIMPLE_TYPE_OR_MIXED = "derivation-ok-restriction.5.1";
 
     /**
-     * derivation-ok-restriction.5.1.1: See clause 5.1.1 of
+     * derivation-ok-restriction.5.1.2: See clause 5.1.2 of
      * <a href="http://www.w3c.org/TR/xmlschema-1/#derivation-ok-restriction">XMLSchema
Structures 1.0: Derivation Valid (Restriction, Complex)</a>
      */
-    public static final String COMPLEX_TYPE_RESTRICTION$SC_AND_SIMPLE_TYPE_VALID = "derivation-ok-restriction.5.1.1";
+    public static final String COMPLEX_TYPE_RESTRICTION$SC_AND_MIXED_EMPTIABLE = "derivation-ok-restriction.5.1.2";
 
     /**
-     * derivation-ok-restriction.5.1.2: See clause 5.1.2 of
+     * derivation-ok-restriction.5.2.2.1: See clause 5.2.2.1 of
      * <a href="http://www.w3c.org/TR/xmlschema-1/#derivation-ok-restriction">XMLSchema
Structures 1.0: Derivation Valid (Restriction, Complex)</a>
      */
-    public static final String COMPLEX_TYPE_RESTRICTION$SC_AND_MIXED_EMPTIABLE = "derivation-ok-restriction.5.1.2";
+    public static final String COMPLEX_TYPE_RESTRICTION$SC_NOT_DERIVED = "derivation-ok-restriction.5.2.2.1";
 
     /**
      * derivation-ok-restriction.5.2: See clause 5.2 of

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties?rev=165352&r1=165351&r2=165352&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/message.properties Fri Apr 29 15:53:53
2005
@@ -599,13 +599,13 @@
 The anyAttribute namespace=''{0}'' is not a subset of the base type anyAttribute.
 
 derivation-ok-restriction.5.1 = \
-A type with a simple content model can only restrict a simple or mixed content model.
-
-derivation-ok-restriction.5.1.1 = \
-KHK: TBD
+A complex type with a simple content model can only restrict a complex type with simple or
mixed content model.
 
 derivation-ok-restriction.5.1.2 = \
 A type with a simple content model can only restrict a mixed content model that has skippable
elements.
+
+derivation-ok-restriction.5.2.2.1 = \
+The simple content is not validly derived from the base simple content type.
 
 derivation-ok-restriction.5.2 = \
 A type with an empty content model cannot restrict a type with a simple content model.



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


Mime
View raw message