Is there a way to define a type alias / strong typedef / simpleType with an empty restriction in XSD?
<xsd:simpleType name="identifier">
<xsd:restriction base="xsd:string">
<xsd:pattern value="^[a-zA-Z_][a-zA-Z0-9_]*$" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="type">
<xsd:restriction base="identifier" />
</xsd:simpleType>
I would like to later apply some validation logic on attributes of type "type" more specific than the one for attributes of type "identifier."
Yes, it's quite legal to derive a type like this with an empty restriction. However, although the two types have the same value space, they are not synonyms. The derived type is substitutable for the base type, but not other way around. For example, in a schema-aware XSLT stylesheet, an element validated against the base type will not match a template rule that expects an instance of the derived type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With