Bugzilla – Bug 6535
[SER 1.1]: Add new serialization option suppress-indentation
Last modified: 2010-01-04 22:02:45 UTC
There is a class of XML documents - our errata documents are a good example - that contain "data" at the upper levels of the content hierarchy, and narrative text further down the hierarchy. Atom feeds are another example: the top-level structure contains metadata, and inside this there is a "content" element that holds XHTML.
The nicest way to serialize such documents - exemplified by the way the Atom spec shows its examples - is to use indentation for the "data" part, and to suppress indentation for the "narrative" part.
If the result document is schema-validated, specifying indent="yes" will tend to achieve this, because we specify that indentation should not apply within elements that have mixed content. But usually there is no schema, and it would be useful to be able to achieve the same effect in that case also.
I propose a new serialization property suppress-indentation whose value is a list of QNames. If this property is specified in conjunction with indent="yes", then its effect is to modify the rules for indentation by specifying that no whitespace is to be added to the output within the content (at any depth) of an element whose name appears in the list of QNames. If indent="no" is specified then the attribute is ignored, except that it must still be a syntactally valid list of QNames. The default value is an empty list.
The property behaves like cdata-section-elements in its surface syntax in XSLT and XQuery, and in XSLT its override behavior follows cdata-section-elements in that overriding definitions are additive.
The property should also be useful in purely narrative documents like those using the xmlspec DTD; suppress-indentation="p" to suppress indentation below the paragraph level would be a significant improvement on the results currently obtained.
At its F2F meeting on 2009-02-23 through 2009-02-25, the WG resolved to adopt the suggestion recorded in the bug. As a result, I am marking this bug RESOLVED/FIXED. If you agree with this resolution, please mark the bug CLOSED.
Marked as closed.
Editor's draft of XSLT 2.1 has been updated accordingly.
Updated editor's draft of Serialization 1.1.