parseXmlAttributes static method

Map<String, dynamic> parseXmlAttributes(
  1. XmlElement element,
  2. Dependencies dependencies, {
  3. Inflater? inflater,
  4. Iterable<XmlAttribute>? inheritedAttributes,
})

Implementation

static Map<String, dynamic> parseXmlAttributes(
  XmlElement element,
  Dependencies dependencies, {
  Inflater? inflater,
  Iterable<XmlAttribute>? inheritedAttributes,
}) {
  final attributes = <String, dynamic>{};
  final mergedAttributes = mergeXmlAttributes(element.attributes, inheritedAttributes);
  for (final attribute in mergedAttributes) {
    try {
      final attributeName = attribute.qualifiedName;
      final attributeValue = parseAttribute(
        attributeName: attributeName,
        attributeValue: attribute.value,
        dependencies: dependencies,
        inflater: inflater,
      );
      attributes[attributeName] = attributeValue;
    } catch (e, stacktrace) {
      final msg = "Problem parsing XML attribute '${attribute.qualifiedName}'";
      _log.severe("$msg: ${dump(element, dependencies)}", e, stacktrace);

      // track xml attribute parsing error
      final name = element.position?.filePath;
      final tag = element.position?.openTag;
      final line = tag?.start.line;
      final col = tag?.start.column;
      final pos = "[line:$line, col:$col]";
      Analytics.trackError(fragmentName: name, error: "$msg: $e $pos");
    }
  }
  return attributes;
}