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

Processing of not-declared-element with "xsi:type" under anyType element does not clear SchemaValidator::fXsiType

    XMLWordPrintableJSON

Details

    Description

      input.xml
      =================
      <?xml version="1.0" encoding="UTF-8"?>
      <purchaseOrder xmlns="http://www.openuri.org/mySchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.openuri.org/mySchema xsd.xsd">
      <shipTo>
      <name>ship-to-name</name>
      <element_of_any_type>
      <unknown_element xsi:type="USState">AK</unknown_element>
      </element_of_any_type>
      </shipTo>
      <billTo>
      <name>bill-to-name</name>
      <element_of_any_type/>
      </billTo>
      </purchaseOrder>
      =================

      xsd.xsd
      =================
      <?xml version="1.0"?>
      <xsd:schema xmlns="http://www.openuri.org/mySchema"
      elementFormDefault="qualified"
      targetNamespace="http://www.openuri.org/mySchema"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      >
      <xsd:element name="purchaseOrder" type="PurchaseOrderType" />
      <xsd:complexType name="PurchaseOrderType">
      <xsd:sequence>
      <xsd:element name="shipTo" type="USAddress" />
      <xsd:element name="billTo" type="USAddress" />
      </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="USAddress">
      <xsd:sequence>
      <xsd:element name="name" type="xsd:string" />
      <xsd:element name="element_of_any_type"/>
      </xsd:sequence>
      <!-- declaration of this attribute is necesary to reproduce -->
      <xsd:attribute fixed="US" name="country" type="xsd:NMTOKEN" />
      </xsd:complexType>
      <xsd:simpleType name="USState">
      <xsd:restriction base="xsd:string">
      <xsd:enumeration value="AK"/>
      <xsd:enumeration value="AL"/>
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:schema>
      =================

      Validation of input.xml reports follow error:
      Error at file input.xml, line 11, char 10
      Message: Type 'USState' that is used in xsi:type is not derived from the type of element 'billTo'

      reason for this behavior is that SchemaValidator::fXsiType is not cleared after element "unknown_element" processing.

      Attachments

        1. XsiType.diff
          3 kB
          Anton Nikolaevsky

        Activity

          People

            amassari Alberto Massari
            alexeyme Alexey Miroshnichenko
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: