Understanding XML Options [Word 2003 XML Reference] --  Microsoft Office Word 2003 XML Software Development Kit

Understanding XML Options [Word 2003 XML Reference]

Configuring Important XML Options in Microsoft Office Word 2003

All of the following XML options are document level options except for XML Print Options, which is an application level option and therefore applies to all documents

Show or hide XML tags

To show or hide XML tags in a document use the keyboard shortcut CTRL+SHIFT+X or peform the following steps:

  1. Open the XML Structure task pane.

  2. Check or clear the Show XML tags in the document check box in the task pane.

    Note  This check box is not visible if a schema is not attached to the document.

Display default placeholder text for empty elements

If your document contains empty Extensible Markup Language (XML) elements, you can view these empty elements by name in the body of the document, even when the Show XML tags in the document option is off. The placeholder text for each element defaults to its name.

  1. On the Tools menu, click Templates and Add-Ins, and then click the XML Schema tab.
  2. Click XML Options.
  3. In the XML view options section, select the Show placeholder text for all empty elements check box.

Tip You can specify your own placeholder text for elements by right-clicking a tag, clicking Attributes, and typing text in the Placeholder text box.

Set default save options when saving as an XML files

You can configure default options for saving Extensible Markup Language (XML) files. These defaults apply to the active document only. When you open another XML document, you must reconfigure these defaults.

  1. On the Tools menu, click Templates and Add-Ins.
  2. On the XML Schema tab, click XML Options.
  3. Do one or both of the following:
    • To discard formatting in Microsoft© Office Word 2003 and save only XML data, select the Save data only check box.

    • To use an Extensible Stylesheet Language Transformation (XSLT) file to format the document, select the Apply custom transform check box, and then click Browse to locate the XSLT file.

      Caution  If you apply an XSLT when you save the XML file, Word discards any data that the transformation does not use.

XML Options Dialog Box

To display the XML Options dialog box:

  1. Open the Tools menu.
  2. Choose Templates & Addins.
  3. Select the XML Schema tab.
  4. Click XML Options.

Figure 1. The XML Options dialog box.

The XML Options dialog box contains the following options.

XML save options section

  1. Save data only, turned off by default. This option determines whether Word saves only XML tags from the attached schema and their contents, or whether it also saves Word-specific tags, properties, and formatting and layout information.
  2. Apply custom transform, turned off by default. This option determines whether Word applies a non-default XSLT stylesheet when saving the XML document. The saved file contains only the results of the XSLT transformation.

Schema validation options section

  1. Validate document against attached schemas, turned on by default. This options determines whether Word checks the validity of the document against all attached schemas.

  2. Hide schema violations in this document, turned off by default. This option determines whether Word displays schema violation errors to the user in the main Word document window through the use of a wavy purple line.

  3. Ignore mixed content, turned off by default. This option determines whether text nodes not contained within a leaf element (an element that contains no other elements) from the schema are ignored or displayed as schema validation errors in the XML Structure task pane. When you surround only portions of a document with child element tags, leaving other text both within the parent element and outside any leaf element tags, Word invisibly tags these untagged text portions as text nodes to maintain the well-formed character of the XML and displays them in the XML Structure task pane, treating them as part of the custom document. The presence of these nodes may be considered violations of the attached schema. Enabling the Ignore mixed content option causes Word to treat text nodes not within element tags as not part of the custom XML content so that the schema violation error messages pertaining to them disappear from the task pane; that is, Word ignores these nodes.

    For example, if the following custom XML is in Word:

    Word treats the text "hello" as mixed content because it is not part of a leaf XML element. The text is included in the custom XML and is denoted in the XML Structure task pane as three dots between the spec and the specHeader elements:

    Clearing the Ignore mixed content check box tells Word to ignore all text that is not within a leaf node when building the custom XML tree. When Ignore mixed content is off the text "hello" does not appear in the resulting XML tree or in the XML Structure task pane:

  4. Allow saving as XML even if not valid, turned off by default. This option determines whether Word allows the user to save a document as XML containing XML markup that violates the rules of the attached schema.

XML view options section

  1. Hide namespace alias in XML Structure task pane, turned off by default. This option determines whether Word displays the namespace alias on element names. Enabling this option may make the display of the XML element hierarchy in the task pane easier to read.
  2. Show advanced XML error messages, turned on by default. This option determines whether Word displays the detailed error messages returned by the XML parser, or simplified but less informative error messages.
  3. Show placeholder text for all empty elements, turned off by default. This option determines whether Word displays placeholder text in the document that alerts the user to the presence of empty XML elements.

XML Structure Task Pane Options

Figure 2. XML options available in the XML Structure task pane.

The XML Structure task pane contains the following options.

  1. Show XML tags in the document. This options determines whether Word displays XML tags in the body of the document, surrounding the content they contain.

    Note  This does not affect whether the XML tags are printed with the document. For more information on how to print XML tags see XML Print Options.

  2. List only child elements of current elements, turned on by default. This option determines whether the Choose an element to apply to your current selection list displays only elements that are valid at the current location in the XML document.

XML Schema Validation Options

Figure 3. XML schema validation options.

The XML Schema tab of the Templates and Add-ins dialog box in Word contains the following options. These options also appear in the XML Options dialog box.

  1. Validate document against attached schemas, turned on by default. This options determines whether Word checks the validity of the document against the attached schema.
  2. Allow saving as XML even if not valid, turned off by default. This option determines whether Word allows the user to save a document containing XML content that violates the rules of the attached schema.

XML Print Options

Figure 4. XML print options.

The Print tab of the Word Options dialog box contains the XML tags option, which is turned off by default, in the Include with document section. This option determines whether XML tags appear in printed output along with their contents.

More Information

For additional information and examples that describe or demonstrate the end-to-end process of working with XML documents in Word, see the following articles:

Editing XML Data with Microsoft Office Word 2003 and Microsoft Office Excel 2003

Creating and Applying an XML Resume Template in Microsoft Office Word 2003

Microsoft Office Word 2003 XML: Memo Styles Sample

XML and Microsoft Office Word 2003: Writing a Trip Report

©2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp