First Look Microsoft Office 2003

Although the XML support features that are new throughout Office add exciting new custom development possibilities for developers and IT professionals, the actual day-to-day work with XML has been designed with the everyday information worker in mind. Users in Word, Excel, and Access don't have to be familiar with XML to use the XML features; in fact, they don't have to know anything about XML at all. With a few simple procedures, users can attach XML schema, add XML tags in documents, or create an Excel grid and fill it with XML data simply and easily.

Word 2003 XML Features

Key XML features in Word 2003 focus on allowing users to view, work with, and save XML files easily. Users can create and attach their own custom schemas that can work alongside Word XML or be used alone. XSL transforms save the document in different forms for different views and are available whenever a Word file is opened or saved. Automatic validation makes sure the tags users enter are correct according to the attached schema, and the ability to query a database and import XML data to a Word document ensures that information is as current as possible in reports, proposals, and more. All these possibilities and others make working with XML in Word a simple but powerful feature for changing the way data is prepared, used, shared, and saved for the future.

From the Experts

Michael J. Young, author of Microsoft Office Professional Edition 2003 Inside Out and XML Step by Step (Microsoft Press) sees the capability of using custom XML schemas and working within the familiar interface to be Word's two strongest XML points. Now for the first time, for example, you can save your book data in an inventory database by using the familiar Word interface. It simply involves writing a new XML schema or attaching an existing one to a Word document and then using Word as a general- purpose document with XML. This means end users can work seamlessly in Word to capture valuable information as part of their familiar tasks.

The XML Task Pane

XML now has its own task pane in Word, first giving you the means to attach an XML schema (you actually do this by using the Templates and Add Ins dialog box, available through the Tools menu); then showing the tree structure of your XML document so that you can navigate easily through the document. By using the features in this task pane, you can easily add XML tags into your document while you work. (See Figure 5-1.) Word checks tags against the applied schema to make sure that the code is well formed.

Figure 5-1: The task pane displays the tree structure of the current XML document and enables you to click and add tags while you work.

Working in Tag View

One of the major enhancements in Word is the addition of XML tag view. When you open an XML document and begin to work, any tags you add (or tags that are already present) appear as a kind of graphical bracket around the word, phrase, paragraph, or entire document. Figure 5-2 shows a document in tag view.

Figure 5-2: Tag view enables you to see at a glance where the XML tags are in your document and how they are nested.

Tip 

You can turn tag view off and on by clicking the Show XML tags in the document check box in the task pane.

Attaching a Schema

Word now makes the process of adding a schema simple as well. Choose Tools, Templates And Add Ins, and click the XML Schema to see the various ways you can work with XML schema in your document. (See Figure 5-3, on the next page.)

Figure 5-3: You can select and add a schema to your current document in the XML Schema tab of the Templates and Add Ins dialog box.

Tip 

You can add more than one schema to a single document if you like. Word will apply both sets of definitions and rules and alert you if there is a conflict.

After you attach a schema and click OK, Word evaluates the incoming schema to see whether it's properly formed. If there are errors in the code, Word will alert you and stop the attachment until the code is corrected.

XML Open and Save Features

When you open an XML file in Word and choose XML files from the Files Of Type list in the Open dialog box, you also have the option of applying an XSL transform as you open the file. Display the context menu by clicking the small arrow to the right of the Open button to find the Open With Transform option.

Note 

An XSL transform allows you to display an XML document in different views; for example, perhaps you are opening a report file that you want to display on the Web. Applying a transform allows you to see the file in a Web-based format without making modifications to the file itself.

When you choose XML Document in the Save As type field of the Save As dialog box (see Figure 5-4), two XML-specific options appear to the left of the Save button. You can click the Apply Transform check box to enable the Transform button; then click that button to choose the transform you want to apply.

Figure 5-4: Word makes it easy to save the XML file in different formats.

Note 

Users can manually attach an XML Schema Definition (XSD) file or apply an Extensible Stylesheet Language Transformation (XSLT) to an existing XML file, but Word adds another convenience to simplify this process. Word remembers associated files and gives the user the option of attaching the appropriate XSD or XSLT when a file that matches a recognized category is opened.

Excel 2003 XML Features

Excel's XML features have been significantly expanded over the capabilities in Excel 2002. In that version, XML was first introduced through the application of the XML Spreadsheet Schema (XMLSS); but now users can apply their own schemas and use Excel to import, work with, and export XML data. In addition to this big enhancement, XML features in Excel provide the following:

