patch Re: [xml] List valid values upon enumeration failure?



attached is a diff for the 2.4.23 valid.c that does some nitpicky
grammar cleanup on error and warning messages. i decided to dismiss the
notion of walking the enumerated lists for output in the error messages.

rick jones

-- 
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to raj in cup.hp.com  but NOT BOTH...
*** valid.c.orig        Fri Aug  2 13:16:03 2002
--- valid.c     Fri Aug  2 13:25:07 2002
***************
*** 1299,1305 ****
      }
      if ((defaultValue != NULL) && 
          (!xmlValidateAttributeValue(type, defaultValue))) {
!       VERROR(ctxt->userData, "Attribute %s on %s: invalid default value\n",
               elem, name, defaultValue);
        defaultValue = NULL;
        ctxt->valid = 0;
--- 1299,1305 ----
      }
      if ((defaultValue != NULL) && 
          (!xmlValidateAttributeValue(type, defaultValue))) {
!       VERROR(ctxt->userData, "Attribute %s of %s: invalid default value\n",
               elem, name, defaultValue);
        defaultValue = NULL;
        ctxt->valid = 0;
***************
*** 1362,1368 ****
         * The attribute is already defined in this DTD.
         */
        VWARNING(ctxt->userData,
!                "Attribute %s on %s: already defined\n",
                 name, elem);
        xmlFreeAttribute(ret);
        return(NULL);
--- 1362,1368 ----
         * The attribute is already defined in this DTD.
         */
        VWARNING(ctxt->userData,
!                "Attribute %s of element %s: already defined\n",
                 name, elem);
        xmlFreeAttribute(ret);
        return(NULL);
***************
*** 3203,3209 ****
        val = xmlValidateAttributeValue(attr->atype, attr->defaultValue);
        if (val == 0) {
            VERROR(ctxt->userData, 
!              "Syntax of default value for attribute %s on %s is not valid\n",
                   attr->name, attr->elem);
        }
          ret &= val;
--- 3203,3209 ----
        val = xmlValidateAttributeValue(attr->atype, attr->defaultValue);
        if (val == 0) {
            VERROR(ctxt->userData, 
!              "Syntax of default value for attribute %s of %s is not valid\n",
                   attr->name, attr->elem);
        }
          ret &= val;
***************
*** 3214,3220 ****
          (attr->def != XML_ATTRIBUTE_IMPLIED) &&
        (attr->def != XML_ATTRIBUTE_REQUIRED)) {
        VERROR(ctxt->userData, 
!           "ID attribute %s on %s is not valid must be #IMPLIED or #REQUIRED\n",
               attr->name, attr->elem);
        ret = 0;
      }
--- 3214,3220 ----
          (attr->def != XML_ATTRIBUTE_IMPLIED) &&
        (attr->def != XML_ATTRIBUTE_REQUIRED)) {
        VERROR(ctxt->userData, 
!           "ID attribute %s of %s is not valid must be #IMPLIED or #REQUIRED\n",
               attr->name, attr->elem);
        ret = 0;
      }
***************
*** 3271,3277 ****
        }
        if (tree == NULL) {
            VERROR(ctxt->userData, 
! "Default value \"%s\" for attribute %s on %s is not among the enumerated set\n",
                   attr->defaultValue, attr->name, attr->elem);
            ret = 0;
        }
--- 3271,3277 ----
        }
        if (tree == NULL) {
            VERROR(ctxt->userData, 
! "Default value \"%s\" for attribute %s of %s is not among the enumerated set\n",
                   attr->defaultValue, attr->name, attr->elem);
            ret = 0;
        }
***************
*** 3445,3451 ****
      /* Validity Constraint: Attribute Value Type */
      if (attrDecl == NULL) {
        VERROR(ctxt->userData,
!              "No declaration for attribute %s on element %s\n",
               attr->name, elem->name);
        return(0);
      }
--- 3445,3451 ----
      /* Validity Constraint: Attribute Value Type */
      if (attrDecl == NULL) {
        VERROR(ctxt->userData,
!              "No declaration for attribute %s of element %s\n",
               attr->name, elem->name);
        return(0);
      }
***************
*** 3454,3460 ****
      val = xmlValidateAttributeValue(attrDecl->atype, value);
      if (val == 0) {
        VERROR(ctxt->userData, 
!          "Syntax of value for attribute %s on %s is not valid\n",
               attr->name, elem->name);
          ret = 0;
      }
--- 3454,3460 ----
      val = xmlValidateAttributeValue(attrDecl->atype, value);
      if (val == 0) {
        VERROR(ctxt->userData, 
!          "Syntax of value for attribute %s of %s is not valid\n",
               attr->name, elem->name);
          ret = 0;
      }
