Page 1 of 1

Extending and adding attributes

Posted: Wed Mar 23, 2005 8:58 pm
by ahundiak
I am trying to extend a complex type and add some additional attributes.

<xs:complexType name="EntityType" abstract="true">
<xs:attribute name="id" type="xs:ID" use="optional"/>
<xs:attribute name="href" type="xs:anyURI" use="optional"/>
</xs:complexType>

<xs:complexType name="EdoType">

<xs:complexContent >
<xs:extension base="EntityType"/>
</xs:complexContent>

<xs:attribute name="X-href" type="xs:anyURI"/>
</xs:complexType>

Oxygen complains about the attribute being invalid or misplaced.

Posted: Thu Mar 24, 2005 2:29 pm
by george
Hi,

That is a basic error. If you use complexContent as a child if complexType you cannot have other elements following complexContent. You should place the attribute inside the xs:extension element as below:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EntityType" abstract="true">
<xs:attribute name="id" type="xs:ID" use="optional"/>
<xs:attribute name="href" type="xs:anyURI" use="optional"/>
</xs:complexType>

<xs:complexType name="EdoType">
<xs:complexContent >
<xs:extension base="EntityType">
<xs:attribute name="X-href" type="xs:anyURI"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

</xs:schema>
Best Regards,
George

Posted: Mon Mar 28, 2005 5:40 pm
by ahundiak
Thanks a bunch. That makes sense.