Re: attribute namespace "" or null or both
Stefan Haustein <[email protected]>
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Organization | Univ. Dortmund FB 4 LS 8 |
| Message-ID | <[email protected]> |
Aleksander Slominski wrote:
> looking on some problems that XmlPull API users have reported
> i think that it will be beneficial that in case when namespaces are enabled
> we allow both empty string ("") and null as namespace when retrieving
> value of attribute that has no namespace
Perhaps we can use null as "joker" matching any namespace,
like in the require case?
> those two would be equivalent: if namespaces are enabled:
> getAttributeValue ("", name)
> getAttributeValue (null, name)
> and if namespaces are disabled
> getAttributeValue ("", name) will throw IllegalArgumentException
> getAttributeValue (null, name) works OK
In my opinion, the default namespace ("") should work regardless
whether namespace support is switched on or not, so in the
second case both should work OK. Also, disallowing "" when
namespaces are switched off would break backwards compatibility.
There is another issue associated with getPrefix in the writer:
While the default namespace is valid for elements, it does not
help for attribues. Thus, in my opinion, getPrefix should have
the following signature:
String getPrefix (String namespace, boolean create,
boolean forAttribute)
getPrefix with create==true and forAttribute==false
would return "" for the default namespace if it fits
the namespace parameter, but a newly created namespace
if forAttribute is set to true?
What do you think?
Best,
Stefan