You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2003/01/20 16:47:24 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/xs/traversers XSDComplexTypeTraverser.java

sandygao    2003/01/20 07:47:24

  Modified:    java/src/org/apache/xerces/impl/xs/traversers
                        XSDComplexTypeTraverser.java
  Log:
  Changes for Erratum E1-5: some rules concerning
  "Property mapping for complex type definitions with complex content"
  have changed.
  
  Revision  Changes    Path
  1.28      +51 -32    xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
  
  Index: XSDComplexTypeTraverser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- XSDComplexTypeTraverser.java	14 Jan 2003 20:21:47 -0000	1.27
  +++ XSDComplexTypeTraverser.java	20 Jan 2003 15:47:24 -0000	1.28
  @@ -114,6 +114,8 @@
       private boolean fIsAbstract = false;
       private XSComplexTypeDecl fComplexTypeDecl = null;
   
  +    private XSParticleDecl fEmptyParticle = null;
  +
       // our own little stack to retain state when getGlobalDecls is called:
       private Object [] fGlobalStore = null;
       private int fGlobalStorePos = 0;
  @@ -721,27 +723,12 @@
   
               // This is an EXTENSION
   
  -            //
  -            // Check if the contentType of the base is consistent with the new type
  -            // cos-ct-extends.1.4.2.2
  -            if (baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
  -                if (((baseType.getContentType() ==
  -                      XSComplexTypeDecl.CONTENTTYPE_ELEMENT) &&
  -                     mixedContent) ||
  -                    ((baseType.getContentType() ==
  -                      XSComplexTypeDecl.CONTENTTYPE_MIXED) && !mixedContent)) {
  -
  -                    throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.2.2.2.2.1",
  -                          new Object[]{fName}, complexContent);
  -                }
  -
  -            }
  -
               // Create the particle
               if (fParticle == null) {
  +                fContentType = baseType.getContentType();
                   fParticle = baseContent;
               }
  -            else if (baseContent==null) {
  +            else if (baseType.getContentType() == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
               }
               else {
                   // if the content of either type is an "all" model group, error.
  @@ -767,13 +754,22 @@
                   fParticle = particle;
               }
   
  -            // Set the contentType
  -            if (mixedContent)
  -                fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
  -            else if (fParticle == null)
  -                fContentType = XSComplexTypeDecl.CONTENTTYPE_EMPTY;
  -            else
  -                fContentType = XSComplexTypeDecl.CONTENTTYPE_ELEMENT;
  +            //
  +            // Check if the contentType of the base is consistent with the new type
  +            // cos-ct-extends.1.4.2.2
  +            if (baseType.getContentType() != XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
  +                if (((baseType.getContentType() ==
  +                      XSComplexTypeDecl.CONTENTTYPE_ELEMENT) &&
  +                     fContentType != XSComplexTypeDecl.CONTENTTYPE_ELEMENT) ||
  +                    ((baseType.getContentType() ==
  +                      XSComplexTypeDecl.CONTENTTYPE_MIXED) &&
  +                      fContentType != XSComplexTypeDecl.CONTENTTYPE_MIXED)) {
  +
  +                    throw new ComplexTypeRecoverableError("cos-ct-extends.1.4.2.2.2.2.1",
  +                          new Object[]{fName}, complexContent);
  +                }
  +
  +            }
   
               // Remove prohibited uses.   Must be done before merge for EXTENSION.
               fAttrGrp.removeProhibitedAttrs();
  @@ -830,8 +826,6 @@
           }
       }
   
  -
  -
       private void processComplexContent(Element complexContentChild,
                                          boolean isMixed, boolean isDerivation,
                                          XSDocumentInfo schemaDoc, SchemaGrammar grammar)
  @@ -858,16 +852,31 @@
               else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
                   particle = traverseSequence(complexContentChild,schemaDoc,grammar,
                                               NOT_ALL_CONTEXT,fComplexTypeDecl);
  +                if (particle != null) {
  +                    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
  +                    if (group.fParticleCount == 0)
  +                        particle = null;
  +                }
                   attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
               }
               else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
                   particle = traverseChoice(complexContentChild,schemaDoc,grammar,
                                             NOT_ALL_CONTEXT,fComplexTypeDecl);
  +                if (particle != null && particle.fMinOccurs == 0) {
  +                    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
  +                    if (group.fParticleCount == 0)
  +                        particle = null;
  +                }
                   attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
               }
               else if (childName.equals(SchemaSymbols.ELT_ALL)) {
                   particle = traverseAll(complexContentChild,schemaDoc,grammar,
                                          PROCESSING_ALL_GP,fComplexTypeDecl);
  +                if (particle != null) {
  +                    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
  +                    if (group.fParticleCount == 0)
  +                        particle = null;
  +                }
                   attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
               }
               else {
  @@ -876,17 +885,27 @@
               }
           }
   
  +        if (particle == null && isMixed) {
  +            if (fEmptyParticle == null) {
  +                XSModelGroupImpl group = new XSModelGroupImpl();
  +                group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
  +                group.fParticleCount = 0;
  +                group.fParticles = null;
  +                fEmptyParticle = new XSParticleDecl();
  +                fEmptyParticle.fType = XSParticleDecl.PARTICLE_MODELGROUP;
  +                fEmptyParticle.fValue = group;
  +            }
  +            particle = fEmptyParticle;
  +        }
           fParticle = particle;
   
           // -----------------------------------------------------------------------
           // Set the content type
           // -----------------------------------------------------------------------
  -
  -        if (isMixed) {
  -            fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
  -        }
  -        else if (fParticle == null)
  +        if (fParticle == null)
               fContentType = XSComplexTypeDecl.CONTENTTYPE_EMPTY;
  +        else if (isMixed)
  +            fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;
           else
               fContentType = XSComplexTypeDecl.CONTENTTYPE_ELEMENT;
   
  
  
  

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