[xsd-users] How to distinguish simpleTypes from complexTypes
Boris Kolpackov
boris at codesynthesis.com
Fri Jun 13 05:07:34 EDT 2008
Hi Ray,
Ray Lischner <rlischner at proteus-technologies.com> writes:
> How can I distinguish between a simpleType and a complexType? In the
> past, I used the IsSimpleType functor, but now we have schemas with
> simpleTypes with complexContent and attributes, so that no longer
> works.
In XML Schema the distinction between simpleType and complexType
is somewhat arbitrary so we don't really preserve it the semantic
graph. Consider:
<simpleType name="simple">
<restriction base="string">
<maxLength value="256"/>
</restriction>
</simpleType>
<complexType name="complex">
<simpleContent>
<restriction base="string">
<maxLength value="256"/>
</restriction>
</simpleContent>
</complexType>
The two types are essentially the same but one is simple and the
other is complex in XML Schema speak.
Is you don't care about such technicalities, then the IsSimpleType
does the trick: it returns false for types that have elements
and/or attributes and true otherwise. It will return true for
both of the above types but false for a complexType/simpleContent
that has an attribute.
Boris
More information about the xsd-users
mailing list