title: How to make XSLT emit an angle bracket?
body: <p>I have an XSL transform that merges information from several XML files (secondaries) into another XML file (primary). The output consists of markdown. I need to make the primary XML file generate an HTML tag in the markdown file. How do I do that?</p>
  <p>The primary XML file has a stylesheet with definitions like this:</p>
  <pre><code>&lt;!DOCTYPE stylesheet [
    &lt;!ENTITY xlt     &quot;&amp;amp;lt;&quot; &gt;
    &lt;!ENTITY xgt     &quot;&amp;amp;gt;&quot; &gt;
  ]&gt;
  </code></pre>
  <p>But this makes the transform change <code>&amp;xlt;a id=&quot;...&quot;&amp;xgt;</code> into <code>&amp;lt;a id=&quot;...&quot;&amp;gt;</code>, and when the page is opened in a browser it composes <code>&lt;a id=&quot;...&quot;&gt;</code>. I want to make the HTML <em>contain</em> <code>&lt;a id=&quot;...&quot;&gt;</code>, and compose nothing, but define a label.</p>
  <p>I tried to define the stylesheet like this:</p>
  <pre><code>&lt;!DOCTYPE stylesheet [
    &lt;!ENTITY xlt     &quot;&amp;amp;lt;&quot; &gt;
    &lt;!ENTITY xgt     &quot;&amp;amp;gt;&quot; &gt;
    &lt;!ENTITY xlab    &quot;&lt;&quot; &gt;
    &lt;!ENTITY xrab    &quot;&gt;&quot; &gt;
  ]&gt;
  </code></pre>
  <p>...and use it like this in the primary XML: <code>&amp;xlab;a id=&quot;...&quot;&amp;xrab;</code>.</p>
  <p>But this got me the following error from the XML processor (Saxon-HE 9.9.1.5N from Saxonica):</p>
  <pre><code>Error on line 238 column 7 of &lt;primary XML file):
    SXXP0003: Error reported by XML parser: XML document structures must start and end within
    the same entity.
  </code></pre>
  <p>(Line 238 column 7 is the position immediately after <code>&amp;xlab;</code>.)</p>
  <p>The transform seems to be upset by an entity that resolves to an angle bracket. If I replace the stylesheet with this:</p>
  <pre><code>&lt;!DOCTYPE stylesheet [
    &lt;!ENTITY xlt     &quot;&amp;amp;lt;&quot; &gt;
    &lt;!ENTITY xgt     &quot;&amp;amp;gt;&quot; &gt;
    &lt;!ENTITY xlab    &quot;[&quot; &gt;
    &lt;!ENTITY xrab    &quot;]&quot; &gt;
  ]&gt;
  </code></pre>
  <p>...I get well-behaved output: <code>[a id=&quot;...&quot;]</code>. But that, of course, is not an HTML tag.</p>