XSchema suggestion/wish: Parameter entity (or SGML DTD inclusions/exclusions?) "equivalent"

Jarle Stabell jarle.stabell at dokpro.uio.no
Thu Jan 14 19:22:18 GMT 1999


The company I work for is building an XML tool where we need an easy to 
learn schema language, which needs to be extensible in the way described 
below.
XSchema would suit us well if it had an extension "equivalent" to this.

----------------
DTD Design:
----------------
When (experienced) people design DTD's, they use "tricks/idioms" like the 
below (taken from John Covan's IBTWSH DTD 
http://www.ccil.org/~cowan/XML/ibtwsh.dtd ):


<!ENTITY % local "CITE | CODE | DFN | EM | BIG | SMALL
		| KBD | SAMP | STRONG | VAR | ABBR | ACRONYM">

<!ENTITY % horiz "#PCDATA | %local; | A | BR | SPAN | %ibtwsh.include;">

<!ENTITY % lists "DL | UL | OL | DIR">

<!ENTITY % blocks "BLOCKQUOTE | DIV | HR | P | PRE">

<!ENTITY % vert "%horiz; | %blocks; | %Sets;">

<!ENTITY % headers "H1 | H2 | H3">

<!ENTITY % struct "%vert; | %headers; | ADDRESS">

<!ENTITY % horiz.model "(%horiz;)*">

<!ENTITY % vert.model "(%vert;)*">

<!ENTITY % struct.model "(%struct;)*">

----------------
----------------

We would like to be able to use the same idiom, but within XML instance 
syntax, f.i. like the following:

<ElementSet Name="local">  <!-- Defines a set of elements. The set is named 
'local'-->
 <Include Element=""CITE"/>
 <Include Element="CODE"/>
 <Include Element="DFN"/>
 <Include Element="EM"/>
 <Include Element="BIG"/>
 <Include Element="SMALL"/>
 <Include Element="KBD"/>
 <Include Element="SAMP"/>
 <Include Element="STRONG"/>
 <Include Element="VAR"/>
 <Include Element="ABBR"/>
 <Include Element="ACRONYM"/>
</ElementSet>



<!-- <!ENTITY % horiz "#PCDATA | %local; | A | BR | SPAN | 
%ibtwsh.include;"> -->

<ElementSet Name="horiz">
 <Include ElementSet="local"/>
 <Include Element="A"/>
 <Include Element="BR"/>
 <Include Element="SPAN"/>
</ElementSet>

...etc...

<!-- <!ENTITY % struct "%vert; | %headers; | ADDRESS">  -->

<ElementSet Name="struct">
 <Include ElementSet="vert"/>
 <Include ElementSet="headers"/>
 <Include Element="ADDRESS"/>
</ElementSet>



Now we need the equivalent to: <!ELEMENT CITE %horiz.model;>
F.i. like:


<ElementDecl Name="CITE">
  <Model>
    <Mixed>
      <Ref ElementSet="horiz"/> <!--Note use of imaginary ElementSet 
attribute-->
    </Mixed>
  </Model>
</ElementDecl>



We assume we could also need an <Exlude> element type to be available 
inside <ElementSet> definitions (for set substraction), but DTD design 
gurus probably can tell whether this is needed or not.

We would like "subschemas" to be able to extend (or substract) elementsets 
defined in base-/superschemas, ie changing also the part of the [total] 
schema defined in the baseschema. (The calculations of the extensions of 
the elementsets shouldn't be done before all the schemas have been read)

This "set algebra" is perhaps not so "semantically pretty" as some 
inheritance mechanisms, but is IMHO quite easy to use/understand.


---------
Example:
---------
Assume you have a schema named BaseSchema (which someone else "owns", 
meaning it would bring you ugly maintaince problems if you change it in any 
way), which has an ElementSet named 'formattingtags' (used in a lot of 
mixed content elements).

You would like to be able to extend this set with <note>, <warning> and 
<tip> element types.

You should be allowed to define a schema which "includes/inherits" 
BaseSchema, and "redefines/extends" the set 'formattingtags' to also 
include <note>, <warning> and <tip>.

Something like:


<!--Our extended schema -->

...mechanism to include baseschema...

<ModifyElementSet Name="formattingtags">
 <Include Element="note"/>
 <Include Element="warning"/>
 <Include Element="tip"/>
</ModifyElementSet>

<ElementDecl Name="note">
  <Model>
    <Mixed>
      <Ref ElementSet="formattingtags"/>
<!--<note> should not be used within itself (neither directly nor 
indirectly), but we aren't able to specify this.-->
    </Mixed>
  </Model>
</ElementDecl>

...same for 'warning' and 'tip'...

<!--end of extended schema -->



Advanced schema languages would be useful for DTD/schema designers even 
without any XML parser knowing that particular schema language, because 
authoring tools could automatically translate the advanced schemas into the 
simpler ones.

Directly authoring big/complex XSchemas seems highly problematic without 
extensions like this one.


Cheers,

Jarle Stabell
Digital Logikk AS


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