
Makes HTML documents “standalone”.
To use the exc:standalone step, declare the exc: prefix
for http://exproc.org/ns/contrib and add the following import
to your pipeline:
<p:import href="https://exproc.org/contrib/ndw/standalone/1.0.0.xpl"/>
sourceresult<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:ex="http://exproc.org/ns/contrib"
type="ex:standalone"
name="main" version="3.1">
<p:input port="source" content-types="xml html"/>
<p:output port="result" content-types="xml html"/>
<p:viewport name="vphref" match="h:link[@href and @rel='stylesheet']">
<p:load href="{resolve-uri(h:link/@href, base-uri(.))}"/>
<p:encode name="encoded"/>
<p:set-attributes>
<p:with-input pipe="@vphref"/>
<p:with-option name="attributes"
select="map{'href': 'data:text/css;base64,' || .}">
<p:pipe step="encoded"/>
</p:with-option>
</p:set-attributes>
</p:viewport>
<p:viewport name="vpsrc" match="h:img[@src] | h:script[@src]">
<p:load href="{resolve-uri(*/@src, base-uri(.))}"/>
<p:variable name="ctype" select="p:document-property(., 'content-type')"/>
<p:encode name="encoded"/>
<p:set-attributes>
<p:with-input pipe="@vpsrc"/>
<p:with-option name="attributes"
select="map{'src': 'data:' || $ctype || ';base64,' || .}">
<p:pipe step="encoded"/>
</p:with-option>
</p:set-attributes>
</p:viewport>
</p:declare-step>
This pipeline makes HTML documents “standalone”. It
uses base64 encoding and data: URIs to inline
images, scripts, and CSS stylesheets.