Can you please help me understand what is the difference between 'local name' and 'qualified name' in a xml attribute? From http://developer.android.com/reference/org/xml/sax/Attributes.html:
/** Look up an attribute's local name by index. */
abstract String getLocalName(int index)
/** Look up an attribute's XML qualified (prefixed) name by index. */
abstract String getQName(int index)
In this example,
<anelement attr1="test" attr2="test2"> </anelement>
What will be the difference?
A QName, or qualified name, is the fully qualified name of an element, attribute, or identifier in an XML document. A QName concisely associates the URI of an XML namespace with the local name of an element, attribute, or identifier in that namespace.
Generally speaking, localname is the local name, meaning inside the namespace. qname, or qualified name, is the full name (including namespace).
XML namespaces provide a method for qualifying the names of XML elements and XML attributes in XML documents. A qualified name consists of a prefix and a local name, separated by a colon. The prefix functions only as a placeholder; it is mapped to a URI that specifies a namespace.
A local name is one which isn't qualified by a namespace. The fully qualified one includes the namespace, if any.
It's probably worth reading the W3C recommendation on XML names to get the full details.
Basically if you don't have xmlns
anywhere in your XML file, you probably won't need to worry about namespaces. If you do have namespaces, you'll probably want to create a fully qualified name when checking for element names etc.
Note that attributes are generally less likely to use namespaces than elements, in my experience.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With