A
asd
Hi all,
I am making a simple application which would transform a xml file
according to an xsl file.
There is an exception of which I have no clue what it is?
My code:
----------
import java.io.*;
import javax.xml.transform.*;
//import javax.xml.transform.stream.*;
public class Jax{
public static void main(String args[]) throws FileNotFoundException{
try{
File xmlFile = new File(args[0]);
File xslFile = new File(args[1]);
System.out.println("Created the file");
Source xmlSource = new
javax.xml.transform.stream.StreamSource(xmlFile);
System.out.println("Created XmlSource");
Source xslSource = new
javax.xml.transform.stream.StreamSource(xslFile);
Result result = new
javax.xml.transform.stream.StreamResult(System.out);
System.out.println("Created result");
TransformerFactory transFact = TransformerFactory.newInstance();
System.out.println("Created transFact" + transFact);
Transformer trans = transFact.newTransformer(xslSource);
System.out.println("Created trans");
trans.transform(xmlSource, result);
}catch(TransformerException tex){
System.out.println("tex occured :");
File output = new File("error.txt");
PrintStream ps = new PrintStream(new FileOutputStream(output));
tex.printStackTrace(ps);
ps.close();
}catch(Exception ex){
System.out.println("something else occured :");
System.out.println(ex.getMessage());
}
}
}
XML file:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<message>Yep, it worked!</message>
XSL file:
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="text" encoding="UTF-8"/>
<!-- simply copy the message to the result tree -->
<xsl:template match="/">
<xsl:value-of select="message"/>
</xsl:template>
</xsl:stylesheet>
The error:
-------------
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException:
java.lang.NullPointerException
at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String)
(/usr/lib/./libgcj.so.3)
at 0x4025bcd2: java.lang.Exception.Exception(java.lang.String)
(/usr/lib/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8:
_Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation)
(/usr/lib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw,
_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
........
I am making a simple application which would transform a xml file
according to an xsl file.
There is an exception of which I have no clue what it is?
My code:
----------
import java.io.*;
import javax.xml.transform.*;
//import javax.xml.transform.stream.*;
public class Jax{
public static void main(String args[]) throws FileNotFoundException{
try{
File xmlFile = new File(args[0]);
File xslFile = new File(args[1]);
System.out.println("Created the file");
Source xmlSource = new
javax.xml.transform.stream.StreamSource(xmlFile);
System.out.println("Created XmlSource");
Source xslSource = new
javax.xml.transform.stream.StreamSource(xslFile);
Result result = new
javax.xml.transform.stream.StreamResult(System.out);
System.out.println("Created result");
TransformerFactory transFact = TransformerFactory.newInstance();
System.out.println("Created transFact" + transFact);
Transformer trans = transFact.newTransformer(xslSource);
System.out.println("Created trans");
trans.transform(xmlSource, result);
}catch(TransformerException tex){
System.out.println("tex occured :");
File output = new File("error.txt");
PrintStream ps = new PrintStream(new FileOutputStream(output));
tex.printStackTrace(ps);
ps.close();
}catch(Exception ex){
System.out.println("something else occured :");
System.out.println(ex.getMessage());
}
}
}
XML file:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<message>Yep, it worked!</message>
XSL file:
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="text" encoding="UTF-8"/>
<!-- simply copy the message to the result tree -->
<xsl:template match="/">
<xsl:value-of select="message"/>
</xsl:template>
</xsl:stylesheet>
The error:
-------------
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException:
java.lang.NullPointerException
at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String)
(/usr/lib/./libgcj.so.3)
at 0x4025bcd2: java.lang.Exception.Exception(java.lang.String)
(/usr/lib/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8:
_Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation)
(/usr/lib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw,
_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
........