loadExternalDtd method

Future<void> loadExternalDtd()

Attempts to load all external DTD references contained within the XmlDoctype and nested XmlEntitys, load the pages they reference, and parse the DTD elements contained within.

External DTD will not be loaded if this document's XML declaration's standalone attribute is set to yes.

Implementation

Future<void> loadExternalDtd() async {
  // Don't attempt to load DTDs if the document is flagged as standalone.
  if (xmlDeclaration?.standalone == true || children.isEmpty) return;

  for (var i = 0; i < children.length; i++) {
    final child = children[i];

    if (child is XmlConditional) {
      await child.loadExternalDtd();
    } else if (child is XmlDoctype) {
      final externalDtd = await child.loadExternalDtd();
      if (externalDtd != null) children[i] = externalDtd;
    } else if (child is XmlElement) {
      await child.loadExternalDtd();
    } else if (child is XmlEntity) {
      final externalEntities = await child.loadExternalEntities();
      if (externalEntities != null) children[i] = externalEntities;
    }
  }

  return;
}