[xsd-users] Having trouble with NMTOKENS

Gerard Lanois gerard at lanois.com
Mon Apr 9 13:43:23 EDT 2007


Here is my schema .xsd file:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
 <xsd:simpleType name="SIMPSONS_TYPE">
  <xsd:restriction base="xsd:NMTOKEN">
   <xsd:enumeration value="HOMER"/>
   <xsd:enumeration value="MARGE"/>
   <xsd:enumeration value="BART"/>
   <xsd:enumeration value="LISA"/>
   <xsd:enumeration value="MAGGIE"/>
   <xsd:enumeration value="KRUSTY"/>
   <xsd:enumeration value="APU"/>
   <xsd:enumeration value="SMITHERS"/>
  </xsd:restriction>
 </xsd:simpleType>
 <xsd:element name="BLAH">
  <xsd:annotation>
   <xsd:documentation>Characters from the Simpsons.</xsd:documentation>
  </xsd:annotation>
  <xsd:complexType>
   <xsd:all>
    <xsd:element name="SIMPSONS" type="SIMPSONS_TYPE"/>
   </xsd:all>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>

This works fine.  However, if I change the NMTOKEN to be NMTOKENS
(note the "S" at the end), the resulting .cxx file does not compile.

I produced the .cxx by just running xsd on the above schema (called
BlahSchema.xsd) with no command line options.

Is NMTOKENS working as expected?  It seems to be supported.

Thanks,

-Gerard



PS:  Here are the compilation errors I get:


Compiling...

BlahSchema.cxx

c:\users\gerard\ReadBLAH\BlahSchema.cxx(49) : error C2664:
'xsd::cxx::tree::nmtokens<C,B,nmtoken>::nmtokens(const
xercesc_2_7::DOMElement &,xsd::cxx::tree::flags,xsd::cxx::tree::type
*)' : cannot convert parameter 1 from 'const char *const ' to 'const
xercesc_2_7::DOMElement &'

with

[

C=char,

B=xml_schema::simple_type,

nmtoken=xml_schema::nmtoken

]

Reason: cannot convert from 'const char *const ' to 'const
xercesc_2_7::DOMElement'

No constructor could take the source type, or constructor overload
resolution was ambiguous

c:\users\gerard\ReadBLAH\BlahSchema.cxx(70) : error C2440: 'type cast'
: cannot convert from 'const char *const ' to
'xsd::cxx::tree::nmtokens<C,B,nmtoken>'

with

[

C=char,

B=xml_schema::simple_type,

nmtoken=xml_schema::nmtoken

]

No constructor could take the source type, or constructor overload
resolution was ambiguous

c:\users\gerard\ReadBLAH\BlahSchema.cxx(155) : error C2679: binary
'!=' : no operator found which takes a right-hand operand of type
'const SIMPSONS_TYPE' (or there is no acceptable conversion)

c:\users\gerard\ReadBLAH\BlahSchema.cxx(157) : error C2440: 'type
cast' : cannot convert from 'const SIMPSONS_TYPE' to
'xsd::cxx::tree::unexpected_enumerator<C>'

with

[

C=char

]

No constructor could take the source type, or constructor overload
resolution was ambiguous




More information about the xsd-users mailing list