Structured/XML Authoring Post #2: More XML power with FrameMaker 11- XSLT and XPath
Hope you are well. This is the second post in the structured/XML blog series on FrameMaker 11. Today, I will be discussing the support for additional XML tools that we have provided in the new release. In the XML code view, you will find options for XPath and XSLT. In this post, you will find a quick overview of these popular XML tools, followed by details on the functionality provided on these in FrameMaker 11.
XSLT is a World Wide Web Consortium (W3C) standard and is part of the XSL (EXtensible Stylesheet Language) family of languages, which also includes XPath and XSL-FO. XSL is used to style XML documents and also used to transform XML content (e.g. to HTML, which can then be viewed in a browser or to another XML). XSLT uses XPath expressions to find and match elements which then can be transformed. In addition, XSLT can be used as an automation tool.
XSLT 2.0 support in FrameMaker 11
In FrameMaker 11, we have provided XSLT 2.0 support. You can now run XSLT from within FrameMaker 11 interface (you have to be in the XML code view to access the XSLT functionality). You can run XSLT through the XSLT toolbar by simply browsing to an XSL or through the advanced run option, through which you can define the scope for the run (i.e. whether you want the XSLT to run on the current file, all open files or on a folder containing XML files). In addition, you can also choose a pre-defined transformation when running your XSLT.
Define and store XSL transformations
Since you may want to run the same transformation on different XML files, we are letting you create and store transformations. In a transformation, you can specify which XSL file to use, the XSL processor, where do you want the output to be saved and which program you want to open the output file in. In addition, you can configure xsl parameters through Stylesheet Parameters dialog. See the screenshot on the right to see how to create and store new transformations.
Choose your own XSLT processor
FrameMaker 11 ships with two popular XSL processors – Saxon and Xalan-j. These processors are configured and are available to you for choosing when you are creating your transformation. However, you can also configure your own processor as long as it is JAXP compliant processor.
Different types of transformation
You can store your transformations in three different types of files. You can access and manage these transformations using with the XSLT > Manage Transformations menu.
- Default: These are global transformations and are available for all XML files. This file contains some sample XSLT that FrameMaker 11 ships with. The transformation definitions are themselves contained in in an XML file, the path of which can be seen when you click the Edit button
- Structure application specific: As the name suggests, these belong to application definition provided in structapps.fm and are available only when an XML file opened with that particular structured application (e.g. DITA 1.2 topic)
- Transformation file: This is a user created and stored transformation file. You can easily share this transformation and associated XSL files with any other user.
Advanced run dialog
The advanced run box has more options for the user when running the XSLT. It lets you define the scope of running the transformation and also, choose an XSL file or a pre-defined transformation to run the XSLT with.
Please watch the videos below see how to run XSL transformations in FrameMaker 11.
FrameMaker 11: XSLT 2.0 support
FrameMaker 11: Managing XSL transformations
As mentioned above, XPath is also part of the XSL family of languages and is used to navigate XML documents through elements and attributes. With XPath, you can write expressions to look for elements which meet certain conditions (e.g. find all books where the style attribute matches a certain value). XPath expressions are used when writing XSL transformations to navigate and match certain elements.
XPath 2.0 support in FrameMaker 11
In FrameMaker 11, you can run XPath expressions through 2 ways. You have to be in the XML code view to access the XPath functionality.
- Xpath toolbar has a textbox for you to quickly type an XPath expression and run it (includes a drop-down for selecting from the previous 15 XPath queries)
- XPath query builder (View > Pods > XPath) is a powerful panel, which has the following main features (see screenshot on the right)
- Auto-Suggest feature will suggest elements and attributes as you type your expression
- You can define scope of your search (current file, all open files, book or DITAmap, folder)
- Comprehensive results pane will show you a navigable list of results from your XPath expression, along with other useful information like location of the result and the filename etc.
See the video below to see XPath in action in FrameMaker 11:
Additional Information on XPATH
Here are some additional resources on XSLT and XPath for you to learn more.
- 5 part eSeminar series on “How to write XSLT statements” from Tom Aldous is available here
- Lynne Price’s eSeminar on how to use structured FrameMaker application for editing XSLT can be found here (scroll down to the entry titled “Maintaining XSLT code as a structured FrameMaker document”)
- W3C school tutorials on XSLT and XPath
Until the next post then …
Sr. Product Manager, FrameMaker and FrameMaker Publishing Server