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:add-xml-base

<p:declare-step type="p:add-xml-base">
   <p:input port="source"/>
   <p:output port="result"/>
   <p:option name="all" select="'false'"/> <!-- boolean -->
   <p:option name="relative" select="'true'"/> <!-- boolean -->
</p:declare-step>

The <p:add-xml-base> step adds an attribute called “xml:base“ to the root element of the underlying document and outputs it at the output port (“result“). As a value the attribute contains the path in the file system to the file originally read in at the input port (“source“). If the Boolean option “all“ is set to “true“, the “xml:base“ attribute will be written into each element in the input document. If “relative“ is set to “true“, the path indication is displayed relatively in the respective “xml:base“ attribute, in case other elements already have a “xml:base“ attribute with another path indication as the one of the root element. Only one of both options at a time can be set to “true“, otherwise the processor outputs a dynamic error.

Example

In this example, only a <p:identity> step is performed, but with a prepended <p:add-xml-base> step.

<?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"/>
   <p:add-xml-base/>
   <p:identity/>
</p:declare-step>

The result of this procedure is as follows (excerpt):

<FilmCollection xml:base="file:/Users/tg/Documents/XProc/SourceCodes/FilmCollection.xml">
   <Film>
      <Title>Star Wars: Episode IV - A New Hope</Title>
      <Year>1978</Year>
      <Genre>SciFi</Genre>
 [...]