2015-04-20 31 views
0

我要創建在不同的SQL存儲過程的幾個XML模式驗證輸入XML,但它是一種惱人的重複複製和粘貼自定義模式類型,幾乎都是一樣的。如何重用XML模式中的自定義類型集?

像以下幾種類型:

<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> 

我怎麼能重複使用這部分在不同的XML模式?

我知道我們可以使用<xs:import>之間XSD文件,但如何在SQL架構使用?

+0

你是否已經嘗試了''? [見這裏](http://www.w3schools.com/schema/el_import.asp) – Xstian

+0

感謝@Xstian,XSD文件之間的作品,但在SQL,我不知道如何使它工作。 –

回答

1

我的解決辦法是,在SQL字符串,將XML模式使用時,只需將它們連接在一起。

相關問題