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:input> <p:output port="result" sequence="true"/> <p:filter select="/FilmCollection/Film/Title"/> </p:declare-step>
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> <Title>Eraserhead</Title> <Title>Unforgiven</Title>