You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/06/01 22:08:47 UTC

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

neilg       01/06/01 13:08:46

  Modified:    java/src/org/apache/xerces/validators/schema
                        TraverseSchema.java
               java/src/org/apache/xerces/validators/schema/identity
                        XPath.java Selector.java Field.java
  Log:
  identity constraint bugfixes
  
  Revision  Changes    Path
  1.185     +14 -1     xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java
  
  Index: TraverseSchema.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java,v
  retrieving revision 1.184
  retrieving revision 1.185
  diff -u -r1.184 -r1.185
  --- TraverseSchema.java	2001/05/31 21:13:14	1.184
  +++ TraverseSchema.java	2001/06/01 20:08:43	1.185
  @@ -128,7 +128,7 @@
    *  
    * @see org.apache.xerces.validators.common.Grammar
    *
  - * @version $Id: TraverseSchema.java,v 1.184 2001/05/31 21:13:14 neilg Exp $
  + * @version $Id: TraverseSchema.java,v 1.185 2001/06/01 20:08:43 neilg Exp $
    */
   public class TraverseSchema implements 
                               NamespacesScope.NamespacesHandler{
  @@ -6836,6 +6836,9 @@
           }
           String eName = getElementNameFor(uElem);
           Unique unique = new Unique(uName, eName);
  +        if(fIdentityConstraintNames.get(fTargetNSURIString+","+uName) != null) {
  +            reportGenericSchemaError("More than one identity constraint named " + uName);
  +        }
           fIdentityConstraintNames.put(fTargetNSURIString+","+uName, unique);
   
           // get selector and fields
  @@ -6860,6 +6863,9 @@
           }
           String eName = getElementNameFor(kElem);
           Key key = new Key(kName, eName);
  +        if(fIdentityConstraintNames.get(fTargetNSURIString+","+kName) != null) {
  +            reportGenericSchemaError("More than one identity constraint named " + kName);
  +        }
           fIdentityConstraintNames.put(fTargetNSURIString+","+kName, key);
   
           // get selector and fields
  @@ -6884,6 +6890,10 @@
               System.out.println("<IC>: traverseKeyRef(\""+krElem.getNodeName()+"\") ["+krName+','+kName+']');
           }
   
  +        if(fIdentityConstraintNames.get(fTargetNSURIString+","+krName) != null) {
  +            reportGenericSchemaError("More than one identity constraint named " + krName);
  +        }
  +
           // verify that key reference "refer" attribute is valid
           String prefix = "";
           String localpart = kName;
  @@ -6908,6 +6918,9 @@
   
           // add key reference to element decl
           eDecl.keyRef.addElement(keyRef);
  +        // store in fIdentityConstraintNames so can flag schemas in which multiple
  +        // keyrefs with the same name are present.
  +        fIdentityConstraintNames.put(fTargetNSURIString+","+krName, keyRef);  
   
       } // traverseKeyRef(Element,XMLElementDecl)
   
  
  
  
  1.9       +11 -6     xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPath.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XPath.java	2001/05/16 14:18:38	1.8
  +++ XPath.java	2001/06/01 20:08:44	1.9
  @@ -66,7 +66,7 @@
    * Bare minimum XPath parser.
    *
    * @author Andy Clark, IBM
  - * @version $Id: XPath.java,v 1.8 2001/05/16 14:18:38 neilg Exp $
  + * @version $Id: XPath.java,v 1.9 2001/06/01 20:08:44 neilg Exp $
    */
   public class XPath {
   
  @@ -207,7 +207,7 @@
               switch (token) {
   				case  XPath.Tokens.EXPRTOKEN_OPERATOR_UNION :{
   					if (i == 0) {
  -						throw new XPathException("not allowed to have '|' here");
  +						throw new XPathException("not allowed to have '|' at the beginning of an xpath value");
   					}
   					
   					int size = stepsVector.size();
  @@ -410,6 +410,9 @@
   					throw new XPathException("'//' only allowed after '.' at the beginning of an xpath");
   				}
                   case XPath.Tokens.EXPRTOKEN_OPERATOR_SLASH: {
  +					if (i == 0) {
  +						throw new XPathException("not allowed to have '/' at the beginning of an xpath value");
  +					}
                       // keep on truckin'
   					if (firstTokenOfLocationPath) {
                           throw new XPathException("not allowed to select the root");
  @@ -773,7 +776,7 @@
        * @author Glenn Marcy, IBM
        * @author Andy Clark, IBM
        *
  -     * @version $Id: XPath.java,v 1.8 2001/05/16 14:18:38 neilg Exp $
  +     * @version $Id: XPath.java,v 1.9 2001/06/01 20:08:44 neilg Exp $
        */
       private static final class Tokens {
       
  @@ -1287,7 +1290,7 @@
        * @author Glenn Marcy, IBM
        * @author Andy Clark, IBM
        *
  -     * @version $Id: XPath.java,v 1.8 2001/05/16 14:18:38 neilg Exp $
  +     * @version $Id: XPath.java,v 1.9 2001/06/01 20:08:44 neilg Exp $
        */
       private static class Scanner {
       
  @@ -1571,10 +1574,12 @@
                           addToken(tokens, XPath.Tokens.EXPRTOKEN_NUMBER);
                           starIsMultiplyOperator = true;
                           currentOffset = scanNumber(tokens, data, endOffset, currentOffset/*, encoding*/);
  -                    } else {                    // '.'
  +                    } else if (ch == '/') {
                           addToken(tokens, XPath.Tokens.EXPRTOKEN_PERIOD);
                           starIsMultiplyOperator = true;
                           currentOffset++;
  +                    } else {                    // '.'
  +                        throw new XPathException ("Invalid character following '.'");
                       }
                       if (currentOffset == endOffset) {
                           break;
  @@ -2343,7 +2348,7 @@
        * @author Glenn Marcy, IBM
        * @author Andy Clark, IBM
        *
  -     * @version $Id: XPath.java,v 1.8 2001/05/16 14:18:38 neilg Exp $
  +     * @version $Id: XPath.java,v 1.9 2001/06/01 20:08:44 neilg Exp $
        */
       /***
       public static class XPathExprParser {
  
  
  
  1.12      +4 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Selector.java	2001/05/15 22:18:15	1.11
  +++ Selector.java	2001/06/01 20:08:45	1.12
  @@ -69,7 +69,7 @@
    * Schema identity constraint selector.
    *
    * @author Andy Clark, IBM
  - * @version $Id: Selector.java,v 1.11 2001/05/15 22:18:15 neilg Exp $
  + * @version $Id: Selector.java,v 1.12 2001/06/01 20:08:45 neilg Exp $
    */
   public class Selector {
   
  @@ -132,7 +132,7 @@
        * Schema identity constraint selector XPath expression.
        *
        * @author Andy Clark, IBM
  -     * @version $Id: Selector.java,v 1.11 2001/05/15 22:18:15 neilg Exp $
  +     * @version $Id: Selector.java,v 1.12 2001/06/01 20:08:45 neilg Exp $
        */
       public static class XPath
           extends org.apache.xerces.validators.schema.identity.XPath {
  @@ -149,7 +149,8 @@
               //       the element container because the fields could be
               //       relative to that element. -Ac
   			//       Unless xpath starts with a descendant node -Achille Fokoue
  -			super(((xpath.trim().startsWith("//") ||xpath.trim().startsWith(".//"))?
  +            //      ... or a '.' or a '/' - NG
  +			super(((xpath.trim().startsWith("/") ||xpath.trim().startsWith("."))?
   				xpath:"./"+xpath), stringPool, context);
       
               // verify that an attribute is not selected
  
  
  
  1.10      +3 -2      xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Field.java	2001/05/15 17:21:28	1.9
  +++ Field.java	2001/06/01 20:08:45	1.10
  @@ -68,7 +68,7 @@
    * Schema identity constraint field.
    *
    * @author Andy Clark, IBM
  - * @version $Id: Field.java,v 1.9 2001/05/15 17:21:28 neilg Exp $
  + * @version $Id: Field.java,v 1.10 2001/06/01 20:08:45 neilg Exp $
    */
   public class Field {
   
  @@ -166,7 +166,8 @@
               //       select the attribute because the fields could be
               //       relative to the selector element. -Ac
   			//       Unless xpath starts with a descendant node -Achille Fokoue
  -			super(((xpath.trim().startsWith("//") ||xpath.trim().startsWith(".//"))?
  +            //      ... or a / or a . - NG
  +			super(((xpath.trim().startsWith("/") ||xpath.trim().startsWith("."))?
   				xpath:"./"+xpath), stringPool, context);
   			
           } // <init>(String,StringPool,NamespacesScope)
  
  
  

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