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

With the help of the <p:set-attributes> step, elements of the source document (at the “source“ input port) can be extended with attributes. The attributes are defined at the “attributes“ input port. The XSLT expression within the “match“ option indicates where the attributes shall be placed in the source document. In the event that there are already identical attributes in the source document, the value being determined within the “attributes“ input port is passed on to this attribute. The result is outputted at the output port (“result“).


In the following example all “Director“ elements shall get a “gender“ attribute with the value “Male“.

<?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:set-attributes match="/FilmCollection/Film/Director">
      <p:input port="attributes">
            <Director gender="Male"></Director>

The indication of the attribute is generated by <p:inline> in the “attributes“ port. The result of this process is as follows (excerpt):

  <Director gender="Male">George Lucas</Director>