[xsd-users] Compilation Error

Andrew Ward andy.ward at hevday.com
Wed Apr 26 21:11:04 EDT 2006


Hi All,

Using this schema:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:simpleType name="SideType">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="top"/>
            <xsd:enumeration value="left"/>
            <xsd:enumeration value="bottom"/>
            <xsd:enumeration value="right"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="TopOrBottomType">
        <xsd:restriction base="SideType">
            <xsd:enumeration value="top"/>
            <xsd:enumeration value="bottom"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="hello_type">
        <xsd:sequence>
          <xsd:element name="greeting" type="xsd:string"/>
          <xsd:element name="name" type="xsd:string" maxOccurs="unbounded"/>
          <xsd:element name="side" type="SideType"/>
          <xsd:element name="toporbottom" type="TopOrBottomType"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="hello" type="hello_type"/>
</xsd:schema>

And using this command:

xsd cxx-tree --generate-serialization --hxx-suffix .h --cxx-suffix .cpp 
s.xsd

I get the following compilation errors when trying to compile the XSD 
generated code:

s.cpp
s.cpp(852) : error C2450: switch expression of type 'TopOrBottomType' is 
illegal
        Ambiguous user-defined-conversion
s.cpp(872) : error C2450: switch expression of type 'TopOrBottomType' is 
illegal
        Ambiguous user-defined-conversion
s.cpp(892) : error C2450: switch expression of type 'TopOrBottomType' is 
illegal
        Ambiguous user-defined-conversion
Generating Code...
NMAKE : fatal error U1077: 'cl' : return code '0x2'

The code that the compiler is complaining about is here:

void
operator<< (::xsd::cxx::xml::dom::element< char >& n,
            class TopOrBottomType i)
{
  switch (i)
  {
    case TopOrBottomType::top:
    {
      n.value ("top");
      break;
    }

    case TopOrBottomType::bottom:
    {
      n.value ("bottom");
      break;
    }
  }
}

void
operator<< (::xsd::cxx::xml::dom::attribute< char >& n,
            class TopOrBottomType i)
{
  switch (i)
  {
    case TopOrBottomType::top:
    {
      n.value ("top");
      break;
    }

    case TopOrBottomType::bottom:
    {
      n.value ("bottom");
      break;
    }
  }
}

void
operator<< (::xsd::cxx::xml::dom::list_stream< char >& l,
            class TopOrBottomType i)
{
  switch (i)
  {
    case TopOrBottomType::top:
    {
      l << "top";
      break;
    }

    case TopOrBottomType::bottom:
    {
      l << "bottom";
      break;
    }
  }
}


Any ideas anyone?
Thanks.





More information about the xsd-users mailing list