Code example for InputSource

0
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        XMLReader reader = parser.getXMLReader();
        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", prefixes);
        reader.setFeature("http://xml.org/sax/features/namespaces", namespaces);
        reader.setContentHandler(handler);
        reader.parse(new InputSource(new StringReader(xml)));
    } 
 
    /** 
     * @param expected an optional value that may or may have not been supplied 
     * @param sentinel a marker value that means the expected value was omitted 
     */ 
    private void assertOneOf(String expected, String sentinel, String actual) {
        List<String> optionsList = Arrays.asList(sentinel, expected);
        assertTrue("Expected one of " + optionsList + " but was " + actual,
                optionsList.contains(actual));
    } 
 
    /** 
     * This SAX handler throws on everything but startDocument, endDocument, 
     * and setDocumentLocator(). Override the methods that are expected to be