private void WriteAttributeName(XAttribute attribute)
{
XPath.Append("@");
if(string.IsNullOrEmpty(attribute.Name.NamespaceName))
{
XPath.Append(attribute.Name.LocalName);
return;
}
if(attribute.Parent == null)
{
throw new XmlException($"Unable to determine namespace prefix for attribute \"{attribute.Name}\". Parent is null.");
}
var namespacePrefix = attribute.Parent.GetPrefixOfNamespace(attribute.Name.Namespace);
if(string.IsNullOrEmpty(namespacePrefix))
{
WriteAttributeNameWithoutPrefix(attribute.Name);
}
else
{
WriteAttributeNameWithPrefix(namespacePrefix, attribute.Name.LocalName);
}
}