W3C home > Mailing lists > Public > www-style@w3.org > October 2000

Entities in XML (Re: New version of the Selectors module of CSS3)

From: Bert Bos <bert@w3.org>
Date: Mon, 9 Oct 2000 11:52:44 +0200 (MEST)
To: <www-style@w3.org>
Message-ID: <14817.36552.927794.89554@lanalana.inria.fr>
Jonas Sicking writes:
> Bjoern Hoehrmann wrote:
> 
> > | 5. entities
> > | If I have a XML file containing unresolved entities it could be really
> > | useful to be able to style those.
> 
> > No problem. Wrap them in an inline element.
> 
> I don't want to adjust my XML for display. The usecase is:
> I have an XML file containg some data. The markup is not designed for
> display but rather for the data it contains. To be able to display the data
> I want to use CSS. The markup contains some entities that have special
> meanings, such as &null; could mean that data is not availible, &error;
> means datacalculation resulted in an error.
> Lets say I have the following XML file:
> <person>
>   <name>Mr Foo</name>
>   <age>&null;</age>
>   <income>&error;</income>
> </person>
> 
> I could use this CSS
> 
> :root { font-family: sans-serif }
> person {display: block; padding: 2em; border-bottom: 2px solid black}
> name { font-size: 200%; text-decoration: underline; display: block; margin
> 1em;}
> age,income { display: block; }
> &null; { content: 'Data not avalible'; color: gray }
> &error; { content: 'Error'; background: red }
> 
> Maybe I'm just not using entities correctly. This might not at all be the
> purpos they were designed for.

Entities may be useful to the author, to make changing certain parts
of a document easier or to make the document shorter, but they are not
meant to convey any semantics to the reader. An entity is simply a
macro. If an entity "&foo;" is defined as "bar" then to the reader
there is absolutely no difference between the documents

    <elt>&foo;</elt>
and
    <elt>bar</elt>

If you need metadata, you have to use elements or attributes. E.g.:

    <person>
      <name>Mr Foo</name>
      <age><null/></age>
      <income><error/></income>
    </person>
or
    <person>
      <name>Mr Foo</name>
      <age null="y"></age>
      <income error="y"></income>
    </person>

Of course, XML is just a syntax, and you could use it in any way you
want. But you may encounter difficulties, since most XML tools
(parsers, transformation tools, renderers, etc.) implicitly assume a
certain way of using XML. E.g., as you discovered, CSS has no way of
styling an entity, since it assumes it only ever has to render the
expansion of the entity.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Monday, 9 October 2000 05:52:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:06 GMT