[xsd-users] Elements/attrs not recognized
Homer J S
js.homer at yahoo.com
Fri Dec 12 08:57:37 EST 2008
Thank you so much Boris. I hope you wont mind I ask another question please. The input string I parsed
'<wells xmlns="http://www.witsml.org/schemas/120"
version="1.2.0"><well
uidWell=''><nameWell/><nameLegal/><dTimSpud/><numAPI/><statusWell/><field></field><country/><state/><county/><block/><operator/><location><latitude/><longitude/><inputType/></location><commonData><nameSource/><dTimStamp/><dTimCreation/><dTimLastChange/><itemState/><comments/></commonData></well></wells>'
contains element <statusWell/> which is an enumeration defined below:
<xsd:simpleType name="WellStatus">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Abandoned"/>
<xsd:enumeration value="Active"/>
<xsd:enumeration value="Drilling"/>
<xsd:enumeration value="DrillingSuspended"/>
<xsd:enumeration value="Permitted"/>
<xsd:enumeration value="PartiallyPlugged"/>
<xsd:enumeration value="PluggedAndAbandoned"/>
<xsd:enumeration value="Proposed"/>
<xsd:enumeration value="Plugged"/>
<xsd:enumeration value="StatusUnknown"/>
<xsd:enumeration value="Suspended"/>
<xsd:enumeration value="TemporarilyAbandoned"/>
</xsd:restriction>
</xsd:simpleType>
The
problem is that the parser raised an error because the input string
does not explicitly specify a value for element statusWell. Is there a
way to bypassing this problem please.
Thanks
JS
________________________________
From: Boris Kolpackov <boris at codesynthesis.com>
To: Homer J S <js.homer at yahoo.com>
Cc: xsd-users at codesynthesis.com
Sent: Friday, December 12, 2008 7:13:47 AM
Subject: Re: [xsd-users] Elements/attrs not recognized
Hi,
Homer J S <js.homer at yahoo.com> writes:
> try
> {
> std::string str(_QueryIn); // XML in a string.
> std::istringstream iss(str);
> auto_ptr<obj_wells> h (wells (iss));
> }
> catch (const xml_schema::exception& e)
> {
> cerr << e << endl;
> }
>
> to parse this XML string:
>
> '<wells xmlns="http://www.witsml.org/schemas/120" version="1.2.0">...
>
> But all I got back are just errors. It look like the generated parser
> did not recognize any of the elements/attributes, I must have missed
> something serious:
No, not too serious ;-). See Q2.1 in the C++/Tree Mapping FAQ:
http://wiki.codesynthesis.com/Tree/FAQ
Boris
More information about the xsd-users
mailing list