use of javax.xml.parsers.SAXParser in project robovm by robovm.
the class SimpleParserTest method testWorkingFile2.
public void testWorkingFile2() throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(false);
factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
SAXParser parser = factory.newSAXParser();
parser.getXMLReader().setContentHandler(contentHandler);
parser.parse(getClass().getResourceAsStream("/SimpleParserTest.xml"), (DefaultHandler) null);
assertFalse(parser.isNamespaceAware());
assertEquals("The:quick,brown:fox", instructions.toString());
assertEquals("t:stuff,nestedStuff,nestedStuff,nestedStuff", elements2.toString());
assertEquals("Some text here,some more here...", text.toString());
assertEquals("eins", attributes2.get("one"));
assertEquals("zwei", attributes2.get("two"));
assertEquals("drei", attributes2.get("three"));
assertEquals(0, namespaces2.size());
}
use of javax.xml.parsers.SAXParser in project robovm by robovm.
the class XercesHTML2DocumentBuilderFactory method load.
public Document load(java.net.URL url) throws DOMTestLoadException {
Document doc = null;
try {
SAXParser parser = factory.newSAXParser();
HTMLHandler handler = new HTMLHandler(htmlBuilderConstructor, getHTMLDocumentMethod);
parser.parse(url.toString(), handler);
doc = handler.getHTMLDocument();
} catch (Exception ex) {
throw new DOMTestLoadException(ex);
}
return doc;
}
use of javax.xml.parsers.SAXParser in project robovm by robovm.
the class XercesHTMLDocumentBuilderFactory method load.
public Document load(java.net.URL url) throws DOMTestLoadException {
Document doc = null;
try {
SAXParser parser = factory.newSAXParser();
HTMLHandler handler = new HTMLHandler(htmlBuilderConstructor, getHTMLDocumentMethod);
parser.parse(url.toString(), handler);
doc = handler.getHTMLDocument();
} catch (Exception ex) {
throw new DOMTestLoadException(ex);
}
return doc;
}
use of javax.xml.parsers.SAXParser in project robovm by robovm.
the class SAXParserTest method initFiles.
public void initFiles() throws Exception {
// we differntiate between a validating and a non validating parser
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
validating = parser.isValidating();
} catch (Exception e) {
fail("could not obtain a SAXParser");
}
String tmpPath = System.getProperty("java.io.tmpdir");
// nwf = not well formed, wf = well formed
list_wf = new File[] { new File(tmpPath + "/" + SAXParserTestSupport.XML_WF + "staff.xml") };
list_nwf = new File[] { new File(tmpPath + "/" + SAXParserTestSupport.XML_NWF + "staff.xml") };
list_out_dh = new File[] { new File(tmpPath + "/" + SAXParserTestSupport.XML_WF_OUT_DH + "staff.out") };
list_out_hb = new File[] { new File(tmpPath + "/" + SAXParserTestSupport.XML_WF_OUT_HB + "staff.out") };
list_wf[0].deleteOnExit();
list_nwf[0].deleteOnExit();
list_out_hb[0].deleteOnExit();
list_out_dh[0].deleteOnExit();
Support_Resources.copyLocalFileto(list_wf[0], getResource(SAXParserTestSupport.XML_WF + "staff.xml"));
Support_Resources.copyLocalFileto(new File(tmpPath + "/" + SAXParserTestSupport.XML_WF + "staff.dtd"), getResource(SAXParserTestSupport.XML_WF + "staff.dtd"));
Support_Resources.copyLocalFileto(list_nwf[0], getResource(SAXParserTestSupport.XML_NWF + "staff.xml"));
Support_Resources.copyLocalFileto(new File(tmpPath + "/" + SAXParserTestSupport.XML_NWF + "staff.dtd"), getResource(SAXParserTestSupport.XML_NWF + "staff.dtd"));
Support_Resources.copyLocalFileto(list_out_dh[0], getResource(SAXParserTestSupport.XML_WF_OUT_DH + "staff.out"));
Support_Resources.copyLocalFileto(list_out_hb[0], getResource(SAXParserTestSupport.XML_WF_OUT_HB + "staff.out"));
}
use of javax.xml.parsers.SAXParser in project platform_frameworks_base by android.
the class XMLParser method parse.
public XMLNode parse(String text) throws IOException, SAXException {
if (TextUtils.isEmpty(text)) {
throw new IOException("XML string not provided");
}
// Reset pointers.
mRoot = null;
mCurrent = null;
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new InputSource(new StringReader(text)), this);
return mRoot;
} catch (ParserConfigurationException pce) {
throw new SAXException(pce);
}
}
Aggregations