To a simple element with type="xs:int"
I would like to add both a restriction and a number of attributes. However, the only way I have seen it done is in a two-step approach:
Declare a named (global) type and put all the restrictions in the named type
Refer to the named type in the
base
of an<xs:extension>
and add the attributes to the extension node.
It could be nice if I could avoid declaring a global named type as the schema is generated dynamically and it would be a lot cleaner to specify all restrictions locally. E.g. like this:
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:int">
<xs:minInclusive>2</xs:minInclusive>
<xs:attribute name="myAttribute" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
or in case of a string-type:
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:enumeration Value="FOO" />
<xs:enumeration Value="BAR" />
<xs:enumeration Value="BAZ" />
<xs:attribute name="myAttribute" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Unfortunately, it does not seem that a "combined" declaration like this is allowed.