Previous Up Next


p:make-absolute-uris

p:make-absolute-uris — Resolves relative URIs to absolute URIs in the source document.

Synopsis

<p:declare-step type="p:make-absolute-uris">
     <p:input port="source"/>
     <p:output port="result"/>
     <p:option name="match" required="true"/>                      <!-- XSLTMatchPattern -->
     <p:option name="base-uri"/>                                   <!-- anyURI -->
</p:declare-step>

Description

The p:make-absolute-uris expands relative URIs in the matched node into absolute URIs. If an explicit base-uri is specified, then the relative URIs are made absolute against that base, otherwise they are made absolute relative to the base URI in scope where they occur.

The value of the base-uri is interpreted as an IRI reference. If the option value is relative, it is made absolute with respect to the in-scope base URI where the option occurs.

If the IRI reference specified by the base-uri option on p:make-absolute-uris is not valid, or if it is absent and the input document has no base URI, the results are implementation-dependent.

Errors

Error Description
err:C0023 Occurs if the pattern matches anything other than element or attribute nodes.

Examples

In the following example, the href attribute is made absolute:

  1 <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
                version="1.0">
    
      <p:make-absolute-uris match="@href"/>
  5 </p:pipeline>
Input Output
1 <doc>
<link href="../test.xml"/>
<div xml:base="http://example.com/path/">
<link href="relative.xml"/>
5 </div>
</doc>
 
1 <doc>
<link href="file:/projects/xproc/src/core/test.xml"/>
<div xml:base="http://example.com/path/">
<link href="http://example.com/path/relative.xml"/>
5 </div>
</doc>

In this example, we specify an explicit base URI.

  1 <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
                version="1.0">
    
      <p:make-absolute-uris match="@href"
  5                         base-uri="file:///absolute/path/"/>
    </p:pipeline>
Input Output
1 <doc>
<link href="../test.xml"/>
<div xml:base="http://example.com/path/">
<link href="relative.xml"/>
5 </div>
</doc>
 
1 <doc>
<link href="file:/absolute/test.xml"/>
<div xml:base="http://example.com/path/">
<link href="file:/absolute/path/relative.xml"/>
5 </div>
</doc>