GetOwnerDocumentObject
Description
The GetOwnerDocumentObject method returns the owning
PBDOM_DOCUMENT of the current PBDOM_CHARACTERDATA.
Syntax
|
1 |
pbdom_chardata_name.GetOwnerDocumentObject() |
|
Argument |
Description |
|---|---|
|
pbdom_chardata_name |
The name of a PBDOM_CHARACTERDATA |
Return value
PBDOM_OBJECT.
Throws
EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE — If this
PBDOM_CHARACTERDATA is not associated with a derived PBDOM_CHARACTERDATA
class.
Examples
-
This example creates a PBDOM_DOCUMENT based on the following
DOM tree:123<abc><data>Data</data></abc>The PowerScript code obtains the root element, uses it to
obtain the child element, and then obtains an array of the child
element’s own children. This array has a single item, the PBDOM_TEXT
object with the text Data. The array can be cast to a
PBDOM_CHARACTERDATA object because it does not contain any objects
that are not derived from PBDOM_CHARACTERDATA,The call to GetOwnerDocumentObject returns a PBDOM_OBJECT,
which is stored in a PBDOM_DOCUMENT called pbdom_owner_doc. The call
to Equals tests whether the owner document of the “Data” PBDOM_TEXT
and the main document, referenced using pbdom_doc, refer to the same
document.12345678910111213141516171819202122232425262728293031323334PBDOM_Builder pbdombuilder_newpbdom_document pbdom_docpbdom_document pbdom_owner_docpbdom_element pbdom_elemPBDOM_CHARACTERDATA pbdom_chardataPBDOM_OBJECT pbdom_obj_array[]string strXML = "<abc><data>Data</data></abc>"TRYpbdombuilder_new = Create PBDOM_Builderpbdom_doc = pbdombuilder_new.BuildFromString (strXML)pbdom_elem = pbdom_doc.GetRootElement(). &GetChildElement("data")pbdom_elem.GetContent(pbdom_obj_array)pbdom_chardata = pbdom_obj_array[1]pbdom_owner_doc = &pbdom_chardata.GetOwnerDocumentObject()if (pbdom_doc.Equals(pbdom_owner_doc)) thenMessageBox ("Equals", &"pbdom_doc Equals pbdom_owner_doc")elseMessageBox ("Equals", &"pbdom_doc Not Equals pbdom_owner_doc")end ifDestroy pbdombuilder_newCATCH (PBDOM_Exception except)MessageBox ("Exception Occurred", except.Text)END TRY -
This example creates a PBDOM_DOCUMENT based on the same DOM
tree as example 1. It creates a PBDOM_TEXT, stores it in the
PBDOM_CHARACTERDATA variable pbdom_chardata, and assigns it some
text. Objects created in this way are standalone objects — they
have no owner document or parent. Calling GetOwnerDocumentObject on
pbdom_chardata returns null.The code then adds pbdom_chardata as a child to the data
element. This implicitly imports pbdom_chardata into the original
document. pbdom_chardata now has an owner document and a parent (the
data element). Calling GetOwnerDocumentObject on
pbdom_chardata returns the original document. When the returned
PBDOM_DOCUMENT has been assigned into pbdom_owner_doc, a call to
Equals to compare pbdom_doc with pbdom_owner_doc returns
true:1234567891011121314151617181920212223242526272829303132333435363738PBDOM_Builder pbdombuilder_newpbdom_document pbdom_docpbdom_document pbdom_owner_docPBDOM_CHARACTERDATA pbdom_chardatastring strXML = "<abc><data>Data</data></abc>"TRYpbdombuilder_new = Create PBDOM_Builderpbdom_doc = pbdombuilder_new.BuildFromString (strXML)pbdom_chardata = Create PBDOM_TEXTpbdom_chardata.SetText(" Some Text")if (IsValid (pbdom_chardata.GetOwnerDocumentObject())) thenMessageBox ("Owner Document", &"PBDOM_TEXT (~'Some Text~') has an owner document.")elseMessageBox ("Owner Document", &"PBDOM_TEXT (~'Some Text~') has NO owner document.")end ifpbdom_doc.GetRootElement().GetChildElement("data"). &AddContent(pbdom_chardata)pbdom_owner_doc = pbdom_chardata.GetOwnerDocumentObject()if (pbdom_doc.Equals(pbdom_owner_doc)) thenMessageBox ("Equals", "pbdom_doc Equals pbdom_owner_doc")elseMessageBox ("Equals", "pbdom_doc Not Equals pbdom_owner_doc")end ifDestroy pbdombuilder_newDestroy pbdom_chardataCATCH (PBDOM_Exception except)MessageBox ("Exception Occurred", except.Text)END TRY
Usage
If there is no owning PBDOM_DOCUMENT, null is returned.
See also