Since many prefixes may be mapped to the same URI, the return value may be unreliable.
Parameters:
uri
: URI to look up.Returns:
The associated prefix, or null
if none is declared.
SEE: NamespaceSupport.prefix
# Look up one of the prefixes associated with a URI in this context.
#
# Since many prefixes may be mapped to the same URI,
# the return value may be unreliable.
#
# Parameters:
#
# * `uri`: URI to look up.
#
# Returns:
#
# The associated prefix, or `null` if none is declared.
#
# SEE: `NamespaceSupport.prefix`
fun prefix(uri: String): nullable String do
# Note: We do not use the original code from SAX 2.0.1 because it is
# buggy with redefined prefixes. For example, with
# `<x xmlns:y="1"><z xmlns:y="2" /></x>`, when in `z`, `uri("1")`
# returns `"y"` in the original code while it should return `null`.
# Our code is slower, but it works.
var all_prefixes = prefixes
for prefix in all_prefixes do
if uri == self.uri(prefix) then
return prefix
end
end
return null
end
lib/sax/helpers/namespace_support.nit:594,2--622,4