Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to rename a base type in XSD

Tags:

xml

xsd

I am developing some xsd and it contains a number of identifiers to shared master data by ID. I am not keen to just identify these as positiveInteger nor to create an extra level of indirection and would rather define my own type where I simply rename positiveInteger

My question is, is the following legitimate?

<xs:complexType name="masterDataKey">
    <xs:simpleContent>
      <xs:extension base="xs:positiveInteger" /> 
    </xs:simpleContent>
</xs:complexType>

and if not then what options are open to me.

Cheers, Daryl

like image 507
Daryl O Regan Avatar asked Oct 16 '25 18:10

Daryl O Regan


1 Answers

Well, your example isn't a simple renaming. You've created a complexType, whereas xs:positiveInteger is a simpleType, so you won't be able to use it for example as the type of an attribute (which has to be simple).

It's probably better to define a trivial restriction:

<xs:simpleType name="masterDataKey">
    <xs:restriction base="xs:positiveInteger" /> 
</xs:simpleType>

But even then you need to be aware that your type isn't a simple alias for xs:positiveInteger; for example a type that's derived from positiveInteger won't be substitutable for masterDataKey.

like image 125
Michael Kay Avatar answered Oct 18 '25 13:10

Michael Kay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!