Troubleshooting XML Documents in Word [Word 2003 XML Reference] --  Microsoft Office Word 2003 XML Software Development Kit

Troubleshooting XML Documents in Word [Word 2003 XML Reference]

This topic lists some problems that users may encounter while working with XML documents in Microsoft® Office Word 2003, and the explanations for or solutions to those problems.

Problem: The XML Document task pane disappears and is not in the task pane list once I start to edit a document.

Resolution: Once you start to edit an XML document that has data views available in the XML Document task pane, you activate the data view that you selected. This process cannot be reversed, because a data view is an Extensible Stylesheet Language Transformation (XSLT) that processes data in the XML document at the time the XML document is opened for editing. Note also that after editing the document, the XSLT may not be valid. For this reason, be sure to select the data view you want to use before you start editing the document.

Note  The XML Document task pane also disappears if you switch to the Mail Merge task pane, because the data view is applied if you start a mail merge.

Problem: I tried inserting XML from another file into my document using the Include Text field as shown in Inserting XML Markup, but it didn't work.

Resolution: When an XPath is specified as a parameter in the Include Text field, Microsoft Word does not validate the syntax of the XPath expression that you type. If the XPath expression is incorrect, Word cannot locate the XML for insertion.

Important  The information set out in the rest of this topic is presented exclusively for the benefit and use of individuals and organizations outside the United States and its territories or whose products were distributed by Microsoft before January 2010, when Microsoft removed an implementation of particular functionality related to custom XML from Word. This information may not be read or used by individuals or organizations in the United States or its territories whose products were licensed by Microsoft after January 10, 2010; those products will not behave the same as products licensed before that date or licenses for use outside the United States.

Problem: Word doesn't open my XML file properly.

Resolution: Check the following:

  • The file must use proper XML syntax; that is, it must be well formed. If the XML file is not well formed, Word displays a message. In the message dialog box, click Details to read the XML error message. Then, open the file in a text or XML editor to correct the problem, and try to reopen the file in Word.

    If you're editing a file in Word and intend to save only the XML data (discarding the Word XML schema information), avoid saving the document when it is not well formed. For example, in the XML Structure task pane, check to make sure that you have just one root element defined for the document.

    Note  The XML Structure task pane displays errors where the XML structure does not follow the rules of the attached XML schema (validation errors), but the pane does not report syntax errors where the document is not well formed. To find XML syntax errors, open the file with a program that reads XML and reports errors, such as Microsoft Internet Explorer 5 or later.

  • If the file is in the WordprocessingML namespace, it must conform to the WordprocessingML schema. If it does not, then Office Word 2003 displays a message. In the message box, click Details to read the XML error message. Use this error message to correct the problem in a text or XML editor and then try opening the file again in Office Word 2003.

  • There must be XML tags in the document if you are saving data only. If you save an XML document that has no custom schema attached or that has no XML elements in the document, you must keep the Word XML schema (WordProcessingML) when you save the document. Otherwise, the document is not well formed, because it lacks a root element.

  • Word must be able to apply an XSL Transformation. If Word cannot use the Extensible Stylesheet Language Transformation (XSLT) that you specify, then Word attempts to apply any XSLT that is specified within the document. If none is specified, then Word attempts to apply its default transformation to open the document. If the default transformation doesn't work, Word alerts you to the problem. You can try specifying another XSLT file (.xslt), or you can open the file in a text editor.

Problem: When I saved my Word document as an XML file, I lost some data.

Resolution: If you apply an Extensible Stylesheet Language Transformation (XSLT) when you save your XML file, Word saves the result of the transformation, not the original XML file. If your original XML file contains data that is not included in the output of the transformation, then that data is discarded. To solve this problem, keep a separate copy of the XML file with no transformation applied, and when you apply a transformation, use Save As to create a new file.

Also, ensure that the Save data only checkbox is not checked unless you want to save only the custom XML content of the document. Checking this box tells Office Word 2003 to discard all of the document's Word formatting and layout information when it is saved.

Problem: The list of elements is hard to read.

Resolution: If the element names in the XML Structure task pane are long and include content similar to "{urn:," you can turn off the display of the namespace in element names. In the XML Structure task pane, click XML Options, and then select the Hide namespace alias in XML Structure task pane check box.

Problem: The elements inserted in a Office Word 2003 document don't all look the same. Some are different colors than others.

Resolution: When XML markup is inserted into a document, it is classified as either block-level or inline. How it is classified depends on the selection the tag is applied to. See Understanding Word's XML Markup for details on the differences between block-level and inline tags.

**Problem:**When I press Enter inside an XML element, the resulting paragraph marker is placed outside the tag's contents.

Resolution: When XML markup is inserted into a document, it is classified as either block-level or inline. Inline elements cannot contain paragraph markers, so the resulting paragraph marker is placed outside the tag. See Understanding Word's XML Markup for details on the differences between block-level and inline tags.

**Problem:**When I try to apply XML markup in a document the resulting tag is not located around the exact contents of my selection.

Resolution: When XML markup is inserted Office Word 2003 attempts to place it around the current selection. However, if applying XML markup to the selection would result in XML that is not well-formed, then Office Word 2003 snaps the selection to find the closest location where the XML markup would result in a well-formed XML document. For more information about snapping see Understanding Word's XML Markup.

©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