title: Java Transformer error: Could not compile stylesheet
body: <p>I'm want to transform a XML with XSLT in Java. For that I'm using the <code>javax.xml.transform</code> package. However, I get the exception <code>javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet</code>. This is the code I'm using:</p>
  
  <pre><code>public static String transform(String XML, String XSLTRule) throws TransformerException {
  
      Source xmlInput = new StreamSource(XML);
      Source xslInput = new StreamSource(XSLTRule);
  
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer(xslInput); // this is the line that throws the exception
  
      Result result = new StreamResult();
      transformer.transform(xmlInput, result);
  
      return result.toString();
  }
  </code></pre>
  
  <p>Note that I marked the line which throws the exception.</p>
  
  <p>When I enter the method, the value of <code>XSLTRule</code> is this:</p>
  
  <pre><code>&lt;xsl:stylesheet version='1.0'
   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
   xmlns:msxsl='urn:schemas-microsoft-com:xslt'
   exclude-result-prefixes='msxsl'
   xmlns:ns='http://www.ibm.com/wsla'&gt;
      &lt;xsl:strip-space elements='*'/&gt;
      &lt;xsl:output method='xml' indent='yes'/&gt;
      &lt;xsl:template match='@* | node()'&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select='@* | node()'/&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="/ns:SLA
                              /ns:ServiceDefinition
                                 /ns:WSDLSOAPOperation
                                    /ns:SLAParameter[@name='Performance']"/&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>