[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 whitespace
Thomas B. Passin wrote:

> The only whitespace that can really be in question is whitespace between 
> elements - that is, between the end of one element and the start of the 
> next.  Whitespace in element content is simply part of the content and 
> is not to be removed.  Whitespace is allowed between elements for visual 
> formatting, and it is a sensible question to ask about how to tell when 
> such whitespace is just for formatting and when it is actually supposed 
> to be part of the content.

Indeed.  In fact, with a bit of thought, you can construct any number of 
corner cases where it's horribly non-obvious whether the whitespace 
matters.  Unfortunately, you can do this whether or not there's a DTD in 
play.  Don't know if schema solved this but I doubt it.  The designers 
of SGML worked really hard on writing all this down and giving rules, 
and then the implementors disagreed on what they meant.   The handling 
of whitespace is highly application-specific, and xml:space is nothing 
more than a signal of intent from upstream, that may freely be ignored 
downstream.

The best rule, if you're generating XML, is not to put in any white 
space that you don't mean.  One common trick to make things totally 
unamibiguous is what used to be called RAST format:

<html
 ><head
 ><title>the Title</title></head><body
 ><h1
 >whatever</h1>
<p
 >first para with no whitespace problems, with <a href="#foo"
 >embedded link</a> you see how it goes?</p></body></html>

i.e. no newlines in content ever.  This may be taking it a bit far, but 
maybe not.
-- 
Cheers, Tim Bray
         (ongoing fragmented essay: http://www.tbray.org/ongoing/)



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.