[xsd-users] custom type
Boris Kolpackov
boris at codesynthesis.com
Tue Apr 22 02:42:56 EDT 2008
Hi,
kun lv <lvkun2006 at gmail.com> writes:
> <xs:element name="arg0" type="xs:anyType"/>
> [...]
>
> I just want to use string instead of xs:anyType, with the option
> "--custom-type anyType=string", but It does't work out.
anyType is a somewhat special type and you cannot re-map it to string.
Here is the excerpt from C++/Tree Customization Guide[1]:
"The xsd:anyType type, which is mapped to xml_schema::type, is a base
type for every generated and built-in type in the C++/Tree mapping.
Because of this property it is often useful to customize this type
in order to provide a common functionality to all types in an object
model. One special requirement when customizing anyType is that you
should always inherit your version from the default implementation.
For an example on how to customize anyType refer to the comments
example which can be found in the examples/cxx/tree/custom/
directory of the XSD distribution."
I suggest that you also read the whole guide if you are planning
to customize types.
The way to handle this particular situation is to customize the
outer type that contains the arg0 element. You can then override
its parsing c-tor (and serialization operator, if required) and
extract the data for arg0 element as string. You can also add
accessors and modifiers that use string as a type. For more
information on how to implement parsing c-tor, etc., see the
custom/wildcard example.
[1] http://wiki.codesynthesis.com/Tree/Customization_guide
Boris
More information about the xsd-users
mailing list