[whatwg] xml:space

Ian Hickson ian at hixie.ch
Sun Apr 27 18:28:31 PDT 2008

I haven't done anything with xml:space. It doesn't do anything, and it's 
not an HTML5 thing, so as far as I can tell it is out of scope for HTML5.

On Mon, 22 Jan 2007, Henri Sivonen wrote:
> > 
> > Since this editor artifact is harmless in browsers and useful in 
> > editors, it would be nice if the spec made it conforming at least on 
> > the <pre> element in XHTML5.
> Suggested text:
> The xml:space attribute may be used on XHTML elements of XML documents. 
> Authors must not use the xml:space attribute in HTML documents. The 
> xml:space attribute, if present, must have the literal value "default" 
> or the literal value "preserve". The meaning of this attribute is 
> outside the scope of this specification.
> If that's too permissive, here's what would minimally cover my use case: 
> In XHTML (but not in HTML), the element pre may have the attribute 
> xml:space. If the attribute is present, the value of the attribute must 
> be "preserve".
> The first conforms to XML 1.0 for sure. The latter may not exactly, 
> depending on spec interpretation.

I don't see why we should special-case this particular harmless non-HTML 
feature, and not any number of other harmless non-HTML features. If 
another specification wants to define something, then it's up to that 
specification to define when it can be used.

On Tue, 23 Jan 2007, Henri Sivonen wrote:
> (As a practical matter, it would be nice to explicitly remind 
> conformance checker developers that the attribute is conforming. 
> Otherwise, it is easily forgotten. :-)

Forgeting it seems fine to me...

On Tue, 23 Jan 2007, liorean wrote:
> Well, considering the purpose of XHTML (main purpose is presentation for 
> humans, no?) is there any reason to NOT just set it to default to 
> "preserve" on the html element, fixed to "preserve" on the script, 
> style, pre and textarea elements and have it implied through an entity 
> for all other elements? Style sheets can change whether presentation of 
> whitespace is collapsed or not. By default, the whitespace is collapsed 
> but for the pre element it's conserved, but that can overridden by user 
> or author style sheets. But whitespace that is structurally collapsed at 
> the XML level cannot be restored for presentation by the style sheet, so 
> this whitespace is lost from ever being presented as it appeared in the 
> document.

xml:space doesn't allow whitepsace to be collapsed at the XML level as far 
as I can tell.

On Tue, 23 Jan 2007, Anne van Kesteren wrote:
> Regarding whether or not HTML5 should mention it. It seems the intention 
> of the XML specification is that you have to say it's allowed: "In valid 
> documents, this attribute, like any other, MUST be declared if it is 
> used." Opinions probably vary on this.

"Valid" in XML is only relevant for DTDs.

On Tue, 23 Jan 2007, liorean wrote:
> Hmm, reading the relevant part of the XML1.0 spec again, I see you're 
> right. So, it would seem to me that it's an attribute describing 
> whitespace semantics in content, not a structural attribute like I 
> thought. So, say you have a <poetry:poem> element, but where the element 
> semantics doesn't specify whether whitespace is important in the poem or 
> not (it might be, but that depends on the poem content), you can specify 
> it in that attribute.

Seems like it'd be better for the spec itself to define the semantics of 
its elements rather than depend on the author to specify the attribute...

On Tue, 23 Jan 2007, Martin Atkins wrote:
> Presumably its primary purpose is to act as a signal to generic XML 
> tools — that don't have any special knowledge about XHTML — that 
> they should not screw around with the whitespace inside PRE, etc.
> One obvious example of such a tool is an XML pretty-printer. While an 
> HTML pretty-printer like HTML Tidy can have rules "hard-coded" into it, 
> this is not true of a non-validating XML formatter unless it is 
> specifically written for XHTML.

It seems that given the importance of XHTML, we can expect pretty printers 
to be written for it.

On Tue, 23 Jan 2007, Henri Sivonen wrote:
> (And this isn't theoretical, either. I came across this issue when 
> editing an XHTML document in oXygen.)

File a bug with them. :-)

On Tue, 23 Jan 2007, liorean wrote:
> How doesn't it? If the DTD allows it on all elements, you can put 
> xml:space="preserve" on all elements in the document that need it for 
> the tools that don't use the external subset or namespace recognition

On Wed, 24 Jan 2007, Henri Sivonen wrote:
> There's no DTD.


Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list