title: Transform an XML document with XSLT before processing
body: <p>I have an XML document which I will be processing within a Java application.
  However, I need to transform it with an XSLT file to be able to do the processing afterwards.</p>
  
  <p>This is how I am loading the XML file at present.</p>
  
  <pre><code>    DocumentBuilderFactory factory;
      DocumentBuilder docbuilder;
      Document doc;
      Element root;
  
      factory = DocumentBuilderFactory.newInstance();
      try
      {
          // open up the xml document
          docbuilder = factory.newDocumentBuilder();
          doc = docbuilder.parse(new FileInputStream(m_strFileName));
  
          // get the document type
          doctype = doc.getDoctype();
          strDTD = doctype.getPublicId();
  
          // get the root of the document
          root = doc.getDocumentElement();
          // get the list of child nodes
          nodes = root.getChildNodes();
          // now process each node
          ...
      }
      catch(ParserConfigurationException e)
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      catch(SAXException e)
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>How can I apply an XSLT transform to the XML document and then obtain the root node of the new document ?</p>
  
  <p>Note that I am <strong>not</strong> wanting to write the resulting xml tree to disk.</p>