***************
*** 3463,3469 ****
      if (attrDecl->def == XML_ATTRIBUTE_FIXED) {
        if (!xmlStrEqual(value, attrDecl->defaultValue)) {
            VERROR(ctxt->userData, 
!          "Value for attribute %s on %s is different from default \"%s\"\n",
                   attr->name, elem->name, attrDecl->defaultValue);
            ret = 0;
        }
--- 3463,3469 ----
      if (attrDecl->def == XML_ATTRIBUTE_FIXED) {
        if (!xmlStrEqual(value, attrDecl->defaultValue)) {
            VERROR(ctxt->userData, 
!          "Value for attribute %s of %s is different from default \"%s\"\n",
                   attr->name, elem->name, attrDecl->defaultValue);
            ret = 0;
        }
***************
*** 3493,3499 ****
        
        if (nota == NULL) {
            VERROR(ctxt->userData, 
!        "Value \"%s\" for attribute %s on %s is not a declared Notation\n",
                   value, attr->name, elem->name);
            ret = 0;
          }
--- 3493,3499 ----
        
        if (nota == NULL) {
            VERROR(ctxt->userData, 
!        "Value \"%s\" for attribute %s of %s is not a declared Notation\n",
                   value, attr->name, elem->name);
            ret = 0;
          }
***************
*** 3505,3511 ****
        }
        if (tree == NULL) {
            VERROR(ctxt->userData, 
! "Value \"%s\" for attribute %s on %s is not among the enumerated notations\n",
                   value, attr->name, elem->name);
            ret = 0;
        }
--- 3505,3511 ----
        }
        if (tree == NULL) {
            VERROR(ctxt->userData, 
! "Value \"%s\" for attribute %s of %s is not among the enumerated notations\n",
                   value, attr->name, elem->name);
            ret = 0;
        }
***************
*** 3520,3526 ****
        }
        if (tree == NULL) {
            VERROR(ctxt->userData, 
!        "Value \"%s\" for attribute %s on %s is not among the enumerated set\n",
                   value, attr->name, elem->name);
            ret = 0;
        }
--- 3520,3526 ----
        }
        if (tree == NULL) {
            VERROR(ctxt->userData, 
!        "Value \"%s\" for attribute %s of %s is not among the enumerated set\n",
                   value, attr->name, elem->name);
            ret = 0;
        }
***************
*** 3530,3536 ****
      if ((attrDecl->def == XML_ATTRIBUTE_FIXED) &&
          (!xmlStrEqual(attrDecl->defaultValue, value))) {
        VERROR(ctxt->userData, 
!          "Value for attribute %s on %s must be \"%s\"\n",
               attr->name, elem->name, attrDecl->defaultValue);
          ret = 0;
      }
--- 3530,3536 ----
      if ((attrDecl->def == XML_ATTRIBUTE_FIXED) &&
          (!xmlStrEqual(attrDecl->defaultValue, value))) {
        VERROR(ctxt->userData, 
!          "Value for attribute %s of %s must be \"%s\"\n",
               attr->name, elem->name, attrDecl->defaultValue);
          ret = 0;
      }
