[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Inheritance in XML


xml inheritance
Chiusano Joseph wrote:

>Elliotte Rusty Harold wrote:
>  
>
>>At 12:14 AM +0200 6/18/04, Mohammad Ghazal wrote:
>>    
>>
>>>Dear Sir,
>>>      I would like to know the relation between XML and the
>>>Inheritance/Subtype concepts, I have read from several books and I
>>>
>>>      
>>>
>>It's roughly the same as the relationship between a grapefruit and a
>>bicycle. That is, there isn't one. :-)
>>
...

>I would add that W3C Schema has some features that one can say involve
>inheritance, such as derivation by extension. But the bottom line is
>that it's all about how one chooses to use XML.
>  
>

There was a quite controversial panel at ECOOP 2004 which talked about 
XML and objects. http://www.ifi.uio.no/ecoop2004/

For Eric Meijer, XML was just a way to serialize (XEN or C-omega) 
objects - hence, I guess, you could say there is a relation, because 
objects have subtyping and inheritance, so you can somewhere use XML to 
model it.

My take was this: With XML you can, among other things, represent data, 
such as the *state* of an object.

The derivation by extension then comes close to inheritance, because 
your derived type has all the data of the type you derived it from.

A derived type is a bit like a subtype - you can, in principle, use it 
everywhere where the original type (like the supertype) is expected.
However, you have to annotate the enclosing element using the xsi:type 
attribute.

BUT this is all very far away from the kind of inheritance and subtyping 
in OOP because inheriting the behaviour of objects (the methods) 
interacts with other things like overloading, overriding, refining.

For instance, some languages (not Java) would allow you to have classes
class Author;
class BookAuthor extends Author;
class Publication { val author:Author }
class Book{ override val author: BookAuthor } extends Publication

I do not think specialising the type of author (say, the first element 
in XML element content) can be done with XML Schema 
derivation-by-restriction, because restriction (and in general all 
schema types) speak about structure (restriction means regular language 
inclusion, it is not covariant, if you will).

So in essence, you seem to get a form of inheritance for *state* with 
derivation-by-extension. To do subtyping etc. you do need much more than 
that, e.g. build a data binding framework that makes your classes 
correspond to W3C XML Schema derived types + something more.

hope this helps. cheers,
Burak

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.