title: Embedding XSLT in the XML file?
body: <p>Let's suppose we have:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="class.xsl"?&gt;
  &lt;class&gt;
      &lt;student&gt;Jack&lt;/student&gt;
      &lt;student&gt;Harry&lt;/student&gt;
      &lt;student&gt;Rebecca&lt;/student&gt;
      &lt;teacher&gt;Mr. Bean&lt;/teacher&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>This file would render nicely in a browser with a proper <code>class.xsl</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:template match="/"&gt;
    &lt;html&gt;&lt;body&gt;
    &lt;ol&gt;
      &lt;xsl:for-each select="class/student"&gt;
        &lt;li&gt;&lt;xsl:value-of select="."/&gt;&lt;/li&gt;
      &lt;/xsl:for-each&gt;
    &lt;/ol&gt;
    &lt;/body&gt;&lt;/html&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Is there a way to include the content of <code>class.xsl</code> in the same XML file, so that the file <code>class.xsl</code> does not exist?</p>
  
  <p>I know this is possible with a CSS stylesheet, normally referred by <code>&lt;link&gt;</code>, can also be nested in.</p>
  
  <hr>
  
  <p><strong>Edit</strong>: I experimented with referencing the same XML file as the stylesheet, however, XSLT's <code>&lt;stylesheet&gt;</code> does not function if not used as the root element.</p>
  
  <p>Is it possible to allow <code>class.xsl</code> to source some XSLT segment defined in the XML file and use it as XSLT? This would allow a generic XSLT file to be defined to load XSLT rules from each individual XML file.</p>