xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: XML Inheritance Extentions (first try)
Date Mon, 20 Dec 1999 19:46:21 GMT
On Mon, 20 Dec 1999, Stefano Mazzocchi wrote:

> Donald Ball wrote:
> > 
> > My proposed syntax differs somewhat from Stefano's. For the purposes of
> > this document, I'll choose, uh, 'ixml' for its namespace:
> > 
> > <connection id="normal" driver="org.gjt.mm.mysql.Driver"
> >             dburl="jdbc:mysql://mysql.example.com/test"/>
> > 
> > <querydefs name="options" doc-element="options" row-element="option"
> >            tag-case="lower">
> >  <column name="creation_date" format="MMMM d, yyyy"/>
> > </querydefs>
> > 
> > <query>
> >  <ixml:extends name="connection" id="normal"/>
> >  <ixml:extends name="querydefs" id="options" id-element="name"
> >                inherits-elements="true"/>
> >  select * from foo_table
> > </query>
> > 
> > would generate:
> > 
> > <query driver="org.gjt.mm.mysql.Driver"
> >        dburl="jdbc:mysql://mysql.example.com/test"
> >        doc-element="options" row-element="option" tag-case="lower">
> >  <column name="creation_date" format="MMMM d, yyyy"/>
> >  select * from foo_table
> > </query>
> 
> ???
> 
> Are you sure this is algorithmically certain? I can't visualize a
> turing-machine that performs such generation, given the information you
> provide. Am I missing something?

Absolutely. The algorhtim is very simple:

For each element (call it the base node) with <ixml:extends> children {

 For each <ixml:extends> element (call it the extends node) {

  Locate the element (call it the logical parent node) referenced by the 
  <ixml:extends> element

  If the extends node's inherits-attributes attribute is true {

   For each attribute on the logical parent node {

    If the attribute does not exist on the base node and the attribute is
    not the element's referenced id attribute, copy the attribute
    from the logical parent node to the base node

   }

  }

  If the extends node's inherits-elements attribute is true {

   For each element child of the logical parent node {

    Copy the element from the logical parent node to the base node,
    immediately after the current <ixml:extends> element

   }

  }

  Remove the <ixml:extends> element from the base node

 }

}

I can provide an algorithm for locating the logical parent node from the
name, id, and id-attribute attributes if you're unclear on how that
should work. It's very easy, essentially, look for the first element named
'name' with an attribute named 'id-attribute' (where id-attribute defaults
to 'id') with value 'id'. I don't think I'll always want to inherit a
document root, which you'd have to do under your syntax; I can see many
instances in which I'd like to specify a certain node in a document from
which to inherit attributes.

- donald 


Mime
View raw message