Description
Creates a clone of the PBDOM_ATTRIBUTE object.
Syntax
pbdom_attribute_name.Clone(boolean bDeep)
Argument |
Description |
---|---|
pbdom_attribute_name |
The name of the PBDOM_ATTRIBUTE. |
bDeep |
A boolean specifying whether a deep or shallow clone is returned. Values are true for a deep clone and false for a shallow clone. |
Return value
PBDOM_OBJECT. A clone of this PBDOM_ATTRIBUTE returned as a PBDOM_OBJECT.
Throws
EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE -- This PBDOM_ATTRIBUTE object's internal implementation is null. The occurrence of this exception is rare but can take place if severe memory corruption occurs.
EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT -- If this PBDOM_ATTRIBUTE does not have or has not been assigned a user-defined name.
Examples
This example creates a PBDOM_DOCUMENT from the string <abc My_Attr="An Attribute"/>, gets the attribute from the root element, and creates a shallow clone and a deep clone from it. For the shallow clone, an empty string is returned in the message box. For the deep clone, the string An Attribute is returned:
PBDOM_BUILDER pbdom_buildr PBDOM_DOCUMENT pbdom_doc PBDOM_ATTRIBUTE pbdom_attr PBDOM_ATTRIBUTE pbdom_attr_clone_deep PBDOM_ATTRIBUTE pbdom_attr_clone_shallow string strXML = "<abc My_Attr=~"An Attribute~"/>" TRY pbdom_buildr = Create PBDOM_BUILDER pbdom_doc = pbdom_buildr.BuildFromString(strXML) pbdom_attr = pbdom_doc.GetRootElement(). & GetAttribute("My_Attr") pbdom_attr_clone_shallow = pbdom_attr.Clone(false) MessageBox ("Shallow Attribute Clone Text", & pbdom_attr_clone_shallow.GetText()) pbdom_attr_clone_deep = pbdom_attr.Clone(true) MessageBox ("Deep Attribute Clone Text", & pbdom_attr_clone_deep.GetText()) CATCH (PBDOM_EXCEPTION pbdom_except) MessageBox ("PBDOM_EXCEPTION", & pbdom_except.GetMessage()) END TRY
Usage
The Clone method creates and returns a duplicate of the current PBDOM_ATTRIBUTE.
If a shallow clone is requested, this method clones the original PBDOM_ATTRIBUTE together with its namespace information values. The subtree of child PBDOM_TEXT and/or PBDOM_ENTITYREFERENCE objects is not cloned.
If a deep clone is requested, this method additionally recursively clones the subtree under the PBDOM_ATTRIBUTE. This subtree consists of a combination of PBDOM_TEXT and PBDOM_ENTITYREFERENCE objects that are the legal children of a PBDOM_ATTRIBUTE.
A PBDOM_ATTRIBUTE clone has no parent. However, the clone resides in the same PBDOM_DOCUMENT as its original, and if the original PBDOM_ATTRIBUTE is standalone, the clone is standalone.