title: Include external XML ENTITIES using SYSTEM while resolving path with $ENV variable
body: <p>Looking at <a href="https://stackoverflow.com/questions/2923273/can-entity-declarations-be-nested-in-referenced-xml-files?lq=1">some posts</a> and <a href="http://xmlwriter.net/xml_guide/entity_declaration.shtml" rel="nofollow noreferrer">others</a>, I'm close to what I'm looking for, but not there yet.</p>
  
  <p><strong>Overall goal</strong></p>
  
  <p>To have XML ENTITY file<strong>s</strong> included within other XML file<strong>s</strong>, with the URI to SYSTEM taken from the an environment variable!</p>
  
  <p><strong>Sample XML ENTITY files</strong> (not sure if <a href="https://stackoverflow.com/questions/30085988/should-an-xml-file-included-via-entity-system-have-an-xml-declara">xml declaration</a> needed)</p>
  
  <p><code>$XML_PATH_SET_PER_ENV/entites/$CLIENT/entities.ent</code></p>
  
  <pre><code>&lt;!ENTITY COMPANY_ID "9800"&gt;
  &lt;!ENTITY PARENT_ID "98100"&gt;
  &lt;!ENTITY ACCOUNT_NAME "THE SUN PEOPLE"&gt;
  &lt;!ENTITY ACCOUNT_AB "TSP"&gt;
  </code></pre>
  
  <p>or <code>$XML_PATH_SET_PER_ENV/entites/$CLIENT/entities.ent</code></p>
  
  <pre><code>&lt;!ENTITY COMPANY_ID "7900"&gt;
  &lt;!ENTITY PARENT_ID "98500"&gt;
  &lt;!ENTITY ACCOUNT_NAME "FRUITS VEGGIES N MORE"&gt;
  &lt;!ENTITY ACCOUNT_AB "FVNM"&gt;
  </code></pre>
  
  <p>or <code>$XML_PATH_SET_PER_ENV/entites/$CLIENT/entities.ent</code></p>
  
  <pre><code>&lt;!ENTITY COMPANY_ID "84500"&gt;
  &lt;!ENTITY PARENT_ID "861675"&gt;
  &lt;!ENTITY ACCOUNT_NAME "THE SUN PEOPLE"&gt;
  &lt;!ENTITY ACCOUNT_AB "TSP"&gt;
  </code></pre>
  
  <p>Then within any XML file, I wish to <em>pull in</em> a specific <code>entities.ent</code> as needed:</p>
  
  <p>doc.xml</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="no" ?&gt;
  &lt;!DOCTYPE TEST [
  
      &lt;!ENTITY % get_em SYSTEM "entities.ent" &gt;
      %get_em;
  
  ]&gt;
  
  &lt;TEST&gt;
          &lt;COMPANY_ID&gt;&amp;COMPANY_ID;&lt;/COMPANY_ID&gt;
  &lt;/TEST&gt;
  </code></pre>
  
  <p>However, before getting to my stated goal, I struggling first to get this simple <code>doc.xml</code> to work:</p>
  
  <pre><code>$ ls -lrt doc.xml entities.ent
  -rw-r--r--. 1 user other 186 Dec 28 14:33 entities.ent
  -rw-r--r--. 1 user other 182 Dec 28 14:34 doc.xml
  </code></pre>
  
  <p>And xmllint is not happy :(</p>
  
  <pre><code>$ xmllint --noout doc.xml
  doc.xml:10: parser error : Entity 'COMPANY_ID' not defined
          &lt;COMPANY_ID&gt;&amp;COMPANY_ID;&lt;/COMPANY_ID&gt;
                                          ^
  </code></pre>