Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-2243

choice validation with branch an empty sequence does not validate correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Say we have this schema, which contains a choice where one branch is an empty sequence:

      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      
        <xs:element name="root">
          <xs:complexType>
            <xs:choice>
              <xs:element name="foo" type="xs:int" />
              <xs:sequence />
            </xs:choice>
          </xs:complexType>
        </xs:element>
      
      </xs:schema>
      

      This XML with a foo child validates correctly:

      <root>
        <foo>3</foo>
      </root>
      

      But, this fails to validate:

      <root></root>
      

      With error message:

      Message: empty content is not valid for content model '(foo)'

      Related, if you change the XML to this, it also fails to validate:

      <root/>
      

      But with a slightly different error message:

      Message: element 'root' is not allowed for content model '(foo)'

      The expected behavior is that all above XML snippets should validate.

      Note that in our specific case, the empty sequence has annotations on it that make the branch meaningful even though it seems empty from an XML schema perspective. Adding something like minOccurs="0" to the choice or the foo element is not possible.

      Attachments

        Activity

          People

            Unassigned Unassigned
            slawrence Steve Lawrence
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: