XSD file extension

I have an XSD file with an enumerated type. I would like to create an “extended” XSD file that adds some additional enumerations, but otherwise behaves the same as the main XSD.

For example, the main XSD file contains the following:

<xsd:simpleType name="color">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="red"></xsd:enumeration>
        <xsd:enumeration value="orange"></xsd:enumeration>
        <xsd:enumeration value="yellow"></xsd:enumeration>
    </xsd:restriction>
</xsd:simpleType>
...
<xsd:element name="myColor" type="color" />

My imaginary extended XSD file will simply add gold to the color type. The existing "myColor" element will now be able to contain "gold" if it used this XSD instead of the main one.

Is it possible?

+3
source share
1 answer

How about something like that?

<!-- Your base enumeration -->
<xsd:simpleType name="color">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="red"/>
        <xsd:enumeration value="orange"/>
        <xsd:enumeration value="yellow"/>
    </xsd:restriction>
</xsd:simpleType>

<!-- You extended enumeration -->
<xsd:simpleType name="colorEx">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="gold"/>
    </xsd:restriction>
</xsd:simpleType>


<xsd:simpleType name="color_union">
     <xsd:union memberTypes="colorEx color"/>
</xsd:simpleType>

<xsd:element name="myColor" type="color_union"/>
+4
source

Source: https://habr.com/ru/post/1710179/


All Articles