| ||
Before we get started, you need to understand why you might want to use Office 2003 to generate XML content. Microsoft Office is one of the most popular software packages used by organizations. Most people have skills in working with at least Word and Excel, and many companies store a large portion of their information within Office documents.
XML makes it possible for Office 2003 to share information with other applications, including Flash. You can use Office to generate and update XML documents. You can use XML schemas and Extensible Stylesheet Language Transformations (XSLT) style sheets to change the way Office creates these documents. You can also use XML in external software packages to create and modify Word and Excel documents.
Documents serve two purposes within Office. First, they provide storage for data. This is particularly relevant for applications like Excel and Access. They also provide formatting information about the data they store. This is particularly important in packages like Word and Excel.
When you work with XML content, youre usually more interested in the data rather than its presentation. Youll normally add style and formatting to an XML document by transforming the content with an XSLT style sheet or by using Cascading Style Sheets (CSS). Flash can also provide a presentation layer for the data.
As developers, we often populate our dynamic Flash applications from XML documents. The actual content isnt importantwe are more concerned with the structure of the data so we can include it in the application. Using external XML documents allows us to update the content of applications without opening Flash. If were building applications for clients , we can either modify the XML documents ourselves each time the data changes or provide update mechanisms for our clients to use.
One option is to provide clients with an XML editor and teach them the tag structure of their XML documents. However, for many clients, the prospect of working with raw XML may be quite daunting. Its also very easy for them to make mistakes and generate documents that arent well formed .
Another approach is to create web forms that allow clients to update XML content using server-side files. Most clients are quite comfortable filling in web forms in a web browser. Its a good solution, but someone has to build the web forms, which means the client ends up paying extra. The forms also have to run through a web server, so this approach wont work as easily in stand-alone applications, for example, those running from CD-ROMs.
You can use Office 2003 to provide another solution to this problem by treating Office 2003 documents as a storage mechanism for XML content. Clients can use packages like Word and Excel to update XML documents. Providing you set up Office correctly, clients need to learn only a few additional skills. If the Flash application is running on a web server, you can also build a web form that allows a client to upload the new XML content to the website.
Ive used this approach successfully with a number of clients. Because theyre comfortable with Office 2003, its not too much of a stretch for them to work with data and generate XML content. You can find out more about one of my clients who uses this approach in Chapter 1.
If XML functionality is available in Word, Excel, and Access 2003, how do you decide which application you should use? In part, that depends on your clients skill levels, but its also important to understand the data structures supported by each package.
Within Microsoft Office 2003, both Word and Excel come with their own built-in XML vocabularies. Both packages can describe document structures and content using a set of predefined XML elements. Word 2003 uses WordprocessingML while Excel uses SpreadsheetML. Word and Excel can open XML documents written in WordprocessingML or SpreadsheetML as if they were .doc or .xls files.
You can find out more about these languages at www.microsoft.com/office/xml/default.mspx. You can also download the documentation for the XML schemas for Microsoft products from www.microsoft.com/downloads/details.aspx?FamilyId=FE118952-3547-420A-A412-00A2662442D9&displaylang=en. The schemas come with reference documentation in the form of a help file.
Access 2003 allows you to export existing data in XML format. Unlike the other Office applications, it doesnt have its own XML vocabulary. Other Microsoft applications have varying levels of XML support. PowerPoint 2003 and Outlook 2003 dont include XML features. Visio has had XML support since the release of the XP version. Visio 2003 uses the DataDiagramingML language and supports Scalable Vector Graphics (SVG), an XML-based standard for describing graphical elements. The Enterprise edition of Office 2003 includes an additional product, InfoPath, that works specifically with XML data. It uses forms to collect and manage information that the whole organization can share.
You can also use InfoPath, Word, Excel, and Access 2003 to consume SOAP-based web services. However, youd need to install the Web Services toolkit from Microsoft and write some VBA code to make this happen. Its a little beyond the scope of this book, but if youre interested you can download the toolkit from www.microsoft.com/downloads/ details.aspx?familyid=fa36018a-e1cf-48a3-9b35-169d819ecf18&displaylang=en. Theres an article covering Excel at http://msdn.microsoft.com/msdnmag/issues/05/02/ExcelWebServices/ default.aspx.
You dont have to use the built-in languages within Word and Excel 2003 in the XML documents that you generate. Instead, you can transform Office documents using XSLT style sheets and XML schemas. This allows you to extract the data from the document and ignore formatting information. In other words, you can create your own data structures for the XML documents. If you want to find out more about style sheets and schemas, refer back to Chapter 3.
You can structure data in many different ways. Some of it is list-based , and we often display this type of information in tables. Other data is relational in naturewe organize it according to the relationships between data items. The way the data is structured determines which Office 2003 application you should use to generate XML documents.
Word documents serve two purposesthey manage both style and content. We dont use Word to manage complicated tables of datathats often best left to Excel. Instead, were usually interested in template-style information, for example, a form letter or report. This gives you a clue about how best to use Word for generating XML documents.
Word 2003 doesnt generate repeating XML information particularly well, although there are some exceptions to this rule. Instead, you should treat Word as a template or form for generating XML content. You fill in the information and Word creates the XML document. This means that you should use Word for text-based Flash applications. An example of this is a latest news item display or a content management system, where the content is restricted to a fixed set of categories. Well work through an example application later in this chapter.
Excel, on the other hand, is most concerned with data and data analysis. We often use Excel to manage flat-file or list databases. Although formatting the data is important, it is a secondary consideration. The grid structure within Excel makes it easy for us to format and manipulate list-based data.
The Excel interface gives you a good idea about the type of XML structures that it will support. Excel works best with grid-based content, particularly data that you can describe in terms of rows and columns . Excel isnt suited for data that contains large quantities of textthats best left to Word. Later in the book, well see an example of using Excel 2003 to manage catalog data.
Access 2003 is a relational database so it works best with groups of data that are related . Although Access includes tools that deal with the layout of data, its primary concern is with content. In Chapter 7, well look at how you can search an existing database using Access and Flash.
In the rest of this chapter, Ill focus on Word 2003. Youll learn how to set up a Word document that generates XML content for use in Flash. Well work through several examples to illustrate how Word treats XML data. Well also work through a complete Flash application so that you can see the workflow from Word to Flash.