从元素扩展complextype

时间:2012-10-17 14:03:48

标签: xsd complextype

假设我已经定义了一般的复杂类型

<xs:complexType name="Address">
<!--definition of address-->
</complexType>

现在假设我想定义一种只使用一次的新类型地址,我想在一个新元素中扩展complextype地址

e.g。

<element type="Address">
    <!--how to extend the base type address here-->
</element>

我不想定义一个新的复杂类型来扩展类型地址,因为它只会被使用一次

1 个答案:

答案 0 :(得分:4)

你可能想要一个匿名的复杂类型;作为匿名,它不能被引用,所以有效地你只能“使用”它。

<xsd:complexType name="Address">
    <!-- definition of address --> 
</xsd:complexType>  
<xsd:element name="AnotherAddress">
    <xsd:complexType>
        <xsd:complexContent>
            <xsd:extension base="Address">
                <!-- Extra content for address -->                  
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
</xsd:element>
相关问题