getXmlDocument function

KElement getXmlDocument(
  1. String source
)

Parses source and consolidates its text, as JavaRosa's XFormParser.getXMLDocument does: the document element of the result.

Throws XFormParseException for malformed XML, with JavaRosa's message (XML Syntax Error at Line: 1, Column: 7!).

Implementation

KElement getXmlDocument(String source) {
  final KElement root;
  try {
    root = parseKDocument(source);
  } on xml.XmlParserException catch (e) {
    throw XFormParseException(
      'XML Syntax Error at Line: ${e.line}, Column: ${e.column}!',
    );
  } on xml.XmlException {
    throw XFormParseException('Unhandled Exception while Parsing XForm');
  }
  consolidateText(root);
  return root;
}