RATING: Intermediate
PLATFORM: Windows & Mac
VERSION: Requires FileMaker 6
TECHNIQUE FILES: Contact Management.fp5
DOWNLOAD: < http://www.filemaker.com/products/try_filemaker.html >
Hidden within the nested FileMaker Examples > XML Examples > Export folders there contains the technical equivalent of a magic wand. Rest assured, this article is not about the wizardry of Harry Potter or Lord of the Rings. It's simply about the magic of XSLT and FileMaker Pro 6.
Since FileMaker Pro 6 introduced the ability to export records using tagged XML format while utilizing an XSL style sheet, the power you wield is data transformation. Presto! With just a mouse drag and two clicks, you have transformed boring, ugly, tagged XML data into a beautiful complex HTML table. (Professor McGonagall would be quite proud).
FileMaker, Inc. built upon the embedded Xerxes XML processor < http://xml.apache.org/ > of FileMaker Pro's predecessors by adding the ability to directly export XML content from your databases. But FileMaker, Inc. did not stop adding the features there! They bundled the Xalan XSL processor < http://xml.apache.org/ > to add unbridled power.
Upon export, you may select a locally existing XSL template or remote template via http protocol. FileMaker Pro 6 runs the exported XML through the XSL processor using the specified XSLT style sheets. The results will be as the style sheet specifies.
It's All Inside
FileMaker Pro 6 ships with everything you need to begin a basic introduction to Extensible Stylesheet Language Transformations (XSLT). Of course, you will need a copy of FileMaker Pro 6 before proceeding with this article. You can download a demo copy from:
< http://www.filemaker.com/products/try_filemaker.html >
First, locate the FileMaker Examples > XML Examples > Export folder within your FileMaker Pro 6 application folder. Inside of the Export folder is a document named, "complex_table.xsl". Make a copy of this document and save it on your Desktop (we will be able to easily access it here later in this article). Next, create a new database from the new Business template called "Contact Management.fp5". Begin data entry. Enter ten or so records of sample data that will then be used to illustrate the power of XSLT.
When you have completed all of the above, decompress the boxed_xslt.zip and boxed_xslt.sit files that are included with this article.
Creating Complex Tables
1. Select the Export Records... command from the File menu.
2. In the Save As box, name your file but remember it is good practice to stick to lowercase alphanumeric characters without spaces and utilize a file extension of.xml. I have chosen to name my file try_it.xml.
3. Choose the location where you would like to save the exported XML file. I recommend that you choose to save it on the Desktop so that you may easily find it in the next step.
4. Choose XML in the Type pop-up menu,
5. Click the Save button.
6. In the resulting Specify XML and XSL Options dialog, ensure that the Grammar pop-up menu has FMPXMLRESULT chosen.
Author's Note: Do NOT choose the FMPDSORESULT option. We will cover this feature in a future article. Choosing this option for this example will result in a non-HTML tagged document that Internet Explorer will not be able to display (you will receive an "Invalid at the top level of the document" error at "Line: 1", "Character: 1"). But, if you must try it out for yourself, go ahead.
7. Ensure that the Use XSL style sheet check box is checked and that the File radio button is selected.
8. In the resulting Open dialog box, choose the complex_table.xsl style sheet that you previously copied to the Desktop from the FileMaker Examples > XML Examples > Export folder.
9. Click the Open button.
10. Click the OK button.
11. Choose which fields you would like to exported to the XML file and have processed by the complex_table.xsl style sheet. I have chosen to export the following fields:
Last Name
First Name
Company
Title
Street 1
City 1
State Province 1
Postal Code 1
Notes
Phone 1
Date Created
Date Modified
Identification Number
12. Click the Export button.
In order to see the complex HTML table that you just created, open the *.xml file in Internet Explorer. Since I named my XML export file try_it.xml and the XSL processor has used complex_table.xsl to transform the data held within XML tags of this document into a beautiful HTML table, Internet Explorer should have absolutely no problem opening my document. Presto.
You now have a multi-colored table for your viewing pleasure.
Conclusion
I realize that some have resisted using XML since its introduction into FileMaker Pro in version 5. It was a weird tagged language that had little usage due to a lack of solid web browser support for the standard (and for cascading style sheets to make it look presentable). XML was largely used in the FileMaker world for server-to-server communications.
Those days are gone. Using XSLT, you may now literally transform exported XML data into any file format you choose. Following XSL processing, the result is a standard web server servable, web browser viewable run-of-the-mill HTML page. You just need to learn the scripting language.
This article has shielded you from the complexities of the XSLT syntax and XML for that matter. Next month will be different. We will begin our dive into XSLT.
Earlier in the article, I had you copy complex_table.xsl to your Desktop. Open it in your favorite text editor and see if you can begin to make heads or tails of it. Next month we will. Next month we will change the syntax to result in exactly what we want to see.
Big touted feature: XSLT. Complicated scripting language: XSLT. Salvation to data transformation: XSLT. No magic wand required.
Happy XSLTing!
Clint Roberts is happy muggle who has turned to the magical world of FileMaker to automate his life. He enjoys all four Harry Potter books and is eagerly awaiting the next installment. Email him at <clint@dbpublishing.com >.