[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

  • From: "Rick Jelliffe" <ricko@a...>
  • To: <xml-dev@i...>
  • Date: Thu, 4 Jun 1998 01:11:37 +1000

pre and post conditions
> 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" ?>

<!NOTATION XASSERT SYSTEM >
<!-- The XASSERT notation is a simple language with the following
     syntax:
 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* )>
<!ATTLIST XASSERT:true
      subject ( element | entity | PI | comment | attribute )  "element"
	name ID #REQUIRED >

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

<!ELEMENT XASSERT:post-condition  ( #PCDATA )>
<!ATTLIST XASSERT:post-condition
	id ID #IMPLIED
	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>
</XASSERT:true>

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.sil.org/sgml/jelliffeXMLAnn.html
http://www.phptr.com/  > Book Search > "Jelliffe"
http://www.amazon.com/exec/obidos/ASIN/0136142230/002-4102466-3352420


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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.