Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRunt imeException:

    hello experts

    i am a newbie to jaxp

    when i ran my xml file in the browser i am getting the correct output
    when i am parsing the file using java i am getting a error like this

    ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRunt imeException:Premature End of File'

    below is my file1.xml
    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="empformattr.xsl"?>
    <employee>
    <employeeForm name="employeeform"> 
    <field name="enter the id" id="empId" type="text" nodeValue="empid"></field>
    <field name="enter the name" id="empName" type="text" nodeValue="empname"></field>
    <field name="enter the department" id="empLoc" type="text" nodeValue="empdep"></field>
    <field name="enter the role" id="empRole" type="text" nodeValue="emprole"></field>
    </employeeForm>
    </employee>
    this is my file2.xml

    Java Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <employee>
    	<empid>1231</empid>
    	<empname>kiran</empname>
    	<empdept>ers</empdept>
    	<emprole>sw</emprole>
    </employee>
    this is my xslt
    Java Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:variable name="emp" select="document('emp1.xml')"/>
    <xsl:template match="/employee/employeeForm">
    	<html>
    		<body>
    			<table border="1">
    				<xsl:for-each select="field">
    					<xsl:variable name="nodeid">
    					<xsl:value-of select="@nodeValue"/>
    					</xsl:variable>
    					<xsl:if test="$nodeid= 'empid'">
    					<xsl:if test="@type[. = 'text']">
    						<tr>
    						<td><xsl:value-of select="@name"/></td><td><input type="text" name="id" id="{@id}" value="{$emp/employee/empid}"/></td>
    						</tr>
    					</xsl:if>
    					</xsl:if>
    					<xsl:if test="$nodeid= 'empname'">
    					<xsl:if test="@type[. = 'text']">
    						<tr>
    						<td><xsl:value-of select="@name"/></td><td><input type="text" name="id" id="{@id}" value="{$emp/employee/empname}"/></td>
    						</tr>
    					</xsl:if>
    					</xsl:if>
    					<xsl:if test="$nodeid= 'empdep'">
    					<xsl:if test="@type[. = 'text']">
    						<tr>
    						<td><xsl:value-of select="@name"/></td><td><input type="text" name="id" id="{@id}" value="{$emp/employee/empdept}"/></td>
    						</tr>
    					</xsl:if>
    					</xsl:if>
    					<xsl:if test="$nodeid= 'emprole'">
    					<xsl:if test="@type[. = 'text']">
    						<tr>
    						<td><xsl:value-of select="@name"/></td><td><input type="text" name="id" id="{@id}" value="{$emp/employee/emprole}"/></td>
    						</tr>
    					</xsl:if>
    					</xsl:if>
    				</xsl:for-each>
    			</table>
    		</body>
    	</html>
    </xsl:template>
    </xsl:stylesheet>
    every thing is fine upto this point

    but when i am trying to parse the file using java i am getting an error l
    below is my java code
    Java Code:
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import java.io.*;
    
    public class xmltohtml {
    	  public static void main(String[] args)
    	    throws TransformerException, 
    	    TransformerConfigurationException, 
    	           FileNotFoundException, IOException
    	  {  
    	        TransformerFactory tFactory = 
    	        TransformerFactory.newInstance();
    	        Transformer transformer = 
    	        tFactory.newTransformer(new StreamSource("C:\\Documents and Settings\\mketireddi\\Desktop\\empformxsl\\empformattr.xsl"));
    	        transformer.transform( new StreamSource(args[0]), 
    	        new StreamResult(new FileOutputStream(args[1])));
    	        System.out.println("** The output is written in "+args[1]+" **");
    	  }
    }
    now i am getting errors when i run this java code
    help me in solving this issue

  2. #2
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    Check the file path you're passing in--that's the most likely culprit for a premature end-of-file exception.

Similar Threads

  1. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  2. The server encountered an internal error ()
    By rakesh_n_mehta in forum Web Frameworks
    Replies: 0
    Last Post: 01-19-2009, 01:09 PM
  3. The Utils
    By JavaLovenJoe in forum New To Java
    Replies: 1
    Last Post: 04-19-2008, 08:59 PM
  4. an internal error occurred during refresh
    By christina in forum Eclipse
    Replies: 1
    Last Post: 08-06-2007, 09:37 PM
  5. Description the server encountered an internal error
    By Jack in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-02-2007, 02:24 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •