title: Java, xml, XSLT: Prevent DTD-Validation
body: <p>I use the Java (6) XML-Api to apply a xslt transformation on a html-document from the web. This document is wellformed xhtml and so contains a valid DTD-Spec (<code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</code>). 
  Now a problem occurs: Uppon transformation the XSLT-Processor tries to download the DTD and the w3-server denies this by a HTTP 503 error (due to <a href="http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic" rel="nofollow noreferrer">Bandwith Limitation</a> by w3). </p>
  
  <p><strong>How can I prevent the XSLT-Processor from downloading the dtd? I dont need my input-document validated.</strong> </p>
  
  <p>Source is:</p>
  
  <pre><code>import javax.xml.transform.Source;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.stream.StreamResult;
  import javax.xml.transform.stream.StreamSource;
  </code></pre>
  
  <p>--</p>
  
  <pre><code>   String xslt = "&lt;?xml version=\"1.0\"?&gt;"+
     "&lt;xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"&gt;"+
     "    &lt;xsl:output method=\"text\" /&gt;"+          
     "    &lt;xsl:template match=\"//html/body//div[@id='bodyContent']/p[1]\"&gt; "+
     "        &lt;xsl:value-of select=\".\" /&gt;"+
     "     &lt;/xsl:template&gt;"+
     "     &lt;xsl:template match=\"text()\" /&gt;"+
     "&lt;/xsl:stylesheet&gt;";
  
     try {
     Source xmlSource = new StreamSource("http://de.wikipedia.org/wiki/Right_Livelihood_Award");
     Source xsltSource = new StreamSource(new StringReader(xslt));
     TransformerFactory ft = TransformerFactory.newInstance();
  
     Transformer trans = ft.newTransformer(xsltSource);
  
     trans.transform(xmlSource, new StreamResult(System.out));
     }
     catch (Exception e) {
       e.printStackTrace();
     }
  </code></pre>
  
  <p>I read the following quesitons here on SO, but they all use another XML-Api:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/998280/dtd-download-error-while-parsing-xhtml-document-in-xom">"DTD download error while parsing XHTML document in XOM"</a></li>
  </ul>
  
  <p>Thanks!</p>