PBDOM_ATTRIBUTE – PB Docs 150

PBDOM_ATTRIBUTE

The PBDOM_ATTRIBUTE class represents an XML attribute
modeled in PowerScript. The PBDOM_ATTRIBUTE methods allow
access to element attributes and namespace information.

Methods

In addition to the methods inherited from PBDOM_OBJECT,
the PBDOM_ATTRIBUTE class has the following methods:

  • GetBooleanValue, SetBooleanValue, GetDateValue, SetDateValue, GetDateTimeValue, SetDateTimeValue, GetDoubleValue, SetDoubleValue, GetIntValue, SetIntValue, GetLongValue, SetLongValue, GetRealValue, SetRealValue, GetTimeValue, SetTimeValue, GetUIntValue, SetUintValue, GetULongValue,and SetULongValue to
    get and set the value of the PBDOM_ATTRIBUTE as the specified
    datatype

  • GetNamespacePrefix and GetNamespaceURI to
    get the prefix and URI of the namespace associated with the PBDOM_ATTRIBUTE

  • GetOwnerElementObject and
    SetOwnerElementObject to get and set the owner PBDOM_ELEMENT
    of the PBDOM_ATTRIBUTE

  • GetQualifiedName to
    get the full name of the PBDOM_ATTRIBUTE including the
    prefix, if any

  • SetNamespace to
    set the namespace of the PBDOM_ATTRIBUTE

  • SetText to
    set the text content of the PBDOM_ATTRIBUTE

Child PBDOM_OBJECTs

A PBDOM_ATTRIBUTE contains a subtree of child PBDOM_OBJECTs.
The child objects can be a combination of PBDOM_TEXT and PBDOM_ENTITYREFERENCE
objects.

The following example produces a PBDOM_ELEMENT named elem that contains
a PBDOM_ATTRIBUTE named attr:

The element tag in the XML looks like this:

In Figure 14-3,
the arrows indicate a parent-child relationship between the PBDOM_ATTRIBUTE
and the other PBDOM_OBJECTs:

Figure 14-3: PBDOM_ATTRIBUTE
subtree example

attrs2.gif

The Default PBDOM_TEXT child

A PBDOM_ATTRIBUTE generally always contains at least
one PBDOM_TEXT child that might contain an empty string.
This is the case unless the RemoveContent method
has been called to remove all contents of the PBDOM_ATTRIBUTE.

The following examples show how a PBDOM_TEXT object
with an empty string can become the child of a PBDOM_ATTRIBUTE.

Example 1

The following example uses the PBDOM_ELEMENT SetAttribute method.
The name of the PBDOM_ATTRIBUTE is set to attr but the
text value is an empty string. The PBDOM_ATTRIBUTE will
have one child PBDOM_TEXT that will contain an empty string:

When you use the SaveDocument method to
render pbdom_doc as XML, it looks
like this:

Example 2

The following example creates a PBDOM_ATTRIBUTE and
sets its name to attr. No text value is set,
but a PBDOM_TEXT object is automatically created and attached
to the PBDOM_ATTRIBUTE. This is the default behavior for
every PBDOM_ATTRIBUTE created in this way:

When you call the SetText method (or any
of the other Set* methods except SetNamespace),
the default PBDOM_TEXT is replaced by a new PBDOM_TEXT.
If you call the SetContent method, you can replace
the default PBDOM_TEXT by a combination of PBDOM_TEXT
and PBDOM_ENTITYREFERENCE objects.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x