[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Guidelines for handling of elements' content?


handling of elements
Ralf <ralfml@a...> 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
</example>

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.

HTH

Ari.

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.