Top Banner
FileMaker XML Technology Overview - March 2000 - by Elliotte Rusty Harold
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XML Overview

FileMaker XMLTechnology Overview

- March 2000 -

by

Elliotte Rusty Harold

FILEMAKER TECHNOLOGY OVERVIEW

TABLE OF CONTENTS

XML AND FILEMAKER 5mdashA TECHNOLOGY OVERVIEWEXECUTIVE SUMMARY 3

Performance 3

More Customizable 3

Data Exchange Standard 3

Publishing FileMaker Pro Data on the Web 4

WHAT IS XML 4

WHY USE XML 5

OTHER WEB SOLUTIONS 6

Export as HTML 6

Instant Web Publishing 6

Custom Web Publishing with Proprietary Tags 7

Other Web APIs 7

The XML Advantage 7

HOW DOES FILEMAKER PRO SUPPORT XML 8

REQUESTING XML DATA FROM FILEMAKER PRO 9

CHOOSING A FILEMAKER PRO XML GRAMMAR 11

FMPDSORESULT a database table-specific grammar 11

FMPXMLRESULT a database table-independent grammar 11

FMPXMLLAYOUT a grammar for layouts 12

FORMATTING XML DOCUMENTS 12

Formatting XML using CSS 13

Formatting XML using XSL 14

Scripting and the Document Object Model (JavaScriptVBScript) 15

Tools to help format XML documents 17

DEPLOYING A FILEMAKER PRO XML SOLUTION 18

FURTHER READING 19

GLOSSARY 20

2

EXECUTIVE SUMMARYXML the Extensible Markup Language is perhaps the mostheavily hyped technology since Java Its been touted as thesolution for a multitude of problems in fields as diverse asweb page designdatabase developmentnewspaper syndicationmortgage brokering and muskrat trapping But just maybeXML really does live up to the hype (Well maybe not in muskrat trapping but the other four are real examples)

FileMaker Inc is moving to support XML throughout itsaward-winning software product line We believe it isextremely important that third-party independent developersgain a working knowledge of how XML technology can be leveraged for FileMaker Pro users

As youll see XML is an extremely convenient format fordynamically accessing FileMaker Pro data from the web orother databases and clientsWith XML the data becomes farmore usable and closer to its native format than it would be ifit were first flattened into HTML And by applying a simplestyle sheet or JavaScript you can make the data look andbehave however you like In addition XML lets FileMaker Prosend the information to the user more quickly and with less load on the web server

This Technology Overview shows you how to take advantageof XML to serve data-centric web pages from FileMaker Pro5 or FileMaker Pro 5 Unlimited with a particular focus onhow XML surpasses prior technologies for embedding datain web pagesTo that end its assumed youve worked withFileMaker Pro before though not necessarily version 5 thatyoure familiar with HTML and that youve got some expe-rience publishing web pages and sites However no prior knowledge of XML is assumed

THE ADVANTAGES OF XML FOR FILEMAKER PRO WEBSERVERSXML offers many advantages to the FileMaker Pro developerwho is serving data over the Web Perhaps the single mostimportant is raw speed XML makes a very lightweight enve-lope to hold data so its fast to read and fast to write Manypopular web sites are really just HTML views onto aFileMaker Pro databaseThese range from large sites like theFileMaker web store to relatively small operationsThese sitesand many others like them use FileMaker Prorsquos built-in CGIor additional middleware products to connect their webpages to the underlying FileMaker Pro databaseHowever thisrequires the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker database then insertingthe results back into the HTML before sending it to the clientThen if the client wants something changed for instance hav-ing the results sorted by date instead of price the entire

process has to be repeatedThis is an inefficient use of limit-ed server resources Serving data in XML allocates serverresources much more efficiently The server that uses XMLperforms faster is more customizable and can more easily exchange data with other databases

HIGHER PERFORMANCEServing data encoded in XML is faster because it letsFileMaker Pro do what databases are designed to do storesearch and sort data By using a web browser to format theXML andor transform it into HTML yoursquore freeing upFileMaker Pro to accept more requests When using XMLFileMaker Pro only sends data to the browserThe client thenmassages that data into a reasonable display and presents itto the user More of the work is shifted to the client whichlets FileMaker Pro service a lot more requests in less timeusing the same network bandwidthAnd since what the clientgets is more neatly organized as data than a typical HTMLpage the client can treat it as data It can use JavaScript tosort or search the result set FileMaker Pro sent in real timeChanging the display to sort by date instead of last name forexampledoesnrsquot have to require a new request to the data-base server and accompanying expensive round trip

MORE CUSTOMIZABLEThe most common way to integrate XML with FileMakerPro is through forms and style sheets The web browsershows the user a standard HTML formThe user fills outand submits the form FileMaker Pro receives the form dataand sends a response in XML that includes the data andthe details about where a style sheet for the data can befoundAt this point the servers job is done and its readyto process the next request from some other client Thebrowser then retrieves a style sheet that tells it how toformat the data for display to the userThe server can alsosend the browser a JavaScript program telling the browserhow to make the data dynamic so the user can sort orsearch it in real time Supplying a different style sheet orJavaScript program shows the user a different view of thedata And all of this can be done without bothering theserver again with more requests One request toFileMaker Pro gives the browser all the information the user needs

DATA EXCHANGE STANDARDXML isnt just for the Web either It has other uses too Itsan ideal format for sharing and exchanging data with thirdparties Your data may be in a FileMaker Pro database butyour customers or suppliers might use other databasesYoucan move data from one system to the other by generatingXML using XSL to transform into an agreed standard XMLformat and then importing the data into the new database or

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3

system as Figure 1 diagramsThis format can be documentedusing a document type definition (DTD) or in the future aneven more precise schema Most importantly particular XMLdocuments can be easily compared against DTDs orschemas to determine whether they adhere to the agreed-onformatYou get to validate the data your customers and sup-pliers are sending you before you store it in your databaseThis is key for the expanding busi-ness-to-business market segment

PUBLISHING FILEMAKER PRO

DATA ON THE WEBFileMaker Pro 5 includes a plug-inweb server called the FileMakerWeb Companion The FileMakerWeb Companion can serve staticHTML files and JPEG images justlike a traditional web server likeApache However its real advan-tage is that it can serve HTML andXML straight out of a FileMakerPro database The data does nothave to be exported and stored instatic HTML files firstThis meansthat the browser always gets themost current up-to-the-minuteinformation from the database

Since the FileMaker Web Companion is a web server it needsto run on a machine thats connected to the Internet at astatic domain name and IP addressThis machine must havethe database(s) users are browsing openThe FileMaker WebCompanion can handle the various web services themachine provides or it can run in conjunction with atraditional web server like Apache If so the two servers willsimply run on different ports Generally requests for staticHTML files will be directed to the traditional web serverwhilerequests for dynamic data in XML format will be steered to the FileMaker Web Companion

Client browsers like Netscape Mozilla and Internet Explorerconnect to a web server running FileMaker Pro just like theyconnect to any other web server Clients dont need anybrowser plug-ins or special software The user can interactwith the FileMaker Pro database using standard technologieslike HTML forms JavaScript and of course XML The mostcommon way a user queries a FileMaker Pro database is byfilling out a form in their browser submitting it and receivingthe results back as XMLFileMaker can also send a CSS or XSLstyle sheet or a JavaScript or VBScript program with theresults to tell the browsers how best to format the data for display to the end user

WHICH FILEMAKER PRODUCT IS RIGHT FOR YOUFileMaker Pro software is available in several different varietiesfor different customers with different needs All FileMaker Proproducts support XML and can publish XML data on the Web

FileMaker Pro 5 is the entry level product designed for sin-gle-user databases and small web sites It includes the

FileMaker Web Companion but islimited to connections from nomore than 10 unique IP addresses in any twelve hour period

FileMaker Developer 5 includesFileMaker Pro 5 along with a vari-ety of tools useful to professionaldatabase developers such asODBC and JDBC driversenhanced layout design tools XMLexamples and documentation andthe ability to build and distributestand-alone runtime copies of adatabase FileMaker Developer 5also includes the FileMaker WebCompanion and is limited toconnections from no more than10 unique IP addresses in any twelve hour period

For medium-to-high volume web sitesyoull probably want tomove up to FileMaker Pro 5 UnlimitedThis offers all thefeatures of FileMaker Pro 5 including the FileMaker WebCompanion and full XML supportAdditionally it removes the10 IP address in twelve hour restriction and offers scalableload balancing and fault tolerance by using a Redundant Arrayof Inexpensive Computers (RAIC)each running its own copy of FileMaker Pro 5 Unlimited

WHAT IS XMLThe Extensible Markup Language XML for short is aW3C-endorsed standard for structured markup of docu-ments and data XML defines a syntax for a hierarchicallystructured text document divided into elements Elementsare delimited by start and end tagsThese tags look super-ficially like HTML tags that is they begin with a lt and endwith a gtAttributes are provided in name=value pairs inthe start tag of an element Closing tags begin with a ltand so forth However unlike HTML XML elements arenot limited to a fixed set of tag namesYou can define tagslike ltbookgt ltpersongt ltskugt ltID_Numbergt ltintegergtltDATAgt ltROWgt ltERRORCODEgt and more Forexample in HTML a listing for a book might look like this

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

FileMaker Pro generates XML

XSL processor transforms data intoagreed format

XML parser validates data

Database imports data

Figure 1Exchanging databetween databasesusing XML

4

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltimg src=0140012133gif width=87 height=140 align=leftgtltdtgtThree Men in a BoatltddgtJerome K Jeromeltulgtltligt0140012133ltligt$695ltligt131998ltulgt

Theres a lot missing from this listing For instance is this abook or a video What is the rather mysterious number0140012133 Is $695 a sale price a rental fee the shippingcost or something else The last item looks suspiciously like adate but is that date January 3 1998 or March 1 1998 Andwhat happened on that date All of this information should beeasily ascertainable from the database but its not so obviousfrom the HTMLHowever in XML the same listing would look something like this

ltbook isbn=0140012133gtlttitlegtThree Men in a BoatlttitlegtltauthorgtJerome K Jeromeltauthorgtltcover source=0140012133gif width=87 height=140gtltcovergtltpricegt$695ltpricegtltpublication_dategt

ltmonthgt1ltmonthgtltdaygt3ltdaygtltyeargt1998ltyeargt

ltpublication_dategtltbookgt

There are several points to consider in this example

bull The tag names tell you whats inside the tagXML retainsnot only the databut can also reveal the meta-data aboutwhat the data is If youre mapping documents to data-bases XML retains not only the field values but in some cases the field names as well

bull This XML sample says absolutely nothing about how thebook record is to be displayed to the reader It says thatthere is a book with the title Three Men in a Boat and theauthor Jerome K Jeromebut it doesnt say that the titleshould be 14-point Helvetica bold It says that the price is$695but it doesnt say that $695 should be a bullet pointin a listXML tags add structure and semantics to the datain a documentHowever they say nothing about how that data is formatted Formatting is applied later via a stylesheet Different style sheets can change the presentationof the data without affecting the underlying document

bull This document is well-formedThat means that it adheres to several rules First all tags that are opened ar even-tually closedThere are no opening ltbookgt or ltyeargt orltisbngt tags without corresponding closing ltbookgtltyeargt and ltisbngt tags Furthermore the elementsdont overlapThe ltmonthgt tag can be contained in the

year element but then there must also be a correspond-ing closing ltmonthgt tag in the year element as wellWhen you use FileMaker Pro to generate HTML well-formedness comes for free That is all the XML FileMaker Pro serves is well-formed without any extra effort on your part so you dont have to spend a lot of effort wor-rying about the detailed rules of well-formedness

Applications that read XML documents are required to reject malformed documentsThey are not allowedto try to fix the mistake and go onThis makes it mucheasier to write software that processes XML and to exchange XML documents between FileMaker Pro and other software It helps avoid the browser com-patibility wars that plagued HTML from its early days

The set of possible documents with a given group of ele-ments is sometimes called an XML vocabulary or XMLgrammar However the technical term is XML applicationThis is not an application like FileMaker Pro or InternetExplorer that uses XML but rather an application of XMLto a particular domain like book inventories or chemistryYou can go beyond simple well-formedness by document-ing your XML application with a document type definition(DTD) and requiring that documents be valid according tothe DTD The DTD very formally describes which ele-ments are allowed in what contexts The DTD can beembedded in the XML document or stored in a separatefile whichever is more convenientWhen a validating pars-er reads an XML document it not only checks to see thatthe document is well-formed It also checks to see thatevery element in the document matches the declarationfor that element in the documents DTD By providing aDTD you add rules that are specific to your documenttype These are in addition to the well-formedness rulesthat must be adhered to by all XML documents Howevera DTD is optional If it isnrsquot useful to you you dont need to use one

WHY USE XMLXML offers many advantages to the FileMaker Pro devel-oper who needs to send data to or receive data from nonFileMaker Pro clients Firstly there has been an explosionof third party tools on many platforms in many languagesfor parsing displaying editing exchanging and validatingXML documents These tools run the gamut from publicdomain to open source to fully supported payware fromC to Java to Perl from Macintosh to Unix to WindowsChances are whatever youre doing with XML part of thework has already been done for you and can be easily incorporated in your project at low cost and little effort

5

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Even more importantly XML is much faster than propri-etary solutions Web sites that use CDML Java ServerPages (JSP) or other middleware products to connecttheir web pages to a backend FileMaker Pro databaserequire the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker Pro database theninserting the results back into the HTML before sending itto the client If the client wants anything changed no mat-ter how small it has to go back to the server which has torepeat the entire processThis is an extremely wasteful use of finite server resources

XML works better because all the server has to do is sendsome simple query results to the clientThe browser doesall the tricky formatting and manipulation of the data Forsmaller data sets it can even be more efficient to move allthe data to the client as XML then use Java or JavaScript toperform all the manipulations on the client side Searchesand sorts can be performed against the local XML view ofthe data rather than requiring a round trip to the serverAnother possibility is to show the user only part of the datatheir query returned (say ten records out of a hundred) butgive them a link or button to select the next ten recordsAslong as the data can be stored and manipulated on theclient the number of queries and consequently the load on the server are reduced

OTHER WEB SOLUTIONSXML is not the only way to combine FileMaker Pro data-bases with web sites but it is one of the best To moreclearly see XMLs advantages lets first look at some of theother approaches that have been taken over the last few years and the problems theyve had

EXPORT AS HTMLThe first and most obvious approach is to simply exportthe data to HTMLThis can be done by exporting a data-base as an HTML table or for more precise formattingwith calculation fields and a little AppleScript or Perl (Thisapproach works equally well for exporting data to an XMLvocabulary other than one of the three FileMaker Pronatively supports) This approach also allows you to servedata from any computer with a web server including Unixand Linux systems that cant run FileMaker ProAs already notedyou tend to lose a lot of the datas structurewhen moving to pure HTML But the biggest problem withthis approach is that the web site is not automaticallyupdated when the database changes Sometimes thats OKif you just want to present a static picture of the data tothe user but it doesnt work so well if the data changes ona frequent basis For instance it wouldnt be adequate for

