[xsd-users] Problem with ostream output of anonymous types and substitution groups

Ray Lischner rlischner at proteuseng.com
Wed Dec 14 08:06:27 EST 2011


There seems to be a problem with ostream output of anonymous polymorphic types, using substitution groups. This is illustrated by copying the tests/cxx/tree/polymorphism/ostream example and changing the schema to:

<xsd:schema targetNamespace="test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="test" elementFormDefault="qualified">
  <xsd:element name="root" type="type"/>
  <xsd:complexType name="type">
    <xsd:sequence>
      <xsd:element ref="base" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="base" type="Base" abstract="true"/>
  <xsd:complexType name="Base" abstract="true"/>

  <xsd:element name="der1" substitutionGroup="base">
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="Base"/>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="der2" type="Der2" substitutionGroup="base"/>
  <xsd:complexType name="Der2">
    <xsd:complexContent>
      <xsd:extension base="Base"/>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:schema>

Change the test.xml file to:

<root xmlns="test" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="test test.xsd">
  <der1/>
  <der2/>
</root>

Add --root-element root to the xsd_options in the makefile.

When I run the driver, I get a type_info exception:

no type information available for type ''

Also, the name "base" is printed instead of "der1" or "der2".


Ray Lischner,
Distinguished Member of Technical Staff
133 National Business Pkwy, Ste 150     t. 443.539.3448
Annapolis Junction, MD 20701            c. 410.854.5170
rlischner at proteuseng.com                f. 443.539.3370



More information about the xsd-users mailing list