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/10/25 15:09:15 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 XSDHandler.java XSDKeyrefTraverser.java

sandygao    01/10/25 06:09:15

  Modified:    java/src/org/apache/xerces/impl/msg
                        XMLSchemaMessages.properties
               java/src/org/apache/xerces/impl/v2 XSDHandler.java
                        XSDKeyrefTraverser.java
  Log:
  1. Fixing a bug in KeyrefTraverser: after XSDHandler#getGlobalDecl(),
  we need to check whether the returned component is a key or unique.
  if it's a keyref, we need to report an error.
  2. Also updated some error message for XSDHandler#getGlobalDecl().
  
  Revision  Changes    Path
  1.26      +2 -1      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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- XMLSchemaMessages.properties	2001/10/24 15:07:50	1.25
  +++ XMLSchemaMessages.properties	2001/10/25 13:09:15	1.26
  @@ -188,7 +188,8 @@
           src-redefine.6.1.1 = src-redefine.6.1.1:  if a group child of a <redefine> element contains an group ref'ing itself, it must have exactly 1; this one has ''{0}''.
           src-redefine.6.1.2 = src-redefine.6.1.2:  the group ''{0}'' which contains a reference to a group being redefined must have minOccurs = maxOccurs = 1.
           src-redefine.7.1 = src-redefine.7.1:  if an attributeGroup child of a <redefine> element contains an attributeGroup ref'ing itself, it must have exactly 1; this one has ''{0}''.
  -        src-resolve = src-resolve: error.
  +        src-resolve = src-resolve: Cannot resolve the name ''{0}'' to a(n) {1} component.
  +        src-resolve.4 = src-resolve.4: Components from namespace ''{1}'' are not referenceable from schema document ''{0}''.
           src-restriction-base-or-simpleType = src-restriction-base-or-simpleType: error.
           src-simple-type = src-simple-type: error.
           src-single-facet-value = src-single-facet-value: error.
  
  
  
  1.56      +16 -4     xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java
  
  Index: XSDHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- XSDHandler.java	2001/10/25 13:03:18	1.55
  +++ XSDHandler.java	2001/10/25 13:09:15	1.56
  @@ -97,7 +97,7 @@
    * schema, other grammars may be constructed as a side-effect.
    *
    * @author Neil Graham, IBM
  - * @version $Id: XSDHandler.java,v 1.55 2001/10/25 13:03:18 elena Exp $
  + * @version $Id: XSDHandler.java,v 1.56 2001/10/25 13:09:15 sandygao Exp $
    */
   
   class XSDHandler {
  @@ -654,6 +654,17 @@
           } // while
       } // end traverseSchemas
   
  +    private static final String[] COMP_TYPE = {
  +        null,               // index 0
  +        "attribute declaration",
  +        "attribute group",
  +        "elment declaration",
  +        "group",
  +        "identity constraint",
  +        "notation",
  +        "type definition",
  +    };
  +
       // since it is forbidden for traversers to talk to each other
       // directly (except wen a traverser encounters a local declaration),
       // this provides a generic means for a traverser to call
  @@ -723,14 +734,13 @@
           if (decl != null)
               schemaWithDecl = findXSDocumentForDecl(currSchema, decl);
           else {
  -            reportGenericSchemaError("Could not locate a component corresponding to " + declToTraverse.localpart);
  +            reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]});
               return null;
           }
   
           if (schemaWithDecl == null) {
               // cannot get to this schema from the one containing the requesting decl
  -            // REVISIT: report component not found error
  -            reportGenericSchemaError("components from the schema document containing " + declToTraverse.localpart + " are not referenceable from schema document " + currSchema);
  +            reportSchemaError("src-resolve.4", new Object[]{currSchema, declToTraverse.uri});
               return null;
           }
           SchemaGrammar sGrammar = fGrammarResolver.getGrammar(schemaWithDecl.fTargetNamespace);
  @@ -791,7 +801,9 @@
               break;
           case IDENTITYCONSTRAINT_TYPE :
               // identity constraints should have been parsed already...
  +            // we should never get here
               retObj = null;
  +            break;
           case NOTATION_TYPE :
               retObj = fNotationTraverser.traverse(decl, schemaWithDecl, sGrammar);
               break;
  
  
  
  1.10      +14 -4     xml-xerces/java/src/org/apache/xerces/impl/v2/XSDKeyrefTraverser.java
  
  Index: XSDKeyrefTraverser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDKeyrefTraverser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XSDKeyrefTraverser.java	2001/10/24 15:07:50	1.9
  +++ XSDKeyrefTraverser.java	2001/10/25 13:09:15	1.10
  @@ -68,7 +68,7 @@
    * This class contains code that is used to traverse <keyref>s.
    *
    * @author Neil Graham, IBM
  - * @version $Id: XSDKeyrefTraverser.java,v 1.9 2001/10/24 15:07:50 sandygao Exp $
  + * @version $Id: XSDKeyrefTraverser.java,v 1.10 2001/10/25 13:09:15 sandygao Exp $
    */
   class XSDKeyrefTraverser extends XSDAbstractIDConstraintTraverser {
   
  @@ -98,11 +98,21 @@
               fAttrChecker.returnAttrArray(attrValues, schemaDoc);
               return;
           }
  -        UniqueOrKey key = (UniqueOrKey)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, kName);
   
  +        UniqueOrKey key = null;
  +        IdentityConstraint ret = (IdentityConstraint)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, kName);
  +        // if ret == null, we've already reported an error in getGlobalDecl
  +        // we report an error only when ret != null, and the return type keyref
  +        if (ret != null) {
  +            if (ret.getType() == IdentityConstraint.KEY ||
  +                ret.getType() == IdentityConstraint.UNIQUE) {
  +                key = (UniqueOrKey)ret;
  +            } else {
  +                reportSchemaError("src-resolve", new Object[]{kName.rawname, "identity constraint key/unique"});
  +            }
  +        }
  +
           if(key == null) {
  -            // reportSchemaError(SchemaMessageProvider.KeyRefReferNotFound,
  -                              // new Object[]{krName,kName});
               fAttrChecker.returnAttrArray(attrValues, schemaDoc);
               return;
           }
  
  
  

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