an e-commerce site that needed to let customers knowwhether a product was in stock right this minuteFurthermore it doesnt allow users to interact with thedata on either the client or server side such as searchingfor all the books by a particular authorThey canrsquot chooseto sort by price or add items to or remove items from ashopping cartThis approach is only suitable for very staticslowly changing sites

INSTANT WEB PUBLISHING

Another approach first introduced in FileMaker Pro 4 is topublish the database itself on the Web using Instant WebPublishingThis shows users a dynamic view of the data asit exists at the moment they load the page Users can restassured that any page they see has the most current andup-to-date data even if records are being added to or editedin the database at the same time theyre browsing andsearching it From their web browsers users can even seeand interact with the same layouts theyd use if they wereconnected with a FileMaker Pro client making sortingsearching and editing records in the database very easyAnd all of this can be accomplished without having to write any programs scripts or style sheetsOne of the biggest advantages of Instant Web Publishing is that it does an excellent job of simulating the look and feelof a FileMaker Pro layout Figure 2 shows the same recorddisplayed in Internet Explorer through Instant WebPublishing in the front window and in the actual FileMaker

Pro database in the back windowThe fidelity of the HTML page to the original FileMaker Pro layout is amazingHowever Instant Web Publishing offers limited customizationYou can use layout themes to modify color schemes butyou cant rearrange items on the pageTo change the way

Figure 2 A record in a FileMaker Pro database served via the FileMaker Web Companion

6

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 2: XML Overview

FILEMAKER TECHNOLOGY OVERVIEW

TABLE OF CONTENTS

XML AND FILEMAKER 5mdashA TECHNOLOGY OVERVIEWEXECUTIVE SUMMARY 3

Performance 3

More Customizable 3

Data Exchange Standard 3

Publishing FileMaker Pro Data on the Web 4

WHAT IS XML 4

WHY USE XML 5

OTHER WEB SOLUTIONS 6

Export as HTML 6

Instant Web Publishing 6

Custom Web Publishing with Proprietary Tags 7

Other Web APIs 7

The XML Advantage 7

HOW DOES FILEMAKER PRO SUPPORT XML 8

REQUESTING XML DATA FROM FILEMAKER PRO 9

CHOOSING A FILEMAKER PRO XML GRAMMAR 11

FMPDSORESULT a database table-specific grammar 11

FMPXMLRESULT a database table-independent grammar 11

FMPXMLLAYOUT a grammar for layouts 12

FORMATTING XML DOCUMENTS 12

Formatting XML using CSS 13

Formatting XML using XSL 14

Scripting and the Document Object Model (JavaScriptVBScript) 15

Tools to help format XML documents 17

DEPLOYING A FILEMAKER PRO XML SOLUTION 18

FURTHER READING 19

GLOSSARY 20

2

EXECUTIVE SUMMARYXML the Extensible Markup Language is perhaps the mostheavily hyped technology since Java Its been touted as thesolution for a multitude of problems in fields as diverse asweb page designdatabase developmentnewspaper syndicationmortgage brokering and muskrat trapping But just maybeXML really does live up to the hype (Well maybe not in muskrat trapping but the other four are real examples)

FileMaker Inc is moving to support XML throughout itsaward-winning software product line We believe it isextremely important that third-party independent developersgain a working knowledge of how XML technology can be leveraged for FileMaker Pro users

As youll see XML is an extremely convenient format fordynamically accessing FileMaker Pro data from the web orother databases and clientsWith XML the data becomes farmore usable and closer to its native format than it would be ifit were first flattened into HTML And by applying a simplestyle sheet or JavaScript you can make the data look andbehave however you like In addition XML lets FileMaker Prosend the information to the user more quickly and with less load on the web server

This Technology Overview shows you how to take advantageof XML to serve data-centric web pages from FileMaker Pro5 or FileMaker Pro 5 Unlimited with a particular focus onhow XML surpasses prior technologies for embedding datain web pagesTo that end its assumed youve worked withFileMaker Pro before though not necessarily version 5 thatyoure familiar with HTML and that youve got some expe-rience publishing web pages and sites However no prior knowledge of XML is assumed

THE ADVANTAGES OF XML FOR FILEMAKER PRO WEBSERVERSXML offers many advantages to the FileMaker Pro developerwho is serving data over the Web Perhaps the single mostimportant is raw speed XML makes a very lightweight enve-lope to hold data so its fast to read and fast to write Manypopular web sites are really just HTML views onto aFileMaker Pro databaseThese range from large sites like theFileMaker web store to relatively small operationsThese sitesand many others like them use FileMaker Prorsquos built-in CGIor additional middleware products to connect their webpages to the underlying FileMaker Pro databaseHowever thisrequires the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker database then insertingthe results back into the HTML before sending it to the clientThen if the client wants something changed for instance hav-ing the results sorted by date instead of price the entire

process has to be repeatedThis is an inefficient use of limit-ed server resources Serving data in XML allocates serverresources much more efficiently The server that uses XMLperforms faster is more customizable and can more easily exchange data with other databases

HIGHER PERFORMANCEServing data encoded in XML is faster because it letsFileMaker Pro do what databases are designed to do storesearch and sort data By using a web browser to format theXML andor transform it into HTML yoursquore freeing upFileMaker Pro to accept more requests When using XMLFileMaker Pro only sends data to the browserThe client thenmassages that data into a reasonable display and presents itto the user More of the work is shifted to the client whichlets FileMaker Pro service a lot more requests in less timeusing the same network bandwidthAnd since what the clientgets is more neatly organized as data than a typical HTMLpage the client can treat it as data It can use JavaScript tosort or search the result set FileMaker Pro sent in real timeChanging the display to sort by date instead of last name forexampledoesnrsquot have to require a new request to the data-base server and accompanying expensive round trip

MORE CUSTOMIZABLEThe most common way to integrate XML with FileMakerPro is through forms and style sheets The web browsershows the user a standard HTML formThe user fills outand submits the form FileMaker Pro receives the form dataand sends a response in XML that includes the data andthe details about where a style sheet for the data can befoundAt this point the servers job is done and its readyto process the next request from some other client Thebrowser then retrieves a style sheet that tells it how toformat the data for display to the userThe server can alsosend the browser a JavaScript program telling the browserhow to make the data dynamic so the user can sort orsearch it in real time Supplying a different style sheet orJavaScript program shows the user a different view of thedata And all of this can be done without bothering theserver again with more requests One request toFileMaker Pro gives the browser all the information the user needs

DATA EXCHANGE STANDARDXML isnt just for the Web either It has other uses too Itsan ideal format for sharing and exchanging data with thirdparties Your data may be in a FileMaker Pro database butyour customers or suppliers might use other databasesYoucan move data from one system to the other by generatingXML using XSL to transform into an agreed standard XMLformat and then importing the data into the new database or

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3

system as Figure 1 diagramsThis format can be documentedusing a document type definition (DTD) or in the future aneven more precise schema Most importantly particular XMLdocuments can be easily compared against DTDs orschemas to determine whether they adhere to the agreed-onformatYou get to validate the data your customers and sup-pliers are sending you before you store it in your databaseThis is key for the expanding busi-ness-to-business market segment

PUBLISHING FILEMAKER PRO

DATA ON THE WEBFileMaker Pro 5 includes a plug-inweb server called the FileMakerWeb Companion The FileMakerWeb Companion can serve staticHTML files and JPEG images justlike a traditional web server likeApache However its real advan-tage is that it can serve HTML andXML straight out of a FileMakerPro database The data does nothave to be exported and stored instatic HTML files firstThis meansthat the browser always gets themost current up-to-the-minuteinformation from the database

Since the FileMaker Web Companion is a web server it needsto run on a machine thats connected to the Internet at astatic domain name and IP addressThis machine must havethe database(s) users are browsing openThe FileMaker WebCompanion can handle the various web services themachine provides or it can run in conjunction with atraditional web server like Apache If so the two servers willsimply run on different ports Generally requests for staticHTML files will be directed to the traditional web serverwhilerequests for dynamic data in XML format will be steered to the FileMaker Web Companion

Client browsers like Netscape Mozilla and Internet Explorerconnect to a web server running FileMaker Pro just like theyconnect to any other web server Clients dont need anybrowser plug-ins or special software The user can interactwith the FileMaker Pro database using standard technologieslike HTML forms JavaScript and of course XML The mostcommon way a user queries a FileMaker Pro database is byfilling out a form in their browser submitting it and receivingthe results back as XMLFileMaker can also send a CSS or XSLstyle sheet or a JavaScript or VBScript program with theresults to tell the browsers how best to format the data for display to the end user

WHICH FILEMAKER PRODUCT IS RIGHT FOR YOUFileMaker Pro software is available in several different varietiesfor different customers with different needs All FileMaker Proproducts support XML and can publish XML data on the Web

FileMaker Pro 5 is the entry level product designed for sin-gle-user databases and small web sites It includes the

FileMaker Web Companion but islimited to connections from nomore than 10 unique IP addresses in any twelve hour period

FileMaker Developer 5 includesFileMaker Pro 5 along with a vari-ety of tools useful to professionaldatabase developers such asODBC and JDBC driversenhanced layout design tools XMLexamples and documentation andthe ability to build and distributestand-alone runtime copies of adatabase FileMaker Developer 5also includes the FileMaker WebCompanion and is limited toconnections from no more than10 unique IP addresses in any twelve hour period

For medium-to-high volume web sitesyoull probably want tomove up to FileMaker Pro 5 UnlimitedThis offers all thefeatures of FileMaker Pro 5 including the FileMaker WebCompanion and full XML supportAdditionally it removes the10 IP address in twelve hour restriction and offers scalableload balancing and fault tolerance by using a Redundant Arrayof Inexpensive Computers (RAIC)each running its own copy of FileMaker Pro 5 Unlimited

WHAT IS XMLThe Extensible Markup Language XML for short is aW3C-endorsed standard for structured markup of docu-ments and data XML defines a syntax for a hierarchicallystructured text document divided into elements Elementsare delimited by start and end tagsThese tags look super-ficially like HTML tags that is they begin with a lt and endwith a gtAttributes are provided in name=value pairs inthe start tag of an element Closing tags begin with a ltand so forth However unlike HTML XML elements arenot limited to a fixed set of tag namesYou can define tagslike ltbookgt ltpersongt ltskugt ltID_Numbergt ltintegergtltDATAgt ltROWgt ltERRORCODEgt and more Forexample in HTML a listing for a book might look like this

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

FileMaker Pro generates XML

XSL processor transforms data intoagreed format

XML parser validates data

Database imports data

Figure 1Exchanging databetween databasesusing XML

4

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltimg src=0140012133gif width=87 height=140 align=leftgtltdtgtThree Men in a BoatltddgtJerome K Jeromeltulgtltligt0140012133ltligt$695ltligt131998ltulgt

Theres a lot missing from this listing For instance is this abook or a video What is the rather mysterious number0140012133 Is $695 a sale price a rental fee the shippingcost or something else The last item looks suspiciously like adate but is that date January 3 1998 or March 1 1998 Andwhat happened on that date All of this information should beeasily ascertainable from the database but its not so obviousfrom the HTMLHowever in XML the same listing would look something like this

ltbook isbn=0140012133gtlttitlegtThree Men in a BoatlttitlegtltauthorgtJerome K Jeromeltauthorgtltcover source=0140012133gif width=87 height=140gtltcovergtltpricegt$695ltpricegtltpublication_dategt

ltmonthgt1ltmonthgtltdaygt3ltdaygtltyeargt1998ltyeargt

ltpublication_dategtltbookgt

There are several points to consider in this example

bull The tag names tell you whats inside the tagXML retainsnot only the databut can also reveal the meta-data aboutwhat the data is If youre mapping documents to data-bases XML retains not only the field values but in some cases the field names as well

bull This XML sample says absolutely nothing about how thebook record is to be displayed to the reader It says thatthere is a book with the title Three Men in a Boat and theauthor Jerome K Jeromebut it doesnt say that the titleshould be 14-point Helvetica bold It says that the price is$695but it doesnt say that $695 should be a bullet pointin a listXML tags add structure and semantics to the datain a documentHowever they say nothing about how that data is formatted Formatting is applied later via a stylesheet Different style sheets can change the presentationof the data without affecting the underlying document

bull This document is well-formedThat means that it adheres to several rules First all tags that are opened ar even-tually closedThere are no opening ltbookgt or ltyeargt orltisbngt tags without corresponding closing ltbookgtltyeargt and ltisbngt tags Furthermore the elementsdont overlapThe ltmonthgt tag can be contained in the

year element but then there must also be a correspond-ing closing ltmonthgt tag in the year element as wellWhen you use FileMaker Pro to generate HTML well-formedness comes for free That is all the XML FileMaker Pro serves is well-formed without any extra effort on your part so you dont have to spend a lot of effort wor-rying about the detailed rules of well-formedness

Applications that read XML documents are required to reject malformed documentsThey are not allowedto try to fix the mistake and go onThis makes it mucheasier to write software that processes XML and to exchange XML documents between FileMaker Pro and other software It helps avoid the browser com-patibility wars that plagued HTML from its early days

The set of possible documents with a given group of ele-ments is sometimes called an XML vocabulary or XMLgrammar However the technical term is XML applicationThis is not an application like FileMaker Pro or InternetExplorer that uses XML but rather an application of XMLto a particular domain like book inventories or chemistryYou can go beyond simple well-formedness by document-ing your XML application with a document type definition(DTD) and requiring that documents be valid according tothe DTD The DTD very formally describes which ele-ments are allowed in what contexts The DTD can beembedded in the XML document or stored in a separatefile whichever is more convenientWhen a validating pars-er reads an XML document it not only checks to see thatthe document is well-formed It also checks to see thatevery element in the document matches the declarationfor that element in the documents DTD By providing aDTD you add rules that are specific to your documenttype These are in addition to the well-formedness rulesthat must be adhered to by all XML documents Howevera DTD is optional If it isnrsquot useful to you you dont need to use one

WHY USE XMLXML offers many advantages to the FileMaker Pro devel-oper who needs to send data to or receive data from nonFileMaker Pro clients Firstly there has been an explosionof third party tools on many platforms in many languagesfor parsing displaying editing exchanging and validatingXML documents These tools run the gamut from publicdomain to open source to fully supported payware fromC to Java to Perl from Macintosh to Unix to WindowsChances are whatever youre doing with XML part of thework has already been done for you and can be easily incorporated in your project at low cost and little effort

5

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Even more importantly XML is much faster than propri-etary solutions Web sites that use CDML Java ServerPages (JSP) or other middleware products to connecttheir web pages to a backend FileMaker Pro databaserequire the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker Pro database theninserting the results back into the HTML before sending itto the client If the client wants anything changed no mat-ter how small it has to go back to the server which has torepeat the entire processThis is an extremely wasteful use of finite server resources

XML works better because all the server has to do is sendsome simple query results to the clientThe browser doesall the tricky formatting and manipulation of the data Forsmaller data sets it can even be more efficient to move allthe data to the client as XML then use Java or JavaScript toperform all the manipulations on the client side Searchesand sorts can be performed against the local XML view ofthe data rather than requiring a round trip to the serverAnother possibility is to show the user only part of the datatheir query returned (say ten records out of a hundred) butgive them a link or button to select the next ten recordsAslong as the data can be stored and manipulated on theclient the number of queries and consequently the load on the server are reduced

OTHER WEB SOLUTIONSXML is not the only way to combine FileMaker Pro data-bases with web sites but it is one of the best To moreclearly see XMLs advantages lets first look at some of theother approaches that have been taken over the last few years and the problems theyve had

EXPORT AS HTMLThe first and most obvious approach is to simply exportthe data to HTMLThis can be done by exporting a data-base as an HTML table or for more precise formattingwith calculation fields and a little AppleScript or Perl (Thisapproach works equally well for exporting data to an XMLvocabulary other than one of the three FileMaker Pronatively supports) This approach also allows you to servedata from any computer with a web server including Unixand Linux systems that cant run FileMaker ProAs already notedyou tend to lose a lot of the datas structurewhen moving to pure HTML But the biggest problem withthis approach is that the web site is not automaticallyupdated when the database changes Sometimes thats OKif you just want to present a static picture of the data tothe user but it doesnt work so well if the data changes ona frequent basis For instance it wouldnt be adequate for

an e-commerce site that needed to let customers knowwhether a product was in stock right this minuteFurthermore it doesnt allow users to interact with thedata on either the client or server side such as searchingfor all the books by a particular authorThey canrsquot chooseto sort by price or add items to or remove items from ashopping cartThis approach is only suitable for very staticslowly changing sites

INSTANT WEB PUBLISHING

Another approach first introduced in FileMaker Pro 4 is topublish the database itself on the Web using Instant WebPublishingThis shows users a dynamic view of the data asit exists at the moment they load the page Users can restassured that any page they see has the most current andup-to-date data even if records are being added to or editedin the database at the same time theyre browsing andsearching it From their web browsers users can even seeand interact with the same layouts theyd use if they wereconnected with a FileMaker Pro client making sortingsearching and editing records in the database very easyAnd all of this can be accomplished without having to write any programs scripts or style sheetsOne of the biggest advantages of Instant Web Publishing is that it does an excellent job of simulating the look and feelof a FileMaker Pro layout Figure 2 shows the same recorddisplayed in Internet Explorer through Instant WebPublishing in the front window and in the actual FileMaker

Pro database in the back windowThe fidelity of the HTML page to the original FileMaker Pro layout is amazingHowever Instant Web Publishing offers limited customizationYou can use layout themes to modify color schemes butyou cant rearrange items on the pageTo change the way

Figure 2 A record in a FileMaker Pro database served via the FileMaker Web Companion

6

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 3: XML Overview

EXECUTIVE SUMMARYXML the Extensible Markup Language is perhaps the mostheavily hyped technology since Java Its been touted as thesolution for a multitude of problems in fields as diverse asweb page designdatabase developmentnewspaper syndicationmortgage brokering and muskrat trapping But just maybeXML really does live up to the hype (Well maybe not in muskrat trapping but the other four are real examples)

FileMaker Inc is moving to support XML throughout itsaward-winning software product line We believe it isextremely important that third-party independent developersgain a working knowledge of how XML technology can be leveraged for FileMaker Pro users

As youll see XML is an extremely convenient format fordynamically accessing FileMaker Pro data from the web orother databases and clientsWith XML the data becomes farmore usable and closer to its native format than it would be ifit were first flattened into HTML And by applying a simplestyle sheet or JavaScript you can make the data look andbehave however you like In addition XML lets FileMaker Prosend the information to the user more quickly and with less load on the web server

This Technology Overview shows you how to take advantageof XML to serve data-centric web pages from FileMaker Pro5 or FileMaker Pro 5 Unlimited with a particular focus onhow XML surpasses prior technologies for embedding datain web pagesTo that end its assumed youve worked withFileMaker Pro before though not necessarily version 5 thatyoure familiar with HTML and that youve got some expe-rience publishing web pages and sites However no prior knowledge of XML is assumed

THE ADVANTAGES OF XML FOR FILEMAKER PRO WEBSERVERSXML offers many advantages to the FileMaker Pro developerwho is serving data over the Web Perhaps the single mostimportant is raw speed XML makes a very lightweight enve-lope to hold data so its fast to read and fast to write Manypopular web sites are really just HTML views onto aFileMaker Pro databaseThese range from large sites like theFileMaker web store to relatively small operationsThese sitesand many others like them use FileMaker Prorsquos built-in CGIor additional middleware products to connect their webpages to the underlying FileMaker Pro databaseHowever thisrequires the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker database then insertingthe results back into the HTML before sending it to the clientThen if the client wants something changed for instance hav-ing the results sorted by date instead of price the entire

process has to be repeatedThis is an inefficient use of limit-ed server resources Serving data in XML allocates serverresources much more efficiently The server that uses XMLperforms faster is more customizable and can more easily exchange data with other databases

HIGHER PERFORMANCEServing data encoded in XML is faster because it letsFileMaker Pro do what databases are designed to do storesearch and sort data By using a web browser to format theXML andor transform it into HTML yoursquore freeing upFileMaker Pro to accept more requests When using XMLFileMaker Pro only sends data to the browserThe client thenmassages that data into a reasonable display and presents itto the user More of the work is shifted to the client whichlets FileMaker Pro service a lot more requests in less timeusing the same network bandwidthAnd since what the clientgets is more neatly organized as data than a typical HTMLpage the client can treat it as data It can use JavaScript tosort or search the result set FileMaker Pro sent in real timeChanging the display to sort by date instead of last name forexampledoesnrsquot have to require a new request to the data-base server and accompanying expensive round trip

MORE CUSTOMIZABLEThe most common way to integrate XML with FileMakerPro is through forms and style sheets The web browsershows the user a standard HTML formThe user fills outand submits the form FileMaker Pro receives the form dataand sends a response in XML that includes the data andthe details about where a style sheet for the data can befoundAt this point the servers job is done and its readyto process the next request from some other client Thebrowser then retrieves a style sheet that tells it how toformat the data for display to the userThe server can alsosend the browser a JavaScript program telling the browserhow to make the data dynamic so the user can sort orsearch it in real time Supplying a different style sheet orJavaScript program shows the user a different view of thedata And all of this can be done without bothering theserver again with more requests One request toFileMaker Pro gives the browser all the information the user needs

DATA EXCHANGE STANDARDXML isnt just for the Web either It has other uses too Itsan ideal format for sharing and exchanging data with thirdparties Your data may be in a FileMaker Pro database butyour customers or suppliers might use other databasesYoucan move data from one system to the other by generatingXML using XSL to transform into an agreed standard XMLformat and then importing the data into the new database or

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3

system as Figure 1 diagramsThis format can be documentedusing a document type definition (DTD) or in the future aneven more precise schema Most importantly particular XMLdocuments can be easily compared against DTDs orschemas to determine whether they adhere to the agreed-onformatYou get to validate the data your customers and sup-pliers are sending you before you store it in your databaseThis is key for the expanding busi-ness-to-business market segment

PUBLISHING FILEMAKER PRO

DATA ON THE WEBFileMaker Pro 5 includes a plug-inweb server called the FileMakerWeb Companion The FileMakerWeb Companion can serve staticHTML files and JPEG images justlike a traditional web server likeApache However its real advan-tage is that it can serve HTML andXML straight out of a FileMakerPro database The data does nothave to be exported and stored instatic HTML files firstThis meansthat the browser always gets themost current up-to-the-minuteinformation from the database

Since the FileMaker Web Companion is a web server it needsto run on a machine thats connected to the Internet at astatic domain name and IP addressThis machine must havethe database(s) users are browsing openThe FileMaker WebCompanion can handle the various web services themachine provides or it can run in conjunction with atraditional web server like Apache If so the two servers willsimply run on different ports Generally requests for staticHTML files will be directed to the traditional web serverwhilerequests for dynamic data in XML format will be steered to the FileMaker Web Companion

Client browsers like Netscape Mozilla and Internet Explorerconnect to a web server running FileMaker Pro just like theyconnect to any other web server Clients dont need anybrowser plug-ins or special software The user can interactwith the FileMaker Pro database using standard technologieslike HTML forms JavaScript and of course XML The mostcommon way a user queries a FileMaker Pro database is byfilling out a form in their browser submitting it and receivingthe results back as XMLFileMaker can also send a CSS or XSLstyle sheet or a JavaScript or VBScript program with theresults to tell the browsers how best to format the data for display to the end user

WHICH FILEMAKER PRODUCT IS RIGHT FOR YOUFileMaker Pro software is available in several different varietiesfor different customers with different needs All FileMaker Proproducts support XML and can publish XML data on the Web

FileMaker Pro 5 is the entry level product designed for sin-gle-user databases and small web sites It includes the

FileMaker Web Companion but islimited to connections from nomore than 10 unique IP addresses in any twelve hour period

FileMaker Developer 5 includesFileMaker Pro 5 along with a vari-ety of tools useful to professionaldatabase developers such asODBC and JDBC driversenhanced layout design tools XMLexamples and documentation andthe ability to build and distributestand-alone runtime copies of adatabase FileMaker Developer 5also includes the FileMaker WebCompanion and is limited toconnections from no more than10 unique IP addresses in any twelve hour period

For medium-to-high volume web sitesyoull probably want tomove up to FileMaker Pro 5 UnlimitedThis offers all thefeatures of FileMaker Pro 5 including the FileMaker WebCompanion and full XML supportAdditionally it removes the10 IP address in twelve hour restriction and offers scalableload balancing and fault tolerance by using a Redundant Arrayof Inexpensive Computers (RAIC)each running its own copy of FileMaker Pro 5 Unlimited

WHAT IS XMLThe Extensible Markup Language XML for short is aW3C-endorsed standard for structured markup of docu-ments and data XML defines a syntax for a hierarchicallystructured text document divided into elements Elementsare delimited by start and end tagsThese tags look super-ficially like HTML tags that is they begin with a lt and endwith a gtAttributes are provided in name=value pairs inthe start tag of an element Closing tags begin with a ltand so forth However unlike HTML XML elements arenot limited to a fixed set of tag namesYou can define tagslike ltbookgt ltpersongt ltskugt ltID_Numbergt ltintegergtltDATAgt ltROWgt ltERRORCODEgt and more Forexample in HTML a listing for a book might look like this

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

FileMaker Pro generates XML

XSL processor transforms data intoagreed format

XML parser validates data

Database imports data

Figure 1Exchanging databetween databasesusing XML

4

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltimg src=0140012133gif width=87 height=140 align=leftgtltdtgtThree Men in a BoatltddgtJerome K Jeromeltulgtltligt0140012133ltligt$695ltligt131998ltulgt

Theres a lot missing from this listing For instance is this abook or a video What is the rather mysterious number0140012133 Is $695 a sale price a rental fee the shippingcost or something else The last item looks suspiciously like adate but is that date January 3 1998 or March 1 1998 Andwhat happened on that date All of this information should beeasily ascertainable from the database but its not so obviousfrom the HTMLHowever in XML the same listing would look something like this

ltbook isbn=0140012133gtlttitlegtThree Men in a BoatlttitlegtltauthorgtJerome K Jeromeltauthorgtltcover source=0140012133gif width=87 height=140gtltcovergtltpricegt$695ltpricegtltpublication_dategt

ltmonthgt1ltmonthgtltdaygt3ltdaygtltyeargt1998ltyeargt

ltpublication_dategtltbookgt

There are several points to consider in this example

bull The tag names tell you whats inside the tagXML retainsnot only the databut can also reveal the meta-data aboutwhat the data is If youre mapping documents to data-bases XML retains not only the field values but in some cases the field names as well

bull This XML sample says absolutely nothing about how thebook record is to be displayed to the reader It says thatthere is a book with the title Three Men in a Boat and theauthor Jerome K Jeromebut it doesnt say that the titleshould be 14-point Helvetica bold It says that the price is$695but it doesnt say that $695 should be a bullet pointin a listXML tags add structure and semantics to the datain a documentHowever they say nothing about how that data is formatted Formatting is applied later via a stylesheet Different style sheets can change the presentationof the data without affecting the underlying document

bull This document is well-formedThat means that it adheres to several rules First all tags that are opened ar even-tually closedThere are no opening ltbookgt or ltyeargt orltisbngt tags without corresponding closing ltbookgtltyeargt and ltisbngt tags Furthermore the elementsdont overlapThe ltmonthgt tag can be contained in the

year element but then there must also be a correspond-ing closing ltmonthgt tag in the year element as wellWhen you use FileMaker Pro to generate HTML well-formedness comes for free That is all the XML FileMaker Pro serves is well-formed without any extra effort on your part so you dont have to spend a lot of effort wor-rying about the detailed rules of well-formedness

Applications that read XML documents are required to reject malformed documentsThey are not allowedto try to fix the mistake and go onThis makes it mucheasier to write software that processes XML and to exchange XML documents between FileMaker Pro and other software It helps avoid the browser com-patibility wars that plagued HTML from its early days

The set of possible documents with a given group of ele-ments is sometimes called an XML vocabulary or XMLgrammar However the technical term is XML applicationThis is not an application like FileMaker Pro or InternetExplorer that uses XML but rather an application of XMLto a particular domain like book inventories or chemistryYou can go beyond simple well-formedness by document-ing your XML application with a document type definition(DTD) and requiring that documents be valid according tothe DTD The DTD very formally describes which ele-ments are allowed in what contexts The DTD can beembedded in the XML document or stored in a separatefile whichever is more convenientWhen a validating pars-er reads an XML document it not only checks to see thatthe document is well-formed It also checks to see thatevery element in the document matches the declarationfor that element in the documents DTD By providing aDTD you add rules that are specific to your documenttype These are in addition to the well-formedness rulesthat must be adhered to by all XML documents Howevera DTD is optional If it isnrsquot useful to you you dont need to use one

WHY USE XMLXML offers many advantages to the FileMaker Pro devel-oper who needs to send data to or receive data from nonFileMaker Pro clients Firstly there has been an explosionof third party tools on many platforms in many languagesfor parsing displaying editing exchanging and validatingXML documents These tools run the gamut from publicdomain to open source to fully supported payware fromC to Java to Perl from Macintosh to Unix to WindowsChances are whatever youre doing with XML part of thework has already been done for you and can be easily incorporated in your project at low cost and little effort

5

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Even more importantly XML is much faster than propri-etary solutions Web sites that use CDML Java ServerPages (JSP) or other middleware products to connecttheir web pages to a backend FileMaker Pro databaserequire the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker Pro database theninserting the results back into the HTML before sending itto the client If the client wants anything changed no mat-ter how small it has to go back to the server which has torepeat the entire processThis is an extremely wasteful use of finite server resources

XML works better because all the server has to do is sendsome simple query results to the clientThe browser doesall the tricky formatting and manipulation of the data Forsmaller data sets it can even be more efficient to move allthe data to the client as XML then use Java or JavaScript toperform all the manipulations on the client side Searchesand sorts can be performed against the local XML view ofthe data rather than requiring a round trip to the serverAnother possibility is to show the user only part of the datatheir query returned (say ten records out of a hundred) butgive them a link or button to select the next ten recordsAslong as the data can be stored and manipulated on theclient the number of queries and consequently the load on the server are reduced

OTHER WEB SOLUTIONSXML is not the only way to combine FileMaker Pro data-bases with web sites but it is one of the best To moreclearly see XMLs advantages lets first look at some of theother approaches that have been taken over the last few years and the problems theyve had

EXPORT AS HTMLThe first and most obvious approach is to simply exportthe data to HTMLThis can be done by exporting a data-base as an HTML table or for more precise formattingwith calculation fields and a little AppleScript or Perl (Thisapproach works equally well for exporting data to an XMLvocabulary other than one of the three FileMaker Pronatively supports) This approach also allows you to servedata from any computer with a web server including Unixand Linux systems that cant run FileMaker ProAs already notedyou tend to lose a lot of the datas structurewhen moving to pure HTML But the biggest problem withthis approach is that the web site is not automaticallyupdated when the database changes Sometimes thats OKif you just want to present a static picture of the data tothe user but it doesnt work so well if the data changes ona frequent basis For instance it wouldnt be adequate for

an e-commerce site that needed to let customers knowwhether a product was in stock right this minuteFurthermore it doesnt allow users to interact with thedata on either the client or server side such as searchingfor all the books by a particular authorThey canrsquot chooseto sort by price or add items to or remove items from ashopping cartThis approach is only suitable for very staticslowly changing sites

INSTANT WEB PUBLISHING

Another approach first introduced in FileMaker Pro 4 is topublish the database itself on the Web using Instant WebPublishingThis shows users a dynamic view of the data asit exists at the moment they load the page Users can restassured that any page they see has the most current andup-to-date data even if records are being added to or editedin the database at the same time theyre browsing andsearching it From their web browsers users can even seeand interact with the same layouts theyd use if they wereconnected with a FileMaker Pro client making sortingsearching and editing records in the database very easyAnd all of this can be accomplished without having to write any programs scripts or style sheetsOne of the biggest advantages of Instant Web Publishing is that it does an excellent job of simulating the look and feelof a FileMaker Pro layout Figure 2 shows the same recorddisplayed in Internet Explorer through Instant WebPublishing in the front window and in the actual FileMaker

Pro database in the back windowThe fidelity of the HTML page to the original FileMaker Pro layout is amazingHowever Instant Web Publishing offers limited customizationYou can use layout themes to modify color schemes butyou cant rearrange items on the pageTo change the way

Figure 2 A record in a FileMaker Pro database served via the FileMaker Web Companion

6

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 4: XML Overview

system as Figure 1 diagramsThis format can be documentedusing a document type definition (DTD) or in the future aneven more precise schema Most importantly particular XMLdocuments can be easily compared against DTDs orschemas to determine whether they adhere to the agreed-onformatYou get to validate the data your customers and sup-pliers are sending you before you store it in your databaseThis is key for the expanding busi-ness-to-business market segment

PUBLISHING FILEMAKER PRO

DATA ON THE WEBFileMaker Pro 5 includes a plug-inweb server called the FileMakerWeb Companion The FileMakerWeb Companion can serve staticHTML files and JPEG images justlike a traditional web server likeApache However its real advan-tage is that it can serve HTML andXML straight out of a FileMakerPro database The data does nothave to be exported and stored instatic HTML files firstThis meansthat the browser always gets themost current up-to-the-minuteinformation from the database

Since the FileMaker Web Companion is a web server it needsto run on a machine thats connected to the Internet at astatic domain name and IP addressThis machine must havethe database(s) users are browsing openThe FileMaker WebCompanion can handle the various web services themachine provides or it can run in conjunction with atraditional web server like Apache If so the two servers willsimply run on different ports Generally requests for staticHTML files will be directed to the traditional web serverwhilerequests for dynamic data in XML format will be steered to the FileMaker Web Companion

Client browsers like Netscape Mozilla and Internet Explorerconnect to a web server running FileMaker Pro just like theyconnect to any other web server Clients dont need anybrowser plug-ins or special software The user can interactwith the FileMaker Pro database using standard technologieslike HTML forms JavaScript and of course XML The mostcommon way a user queries a FileMaker Pro database is byfilling out a form in their browser submitting it and receivingthe results back as XMLFileMaker can also send a CSS or XSLstyle sheet or a JavaScript or VBScript program with theresults to tell the browsers how best to format the data for display to the end user

WHICH FILEMAKER PRODUCT IS RIGHT FOR YOUFileMaker Pro software is available in several different varietiesfor different customers with different needs All FileMaker Proproducts support XML and can publish XML data on the Web

FileMaker Pro 5 is the entry level product designed for sin-gle-user databases and small web sites It includes the

FileMaker Web Companion but islimited to connections from nomore than 10 unique IP addresses in any twelve hour period

FileMaker Developer 5 includesFileMaker Pro 5 along with a vari-ety of tools useful to professionaldatabase developers such asODBC and JDBC driversenhanced layout design tools XMLexamples and documentation andthe ability to build and distributestand-alone runtime copies of adatabase FileMaker Developer 5also includes the FileMaker WebCompanion and is limited toconnections from no more than10 unique IP addresses in any twelve hour period

For medium-to-high volume web sitesyoull probably want tomove up to FileMaker Pro 5 UnlimitedThis offers all thefeatures of FileMaker Pro 5 including the FileMaker WebCompanion and full XML supportAdditionally it removes the10 IP address in twelve hour restriction and offers scalableload balancing and fault tolerance by using a Redundant Arrayof Inexpensive Computers (RAIC)each running its own copy of FileMaker Pro 5 Unlimited

WHAT IS XMLThe Extensible Markup Language XML for short is aW3C-endorsed standard for structured markup of docu-ments and data XML defines a syntax for a hierarchicallystructured text document divided into elements Elementsare delimited by start and end tagsThese tags look super-ficially like HTML tags that is they begin with a lt and endwith a gtAttributes are provided in name=value pairs inthe start tag of an element Closing tags begin with a ltand so forth However unlike HTML XML elements arenot limited to a fixed set of tag namesYou can define tagslike ltbookgt ltpersongt ltskugt ltID_Numbergt ltintegergtltDATAgt ltROWgt ltERRORCODEgt and more Forexample in HTML a listing for a book might look like this

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

FileMaker Pro generates XML

XSL processor transforms data intoagreed format

XML parser validates data

Database imports data

Figure 1Exchanging databetween databasesusing XML

4

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltimg src=0140012133gif width=87 height=140 align=leftgtltdtgtThree Men in a BoatltddgtJerome K Jeromeltulgtltligt0140012133ltligt$695ltligt131998ltulgt

Theres a lot missing from this listing For instance is this abook or a video What is the rather mysterious number0140012133 Is $695 a sale price a rental fee the shippingcost or something else The last item looks suspiciously like adate but is that date January 3 1998 or March 1 1998 Andwhat happened on that date All of this information should beeasily ascertainable from the database but its not so obviousfrom the HTMLHowever in XML the same listing would look something like this

ltbook isbn=0140012133gtlttitlegtThree Men in a BoatlttitlegtltauthorgtJerome K Jeromeltauthorgtltcover source=0140012133gif width=87 height=140gtltcovergtltpricegt$695ltpricegtltpublication_dategt

ltmonthgt1ltmonthgtltdaygt3ltdaygtltyeargt1998ltyeargt

ltpublication_dategtltbookgt

There are several points to consider in this example

bull The tag names tell you whats inside the tagXML retainsnot only the databut can also reveal the meta-data aboutwhat the data is If youre mapping documents to data-bases XML retains not only the field values but in some cases the field names as well

bull This XML sample says absolutely nothing about how thebook record is to be displayed to the reader It says thatthere is a book with the title Three Men in a Boat and theauthor Jerome K Jeromebut it doesnt say that the titleshould be 14-point Helvetica bold It says that the price is$695but it doesnt say that $695 should be a bullet pointin a listXML tags add structure and semantics to the datain a documentHowever they say nothing about how that data is formatted Formatting is applied later via a stylesheet Different style sheets can change the presentationof the data without affecting the underlying document

bull This document is well-formedThat means that it adheres to several rules First all tags that are opened ar even-tually closedThere are no opening ltbookgt or ltyeargt orltisbngt tags without corresponding closing ltbookgtltyeargt and ltisbngt tags Furthermore the elementsdont overlapThe ltmonthgt tag can be contained in the

year element but then there must also be a correspond-ing closing ltmonthgt tag in the year element as wellWhen you use FileMaker Pro to generate HTML well-formedness comes for free That is all the XML FileMaker Pro serves is well-formed without any extra effort on your part so you dont have to spend a lot of effort wor-rying about the detailed rules of well-formedness

Applications that read XML documents are required to reject malformed documentsThey are not allowedto try to fix the mistake and go onThis makes it mucheasier to write software that processes XML and to exchange XML documents between FileMaker Pro and other software It helps avoid the browser com-patibility wars that plagued HTML from its early days

The set of possible documents with a given group of ele-ments is sometimes called an XML vocabulary or XMLgrammar However the technical term is XML applicationThis is not an application like FileMaker Pro or InternetExplorer that uses XML but rather an application of XMLto a particular domain like book inventories or chemistryYou can go beyond simple well-formedness by document-ing your XML application with a document type definition(DTD) and requiring that documents be valid according tothe DTD The DTD very formally describes which ele-ments are allowed in what contexts The DTD can beembedded in the XML document or stored in a separatefile whichever is more convenientWhen a validating pars-er reads an XML document it not only checks to see thatthe document is well-formed It also checks to see thatevery element in the document matches the declarationfor that element in the documents DTD By providing aDTD you add rules that are specific to your documenttype These are in addition to the well-formedness rulesthat must be adhered to by all XML documents Howevera DTD is optional If it isnrsquot useful to you you dont need to use one

WHY USE XMLXML offers many advantages to the FileMaker Pro devel-oper who needs to send data to or receive data from nonFileMaker Pro clients Firstly there has been an explosionof third party tools on many platforms in many languagesfor parsing displaying editing exchanging and validatingXML documents These tools run the gamut from publicdomain to open source to fully supported payware fromC to Java to Perl from Macintosh to Unix to WindowsChances are whatever youre doing with XML part of thework has already been done for you and can be easily incorporated in your project at low cost and little effort

5

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Even more importantly XML is much faster than propri-etary solutions Web sites that use CDML Java ServerPages (JSP) or other middleware products to connecttheir web pages to a backend FileMaker Pro databaserequire the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker Pro database theninserting the results back into the HTML before sending itto the client If the client wants anything changed no mat-ter how small it has to go back to the server which has torepeat the entire processThis is an extremely wasteful use of finite server resources

XML works better because all the server has to do is sendsome simple query results to the clientThe browser doesall the tricky formatting and manipulation of the data Forsmaller data sets it can even be more efficient to move allthe data to the client as XML then use Java or JavaScript toperform all the manipulations on the client side Searchesand sorts can be performed against the local XML view ofthe data rather than requiring a round trip to the serverAnother possibility is to show the user only part of the datatheir query returned (say ten records out of a hundred) butgive them a link or button to select the next ten recordsAslong as the data can be stored and manipulated on theclient the number of queries and consequently the load on the server are reduced

OTHER WEB SOLUTIONSXML is not the only way to combine FileMaker Pro data-bases with web sites but it is one of the best To moreclearly see XMLs advantages lets first look at some of theother approaches that have been taken over the last few years and the problems theyve had

EXPORT AS HTMLThe first and most obvious approach is to simply exportthe data to HTMLThis can be done by exporting a data-base as an HTML table or for more precise formattingwith calculation fields and a little AppleScript or Perl (Thisapproach works equally well for exporting data to an XMLvocabulary other than one of the three FileMaker Pronatively supports) This approach also allows you to servedata from any computer with a web server including Unixand Linux systems that cant run FileMaker ProAs already notedyou tend to lose a lot of the datas structurewhen moving to pure HTML But the biggest problem withthis approach is that the web site is not automaticallyupdated when the database changes Sometimes thats OKif you just want to present a static picture of the data tothe user but it doesnt work so well if the data changes ona frequent basis For instance it wouldnt be adequate for

an e-commerce site that needed to let customers knowwhether a product was in stock right this minuteFurthermore it doesnt allow users to interact with thedata on either the client or server side such as searchingfor all the books by a particular authorThey canrsquot chooseto sort by price or add items to or remove items from ashopping cartThis approach is only suitable for very staticslowly changing sites

INSTANT WEB PUBLISHING

Another approach first introduced in FileMaker Pro 4 is topublish the database itself on the Web using Instant WebPublishingThis shows users a dynamic view of the data asit exists at the moment they load the page Users can restassured that any page they see has the most current andup-to-date data even if records are being added to or editedin the database at the same time theyre browsing andsearching it From their web browsers users can even seeand interact with the same layouts theyd use if they wereconnected with a FileMaker Pro client making sortingsearching and editing records in the database very easyAnd all of this can be accomplished without having to write any programs scripts or style sheetsOne of the biggest advantages of Instant Web Publishing is that it does an excellent job of simulating the look and feelof a FileMaker Pro layout Figure 2 shows the same recorddisplayed in Internet Explorer through Instant WebPublishing in the front window and in the actual FileMaker

Pro database in the back windowThe fidelity of the HTML page to the original FileMaker Pro layout is amazingHowever Instant Web Publishing offers limited customizationYou can use layout themes to modify color schemes butyou cant rearrange items on the pageTo change the way

Figure 2 A record in a FileMaker Pro database served via the FileMaker Web Companion

6

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 5: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltimg src=0140012133gif width=87 height=140 align=leftgtltdtgtThree Men in a BoatltddgtJerome K Jeromeltulgtltligt0140012133ltligt$695ltligt131998ltulgt

Theres a lot missing from this listing For instance is this abook or a video What is the rather mysterious number0140012133 Is $695 a sale price a rental fee the shippingcost or something else The last item looks suspiciously like adate but is that date January 3 1998 or March 1 1998 Andwhat happened on that date All of this information should beeasily ascertainable from the database but its not so obviousfrom the HTMLHowever in XML the same listing would look something like this

ltbook isbn=0140012133gtlttitlegtThree Men in a BoatlttitlegtltauthorgtJerome K Jeromeltauthorgtltcover source=0140012133gif width=87 height=140gtltcovergtltpricegt$695ltpricegtltpublication_dategt

ltmonthgt1ltmonthgtltdaygt3ltdaygtltyeargt1998ltyeargt

ltpublication_dategtltbookgt

There are several points to consider in this example

bull The tag names tell you whats inside the tagXML retainsnot only the databut can also reveal the meta-data aboutwhat the data is If youre mapping documents to data-bases XML retains not only the field values but in some cases the field names as well

bull This XML sample says absolutely nothing about how thebook record is to be displayed to the reader It says thatthere is a book with the title Three Men in a Boat and theauthor Jerome K Jeromebut it doesnt say that the titleshould be 14-point Helvetica bold It says that the price is$695but it doesnt say that $695 should be a bullet pointin a listXML tags add structure and semantics to the datain a documentHowever they say nothing about how that data is formatted Formatting is applied later via a stylesheet Different style sheets can change the presentationof the data without affecting the underlying document

bull This document is well-formedThat means that it adheres to several rules First all tags that are opened ar even-tually closedThere are no opening ltbookgt or ltyeargt orltisbngt tags without corresponding closing ltbookgtltyeargt and ltisbngt tags Furthermore the elementsdont overlapThe ltmonthgt tag can be contained in the

year element but then there must also be a correspond-ing closing ltmonthgt tag in the year element as wellWhen you use FileMaker Pro to generate HTML well-formedness comes for free That is all the XML FileMaker Pro serves is well-formed without any extra effort on your part so you dont have to spend a lot of effort wor-rying about the detailed rules of well-formedness

Applications that read XML documents are required to reject malformed documentsThey are not allowedto try to fix the mistake and go onThis makes it mucheasier to write software that processes XML and to exchange XML documents between FileMaker Pro and other software It helps avoid the browser com-patibility wars that plagued HTML from its early days

The set of possible documents with a given group of ele-ments is sometimes called an XML vocabulary or XMLgrammar However the technical term is XML applicationThis is not an application like FileMaker Pro or InternetExplorer that uses XML but rather an application of XMLto a particular domain like book inventories or chemistryYou can go beyond simple well-formedness by document-ing your XML application with a document type definition(DTD) and requiring that documents be valid according tothe DTD The DTD very formally describes which ele-ments are allowed in what contexts The DTD can beembedded in the XML document or stored in a separatefile whichever is more convenientWhen a validating pars-er reads an XML document it not only checks to see thatthe document is well-formed It also checks to see thatevery element in the document matches the declarationfor that element in the documents DTD By providing aDTD you add rules that are specific to your documenttype These are in addition to the well-formedness rulesthat must be adhered to by all XML documents Howevera DTD is optional If it isnrsquot useful to you you dont need to use one

WHY USE XMLXML offers many advantages to the FileMaker Pro devel-oper who needs to send data to or receive data from nonFileMaker Pro clients Firstly there has been an explosionof third party tools on many platforms in many languagesfor parsing displaying editing exchanging and validatingXML documents These tools run the gamut from publicdomain to open source to fully supported payware fromC to Java to Perl from Macintosh to Unix to WindowsChances are whatever youre doing with XML part of thework has already been done for you and can be easily incorporated in your project at low cost and little effort

5

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Even more importantly XML is much faster than propri-etary solutions Web sites that use CDML Java ServerPages (JSP) or other middleware products to connecttheir web pages to a backend FileMaker Pro databaserequire the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker Pro database theninserting the results back into the HTML before sending itto the client If the client wants anything changed no mat-ter how small it has to go back to the server which has torepeat the entire processThis is an extremely wasteful use of finite server resources

XML works better because all the server has to do is sendsome simple query results to the clientThe browser doesall the tricky formatting and manipulation of the data Forsmaller data sets it can even be more efficient to move allthe data to the client as XML then use Java or JavaScript toperform all the manipulations on the client side Searchesand sorts can be performed against the local XML view ofthe data rather than requiring a round trip to the serverAnother possibility is to show the user only part of the datatheir query returned (say ten records out of a hundred) butgive them a link or button to select the next ten recordsAslong as the data can be stored and manipulated on theclient the number of queries and consequently the load on the server are reduced

OTHER WEB SOLUTIONSXML is not the only way to combine FileMaker Pro data-bases with web sites but it is one of the best To moreclearly see XMLs advantages lets first look at some of theother approaches that have been taken over the last few years and the problems theyve had

EXPORT AS HTMLThe first and most obvious approach is to simply exportthe data to HTMLThis can be done by exporting a data-base as an HTML table or for more precise formattingwith calculation fields and a little AppleScript or Perl (Thisapproach works equally well for exporting data to an XMLvocabulary other than one of the three FileMaker Pronatively supports) This approach also allows you to servedata from any computer with a web server including Unixand Linux systems that cant run FileMaker ProAs already notedyou tend to lose a lot of the datas structurewhen moving to pure HTML But the biggest problem withthis approach is that the web site is not automaticallyupdated when the database changes Sometimes thats OKif you just want to present a static picture of the data tothe user but it doesnt work so well if the data changes ona frequent basis For instance it wouldnt be adequate for

an e-commerce site that needed to let customers knowwhether a product was in stock right this minuteFurthermore it doesnt allow users to interact with thedata on either the client or server side such as searchingfor all the books by a particular authorThey canrsquot chooseto sort by price or add items to or remove items from ashopping cartThis approach is only suitable for very staticslowly changing sites

INSTANT WEB PUBLISHING

Another approach first introduced in FileMaker Pro 4 is topublish the database itself on the Web using Instant WebPublishingThis shows users a dynamic view of the data asit exists at the moment they load the page Users can restassured that any page they see has the most current andup-to-date data even if records are being added to or editedin the database at the same time theyre browsing andsearching it From their web browsers users can even seeand interact with the same layouts theyd use if they wereconnected with a FileMaker Pro client making sortingsearching and editing records in the database very easyAnd all of this can be accomplished without having to write any programs scripts or style sheetsOne of the biggest advantages of Instant Web Publishing is that it does an excellent job of simulating the look and feelof a FileMaker Pro layout Figure 2 shows the same recorddisplayed in Internet Explorer through Instant WebPublishing in the front window and in the actual FileMaker

Pro database in the back windowThe fidelity of the HTML page to the original FileMaker Pro layout is amazingHowever Instant Web Publishing offers limited customizationYou can use layout themes to modify color schemes butyou cant rearrange items on the pageTo change the way

Figure 2 A record in a FileMaker Pro database served via the FileMaker Web Companion

6

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 6: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Even more importantly XML is much faster than propri-etary solutions Web sites that use CDML Java ServerPages (JSP) or other middleware products to connecttheir web pages to a backend FileMaker Pro databaserequire the server to do a lot of work reading HTML filesfinding the database queries embedded in the files makingthose queries against the FileMaker Pro database theninserting the results back into the HTML before sending itto the client If the client wants anything changed no mat-ter how small it has to go back to the server which has torepeat the entire processThis is an extremely wasteful use of finite server resources

XML works better because all the server has to do is sendsome simple query results to the clientThe browser doesall the tricky formatting and manipulation of the data Forsmaller data sets it can even be more efficient to move allthe data to the client as XML then use Java or JavaScript toperform all the manipulations on the client side Searchesand sorts can be performed against the local XML view ofthe data rather than requiring a round trip to the serverAnother possibility is to show the user only part of the datatheir query returned (say ten records out of a hundred) butgive them a link or button to select the next ten recordsAslong as the data can be stored and manipulated on theclient the number of queries and consequently the load on the server are reduced

OTHER WEB SOLUTIONSXML is not the only way to combine FileMaker Pro data-bases with web sites but it is one of the best To moreclearly see XMLs advantages lets first look at some of theother approaches that have been taken over the last few years and the problems theyve had

EXPORT AS HTMLThe first and most obvious approach is to simply exportthe data to HTMLThis can be done by exporting a data-base as an HTML table or for more precise formattingwith calculation fields and a little AppleScript or Perl (Thisapproach works equally well for exporting data to an XMLvocabulary other than one of the three FileMaker Pronatively supports) This approach also allows you to servedata from any computer with a web server including Unixand Linux systems that cant run FileMaker ProAs already notedyou tend to lose a lot of the datas structurewhen moving to pure HTML But the biggest problem withthis approach is that the web site is not automaticallyupdated when the database changes Sometimes thats OKif you just want to present a static picture of the data tothe user but it doesnt work so well if the data changes ona frequent basis For instance it wouldnt be adequate for

an e-commerce site that needed to let customers knowwhether a product was in stock right this minuteFurthermore it doesnt allow users to interact with thedata on either the client or server side such as searchingfor all the books by a particular authorThey canrsquot chooseto sort by price or add items to or remove items from ashopping cartThis approach is only suitable for very staticslowly changing sites

INSTANT WEB PUBLISHING

Another approach first introduced in FileMaker Pro 4 is topublish the database itself on the Web using Instant WebPublishingThis shows users a dynamic view of the data asit exists at the moment they load the page Users can restassured that any page they see has the most current andup-to-date data even if records are being added to or editedin the database at the same time theyre browsing andsearching it From their web browsers users can even seeand interact with the same layouts theyd use if they wereconnected with a FileMaker Pro client making sortingsearching and editing records in the database very easyAnd all of this can be accomplished without having to write any programs scripts or style sheetsOne of the biggest advantages of Instant Web Publishing is that it does an excellent job of simulating the look and feelof a FileMaker Pro layout Figure 2 shows the same recorddisplayed in Internet Explorer through Instant WebPublishing in the front window and in the actual FileMaker

Pro database in the back windowThe fidelity of the HTML page to the original FileMaker Pro layout is amazingHowever Instant Web Publishing offers limited customizationYou can use layout themes to modify color schemes butyou cant rearrange items on the pageTo change the way

Figure 2 A record in a FileMaker Pro database served via the FileMaker Web Companion

6

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 7: XML Overview

your web site behaves after a record has been added ordeleted you need to use additional technology like XMLAnd while FileMaker Pros layout tools give you the abilityto create beautiful user interfaces most database expertsarent accomplished graphic designers and more graphicdesigners are comfortable working with HTML than with FileMaker Pro

CUSTOM WEB PUBLISHING WITH PROPRIETARY TAGS

Still a third approach is to add CDML tags to your HTMLfilesThis allows you to use a sort of server-side include tointegrate your HTML pages with data from a FileMakerPro databaseYou write an HTML file in which you includespecial tags like [FMP-FIELD title] and [FMP-if] that tell theserver what query to make against the databaseWhen abrowser requests a document the server replaces theCDML tags with data from the databaseThe server thensends the browser pure HTML that it can display without any special software

The biggest problem here is speed Parsing an HTML file tofind out what queries to make making the queries andthen building a new document by combining the old doc-ument with the results of those queries puts a lot of loadon a database XML can be a lot faster because it removesthe need to parse the HTML just to find the queriesFurthermore FileMaker Pro does less work on the backend because XML is a lot closer to the datas native formatIts a lot quicker for FileMaker to send the data out in pureXML and let the client convert that to HTML than to do all the work on the server side

Additionally CDML (and other middleware technologies)are proprietary Since these arent extensible youre prettymuch stuck with whatever features the vendor has providedtags forWith XML you can use JavaScript or VBScript tobuild robust custom applications and behaviorsFurthermore proprietary tag sets prevent you from easilymigrating your data and web site to Oracle or IBMs DB2XML is non-proprietary and supported by more databasevendors every day like FileMaker Inc IBM and OracleWith strong XML JDBC and ODBC support across theFileMaker 5 family FileMaker Inc is moving towards moreopen standards New applications should move to XML so they can take advantage of future developments

OTHER WEB APISAnother possibility is to use database middleware likeODBC or JDBC to connect to the FileMaker Pro databaseand load data into the HTML pages JDBC is especially con-venient if your web server supports servlets or Java ServerPages (JSP) The Java code includes standard SQL queries

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

that the FileMaker JDBC driver forwards to the FileMakerWeb Companion The Web Companion returns theresults and the servlet or JSP wraps them in HTML beforepassing them on to the client Other non-Java Web devel-opment tools like Allaires Cold Fusion and AdobesGoLive 401 can build pages in this fashion by using the FileMaker ODBC driver

However both ODBC and JDBC process data on theserver side either on the database server or the web serverwhich has to do a lot of expensive time-consumingformatting that could be done more cheaply and quicklyon the clientThe more successful your web site is and themore hits it gets the more problematic this becomesYoucan always buy bigger and faster hardware but its a lotcheaper to move to an XML-based client-side approachFurthermore with ODBC or JDBC the client still onlygets unstructured HTML with all of its attendant disad-vantages This may be sufficient if you want to hide yourdatas structure or you only want to present a static pictureof the data to browsers but its not suitable for dynamicsites that let the user rearrange the data to meet their needs

THE XML ADVANTAGE

XML has a number of advantages compared to all these approaches

1 Most importantly XML is faster because it moves a lotof the work to the clientThe server receives a queryand sends a response thats very close to the raw dataIt doesnt have to spend a lot of CPU power or pro-cessing time massaging the data into HTML thats suitablefor client display Formatting a single HTML documentisnrsquot a significant resource issue Formatting thousandsof them is Its faster for each of thousands of clientsto do its own small piece of the work in parallel thanfor one server even a very fast one to do all the work itself

2 Secondly XML is a standard XML is well-documentedwell-understood technology with lots of third party support in the form of software books specificationsand moreThis broad support makes it much easier tolearn and use XML It also makes it much easier to exchange data with other individuals companies ven-dors customers contractors and with their databases since youre all using the same technology XML isplatform database and programming language agnosticIts just as happy to work with FileMaker Pro andWebStar on a Macintosh as Oracle and Apache on Solaris

7

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 8: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

3 Another important benefit of XML in todays increasinglyheterogeneous Internet is that XML documents are atleast partially self-documenting When you see an item l ikeltpersongtltlas tgtE l i a slt l a s tgtltf i r s tgt Jasonltfirstgtltpersongt you can easily tell that Elias is thelast name of a person and that Jason is the first nameWith a DTD or schema and appropriate commentsthe identification becomes even clearerThat isnt trueof less flexible formats like HTML or tab delimited text

HOW DOES FILEMAKER PRO SUPPORT XMLFileMaker Pro serves XML via the FileMaker Web CompanionA client system generally a browser makes a request tothe server using an HTML link or formThis form or linkis set up to pass both a query to the server and detailsabout how the information is to be encoded in XMLTheserver formats the data as XML then passes that XMLback to the client If the XML is intended to be displayedto a person the server will include information with thedocument telling where a style sheet for the documentcan be foundThe browser then requests the style sheetOnce it has retrieved this style sheet it formats the XMLaccording to the instructions in the style sheet and shows it to the user Figure 3 summarizes this process

Again there are many other approaches for a web browserto get data out of a databaseAdding CDML to pages is oneapproach historically used by FileMaker Pro backed sitesAnother is to use Java Server Pages servlets CGIs or anapplication server to talk to the databaseAlthough the low

level syntax differs the basic approach of these solutions isthe sameThe client generally a browser makes a particularrequest to the web server probably by filling out and sub-mitting a form The page the user requests containsmarkup in the proprietary language telling the web serverhow to fill it out with data from the database For instanceheres a page that uses CDML markup to provide a cur-rent list of titles in stockThe proprietary tags are in boldFigure 4 shows the resulting HTML page displayed in Netscape Navigator

lthtmlgtltheadgtlttitlegtAvailable Titles at FunnyNovelscomlttitlegtltheadgt

ltbodygtlth1gtFunny Novels in stock on [FMP-CurrentDate]lth1gt

ltULgt[FMP-Record]ltLIgt[FMP-Field title] ltigt[FMP-Field author]ltigt

[FMP-Record]ltULgtltHRgtCopyright 1999 Funny NovelsltBRgtltA HREF=mailtowebmasterfunnynovelscomgtweb-masterfunnynovelscomltAgt

ltbodygtlthtmlgt

FileMaker Web Companion must replace the bold tags withstandard HTML before sending this file to a browser Thusthe FileMaker Web Companion web server retrieves therequested data from the database server and replaces theproprietary markup with the dataThe result is a page of pureHTML FileMaker Web Companion then sends this HTMLpage to the client which displays it to the user Figure 5 summarizes this process

This looks simpler than the XML process in Figure 3 and insome ways it is But thats because the FileMaker WebCompanion is doing a lot more of the work and the browser

Figure 3 Querying FileMaker Pro for XML

Figure 4 A Web Page generated by FileMaker Pro in response to CDML markup

8

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 9: XML Overview

is doing a lot less As long as there are many clients perserver it makes sense to push as much of the work as pos-sible onto the clients to relieve the burden on the serverWith XML clients are closer to the real data If they needto further process the data for instance by sorting or sum-ming it they can If they want to import the data into theirown databases they canThis doesnt just have to happenonce By using JavaScript the client can re-sort and organizethe data multiple times according to a variety of criteriaBy contrast in the second approach a client only getsHTML which is good for presentation but not much elseIf it wants to see a slightly different view of the data it hasto go back to the server and ask for the exact same datajust formatted and organized a little differently On medium-to-high volume web sites this is an inefficient use of a serverslimited resources

On the other hand any server-based solution currently hasmuch broader browser support It can send viewable data topretty much any browser since Netscape 10The pure XMLbased solution more or less requires a fifth generation browser(for example Internet Explorer 5 or the upcoming browserfrom Netscape) which limits your ability to deploy a solutionlike this Of course as users upgrade their browsers this willbecome less of a concern (The Gartner Group estimates thatby year-end 2001 80 of all Web-based technology will useXML-defined data interchange) In the meantimea lot of siteshave chosen to go with a hybrid solution in which the databasegenerates XML However the XML rather than being sentdirectly to the client is transformed to HTML on the serverside typically using an XSLT style sheet and Microsoftrsquos ActiveServer Pages (ASP) or Sunrsquos Java Server Pages (JSP)This allowsyou to support all web browsers while sticking with standardmarkup languages and still achieve substantial speed-ups

REQUESTING XML DATA FROM FILEMAKER PROData can be retrieved in XML format from a FileMaker Pro

Figure 5 Querying a server for HTML with CDML

database over the Web in much the same way it can beretrieved in HTML format by opening FileMaker Pro (andhence the FileMaker Web Companion) on the server andusing CGI commands from the client to make queriesHowever since unlike HTML XML doesnt carry any for-matting information theres an extra stepYoull also needto provide a CSS or XSL style sheet or use JavaScript to tell the browser how to display the XML data

To get data out of a FileMaker Pro database as XML themachine running FileMaker Pro must be connected to theInternet using TCPIP and the FileMaker Web Companionmust be turned on To activate this pull down the Editmenu and open the PreferencesApplicationhellip dialog boxChoose the Plug-In tab and check the Web companioncheck box Next select Web Companion and click theConfigure button If youre running another web server onthe same system youll need to pick some port other than80 FileMaker has registered port 591 with the IANA forthis purpose Click OK twice to get out of the dialog andsave your changesThen open each database you want toshare go to the File Menu and select Sharing In the resultingdialog box enable the Web Companion checkbox

Once the Web Companion is enabled its simply a matter ofconnecting to the server with a Web browser using a URLwith the appropriate query string For example suppose youwant to get an XML formatted list of the records in thenovelsfp5 database from a FileMaker Pro database runningon the host funnynovelscom on port 591Then you wouldtype this URL into your Web browsers location bar or Open page dialog

httpfunnynovelscom591FMPro-db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This URL can be divided into five parts

the scheme http

This specifies which protocol is used to communicate with theserverWhen talking to FileMaker Pro over the Web this will always be http the hypertext transfer protocol

the host funnynovelscom

This specifies the name or IP address of the server FileMaker Pro is running on

the port 591

Normally HTTP servers run on port 80 However if FileMaker Pro is sharing a machine with another web server like Apache or WebStar then youll need to choose a different port

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

9

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 10: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

the file path FMPro

This tells the server which file to serveWhen using the FileMaker Web Companion as your server to serve XMLthis is always FMPro

the query string -db=novelsfp5amp-format=-fmp_xmlamp-max=allamp-find

This provides input for the web server program that decides what data to send backThe information is providedin name=value pairs separated by amp signsThis query stringhas four variables -database which specifies the database name (in this case the value novelsfp5 -format which specifies which FileMaker XML grammar to use (in this example -fmp_xml -max which specifies the number of records to retrieve (in this case all) and -find which is therequest for data

Figure 6 shows Internet Explorer 5 connecting to thisdatabase using this URL Since we havent yet attached astyle sheet to the document IE uses its default tree structuredXML presentation that allows you to collapse and expand headings

Of course most of the time you wont be blindly typingquery strings into the location bar Instead youll set uponline forms so surfers can just press a button to accessthe database For example this HTML form would let users access the complete book list

ltFORM METHOD=GETACTION=httpfunnynovelscom591FMProgt

ltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=-max VALUE=all TYPE=hiddengtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

This form uses hidden INPUT elements so that the querystring will be set up exactlyAnother approach is to makethe complete query string part of the value of the href attribute of a link like this

lta href=httpfunnynovelscom591FMPro-db=novelsfp5amp-format=fmp_xmlamp-max=allamp-findgt List Books ltagt

On the other handone of the advantages of a FileMaker Probacked web site is that users can search sort and performother operations in the database directly from theirbrowsers In this case youd give the user non-hiddenINPUT elements that let them type in what they wanted tosearch for or sort by For instance this form lets the user search by author

ltFORM METHOD=GET ACTION=httpfunnynovelscomFMProgtltINPUT NAME=-db VALUE=novelsfp5 TYPE=hiddengtltINPUT NAME=-format VALUE=-fmp_xml TYPE=hiddengtltINPUT NAME=AuthorgtltbrgtltINPUT NAME=-find VALUE=List Books TYPE=submitgt

ltFORMgt

The form is shown in Figure 7

The query string it builds up looks like this

-db=novelsfp5amp-format=-fmp_xmlampAuthor=Jeromeamp-find=List+Books

The query string variables that begin with a hyphen like -db-format and -find are all instructions to FileMaker ProThequery string variables that donrsquot begin with a hyphenAuthor in this example are names of fields in the databaseBy using INPUT elements with different names you can search by different fields in the database

FileMaker Pro supports over two dozen different variablesin its query strings that allow web surfers to create newrecords edit existing records search databases sort data-bases and run scripts in databasesAll of these operationsare performed by changing the values of query string vari-ables or indirectly by setting up forms to use differentquery string variables A complete list of the query string

Figure 6 Internet Explorer 5 showing raw XML from a FileMaker Prodatabase served over the Web

Figure 7 A simple author search form

10

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 11: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

variables you can use to request XML from a FileMakerPro database as well as the exact syntax for the values ofthese variables can be found in Appendix B of the FileMaker Developers Guide or at the FileMaker XMLcentral web site wwwfilemakercomxml

CHOOSING A FILEMAKER PRO XML GRAMMARXML is a very general syntax for documents XML itselfsays very little about what tags you may and may not usewhere in your documents Most applications of XMLrestrict themselves to a well-specified subset of XMLFileMaker Pro can serve data encoded in any of three different XML vocabulariesThese are

bull The FMPDSORESULT grammar (database dependent)

bull The FMPXMLRESULT grammar (database independent)

bull The FMPXMLLAYOUT grammar

FMPDSORESULT and FMPXMLRESULT are alternativeXML vocabularies for describing the records and fields in aFileMaker Pro 5 databaseWhich one you choose dependson whether you want to use the same XML vocabulary forall your databases or different more specific vocabularies for different databases

The FMPDSORESULT grammar uses elements whosenames match the names of the fields in the databaseThismeans you can apply different CSS style rules to differentfields However you do have to write a new style sheet for every different database you want to work with

The FMPXMLRESULT grammar uses a vocabulary withelements that represent database records fields result setsand so forthThese are enough to describe any database buttheyre a little generic For instance a book title would bedescribed with the same generic DATA tags that are usedfor author names ISBN numbers prices and other fieldsThis makes it difficult to use CSS to apply different styles todifferent fields XSL style sheets are more flexible and canbetter deal with a database table-independent grammar like this using other non-name cues like element position

Finally the FMPXMLLAYOUT grammar is used to describenot the data in a table but rather the semantic organization of the table such as the values allowed in a value list

FMPDSORESULT a database dependent grammar

The FMPDSORESULT grammar uses field names as elementnamesA small result set in the FMPDSORESULT grammar looks like this

ltxml version=10 encoding=UTF-8 gt ltFMPDSORESULT xmlns=httpwwwfilemakercomfmpdsoresultgt

ltERRORCODEgt0ltERRORCODEgt ltDATABASEgtnovelsfp5ltDATABASEgt ltLAYOUTgtltLAYOUTgt ltROW MODID=2 RECORDID=1gt

ltTitlegtThree Men in a Boat To Say Nothing of the DogltTitlegt ltISBNgt0140012133ltISBNgt ltAuthorgtJerome K JeromeltAuthorgt ltCovergtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltCovergt ltPricegt$695ltPricegt

ltROWgtltFMPDSORESULTgt

One consequence of using field names as element names(rather than as element content or attribute values) is thatthe field names must be included in the DTD Every data-base with a different schema will need a different DTDSimilarly you cant write a very good generic style sheetfor displaying this data Any style sheet that provides anattractive format for this data will have to know that ISBN numbers are included in ISBN elements and so forth

Of course if you work mostly with one database at a timethen having the field names encoded as element namesmakes it a lot easier to apply style rules to particular ele-mentsThis is especially true in CSS because most currentCSS implementations cant select based on attributes orelement content However even with XSLmdashwhich canselect based on attributes and element contentmdashits easierto select element names Furthermore this is a lot easierfor human beings to read than the next two formats well look at Computers of course dont much care about that

FMPXMLRESULT a database independent grammar

The FMPXMLRESULT grammar can encode an arbitrarytable in XMLThis is becauseunlike FMPDSORESULT it usesa fixed set of elementsThe database schema is described bya METADATA element that contains one FIELD elementgiving the name and type of each fieldThe benefit of usinggeneric tags is that the same style sheet can be easilyreused with other FileMaker Pro databasesThe same result set encoded in FMPXMLRESULT looks like this

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLRESULT xmlns=httpwwwfilemakercomfmpxmlresultgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999 NAME=FileMaker Pro Web Companion

VERSION=50v2 gt

ltDATABASE DATEFORMAT=Mdyyyy LAYOUT=NAME=novelsfp5

RECORDS=4 TIMEFORMAT=hmmss a gt

ltMETADATAgt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=TitleTYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=ISBN TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Author TYPE=TEXT gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Cover TYPE=CONTAINER gt

ltFIELD EMPTYOK=YES MAXREPEAT=1 NAME=Price TYPE=NUMBER gt

11

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 12: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

ltMETADATAgt

ltRESULTSET FOUND=1gt

ltROW MODID=3 RECORDID=1gt

ltCOLgt

ltDATAgtThree Men in a Boat To Say Nothing of the DogltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt0140012133ltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtJerome K JeromeltDATAgt

ltCOLgt

ltCOLgt

ltDATAgtFMPro-DB=novelsfp5amp-RecID=1ampCover=amp-ImgltDATAgt

ltCOLgt

ltCOLgt

ltDATAgt$695ltDATAgt

ltCOLgt

ltROWgt

ltRESULTSETgt

ltFMPXMLRESULTgt

Since all FMPXMLRESULT documents use the same fixedset of tags and attributes--DATABASE RESULTSET ROWCOLDATA etc--its easy to provide a DTD that can validateany FMPXMLRESULT document Furthermore the docu-ment itself includes a pretty decent schema for the data-base (not the same thing as an XML schema) in the METADATA element

However since the actual data is all stored in DATA elementsits pretty much impossible to use CSS to attach differentstyles to different fields For instance you cant say that thetitle is bold but the author is plain text XSLs more powerfulselection facilities do allow you to make statements likethat though Furthermore the very regular predictablestructure of an FMPXMLRESULT is easier to handlethrough JavaScript and the Document Object Model(DOM) than the looser FMPDSORESULT grammar Ifyoure able to use XSL or fifth generation browsers youshould probably choose FMPXMLRESULT in preference to FMPDSORESULT

FMPXMLLAYOUT A GRAMMAR FOR LAYOUTS

FMPXMLLAYOUT is the third and final XML grammar thatFileMaker Pro supports Its a little different than the othertwo because it provides different information than theother twoWhereas both FMPDSORESULT and FMPXML-RESULT focus on the data in the database FMPXMLLAY-OUT describes the layout of the fields Heres theFMPXMLLAYOUT description of the same database thatthe previous two result sets came from However whatsdescribed here is not a result set but rather one particularlayout from the database the previous result sets came from

ltxml version=10 encoding=UTF-8 gt

ltFMPXMLLAYOUT xmlns=httpwwwfilemakercomfmpxmllayoutgt

ltERRORCODEgt0ltERRORCODEgt

ltPRODUCT BUILD=981999

NAME=FileMaker Pro Web Companion VERSION=50v2 gt

ltLAYOUT DATABASE=novelsfp5 NAME=allfieldsgt

ltFIELD NAME=Titlegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=ISBNgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Authorgt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Covergt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Pricegt

ltSTYLE TYPE=EDITTEXT VALUELIST= gt

ltFIELDgt

ltFIELD NAME=Bindinggt

ltSTYLE TYPE=RADIOBUTTONS VALUELIST=Bindings gt

ltFIELDgt

ltVALUELISTSgt

ltVALUELIST NAME=Bindingsgt

ltVALUEgthardcoverltVALUEgt

ltVALUEgtsoftcoverltVALUEgt

ltVALUELISTgt

ltVALUELISTSgt

ltLAYOUTgt

ltFMPXMLLAYOUTgt

The other grammars tell you what the data is and what thetype of the data isThe FMPXMLLAYOUT grammar by con-trast describes the structure and layout of a record Forexample it provides field names the types of the fields(whether theyre formatted as editable text boxes radiobuttons checkboxes pop-up lists or pop-menus and soforth) If the value of the field is taken from a value list eitherdynamic or included in the layout then the list of possiblevalues is included as wellYou can use all this information tobuild HTML forms that use the same value lists the samedefault values and the same user interface componentsWhat an FMPXMLLAYOUT document doesnrsquot tell you isany data that belongs to any particular record as opposed to the general structure of all records in the table

FORMATTING XML DOCUMENTSThe almost source code like view of the XML in Figure 4is not ideal In practice you need a much more attractiveweb page However XML says nothing about how the datais presented Instead it relies on a style sheet or script to specify how each individual element is to be presented

There are several choices for formatting languagesCascading Style Sheets (CSS) is the most broadly supportedstyle sheet language and one of the simplest However itsquite limited in what it can accomplishThe Extensible Style

12

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 13: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Language (XSL) is more powerful but more complex anddoes not yet have broad browser support It does howeverhave substantial third party supportAnother extremely pow-erful option albeit one that comes with a price in increasedcomplexity is using the Document Object Model and a script-ing language like JavaScript or VBScript to format and manip-ulate the native XML data andor reformat it into HTMLTable 1 summarizes the various options and their advantages and disadvantages

Connecting a style sheet or script to the actual datareturned from the database is easy even if the style sheet isdelivered from a different web server All of these optionsshare the advantage that the actual formatting informationcan be stored in a separate file from the data itself allowingdesigners and programmers to use familiar tools like BBEditor HomeSite to write their style sheets and scriptsWith justa little forethought when first designing the style sheets orscripts many different queries can all use the same few standard style sheets or scripts

FORMATTING XML USING CSSThe simplest most widely supported style sheet languagefor XML is Cascading Style Sheets Level 1 (CSS1)This is avery straight-forward language that simply lists propertiesfor particular elements Figure 9 shows the books databaseserved in XML and formatted with this CSS1 style sheet (comments are enclosed in and )

These are the defaults for the entire page

FMPDSORESULT display block font-family New York

Times New Roman serif

These are the elements we want to hide from the user

ERRORCODE DATABASE LAYOUT Cover display none

Make the title look like an H1 header big and bold

Title font-weight bold font-family Helvetica

Arial sans-serif font-size large

Put author ISBN and Price on separate lines

Author display block font-style italic

ISBN Price display block

Here were using the FMDSORESULT grammar becauseCSS is quite limited in what it can apply styles to It can saythat the Title element should be bold However saying thatthe first COL element in a RESULTSET should be boldexceeds CSSs limited selection capabilities (althoughCSS2 may do this) Wersquoll demonstrate using XSL belowFigure 8 shows what the result looks like after the abovestyle sheet has been applied Its a lot more attractive than Figure 5

Elements generally inherit properties from their parentsbut can override them if they choose For example in theabove style sheet the Author and Price are in a serif font(preferably New York) but Title is in a sans serif font inheritedfrom their parent FMPDSORESULT element because it has a more specific rule setting its font face

Unfortunately CSS Level 1 alone is too simple to handlemany common needs For instance it doesnt allow you toorganize information as tables instead of paragraphs orembed images in a document It relies on features ofHTML to accomplish tasks like this However XML has nosuch underlying formatting model Unlike HTML it makesno assumptions about how data is to be arranged on thepage CSS Level 2 does add a lot of features that are nec-essary for the more complex task of styling XML such astable structures and text that doesnt flow from left toright and top to bottom (like Arabic or traditionalChinese) However CSS2 isnt very well supported bycommon browsers yet Finally since CSS1 and CSS2 arestatic markup languages they are limited to applying stylesto what text is present in the document They cantreorder that textor merge text with boilerplate informationTo do this with CSS you must use CSS properties via the DOM from scripting languages like JavaScript

Figure 8 A find request with a CSS style sheet applied

13

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 14: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

Connecting a style sheet to the actual data returned fromthe database is easyYou just need to add -styletype and-stylehref variables to the query string that specify theMIME type and URL respectively of the style sheet youwant to use The ndashstyletype tag specifies the type ofstylesheet to use and the ndashstylehref tag specifies the filelocation)Then before serving the document FileMaker Prowill insert the necessary ltxml-stylesheetgt processinginstruction to connect the document it sends to the stylesheet youve prepared For example suppose your stylesheet is at the absolute URL httpwwwfunnynovelscomstylesbookscssAll you have to do is add these two hiddenfields to the form that makes the query

ltINPUT NAME=-styletype VALUE=textcss TYPE=hiddengt

ltINPUTNAME=-stylehref

VALUE=httpwwwfunnynovelscomstylesbookscss

TYPE=hiddengt

This will add these two variables to the query string

-styletype=textcssamp-stylehref=httpwwwfunnynovels

comstylesbookscss

XSL style sheets are attached in much the same wayTheonly difference is that the -styletype query string variable would have the value textxsl instead of textcss

FORMATTING XML USING XSLXSL is a much more complete style sheet language thanCSS Furthermore XSL is much better suited to the specificneeds of XML as opposed to CSS which is really designedfor HTML with XML support tacked on as an after-thought However while XSL is much more powerful thanCSS its also quite a bit more complex XSL is divided intotwo parts XSL Transformations (XSLT) and XSLFormatting Objects (XSL-FO) The transformations halfdefines an XML vocabulary for describing how one XMLdocument is transformed into another XML documentThe formatting objects half defines an XML vocabulary fordescribing the layout styles and contents of boxes onpages Its almost PostScript like in its power and flexibilityThese two parts are useful independently of each otherand indeed XSLT is much further along in both specificationand shipping software than XSL-FO The most commonway to use XSL with FileMaker Pro is to write an XSLTstyle sheet that transforms the XML FileMaker Pro emitsinto HTML that the browser knows how to display SinceHTML can use CSS formatting properties this means thatXSLT can do anything CSS can do and then quite a bit more

An XSLT style sheet for the books example using theFMPDSORESULT grammar would look something like this

ltxml version=10gt

ltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpdsoresultgt

ltxsltemplate match=fmFMPDSORESULTgt

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltxslapply-templates select=fmROWgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgt

lth2gt

ltxslvalue-of select=fmTitlegt

by

ltigtltxslvalue-of select=fmAuthorgtltigt

lth2gt

ltulgt

ltligtISBN ltxslvalue-of select=fmISBNgtltligt

ltligtPrice ltxslvalue-of select=fmPricegtltligt

ltulgt

ltxsltemplategt

ltxslstylesheetgt

This transforms the XML FileMaker Pro sends into verynicely formatted HTML as Figure 9 shows Since the stylesheet can contain literal result elements like ltTITLEgt andtext strings like Copyright 1999 Funny Novels as well asXSL instructions like xsltemplate its straight-forward tomix the actual data from the database with boilerplate text like this

This style sheet matches one template to the root element FMPDSORESULT that wraps the entire page in a standard

Figure 9 A find request with an XSL style sheet applied

14

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 15: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

HTML envelope like a HEAD element and a signatureblock with a copyright notice Inside the template for theroot element xslapply-templates processes each ROWchild element For every ROW child it fills in and outputsthe template for the ROW element The ROW templatepulls each piece of datamdashthe author the title etcmdashand putsit together along with some standard HTML formatting tags like ltH2gt and ltigt

XSLT also works for the FMPXMLRESULT grammar In thiscase you cant select individual fields like Author using theelement names since all the element names are the sameInstead you have to choose fields by their positions relative to their siblings in their parent ROW element

ltxml version=10gtltxslstylesheet xmlnsxsl=httpwwww3org1999XSLTransform

xmlnsfm=httpwwwfilemakercomfmpxmlresultgt

ltxsltemplate match=fmFMPXMLRESULTgtltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gtltxslapply-templates select=fmRESULTSETgtltHRgtltHRgtCopyright 1999 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

ltxsltemplategt

ltxsltemplate match=fmROWgtlth2gt

ltxslvalue-of select=fmCOL[position()=1]gtbyltigtltxslvalue-of select=fmCOL[position()=3]gtltigt

lth2gtltulgt

ltligtISBN ltxslvalue-of select=fmCOL[position()=2]gtltligt

ltligtPrice ltxslvalue-of select=fmCOL[position()=5]gtltligt

ltulgtltxsltemplategt

ltxslstylesheetgt

Since XSLT can produce essentially arbitrary HTML output(possibly including some CSS as well) youre only limited bythe capabilities of HTML Anything you can do in HTMLyou can do in XML + XSLT transformed to HTML Thesame cant be said for XML + CSS which is missing some of the power of HTML

SCRIPTING AND THE DOCUMENT OBJECT MODEL

(JAVASCRIPTVBSCRIPT)XSLT is extremely powerful and can accomplish a lotBeyond the simple style sheets weve seen here it can sortand reorder elements select elements based on attributevalues perform simple arithmetic format elements withthe same name but different content differently and more

However ultimately XSL is a declarative language thatfocuses on the structure of the input document If youreally need to manipulate XML on the client side in a trulyarbitrary fashion then you need to use a scripting languagelike VBScript or JavaScript Scripting can accomplish anythingXSLT can as well as performing a lot of things XSLT cantmdashlike making network connections to load document partsthat are only referenced by URL in the input document ordynamically updating the view of the data based on whatthe user does with the mouse For instance in InternetExplorer 5s default tree-structured XML view scripting isresponsible for showing and hiding the individual parts of thedocument as the user clicks on the + and - signs in the left hand column

The trade off of using a scripting language to access thedocument is that its considerably more complex than thealternatives of CSS and XSLT Scripting is programming andwhile programming in JavaScript may be easier than program-ming in traditional languages like C or Java it still requires areasonable facility with programming fundamentals Anddepending on your task you may find that 90 of yourcode does something that could be more easily and cleanlydone in XSLT while less than ten percent of your programis devoted to the dynamic features that really demand scripting

The first step in using JavaScript to format XML data is toget the XML into the HTML document that holds thescript Internet Explorer 5 provides several approachesincluding XML data islands and an XMLDSO appletHowever here well focus on a method supported inInternet Explorer 4 for Windows and later This is anActiveX control that connects to the MSXML parserThisActiveX control can load an XML document from a URLon the network It then exposes the XML document to thescript as an object The child elements of the documentbecome properties of the object By reading the values ofthe properties of the object (and the values of the prop-erties of the properties and so forth) you can access anynode in the XML document Naturally well set theActiveX control to a URL that points into a FileMaker ProdatabaseThis demonstrates the power of XML Microsoftnever considered the needs of FileMaker Pro when itwrote Internet Explorer yet because FileMaker Pro sup-ports XML we can easily make FileMaker Pro records andresult sets into objects that Internet Explorer natively handles

The MSXML parser exposes the contents of the XML docu-ment using Internet Explorers Document Object Model orDOM (Netscape has a different DOM which supports none

15

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 16: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

of this to date The W3C is making efforts to standardizeDOMs between browsers It has released an official speci-fication for DOM Level 1 of which Internet Explorer 5 haspartial support However true cross-browser scripting andDOM support is still some time in the future) The IEDOM allows you to access the XML document at aremote URL by invoking the MSXML XML parser as anActiveX Control This returns an XML Document object whose child elements you can inspect

Below you see an HTML page designed to handle this Itloads an external script file called loadbooksjs that willconnect to the database download the XML and format it as HTML for insertion in the page

ltHTMLgt

ltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgt

ltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=JavaScript SRC=loadbooksjsgt

ltSCRIPTgt

ltHRgtltHRgt

Copyright 1999 Funny NovelsltBR gt

ltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscom

ltAgt

ltBODYgt

ltHTMLgt

Heres the loadbooksjs script

Load the parser

var xml = new ActiveXObject(msxml)

Tell the parser which document will be parsed

xmlURL = httplocalhostfmpro-db=novelsfp5amp-

format=-fmp_xmlamp-find

Get the root element of the document

var docroot = xmlroot

Look for the RESULTSET child of the root

We know that in the FMPXMLRESULT grammar

there should be exactly one of these

var resultset = docrootchildrenitem(RESULTSET)

We know that in the FMPXMLRESULT grammar

RESULTSET has zero or more ROW children

and no children of any other type

var rows = resultsetchildren

Each row in this database represents a book

for (row=0 row lt rowslength row++)

The fields are in COL elements which are the

only children of the ROW elements

var columns = rowsitem(row)children

The title ISBN author and price are always

in the same columns We could get the DATA children

here as well but its simpler just to take the

complete text of each column since our database doesnt

have any repeating fields

var title = columnsitem(0)text

var isbn = columnsitem(1)text

var author = columnsitem(2)text

var price = columnsitem(4)text

Now that the title author price and ISBN are stored in

convenient variables we simply wrap them in a little

literal HTML and write the data into the web page

documentwrite(lth2gt + title + by ltigt + author +

ltigtlth2gt )

documentwrite(ltulgt)

documentwrite(ltligtISBN + isbn)

documentwrite(ltligtPrice + price)

documentwrite(ltulgt)

The resulting web page shown in Figure 10 is almost identicalto the page produced earlier by XSLT Probably more than90 of the time both JavaScript and XSLT are completelycapable of doing anything you need and your choice betweenthem is mostly a matter of personal preference and softwaresupportThe exceptions would be cases where you wantedto respond to the user dynamically in real time or you neededto merge data from multiple XML documents In these cases you really need a scripting language

This script is extremely short on error checking andmakes a lot of assumptions that particular fields like Titleand Author will be in particular places in the documentThese positions shouldnt change capriciously from run torun However they might change if someone deleted a fieldfrom the database or changed which fields appear on thelayout Ideally youd want to compare the expected posi-tions for fields with the position of the correspondingFIELD child of the METADATA element The XSLT stylesheet shared this issue However in that case the solutionwould be a lot more complex to implement than hereThe

Figure 10 A find request that uses JavaScript formatting

16

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 17: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

CSS style sheet did not share this problem because it usedthe FMPDSORESULT grammar that identifies the differentfields by their names rather than by their positions Analternative solution would be to simply use that grammar instead of FMPXMLRESULT

This is far from the only way to format a page usingJavaScriptThere are at least half a dozen other ways to do itthat would produce identical results For instance you coulduse an XML element as a data island tied to DIV elementsor you could load the XML when the document firstloaded and insert it into an element rather than simplywriting it into the middle of the document Of course allthese examples really only reproduce what we alreadyaccomplished more simply with XSLT The real advantageto JavaScript is dynamically manipulating the XML inresponse to user action Once youve loaded the XMLdocument into memory from the FileMaker WebCompanion and possibly converted it to some convenientformat its a simple matter of programming to sort itcollapse it rearrange it or reformat it on the fly SinceJavaScript is a full programming language it lends itself to multiple solutions

The same technique works with virtually any embeddedscripting language provided it has some way to translate aremote XML document into an object to be accessed bythe script For example heres a version of the same scriptthat uses VBScript instead of JavaScript Since VBScriptscant be included in external files its embedded directly in the HTML source

ltHTMLgtltHEADgtltTITLEgtBooks in InventoryltTITLEgtltHEADgtltBODYgt

ltH1gtFunny Novels InventoryltH1gt

ltSCRIPT LANGUAGE=VBScriptgt

Dim rows columnsDim xmldocSet xmldoc = CreateObject(MicrosoftXMLDOM)

REM wait for the document to finish loading before continuingxmldocasync = false

REM validation isnt required well-formedness is enoughxmldocvalidateOnParse = false

REM Load the XMl data from the database Notice we use the REM FMPXMLRESULT grammarxmldocload(httplocalhostfmpro-db=novelsfp5amp-format=-fmp_xmlamp-find)

REM Here we go straight to the ROW elements theres one row per record Set rows = xmlDocgetElementsByTagName(ROW)

REM Format each recordFor i=0 To (rowslength -1)

REM Put the fields of the record into the columns variable Set columns = rowsitem(i)getElementsByTagName(DATA)

REM Get each field from its known positiontitle = columnsitem(0)textisbn = columnsitem(1)textauthor = columnsitem(2)textprice = columnsitem(4)text

REM Wrap the data in HTMl and write it into the documentdocumentwrite(lth2gt + title + by ltigt +

author + ltigtlth2gt )documentwrite(ltulgt)documentwrite(ltligtISBN + isbn)documentwrite(ltligtPrice + price)documentwrite(ltulgt)

NextltSCRIPTgt

ltHRgtltHRgtCopyright 2000 Funny NovelsltBR gtltA HREF=mailtowebmasterfunnynovelscomgt

webmasterfunnynovelscomltAgt

ltBODYgtltHTMLgt

Aside from the syntactic differences between Visual Basicand JavaScript this script is really quite similar to theJavaScript version and produces the same end result Somelines look almost identical The reason is that bothJavaScript and VBScript are accessing the same objectsusing the same object model For instance the documentobject is the same thing in VBScript as it is in JavaScript arepresentation of the HTML page However because thisscript was written using Microsofts Document ObjectModel it only runs on Internet Explorer if you add supportin this script for W3C DOM the script would work across platforms on W3C-DOM compliant browsers

TOOLS TO HELP FORMAT XML DOCUMENTS

The basic tool for editing CSS is a text editor likeUltraEdit emacs or BBEdit and a CSS compliant webbrowser like Mozilla 5 or Internet Explorer 5Various texteditors like HotMetal HomeSite FrontPage and BBEditprovide varying levels of support for CSS but for the mostpart any software you can edit HTML+CSS in will do thetrick for XML+CSS as well If you prefer to design yourdocuments visually rather than by typing style rules in atext editormdashand most people domdashthen there are a numberof free and cheap tools to help you do so by editing stylesheets Not all of these can work with data loaded directlyfrom a FileMaker Pro query over the WebYou may needto load an example page into your browser first then save

17

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 18: XML Overview

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

it to a local file from the browserThen you can work onthis local file instead However once youve done that itsquite easy to create the style sheetAttaching the finishedstyle sheet to future queries simply requires moving it intothe FileMaker Pro Web folder and adding -stylehref and-styletype variables to your query strings that point to your style sheet

XSLT style sheets are trickierYoull still need a text editorlike emacs or BBEdit and a web browser to view the finishedproduct However if youre relying on transforming XMLto HTML on the server side rather than letting the browserdo it for you youre probably better off with a commandline processor like xt or Xalan since theyre more up todate with the final W3C XSLT Recommendation XSLTprocessors that are open source and written in Java include

James Clarks xthttpwwwjclarkcomxmlxthtml

The Apache XML Projects Xalanhttpxmlapacheorgxalanindexhtml

Michael Kays Saxonhttpusersiclwaycoukmhkaysaxon

There are numerous others including ones written in CC++ Python and many other languages However thesethree appear to be frequently updated an important characteristic on the bleeding edge that is XSL

There are fewer tools for editing XSL style sheets thanCSS style sheets and they arent nearly as visualTo a largeextent thats because XSLs formatting model doesnt easilylend itself to making text selections and pulling down afont or a style from a menu However there are a couple of packages worth checking out

IBMs alphaWorks XSL Editor is a pure Java program forediting and debugging XSLT style sheets It lets you tracethe path the templates follow through a document andhelps you write select and match expressions by auto-matically generating the necessary XPath syntax from example input and output documents

See httpwwwalphaworksibmcomtechxsleditor

Object Designs eXcelon Stylus is an XML IntegratedDevelopment Environment (IDE) for Windows 9598NTthat can be used to develop XSLT style sheets compliantwith the W3Cs specification or with Microsofts version of XSL supported in Internet Explorer 5See httpwwwodicomexcelonProductsProdMainhtm

DEPLOYING A FILEMAKER PRO XML SOLUTION

On an intranet where you know that your users surf withInternet Explorer 50 or later you can deploy XML on theclient side with reasonable confidence that users will be ableto handle what you send themUnfortunatelywell over half ofweb surfers today are still using 4x generation or earlierbrowsers that only support HTML These browsers havelimited ability to handle particular XML documents in specialcircumstances In particular Internet Explorer 4 for Windowscan do a passable job of handling XML via JavaScript and theDOM However for most practical purposes both InternetExplorer 45 and earlier and Netscape Navigator 47 andearlier only support HTMLNetscape 5x and laterMozilla 5xand later and Internet Explorer 5x and later provide varying levels of support for XML XSL and CSS

There are two basic ways to serve XML data to clientsThe first is to send the raw XML along with a style sheetthat tells the browser how to render the documentThisrequires that the client application know both XML andthe specific style sheet language (and indeed the particularversion of the specific style sheet language) youre sendingit The second approach is to have the server apply thestyle sheet to the XML data to convert into lowest-com-mon-denominator HTML that all browsers understandMost of the time CSS is more reliable when you want tosend the XML documents themselves to fifth generationbrowsers because Mozilla Netscape and Internet Explorerall support CSS to some degreeHoweverXSLT is more con-venient for server side transformations to HTML because ofthe much broader availability of tools to handle this

Table 2 below summarizes the level of support for differentcombinations of XML and style sheets and scripting languages in the common browsers

Table 2 Browser support for style sheet and scripting languages

18

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 19: XML Overview

One thing this table indicates is that if your client environ-ment is at all heterogeneous then the only really plausiblesolution is to convert to HTML on the server side Evenamong fifth generation browsers Internet Explorers CSSsupport is incomplete and MozillaNavigators XSL support isnon-existent In an Intranet situation with homogeneousclients you may have a few more choices

There are two basic approaches to server side conversion ofXML dataThe first approach is to put pure XML files on theweb server (or in this case serve them out of a FileMaker Prodatabase) and have the web server convert those XML docu-ments to HTML before delivering them to browsersThis ismost commonly accomplished with Java servlets or ASPThesecond approach is to embed a reference to the XML data inHTML files (or an XSL style sheet) along with some instruc-tions to the server about how to replace the data and instruc-tions with HTML before serving it to the clientThis is com-monly accomplished with ASPJSPor PHPThe advantage of thisapproach is that designers can write all the presentationalaspects of the page in normal familiar HTMLThey dont haveto learn a new style sheet language just to place a few tableson a page Figure 11 shows this process using Java ServerPages The key element in this process is the servlet thatknows how to transform the XML FileMaker Pro sends intothe HTML the browser readsThis servlet can either operatedirectly on the XML using a parser much like the JavaScriptand VBScript examples we saw earlier or it can be a moregeneric servlet that applies an XSLT style sheet to FileMakerPros XMLThere are many good free servlets available to doexactly that including IBM alphaWorks XML Enabler(httpwwwalphaworksibmcomtechxmlenabler) and James Clarks XSLServlet (httpwwwjclarkcomxmlxthtml)

FURTHER READING

For more detailed information and examples of how toserve a FileMaker Pro database as XML consult theFileMaker Pro Developers Guide included with FileMakerDeveloper 5 An appendix to the Developers Guide contains acomplete list of the query string variables you can use torequest XML from a FileMaker Pro database as well as theexact syntax for the values of these variables For moreinformation about working with the FileMaker WebCompanion refer to the FileMaker Pro 5 Users Guideincluded with FileMaker Pro 5 Unlimited FileMaker Pro 5 and FileMaker Developer 5

For a detailed specification of the FMPDSORESULTFMPXMLRESULT and FMPXMLLAYOUT grammars youshould read the document type definitions for thesevocabularies included on the FileMaker Developer 5 CDThis CD also includes a complete XML example thatshows an inventory database designed to be run in con-junction with Internet Explorer 5 for WindowsYoull findthe necessary files in the FileMaker ProWeb folderXMLExample folder on your CDThis example is also described in the FileMaker Developers Guide

There are many web sites on the Internet dedicated toXMLThe World Wide Web Consortium (W3C) has takenthe lead in standardizing XML and many related technolo-gies like XSL and CSSYoull find the official specificationsfor these on their web site at httpwwww3orgTRSome of the most important include

Other sites of interest include

xmlcom httpwwwxmlcomOngoing news coverage of developments in XMLParticularly useful here is Tim Brays Annotated XML Specification that explains both what the somewhat turgid XML specification really means and why it means it

Figure 11 Java Server pages used to perform server side transformations of XML

XML 10 httpwwww3orgTRREC-xml

Nameplaces in XML httpwwww3orgTRREC-xml-names

XSL Transformations httpwwww3orgTRxslt

XPath httpwwww3orgTRxpath

Document Object Model httpwwww3orgTRREC-DOM-Level-1(DOM) Level 1

Cascading Style Sheets httpwwww3orgTRREC-CSS2Level 2 (one of the mostreadable specifications)

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

19

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 20: XML Overview

Microsoft XML Developer Centerhttpmsdnmicrosoftcomxmldefaultasp

This site on the Microsoft Developer Network provides detailed information about how XML can be used in Internet Explorer 4 and 5 particularly through XML Data Islands and the DOM Be warned however that this doesntalways clearly distinguish between Microsoft and Internet Explorer specific extensions and standard XML

Cafe con Leche httpmetalabunceduxmlDaily news updates about XML software applications and specifications as well as links to XML mailing lists conferencesbooks and more

XMLInfo httpwwwxmlinfocomJames Taubers XMLInfo is a well organized collection of links to XML resources including schemas style sheetsexamples specifications software articles and more

The SGMLXML Web Page httpwwwoasis-openorgcoverxmlhtml

Robin Cover maintains a huge database of almost everything anyone or anybody has ever said done written or posted about XMLThis massive site includes summaries of andlinks to W3C XML Working Groups specifications schemasFAQ lists other web sites about XML XML applicationsarticles and books about XML press releases mailing lists newsgroups and more

OASIS httpwwwoasis-openorgOASIS the Organization for the Advancement of StructuredInformation Standards is a nonprofit international consortiumdedicated to standards based product-independent formats for structured information including XML Membership in OASIS is open to interested individuals for a reasonable price

xml-dev httpwwwlistsicacukhypermailxml-devThe xml-dev mailing list is for high-level discussion among people writing software and specifications for XML processingIts intensely technicalTo subscribe send email to majordomoicacuk with the words subscribe xml-dev youhostdomain in the body of the message

XML-L xml-llistservheaie The XML-L mailing list is a user oriented list for people tryingto use existing tools to work with XML documentsTo subscribe send email to listservlistservheaie with the words SUBSCRIBE XML-L your name here in the message body

GLOSSARY

CDMLFileMaker Inc proprietary tags for publishing FileMaker Pro data tothe Web using custom web publishing You can now choose to useXML or other APIrsquos such as JDBC or ODBC instead

CSSThe simplest and least powerful way to apply style formattingto XML data for example for display in a browser

See the Technology Previewrsquos section on Formatting XML docu-ments for the uses pros and cons of this and other formattingmethods

DOM -Document Object ModelA DOM is the way a browser makes elements in XML docu-ments available to scripting and programming languages forexample for the creation of dynamic web pages Currentlyeach browser has its own version of a ldquoDOMrdquo but the theWorld Wide Web Consortium is developing a standard thatwill make it possible to write programs and scripts that workwith any browser on any platform

DTD- document type definitionA document containing rules to which all documents and pro-grams involved in a particular project or application of XMLmust adhere in order to ensure compatibility and consistencyField names for example would be specified in a DTD AnXML document must declare any DTD that it must be validat-ed by Validation is done by a validating parser (see)

FileMaker Pro optionally generates a DTD describing the rulesgoverning each of the three grammars it can publish

meta dataData that describes data for example a field name

parserAn application (or part of an application) that interprets anXML document so that it can be manipulated or used forexample to display data in a browser

schemaThe structure of a database as determined by the databasefiles and fields The schema is the basis for rules that can bedescribed in a DTD (see)

structured dataData that knows what it is and how it is related to other ele-ments around it Data stored in a table (ie a FileMaker Profile) is structured data XML data is structured data In XMLdata from FileMaker Pro each piece of data is identified by itsfield name and is a subset of the data in a particular record

Structured data has the potential to be manipulated and usedmuch more precisely than unstructured data For example for-matting can be applied to data based on its category

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

20

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21

Page 21: XML Overview

Style sheetA style sheet determines the appearance and formatting of elements in the set of documents that references it BecauseXML data contains no information about how information is tobe displayed an XML document can specify a style sheet inorder to display its data in a browser

Style sheets can be written using CSS or XSL See theTechnology Previewrsquos section on Formatting XML documentsfor details

validAn XML document is valid according to the rules specified in aDTD (see) if it follows those rules Validity is determined by avalidating parser (see)

validating parserAn application program (such as the one contained inMicrosoft Internet Explorer 5) that evaluates an XMLdocument to be sure it is valid (see)

W3CThe World Wide Web Consortium the organization dedicatedto standardizing WWW technologies

XSLA language used to write style sheets to format or transformdata in XML documentsThe most commonly used of its twoparts XSLT can be used to transform the XML from FileMakerPro into HTML for display in a browser or into an agreed-upon standard for data exchange

See the Technology Previewrsquos section on Formatting XML documents for the uses pros and cons of this and otherformatting methods

XSLTPart of the XSL formatting language Use an XSLT style sheetfor example to transform the XML that FileMaker Pro gener-ates into HTML for display in a browser

copy2000 FileMaker Inc All rights reserved FileMaker is a trademark ofFileMaker Inc registered in the US and other countries and the filefolder logo is a trademark of FileMaker Inc Portions of some screenshots are reprinted by permission from Microsoft CorporationPortions of some screen shots are copyright 1996-2000 NetscapeCommunications Corp All rights reservedThese screen shots maynot be reprinted or copied without the express written permission ofNetscape All other trademarks are the property of their respectiveowners Menton of third party products and companies is for infor-mational purposes only and does not constitute an endorsement norrecommendation Some persons and companies listed in the examplesare purely fictitious and any resemblance to existing persons andcompanies is purely coincidental Product specifications and availabilitysubject to change without notice

FileMaker Product Family

ABOUT THE AUTHORElliotte Rusty Harold is an internationally respected writerprogrammer and educator both on the Internet and offHe lectures about Java and object oriented programmingat Polytechnic University in Brooklyn His Cafe au Lait website at httpmetalabuncedujavafaq has become one ofthe most popular independent Java sites on the Internetand his spin-off site Cafe con Leche athttpmetalabunceduxml has become one of the mostpopular XML sites He is the author of numerous booksmost recentlyThe XML Bible from IDG and Java IO fromOReilly

For more information visit the FileMaker XML website at httpwwwfilemakercomxml which provides additional technical papers examplesdocumentation and links to 3rd party resources

For more information on the FileMaker productfamily or to order software visit wwwfilemakercom

FileMaker Inc5201 Patrick Henry DriveSanta Clara CA 95054httpwwwfilemakercom

Increase network performance and centralize administrationof FileMaker Pro fileswith up to 250 guestsdagger

FileMaker Server 5

Author custom solutionsfor the Web FileMakerPro or the runtime application (included)

Includes FileMaker Pro

FileMaker Developer 5

Enables a single user tocreate manage and shareinformation and projectsin workgroups of up to10 guestsdagger

FileMaker Pro 5

Unlimited sharing ofFileMaker files over theWeb with built-in supportfor leading Web servers

Includes FileMaker Pro

FileMaker Pro 5 Unlimited

FileMakerPro 5

FileMakerServer 5

FileMakerPro 5 Unlimited

FileMakerDeveloper 5

If you use FileMaker Pro 5 with other FileMaker products those other FileMaker Products must be version 5 or laterdaggerEach FileMaker Pro guest requires an additional licensed copy of FileMaker Pro

TECHNOLOGY OVERVIEW ndash FILEMAKER PRO AND XML

21