The XML Options Dialog Box


The XML Options dialog box, shown in Figure 22.11 earlier in this chapter, has three categories of options: XML Save Options, Schema Validation Options, and XML View Options. These options are applied and saved at the document level; different documents can have different sets of XML options. For XML Save Options, checking the Save Data Only option makes it so when you save the document as XML, Word will save the XML mapped into the document rather than saving the document in WordML format. The Apply Custom Transform option lets you specify an XSLT file to apply when you save the document. This feature is the inverse of the import XSLT file we considered earlier and is beyond the scope of this book.

The Schema Validation Options let you control the way Word validates the document against the attached schema. With Validate Document Against Attached Schemas checked, Word validates the XML data in the document against the attached schema. If Hide Schema Violations in This Document is not checked, Word displays squiggly lines under data that does not conform to the schema being used in the document. In our book-order document, for example, consider what happens if we type an invalid date for the date of the order. Word displays a squiggly line under the date. If you right-click the squiggly line, you get a schema-validation error, as shown in Figure 22.28.

Figure 22.28. A schema-validation error for an illegal date.


We have already considered the Ignore Mixed Content option and the necessity of turning this option on when you intermix formatting and labels with the XML that is mapped into the document. The Allow Saving As XML Even If Not Valid option will let you save invalid XML; typically, you should not check this option. Although Word will let you construct a document with multiple schemas attached that generate invalid XML, this prevents you from using features such as the XSLT feature and VSTO programming model features.

The XML View Options section has some additional options for how Excel displays XML information. The Hide Namespace Alias in XML Structure Task Pane option makes it so that the XML structure tree view does not display the namespace prefix before element names. If the namespace is ns1 and the element is CustomerName, for example, unchecking this option will result in Word's displaying ns1:CustomerName in the tree view. Checking this option will result in Word's displaying CustomerName.

Show Advanced XML Error Messages shows advanced schema-validation errors. This is useful during development of the document when you want to see the exact error message being returned by Word's XML validator. But these messages are not very friendly for end users, so you should be sure to turn this option off before you deploy your document. Figure 22.29 shows the error display for an illegal date when advanced XML error messages are turned on.

Figure 22.29. An advanced schema-validation error for an illegal date.


Show Placeholder Text for All Empty Elements is an option you will almost always want to turn on before you deploy your document to end users. In a deployed document, you typically will not want to have the XML tags displayed because they are busy and confusing to the user of your document. But when the data within an XML tag is empty, it is impossible for the user of your document to know where to enter data. If you turn on Show Placeholder Text for All Empty Elements, Word displays the name of the fields that need to be filled in so the user of the document can click the field name and type (see Figure 22.30). We have emptied all the data between tags, but the placeholder text makes it clear to the user of the document where to enter data.

Figure 22.30. A document with Show Placeholder Text for All Empty Elements turned on.





Visual Studio Tools for Office(c) Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
Visual Studio Tools for Office: Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
ISBN: 0321411757
EAN: 2147483647
Year: N/A
Pages: 221

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net