The XProc Quine

http://blog.innovimax.fr/index.php/2011/08/11/38-xproc-quine

You may have heard of the Quicksort implementation in
XProc<http://en.literateprograms.org/Quicksort_(XProc)>
 of the famous algorithm <http://en.wikipedia.org/wiki/Quicksort> in
XProc<http://w3.org/TR/xproc>

Here comes now the Quine <http://en.wikipedia.org/wiki/Quine_(computing)>, *
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<http://xproc.org/implementations/>.
If you run for GPL <http://en.wikipedia.org/wiki/GNU_General_Public_License>,
go look atQuiXProc <http://code.google.com/p/quixproc>
Xmlizer

Received on Thursday, 11 August 2011 14:39:02 UTC