JDOM Xalan org.w3c.dom.Document:

HI,

I am trying to use JDOM is load and render an XML file. However when I try to run the program I get the following below:

org.jdom.JDOMException: Exception outputting Document: org.w3c.dom.Document: method createElementNS(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/Element; not found

Any help is greatly appreciated.

Lenin

Source:

=======

package com;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileWriter;

import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerConfigurationException;

import javax.xml.transform.TransformerException;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.stream.StreamResult;

import javax.xml.transform.stream.StreamSource;

import org.jdom.Attribute;

import org.jdom.Comment;

import org.jdom.Document;

import org.jdom.Element;

import org.jdom.JDOMException;

import org.jdom.input.SAXBuilder;

import org.jdom.output.XMLOutputter;

public class Article {

public static Document readDocument() {

try {

SAXBuilder builder = new SAXBuilder();

Document anotherDocument = builder.build(new File("xml/sample.xml"));

return anotherDocument;

} catch(JDOMException e) {

e.printStackTrace();

} catch(NullPointerException e) {

e.printStackTrace();

}

return null;

}

public static void executeXSL(Document myDocument) {

try {

TransformerFactory tFactory = TransformerFactory.newInstance();

// Make the input sources for the XML and XSLT documents

org.jdom.output.DOMOutputter outputter = new org.jdom.output.DOMOutputter();

org.w3c.dom.Document domDocument = outputter.output(myDocument);

javax.xml.transform.Source xmlSource = new javax.xml.transform.dom.DOMSource(domDocument);

StreamSource xsltSource = new StreamSource(new FileInputStream("xml/car.xsl"));

//Make the output result for the finished document

StreamResult xmlResult = new StreamResult(System.out);

//Get a XSLT transformer

Transformer transformer = tFactory.newTransformer(xsltSource);

//do the transform

transformer.transform(xmlSource, xmlResult);

} catch(FileNotFoundException e) {

e.printStackTrace();

} catch(TransformerConfigurationException e) {

e.printStackTrace();

} catch(TransformerException e) {

e.printStackTrace();

} catch(org.jdom.JDOMException e) {

e.printStackTrace();

}

}

}

[2707 byte] By [Lenin_tony] at [2007-9-26 5:28:43]
# 1
You should use JDOMSource instead of DOMSource
fayefun at 2007-6-29 19:37:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...