Understanding XML Options [Word 2003 XML Reference] -- Microsoft Office Word 2003 XML Software Development Kit
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
To show or hide XML tags in a document use the keyboard shortcut CTRL+SHIFT+X or peform the following steps:
- Open the XML Structure task pane.
- 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.
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.
- On the Tools menu, click Templates and Add-Ins, and then click the XML Schema tab.
- Click XML Options.
- 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.
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.
- On the Tools menu, click Templates and Add-Ins.
- On the XML Schema tab, click XML Options.
- 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.
To display the XML Options dialog box:
- Open the Tools menu.
- Choose Templates & Addins.
- Select the XML Schema tab.
- Click XML Options.
Figure 1. The XML Options dialog box.
The XML Options dialog box contains the following options.
- 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.
- 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.
- Validate document against attached schemas, turned on by default. This options determines whether Word checks the validity of the document against all attached schemas.
- 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.
- 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:
- 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.
- 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.
- 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.
- 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.
Figure 2. XML options available in the XML Structure task pane.
The XML Structure task pane contains the following options.
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.
- 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.
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.
- Validate document against attached schemas, turned on by default. This options determines whether Word checks the validity of the document against the attached schema.
- 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.
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.
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:
©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