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 {};
      }
  }
  final value = this.value;
  final lang = this.lang;
  context.element(
    name,
    namespace: namespace,
    namespaces: namespaces,
    attributes: lang != null ? {kXmlLangAttrName: lang} : const {},
    nest: value != null ? () => value.toXml(context, nsmgr) : null,
  );
}