xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r160955 - xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values
Date Mon, 11 Apr 2005 21:29:11 GMT
Author: radup
Date: Mon Apr 11 14:29:09 2005
New Revision: 160955

URL: http://svn.apache.org/viewcvs?view=rev&rev=160955
Log:
Code refactoring for resolving anonymous simple types.
Fixed OOME when running xsd2inst over very large Schemas.
Fixed default value syncronization between store and XmlObject.


Modified:
    xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java

Modified: xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java?view=diff&r1=160954&r2=160955
==============================================================================
--- xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java (original)
+++ xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst/SampleXmlUtil.java Mon Apr
11 14:29:09 2005
@@ -68,12 +68,14 @@
 public class SampleXmlUtil
 {
     private boolean _soapEnc;
+    private static final int MAX_ELEMENTS = 1000;
+    private int _nElements;
 
     private SampleXmlUtil(boolean soapEnc)
     {
         _soapEnc = soapEnc;
     }
-    
+
     public static String createSampleForType(SchemaType sType)
     {
         XmlObject object = XmlObject.Factory.newInstance();
@@ -967,7 +969,7 @@
             return minOccurs;
         
         int result = minOccurs;
-        if (result == 0)
+        if (result == 0 && _nElements < MAX_ELEMENTS)
             result = 1;
         
         if (sp.getParticleType() != SchemaParticle.ELEMENT)
@@ -1020,6 +1022,7 @@
             xmlc.insertElement(element.getName().getLocalPart()); // soap encoded? drop namespaces.
         else
             xmlc.insertElement(element.getName().getLocalPart(), element.getName().getNamespaceURI());
+        _nElements++;
         /// -> <elem>^</elem>
         xmlc.toPrevToken();
         // -> <elem>stuff^</elem>

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&r1=160954&r2=160955
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscComplexTypeResolver.java
Mon Apr 11 14:29:09 2005
@@ -632,8 +632,16 @@
         StscState state = StscState.get();
         String targetNamespace = sImpl.getTargetNamespace();
         boolean chameleon = (sImpl.getChameleonNamespace() != null);
+        List anonymousTypes = new ArrayList();
         if (parseTree.getSimpleType() != null)
         {
+            LocalSimpleType typedef = parseTree.getSimpleType();
+            SchemaTypeImpl anonType = StscTranslator.
+                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.
         }
@@ -710,7 +718,6 @@
         }
 
         // build attr model and anonymous types
-        List anonymousTypes = new ArrayList();
         SchemaAttributeModelImpl attrModel;
         if (baseType == null)
             attrModel = new SchemaAttributeModelImpl();

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&r1=160954&r2=160955
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
(original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
Mon Apr 11 14:29:09 2005
@@ -208,14 +208,10 @@
         }
         else if (parseInner != null)
         {
-            itemImpl = new SchemaTypeImpl(sImpl.getContainer());
+            itemImpl = StscTranslator.translateAnonymousSimpleType(parseInner,
+                sImpl.getTargetNamespace(), sImpl.getChameleonNamespace() != null,
+                sImpl.getElemFormDefault(), sImpl.getAttFormDefault(), anonTypes, sImpl);
             errorLoc = parseInner;
-            itemImpl.setSimpleType(true);
-            itemImpl.setParseContext(parseInner, sImpl.getTargetNamespace(), sImpl.getChameleonNamespace()
!= null, sImpl.getElemFormDefault(), sImpl.getAttFormDefault(), false);
-            itemImpl.setOuterSchemaTypeRef(sImpl.getRef());
-            SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(sImpl.getContainer(),
parseInner);
-            itemImpl.setAnnotation(ann);
-            anonTypes.add(itemImpl);
         }
         else
         {
@@ -317,15 +313,11 @@
         for (int i = 0; i < simpleTypes.length; i++)
         {
             // BUGBUG: see if non<simpleType> children can leak through
-            SchemaTypeImpl mImpl = new SchemaTypeImpl(sImpl.getContainer());
-            mImpl.setSimpleType(true);
-            mImpl.setParseContext(simpleTypes[i], sImpl.getTargetNamespace(), sImpl.getChameleonNamespace()
!= null, sImpl.getElemFormDefault(), sImpl.getAttFormDefault(), false);
+            SchemaTypeImpl mImpl = StscTranslator.translateAnonymousSimpleType(simpleTypes[i],
+                sImpl.getTargetNamespace(), sImpl.getChameleonNamespace() != null,
+                sImpl.getElemFormDefault(), sImpl.getAttFormDefault(), anonTypes, sImpl);
             memberImplList.add(mImpl);
-            mImpl.setOuterSchemaTypeRef(sImpl.getRef());
             mImpl.setAnonymousUnionMemberOrdinal(i + 1);
-            SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(sImpl.getContainer(),
simpleTypes[i]);
-            mImpl.setAnnotation(ann);
-            anonTypes.add(mImpl);
         }
 
         // Recurse and resolve all member types
@@ -458,14 +450,9 @@
                 // recovery: oh well.
             }
             
-            baseImpl = new SchemaTypeImpl(sImpl.getContainer());
-            baseImpl.setSimpleType(true);
-            baseImpl.setParseContext(parseInner, sImpl.getTargetNamespace(), sImpl.getChameleonNamespace()
!= null, sImpl.getElemFormDefault(), sImpl.getAttFormDefault(), false);
-            // baseImpl.setSkippedAnonymousType(true);
-            baseImpl.setOuterSchemaTypeRef(sImpl.getRef());
-            SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(sImpl.getContainer(),
parseInner);
-            baseImpl.setAnnotation(ann);
-            anonTypes.add(baseImpl);
+            baseImpl = StscTranslator.translateAnonymousSimpleType(parseInner,
+                sImpl.getTargetNamespace(), sImpl.getChameleonNamespace() != null,
+                sImpl.getElemFormDefault(), sImpl.getAttFormDefault(), anonTypes, sImpl);
         }
         else
         {

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&r1=160954&r2=160955
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java Mon Apr
11 14:29:09 2005
@@ -53,6 +53,7 @@
 import org.apache.xmlbeans.impl.xb.xsdschema.NamedGroup;
 import org.apache.xmlbeans.impl.xb.xsdschema.RedefineDocument.Redefine;
 import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument.Schema;
+import org.apache.xmlbeans.impl.xb.xsdschema.SimpleType;
 import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelAttribute;
 import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelComplexType;
 import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelElement;
@@ -811,6 +812,22 @@
         sType.setName(name);
         sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.getContainer(targetNamespace),
xsdType));
         sType.setUserData(getUserData(xsdType));
