XProc steps

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z


<p:declare-step type="p:filter">
   <p:input port="source"/>
   <p:output port="result" sequence="true"/>
   <p:option name="select" required="true"/> <!-- XPathExpression -->

The filter port has basically the same functionality as the input port. The crucial difference is that the content to be read in can be precisely defined and filtered by the appropriate XPath expression.


In the following example any title elements are filtered out from the input document.

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
   <p:input port="source">
      <p:document href="FilmCollection.xml"/>
   <p:output port="result" sequence="true"/>
   <p:filter select="/FilmCollection/Film/Title"/>

In the “select“ attribute, the XPath expression is indicated. The Boolean value in the “sequence“ href attribute of <p:output> should be set to “true“ since XPath expressions normally produce several output documents (for each match one document).

The following output is produced by the XProc processor:

<Title>Star Wars: Episode IV - A New Hope</Title>