[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Inheritance in XML
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|