+        return sType;
+    }
+
+    /*package*/ static SchemaTypeImpl translateAnonymousSimpleType(SimpleType typedef,
+        String targetNamespace, boolean chameleon, String elemFormDefault,
+        String attFormDefault, List anonymousTypes, SchemaType outerType)
+    {
+        StscState state = StscState.get();
+        SchemaTypeImpl sType = new SchemaTypeImpl(state.getContainer(targetNamespace));
+        sType.setSimpleType(true);
+        sType.setParseContext(typedef, targetNamespace, chameleon,
+            elemFormDefault, attFormDefault, false);
+        sType.setOuterSchemaTypeRef(outerType.getRef());
+        sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.getContainer(targetNamespace),
typedef));
+        sType.setUserData(getUserData(typedef));
+        anonymousTypes.add(sType);
         return sType;
     }
 

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&r1=160954&r2=160955
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/values/XmlObjectBase.java Mon Apr
11 14:29:09 2005
@@ -1079,7 +1079,8 @@
         if ((_flags & FLAG_STORE) != 0)
         {
             _flags &= ~FLAG_VALUE_DATED;
-            get_store().store_text(v);
+            if ((_flags & FLAG_SETTINGDEFAULT) == 0)
+                get_store().store_text(v);
             if (wasNilled)
                 get_store().invalidate_nil();
         }



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


Mime
View raw message