[
Lists Home |
Date Index |
Thread Index
]
Since we are still not done with all the SAX issues:
here is another thing that has never been clear to me:
Docs for startElement say this:
<quote>
This event allows up to three name components for each element:
1.. the Namespace URI;
2.. the local name; and
3.. the qualified (prefixed) name.
Any or all of these may be provided, depending on the values of the
http://xml.org/sax/features/namespaces and the
http://xml.org/sax/features/namespace-prefixes properties:
a.. the Namespace URI and local name are required when the namespaces
property is true (the default), and are optional when the namespaces
property is false (if one is specified, both must be);
b.. the qualified name is required when the namespace-prefixes property
is true, and is optional when the namespace-prefixes property is false
(the default).
</quote>
Strictly speaking that means that, when both features above are false,
all three components - uri, localName, qName - are optional?
And if I have a localName then an URI must be specified, based on a).
So, if there is no namespace defined, then there is no URI and therefore
localName must be empty, which leaves the qName. Now, if namespace processing
is turned off, then qNames don't exist, but we also can't use the localName.
So, one could say that in the absence of namespace processing qName = Name.
But it is still optional.
This leaves me with this scenario - assuming namespace processing is turned on,
but namespace-prefixes is turned off:
- If the name is in a namespace, I will receive an URI and a localName,
but not necessarily a qName.
- If the name is not in a namespace, I will not receive an URI and a localName,
but I should receive a qName (although strictly speaking it is optional).
This forces me to have some checking logic even when I know how
the features are set.
So far I have used this approach in the SAX2 adapter for Expat:
Always provide a localName and qName, even if they are the same.
I know, this contradicts a), but I am confused anyway.
The API would be easier to use if the three components provided
were URI, localName and prefix. No confusion there.
But considering the current API can't be changed, why not make
the qName parameter required at all times, even if it is not
required to contain the prefix?
Karl
|