***************
*** 4082,4088 ****
      ret = xmlValidateElementType(ctxt);
      if ((ret == -3) && (warn)) {
        VWARNING(ctxt->userData,
!          "Element %s content model is ambiguous\n", name);
      } else if (ret == -2) {
        /*
         * An entities reference appeared at this level.
--- 4082,4088 ----
      ret = xmlValidateElementType(ctxt);
      if ((ret == -3) && (warn)) {
        VWARNING(ctxt->userData,
!          "Content model for Element %s is ambiguous\n", name);
      } else if (ret == -2) {
        /*
         * An entities reference appeared at this level.
***************
*** 4185,4205 ****
  
            if (name != NULL) {
                VERROR(ctxt->userData,
!          "Element %s content doesn't follow the DTD\nExpecting %s, got %s\n",
                       name, expr, list);
            } else {
                VERROR(ctxt->userData,
!          "Element content doesn't follow the DTD\nExpecting %s, got %s\n",
                       expr, list);
            }
        } else {
            if (name != NULL) {
                VERROR(ctxt->userData,
!                      "Element %s content doesn't follow the DTD\n",
                       name);
            } else {
                VERROR(ctxt->userData,
!                      "Element content doesn't follow the DTD\n");
            }
        }
        ret = 0;
--- 4185,4205 ----
  
            if (name != NULL) {
                VERROR(ctxt->userData,
!          "Element %s content does not follow the DTD\nExpecting %s, got %s\n",
                       name, expr, list);
            } else {
                VERROR(ctxt->userData,
!          "Element content does not follow the DTD\nExpecting %s, got %s\n",
                       expr, list);
            }
        } else {
            if (name != NULL) {
                VERROR(ctxt->userData,
!                      "Element %s content does not follow the DTD\n",
                       name);
            } else {
                VERROR(ctxt->userData,
!                      "Element content does not follow the DTD\n");
            }
        }
        ret = 0;
***************
*** 4620,4631 ****
            if (qualified == -1) {
                if (attr->prefix == NULL) {
                    VERROR(ctxt->userData,
!                      "Element %s doesn't carry attribute %s\n",
                           elem->name, attr->name);
                    ret = 0;
                } else {
                    VERROR(ctxt->userData,
!                      "Element %s doesn't carry attribute %s:%s\n",
                           elem->name, attr->prefix,attr->name);
                    ret = 0;
                }
--- 4620,4631 ----
            if (qualified == -1) {
                if (attr->prefix == NULL) {
                    VERROR(ctxt->userData,
!                      "Element %s does not carry attribute %s\n",
                           elem->name, attr->name);
                    ret = 0;
                } else {
                    VERROR(ctxt->userData,
!                      "Element %s does not carry attribute %s:%s\n",
                           elem->name, attr->prefix,attr->name);
                    ret = 0;
                }
***************
*** 4669,4675 ****
                    if (xmlStrEqual(attr->name, ns->prefix)) {
                        if (!xmlStrEqual(attr->defaultValue, ns->href)) {
                            VERROR(ctxt->userData,
!                  "Element %s namespace name for %s doesn't match the DTD\n",
                                   elem->name, ns->prefix);
                            ret = 0;
                        }
--- 4669,4675 ----
                    if (xmlStrEqual(attr->name, ns->prefix)) {
                        if (!xmlStrEqual(attr->defaultValue, ns->href)) {
                            VERROR(ctxt->userData,
!                  "Element %s namespace name for %s does not match the DTD\n",
                                   elem->name, ns->prefix);
                            ret = 0;
                        }
***************
*** 4732,4738 ****
                (xmlStrEqual(root->name, BAD_CAST "html")))
                goto name_ok;
            VERROR(ctxt->userData,
!                  "Not valid: root and DtD name do not match '%s' and '%s'\n",
                   root->name, doc->intSubset->name);
            return(0);
            
--- 4732,4738 ----
                (xmlStrEqual(root->name, BAD_CAST "html")))
                goto name_ok;
            VERROR(ctxt->userData,
!                  "Not valid: root and DTD name do not match '%s' and '%s'\n",
                   root->name, doc->intSubset->name);
            return(0);
            
***************
*** 4820,4826 ****
        id = xmlGetID(ctxt->doc, name);
        if (id == NULL) {
            VERROR(ctxt->userData, 
!              "IDREF attribute %s reference an unknown ID \"%s\"\n",
                   attr->name, name);
            ctxt->valid = 0;
        }
--- 4820,4826 ----
        id = xmlGetID(ctxt->doc, name);
        if (id == NULL) {
            VERROR(ctxt->userData, 
!              "IDREF attribute %s references an unknown ID \"%s\"\n",
                   attr->name, name);
            ctxt->valid = 0;
        }
***************
*** 4841,4847 ****
            id = xmlGetID(ctxt->doc, str);
            if (id == NULL) {
                VERROR(ctxt->userData, 
!              "IDREFS attribute %s reference an unknown ID \"%s\"\n",
                       attr->name, str);
                ctxt->valid = 0;
            }
--- 4841,4847 ----
            id = xmlGetID(ctxt->doc, str);
            if (id == NULL) {
                VERROR(ctxt->userData, 
!              "IDREFS attribute %s references an unknown ID \"%s\"\n",
                       attr->name, str);
                ctxt->valid = 0;
            }
***************
*** 5050,5056 ****
        }
        if (elem->etype == XML_ELEMENT_TYPE_EMPTY) {
            VERROR(ctxt->userData, 
!                  "NOTATION attribute %s declared on EMPTY element %s\n",
                   cur->name, cur->elem);
            ctxt->valid = 0;
        }
--- 5050,5056 ----
        }
        if (elem->etype == XML_ELEMENT_TYPE_EMPTY) {
            VERROR(ctxt->userData, 
!                  "NOTATION attribute %s declared for EMPTY element %s\n",
                   cur->name, cur->elem);
            ctxt->valid = 0;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]