OO Schemas

Paul Prescod papresco at technologist.com
Thu Sep 17 01:57:01 BST 1998


On 15 Sep 1998 matt at veosystems.com wrote:

> Don't you mean "In my mind's eye they don't share a content model"?
> You are making statements about the characteristics of systems you
> haven't seen yet (OO Schemas or whatever) and certainly haven't used.
> Once you _can_ declare them subclasses of a parent grouping element,
> you might find you start doing things differently.  You might not, but
> you can't really make such statements until we've got some proposals
> on the table.

The real question is what makes two elements have the same type? In XML,
two elements have the same type if they share a GI. Since elements may or
may not have a DTD, they may or not share a content model or attributes. 
In SGML, we know that two elements with the same GI can have different
effective content models (exceptions) and different allowed attributes
(CONREF). We also know that people use these features (especially 
exceptions, which are used even in HTML). We also know that elements with 
the same GI can have different semantics and behaviours (especially 
rendering behaviour...consider titles in sections vs. titles of chapters!).

So in both SGML and XML, the fundamental thing that "binds" two elements 
to the same type is the GI. What's interesting is that this isn't the 
case with other languages. That was the point of the PAREN example. In 
C++, the "(" or "=" tokens can mean radically different things in 
different contexts (to say nothing of "const"). The advisability of 
reusing tokens is another issue, of course. (that's what an XML GI is, 
BTW, a tree-level token).

> I know your opinion here.  But inheritance is just a subset of
> subclass relationships (subclass is an as-a relationship, inheritance
> is an is-a relationship, and all is-a relationship are also as-a
> relationships).

I don't think that there is anything in the word "inheritance" that 
implies an is-a relationship, though I agree that sometimes it is used 
that way. As the OO FAQ says:

"Defining inheritance (with a thorough description or denotational 
semantic definition, or both) can avoid confusion about which inheritance 
scheme is being used (especially in OOD), because inheritance has many 
variations and combinations of state and environment (sometimes with 
complex rules). Inheritance can also be used for typing, where a type or 
class can be used to specify required attributes of a matching object 
(see sections 2.1, 2.7 and [Cardelli 85]). It would be more judicious to 
have discussions on how inheritance should be defined instead of over 
what it is, since it has many existing uses and semantics."

So let me do so:

XML element types have three interesting properties: content models,
attributes and GIs. So to me, "inheritance" between element types would be
about borrowing some or all of another element types content model,
attributes or GIs.

Subclassing, on the other hand, would be about having an element of one 
type "play the part of" an element of another type, such as a 
cross-reference "playing" an XLink.

> > <!ELEMENT FOO (LHS,"=",RHS)>
> > 
> 
> Datatag?
> 
> What's wrong is it doesn't identify the "=" as an operator, so either
> you know it's an = sign by default, in which case it's redundant,
> or you have an expression but no way to know what the operator is.
> You are mixing levels - you've got parsing and lexing mixed, which is
> what made SGML so twisted.

It has nothing to do with either parsing OR lexing. It simply says that 
the node between the LHS element node and the RHS element node must be 
the data character "=". This simple case could only be a mmenonmic for a 
human author. But you could also do this:

<!ELEMENT FOO (LHS,"=",OP1,("+"|"-"|"/"|"*"),OP2)>

Again, there is no parsing or lexing involved. Instead of asking if the 
node between the OPs has a GI property of "PLUS" or "MULT", you'd ask if the 
char property of the datachar node is "+" or "*".

 Paul Prescod

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list