Code example for SAXSource

0
    protected void runTest() throws Throwable { 
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
        SAXParser parser = factory.newSAXParser();
        SAXSource source = new SAXSource(parser.getXMLReader(),
                new InputSource(new StringReader("<root xmlns=''/>")));
        OMElement element = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
                source).getDocumentElement();
        assertNull(element.getNamespace());
    } 
} 
Experience pair programming with AI  Get Codota for Java