Once you perform a manual export of XML from FileMaker Pro, you can set up a script to perform the export. You must preselect the fields with the manual export, or allow the user to select fields by unchecking the Perform without dialog option for the Export Records script step. Remember that the found set and sort order is used in the XML export. You may include a find and sort in your script or use a manual find and sort with the export script. The scripted export is similar to the manual export.
Using the Export.FP5 sample file, manually export one record with all the fields. Create a script called ExportPlain. Choose the script step Export Records and check the Restore export order and Perform without dialog options for this script step. Next, click the Specify File button and you will be presented with an Export Records to File dialog to specify the file name and file type and to navigate to the location for saving the file. Call the file ExportPlain.xml and select the XML type. Click Save and you will get the Specify XML and XSL Options dialog as shown in Figure 2.1.
Choose the FMPXMLRESULT grammar and ignore the stylesheet selection for now. When you click the OK button, your export script will be saved with the last manual export field order. The script step will look like this in the Script Definition dialog:
Export Records [Restore, No dialog, "ExportPlain.xml", "FMPXMLRESULT"]
If you print the script, you may see the fields used in the export, as in Listing 2.11.
ExportPlain Export Records [ Filename: "ExportPlain.xml"; Grammar: "FMPXMLRESULT"; Export Order: First Name (Text), Last Name (Text), City (Text), State (Text), Text (Text), Number (Number), Date (Date), Time (Time), Calculation (Calculation), Summary (Summary), gText (Text), gNumber (Number), gDate (Date), gTime (Time) ] [ Restore export order, No dialog ]
If you create the script and change the fields to export or forgot the manual export before creating the script, you may save the changes by editing the ExportPlain script and choosing Replace by the Export Order radio button in the dialog. If you have made no manual changes prior to editing the script, you will not get the dialog. If you do not wish to change the Export Order, leave Keep selected and close the dialog by clicking the OK button.
You may choose a stylesheet to be used when you export these records as XML at a later date. You may perform the manual export, create the script, and add or change the stylesheet options. Remember to check Replace to assure that the new stylesheet information is saved with the script. More information about using stylesheets with exports is covered in Chapter 7. There, you will set up a scripted export with an XSL stylesheet.
Before we move on to importing XML with FileMaker Pro, you may want to take a look at an application that can help create an XSL stylesheet to transform your XML export into an RTF (Rich Text Format) document. Chaparral Software & Consulting Services Inc., of Calabasas, California, has created EZxslt. This method is similar to creating a mail merge formatted document.
You make a document in Microsoft Word and select locations where you want your data to be inserted. You may use the field names in your database for easier matches when you export the data. Once you highlight the field names, save your document as a template using the RTF option. Open your template with EZxslt and it will create your XSL stylesheet for use with the template you just created. There are two options to create the stylesheet. You may specify the record separator, such as two blank lines (the default), one space, a page break, or no separator. Depending upon your record separator, this method may produce a new page for each record. You may also choose the character encoding of the stylesheet.
The newly created stylesheet will list all of your fields and the export order so that they will match the stylesheet. Create a scripted export and arrange the fields in the correct order. You can then specify the stylesheet to produce your RTF document with all of your data inserted. You can read more about EZxslt at http://www.ezxslt.com.
You can find detailed information about the FileMaker Pro plug-in FileBooks Link at http://www.filebookslink.com/. A fully functional trial version comes with sample files and documentation. FileBooks Link provides two-way data exchange between FileMaker Pro and QuickBooks and works with FileMaker Pro 4.0 through 6.0 and QuickBooks 2002 to 2003 editions.
QuickBooks is the most popular small business accounting and bookkeeping application. The current version for Windows OS uses qbXML for real-time data exchange. Information about the QuickBooks application can be found on the Intuit web site at http://quickbooks.intuit.com/.