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:error

<p:declare-step type="p:error">
   <p:input port="source" primary="false"/>
   <p:output port="result" sequence="true"/>
   <p:option  required="true"/> <!-- QName -->
   <p:option name="code-prefix"/> <!-- NCName -->
   <p:option name="code-namespace"/> <!-- anyURI -->
</p:declare-step>
 

With the help of the <p:error> step, user-defined (dynamic) error outputs can be generated. For example, it makes sense when using decision-based steps such as <p:choose>. At its (not primary) input port the appropriate error ouput is defined and outputted at the output port (“result“). With the help of the three options “code-prefix“, “code“ and “code-namespace“ the user can mark the error accordingly. In this way, a prefix can be defined in addition to a namespace in order to realise a reasonable output of the error.

Example

Here, a simple error output is demonstrated.

<?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:output port="result"/>
   <p:error code="error" code-namespace="http://www.example.de/error" code-prefix="tg">
      <p:input port="source">
         <p:inline>
            <message>An error has occurred...</message>
         </p:inline>
       </p:input>
    </p:error>
</p:declare-step>

The Calabash processor shows the following output:

tg:error : An error has occurred...