The sections that follow take a closer look at the key XML features available in Excel 2003.

Figure 5-5 displays the XML Structure task pane available in Excel. When you first display the task pane, Excel asks whether you want to find a structured (XML) document, create a new one, or add structure to this document (which means adding a schema to your current data file). When you click Create New in the XML Structure task pane, Excel switches to XML design mode and prompts you to select a schema.

Figure 5-5: The XML Structure task pane in Excel enables you to map XML elements to your worksheet and customize the design.

Importing and Exporting XML Data

Importing an XML file is as simple as clicking the Import button on the XML toolbar. The XML toolbar is a new addition in Excel 2003, providing quick and easy access to import, export, and refresh actions.

When you click Import, the Import XML dialog box appears so that you can choose your file. Excel asks you to choose the range for the imported data and then places the information in list form in the range you specified. (See Figure 5-6.)

Figure 5-6: The imported XML data is placed in a data list in the specified range.

Excel prompts you if there's a problem with your imported data by displaying a small flag on problem cells. When you click the cell, an exclamation point icon appears. Click that icon, and a submenu appears, letting you know what the problem is and listing possible corrective actions. (See Figure 5-7.) This helps even new XML users understand how to save more accurate and usable data.

Figure 5-7: Excel lets you know if there's a problem with the imported data.

More Info 

The Lists feature gives you additional, easy-to-use tools for organizing, viewing, analyzing, and sharing data in your Excel worksheets. For more on Excel's List feature, see Chapter 8, 'Microsoft Office 2003 Productivity Enhancements.'

Exporting XML data in Excel is as simple as selecting the data you want to export, clicking the Export button in the XML toolbar, and choosing a folder and filename for the file. The file is exported in straight XML format, ready to be incorporated in other XML applications.

Mapping XML Data

The new visual mapping tool in Excel allows you to add XML elements to your workbooks by dragging and dropping them onto the current worksheet. Figure 5-8, shows the map that is created from a sample XML schema. The XML structure is shown in a tree-like form. You can use parts of the structure by dragging branches or individual items (or the entire list) to your worksheet.

Figure 5-8: The visual mapping tool enables you to create XML worksheets by dragging and dropping XML elements.

Tip 

You can add additional workbook maps to the current document by clicking the Workbook Maps button in the XML Structure task pane and clicking Add.

Access 2003 XML Features

The XML changes in Access include fewer end-user features than Excel and Word but expand the flexibility and functionality of Access. Now you can import an XML file (and information from SharePoint Team Services, which also comes in as XML) directly into your Access data tables. Additionally, you can export Access data as straight XML, giving you the means to produce data from a variety of formats in XML output.

From the Experts

Frank Rice, from the MSDN Office Developer Center (msdn.microsoft.com/office), thinks the biggest benefit in the XML support in Access 2003 is that it 'allows you to transform an XML form coming in and an XML form going out. If you've got an Adobe file and you're translating with an XSL that Access can recognize, when you save it out, you can use a transformer to transform it back. No data maps are needed. Access will take a straight XML file and produce a raw XML file as output. This means you can take a file in another application (such as Lotus Notes), and a good developer can come up with a transform file for it. So instead of the two formats being totally incompatible, we can take this file, run the XSL file to transform the data, and then read it into Access. You can do the same thing going out.'

Importing XML Data

There are a number of import options when you bring XML data into Access. A new Import XML dialog box includes an Options button you can click to display the various types of imports available. (See Figure 5-9.) These choices enable you to import only the structure of the XML file, import both structure and data, or append the XML data to an existing Access table.

Figure 5-9: The Import XML dialog box in Access enables you to choose whether to import the structure or both the structure and data, or simply append data to an existing table.

After you click OK, Access imports the data and displays a completion message. The new XML data is placed in a table in your current database. You can open and work with the table as normal.

Exporting XML Data

When you export a table as XML data in Access 2003, you've got a number of options to use to control the type of output produced. Begin the export by right-clicking the table in the Database window; then choose XML in the Files of type list. The Export XML dialog box enables you to choose whether you want to export data only, the schema only, or the presentation of the data.

If you want to further control the output, you can click More Options to display additional choices for the output of the XML, XSD, and XSL files.

Tip 

When you export forms and reports, Access generates the output file using an XML-based language called ReportML. When you generate tables, queries, and datasheets, the output resembles a spreadsheet.

Категории