p:xsl-formatter (3.0) 

Renders an XSL-FO document.

Summary

<p:declare-step type="p:xsl-formatter">
  <input port="source" primary="true" content-types="xml" sequence="false"/>
  <output port="result" primary="true" content-types="any" sequence="false"/>
  <option name="content-type" as="xs:string?" required="false" select="()"/>
  <option name="parameters" as="map(xs:QName,item()*)?" required="false" select="()"/>
</p:declare-step>

The p:xsl-formatter step expects a valid XSL-FO document on its source port. This is rendered, usually into PDF. The resulting rendition appears, as a binary document, on the result port.

Ports:

Port

Type

Primary?

Content types

Seq?

Description

source

input

true

xml

false

The XSL-FO document to render.

result

output

true

any

false

The resulting rendition.

Options:

Name

Type

Req?

Default

Description

content-type

xs:string?

false

()

The content-type (media type) of the rendition that appears on the result port. The default value is application/pdf. Whether any other formats are supported is implementation-defined and therefore dependent on the XProc processor and renderer used.

parameters

map(xs:QName,item()*)?

false

()

Parameters used to control the rendering. The XProc specification does not define any parameters for this option. A specific XProc processor (or renderer used) might define its own.

Description

The p:xsl-formatter step allows you to transform XML into some kind of rendition, usually PDF. To do this, you must first transform your XML into XSL-FO. This can be done by several means, most likely one or more XSLT transformations by p:xslt. After this, the p:xsl-formatter step renders the document for you.

In most cases, p:xsl-formatter relies on an external XSL-FO formatter, for instance the open source FOP or one of the commercial ones. You’ll probably have to do some XProc processor dependent configuration before this step will work. Please consult the XProc processor documentation about this.

Examples

Basic usage

The following pipeline transforms an XSL-FO document into PDF using p:xsl-formatter, and stores it as result.pdf:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">

  <p:input port="source"/>
  <p:output port="result" pipe="result-uri@store-pdf"/>

  <p:xsl-formatter/>
  <p:store href="result.pdf" name="store-pdf"/>

</p:declare-step>

Additional details

  • The document appearing on the result port only has a content-type property. It has no other document-properties (also no base-uri).

Errors raised

Error code

Description

XC0167

It is a dynamic error if the requested document cannot be produced.

XC0204

It is a dynamic error if the requested content-type is not supported.

XD0079

It is a dynamic error if a supplied content-type is not a valid media type of the form “type/subtype+ext” or “type/subtype”.

Reference information

This description of the p:xsl-formatter step is for XProc version: 3.0. This is a non-required step (an XProc 3.0 processor does not have to support this).

The formal specification for the p:xsl-formatter step can be found here.

The p:xsl-formatter step is part of categories:

The p:xsl-formatter step is also present in version: 3.1.