[xsd-users] Elements/attrs not recognized

Boris Kolpackov boris at codesynthesis.com
Fri Dec 12 10:54:12 EST 2008


Hi,

Homer J S <js.homer at yahoo.com> writes:

> The input string I parsed 
> 
> [...]
> 
> 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: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.

Your XML document is not valid per your schema. There are generally
two ways to resolve this:

1. Fix your XML document to be valid.

2. Fix your schema to allow for the invalid construct. In your case
   that would mean, for example, adding <xsd:enumeration value=""/>
   to the WellStatus.

3. Disable XML Schema validation in the underlying XML parser and
   customize the generated code (the WellStatus class in your case)
   to take care of the invalid parts in your XML documents.

For more information on type customization see the C++/Tree Mapping
Customization Guide[1] as well as the examples in the 
examples/cxx/tree/custom/ directory. In your case you would want
to customize the parsing constructors to detect the empty value
situation.

[1] http://wiki.codesynthesis.com/Tree/Customization_guide

Boris




More information about the xsd-users mailing list