Thursday 11 August 2011
XProc Quine
Par MoZ, Thursday 11 August 2011 à 16:13 :: XProc
You may have heard of the Quicksort implementation in XProc of the famous algorithm in XProc
Here comes now the Quine, i.e a computer program which takes no input and produces a copy of its own source code as its only output.
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
<p:documentation>
<p>(c) Innovimax 2011 - The first XProc Quine</p>
</p:documentation>
<p:output port="result"/>
<p:identity>
<p:input port="source">
<p:inline>
<p:declare-step version="1.0">
<p:documentation>
<p>(c) Innovimax 2011 - The first XProc Quine</p>
</p:documentation>
<p:output port="result"/>
<p:identity>
<p:input port="source">
<p:inline/>
</p:input>
</p:identity>
<p:insert match="p:inline" position="first-child">
<p:input port="source"/>
<p:input port="insertion"/>
</p:insert>
</p:declare-step>
</p:inline>
</p:input>
</p:identity>
<p:insert match="p:inline" position="first-child">
<p:input port="source"/>
<p:input port="insertion"/>
</p:insert>
</p:declare-step>
It works in any of the many implementations of XProc. If you run for GPL, go look at QuiXProc