[xsd-users] Restricted NMTOKENS (enumeration) with default value
Boris Kolpackov
boris at codesynthesis.com
Fri Jan 9 04:43:49 EST 2015
Hi Andre,
Andre Vautour <andre.vautour at caris.com> writes:
> I ran into a problem with a schema that has an enumeration
> (xsd:NMTOKENS with restrictions) that has a default value. The
> generated enum does not seem to have a default constructor, yet the
> generated default initialization method tries to use the default
> constructor.
I have a fix in the repository and can build you a pre-release binary if
you would like. An easy workaround is to add the --generate-default-ctor
option or change NMTOKENS to NMTOKEN (see below).
> <xsd:simpleType>
> <xsd:restriction base="xsd:NMTOKENS">
> <xsd:enumeration value="red"/>
> <xsd:enumeration value="green"/>
> <xsd:enumeration value="blue"/>
> </xsd:restriction>
>
> [...]
>
> I ran into this particular problem when trying to generate OGC's OWS
> 1.1.0 schema, see the rangeClosure attribute of RangeType:
> http://schemas.opengis.net/ows/1.1.0/owsDomainType.xsd
Using NMTOKENS for this enumeration doesn't make any sense. Why would
you base a color type on a list of tokens? In fact I suspect what
happened is this: someone was editing this schema in some visual
editor and when selecting the attribute's type from the drop-down
list, accidentally clicked on NMTOKENS instead of NMTOKEN (they would
be right next to each other). The result doesn't make sense but is
legal XML Schema (as are a lot of other bizarre cases), so nobody
noticed.
Boris
More information about the xsd-users
mailing list