Word provides you with several options to control how it will save, validate, and display XML. These options can be set using the XML Options dialog. To access the XML Options dialog, click the XML Options button on the XML Schema tab in the Templates and Add-Ins dialog (see Figure 25.4).
The XML Options dialog is shown in Figure 25.6.
Using the XML Options dialog, you can control these settings:
Save Data Only: When this option is checked, Word will save only the data in the file that corresponds with the attached schema. No document properties, settings, and so on are included with the saved file. When this option is cleared, Word will save the file in XML format using the WordML schema so that all properties, settings, formatting, and so on are preserved.
Apply Custom Transform: When this option is checked, Word will apply the selected XSLT transformation to the file when it is saved. You can enter the full path for the XSLT file in the Custom transform text box or you can click on the Browse button and navigate to it.
If you save a file using an XSLT transformation, Word saves only the result of the transformation. See "What to Do If You Lose Data after Saving Your XML File," in the Troubleshooting section at the end of this chapter.
Validate Document Against Attached Schemas: When this option is checked, Word will dynamically validate the XML using any attached schemas and display violations using various icons in the XML Structure task pane (see the section "Using the XML Structure Task Pane," later in this chapter).
This option does not affect Word's validation of the schema when saving an XML File. See the option Allow Saving as XML Even If Not Valid in the following text.
Hide Schema Violations in This Document: When this option is checked, Word will not display the wavy lines in the document that identify schema violations.
Ignore Mixed Content: When this option is checked, Word will create valid XML documents without concern for any text formatting that may be inserted into the elements of the template. This is useful when saving document templates (.dot files) from which users will be entering data into an XML structure.
Allow Saving as XML Even If Not Valid: When this option is checked, Word will allow an XML file to be saved when the content cannot be validated against the attached schema(s). This is useful when you're filling in more complex XML structures and you want to save your interim changes without completing all the data. When this option is not checked, Word will present the dialog shown in Figure 25.7 if you attempt to save an XML file that has schema violations.
Hide Namespace Alias in XML Structure Task Pane: When this option is checked, Word will display only the element names from the attached schemas in the XML Structure task pane (see the section "Using the XML Structure Task Pane," later in this chapter). When this option is not checked, Word will append the namespace alias (or the full namespace if no alias is specified; see "What to Do If the List of Elements Is Hard to Read," in the Troubleshooting section at the end of the chapter) to the end of each element name. This is very useful if you have attached more than one schema to your XML file. Figure 25.8 shows an XML schema with the namespace alias displayed.
Show Advanced XML Error Messages: When this option is checked, Word will display very detailed messages when schema violations are detected. When the option is not checked, Word will display a shorter summary of the problem. The advanced error messages are very valuable when debugging schema problems, but they can be confusing to general users if shown all the time. Figure 25.9 shows an example of an advanced message. Figure 25.10 shows the same error with this option turned off.
Show Placeholder Text for All Empty Elements: When this option is checked, Word will display a placeholder for all empty elements when display of the XML tags has been turned off (see the next section, "Using the XML Structure Task Pane"). This is a useful option when creating "fill in the blank" templates for users that you want to be entered based on a defined schema. The user can see what is expected to be filled in without having to deal with the distraction of seeing the XML tags in the document.