use of org.javarosa.xform.util.InterningKXmlParser in project javarosa by opendatakit.
the class XFormParser method getXMLDocument.
/**
* Uses xkml to parse the provided XML content, and then consolidates text elements.
*
* @param reader the XML content provider
* @param stringCache an optional string cache, whose presence will cause the use of
* {@link InterningKXmlParser} rather than {@link KXmlParser}.
* @return the parsed document
* @throws IOException
* @deprecated The InterningKXmlParser is not used.
*/
@Deprecated
public static Document getXMLDocument(Reader reader, CacheTable<String> stringCache) throws IOException {
final CodeTimer ctParse = new CodeTimer("Reading XML and parsing with kXML2");
Document doc = new Document();
try {
KXmlParser parser;
if (stringCache != null) {
parser = new InterningKXmlParser(stringCache);
} else {
parser = new KXmlParser();
}
parser.setInput(reader);
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
doc.parse(parser);
} catch (XmlPullParserException e) {
String errorMsg = "XML Syntax Error at Line: " + e.getLineNumber() + ", Column: " + e.getColumnNumber() + "!";
Std.err.println(errorMsg);
Std.printStack(e);
throw new XFormParseException(errorMsg);
} catch (IOException e) {
// CTS - 12/09/2012 - Stop swallowing IO Exceptions
throw e;
} catch (Exception e) {
// #if debug.output==verbose || debug.output==exception
String errorMsg = "Unhandled Exception while Parsing XForm";
Std.err.println(errorMsg);
Std.printStack(e);
throw new XFormParseException(errorMsg);
// #endif
}
try {
reader.close();
} catch (IOException e) {
Std.out.println("Error closing reader");
Std.printStack(e);
}
ctParse.logDone();
final CodeTimer ctConsolidate = new CodeTimer("Consolidating text");
XmlTextConsolidator.consolidateText(stringCache, doc.getRootElement());
ctConsolidate.logDone();
return doc;
}
Aggregations