title: Reading Environment Variables in an XSLT Stylesheet with Saxon
body: <p>I'm trying to generate an XML file with the my machine's hostname in some arbitrary element or attribute, e.g.</p>
  
  <pre><code>&lt;hostname&gt;myHostname&lt;/hostname&gt;
  </code></pre>
  
  <p>I'm using Saxon 9.2.  I can think of three ways to do this:</p>
  
  <ol>
  <li>Read and parse <code>/etc/sysconfig/network</code> (I'm using Fedora)</li>
  <li>Read the environment variable (as in <code>$ echo $HOSTNAME</code>)</li>
  <li>Pass the hostname to saxon and then use somehow dereference a variable (not sure if this is possible)</li>
  </ol>
  
  <p>Are any of these possible?  I think the first option is most likely to work, but I think the other two options will produce less verbose XSLT.</p>
  
  <p>I also have a related question: </p>
  
  <p>Currently, I have an XSLT and source XML file that generates a bunch of XML files, it works like I expect it to.  Is there anyway I can selectively generate one file per host?  That is, I want to say 'if the hostname is myHostName then generate the XML file for myHostName, if the hostname is myOtherHostName then generate the XML file for myOtherHostName'.  </p>
  
  <p>I ask this because I'm trying to configure a large number of machines and if I could drop an XSLT and XML file on each and then call the same command on every machine and hten get the right XML on each it would be really convienent.</p>