title: java - spring - xsl transformation dtd not found error
body: <p>I have a code which transform xml file using xsl, my peace of code as following. My problem is when i run the execution point it gives me following error.</p>
  
  <pre><code>StackTrace: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: /home/app/myapp/bin/xhtml11-flat.dtd (No such file or directory)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:720)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
      at com.core.util.XmlUtils.transform(XmlUtils.java:151)
      at com.core.util.XmlUtils.transform(XmlUtils.java:147)
  </code></pre>
  
  <p>Long story short it is trying to find dtd file inside the bin directory from where i executed the application.</p>
  
  <p><strong>/home/app/myapp/bin/xhtml11-flat.dtd</strong></p>
  
  <p>I have the xhtml11-flat.dtd file if i copy this file in bin directory it works fine, instead of the bin directory i want to load it from classpath any idea how can i achieve this with minimum changes ?
  I don't know from where it is laoding .dtd code so that i can set my path in it.</p>
  
  <pre><code>//Execution Point
  function transform(){
      Templates templates = getTemplates();
      StringWriter result = new StringWriter();
      XmlUtils.transform(templates.newTransformer(), input, new StreamResult(result));
  
      ...
  }
  
  private Templates getTemplates() throws Exception {
      if (templates == null) {
          templates = XmlUtils.createTemplates(XslRdcSourceDocTransformer.class.getResourceAsStream("/xsl/" + getXslFileName()));
      }
      return templates;
  }
  
  
  public static Templates createTemplates(InputStream stream) throws Exception {
      TransformerFactory tfactory = TransformerFactory.newInstance();
      return tfactory.newTemplates(new StreamSource(stream));
  }
  </code></pre>