toXml method

XmlElement toXml(
  1. String elemName, {
  2. List<XmlAttribute>? attributes,
})

Implementation

_s.XmlElement toXml(String elemName, {List<_s.XmlAttribute>? attributes}) {
  final type = this.type;
  final displayName = this.displayName;
  final emailAddress = this.emailAddress;
  final id = this.id;
  final uri = this.uri;
  final $children = <_s.XmlNode>[
    if (displayName != null)
      _s.encodeXmlStringValue('DisplayName', displayName),
    if (emailAddress != null)
      _s.encodeXmlStringValue('EmailAddress', emailAddress),
    if (id != null) _s.encodeXmlStringValue('ID', id),
    if (uri != null) _s.encodeXmlStringValue('URI', uri),
  ];
  final $attributes = <_s.XmlAttribute>[
    ...?attributes,
    _s.XmlAttribute(_s.XmlName('xsi', 'xmlns'),
        'http://www.w3.org/2001/XMLSchema-instance'),
    _s.XmlAttribute(_s.XmlName('xsi:type'), type.toValue()),
  ];
  return _s.XmlElement(
    _s.XmlName(elemName),
    $attributes,
    $children,
  );
}