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

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: RE: Attribute defaults


I like the idea of an annotation for a default value very much. It keeps
RELAX NG in the 'pure validation' business, and it provides a placeholder
for other processing which may require a default value. It think it is an
elegant compromise.

James Clark wrote:
>We could even have a standard annotation namespace with some useful
>annotations (like a standard name for human-readable documentation)
>including attribute default values.

I think a standard annotation namespace is a good idea as well. Something
like:

xmlns:a="http://relaxng.org/ns/annotation/0.9"

Elements:

a:documentation
a:annotation

Attributes:

a:default or
a:defaultValue

Just a handful of markup for version 1.0 should prove sufficient to satisfy
some important needs.

-Mike


-----Original Message-----
From: James Clark [mailto:jjc@jclark.com]
Sent: Monday, June 18, 2001 9:10 PM
To: Michael Fitzgerald; RNG List
Subject: Re: Attribute defaults



> RELAX NG does not allow you specify defaults for attributes (see section A
> of the tutorial
> http://www.oasis-open.org/committees/relax-ng/tutorial.html#c41b1c17).
Does
> anyone else see this as a tripwire? Example: when you try to rewrite
> something as RELAX NG, such as an XML Schema attribute declaration with
> default="string", what do you do?

Use an annotation:

  <attribute name="foo" x:defaultValue="true">
    <data type="boolean"/>
  </attribute>

Default attribute values in XML serve two purposes:

a) Documentation: they tell a human that if the attribute is not specified,
the document will be interpreted as if the attribute has been specified with
a particular value

b) Processing: an application doesn't have to handle the case when the
attribute is missing

I think (b) is an illusion.  Robust code cannot rely on the attribute being
present.  The DTD may not have been specified or perhaps the parser didn't
read the DTD (as XML 1.0 permits). In any case, it is certainly possible
that the attribute will be missing when the application gets the document; a
conscientious developer will try to handle and recover from that. It would
also be hard to add this to RELAX NG: it would require complex restrictions
on determinism.

(a) is useful, but I think it is more appropriately served by an annotation.
We could even have a standard annotation namespace with some useful
annotations (like a standard name for human-readable documentation)
including attribute default values.

At the moment RELAX NG processing is purely validation: it involves
answering the question is this document valid with respect to the schema,
and no more. Introducing default values would change this: RELAX NG would be
also providing information about how the document should be processed.  The
XML default attribute mechanism allows you to say: if a particular element
does not have a particular attribute, then it should be processed as it had
that attribute with a particular fixed value.  Why is that the only thing
you should be able to say about how the document is processed?  What if I
want to say that if a particular attribute is not present, it should be
inherited or it should default to the value of some other attribute?  What
if I want to say that if some child element is not present, a child element
with a particular value should be added by default?

James










------------------------------------------------------------------
To unsubscribe from this elist send a message with the single word
"unsubscribe" in the body to: relax-ng-request@lists.oasis-open.org



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC