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


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Guidelines for handling of elements' content?

[ Lists Home | Date Index | Thread Index ]

Ralf <ralfml@alfray.com> writes:

> Sure xml:space tells me I should preserve them or not... really? The
> specs doesn't tell me much about it. It just says the application gets
> it all or knows what to do with it. Well personnally I don't. What
> about "good behavior" guidelines for applications?

Some XML applications care about whitespace, some don't. It's up to
your application to decide if it cares or not. SVG in your example
doesn't. Another example of application that doesn't care is XHTML: by
default, a user agent will remove leading and trailing whitespace form
a text node and collapse runs of whitespace into a single space. It
may then break the resulting string into lines that fit the available
canvas. SVG behaves similarly, except it doesn't word-wrap (in
1.0). XHTML also provides examples of contexts where whitespace is
important, e.g. the ``code'' and ``sample'' elements, which a user
agent is expected to render in fixed-width font with all whitespace
and line breaks preserved.

The reason these two models exist is that whitespace is often used in
XML for source readability and has no particular significance.

<example>In many XML applications, line breaks and
    whitespace characters are used only to
    "pretty-print" the source XML and have no
    significance to the application, which may wrap
    the text

As far as best practices go, try to stay away from requiring
significant whitespace when you design a vocabulary. If your
vocabulary needs to break text into pieces on some boundary, mark that
boundary up explicitly with an element. The most common example is a
paragraph, represented in many vocabularies by ``p'' or ``para''
elements instead of relying on newline characters. For a data-oriented
example, if your purchase order allows for multiple items, make every
item its own element instead or relying on newline characters to
separate them.




News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS