Sunday, December 9, 2007

Extensible Stylesheet Language (XSL) and FileMaker

XSL is XML

XSL documents are written with rules and recommendations that follow the structure of well-formed and valid XML documents. If you open an XSL document with a text editor, you will see the familiar tree-like structure of XML with start, end, and empty markup tags. The transformations that are performed by the Extensible Stylesheet Language can be used to create XML documents, as well as other document formats.

Namespaces in FileMaker Pro 6

The XML that results from a query to a web-published FileMaker Pro database with the -format parameter includes the namespace declaration. Each of the three schema types has a different namespace:

  • -format=-fmp_xml&-view

  • -format=-fmp_xml&-find

  • -format=-fmp_dso&-find



Stylesheet Instruction in XML Documents

The XML information for a database file in the Database Design Report contains the prolog . The second line in the report is a processing instruction specifying the stylesheet to be used with the document:

The processing instruction xml-stylesheet has six attributes. The type attribute is required. If the stylesheet is XSL, the type attribute will have the value "text/xsl". The Cascading Style Sheet has a type attribute value of "text/css". The href attribute is also required in the xml-stylesheet processing instruction. The href attribute may be a relative or absolute URI path to the stylesheet document. Just like the hyperlink reference in HTML, this URI is not a namespace declaration, but the real location to the document. The href can be a fragment path, thus allowing the stylesheet to be a part of the XML document:

The examples also use JavaScript and the Document Object Model (DOM) to present the XML published by Web Companion. Only the Windows version of Internet Explorer 5 or greater will work properly with the examples. The JavaScript calls ActiveX, which only works on the Windows operating system.

Repeating Elements

The template can be used to set a rule for every element in the source tree. Another element can be used within the template to repeat a rule. This element is and is never an empty element. The only attribute for this element is select, which has the value of an XPath expression. The element can be used with to sort the source elements before returning to the results tree. Literal text, other elements, and rules can be used between the start and end elements of this element just as for the templates. The following template will return all the field names from the FMPXMLRESULT grammar:


No comments: