title: Circular variable/parameter reference in a Variable XSLT
body: <p>I have a simple XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="form.xsl"?&gt;
  &lt;x&gt;
      &lt;y&gt;Hello&lt;/y&gt;
  &lt;/x&gt;
  </code></pre>
  
  <p>and <code>form.xsl</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"&gt;
  
  &lt;xsl:output encoding="UTF-8" method="xml" indent="yes"/&gt;
  &lt;xsl:variable name="topLevel"&gt;
          &lt;xsl:variable name="inner" select="'Hi'" /&gt;
          &lt;xsl:value-of select="$inner"/&gt;
  &lt;/xsl:variable&gt;
  
  &lt;xsl:template match="/" &gt;
      &lt;xsl:value-of select="$topLevel" /&gt;
  &lt;/xsl:template&gt;
  
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I am using <code>JRE 1.8,</code> and when i transform the XML using <code>javax.xml.transform.Transformer</code>, i get a circular reference error, on the <code>topLevel</code> variable.</p>
  
  <pre><code>Circular variable/parameter reference in '[variable(topLevel)]
  </code></pre>
  
  <p>I found out that there is already an issue related to this logged at: <a href="https://issues.apache.org/jira/browse/XALANJ-2430" rel="noreferrer">JIRA</a>, but am not sure if this has been fixed. </p>
  
  <p>There are various workarounds provided but no solutions provided.</p>
  
  <p><strong>Note</strong>: I have not included any third party jars and am using the default Transformer implementation.</p>