\r
/**\r
* A helper function for derived classes.\r
- * This 'normalizes' newString and then if it is different from oldString\r
- * invalidates the DOM. It returns the normalized value.\r
+ * This 'normalizes' newString, and then if it is different from oldString,\r
+ * it invalidates the DOM, frees the old string, and return the new.\r
+ * If not different, it frees the new string and just returns the old value.\r
* \r
* @param oldValue - the current value\r
* @param newValue - the new value\r
* \r
* @return the value that should be assigned\r
*/\r
- XMLCh* prepareForAssignment(const XMLCh* oldValue, const XMLCh* newValue) {\r
+ XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) {\r
XMLCh* newString = XMLString::replicate(newValue);\r
XMLString::trim(newString);\r
-\r
- if (!XMLString::equals(oldValue,newValue))\r
+ if (!XMLString::equals(oldValue,newValue)) {\r
releaseThisandParentDOM();\r
- \r
- return newString;\r
+ XMLString::release(&oldValue);\r
+ return newString;\r
+ }\r
+ XMLString::release(&newString);\r
+ return oldValue; \r
}\r
- \r
+\r
+ /**\r
+ * A helper function for derived classes, for assignment of (singleton) XML objects.\r
+ * \r
+ * It is indifferent to whether either the old or the new version of the value is null. \r
+ * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
+ * \r
+ * @param oldValue - current value\r
+ * @param newValue - proposed new value\r
+ * @return the value to assign \r
+ * \r
+ * @throws XMLObjectException if the new child already has a parent.\r
+ */\r
+ XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);\r
+\r
private:\r
DOMElement* m_dom;\r
DOMDocument* m_document;\r