sax :: Context :: process_name
Parameters:
qname
: raw XML qualified name.is_attribute
: true
if this is an attribute name.Returns:
An array of three strings containing the URI part (or empty string),
the local part and the raw name, or null
if there is an undeclared
prefix.
SEE: NamespaceSupport.process_name
# Process a raw XML qualified name in this context.
#
# Parameters:
#
# * `qname`: raw XML qualified name.
# * `is_attribute`: `true` if this is an attribute name.
#
# Returns:
#
# An array of three strings containing the URI part (or empty string),
# the local part and the raw name, or `null` if there is an undeclared
# prefix.
#
# SEE: `NamespaceSupport.process_name`
fun process_name(qname: String, is_attribute: Bool):
nullable Array[String] do
var name: Array[String]
var table: Map[String, Array[String]]
var match: nullable Match
# Detect errors in call sequence.
decls_ok = false
# Select the appropriate table.
if is_attribute then
table = attribute_name_table.as(not null)
else
table = element_name_table.as(not null)
end
# Start by looking in the cache, and
# return immediately if the name
# is already known in this content.
if table.keys.has(qname) then
return table[qname]
end
# We haven't seen this name in this
# context before. Maybe in the parent
# context, but we can't assume prefix
# bindings are the same.
name = new Array[String].with_capacity(3)
match = qname.search(':')
if match == null then
# No prefix
if is_attribute then
name.push("")
else
name.push(default_ns or else "")
end
name.push(qname)
name.push(qname)
else
# Prefix
var prefix = qname.substring(0, match.from)
if prefix == "" then
if is_attribute then
name.push("")
else
name.push(default_ns or else "")
end
name.push(qname.substring_from(match.after))
name.push(qname)
else if (not is_attribute) and "xmlns" == prefix then
return null
else if prefix_table.keys.has(prefix) then
name.push(prefix_table[prefix])
name.push(qname.substring_from(match.after))
name.push(qname)
else
return null
end
end
# Save in the cache for future use.
# (Could be shared with parent context...)
table[qname] = name
return name
end
lib/sax/helpers/namespace_support.nit:494,2--573,4