You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2010/11/06 08:39:14 UTC

svn commit: r1031965 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/XMLSchemaMessages.properties xs/traversers/XSDAbstractParticleTraverser.java

Author: mukulg
Date: Sat Nov  6 07:39:13 2010
New Revision: 1031965

URL: http://svn.apache.org/viewvc?rev=1031965&view=rev
Log:
committing changes for jira issue XERCESJ-1472 (allowing xs:group as child of xs:all for schema 1.1). fellow committers are invited to review this change.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1031965&r1=1031964&r2=1031965&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Sat Nov  6 07:39:13 2010
@@ -254,6 +254,7 @@
         maxInclusive-valid-restriction.4 = maxInclusive-valid-restriction.4: Error for type ''{2}''. The maxInclusive value =''{0}'' must be > minExclusive of the base type ''{1}''.
         maxLength-valid-restriction = maxLength-valid-restriction: In the definition of {2}, maxLength value = ''{0}'' must be <= that of the base type ''{1}''.
         mg-props-correct.2 = mg-props-correct.2: Circular definitions detected for group ''{0}''. Recursively following the '{'term'}' values of the particles leads to a particle whose '{'term'}' is the group itself.
+        mg-props-correct.3 = mg-props-correct.3: Incorrect schema instruction ''{0}'' found as child of ''xs:all -> xs:group''. Only the compositor xs:all is permitted as child of ''xs:all -> xs:group''.   
         minExclusive-less-than-equal-to-maxExclusive = minExclusive-less-than-equal-to-maxExclusive: In the definition of {2}, minExclusive value = ''{0}'' must be <= maxExclusive value = ''{1}''.
         minExclusive-less-than-maxInclusive = minExclusive-less-than-maxInclusive: In the definition of {2}, minExclusive value = ''{0}'' must be < maxInclusive value = ''{1}''.
         minExclusive-valid-restriction.1 = minExclusive-valid-restriction.1: Error for type ''{2}''. The minExclusive value =''{0}'' must be >= minExclusive of the base type ''{1}''.

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java?rev=1031965&r1=1031964&r2=1031965&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractParticleTraverser.java Sat Nov  6 07:39:13 2010
@@ -26,6 +26,7 @@ import org.apache.xerces.impl.xs.XSParti
 import org.apache.xerces.impl.xs.util.XInt;
 import org.apache.xerces.impl.xs.util.XSObjectListImpl;
 import org.apache.xerces.util.DOMUtil;
+import org.apache.xerces.xs.XSModelGroup;
 import org.apache.xerces.xs.XSObject;
 import org.apache.xerces.xs.XSObjectList;
 import org.w3c.dom.Element;
@@ -52,7 +53,7 @@ abstract class XSDAbstractParticleTraver
      *   id = ID
      *   maxOccurs = 1 : 1
      *   minOccurs = (0 | 1) : 1&gt;
-     *   Content: (annotation? , element*)
+     *   Content: (annotation?, (element | any | group)*)
      * &lt;/all&gt;
      **/
     XSParticleDecl traverseAll(Element allDecl,
@@ -90,21 +91,39 @@ abstract class XSDAbstractParticleTraver
             // Only elements are allowed in <all>
             if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
                 particle = fSchemaHandler.fElementTraverser.traverseLocal(child, schemaDoc, grammar, PROCESSING_ALL_EL, parent);
+                if (particle != null) {
+                    fPArray.addParticle(particle);
+                }
             }
             else {
-            	// XML Schema 1.1 - allow wildcard
-                if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1 &&
-                    childName.equals(SchemaSymbols.ELT_ANY)) {
-                    particle = fSchemaHandler.fWildCardTraverser.traverseAny(child, schemaDoc, grammar);
+            	// XML Schema 1.1 - allow wildcard and group
+                if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
+                    if (childName.equals(SchemaSymbols.ELT_ANY)) {
+                        particle = fSchemaHandler.fWildCardTraverser.traverseAny(child, schemaDoc, grammar);
+                        if (particle != null) {
+                            fPArray.addParticle(particle);
+                        }
+                    }
+                    else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
+                        particle = fSchemaHandler.fGroupTraverser.traverseLocal(child, schemaDoc, grammar);                                                
+                        if (particle != null) {
+                            expandGroupParticleForCompositorAll(particle, child); 
+                        }
+                    }
+                    else {
+                       // in XML Schema 1.1 mode, it's an error to have anything other than xs:any or xs:group at this point.
+                       // report an error.
+                       Object[] args = {"all", "(annotation?, (element | any | group)*)", DOMUtil.getLocalName(child)};
+                       reportSchemaError("s4s-elt-must-match.1", args, child);
+                    }
                 }
                 else {
+                    // in XML Schema 1.0 mode, it's an error to have anything other than xs:element at this point.
+                    // report an error.
                     Object[] args = {"all", "(annotation?, element*)", DOMUtil.getLocalName(child)};
                     reportSchemaError("s4s-elt-must-match.1", args, child);
                 }
             }
-            
-            if (particle != null)
-                fPArray.addParticle(particle);
         }
         
         particle = null;
@@ -141,6 +160,37 @@ abstract class XSDAbstractParticleTraver
         return particle;
     }
     
+    /*
+     * Given a particle declaration (having model-group as it's term) add all-of it's leaf descendant 
+     * particles (element and wild-card declarations) to a global particle array (fPArray), by expanding
+     * the input particle (method argument) recursively.
+     */
+    private void expandGroupParticleForCompositorAll(XSParticleDecl particle, Element child) {
+        
+        XSModelGroupImpl group = (XSModelGroupImpl) particle.fValue;
+        if (group.getCompositor() == XSModelGroup.COMPOSITOR_ALL) {
+            XSParticleDecl[] subParticles = group.fParticles;
+            for (int partlIdx = 0; partlIdx < group.fParticleCount; partlIdx++) {
+               short particleType = subParticles[partlIdx].fType;
+               if (particleType == XSParticleDecl.PARTICLE_ELEMENT  || 
+                   particleType == XSParticleDecl.PARTICLE_WILDCARD) {
+                     fPArray.addParticle(subParticles[partlIdx]); 
+               }
+               else {
+                   // the sub particle is a model-group. call the method recursively.
+                   expandGroupParticleForCompositorAll(subParticles[partlIdx], child); 
+               }
+            }
+        }
+        else {
+            String wrongCompsName = (group.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) ? 
+                                     "xs:"+SchemaSymbols.ELT_SEQUENCE : "xs:"+SchemaSymbols.ELT_CHOICE;
+            // it's an error to have a non-all (xs:all) compositor within "xs:all -> xs:group"
+            reportSchemaError("mg-props-correct.3", new Object[] {wrongCompsName}, child);
+        }
+        
+    } // expandGroupParticleForCompositorAll
+
     /**
      * Traverse the Sequence declaration
      *



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