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 2001/11/01 21:08:00 UTC

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

sandygao    01/11/01 12:08:00

  Modified:    java/src/org/apache/xerces/impl/xs XSAttributeDecl.java
                        XSAttributeGroupDecl.java XSElementDecl.java
               java/src/org/apache/xerces/impl/xs/traversers
                        XSDAttributeTraverser.java XSDElementTraverser.java
  Log:
  Add more information to element/attribute decls: whether the decl is global.
  This is required for PSVI, and other class (traversers, validator) also need this information.
  
  Revision  Changes    Path
  1.2       +22 -3     xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java
  
  Index: XSAttributeDecl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeDecl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSAttributeDecl.java	2001/10/25 20:36:02	1.1
  +++ XSAttributeDecl.java	2001/11/01 20:08:00	1.2
  @@ -65,14 +65,14 @@
    *
    * @author Elena Litani, IBM
    * @author Sandy Gao, IBM
  - * @version $Id: XSAttributeDecl.java,v 1.1 2001/10/25 20:36:02 elena Exp $
  + * @version $Id: XSAttributeDecl.java,v 1.2 2001/11/01 20:08:00 sandygao Exp $
    */
   public class XSAttributeDecl {
   
       // types of value constraint
       public final static short     NO_CONSTRAINT       = 0;
       public final static short     DEFAULT_VALUE       = 1;
  -    public final static short     FIXED_VALUE        = 2;
  +    public final static short     FIXED_VALUE         = 2;
   
       // the name of the attribute
       public String fName = null;
  @@ -82,8 +82,27 @@
       // REVISIT: to be changed to XSSimpleTypeDecl
       public DatatypeValidator fType = null;
       // value constraint type: default, fixed or !specified
  -    public short fConstraintType = NO_CONSTRAINT;
  +    short fMiscFlags = 0;
       // value constraint value
       public Object fDefault = null;
  +
  +    private static final short CONSTRAINT_MASK = 3;
  +    private static final short GLOBAL          = 4;
  +
  +    // methods to get/set misc flag
  +
  +    public short getConstraintType() {
  +        return (short)(fMiscFlags & CONSTRAINT_MASK);
  +    }
  +    public boolean isGlobal() {
  +        return ((fMiscFlags & GLOBAL) != 0);
  +    }
  +
  +    public void setConstraintType(short constraintType) {
  +        fMiscFlags |= (constraintType & CONSTRAINT_MASK);
  +    }
  +    public void setIsGlobal() {
  +        fMiscFlags |= GLOBAL;
  +    }
   
   } // class XSAttributeDecl
  
  
  
  1.2       +17 -17    xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java
  
  Index: XSAttributeGroupDecl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSAttributeGroupDecl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSAttributeGroupDecl.java	2001/10/25 20:36:02	1.1
  +++ XSAttributeGroupDecl.java	2001/11/01 20:08:00	1.2
  @@ -66,7 +66,7 @@
    * @author Sandy Gao, IBM
    * @author Rahul Srivastava, Sun Microsystems Inc.
    *
  - * @version $Id: XSAttributeGroupDecl.java,v 1.1 2001/10/25 20:36:02 elena Exp $
  + * @version $Id: XSAttributeGroupDecl.java,v 1.2 2001/11/01 20:08:00 sandygao Exp $
    */
   public class XSAttributeGroupDecl {
   
  @@ -166,7 +166,7 @@
           XSAttributeUse attrUse = null;
           XSAttributeDecl attrDecl = null;
           XSAttributeUse baseAttrUse = null;
  -	XSAttributeDecl baseAttrDecl = null;
  +    XSAttributeDecl baseAttrDecl = null;
   
           for (int i=0; i<fAttrUseNum; i++) {
   
  @@ -203,30 +203,30 @@
                // derivation-ok-restriction.  Constraint 2.1.3
                //
                int baseConsType=baseAttrUse.fConstraintType!=XSAttributeDecl.NO_CONSTRAINT?
  -                                 baseAttrUse.fConstraintType:baseAttrDecl.fConstraintType;
  -             int thisConstType = attrUse.fConstraintType!=XSAttributeDecl.NO_CONSTRAINT? 
  -                                 attrUse.fConstraintType:attrDecl.fConstraintType;
  -             
  -             if (baseConsType == XSAttributeDecl.FIXED_VALUE) { 
  -          
  +                                 baseAttrUse.fConstraintType:baseAttrDecl.getConstraintType();
  +             int thisConstType = attrUse.fConstraintType!=XSAttributeDecl.NO_CONSTRAINT?
  +                                 attrUse.fConstraintType:attrDecl.getConstraintType();
  +
  +             if (baseConsType == XSAttributeDecl.FIXED_VALUE) {
  +
                    if (thisConstType != XSAttributeDecl.FIXED_VALUE) {
                      errorCode="derivation-ok-restriction.2.1.3";
                      return errorCode;
                    }
                    else {
  -                   // check the values are the same.  NB - this should not be a string 
  -                   // comparison REVISIT when we have new datatype design! 
  -                   String baseFixedValue=(String) (baseAttrUse.fDefault!=null ? 
  +                   // check the values are the same.  NB - this should not be a string
  +                   // comparison REVISIT when we have new datatype design!
  +                   String baseFixedValue=(String) (baseAttrUse.fDefault!=null ?
                                            baseAttrUse.fDefault: baseAttrDecl.fDefault);
  -                   String thisFixedValue=(String) (attrUse.fDefault!=null ? 
  -                                         attrUse.fDefault: attrDecl.fDefault); 
  +                   String thisFixedValue=(String) (attrUse.fDefault!=null ?
  +                                         attrUse.fDefault: attrDecl.fDefault);
                      if (!baseFixedValue.equals(thisFixedValue)) {
                        errorCode="derivation-ok-restriction.2.1.3";
                        return errorCode;
                      }
   
                    }
  - 
  +
                }
              }
              else {
  @@ -246,7 +246,7 @@
           }
   
           //
  -        // Check that any REQUIRED attributes in the base have matching attributes 
  +        // Check that any REQUIRED attributes in the base have matching attributes
           // in this group
           // derivation-ok-restriction.  Constraint 3
           //
  @@ -255,12 +255,12 @@
              baseAttrUse = baseGroup.fAttributeUses[i];
   
              if (baseAttrUse.fUse == SchemaSymbols.USE_REQUIRED) {
  -           
  +
                baseAttrDecl = baseAttrUse.fAttrDecl;
                // Look for a match in this group
                XSAttributeUse thisAttrUse = getAttributeUse(
                                       baseAttrDecl.fTargetNamespace,baseAttrDecl.fName);
  -             if (thisAttrUse == null) { 
  +             if (thisAttrUse == null) {
                  errorCode = "derivation-ok-restriction.3";
                  return errorCode;
                }
  
  
  
  1.2       +16 -2     xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java
  
  Index: XSElementDecl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSElementDecl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSElementDecl.java	2001/10/25 20:36:02	1.1
  +++ XSElementDecl.java	2001/11/01 20:08:00	1.2
  @@ -65,14 +65,14 @@
    *
    * @author Elena Litani, IBM
    * @author Sandy Gao, IBM
  - * @version $Id: XSElementDecl.java,v 1.1 2001/10/25 20:36:02 elena Exp $
  + * @version $Id: XSElementDecl.java,v 1.2 2001/11/01 20:08:00 sandygao Exp $
    */
   public class XSElementDecl {
   
       // types of value constraint
       public final static short     NO_CONSTRAINT       = 0;
       public final static short     DEFAULT_VALUE       = 1;
  -    public final static short     FIXED_VALUE        = 2;
  +    public final static short     FIXED_VALUE         = 2;
   
       // name of the element
       public String fName = null;
  @@ -98,6 +98,7 @@
       private static final short CONSTRAINT_MASK = 3;
       private static final short NILLABLE        = 4;
       private static final short ABSTRACT        = 8;
  +    private static final short GLOBAL          = 16;
   
       // methods to get/set misc flag
   
  @@ -110,6 +111,9 @@
       public boolean isAbstract() {
           return ((fMiscFlags & ABSTRACT) != 0);
       }
  +    public boolean isGlobal() {
  +        return ((fMiscFlags & GLOBAL) != 0);
  +    }
   
       public void setConstraintType(short constraintType) {
           fMiscFlags |= (constraintType & CONSTRAINT_MASK);
  @@ -120,6 +124,9 @@
       public void setIsAbstract() {
           fMiscFlags |= ABSTRACT;
       }
  +    public void setIsGlobal() {
  +        fMiscFlags |= GLOBAL;
  +    }
   
       public void addIDConstaint(IdentityConstraint idc) {
           if (fIDCPos == fIDConstraints.length) {
  @@ -157,5 +164,12 @@
               fDescription = buffer.toString();
           }
           return fDescription;
  +    }
  +
  +    /**
  +     * get the hash code
  +     */
  +    public int hashCode() {
  +        return (fName.hashCode()<<16)+fTargetNamespace.hashCode();
       }
   } // class XMLElementDecl
  
  
  
  1.3       +8 -5      xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
  
  Index: XSDAttributeTraverser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSDAttributeTraverser.java	2001/10/29 17:10:15	1.2
  +++ XSDAttributeTraverser.java	2001/11/01 20:08:00	1.3
  @@ -88,7 +88,7 @@
    *
    * @author Sandy Gao, IBM
    *
  - * @version $Id: XSDAttributeTraverser.java,v 1.2 2001/10/29 17:10:15 sandygao Exp $
  + * @version $Id: XSDAttributeTraverser.java,v 1.3 2001/11/01 20:08:00 sandygao Exp $
    */
   class XSDAttributeTraverser extends XSDAbstractTraverser {
   
  @@ -179,7 +179,7 @@
               // check 3.5.6 constraint
               // Attribute Use Correct
               // 2 If the {attribute declaration} has a fixed {value constraint}, then if the attribute use itself has a {value constraint}, it must also be fixed and its value must match that of the {attribute declaration}'s {value constraint}.
  -            if (attrUse.fAttrDecl.fConstraintType == XSAttributeDecl.FIXED_VALUE &&
  +            if (attrUse.fAttrDecl.getConstraintType() == XSAttributeDecl.FIXED_VALUE &&
                   attrUse.fConstraintType != XSAttributeDecl.NO_CONSTRAINT) {
                   if (attrUse.fConstraintType != XSAttributeDecl.FIXED_VALUE ||
                       attrUse.fAttrDecl.fType.compare((String)attrUse.fAttrDecl.fDefault,
  @@ -201,6 +201,9 @@
           XSAttributeDecl attribute = traverseNamedAttr(attrDecl, attrValues, schemaDoc, grammar, true);
           fAttrChecker.returnAttrArray(attrValues, schemaDoc);
   
  +        if (attribute != null)
  +            attribute.setIsGlobal();
  +
           return attribute;
       }
   
  @@ -253,12 +256,12 @@
           if (isGlobal) {
               if (fixedAtt != null) {
                   attribute.fDefault = fixedAtt;
  -                attribute.fConstraintType = XSElementDecl.FIXED_VALUE;
  +                attribute.setConstraintType(XSElementDecl.FIXED_VALUE);
               } else if (defaultAtt != null) {
                   attribute.fDefault = defaultAtt;
  -                attribute.fConstraintType = XSElementDecl.DEFAULT_VALUE;
  +                attribute.setConstraintType(XSElementDecl.DEFAULT_VALUE);
               } else {
  -                attribute.fConstraintType = XSElementDecl.NO_CONSTRAINT;
  +                attribute.setConstraintType(XSElementDecl.NO_CONSTRAINT);
               }
           }
   
  
  
  
  1.3       +4 -1      xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
  
  Index: XSDElementTraverser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSDElementTraverser.java	2001/10/29 17:10:15	1.2
  +++ XSDElementTraverser.java	2001/11/01 20:08:00	1.3
  @@ -97,7 +97,7 @@
    *
    * @author Sandy Gao, IBM
    *
  - * @version $Id: XSDElementTraverser.java,v 1.2 2001/10/29 17:10:15 sandygao Exp $
  + * @version $Id: XSDElementTraverser.java,v 1.3 2001/11/01 20:08:00 sandygao Exp $
    */
   class XSDElementTraverser extends XSDAbstractTraverser {
   
  @@ -217,6 +217,9 @@
           Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, true, schemaDoc);
           XSElementDecl element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, true);
           fAttrChecker.returnAttrArray(attrValues, schemaDoc);
  +
  +        if (element != null)
  +            element.setIsGlobal();
   
           return element;
       }
  
  
  

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