Add text to setAttribute

Are you missing a feature? Request its implementation here.
jlpoole
Posts: 23
Joined: Sun Jan 15, 2017 3:15 pm
Location: Salem, Oregon

Add text to setAttribute

Post by jlpoole »

https://www.oxygenxml.com/InstData/Edit ... space.html

has this description for Interface AuthorDocumentController.setAttribute
setAttribute

void setAttribute(java.lang.String qName,
AttrValue attributeValue)

Sets the value of an attribute for this element.
Warning: Use this only when the element is from an AuthorDocumentFragment and not from the current AuthorDocument content.
All operations on nodes from the document model must be done using the AuthorDocumentController methods.

Parameters:
qName - The qualified name of the attribute to be set.
attributeValue - The AttrValue to set. Must not be null.
If an element this method is being applied to does not have the attribute, then an attribute will be created. This is a subtle distinction as some XML models will error out unless the attribute is already present, in other words you have to check for the presence of the attribute, then if it is present you may set its value. In Oxygen, that test is not required, you can simply call setAttribute and if the attribute is not present, then the method will instantiate a new attribute.

I recommend the description of this method indicate this... unless I missed something elsewhere which suggests autovivification is the default behavior.
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Add text to setAttribute

Post by Radu »

Hi,

Thanks for the advice, I modified on our side the Javadoc comment on the method and added to it:
If the element does not have the attribute specified by name, then an attribute with the specified value will be automatically created.
Thanks,
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
jlpoole
Posts: 23
Joined: Sun Jan 15, 2017 3:15 pm
Location: Salem, Oregon

Re: Add text to setAttribute

Post by jlpoole »

Great. Thank you.
Post Reply