The XML Options Dialog

The XML Options dialog shown in Figure 22-11 has three categories of options: XML save options, Schema validation options, and XML view options. These options are applied and saved at the document leveldifferent 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 it 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. For example, in our book order document, 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 will let you save invalid XMLyou typically 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 makes it so that the XML structure tree view does not display the namespace prefix before element names. For example, if the namespace is ns1 and the element is CustomerName, unchecking this option will result in Word displaying ns1:CustomerName in the tree view. Checking this option will result in Word 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 will typically not want to have the XML tags displayed because this is 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 the 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 out 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.


Part One. An Introduction to VSTO

An Introduction to Office Programming

Introduction to Office Solutions

Part Two. Office Programming in .NET

Programming Excel

Working with Excel Events

Working with Excel Objects

Programming Word

Working with Word Events

Working with Word Objects

Programming Outlook

Working with Outlook Events

Working with Outlook Objects

Introduction to InfoPath

Part Three. Office Programming in VSTO

The VSTO Programming Model

Using Windows Forms in VSTO

Working with Actions Pane

Working with Smart Tags in VSTO

VSTO Data Programming

Server Data Scenarios

.NET Code Security

Deployment

Part Four. Advanced Office Programming

Working with XML in Excel

Working with XML in Word

Developing COM Add-Ins for Word and Excel

Creating Outlook Add-Ins with VSTO



Visual Studio Tools for Office(c) Using C# with Excel, Word, Outlook, and InfoPath
Visual Studio Tools for Office(c) Using C# with Excel, Word, Outlook, and InfoPath
ISBN: 321334884
EAN: N/A
Year: N/A
Pages: 214

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