OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: XML and inheritance and transformation of representations

[ Lists Home | Date Index | Thread Index ]
  • From: Rick JELLIFFE <ricko@geotempo.com>
  • To: xml-dev@lists.xml.org
  • Date: Thu, 13 Jul 2000 15:40:44 +0800

"Tolkin, Steve" wrote:
> What kinds of "inheritance" are possible in XML, and in DTD and XML Schema?
> Consider this XML, an excerpt from [1] that illustrates a general issue.
> <OBJECT ID="JTextField0" CLASS="JTextField">
>     <OBJECT PROPERTY="nextFocusableComponent" IDREF="JButton0"/>
>     <OBJECT PROPERTY="bounds" CLASS="Rectangle">
>         <OBJECT CLASS="Integer" VALUE="30"/>
>         <OBJECT CLASS="Integer" VALUE="50"/>
>         <OBJECT CLASS="Integer" VALUE="200"/>
>         <OBJECT CLASS="Integer" VALUE="20"/>
> What techniques are available in XML to increase flexibility and clarity?
> Wearing an object oriented hat we might want to allow CLASS=rectangle
> to be have various possible implementations:
> 1a. As above
> 1b. As above, but also labelled as e.g. x1, y1, x2, y2, with either tags or
> another attribute of Object e.g. ROLE="x1", or with multiple attributes
> 2. As one point and two distance deltas
> 3. As two point objects (with perhaps some constraints e.g. x1 < x2 and y1 <
> y2)
> 4. As subtype of a polygon class, constrained to have 4 sides which form a
> rectangle
> etc.
> What can I say in a DTD or in XML Schema to allow this kind of flexibility?

This data sets you up for a fall: the information you need is in the
CLASS attribute, and the generic identifier OBJECT is almost useless.
The generic identifiers are the primary (in fact, only) markup that XML
DTDs and XML Schemas use to determine the allowed content model (i.e.,
which subelements).  

In SGML terms, you have two "architectures" here: one based on OBJECT
and one based on JTextField. DTDs only let you validate the one using
element names (generic identifiers).
There are three approaches to this.

1) Use an architecture processor. I think Dave Megginson did something
along these lines, but I am not sure how well it works. I think you can
use SP/NSGMLS to validate architectures, but it may be too difficult to
get up to speed on how.

2) Transform the document into the architectural view  of JTextField
using XSLT. Transpose the CLASS attribute value and the value of the
GI.  Then you can make a conventional DTD or XML Schema.  There are
probably almost no constraints that cannot be checked using enough
transformation/schema pairs with a high-powered schema language with
datatyping such as XML Schemas.

3) Create a Schematron schema.   Schematron can describe constraints for
any information item, not just the generic identifer (element name).  So
you can say "An OBJECT with a CLASS attribute "Rectagle" can contain 4
OBJECTS with class attribute "intenger" or 2 OBJECTs with class
attribute "point" etc etc".
Schematron is free and open source.  

Rick Jelliffe


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS