sandygao    2003/02/12 06:23:54

  Modified:    java/src/org/apache/xerces/impl/msg
                        XMLSchemaMessages.properties
               java/src/org/apache/xerces/impl/xs/traversers
                        XSDComplexTypeTraverser.java
  Log:
  Erratum E1-27: a complex type with simple content *can* restrict another
  complex type with mixed content and an emptiable particle.
  
  Revision  Changes    Path
  1.63      +4 -3      
xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
  
  Index: XMLSchemaMessages.properties
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- XMLSchemaMessages.properties      21 Jan 2003 19:14:04 -0000      1.62
  +++ XMLSchemaMessages.properties      12 Feb 2003 14:23:54 -0000      1.63
  @@ -117,11 +117,12 @@
           src-attribute_group = src-attribute_group: Attribute group ''{0}'' does not 
conform to the schema for schemas.  Element ''{1}'' is invalid or misplaced.
           src-attribute_group.3 = src-attribute_group.3: Circular definitions 
detected for attribute group ''{0}''.
           src-ct.0.1 = src-ct.0.1: Complex Type Definition Representation Error for 
type ''{0}''.  Element ''{1}'' is invalid, misplaced, or occurs too often.
  -        src-element.1 = src-element.1: ''default'' and ''fixed'' must not both be 
present in element declaration ''{0}''.
           src-ct.0.2 = src-ct.0.2: Complex Type Definition Representation Error for 
type ''{0}''.  Element ''{1}'' must not be empty.
           src-ct.0.3 = src-ct.0.3: Complex Type Definition Representation Error for 
type ''{0}''.  A base type must be specified.
           src-ct.1 = src-ct.1: Complex Type Definition Representation Error for type 
''{0}''.  When complexContent is used, the base type must be a complexType.
  -        src-ct.2 = src-ct.2: Complex Type Definition Representation Error for type 
''{0}''.  When simpleContent is used, the base type must be a complexType whose 
content type is simple, or, only if extension is specified, a simple type.
  +        src-ct.2.1 = src-ct.2.1: Complex Type Definition Representation Error for 
type ''{0}''.  When simpleContent is used, the base type must be a complexType whose 
content type is simple, or, only if restriction is specified, a complex type with 
mixed content and emptiable particle, or, only if extension is specified, a simple 
type.
  +        src-ct.2.2 = src-ct.2.2: Complex Type Definition Representation Error for 
type ''{0}''.  When a complexType with simpleContent restricts a complexType with 
mixed content and emptiable particle, then there must be a <simpleType> among the 
children of <restriction>.
  +        src-element.1 = src-element.1: ''default'' and ''fixed'' must not both be 
present in element declaration ''{0}''.
           src-element.2.1 = src-element.2.1: : One of ''ref'' or ''name'' must be 
present in a local element declaration.
           src-element.2.2 = src-element.2.2: The content must match (annotation?) for 
the element reference ''{0}''.
           src-element.3 = src-element.3: Element ''{0}'' have both a type attribute 
and a annoymous type child.
  
  
  
  1.31      +24 -7     
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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- XSDComplexTypeTraverser.java      21 Jan 2003 17:51:05 -0000      1.30
  +++ XSDComplexTypeTraverser.java      12 Feb 2003 14:23:54 -0000      1.31
  @@ -400,17 +400,26 @@
           if ((type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)) {
   
               baseComplexType = (XSComplexTypeDecl)type;
  -            if (baseComplexType.getContentType() != 
XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
  -                throw new ComplexTypeRecoverableError("src-ct.2",
  +            baseFinalSet = baseComplexType.getFinal();
  +            // base is a CT with simple content (both restriction and extension are 
OK)
  +            if (baseComplexType.getContentType() == 
XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
  +                baseValidator = (XSSimpleType)baseComplexType.getSimpleType();
  +            }
  +            // base is a CT with mixed/emptiable content (only restriction is OK)
  +            else if (fDerivedBy == XSConstants.DERIVATION_RESTRICTION &&
  +                     baseComplexType.getContentType() == 
XSComplexTypeDecl.CONTENTTYPE_MIXED &&
  +                     ((XSParticleDecl)baseComplexType.getParticle()).emptiable()) {
  +            }
  +            else {
  +                throw new ComplexTypeRecoverableError("src-ct.2.1",
                                   new Object[]{fName}, simpleContent);
               }
  -            baseFinalSet = baseComplexType.getFinal();
  -            baseValidator = (XSSimpleType)baseComplexType.getSimpleType();
           }
           else {
               baseValidator = (XSSimpleType)type;
  +            // base is a ST (only extension is OK)
               if (fDerivedBy == XSConstants.DERIVATION_RESTRICTION) {
  -                throw new ComplexTypeRecoverableError("src-ct.2",
  +                throw new ComplexTypeRecoverableError("src-ct.2.1",
                                   new Object[]{fName}, simpleContent);
               }
               baseFinalSet=baseValidator.getFinal();
  @@ -466,7 +475,8 @@
                   //check that this datatype validator is validly derived from the 
base
                   //according to derivation-ok-restriction 5.1.2.1
   
  -                if (!XSConstraints.checkSimpleDerivationOk(dv, baseValidator,
  +                if (baseValidator != null &&
  +                    !XSConstraints.checkSimpleDerivationOk(dv, baseValidator,
                                                              
baseValidator.getFinal())) {
                       throw new 
ComplexTypeRecoverableError("derivation-ok-restriction.5.1.2.1",
                              new Object[]{fName},
  @@ -476,6 +486,13 @@
                   simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
               }
   
  +            // this only happens when restricting a mixed/emptiable CT
  +            // but there is no <simpleType>, which is required
  +            if (baseValidator == null) {
  +                throw new ComplexTypeRecoverableError("src-ct.2.2",
  +                                new Object[]{fName}, simpleContent);
  +            }
  +            
               // 
-----------------------------------------------------------------------
               // Traverse any facets
               // 
-----------------------------------------------------------------------
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to