protected virtual void WriteAttributes(SvgNode svgNode, XmlElement xmlElement) { var topParentNode = xmlElement; while (topParentNode.ParentNode as XmlElement != null) { topParentNode = topParentNode.ParentNode as XmlElement; } var prefix = xmlElement.GetPrefixOfNamespace(XmlNamespace.AurigmaSvg); if (string.IsNullOrEmpty(prefix)) { topParentNode.SetAttribute("xmlns:aursvg", XmlNamespace.AurigmaSvg); } var type = _typeResolver.ResolveTypeAttribute(svgNode.GetType()); if (!string.IsNullOrEmpty(type)) { xmlElement.SetAttributeNode("type", XmlNamespace.AurigmaSvg).Value = type; } var attributes = svgNode.GetAttributes(); if (attributes != null) { foreach (var attr in attributes) { var value = attr.GetValue(); if (attr.DefaultValue != value && !string.IsNullOrEmpty(value)) { XmlAttribute attrNode; if (attr.NamespaceUri == XmlNamespace.Svg) { attrNode = _xmlDocument.CreateAttribute(attr.LocalName); } else { prefix = xmlElement.GetPrefixOfNamespace(attr.NamespaceUri); if (string.IsNullOrEmpty(prefix)) { prefix = _typeResolver.GetPrefix(attr.NamespaceUri); if (!string.IsNullOrEmpty(prefix)) { topParentNode.SetAttribute("xmlns:" + prefix, attr.NamespaceUri); } } attrNode = _xmlDocument.CreateAttribute(attr.LocalName, attr.NamespaceUri); } attrNode.Value = value; xmlElement.Attributes.Append(attrNode); } } } }