Whitespace handling for XML

Understand whitespace handling in Adobe FrameMaker and the whitespace normalization standard.

In this topic

Introduction

When you open an XML file in FrameMaker’s WYSIWYG View, the white spaces get normalized.

White space in XML is any character from the following set: space, tab and blank line/new line (except hard return). White space serves the following purposes:

  1. Visually format the document in its source form, such as for code, to denote semantic significance for the XML document.

  2. While using a text editor to edit XML, add spaces and line breaks into the element content model for better readability of the XML. This white space is not part of the information conveyed by the document and has no semantic significance for the XML application.

    Note: Default pretty printing is disabled in XML view for new and modified documents.

W3C has defined how white space in XML documents should White-space XML applications.

White-space normalization standard

FrameMaker uses the following rules for white space normalization according to the standard:

  1. XML ignores the first sequence of white space immediately after the opening tag and the last sequence of white space immediately before the closing tag.

  2. XML translates non-space characters (tab and new-line) into a space character and consolidates all multiple space characters into a single space.

  3. XML ignores the sequence of white space occurring between two elements if the parent element is defined to have element content.

  4. You can set the xml:space attribute of an element to preserve to retain the white spaces. For example, if we normalize the following (as appearing in the XML code view):

    Hickory[SPACE][SPACE][SPACE]dikory dock. 
    The mouse[TAB][SPACE]ran up the clock.

    It appears as (in WYSIWYG view):

    Hickory[SPACE]dikory dock. 
    The mouse[SPACE]ran up the clock.
  5. White space introduced through expansion of character references (for example Space =  Tab= 	 Newline=
) is preserved on XML open. It is not considered white space per the above rules.

    For example, if FrameMaker normalizes the following (as appearing in the XML code view):

    Hickory   dikory dock. 
    The mouse	 ran up the clock.

    After normalization, tt appears as the following (in WYSIWYG view):

    Hickory[SPACE][SPACE][SPACE]dikory dock. 
    The mouse[TAB][SPACE]ran up the clock.

Disable dropping whitespaces on import

To disable dropping whitespaces, set the property RemoveExtraWhiteSpacesOnXMLImport in maker.ini to FALSE.

Note: Use caution while editing an ini file.

Preserve whitespaces for specific elements

If the xml:space attribute is set to preserve (xml:space="preserve"), then FrameMaker preserves all whitespaces. You can use this setting to preserve whitespaces for certain elements alone. This setting lets FrameMaker drop whitespaces for all other elements in the WYSIWYG View.