title: A fatal error while converting a String to XML document
body: <p>I'm have XML data in the shape of String and i want to convert it to XML document in order to make some process in it, and i'm using the following method to make that:</p>
  
  <pre><code>private Document convert(String xml) throws ParserConfigurationException,
              SAXException, IOException {
  
          // convert String into InputStream
          InputStream is = new ByteArrayInputStream(xml.getBytes());
  
          // convert InputStream to Document
          domFactory = DocumentBuilderFactory.newInstance();
          domFactory.setNamespaceAware(true);
          builder = domFactory.newDocumentBuilder();
          builder(builder); // this is the error handler method i'm using
          Document doc = builder.parse(is);
          is.close();
  
          return doc;
      }
  </code></pre>
  
  <p>the strange thing is that the processing done correctly and every thing is perfect with my results, but on the other side when i make the convert process i got a message in my console:</p>
  
  <pre><code>[Fatal Error] :1:1: Premature end of file.
  </code></pre>
  
  <p>so, i have used an error handler in order to catch that fatal error and print the exception stack trace, and then i got these exceptions thrown:</p>
  
  <pre><code>org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
      at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
      at com.nc.inotify.dp.xml.impl.XmlSource.convert(XmlSource.java:327)
      at com.nc.inotify.dp.xml.impl.XmlSource.update(XmlSource.java:299)
      at com.nc.inotify.dp.xml.junit.TXmlSource.testUpdate(TXmlSource.java:106)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  The XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;rss xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" version="2.0"&gt;
              &lt;channel&gt;
  
  &lt;title&gt;Yahoo! Weather - Sunnyvale, CA&lt;/title&gt;
  &lt;link&gt;http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/USCA1116_f.html&lt;/link&gt;
  &lt;description&gt;Yahoo! Weather for Sunnyvale, CA&lt;/description&gt;
  &lt;language&gt;en-us&lt;/language&gt;
  &lt;lastBuildDate&gt;Thu, 06 Jun 2013 1:56 am PDT&lt;/lastBuildDate&gt;
  &lt;ttl&gt;60&lt;/ttl&gt;
  &lt;yweather:location city="Sunnyvale" country="United States" region="CA"/&gt;
  &lt;yweather:units distance="mi" pressure="in" speed="mph" temperature="F"/&gt;
  &lt;yweather:wind chill="58" direction="30" speed="3"/&gt;
  &lt;yweather:atmosphere humidity="81" pressure="29.96" rising="2" visibility="10"/&gt;
  &lt;yweather:astronomy sunrise="5:46 am" sunset="8:25 pm"/&gt;
  &lt;image&gt;
  &lt;title&gt;Yahoo! Weather&lt;/title&gt;
  &lt;width&gt;142&lt;/width&gt;
  &lt;height&gt;18&lt;/height&gt;
  &lt;link&gt;http://weather.yahoo.com&lt;/link&gt;
  &lt;url&gt;http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif&lt;/url&gt;
  &lt;/image&gt;
  &lt;item&gt;
  &lt;title&gt;Conditions for Sunnyvale, CA at 1:56 am PDT&lt;/title&gt;
  &lt;geo:lat&gt;37.37&lt;/geo:lat&gt;
  &lt;geo:long&gt;-122.04&lt;/geo:long&gt;
  &lt;link&gt;http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/USCA1116_f.html&lt;/link&gt;
  &lt;pubDate&gt;Thu, 06 Jun 2013 1:56 am PDT&lt;/pubDate&gt;
  &lt;yweather:condition code="26" date="Thu, 06 Jun 2013 1:56 am PDT" temp="58" text="Cloudy"/&gt;
  &lt;description&gt;&lt;![CDATA[
  &lt;img src="http://l.yimg.com/a/i/us/we/52/26.gif"/&gt;&lt;br /&gt;
  &lt;b&gt;Current Conditions:&lt;/b&gt;&lt;br /&gt;
  Cloudy, 58 F&lt;BR /&gt;
  &lt;BR /&gt;&lt;b&gt;Forecast:&lt;/b&gt;&lt;BR /&gt;
  Wed - Partly Cloudy. High: 70 Low: 55&lt;br /&gt;
  Thu - AM Clouds/PM Sun. High: 74 Low: 57&lt;br /&gt;
  Fri - Partly Cloudy. High: 81 Low: 62&lt;br /&gt;
  Sat - Sunny. High: 78 Low: 63&lt;br /&gt;
  Sun - Partly Cloudy. High: 72 Low: 60&lt;br /&gt;
  &lt;br /&gt;
  &lt;a href="http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/USCA1116_f.html"&gt;Full Forecast at Yahoo! Weather&lt;/a&gt;&lt;BR/&gt;&lt;BR/&gt;
  (provided by &lt;a href="http://www.weather.com" &gt;The Weather Channel&lt;/a&gt;)&lt;br/&gt;
  ]]&gt;&lt;/description&gt;
  &lt;yweather:forecast code="29" date="5 Jun 2013" day="Wed" high="70" low="55" text="Partly Cloudy"/&gt;
  &lt;yweather:forecast code="30" date="6 Jun 2013" day="Thu" high="74" low="57" text="AM Clouds/PM Sun"/&gt;
  &lt;yweather:forecast code="30" date="7 Jun 2013" day="Fri" high="81" low="62" text="Partly Cloudy"/&gt;
  &lt;yweather:forecast code="32" date="8 Jun 2013" day="Sat" high="78" low="63" text="Sunny"/&gt;
  &lt;yweather:forecast code="30" date="9 Jun 2013" day="Sun" high="72" low="60" text="Partly Cloudy"/&gt;
  &lt;guid isPermaLink="false"&gt;USCA1116_2013_06_09_7_00_PDT&lt;/guid&gt;
  &lt;/item&gt;
  &lt;/channel&gt;
  &lt;/rss&gt;&lt;!-- api10.weather.ch1.yahoo.com Thu Jun  6 09:34:11 PST 2013 --&gt;
  </code></pre>