title: Why do I get a "Premature End of File" error when performing my XSLT transform?
body: <p>Getting Line #-1; Column #-1; Premature end of file Error while xslt transform</p>
  
  <p><strong>XSL :</strong></p>
  
  <p>
  </p>
  
  <pre><code>&lt;xsl:template match="/"&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;title&gt;Real's HowTo&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;table border="1"&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Titleamit&lt;/th&gt;
                      &lt;th&gt;Link&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;xsl:for-each select="mx:feed/mx:entry"&gt;
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;xsl:value-of select="mx:title" /&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;xsl:value-of select="mx:published" /&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/table&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>XML:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;feed xmlns="http://www.w3.org/2005/Atom" xmlns:clearspace="http://www.jivesoftware.com/xmlns/clearspace/rss"
  xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;
      &lt;title&gt;
          Sprint Community: Space Polls - Android
      &lt;/title&gt;
      &lt;link rel="alternate" href="http://community.sprint.com/baw/poll.jspa?containerType=14&amp;container=2130" /&gt;
      &lt;subtitle&gt;
          List of polls
      &lt;/subtitle&gt;
      &lt;id&gt;
          http://community.sprint.com/baw/poll.jspa?containerType=14&amp;container=2130
      &lt;/id&gt;
      &lt;generator uri="http://jivesoftware.com/products/clearspace/" version="4.5.4.1"&gt;
          Jive SBS
      &lt;/generator&gt;
      &lt;updated&gt;
          2010-02-08T17:30:00Z
      &lt;/updated&gt;
      &lt;dc:date&gt;
          2010-02-08T17:30:00Z
      &lt;/dc:date&gt;
      &lt;dc:language&gt;
          en
      &lt;/dc:language&gt;
      &lt;entry&gt;
          &lt;title&gt;
              What's Valuable
          &lt;/title&gt;
          &lt;link rel="alternate" href="http://community.sprint.com/baw/poll.jspa?poll=1062" /&gt;
          &lt;author&gt;
              &lt;name&gt;
                  wengla02
              &lt;/name&gt;
              &lt;uri&gt;
                  /people/wengla02
              &lt;/uri&gt;
              &lt;email&gt;
                  noreply-buzz@sprint.com
              &lt;/email&gt;
          &lt;/author&gt;
          &lt;updated&gt;
              2010-02-08T17:30:00Z
          &lt;/updated&gt;
          &lt;published&gt;
              2010-02-08T17:30:00Z
          &lt;/published&gt;
          &lt;summary type="html" /&gt;
          &lt;dc:date&gt;
              2010-02-08T17:30:00Z
          &lt;/dc:date&gt;
          &lt;clearspace:dateToText&gt;
              1 year, 2 months ago
          &lt;/clearspace:dateToText&gt;
          &lt;clearspace:objectType&gt;
              0
          &lt;/clearspace:objectType&gt;
      &lt;/entry&gt;
  &lt;/feed&gt;
  </code></pre>
  
  <p>Java code:</p>
  
  <pre><code>// load xslt fromxsltFilePath
  url = getClass().getClassLoader().getResource("com/sprint/mysprint/phoneMedia/myPhoneAndMedia/xsl/announcementFeed.xsl");
  
  BufferedInputStream bis3= new BufferedInputStream(url.openStream());
  
  if (isLoggingDebug()) {
      BufferedInputStream bis1= new BufferedInputStream(url.openStream());
      byte[] buffer1 = new byte[1024];
      int bytesRead1 = 0;
  
      while ((bytesRead1 = bis1.read(buffer1)) != -1) {
          String chunk1 = new String(buffer1, 0, bytesRead1);
          logDebug(" " + chunk1);
      }
  }
  
  TransformerFactory transformerFactory = TransformerFactory.newInstance();
  
  // create xslt Template
  Templates template = transformerFactory.newTemplates(
    new StreamSource(new DataInputStream(url.openStream())));
  
  // Create Transformer 
  Transformer transformer = template.newTransformer();
  transformer.transform(
    new StreamSource(bis), new StreamResult(xhtmlContent));
  </code></pre>