SVGT 1.2: A proposal for how to define SVG whitespace in terms of CSS whitespace

As requested by Jon Ferraiolo, here's a rough cut at reformulating  
SVG whitespace handling in terms of style properties, to eventually  
phase out use of xml:space and to be more compatible with a CDF  
environment. I have Cc'd www-style because I believe that changes to  
CSS may be required.


Here's what the SVG Tiny 1.2 spec says now:

==============

*    default (the initial value for xml:space) - When  
xml:space="default", the SVG user agent will do the following using
a copy of the original character data content. First, it will remove  
all newline characters. Then it will convert all tab
characters into space characters. Then, it will strip off all leading  
and trailing space characters. Then, all contiguous
space characters will be consolidated.
*    preserve - When xml:space="preserve", the SVG user agent will do  
the following using a copy of the original
character data content. It will convert all newline and tab  
characters into space characters. Then, it will draw all space
characters, including leading, trailing and multiple contiguous space  
characters. Thus, when drawn with xml:
space="preserve", the string "a    b" (three spaces between "a" and  
"b") will produce a larger separation between
"a" and "b" than "a b" (one space between "a" and "b").

===============

Here's my proposal for how to change this.


* The default setting for xml:space for SVG elements is "preserve".  
In "preserve" mode, all whitespace is preserved in the DOM as is.
* xml:space="default" is deprecated, in favor of using whitespace- 
related properties.
* The default whitespace property settings for SVG elements are set  
up so that whitespace is not collapsed, but linefeeds and tabs are  
treated as spaces.

At this point, there are two choices:

1) CSS 2.1 has no ability to treat linefeeds or tabs as spaces but  
not collapse them, in the white-space property. However, a new white- 
space value could be added (in CSS 2.1.1?) that gives the SVG  
behavior. Possible names would be "pre-space", "pre-nobreak", "pre- 
all-as-space", or something like that. Then when/if CSS3 expands the  
whitespace properties, it can ensure that the SVG mode is covered too.

2) Some CSS3 Text drafts have included a linefeed-treatment property  
(as in XSL) that allows linefeeds to be treated as spaces. Adding an  
analogoues tab-treatment, it would be possible to say that for SVG  
there is a default style of { white-space: pre; linefeed-treatment:  
treat-as-space; tab-treatment: treat-as-space; } However, the latest  
Text Effects module replaced all the whitespace properties with a new  
white-space-collapse property. As far as I can tell, white-space- 
collapse cannot even be used to implement all the CSS 2.1 white-space  
modes, so I'm not sure what the CSS WG intends here.


Now for xml:space="default", there are multiple options for how to  
treat it.

A) Define it as transforming the DOM in the specified way, such that  
even standard DOM access to the characters gives the transformed  
string. This is useful, but problematic for interoperability since it  
would be harder to use a single XML parser for multiple languages if  
they defined their own meanings for "default". The XML spec does not  
define a behavior for "default".

B) Have it leave the DOM alone, but apply { white-space: collapse;  
linefeed-treatment: ignore; } (or invent yet another CSS 2.1  
whitespace mode for it - "collapse-strip-linefeeds" or something).


My own preference of options is 1 and A, with "default" deprecated  
and its special behavior slated to be removed in a future revision of  
the SVG spec.

I'm hoping for guidance from the CSS WG and feedback from the SVG WG.

Note: this proposal is not meant to supercede my comment that  
whitespace treatment in SVG should be reformulated generally; I would  
like to see that happen even if this specific proposal is fatally  
flawed in some way. I dashed it off pretty quickly and did not try to  
figure out all the details.

Regards,
Maciej

Received on Monday, 30 January 2006 23:23:07 UTC