xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett McLaughlin <bmcla...@algx.net>
Subject Re: XML Inheritance Extentions (first try)
Date Mon, 20 Dec 1999 19:03:30 GMT

Stefano Mazzocchi wrote:
> Brett McLaughlin wrote:
> > I think one of the most significant items missing from this is details
> > about namespace.
> You're right.
> > For example, in your example:
> >
> > > <page>
> > >   <title/>
> > >   <author>John Smith</author>
> > >   <body/>
> > >   <legal>Copyright (c) 1999 John Smith. All rights reserved.</legal>
> > > </page>
> >
> > It is fairly reasonable to assume that this template could be extended
> > by hundreds of pages across a website, and possible across multiple
> > websites (part of the same company).  So I would want to be able to
> > assign different namespaces to these variants:
> >
> > <contents:page xml:extends="template.xml">
> >   <contents:title>Table of Contents</contents:title>
> >   <contents:body>
> >     <p>Hi, welcome to the table of contents.</p>
> >   </contents:body>
> > </contents:page>
> >
> > and:
> >
> > <chapter:page xml:extends="template.xml">
> >   <chapter:title>Chapter One: Introduction</chapter:title>
> >   <chapter:body>
> >     <p>Here is content of Chapter One</p>
> >   </chapter:body>
> > </chapter:page>
> >
> > This allows the same template to be used many places, and still handle
> > inclusions.  For example, my contents:page might include portions of
> > various chapter:page documents, making namespace support critical.  How
> > would this be handled?  This is the problem I was referring to earlier
> > when I said that you should be able to easily map namespaces onto XML
> > documents.  In this case, you would want an initial run through the
> > document to ignore the namespace, handling only [XML_1] and [XML_2]
> > where XML_1 is the original document (template) and XML_2 is the
> > extending document, minus the namespace.  Then it would be the same
> > scenario as you proposed.  At the end of the extension processing, you
> > could simply perform A * [XML_2] where A is the desired namespace to
> > achive the final XML document, with namespace support, but without
> > additional strange processing having to go on.
> I agree and I already had the impression I was missing something on the
> namespace side. Anyway, I still can't focus on a nice and simple way to
> address that problem.
> > Of course the complexity increases with multiple namespaces in
> > documents.  But let's wait on that until I get feedback on this first
> > comment.  What do you think?  I see this as a serious need for inclusion
> > in the note.
> I do too. Have any ideas on how to do it?

Not with XML today.  This is (and I'm playing the same old tune) a
problem with the current XML model - the namespaces specification
doesn't _really_ provide any sort of "multiplier" that is applied to an
XML document.  Once the namespace is used, there _is_ a difference
between <element> and <namespace:element> in terms of equality.  There
is no way (that I know of in anything I've read) to say, "Oh, these are
the same element, and one just has a namespace mapped to it."  This
would come in great use, particularly when you have <namespace1:element>
and <namespace2:element> and element is the same in both.  Oh, to be
able to use the vector type mentality you mentioned earlier...

At the same time, I think your proposoal may be important enough to
begin to try and firm up the XML namespace concept as a precursor. 
However, this is a _lot_ to bite off.  I am more than willing to help
with it, but as you said, you were trying to keep it simple.  I think it
would be nice to be able to do (in an XML Schema):

<archetype name="myElementType">
  <element name="title" type="string"/>
  <element name="page" type="integer"/>

<element name="myElement" type="myElementType" namespace="Book"/>

This would allow the element myElement to be mapped to the Book
namespace, resulting in <Book:myElement> being allowed in the
constrained document.  The magic here is that we can suddenly also have:

<element name="myElement" type="myElementType" namespace="Cassette"/>

and the comaprison between these is a piece of cake!  Is is trivial to
see that <Book:myElement> and <Cassette:myElement> are the same - so
inheritance would be easy:

<myExtendedElement xml:extends="template.xml" xml:namespace="Book">
  <!-- Content -->

At runtime/parsetime, this could then be extended (because
myExtendedElement would extend the correct element) and then the Book
namespace would be applied post extension.  This cleanly seperates
namespace, and allows vector type mapping (I keep saying it - i want to
do A * [XML_1] type mappings!).

Does this make sense?


> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <stefano@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>  Come to the first official Apache Software Foundation Conference!
> ------------------------- http://ApacheCon.Com ---------------------

View raw message