Created
December 22, 2019 13:07
-
-
Save gimsieke/7a9362f47aa8b38dc1b2fc4bced79bf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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:err="http://www.w3.org/ns/xproc-error" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
name="urify-test" | |
version="3.0" | |
exclude-inline-prefixes="#all"> | |
<p:input port="source" primary="true"> | |
<p:inline> | |
<urify-test> | |
<item path="#B"/> | |
<item path="index.html"/> | |
<item path="/en/index.html"/> | |
<item path="//www.acme.com/lib/acme.js"/> | |
</urify-test> | |
</p:inline> | |
</p:input> | |
<p:output port="result" primary="true"/> | |
<p:option name="given-base-uri" select="'https://wiki.acme.com/fr/categories.html'" as="xs:string"/> | |
<p:os-info name="os-info"/> | |
<p:variable name="is-windows" as="xs:boolean" select="starts-with(/c:result/@os-name, 'Windows')"/> | |
<p:variable name="urified-cwd" as="xs:string" select="replace(p:urify(/c:result/@cwd), '([^/])$', '$1/')"/> | |
<p:viewport match="/urify-test/item" name="viewport-against-given-base-uri"> | |
<p:with-input pipe="source@urify-test"/> | |
<p:try name="try1"> | |
<p:add-attribute attribute-value="{p:urify(/item/@path, $given-base-uri)}" attribute-name="uri"/> | |
<p:catch code="err:XD0074 err:XD0075 err:XD0076 err:XD0077" name="catch1"> | |
<p:insert position="last-child"> | |
<p:with-input port="souce" pipe="current@viewport-against-given-base-uri"/> | |
<p:with-input port="insertion" pipe="error@catch1"/> | |
</p:insert> | |
</p:catch> | |
</p:try> | |
</p:viewport> | |
<p:add-attribute attribute-name="against" attribute-value="given-base-uri" name="given-base-uri"/> | |
<p:viewport match="/urify-test/item" name="viewport-against-urified-cwd"> | |
<p:with-input pipe="source@urify-test"/> | |
<p:try name="try2"> | |
<p:add-attribute attribute-value="{p:urify(/item/@path, $urified-cwd)}" attribute-name="uri"/> | |
<p:catch code="err:XD0074 err:XD0075 err:XD0076 err:XD0077" name="catch2"> | |
<p:insert position="last-child"> | |
<p:with-input port="souce" pipe="current@viewport-against-urified-cwd"/> | |
<p:with-input port="insertion" pipe="error@catch2"/> | |
</p:insert> | |
</p:catch> | |
</p:try> | |
</p:viewport> | |
<p:add-attribute attribute-name="against" attribute-value="urified-cwd" name="urified-cwd"/> | |
<p:viewport match="/urify-test/item" name="viewport-with-empty-2nd-arg"> | |
<p:with-input pipe="source@urify-test"/> | |
<p:try name="try3"> | |
<p:add-attribute attribute-value="{p:urify(/item/@path)}" attribute-name="uri"/> | |
<p:catch code="err:XD0074 err:XD0075 err:XD0076 err:XD0077" name="catch3"> | |
<p:insert position="last-child"> | |
<p:with-input port="souce" pipe="current@viewport-with-empty-2nd-arg"/> | |
<p:with-input port="insertion" pipe="error@catch3"/> | |
</p:insert> | |
</p:catch> | |
</p:try> | |
</p:viewport> | |
<p:add-attribute attribute-name="against" attribute-value="emtpy-2nd-arg" name="emtpy-2nd-arg"/> | |
<p:wrap-sequence wrapper="result"> | |
<p:with-input port="source" pipe="result@given-base-uri result@urified-cwd result@empty-2nd-arg"/> | |
</p:wrap-sequence> | |
<p:add-attribute attribute-name="windows" attribute-value="{string($is-windows)}" name="add-windows"/> | |
<!--<result windows="false"> | |
<urify-test against="given-base-uri"> | |
<item path="#B" uri="https://wiki.acme.com/fr/categories.html#B"/> | |
<item path="index.html" uri="https://wiki.acme.com/fr/index.html"/> | |
<item path="/en/index.html" uri="https://wiki.acme.com/en/index.html"/> | |
<item path="//www.acme.com/lib/acme.js" uri="https://www.acme.com/lib/acme.js"/> | |
</urify-test> | |
<urify-test against="urified-cwd"> | |
<item path="#B" uri="file:///some/dir/%23B"/> | |
<item path="index.html" uri="file:///some/dir/index.html"/> | |
<item path="//www.acme.com/lib/acme.js" uri="file:///en/index.html"/> | |
<item path="/en/index.html"> | |
<c:error code="err:XD0076">It is a dynamic error if the operating system does not identify as “Windows” | |
and if a file system path or a file URI has an authority (host name) component.</c:error> | |
</item> | |
</urify-test> | |
<urify-test against="emtpy-2nd-arg"> | |
<item path="#B" uri="file:///some/dir/%23B"/> | |
<item path="index.html" uri="file:///some/dir/index.html"/> | |
<item path="/en/index.html" uri="file:///en/index.html"/> | |
<item path="//www.acme.com/lib/acme.js"> | |
<c:error code="err:XD0076">It is a dynamic error if the operating system does not identify as “Windows” | |
and if a file system path or a file URI has an authority (host name) component.</c:error> | |
</item> | |
</urify-test> | |
</result>--> | |
</p:declare-step> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment