集成两个XML模式

时间:2019-07-11 20:05:11

标签: xml schema integrate

我有一个非常复杂的XML模式,可以在元素“ CustomData”内精确插入自定义数据。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    ...
    ...
    ...
    ...
    <xs:element name="CustomData" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name" type="xs:string"/>
                <xs:element name="UniqueIdentifier" type="xs:string"/>
                <xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    ...
</xs:schema>

在“ CustomData”中有两个必填元素:“名称”和“ UniqueIdentifier”

我已经使用以下模式创建了自己的自定义数据:

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:attribute name="du">
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:enumeration value="S_L"/>
                <xs:enumeration value="RI_L"/>
                <xs:enumeration value="PC_L"/>
                <xs:enumeration value="G_L"/>
                <xs:enumeration value="UC_L"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    <xs:complexType name="du_type">
        <xs:simpleContent>
            <xs:extension base="xs:decimal">
                <xs:attribute ref="du" use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:element name="CustomData">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="CAM_Rated_Voltage" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Max_Voltage" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Min_Voltage" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Rated_Frequency" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Max_Frequency" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Min_Frequency" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Rated_Current" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Max_Current" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Min_Current" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Rated_Power_Factor" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Num_Sources" type="xs:int" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Source_Type" minOccurs="1" maxOccurs="unbounded">
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="H"/>
                            <xs:enumeration value="I"/>
                            <xs:enumeration value="F"/>
                            <xs:enumeration value="T"/>
                            <xs:enumeration value="M"/>
                            <xs:enumeration value="Q"/>
                            <xs:enumeration value="S"/>
                            <xs:enumeration value="LS"/>
                            <xs:enumeration value="DL"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="CAM_Replaceable_Sources" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Nominal_Source_Power" type="xs:decimal" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="CAM_InsulationClass" type="xs:string" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_IP_Body" type="xs:int" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_IP_Box" type="xs:int" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_IK" type="xs:int" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Surge" type="xs:int" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_IDPhotobiological_Risk" type="xs:string" minOccurs="0" maxOccurs="1"/>
                <xs:element name="CAM_Threshold_Distace_PhRisk" type="xs:decimal" minOccurs="0" maxOccurs="1"/>
                <xs:element name="CAM_Rated_Life" type="xs:string" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Failure_Index" type="xs:string" minOccurs="0" maxOccurs="1"/>
                <xs:element name="CAM_Luminous_Efficacy" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Dff" type="xs:decimal" minOccurs="1" maxOccurs="1"/>
                <xs:element name="CAM_Uclass" minOccurs="1" maxOccurs="1">
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="U1"/>
                            <xs:enumeration value="U2"/>
                            <xs:enumeration value="U3"/>
                            <xs:enumeration value="U4"/>
                            <xs:enumeration value="U5"/>
                            <xs:enumeration value=""/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="CAM_G_Class" minOccurs="1" maxOccurs="1">
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value=""/>
                            <xs:enumeration value="G*1"/>
                            <xs:enumeration value="G*2"/>
                            <xs:enumeration value="G*3"/>
                            <xs:enumeration value="G*4"/>
                            <xs:enumeration value="G*5"/>
                            <xs:enumeration value="G*6"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="CAM_IPEA" type="du_type" minOccurs="5" maxOccurs="5"/>
                <xs:element name="CAM_Warranty" type="xs:string" minOccurs="0" maxOccurs="1"/>
                <xs:element name="CAM_ID_Mark" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="CAM_ID_Mark_Link" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

我如何将我的架构集成到主要架构的“ CustomData”元素中?

非常感谢您。

0 个答案:

没有答案