namespaceUri property
The namespace URI, or null
. Can only be resolved when the named entity
has complete and up-to-date XmlParented.parentEvent
information.
Implementation
String? get namespaceUri {
// Identify the prefix and local name to match.
final index = name.indexOf(XmlToken.namespace);
final prefix = index < 0 ? null : xmlns;
final local = index < 0 ? xmlns : name.substring(0, index);
// Identify the start element to match.
final start = this is XmlStartElementEvent
? this as XmlStartElementEvent
: parentEvent;
// Walk up the tree to find the matching namespace.
for (var event = start; event != null; event = event.parentEvent) {
for (final attribute in event.attributes) {
if (attribute.namespacePrefix == prefix &&
attribute.localName == local) {
return attribute.value;
}
}
}
// Namespace could not be identified.
return null;
}