Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Why cant an extended type add an attribute
Why cant an extended type add an attribute [message #598352] Thu, 13 July 2006 08:54
Eclipse UserFriend
Originally posted by: kannan.ekanath.gmail.com

Hi,
I have an XSD model where I have extended SchoolBook to extend Book.
However after extending i am able to add elements to the school book but
i am not able to attributes to school book. The attached xsd has an
element an attribute for school book. Commenting out, the attribute
makes the schema valid.

I am curious to know why this restriction is present in the first place?

Thanks,
Kannan

*********************XSD*******************
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Kannan
Ekanath (Tavant) -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
ecore:documentRoot="library" ecore:package="tavant.platform.infra">
<xsd:complexType name="Book">
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="pages" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Writer">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="books" type="xsd:anyURI" minOccurs="0"
maxOccurs="unbounded" ecore:opposite="author" ecore:reference="Book"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="library">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="writers" type="Writer" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="books" type="Book" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="schoolbooks" type="SchoolBook" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="SchoolBook">
<xsd:complexContent>
<xsd:extension base="Book">
<xsd:sequence>
<xsd:element name="schoolName" type="xsd:string"/>
<xsd:attribute name="yyy" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
Previous Topic:The xs:element with a ref attribute does not show the link
Next Topic:Why cant an extended type add an attribute
Goto Forum:
  


Current Time: Fri Apr 26 19:41:29 GMT 2024

Powered by FUDForum. Page generated in 0.02775 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top