[jdom-interest] Namespace problems in Attributes...

Brett McLaughlin brett.mclaughlin at lutris.com
Fri Jul 28 12:14:26 PDT 2000


philip.nelson at omniresources.com wrote:
> 
> >
> > 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?

As a follow-up to this, we are removing the 3 and 4 argument
constructors, and will just have these:

Attribute(String name, String value);
Attribute(String name, String value, Namespace namespace);

so this is clearer. I hope this will help... 

-Brett

> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org




More information about the jdom-interest mailing list