http://www.zorba-xquery.com/modules/xsl-fo ZC

Module Description
Before using any of the functions below please remember to import the module namespace:
import module namespace xsl-fo = "http://www.zorba-xquery.com/modules/xsl-fo";

This module converts XSL-FO documents to various formats such as PDF, EPS, PCL, AFP, Text, PNG, Postscript, RTF, and TIFF. For instance, the following example converts a simple XSL-FO document to PDF:

 import module namespace fop = "http://www.zorba-xquery.com/modules/xsl-fo";
 import module namespace file = "http://expath.org/ns/file";
 declare namespace fo = "http://www.w3.org/1999/XSL/Format";
 let $xsl-fo := 
              
                
                  
                
              
              
                
                  Hello, world!
                
              
            
 let $pdf := fop:generator($fop:PDF, $xsl-fo)
 return file:write-binary("simple.pdf", $pdf)
 

This module uses Apache-FOP to generate content from an XSL-FO document. See the Apache FOP documentation for further information.

Note for Windows users: On Windows, this module won't work out of the box, since this module uses Java. But the Java VM dll is not in the system path by default. To make this module work, you need to add the directory where the jvm.dll is located to the system path. This dll is located at JRE_DIR\bin\client. On a standard installation, this would be something a path like "C:\Program Files\Java\jre6\bin\client".

Author:

Markus Pilman

XQuery version and encoding for this module:

xquery version "3.0" encoding "utf-8";

Module Resources
  • the XQuery module can be found here.
Module Dependencies

External C++ library dependencies:

Related Documentation

For more details please also see:

Namespaces
err http://www.w3.org/2005/xqt-errors
ver http://www.zorba-xquery.com/options/versioning
xsl-fo http://www.zorba-xquery.com/modules/xsl-fo
Variables
$xsl-fo:AFP as xs:string
The mime type of IBMs AFP format (application/x-afp).
$xsl-fo:EPS as xs:string
The mime type of the EPS format (application/postscript).
$xsl-fo:PCL as xs:string
The mime type of the PCL format (application/x-pcl).
$xsl-fo:PDF as xs:string
The mime type of the PDF format (application/pdf).
$xsl-fo:PLAIN_TEXT as xs:string
The mime type for plain text files (text/plain).
$xsl-fo:PNG as xs:string
The mime type of the PNG format (image/png).
$xsl-fo:POSTSCRIPT as xs:string
The mime type of the postscript format (application/postscript).
$xsl-fo:RTF as xs:string
The mime type of the RTF format (application/rtf).
$xsl-fo:TIFF as xs:string
The mime type of TIFF format (application/tiff).
Function Summary
generator ( $output-format as xs:string, $xsl-fo-document as node() ) as xs:base64Binary
The function behaves like generator#3, but tries to find the needed Java libraries itself.
generator ( $output-format as xs:string, $xsl-fo-document as node(), $classpath as xs:string+ ) as xs:base64Binary
The generator function takes an XSL-FO document as input and generates output in the format given as input.
Functions
generator back to 'Function Summary'
declare function xsl-fo:generator (
            $output-format as xs:string, 
            $xsl-fo-document as node() 
 ) as xs:base64Binary

The function behaves like generator#3, but tries to find the needed Java libraries itself.
On a Mac OS X computer, it should be sufficient to install Apache FOP via Mac Ports.
On Ubuntu it should be sufficient to install the fop packages via apt-get.
On Windows, the classpath needs to be set manually using generator#3.
This function tries to find the jar files via environment variables. The user can set the variable FOP_HOME to the root directory of an Apache FOP distribution. If you have all JAR files in the same directory, you can set the environment variable FOP_LIB_DIR to this directory.

Parameters:
  • $output-format The mime of the output format, to tell Apache FOP which kind of document it should create.
  • $xsl-fo-document The XSL-FO document from which the output should be generated.
Returns:
  • The generated output document.
Errors:
  • xsl-fo:VM001 If zorba was unable to start the JVM.
  • xsl-fo:JAVA-EXCEPTION If Apache FOP throws an exception - i.e. if the input format is not correct/supported.
  • xsl-fo:JAR-NOT-FOUND If a needed Java library could not be found.

generator back to 'Function Summary'
declare function xsl-fo:generator (
            $output-format as xs:string, 
            $xsl-fo-document as node(), 
            $classpath as xs:string+ 
 ) as xs:base64Binary

The generator function takes an XSL-FO document as input and generates output in the format given as input. The output format can be given as a MIME type - for example "application/pdf" - or one of the predefined variables can be used - like $xsl-fo:PDF. Please refer to the Apache FOP documentation for supported output formats. Apache FOP does not support 100% of the XSL-FO standard. Please consult the official documentation for further information.

Parameters:
  • $output-format The mime of the output format.
  • $xsl-fo-document The XSL-FO document from which the output should be generated. More information about XSL-FO documents..
  • $classpath The classpath which has to contain Apache FOP and all its dependencies. If you don't want to set this programmatically, use the generator function without this parameter instead.
Returns:
  • The generated output document.
Errors:
  • xsl-fo:VM001 If zorba was unable to start the JVM.
  • xsl-fo:JAVA-EXCEPTION If Apache FOP throws an exception - i.e. if the input format is not correct/supported.

blog comments powered by Disqus