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


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: Element oriented programming

[ Lists Home | Date Index | Thread Index ]
  • From: "Michael Kay" <M.H.Kay@eng.icl.co.uk>
  • To: "Charles Reitzel" <creitzel@mediaone.net>, <xml-dev@ic.ac.uk>
  • Date: Mon, 28 Sep 1998 16:40:25 +0100

>Likewise, it
>must be possible to fire both when the event when the
element is first
>encountered (pre-XXX) and after all of its contents have
been read in are
>available to the event (post-XXX).

In my GedML (genealogy) app, which makes extensive use of
ID/IDREF relationships, I do the semantic validation of an
element in four phases:
1 - when the start element tag is encountered (check that
the context is OK and the attributes are valid)
2 - when the end element tag is encountered (check element
content, and consistency of subelements)
3 - when all elements have been read (check that all
referenced elements exist and are of the right type, and fix
up IDREF pointers)
4 - when all elements have been through stage 3 (check
inter-element consistency, e.g. that the family tree is

So I define four standard events for each element type.

I don't know whether this represents any kind of general
model or whether it is peculiar to my application. I suspect
it applies to any application that handles data structures
that are not purely sequential or hierarchic.

Note: some of the validation I do duplicates that done by a
validating XML processor, but this is such a small part of
the whole that I decided to put it in anyway. E.g. in phase
3 I have to check that the target element is of the right
type, so it's little extra effort to check first that it
exists, even though a validating parser will have done this
already. (Anyway, I can't be sure that the user chose a
validating parser - a SAX limitation?)

I think there's something to be said for separating
"validity checking" events from any other behaviour. The
above discussion all relates to the problem of ensuring that
the XML document conforms to application-defined validity
rules. Of course, it would be much nicer if most of this
could be done declaratively though XSchema extensions.

Mike Kay

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