Question

Suppose I have define a general complextype

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

now suppose I want to define a new type of address that will be used only once, and i want to extend the complextype address in a a new element

e.g.

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

I don't want to define a new complex type to extend the type address because it will be used only once

Was it helpful?

Solution

You probably want an anonymous complex type; being anonymous, it can't be referenced, so effectively you can use it only "once".

<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top