Hi all,
OMAttribute interface doesn't provide methods to retrieve its parent.
OMAttribute interface is implemented in the following classes,
1. org.apache.axiom.om.impl.llom.OMAttributeImpl
2. org.apache.axiom.om.xpath.DocumentNavigator.OMAttributeEx
3. org.apache.axiom.om.impl.dom.AttrImpl
AttrImpl already has methods, getParent() and setParent() as it implememnts
OMNode interface. OMAttributeEx also set the parent in its constructor. Thus
adding a getParent() and setParent() method to OMAttribute interface would
not affect these two implementations. Thus we can freely implement these two
methods in OMAttributeImpl class.
The issue is if we add a parent reference to OMAttirbute we need to restrict
the use of an instance of OMAttribute only with a particular instance of
OMElement, i.e. we can't do the following,
OMAttribute attr = //create an OMAttribute
OMElement e1 = //create an OMElement
OMElement e2 = //create another OMElement
e1.addAttribute(attr);//same attribute is added to both the elments
e2.addAttribute(attr);
This restriction is infact obvious because if we allow this then an
OMAttribute would have more than one parent which is of no use.
Adding a method to retrieve the parent of an OMAttribute is really useful so
I guess it is worth the cost to enforce this restriction.
Your idea on this matter is greatly accepted
Thanks in advance
Saliya