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:replace">
   <p:input port="source" primary="true"/>
   <p:input port="replacement"/>
   <p:output port="result"/>
   <p:option name="match" required="true"/> <!-- XSLTMatchPattern -->

The <p:replace> step replaces the contents which come from the “source“ input port by the contents which are indicated at the “replacement“ input port. The position where the replacement shall be performed is determined by a XSLT expression in the “match“ option. The result of this process is outputted at the output port (“result“).


In the following example an “LeadingActor“ element is replaced by a new one in a “Film“ element.

<?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"/>
   <p:replace match="/FilmCollection/Film[1]/Cast[1]/LeadingActor[1]">
      <p:input port="replacement">
            <LeadingActor>Carrie Fisher</LeadingActor>

In the example the entry <LeadingActor>Mark Hamill</LeadingActor> is now replaced by the new entry <LeadingActor>Carrie Fisher</LeadingActor> because the XSLT expression is clearly defined.