Shorthand for default attributes (was: Re: Whitespace)

Michael Sperberg-McQueen writes:
 > On Sun, 11 May 1997 13:31:41 -0400 Bert Bos said:
 > > >  2. Default attributes
 > >
 > >The previous XML-lang draft had a handy macro <?xml default...?> that
 > >I find very useful, expecially in dealing with XML-link, where a lot
 > >of elements have fixed attributes.
 > >
 > >Without it, a document like this
 > >
 > >    <!doctype foo "foo">
 > >    <foo/>
 > >
 > >with this DTD
 > >
 > >    <!element foo any>
 > >    <!attlist foo att (def) def>
 > >
 > >is not valid (for some definition of "valid"), since the DTD says that
 > >the "att" attribute cannot be #implied. Note that it could be omitted
 > >if this was SGML-1986, but in XML it cannot.
 > 
 > Why not?
 > 
 > I don't see anything in the spec that says a document is invalid
 > if it allows attributes to take their default values.
 > 
 > If you see something that does say so, where is it, please?

That's the problem: the spec doesn't say so. I think it should be
added, because without it the risk is too great that different parsers
arrive at different results. Implementers that know about SGML may
implement it differently from those that don't.

The problem is that the latest draft still allows documents that
cannot be read without reading the DTD first. The purpose of a DTD is
to constrain the syntax, not to change its interpretation. (This is
also what the draft says, in 2.9). I thought that one of the main
reasons for starting the XML effort was to get rid of this double
(triple?) function of DTDs that has plagued SGML so much:

   1. Limit what is allowed in a document, such as what elements can
      occur where. DTDs are not very good at this, but defining a
      better syntax is not currently on the agenda. So let's stick
      with DTDs for now. This function is needed by generators.

   2. Change interpretation of characters in the document. We don't
      want this, and most of it has been removed by XML already
      (shortrefs, datatags, RS/RE interpretation,...). Only whitespace
      handling hasn't been resolved yet. The keep-all-whitespace rule
      that XML seems to be converging on is not my first choice, but
      at least it is makes whitespace handling independent of the
      DTD.

   3. Provide macro-like capabilities (entities and default
      attributes). To replace entities we already have XML-link, but
      we don't have anything for default attributes yet. Since it is
      not only generators that need this, it has to be an independent
      syntax, outside the DTD.

I would argue for the return of the <?xml default...?>, or some
similar macro mechanism. The syntax around ATTLISTs is too complex,
and requiring people to include all attributes exhaustively is too
cruel and also error prone. Moreover, neither option is compatible
with the stated design goals for XML (especially 4, 5, 6 and 9). A
simple macro mechanism (with scope, please) seems an ideal solution.

I'd like to do this:

    <DOC>
    Start of a long document...

    <DIV>
    <?XML DEFAULT P  CLASS="NOTE" SECT="1"?>
    <P>In this section, all Ps have the same attributes...</P>
    <P>...</P>
    ...
    </DIV>

    <DIV>
    <?XML DEFAULT P  CLASS="DEF" SECT="2"?>
    <P>In this section, all Ps also have the same attributes...</P>
    <P>But different ones from the previous section...</P>
    ...
    </DIV>

    ... etc.
    </DOC>

Btw. Do we need the "xml" string at the start of the PI? I don't see
why we need PIs at all. The only thing we need is three distinct
syntaxes that look neither like data not like tags and that can be
used to specify the encoding, the default attributes, and the XML
version number. How about <?encoding utf8>, <?default...>, and
<?xml1.0>.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/pub/WWW/People/Bos/                      INRIA/W3C
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 4 93 65 77 71               06902 Sophia Antipolis Cedex, France

Received on Monday, 12 May 1997 19:21:33 UTC