java - Why do I get a "Premature End of File" error when performing my XSLT transform? -


getting line #-1; column #-1; premature end of file error while xslt transform

xsl :

<xsl:template match="/">     <html>         <head>             <title>real's howto</title>         </head>         <body>             <table border="1">                 <tr>                     <th>titleamit</th>                     <th>link</th>                 </tr>                 <xsl:for-each select="mx:feed/mx:entry">                     <tr>                         <td>                             <xsl:value-of select="mx:title" />                         </td>                         <td>                             <xsl:value-of select="mx:published" />                         </td>                     </tr>                 </xsl:for-each>             </table>         </body>     </html> </xsl:template> 

xml:

<?xml version="1.0" encoding="utf-8" ?> <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/">     <title>         sprint community: space polls - android     </title>     <link rel="alternate" href="http://community.sprint.com/baw/poll.jspa?containertype=14&container=2130" />     <subtitle>         list of polls     </subtitle>     <id>         http://community.sprint.com/baw/poll.jspa?containertype=14&container=2130     </id>     <generator uri="http://jivesoftware.com/products/clearspace/" version="4.5.4.1">         jive sbs     </generator>     <updated>         2010-02-08t17:30:00z     </updated>     <dc:date>         2010-02-08t17:30:00z     </dc:date>     <dc:language>         en     </dc:language>     <entry>         <title>             what's valuable         </title>         <link rel="alternate" href="http://community.sprint.com/baw/poll.jspa?poll=1062" />         <author>             <name>                 wengla02             </name>             <uri>                 /people/wengla02             </uri>             <email>                 noreply-buzz@sprint.com             </email>         </author>         <updated>             2010-02-08t17:30:00z         </updated>         <published>             2010-02-08t17:30:00z         </published>         <summary type="html" />         <dc:date>             2010-02-08t17:30:00z         </dc:date>         <clearspace:datetotext>             1 year, 2 months ago         </clearspace:datetotext>         <clearspace:objecttype>             0         </clearspace:objecttype>     </entry> </feed> 

java 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)); 

the & ampersand signs not escaped in xml. should change them &amp; in order able parse xml data, otherwise won't work. after parsing , transforming, wrapping, whatever, can update results changing these characters back.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -