parseXml method

void parseXml(
  1. DisplayModel displayModel,
  2. String content
)

Parses a given xml string and creates the renderinstruction-structure. The renderinstruction classes serves two purposes: On the one hand to parse the xml and create the tree structure and on the other hand to render ways and pois appropriately and draw the respective content.

Implementation

void parseXml(DisplayModel displayModel, String content) {
  assert(content.length > 10);
  int time = DateTime.now().millisecondsSinceEpoch;
  XmlDocument document = XmlDocument.parse(content);
  assert(document.children.length > 0);
  bool foundRendertheme = false;
  for (XmlNode node in document.children) {
    switch (node.nodeType) {
      case XmlNodeType.TEXT:
        break;
      case XmlNodeType.PROCESSING:
        break;
      case XmlNodeType.ELEMENT:
        {
          XmlElement element = node as XmlElement;
          if (element.name.toString() != "rendertheme")
            throw Exception("Invalid root node ${element.name.toString()}");
          foundRendertheme = true;
          _parseRendertheme(displayModel, element);
          break;
        }
      case XmlNodeType.ATTRIBUTE:
        throw Exception("Invalid node ${node.nodeType.toString()}");
      case XmlNodeType.CDATA:
        throw Exception("Invalid node ${node.nodeType.toString()}");
      case XmlNodeType.COMMENT:
        // throw Exception("Invalid node ${node.nodeType.toString()}");
        break;
      case XmlNodeType.DOCUMENT:
        throw Exception("Invalid node ${node.nodeType.toString()}");
      case XmlNodeType.DOCUMENT_FRAGMENT:
        throw Exception("Invalid node ${node.nodeType.toString()}");
      case XmlNodeType.DOCUMENT_TYPE:
        throw Exception("Invalid node ${node.nodeType.toString()}");
      case XmlNodeType.DECLARATION:
        break;
    }
  }
  assert(foundRendertheme);
  for (RuleBuilder ruleBuilder in ruleBuilderStack) {
    ruleBuilder.validateTree();
  }
  //_log.info("Found ${initPendings.length} items for lazy initialization");
}