Hello,

I (assume I) have some problems using a SAXParser "the OSGi way".

Code like this is currently (Karaf 4.2.0 and Java 8) working:

===
final SAXParserFactory factory = SAXParserFactory.newInstance();
final SAXParser saxParser;
try {
    saxParser = factory.newSAXParser();
} catch (ParserConfigurationException | SAXException ex) {
    throw new IllegalStateException(ex);
}
===


I have read this:
https://osgi.org/javadoc/r4v41/org/osgi/util/xml/XMLParserActivator.html

So I would assume there exist a SAX XML parser (factory) "somewhere" that
can be referenced as an OSGi service.


I  tried Xerces:

===
karaf@root()> bundle:install -s
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/2.12.0_1

karaf@root()> bundle:classes -a org.apache.servicemix.bundles.xerces | grep
SAXParserFactory

META-INF/services/javax.xml.parsers.SAXParserFactory | exported: false
org/apache/xerces/jaxp/SAXParserFactoryImpl.class | exported: true
org/apache/xerces/jaxp/javax.xml.parsers.SAXParserFactory | exported: true
META-INF/services/javax.xml.parsers.SAXParserFactory | exported: false
org/apache/xerces/jaxp/SAXParserFactoryImpl.class | exported: true
org/apache/xerces/jaxp/SAXParserFactoryImpl.java | exported: true
org/apache/xerces/jaxp/javax.xml.parsers.SAXParserFactory | exported: true

karaf@root()> service:list -a -n | grep -i sax
[nothing]
===


I also tried to install the OSGi XML util:

===
karaf@root()> bundle:install -s mvn:org.osgi/org.osgi.util.xml/1.0.1

karaf@root()> service:list -a -n | grep -i sax
[nothing]
===


Can you point me to a SAX parser factory that is provided as an OSGi
service?

Should I rely that on a working "SAXParserFactory.newInstance()" call?

How to use SAX parsing correctly?

Best regards,
Markus

Reply via email to