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


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: Whitespace question

[ Lists Home | Date Index | Thread Index ]
  • From: "John E. Simpson" <simpson@polaris.net>
  • To: Gavin McKenzie <gmckenzi@JetForm.com>
  • Date: Wed, 04 Aug 1999 10:41:53 -0400

At 09:02 AM 8/4/1999 -0400, Gavin McKenzie wrote:
>...in section 2.10 "White Space Handling" of the XML spec it says:
>"The root element of any document is considered to have signaled no
>intentions as regards application space handling, unless it provides a value
>for this attribute or the attribute is declared with a default value. "
>My understanding of this paragraph is to say that,
>"When a document does not place an explicit xml:space attribute on the root
>element, an application may choose to process the whitespace within that
>document as it chooses; i.e. as equivalent to either one of 'default'or
>'preserve' based on the application's default behaviour"

This is one of those bizarre areas where you can read into the spec almost
anything you want. Since xml:space has only two allowable values, "default"
and "preserve," it might be tempting to think of those two behaviors as
opposites. Since "preserve" pretty clearly means, "Assume all whitespace in
element content is significant," then by this interpretation "default" must
mean the "opposite" -- i.e., "Assume none of the whitespace in element
content is significant."

This interpretation has a couple of problems.

(1) cml:space="default" leaves "what to do" unspecified; it's entirely
dependent on what the processor application normally does.

(2) The fact that there are only these two alternatives means that there's
no way to force a processor to *discard* "extraneous" whitespace in element

Tim Bray's Annotated XML Specification, available at:
has a couple of useful comments about the whole issue. My favorite one for
understanding the core of the issue is, "if it ain't markup, it's data."
Therefore all spaces, newlines, etc. must be passed along by the processor
just as if they were As, $s, 9s, and so on. Using XML alone, you can't tell
a downstream app that it should collapse extraneous whitespace, a la HTML
browsers (although I believe you can do so with XSL); if you don't want it
to consider the extraneous whitespace, don't include such whitespace in the
first place.

All of which is to say, yes, I guess you're right: If you want to be
absolutely sure that the downstream application uses its default behavior,
then I guess it doesn't hurt to explicitly include xml:space="default" in
the root element.

(I still don't know how that will change anything, though. If the
downstream app's default behavior is to preserve whitespace -- say in an
XML-based source code editor -- then using either xml:space="default" or
xml:space="preserve" is the same thing as using *neither*. If the app's
default behavior is to ignore extraneous whitespace, then
xml:space="default" doesn't affect how it processes element content, either.)

Maybe someone with a firmer grasp of the subtleties can chime in here?

John E. Simpson          | It's no disgrace t'be poor, 
simpson@polaris.net      | but it might as well be.
                         |            -- "Kin" Hubbard

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)


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

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