views:

24

answers:

2

Hello guys!

I'm trying to extend a element in my XML Scheme, but its not working:

<xs:complexType name="instituicaoComPais">
    <xs:complexContent>
    <xs:extension base="instituicao">
        <xs:sequence>
        <xs:element ref="pais"/>
    </xs:sequence>
    </xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="instituicao">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="departamento"/>
            <xs:element ref="universidade"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

The error I'm getting is Warning 3 Undefined complexType 'instituicao' is used as a base for complex type extension..

What should I do?

EDIT

I use this two different elements like this:

<xs:element name="autor">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="nome"/>
            <xs:choice>
                <xs:element ref="instituicao"/>
                <xs:element ref="instituicaoComPais"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>
A: 

This should work:

<xs:complexType name="instituicao">
    <xs:sequence>
        <xs:element name="departamento"/>
        <xs:element name="universidade"/>
    </xs:sequence>
</xs:complexType>


<xs:complexType name="instituicaoComPais">
    <xs:complexContent>
        <xs:extension base="instituicao">
            <xs:sequence>
                <xs:element name="pais"/>
            </xs:sequence>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>
Datoon
A: 

You can convert the element 'instituicao' to a type. Elements and types are in different symbol spaces. If you still need it as an element create the element from the type as

<element name="instituicao" type="instituicao"/>
d-live