Skip to Content
avatar image
Former Member

Trying to use SAX Parser

I am trying to get a sax parser to work in nw04 but not having much luck. The sap documentation indicates that I need to define system properties as follows.

javax.xml.parsers.DocumentBuilderFactory=

com.sap.engine.lib.jaxp.DocumentBuilderFactoryImpl

javax.xml.parsers.SAXParserFactory=

com.sap.engine.lib.jaxp.SAXParserFactoryImpl

javax.xml.transform.TransformerFactory=

com.sap.engine.lib.jaxp.TransformerFactoryImpl

But regardless of whether or not I do, I get the following exception.

org.xml.sax.SAXException: System property org.xml.sax.driver not specified

I cannot find a value for this system property that works.

I am writing a standalone dc application. My sample code is as follows.

import java.io.FileReader;

import org.xml.sax.*;

import org.xml.sax.helpers.*;

public class MyHandler extends DefaultHandler {

...

public static void main(String[] args) throws Exception{

System.setProperty

("javax.xml.parsers.DocumentBuilderFactory",

"com.sap.engine.lib.jaxp.DocumentBuilderFactoryImpl");

System.setProperty

"javax.xml.parsers.SAXParserFactory",

"com.sap.engine.lib.jaxp.SAXParserFactoryImpl.apache.xerces.parsers.SAXParser");

System.setProperty

"javax.xml.transform.TransformerFactory",

"com.sap.engine.lib.jaxp.TransformerFactoryImpl");

XMLReader xr = XMLReaderFactory.createXMLReader();

MyHandler handler = new MyHandler();

xr.setContentHandler(handler);

xr.setErrorHandler(handler);

FileReader r = new FileReader("/roses.xml");

xr.parse(new InputSource(r));

}

}

Donald

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jun 08, 2005 at 08:52 PM

    I was able to get it to work without setting any of the properties that I mentioned, just by selecting a different classloader. The JAXPSAXExample2 example code worked like a charm.

    Donald

    Add comment
    10|10000 characters needed characters exceeded