Hy there.
I'm having problems transforming a XML file with dom4j. Here is the class
source code. It's only a few lines:

//---------------------- CODE -------------------------
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;

import org.dom4j.Document;
import org.dom4j.io.DocumentSource;
import org.dom4j.io.SAXReader;
import org.dom4j.DocumentException;

import java.io.File;
import java.io.StringReader;
import java.io.ByteArrayOutputStream;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class GenerateHTML {
  public String process(String xmlString, String xslFile) throws
TransformerConfigurationException, TransformerException, DocumentException,
SAXException {

    ByteArrayOutputStream result = new ByteArrayOutputStream();

    SAXReader reader = new SAXReader("org.apache.xerces.parsers.SAXParser");
    Document document = reader.read(new InputSource(new
StringReader(xmlString)));

    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer(new StreamSource(new
File(xslFile)));

    DocumentSource source = new DocumentSource(document);
    transformer.transform(source, new StreamResult(result));

    return(result.toString());
  }
}
//---------------------- END CODE -------------------------


I've tested the two parameters ("xmlString" and "xslFile") and they have the
information that I want.
I'm using this class inside a bean and every time I try to transform the
generated XML (which is valid! I tested it with XML Spy 5) it keeps giving
me the following error:

--------
javax.xml.transform.TransformerFactoryConfigurationError: Provider null
could not be instantiated: java.lang.NullPointerException
        at javax.xml.transform.TransformerFactory.newInstance(Unknown
Source)
--------

I can't figure out what the problem is!? I've never had this problem before.

Can someone help me please.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to