Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1731

XML Schema validation error message improvements, when XML attributes are validated

    XMLWordPrintableJSON

Details

    Description

      I've been using the following XML Schema validation example, for this issue.

      XML Schema document,

      <?xml version="1.0"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                          elementFormDefault="qualified"
                          attributeFormDefault="qualified"
                          targetNamespace="http://ns0">

            <xs:element name="X">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element name="a" type="xs:string"/>
                     </xs:sequence>
                     <xs:attribute name="att1" type="xs:integer" use="required"/>
                 </xs:complexType>
             </xs:element>

      </xs:schema>

      XML instance document, that's validated with above mentioned XML Schema document,

      <?xml version="1.0"?>
      <X xmlns="http://ns0" att1="105">
          <a>hello</a>
      </X>

      Upon doing, above mentioned XML Schema validation, XercesJ currently produces following two error messages,

      cvc-complex-type.3.2.2: Attribute 'att1' is not allowed to appear in element 'X'.
      cvc-complex-type.4: Attribute 'att1' must appear on element 'X'.

      I find, above mentioned error messages little bit confusing.

      I propose that, the second error message cited above should contain namespace information as well, something like following,

      cvc-complex-type.4: Attribute 'att1' belonging to namespace 'http://ns0', must appear on element 'X'.

      Attachments

        Activity

          People

            mukul_gandhi Mukul Gandhi
            mukul_gandhi Mukul Gandhi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: