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



On Thu, Aug 01, 2002 at 06:00:03PM -0700, Rick Jones wrote:
I've been debugging a DTD and XML file for my netperf4 work and was
getting error messages like:

netperf_config.xml:118: validity error: Value "Tran" for attribute units
on throughput is not among the enumerated set
                    end="later">1235.67</throughput>
                 ^

I have seen where that message is generated in valid.c - does anyone
else think that displaying the valid enumerated values would be of value
here?

  Well the problem is that you may end-up potentially with a really long list

If so I may take a stab at a patch. It does look a triffle ugly -
having to build-up a string by walking the tree again:

    /* Validity Constraint: Enumeration */
    if (attrDecl->atype == XML_ATTRIBUTE_ENUMERATION) {
        xmlEnumerationPtr tree = attrDecl->tree;
      while (tree != NULL) {
          if (xmlStrEqual(tree->name, value)) break;
          tree = tree->next;
      }
      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;
      }
    }

  yup, that's the place

I don't think it would be apropriate to build the list as the tree is
walked the first time - that would be optimizing for an error case.

  agreed too. That list exists but not as a string ...

Also, shouldn't that be "...for attribute %s of element %s..." (of
replacing on)? _That_ patch would be easy :)

  I don't claim any grammar correctness, fixes at that level are welcome !

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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