文書型 > XML Support > Using xml:space to Preserve White Space
  
Using xml:space to Preserve White Space
When creating XML documents, it can be convenient to use white space (meaning spaces, tabs, blank lines, and line breaks) to set apart the pieces of markup for greater readability. White space is typically not intended for inclusion in the published version of the document, but can be important to include when it communicates information such as hierarchy or dependence. The attribute xml:space may be attached to an element to specify that white space should be preserved for certain elements when editing, previewing, composing, and saving a document.
The xml:space attribute must be declared in a document's DTD. (The attribute does not need to be declared to be used in Free-form XML documents.) When declared, it must be declared as an enumerated type with a value of default or preserve. For example:
<!ATTLIST para xml:space (default|preserve) 'default'>
The value default signals that Arbortext Editor should use the FOSI quadding for this element. The value preserve signals that Arbortext Editor should preserve all the white space for this element. As XML is case sensitive, xml:space must be declared using all lowercase letters. The value of xml:space applies to the element and any elements it contains unless overridden by the xml:space value of the contained elements.
Elements can override xml:space declared (default) values by specifying different values in a document. If no value is explicitly specified in the document, the declared default value of xml:space will be used. For example:
<para>This paragraph uses the declared value of the attribute.</para>
<para xml:space="preserve">
This paragraph explicitly
recognizes white space.
</para>
If an element has no xml:space value explicitly specified, Arbortext Editor checks for any values specified in the element's ancestors. If Arbortext Editor finds no specified xml:space values there, Arbortext Editor uses the FOSI quadding for the element when composing.