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:insert">
   <p:input port="source" primary="true"/>
   <p:input port="insertion" sequence="true"/>
   <p:output port="result"/>
   <p:option name="match" select="'/*'"/> <!-- XSLTMatchPattern -->
   <p:option name="position" required="true"/> <!-- "first-child" | "last-child" | "before" | "after" -->

With the help of the <p:insert> step, contents (e.g. XML documents) can be inserted into a document into a position which is determined by the user. The desired contents are indicated at the appropriate input port (“insertion“) and the document concerned is indicated anlogously at a further input port (“source“). The output occurs via the output port (“result“). With the help of the “match“ option, the user can define a XSLT expression which indicates at which position in the concerned document the content shall be written. This indication can be refined by the “position“ option. Since the XSLT expression can only describe one element or attribute when using “match“, it is also possible to indicate at which position the desired contents shall be set by using “first-child“, “last-child“, “before“ and “after“.


A further film shall be added to the known example file (“FilmCollection.xml“).

<?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:insert match="/FilmCollection/Film[3]" position="before">
      <p:input port="insertion">
         <p:inline exclude-inline-prefixes="#all">
              <Title>Star Wars: Episode V - The Empire Strikes Back</Title>
               <Director>Irvin Kershner</Director>
               <Producer>George Lucas</Producer>
                  <LeadingActor>Mark Hamill</LeadingActor>
                  <LeadingActor>Harrison Ford</LeadingActor>
               <Duration>124 min</Duration>
               <Author>George Lucas</Author>

In the example the XSLT expression in “match“ and the indication in “position“ determine that the new “Film“ element generated in <p:inline> shall be placed before the third “Film“ element in the input document.