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


Help: OASIS Mailing Lists Help | MarkMail Help



   Pre- and Post-conditions (was RE: XSchema: multiple proposals)

[ Lists Home | Date Index | Thread Index ]
  • From: "Rick Jelliffe" <ricko@allette.com.au>
  • To: <xml-dev@ic.ac.uk>
  • Date: Thu, 4 Jun 1998 01:11:37 +1000

> From:  Don Park

> >All of which leads me to wonder if is there an (as yet
> >undiscovered) way to
> >represent XML content models in XML without using the basic structure:
> Frankly, I would like to see separate definitions for each element,
> attributes, and containment rules.

On approach would be to get rid of the notion of content models entirely
(i.e. leave them where they are in the markup declarations), and replace
them with more generalized pre- and post-conditions. A document is valid if
each post-condition is true at a start-tag and if each pre-condition is true
at the corresponding end-tag.

Following is a really simple version. The reason why this might be useful is
that it allows all sorts of containment constraints to be expressed but in a
decentralized, incremental manner.

<!-- XASSERT.DTD -->
<!-- A simple DTD for a schema language using pre- and post-conditions -->
<?xml:namespace ns="XASSERT" ?>

<!-- The XASSERT notation is a simple language with the following
 assertion     ::=  simple-test | compound-test
 compound-test ::=  "(" assertion ( "&&" | "||" | "!&" | "!|" ) assertion
 assertion     ::=  Xptr ("==" | "!=" ) ( strings | "#SPECIFIED" )
 strings       ::=  string ( "||" string )*

<!ELEMENT XASSERT:true  ( XASSERT:pre-condition*, XASSERT:post-condition* )>
      subject ( element | entity | PI | comment | attribute )  "element"
	name ID #REQUIRED >

<!ELEMENT XASSERT:pre-condition  ( #PCDATA )>
<!ATTLIST XASSERT:pre-condition
	notation NOTATION ( "XASSERT" ) "XASSERT" >

<!ELEMENT XASSERT:post-condition  ( #PCDATA )>
<!ATTLIST XASSERT:post-condition
	notation NOTATION ( "XASSERT" ) "XASSERT" >

E.g. the following content model
	<!ELEMENT x ( z )>
could be expressed (the XLink is incorrect...dont flame me!!!!!!!!!!)

<XASSERT:true name="z">
	<XASSERT:pre-condition>HERE(parent) == "x" </XASSERT:pre-condition>

This kind of thing can better express complicated validations, such as that
if a certain element above has an attribute with a certain value, the
current element or its children should not provide some attribute value.

Presumably the syntax should follow ECMA or Perl (Yuck) more, and allow
cascading assertions.

Rick Jelliffe

The XML & SGML Cookbook, by Rick Jelliffe
Charles F. Goldfarb Series on Open Information Management
656 pages + CD-ROM, Prentice Hall 1998, ISBN 0-13-614233-0
http://www.phptr.com/  > Book Search > "Jelliffe"

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


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

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