A QName
is a namespace-qualified name. Here is XML containing two QNames
:
<ac:aircraft xmlns:ac="http://www.aircraft.org">
<ac:altitude>12,000 feet</ac:altitude>
</ac:aircraft>
The two abbreviated QNames
are:
ac:aircraft
ac:altitude
The expanded QNames
are:
{http://www.aircraft.org}aircraft
{http://www.aircraft.org}altitude
XML parsers know the rules for converting short names (abbreviated names) to long names (expanded names).
The abbreviated form of the names are statically -- at parse time -- resolvable to the long names.
QNames
may also be used in data. In the following XML, the value of the <log>
element is a QName
:
<network-traffic xmlns:network="http://www.network-traffic.org">
<log>network:client-error</log>
</network-traffic>
XML parsers operate only on markup, not data. So, an XML parser does not convert the short name to the long name. The mapping from short name to long name must be done by a higher level application such as an XSLT processor or an XML Schema validator. In other words, the resolution of short name to long name must be done dynamically, not statically.
Question: Why is it better to statically resolve short names to long names? What are the disadvantages of dynamically resolving short names to long names? Can you provide a concrete example of where problems arise as a result of having to dynamically resolve short names to long names? What are the practical benefits to static analysis of QNames?