[xsd-users] xsd-generated code ignores attributes

Soroush Rabiei soroush.rabiei at gmail.com
Tue May 27 02:20:57 EDT 2014


Hi

I have a problem with my XSD schema. I'm not sure if I'm defining XSD in a
wrong way or there is something to do with XSD-C++ tree map.

The problem is that attributes are simply ignored by the parser. For
example the "presentation" element type is defined like this:

<xs:complexType name="presentation_t"> <xs:attribute name="name"
type="xs:string" use="optional" /> <xs:attribute name="format"
type="xs:string" use="required" /> </xs:complexType>

And this type is used somewhere is "instance" element type:

<xs:complexType name="instance_t"> <xs:sequence minOccurs="1"
maxOccurs="1"> <xs:element name="presentation" minOccurs="1" maxOccurs="1"
type="presentation_t" /> <xs:element name="domains" minOccurs="1"
maxOccurs="1" type="domains_t" /> <xs:element name="variables"
minOccurs="1" maxOccurs="1" type="variables_t" /> </xs:sequence>
</xs:complexType> Finally, there is only one "instance" element which is
root element in document:
<xs:element name="instance" type="instance_t" />

And corresponding parser source is:

class XPresentationParser: public presentation_t_pskel { public:
XPresentationParser(CSP_Problem&); ~XPresentationParser(); void name(const
std::string&); void type(const AIT::CSP::CSP_Problem::Type&); private:
CSP_Problem& instance; };

The "name" and "type" member functions in above code are never called. This
happens for all my elements that have attributes. Contents are parsed
successfully but all attributes are ignored.


More information about the xsd-users mailing list