diff --git a/src/main/xar-resources/data/documentation/documentation.xml b/src/main/xar-resources/data/documentation/documentation.xml index a04408be..cd3192ac 100644 --- a/src/main/xar-resources/data/documentation/documentation.xml +++ b/src/main/xar-resources/data/documentation/documentation.xml @@ -229,6 +229,14 @@ How to perform XSL Transformation with XQuery. + + + FO Rendering + + + How to perform FO (Formatting Objects) Rendering with XQuery. + + Indexing diff --git a/src/main/xar-resources/data/fo-render/fo-render.xml b/src/main/xar-resources/data/fo-render/fo-render.xml new file mode 100644 index 00000000..5904eb05 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/fo-render.xml @@ -0,0 +1,193 @@ + + +
+ + FO Rendering + 1Q22 + + application-development + + + + + + eXist-db can perform FO (Formatting Objects) rendering inside XQuery code. The FO can be + generated used XSL (i.e. XSL:FO) if desired. For this you need to use the xslfo + module. + + + + + The <code>xslfo</code> module + + eXist-db XSL:FO module allows you to do FO rendering from XQuery code using an appropriate + FO Renderer; eXist-db supports Apache FOP and RenderX XEP. Previously there was also support + for AntennaHouse, but that was removed as it was unmaintained, we would welcome a new + contribution to support AntennaHouse again. + Selection of the renderer is configured in eXist-db's conf.xml file. + By default eXist-db ships with and is configured to use Apache FOP, see: Using + the Apache FOP Renderer + If you wish to use RenderX XEP instead, see Using + the RenderX XEP FO Renderer. + Its function namespace is http://exist-db.org/xquery/xslfo. + + + + + + <code>xslfo:render()</code> + + + The xslfo:render function renders an FO document and returns you the result. + It has two signatures: + + + + + + + $document + + + The FO document to be rendered. + + + + + $media-type + + + The Internet Media Type of the desired result. This provides a hint to the renderer as to what format it should render + + + + + $parameters + + + Specify any optional parameters for the rendering of the FO document, these are processor specific. + + + + $processor-config + + An optional configuration document for the processor, this is processor specific. + + + + + + + + + + <code>Streaming the result to a Web Browser</code> + + + If you wish to Stream the result of xslfo:render directly to the Web Browser (i.e. HTTP Response), you + can send the output of xslfo:render directly to the function response:stream-binary. This can be + useful for example when you want an XQuery to download a PDF directly to the Web Browser. + + + + + + Using the Apache FOP Renderer + By default eXist-db ships with and is configured to use Apache FOP. It is configured in eXist-db's conf.xml file through the following configuration option: + + +]]> + + An example of using Apache FOP to transform FO and save the result to a PDF file in the database. + + + Using Apache FOP from XQuery + + + + + + + Using the RenderX XEP FO Renderer + To configure eXist-db to use RenderX XEP instead of Apache FOP, follow these steps: + + + From a RenderX distribution, copy the files lib/xep.jar and lib/xt.jar into the folder $EXIST_HOME/lib. + + + eXist-db uses a number of configuration files, one per script, to determine which jar files to load. You should edit the XML files in the folder $EXIST_HOME/etc to add the following configuration (adjust the version numbers appropriately): + +com.renderx.xep +xep +4.30.961 +xep.jar + + +com.renderx.xep.thirdparty.com.jclark.xsl +xt +4.30.961 +xt.jar +]]> + + + Create the folder $EXIST_HOME/renderx + + + From a RenderX distribution, copy the files xep.xml and rolemap.xml, and the folders fonts, hyphen, and images into the folder $EXIST_HOME/renderx. + + + Edit the file $EXIST_HOME/renderx/xep.xml to make the following changes: + + + From:]]> + To:]]> + + + From: + + To: + + + + From: ]]> + To: ]]> + + + From: ]]> + To: ]]> + + + + + Copy your RenderX XEP license file (license.xml) that you have been provided by RenderX into $EXIST_HOME/renderx. + + + Edit the file $EXIST_HOME/conf.xml to make the following changes: + From: + +]]> + To: + +]]> + + + If eXist-db was running whilst you were making these changes, then you will need to restart it for the change to take effect. + + + + An example of using RenderX XEP to transform FO and save the result to a PDF file on the filesystem. + + + Using RenderX XEP from XQuery + + + + + + + +
diff --git a/src/main/xar-resources/data/fo-render/listings/listing-1.txt b/src/main/xar-resources/data/fo-render/listings/listing-1.txt new file mode 100644 index 00000000..2538985d --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-1.txt @@ -0,0 +1 @@ +xslfo:render($document as node(), $media-type as xs:string, $parameters as node()?) as xs:base64Binary diff --git a/src/main/xar-resources/data/fo-render/listings/listing-10.xml b/src/main/xar-resources/data/fo-render/listings/listing-10.xml new file mode 100644 index 00000000..0b9f49ba --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-10.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-11.xml b/src/main/xar-resources/data/fo-render/listings/listing-11.xml new file mode 100644 index 00000000..edfb42ca --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-11.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-12.xml b/src/main/xar-resources/data/fo-render/listings/listing-12.xml new file mode 100644 index 00000000..6dc9953d --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-12.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-13.xml b/src/main/xar-resources/data/fo-render/listings/listing-13.xml new file mode 100644 index 00000000..d2f43c0b --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-13.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-14.xml b/src/main/xar-resources/data/fo-render/listings/listing-14.xml new file mode 100644 index 00000000..d6fa1a64 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-14.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-15.xml b/src/main/xar-resources/data/fo-render/listings/listing-15.xml new file mode 100644 index 00000000..2f322fd4 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-15.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-16.txt b/src/main/xar-resources/data/fo-render/listings/listing-16.txt new file mode 100644 index 00000000..44a347e5 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-16.txt @@ -0,0 +1,13 @@ +xquery version "3.0"; + +declare namespace file = "http://exist-db.org/xquery/file"; +declare namespace system = "http://exist-db.org/xquery/system"; +declare namespace xslfo = "http://exist-db.org/xquery/xslfo"; + +let $config := fn:parse-xml(file:read(system:get-exist-home() || "/renderx/xep.xml")) +return + + let $fo := fn:doc('/db/test-fo.xml') + let $pdf := xslfo:render($fo, "application/pdf", (), $config) + return + file:serialize-binary($pdf, "/tmp/fop.pdf") \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-2.txt b/src/main/xar-resources/data/fo-render/listings/listing-2.txt new file mode 100644 index 00000000..a10292c0 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-2.txt @@ -0,0 +1 @@ +xslfo:render($document as node(), $media-type as xs:string, $parameters as node()?, $processor-config as node()?) as xs:base64Binary \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-3.xml b/src/main/xar-resources/data/fo-render/listings/listing-3.xml new file mode 100644 index 00000000..fdb53de8 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-3.xml @@ -0,0 +1,3 @@ + + + diff --git a/src/main/xar-resources/data/fo-render/listings/listing-4.txt b/src/main/xar-resources/data/fo-render/listings/listing-4.txt new file mode 100644 index 00000000..ea09dacc --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-4.txt @@ -0,0 +1,10 @@ +xquery version "1.0"; + +declare namespace file = "http://exist-db.org/xquery/file"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; +declare namespace xslfo = "http://exist-db.org/xquery/xslfo"; + +let $fo := fn:doc('/db/test-fo.xml') +let $pdf := xslfo:render($fo, "application/pdf", (), ()) +return + xmldb:store("/db", "result.pdf", $pdf, "application/pdf") \ No newline at end of file diff --git a/src/main/xar-resources/data/fo-render/listings/listing-5.xml b/src/main/xar-resources/data/fo-render/listings/listing-5.xml new file mode 100644 index 00000000..46f67ae3 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-5.xml @@ -0,0 +1,12 @@ + + com.renderx.xep + xep + 4.30.961 + xep.jar + + + com.renderx.xep.thirdparty.com.jclark.xsl + xt + 4.30.961 + xt.jar + diff --git a/src/main/xar-resources/data/fo-render/listings/listing-6.xml b/src/main/xar-resources/data/fo-render/listings/listing-6.xml new file mode 100644 index 00000000..e6a6c455 --- /dev/null +++ b/src/main/xar-resources/data/fo-render/listings/listing-6.xml @@ -0,0 +1 @@ +