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

Alternative type is not detected correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 2.11.0
    • None
    • None

    Description

      When I validate the following xml document with the associated schema, I get the error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'NameFr'. One of '

      {NameEn}

      ' is expected.
      There should be no error because the lang attribute is inheritable, and the Author element type should be frAuthorType.
      I tested on the xml-schema-1.1-dev branch.

      ---------XML Document----------------
      <BookStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
      <Book lang="fr">
      <TitleFr></TitleFr>
      <Author>
      <NameFr></NameFr>
      </Author>
      </Book>
      </BookStore>
      -----------------------------------------------------

      -------------- schema.xsd -----------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
      <xs:element name="BookStore">
      <xs:complexType>
      <xs:sequence>
      <xs:element ref="Book" maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>

      <xs:element name="Book">
      <xs:alternative test="@lang='en'" type="enType"/>
      <xs:alternative test="@lang='fr'" type="frType"/>
      </xs:element>

      <xs:element name="Author">
      <xs:alternative test="@lang='en'" type="enAuthorType"/>
      <xs:alternative test="@lang='fr'" type="frAuthorType"/>
      <xs:alternative type="enAuthorType"/>
      </xs:element>

      <xs:complexType name="enType">
      <xs:sequence>
      <xs:element name="TitleEn" type="xs:string"/>
      <xs:element ref="Author"/>
      </xs:sequence>
      <xs:attribute name="lang" inheritable="true" type="xs:string"/>
      </xs:complexType>

      <xs:complexType name="frType">
      <xs:sequence>
      <xs:element name="TitleFr" type="xs:string"/>
      <xs:element ref="Author"/>
      </xs:sequence>
      <xs:attribute name="lang" inheritable="true" type="xs:string"/>
      </xs:complexType>

      <xs:complexType name="enAuthorType">
      <xs:sequence>
      <xs:element name="NameEn" type="xs:string"/>
      </xs:sequence>
      </xs:complexType>

      <xs:complexType name="frAuthorType">
      <xs:sequence>
      <xs:element name="NameFr" type="xs:string"/>
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      ---------------------------------------------------------

      Attachments

        Activity

          People

            mrglavas@ca.ibm.com Michael Glavassevich
            octavian.nadolu Octavian Nadolu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: