XML (along with its companion technology, XSLT), is the driving technology behind FileMaker’s Custom Web Publishing (CWP). FileMaker Server Advanced can serve out FileMaker data as XML, for use in applications that require XML data. It can also transform the XML data extracted using XSLT stylesheets, to create a variety of output formats, including, of course, an HTML presentation layer.
This section is a reference guide to FileMaker XML syntax. We cover the following areas:
We do not cover in detail all of the XSLT extension functions available in Custom Web Publishing.
FileMaker can provide data in XML format in two ways: via the Export As XML feature in the regular FileMaker client, and via URL-based access requests sent directly to databases hosted via FileMaker Server Advanced.
A URL designed to extract data from FileMaker Server Advanced has two components: a resource name, and a query string. This section demonstrates the correct syntax for resource names within a URL. The query string is made up of potentially many commands and parameters: later sections of this chapter discuss those in more detail.
For more information on the structure of query requests, see “Query Parameters for XML/XSLT URL Requests,” later in this chapter.
In order to extract data from FileMaker Server Advanced in XML format, a URL of the following form is used:
<protocol>://<host>[:<port>]/fmi/xml/<grammar>.xml?<query string>
<protocol>
is either http (for regular HTTP access) or https (for secure HTTP access).<host>
is the hostname or the IP address of the web server that’s been configured with FileMaker Server Advanced. (Note that if the web server is on a machine other than the FileMaker Server, it’s the address of the web server that must be used here, not that of the FileMaker Server machine.)<port>
need only be specified if the web server has been configured to run on a port other than the default for the specified protocol (80 for HTTP, 443 for HTTPS).<grammar>
is the name of one of the four valid FileMaker XML grammars, discussed in the next section.<query string>
is a query string composed of some number of query parameters in combination with a query command. Specifics are discussed in upcoming sections.Example:
http://my.filemakerserver.net:8080/fmi/xml/fmresultset.xml?-dbnames
This query will access a server running on port 8080 on the machine my.filemakerserver.net, and will request a list of all databases available for XML access on that server, with the results returned in the fmresultset
grammar.
FileMaker Server Advanced has a special URL syntax for accessing data in container fields. Such a request will cause the container data to be returned directly (much like clicking on a PDF link in a web page). The exact mechanism depends on whether the container data is stored directly in the database, or stored by reference. In order to extract container data stored directly in a FileMaker database, a URL of the following form is used:
<protocol>://<host>[:<port>]/fmi/xml/cnt/data.<extension>?<query string>
<protocol>
, <host>
, <port>
, and <query string>
are as described in the previous section.<extension>
is the file type extension for the container data being fetched (.jpg, .txt, and the like). This extension allows the web server to set the MIME type of the data correctly.The query string must contain a –field
query parameter with a fully qualified field name, meaning it must contain a repetition index number reference even if the field is not a repeating field.
Example:
This URL will extract container data from a specific field (called photo) from the record with recid=303. Even though photo is not a repeating field, the syntax photo[1]
is still necessary. The web server will return this container data as GIF data, assuming the .gif suffix is correctly mapped to the TIFF MIME type on the server.
For information on how to manage container data when the container data is stored only by reference, please see the FileMaker Server Custom Web Publishing Documentation.
When extracting XML data from FileMaker Server Advanced, it’s also possible to apply an XSLT stylesheet in order to transform the XML into something else, such as an HTML page. The syntax for XSLT access is as follows:
<protocol>://<host>[:<port>]/fmi/xsl/<path>/<stylesheet>.xsl?<query string>
<protocol>
, <host>
, <port>
, and <query string>
are as described in the previous sections.<path>
element is optional. Without it, the Web Publishing engine will look for the specified stylesheet within the xslt-template-files directory on the web server. If you wish to create additional directory structures within the xslt-template-files folder, the relative path to the stylesheet must be specified here.<stylesheet>
is the name of the stylesheet that will be applied to the XML data.Example:
FileMaker can publish data in any of four XML “grammars.” Note that the grammar names are case sensitive.
Following is a sample of each grammar.
The FileMaker Web Publishing Engine delivers XML data in response to specially formatted URLs. The specific details of the request are contained in the query string, which is a specific portion of the URL. For example, the query string is highlighted in the following URL:
The query string consists of a series of name-value pairs, of the form name=value, separated by ampersands, and following a question mark within the URL.
Generally, a query string intended for the Web Publishing Engine consists of a single query command, representing the type of request being made, supported by additional query parameters that add specificity to the request. In the preceding example, the request is –findall
(find all records). Additional query parameters specify the database, the layout, and the maximum number of records to be returned.
Please note the following important points about URL queries.
...&-findall=somevalue
, but the =somevalue
will be ignored.)This section lists the possible query commands. If the command requires certain specific additional parameters, those are listed.
FileMaker’s XML and XSLT publishing technologies use a number of XML namespaces. Each of the four XML grammars has its own namespace. In addition, a number of the XSLT features of Custom Web Publishing have their own namespaces as well. You generally only need to concern yourself with namespaces if you are writing XSLT stylesheets that transform FileMaker XML data.
Table 15.1 lists each namespace, along with its significance, and the conventional namespace prefix used to abbreviate it. The prefix is “conventional” in the sense that, in creating a stylesheet, you may choose any prefix you want for a namespace, but the ones listed below are those used by FileMaker, Inc., in the official documentation.
Table 15.1. Namespace Usage and Prefixes
(*) Since the FMPDSORESULT grammar is deprecated, FileMaker makes no recommendation for a default prefix.