p:css-formatter (3.1) 

Renders a document using CSS formating.

Summary

<p:declare-step type="p:css-formatter">
  <input port="source" primary="true" content-types="xml html" sequence="false"/>
  <output port="result" primary="true" content-types="any" sequence="false"/>
  <input port="stylesheet" primary="false" content-types="text" sequence="true">
    <p:empty/>
  <input/>
  <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:css-formatter step renders an XML or HTML document using CSS formatting, usually into PDF. The CSS stylesheets for this must be present on the stylesheet port. The resulting rendition appears, as a binary document, on the result port.

Ports:

Port

Type

Primary?

Content types

Seq?

Description

source

input

true

xml html

false

The XML or HTML document to render.

result

output

true

any

false

The resulting rendition.

stylesheet

input

false

text

true

The CSS stylesheets to use for the rendering.

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.

This option may include media type parameters as well (for instance application/pdf; charset=UTF-8).

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:css-formatter step allows you to transform XML or HTML into some kind of rendition, usually PDF, by applying CSS formatting. Most likely, CSS Paged Media will be used.

In most cases, p:css-formatter relies on an external CSS formatter. 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 some XML document into PDF using p:css-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:css-formatter content-type="application/pdf">
    <p:with-input port="stylesheet" href="my-paged-media-stylesheet.css"/>
  </p:css-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

XC0166

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:css-formatter step is for XProc version: 3.1. This is a non-required step (an XProc 3.1 processor does not have to support this).

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

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

The p:css-formatter step is also present in version: 3.0.