Hi Thomas
Actually right now its setAttributeValue(name,value) to set the value and
attributeValue(name) to retrieve the value.
The main reason for the difference is that an element can only have one
value for a given name so calling setXX seemed more appropriate than addXX.
Though maybe I'm having second thoughts.
Would people prefer addAttribute?
Element foo = doc.addElement( "foo" ).addAttribute(
"id", "123").addText( "some text" );
It is more consistent I suppose. I'm kinda tempted
now...
It may be quite confusing for users, but we could let the add() method Moving these few methods into AbstractElement and AbstractDocument would be
fine with me (its really not much code and its more 'plumbing' code rather than
'real' code anyway).
Agreed. I miss being able to do mixins in Java. Though like C++ templates,
pointers and operator overloading, its only on rare occasions I miss
them.
Yes, this is elegant... Agreed. After writing the above code, I kinda like
it now. Its a shame we can't think a way of writing the above using addElement()
rather than the add() method to avoid the factory.createElement() lines, it
would be much simpler then...
I've never quite got into XMLC. I wonder if we need
a dom4j equivalent?
Cool.
Agreed. I'm not totally sold on the
add() approach but I think it makes sense. I'll sleep on it some
more.
3.
If add() is to return the added Branch, I'd much prefer add (Element) to return
Element, not Branch - cast ye away the works of Mammon.
Agreed - it must return an Element or Document. We
can just leave the add(Node) to be the polymorphic method.
4.
I'm confused about the distinction between addXYZ and setXYZ methods - I don't
expect setXYZ(...) to create a new object.
Agreed.
What are others thoughts on renaming
setAttributeValue() -> addAttribute()?
James
|
- Re: [dom4j-dev] Why do add(...) methods return void? James Strachan
- Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Re: [dom4j-dev] Why do add(...) methods return void? James Strachan
- Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Re: [dom4j-dev] Why do add(...) methods return void? James Elson
- Re: [dom4j-dev] Why do add(...) methods return void? James Strachan
- Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Fwd: Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Re: Re: [dom4j-dev] Why do add(...) methods return void? James Strachan
- Re: Re: [dom4j-dev] Why do add(...) methods return void? James Strachan
- Re: [dom4j-dev] Why do add(...) methods return void? Thomas Nichols
- Re: [dom4j-dev] Why do add(...) methods return void? James Strachan