cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to use SAX Parser

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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