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 #68612] Thu, 13 July 2006 08:54 Go to next message
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>
Re: Why cant an extended type add an attribute [message #68670 is a reply to message #68612] Thu, 13 July 2006 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------090205000404020801000308
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Kannan,

You're just using bad syntax. The attributes must come after the model
group.

<xsd:complexType name="SchoolBook">
<xsd:complexContent>
<xsd:extension base="Book">
<xsd:sequence>
<xsd:element name="schoolName" type="xsd:string"/>
</xsd:sequence>
* <xsd:attribute name="yyy" type="xsd:string"/> *
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>



Kannan Ekanath wrote:
> 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>


--------------090205000404020801000308
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Kannan,<br>
<br>
You're just using bad syntax.&nbsp; The attributes must come after the model
group.<br>
<blockquote>&nbsp;&nbsp;&nbsp; &lt;xsd:complexType name="SchoolBook"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:extension base="Book"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:element name="schoolName"
type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b> &lt;xsd:attribute name="yyy" type="xsd:string"/&gt;
</b><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:extension&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt; <br>
</blockquote>
<br>
<br>
Kannan Ekanath wrote:
<blockquote cite="mide951kp$kof$1@utils.eclipse.org" type="cite">Hi,
<br>
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.
<br>
<br>
I am curious to know why this restriction is present in the first
place?
<br>
<br>
Thanks,
<br>
Kannan
<br>
<br>
*********************XSD*******************
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;!-- edited with XMLSPY v5 rel. 4 U (<a class="moz-txt-link-freetext" href="http://www.xmlspy.com">http://www.xmlspy.com</a>) by
Kannan Ekanath (Tavant) --&gt;
<br>
&lt;xsd:schema xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
ecore:documentRoot="library" ecore:package="tavant.platform.infra"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:complexT ype name="Book"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="title" type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="pages" type="xsd:int"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:complexT ype name="Writer"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="name" type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="books" type="xsd:anyURI"
minOccurs="0" maxOccurs="unbounded" ecore:opposite="author"
ecore:reference="Book"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:element name="library"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:element name="writers" type="Writer"
minOccurs="0" maxOccurs="unbounded"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:element name="books" type="Book" minOccurs="0"
maxOccurs="unbounded"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:element name="schoolbooks" type="SchoolBook"
minOccurs="0" maxOccurs="unbounded"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:element &gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:complexT ype name="SchoolBook"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:extension base="Book"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:element name="schoolName"
type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:attribute name="yyy" type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:extension&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt;
<br>
&lt;/xsd:schema&gt;
<br>
</blockquote>
<br>
</body>
</html>

--------------090205000404020801000308--
Re: Why cant an extended type add an attribute [message #68676 is a reply to message #68670] Fri, 14 July 2006 07:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kannan.ekanath.gmail.com

Ooops,
Misread the spec. You rock :)

Thanks !!!
Kannan

Ed Merks wrote:
> Kannan,
>
> You're just using bad syntax. The attributes must come after the model
> group.
>
> <xsd:complexType name="SchoolBook">
> <xsd:complexContent>
> <xsd:extension base="Book">
> <xsd:sequence>
> <xsd:element name="schoolName" type="xsd:string"/>
> </xsd:sequence>
> * <xsd:attribute name="yyy" type="xsd:string"/> *
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
>
>
> Kannan Ekanath wrote:
>> 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>
>
Re: Why cant an extended type add an attribute [message #68686 is a reply to message #68676] Fri, 14 July 2006 08:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kannan.ekanath.gmail.com

In the same lines, i have one more doubt, when the school book is
created, the base class schoolnames comes first before other elements,
can you show some snippet where i can declare first my elements and then
extend base class? (Basically the xml created that way will have the
elements of this type coming up first and then followed by the base type?

Kannan Ekanath wrote:
> Ooops,
> Misread the spec. You rock :)
>
> Thanks !!!
> Kannan
>
> Ed Merks wrote:
>> Kannan,
>>
>> You're just using bad syntax. The attributes must come after the
>> model group.
>>
>> <xsd:complexType name="SchoolBook">
>> <xsd:complexContent>
>> <xsd:extension base="Book">
>> <xsd:sequence>
>> <xsd:element name="schoolName"
>> type="xsd:string"/>
>> </xsd:sequence>
>> * <xsd:attribute name="yyy" type="xsd:string"/> *
>> </xsd:extension>
>> </xsd:complexContent>
>> </xsd:complexType>
>>
>>
>>
>> Kannan Ekanath wrote:
>>> 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>
>>
Re: Why cant an extended type add an attribute [message #68702 is a reply to message #68686] Fri, 14 July 2006 10:48 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Kannan,

This isn't possible using a base type since the specification defines
the content type of an extension to consist of a particle that's a
sequence whose first particle is the base type's content type and whose
second particle is the derived type's locally defined content type.


Kannan Ekanath wrote:
> In the same lines, i have one more doubt, when the school book is
> created, the base class schoolnames comes first before other elements,
> can you show some snippet where i can declare first my elements and
> then extend base class? (Basically the xml created that way will have
> the elements of this type coming up first and then followed by the
> base type?
>
> Kannan Ekanath wrote:
>> Ooops,
>> Misread the spec. You rock :)
>>
>> Thanks !!!
>> Kannan
>>
>> Ed Merks wrote:
>>> Kannan,
>>>
>>> You're just using bad syntax. The attributes must come after the
>>> model group.
>>>
>>> <xsd:complexType name="SchoolBook">
>>> <xsd:complexContent>
>>> <xsd:extension base="Book">
>>> <xsd:sequence>
>>> <xsd:element name="schoolName"
>>> type="xsd:string"/>
>>> </xsd:sequence>
>>> * <xsd:attribute name="yyy" type="xsd:string"/> *
>>> </xsd:extension>
>>> </xsd:complexContent>
>>> </xsd:complexType>
>>>
>>>
>>>
>>> Kannan Ekanath wrote:
>>>> 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>
>>>
Re: Why cant an extended type add an attribute [message #598359 is a reply to message #68612] Thu, 13 July 2006 10:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090205000404020801000308
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Kannan,

You're just using bad syntax. The attributes must come after the model
group.

<xsd:complexType name="SchoolBook">
<xsd:complexContent>
<xsd:extension base="Book">
<xsd:sequence>
<xsd:element name="schoolName" type="xsd:string"/>
</xsd:sequence>
* <xsd:attribute name="yyy" type="xsd:string"/> *
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>



Kannan Ekanath wrote:
> 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>


--------------090205000404020801000308
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Kannan,<br>
<br>
You're just using bad syntax.&nbsp; The attributes must come after the model
group.<br>
<blockquote>&nbsp;&nbsp;&nbsp; &lt;xsd:complexType name="SchoolBook"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:extension base="Book"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:element name="schoolName"
type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b> &lt;xsd:attribute name="yyy" type="xsd:string"/&gt;
</b><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:extension&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt; <br>
</blockquote>
<br>
<br>
Kannan Ekanath wrote:
<blockquote cite="mide951kp$kof$1@utils.eclipse.org" type="cite">Hi,
<br>
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.
<br>
<br>
I am curious to know why this restriction is present in the first
place?
<br>
<br>
Thanks,
<br>
Kannan
<br>
<br>
*********************XSD*******************
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;!-- edited with XMLSPY v5 rel. 4 U (<a class="moz-txt-link-freetext" href="http://www.xmlspy.com">http://www.xmlspy.com</a>) by
Kannan Ekanath (Tavant) --&gt;
<br>
&lt;xsd:schema xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
ecore:documentRoot="library" ecore:package="tavant.platform.infra"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:complexT ype name="Book"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="title" type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="pages" type="xsd:int"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:complexT ype name="Writer"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="name" type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:element name="books" type="xsd:anyURI"
minOccurs="0" maxOccurs="unbounded" ecore:opposite="author"
ecore:reference="Book"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:element name="library"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:element name="writers" type="Writer"
minOccurs="0" maxOccurs="unbounded"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:element name="books" type="Book" minOccurs="0"
maxOccurs="unbounded"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:element name="schoolbooks" type="SchoolBook"
minOccurs="0" maxOccurs="unbounded"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:element &gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:complexT ype name="SchoolBook"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:extension base="Book"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:element name="schoolName"
type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:attribute name="yyy" type="xsd:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/xsd:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsd:extension&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:complex Type&gt;
<br>
&lt;/xsd:schema&gt;
<br>
</blockquote>
<br>
</body>
</html>

--------------090205000404020801000308--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Why cant an extended type add an attribute [message #598365 is a reply to message #68670] Fri, 14 July 2006 07:32 Go to previous message
Eclipse UserFriend
Originally posted by: kannan.ekanath.gmail.com

Ooops,
Misread the spec. You rock :)

Thanks !!!
Kannan

Ed Merks wrote:
> Kannan,
>
> You're just using bad syntax. The attributes must come after the model
> group.
>
> <xsd:complexType name="SchoolBook">
> <xsd:complexContent>
> <xsd:extension base="Book">
> <xsd:sequence>
> <xsd:element name="schoolName" type="xsd:string"/>
> </xsd:sequence>
> * <xsd:attribute name="yyy" type="xsd:string"/> *
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
>
>
> Kannan Ekanath wrote:
>> 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>
>
Re: Why cant an extended type add an attribute [message #598374 is a reply to message #68676] Fri, 14 July 2006 08:32 Go to previous message
Eclipse UserFriend
Originally posted by: kannan.ekanath.gmail.com

In the same lines, i have one more doubt, when the school book is
created, the base class schoolnames comes first before other elements,
can you show some snippet where i can declare first my elements and then
extend base class? (Basically the xml created that way will have the
elements of this type coming up first and then followed by the base type?

Kannan Ekanath wrote:
> Ooops,
> Misread the spec. You rock :)
>
> Thanks !!!
> Kannan
>
> Ed Merks wrote:
>> Kannan,
>>
>> You're just using bad syntax. The attributes must come after the
>> model group.
>>
>> <xsd:complexType name="SchoolBook">
>> <xsd:complexContent>
>> <xsd:extension base="Book">
>> <xsd:sequence>
>> <xsd:element name="schoolName"
>> type="xsd:string"/>
>> </xsd:sequence>
>> * <xsd:attribute name="yyy" type="xsd:string"/> *
>> </xsd:extension>
>> </xsd:complexContent>
>> </xsd:complexType>
>>
>>
>>
>> Kannan Ekanath wrote:
>>> 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>
>>
Re: Why cant an extended type add an attribute [message #598379 is a reply to message #68686] Fri, 14 July 2006 10:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Kannan,

This isn't possible using a base type since the specification defines
the content type of an extension to consist of a particle that's a
sequence whose first particle is the base type's content type and whose
second particle is the derived type's locally defined content type.


Kannan Ekanath wrote:
> In the same lines, i have one more doubt, when the school book is
> created, the base class schoolnames comes first before other elements,
> can you show some snippet where i can declare first my elements and
> then extend base class? (Basically the xml created that way will have
> the elements of this type coming up first and then followed by the
> base type?
>
> Kannan Ekanath wrote:
>> Ooops,
>> Misread the spec. You rock :)
>>
>> Thanks !!!
>> Kannan
>>
>> Ed Merks wrote:
>>> Kannan,
>>>
>>> You're just using bad syntax. The attributes must come after the
>>> model group.
>>>
>>> <xsd:complexType name="SchoolBook">
>>> <xsd:complexContent>
>>> <xsd:extension base="Book">
>>> <xsd:sequence>
>>> <xsd:element name="schoolName"
>>> type="xsd:string"/>
>>> </xsd:sequence>
>>> * <xsd:attribute name="yyy" type="xsd:string"/> *
>>> </xsd:extension>
>>> </xsd:complexContent>
>>> </xsd:complexType>
>>>
>>>
>>>
>>> Kannan Ekanath wrote:
>>>> 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>
>>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Why cant an extended type add an attribute
Next Topic:XSDParser Question :(
Goto Forum:
  


Current Time: Thu Mar 28 13:59:04 GMT 2024

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

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

Back to the top