Page 1 of 1

Add text to setAttribute

Posted: Thu Apr 11, 2019 12:20 am
by jlpoole ... space.html

has this description for Interface AuthorDocumentController.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.

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.

Re: Add text to setAttribute

Posted: Thu Apr 11, 2019 1:26 pm
by Radu

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.

Re: Add text to setAttribute

Posted: Fri Apr 12, 2019 2:12 am
by jlpoole
Great. Thank you.