Skip to content

Instantly share code, notes, and snippets.

@rdeltour
Created December 24, 2014 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdeltour/0bb718ba4ed490be2b77 to your computer and use it in GitHub Desktop.
Save rdeltour/0bb718ba4ed490be2b77 to your computer and use it in GitHub Desktop.
Test XProc file for I/O-related steps
<?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"
xmlns:pxf="http://exproc.org/proposed/steps/file" xmlns:pxp="http://exproc.org/proposed/steps" version="1.0">
<p:output port="result" sequence="true">
<p:pipe port="result" step="load"/>
<p:pipe port="result" step="http"/>
<p:pipe port="result" step="copy"/>
<p:pipe port="result" step="info"/>
<p:pipe port="result" step="tempfile"/>
<p:pipe port="result" step="zip"/>
</p:output>
<p:option name="uri" select="resolve-uri('')"/>
<p:serialization port="result" indent="true"/>
<p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl"/>
<p:load>
<p:with-option name="href" select="$uri"/>
</p:load>
<p:delete match="/*/*|text()"/>
<p:wrap name="load" match="/*" wrapper="load"/>
<p:add-attribute attribute-name="href" match="/*">
<p:with-option name="attribute-value" select="$uri"/>
<p:input port="source">
<p:inline>
<c:request method="GET" override-content-type="text/xml"/>
</p:inline>
</p:input>
</p:add-attribute>
<p:http-request method="xml" encoding="utf8"/>
<p:delete match="/*/*|text()"/>
<p:wrap name="http" match="/*" wrapper="http"/>
<pxf:copy name="copy-do">
<p:with-option name="href" select="$uri"/>
<p:with-option name="target" select="concat($uri,'.copy.xml')"/>
</pxf:copy>
<p:delete match="/*/*|text()">
<p:input port="source">
<p:pipe port="result" step="copy-do"/>
</p:input>
</p:delete>
<p:wrap name="copy" match="/*" wrapper="copy"> </p:wrap>
<pxf:info>
<p:with-option name="href" select="$uri"/>
</pxf:info>
<p:delete match="/*/*|text()"/>
<p:wrap name="info" match="/*" wrapper="info"/>
<pxf:tempfile name="tempfile-do" suffix=".tmp">
<p:with-option name="href" select="replace($uri,'[^/]+$','')"/>
</pxf:tempfile>
<p:delete match="/*/*|text()">
<p:input port="source">
<p:pipe port="result" step="tempfile-do"/>
</p:input>
</p:delete>
<p:wrap name="tempfile" match="/*" wrapper="tempfile"/>
<p:add-attribute name="zip-manifest" attribute-name="href" match="/*/*">
<p:with-option name="attribute-value" select="$uri"/>
<p:input port="source">
<p:inline>
<zip-manifest xmlns="http://www.w3.org/ns/xproc-step">
<entry name="entry.xml" href="http://example.org/file1.xml"
comment="An example file"/>
</zip-manifest>
</p:inline>
</p:input>
</p:add-attribute>
<pxp:zip>
<p:with-option name="href" select="concat($uri,'.zip')"/>
<p:input port="source">
<p:empty/>
<!-- <p:pipe port="result" step="load"/>-->
</p:input>
<p:input port="manifest">
<p:pipe port="result" step="zip-manifest"/>
</p:input>
</pxp:zip>
<p:delete match="/*/*|text()"/>
<p:wrap name="zip" match="/*" wrapper="zip"/>
</p:declare-step>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment