You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/02/21 10:57:16 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema/identity Selector.java

andyc       01/02/21 01:57:16

  Modified:    java/src/org/apache/xerces/validators/common
                        XMLValidator.java
               java/src/org/apache/xerces/validators/schema/identity
                        Selector.java
  Log:
  More fixes to identity constraint support:
  1) Fixed bug that was activating fields at multiple element
     levels instead of just at the level where the selector
     was matched.
  2) Fixed bug that was only allowing one complete set of
     field matches per identity constraint scope.
  
  Revision  Changes    Path
  1.122     +40 -18    xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
  
  Index: XMLValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- XMLValidator.java	2001/02/21 08:08:36	1.121
  +++ XMLValidator.java	2001/02/21 09:57:15	1.122
  @@ -121,7 +121,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.121 2001/02/21 08:08:36 andyc Exp $
  + * @version $Id: XMLValidator.java,v 1.122 2001/02/21 09:57:15 andyc Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -4303,15 +4303,6 @@
                   return;
               }
               
  -            // is this value as a group duplicated?
  -            if (contains(fValues)) {
  -                duplicateValue(fValues);
  -            }
  -
  -            // store values
  -            OrderedHashtable values = (OrderedHashtable)fValues.clone();
  -            fValueTuples.addElement(values);
  -
           } // endValueScope()
   
           /** 
  @@ -4353,18 +4344,24 @@
                   return;
               }    
   
  -            // duplicate value?
  +            // store value
               String storedValue = fValues.valueAt(index);
  -            if (!storedValue.equals(NOT_A_VALUE)) {
  -                int code = SchemaMessageProvider.DuplicateField;
  -                reportSchemaError(code, new Object[]{field.toString()});
  -                return;
  +            if (storedValue.equals(NOT_A_VALUE)) {
  +                fValuesCount++;
               }
  -
  -            // store value
  -            fValuesCount++;
               fValues.put(field, value);
   
  +            if (fValuesCount == fValues.size()) {
  +                // is this value as a group duplicated?
  +                if (contains(fValues)) {
  +                    duplicateValue(fValues);
  +                }
  +    
  +                // store values
  +                OrderedHashtable values = (OrderedHashtable)fValues.clone();
  +                fValueTuples.addElement(values);
  +            }
  +
           } // addValue(String,Field)
   
           /** 
  @@ -4908,6 +4905,31 @@
               return hashtable;
   
           } // clone():Object
  +
  +        //
  +        // Object methods
  +        //
  +
  +        /** Returns a string representation of this object. */
  +        public String toString() {
  +            if (fSize == 0) {
  +                return "[]";
  +            }
  +            StringBuffer str = new StringBuffer();
  +            str.append('[');
  +            for (int i = 0; i < fSize; i++) {
  +                if (i > 0) {
  +                    str.append(',');
  +                }
  +                str.append('{');
  +                str.append(fEntries[i].key);
  +                str.append(',');
  +                str.append(fEntries[i].value);
  +                str.append('}');
  +            }
  +            str.append(']');
  +            return str.toString();
  +        } // toString():String
   
           //
           // Classes
  
  
  
  1.6       +3 -3      xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Selector.java	2001/02/20 07:47:05	1.5
  +++ Selector.java	2001/02/21 09:57:16	1.6
  @@ -68,7 +68,7 @@
    * Schema identity constraint selector.
    *
    * @author Andy Clark, IBM
  - * @version $Id: Selector.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
  + * @version $Id: Selector.java,v 1.6 2001/02/21 09:57:16 andyc Exp $
    */
   public class Selector {
   
  @@ -131,7 +131,7 @@
        * Schema identity constraint selector XPath expression.
        *
        * @author Andy Clark, IBM
  -     * @version $Id: Selector.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
  +     * @version $Id: Selector.java,v 1.6 2001/02/21 09:57:16 andyc Exp $
        */
       public static class XPath
           extends org.apache.xerces.validators.schema.identity.XPath {
  @@ -218,7 +218,7 @@
               fElementDepth++;
       
               // activate the fields, if selector is matched
  -            if (isMatched()) {
  +            if (fMatchedDepth == -1 && isMatched()) {
                   fMatchedDepth = fElementDepth;
                   fFieldActivator.startValueScopeFor(fIdentityConstraint);
                   int count = fIdentityConstraint.getFieldCount();