import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TestTransform{
public static void main(String[] args)
throws TransformerException, TransformerConfigurationException,
FileNotFoundException, IOException{
String xml_input = "c:/testXML/test.xml";
String html_output = "c:/testXML/test.html";
TransformerFactory tFactory = TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tFactory.newTransformer(new
StreamSource("c:/testXML/internal.xsl"));
transformer.transform(new StreamSource(xml_input), new StreamResult(new
FileOutputStream(html_output))); //this is the line causing the errors
System.out.println("************* The result is in birds.out
*************");
}
}
The errors i get are:
java.lang.NoSuchMethodError
at org.apache.xpath.DOM2Helper.getLocalNameOfNode(DOM2Helper.java:326)
at org.apache.xalan.templates.TemplateList.getHead(TemplateList.java:471)
at
org.apache.xalan.templates.TemplateList.getTemplate(TemplateList.java:528)
at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.ja
va:432)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
a:193)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
erImpl.java:2202)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transformer
Impl.java:2085)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1219)
at
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
at java.lang.Thread.run(Thread.java:484)
************* The result is in birds.out *************
Interactive Session Ended
Class org.w3c.dom.Node should have following method:
/**
* Returns the local part of the qualified name of this node.
* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
* method, such as <code>createElement</code> from the
* <code>Document</code> interface, this is always <code>null</code>.
* @since DOM Level 2
*/
public String getLocalName();
Or you can use JAXP.
I compiled your code with it.
Maris
Baltic Technology Group