[jdom-interest] Namespace problems in Attributes...
philip.nelson at omniresources.com
philip.nelson at omniresources.com
Fri Jul 28 07:36:17 PDT 2000
>
> The problem is that I don't know enough about namespaces to
> understand what
> the code should be doing but here are the details that may
> mean more to you
> than me:
>
> The method startElement() in SAXBuilder.SAXHandler is called
> and an attept
> is made at creating an attribute inside the 'if' clause:
> if (!attName.startsWith("xmlns")) {
>
> obviously in response to finding xml:lang="en".
>
> The four Attribute constuctor values are:
> name = 'lang'
> prefix = 'xml'
> uri = [empty string]
> val = 'en'
I remember this happening to me once while writing Attribute test cases.
The problem which wasn't at all obvious to me was that the constructor that
uses the URI couldn't be passed an empty string. You are not suppose to
use that constructor if you don't actually have a URI
OK
Attribute attr = new Attribute("test", "prefx", "http://some.other.place",
"value");
Not OK
Attribute attr = new Attribute("test", "prefx", "", "value");
This would be a problem of course of if you didn't know for certain at
design time whether or not you actually had the URI.
Are you passing an empty string to the URI argument?
More information about the jdom-interest
mailing list