Josan
Josan

Reputation: 722

How to reuse customized type set in XML schema?

I have to create several XML schema in different SQL stored procedures to validate input XML, but it is kind of annoying to repeatedly copy and paste the customized schema type, which almost all the same.

Like following types:

<xs:simpleType name="CodeLen1">
    <xs:restriction base="xs:string">
        <xs:maxLength value="1" />
    </xs:restriction>
</xs:simpleType>
<xs:simpleType name="CodeLen2">
    <xs:restriction base="xs:string">
        <xs:maxLength value="2" />
    </xs:restriction>
</xs:simpleType>
<xs:simpleType name="CodeLen3">
    <xs:restriction base="xs:string">
        <xs:maxLength value="3" />
    </xs:restriction>
</xs:simpleType>
<xs:simpleType name="CodeLen4">
    <xs:restriction base="xs:string">
        <xs:maxLength value="4" />
    </xs:restriction>
</xs:simpleType>
<xs:simpleType name="CodeLen5">
    <xs:restriction base="xs:string">
        <xs:maxLength value="5" />
    </xs:restriction>
</xs:simpleType>

How could I reuse this part in different XML schemas?

I know we could use the <xs:import> between XSD files, but how to use this in SQL schema?

Upvotes: 0

Views: 75

Answers (1)

user6754063
user6754063

Reputation:

My solution is that treat XML schemas in SQL as String, when using it, just concatenate them together.

Upvotes: 1

Related Questions