Search code examples
xsltself

Simplest XSLT Stylesheet whose output is the XSLT Stylesheet...For learning purposes


What's the simplest XSLT (1.0) stylesheet that can be used to output itself?

I have started it off (and haven't got very far...). self.xml is the name of the stylesheet (and the input document):

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="self.xml"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
...

And the output should be, well the same....

EDIT (after reading about quines from a poster...)

Let me make this request harder...

Does an XSLT stylesheet exist which will just simply output any input document. (I mean output, not just internally represent it) : 'any input document' would include itself of course...


Solution

  • This kind of program is called a "quine," and a quick Google of "XSLT quine" resulted in this link: http://www2.informatik.hu-berlin.de/~obecker/XSLT/#quine