toXml method

  1. @override
void toXml(
  1. XmlBuilder context,
  2. NamespaceManager nsmgr
)
override

Implementation

@override
void toXml(XmlBuilder context, NamespaceManager nsmgr) {
  final Map<String, String?> namespaces;
  final namespace = this.namespace;
  switch (namespace) {
    case null:
      namespaces = const {};
    case "":
      namespaces = const {"": null};
    default:
      if (!nsmgr.contain(namespace)) {
        namespaces = {namespace: nsmgr.generate(namespace)};
      } else {
        namespaces = const {};
      }
  }
  context.element(name, namespace: namespace, namespaces: namespaces);
}