Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Setting the name and namespace of a PBDOM_ATTRIBUTE – PB Docs 2022 – PowerBuilder Library

Setting the name and namespace of a PBDOM_ATTRIBUTE – PB Docs 2022

Setting the name and namespace of a PBDOM_ATTRIBUTE

The W3C “Namespaces in XML” specification (in section 5.3) places
restrictions on setting the name and namespace of a PBDOM_ATTRIBUTE. No
tag can contain two attributes with identical names, or with qualified
names that have the same local name and have prefixes that are bound to
identical namespace names.

The specification provides the following examples of illegal and
legal attributes:

In the first example, <bad a=”1″ a=”2″ /> violates the rule
that no tag can contain two attributes with identical names. In the
second tag, the attributes have the same local name but different
prefixes, so that their names are different. However, their prefixes
point to the same namespace URI, http://www.w3.org, so it is illegal to
place them inside the same owner element.

PBDOM scenarios

The following scenarios illustrate how PBDOM conforms to these
requirements.

  • When the PBDOM_ATTRIBUTE SetName method is invoked:

    If the PBDOM_ATTRIBUTE pbdom_attr1 has an owner PBDOM_ELEMENT
    that contains an existing PBDOM_ATTRIBUTE with the same name that is
    to be set for pbdom_attr1 and has the same namespace URI as
    pbdom_attr1, the EXCEPTION_INVALID_NAME exception is thrown.

  • When the PBDOM_ATTRIBUTE SetNamespace method is
    invoked:

    If the PBDOM_ATTRIBUTE pbdom_attr1 has an owner PBDOM_ELEMENT
    that contains an existing PBDOM_ATTRIBUTE with the same name as
    pbdom_attr1 and the same namespace URI that is to be set for
    pbdom_attr1, the EXCEPTION_INVALID_NAME exception is thrown.

  • When the PBDOM_ELEMENT
    SetAttribute(pbdom_attribute pbdom_attribute_ref) method is
    invoked:

    If the PBDOM_ELEMENT already contains an attribute that has
    the same name and namespace URI as the input PBDOM_ATTRIBUTE, the
    existing attribute is replaced by the input PBDOM_ATTRIBUTE. The
    existing attribute is thus removed (detached) from the owner
    element.

  • When the PBDOM_ELEMENT
    SetAttributes(pbdom_attribute pbdom_attribute_array[]) method is
    invoked:

    If any two PBDOM_ATTRIBUTE objects in the array have the same
    name and namespace URI, the EXCEPTION_INVALID_NAME exception is
    thrown. If there is no name or namespace conflict within the array,
    all the existing attributes of the PBDOM_ELEMENT are replaced by the
    PBDOM_ATTRIBUTE objects in the array.

    Note

    All the above scenarios apply to PBDOM_ATTRIBUTE objects
    that are contained in the NONAMESPACE namespace.

  • When the PBDOM_ELEMENT SetAttribute(string strName,
    string strValue) method is invoked:

    A new PBDOM_ATTRIBUTE with the specified name and value is
    created and set into the PBDOM_ELEMENT. If the PBDOM_ELEMENT already
    contains an attribute that has the same name and that is contained
    within the NONAMESPACE namespace, it is removed (detached) from the
    PBDOM_ELEMENT.

  • When the PBDOM_ELEMENT SetAttribute(string strName,
    string strValue, string strNamespacePrefix, string strNamespaceUri,
    boolean bVerifyNamespace) method is invoked:

    A new PBDOM_ATTRIBUTE with the specified name, value, and
    namespace information is created and set into the PBDOM_ELEMENT. If
    the PBDOM_ELEMENT already contains a PBDOM_ATTRIBUTE that has the
    same name and namespace URI as the input namespace URI, it is
    removed (detached) from the PBDOM_ELEMENT.

Example

The following example demonstrates the impact of setting a
PBDOM_ATTRIBUTE for a PBDOM_ELEMENT where the PBDOM_ELEMENT already
contains an attribute of the same name and namespace URI as the input
PBDOM_ATTRIBUTE.

The example creates a PBDOM_DOCUMENT based on the following
document:

Then it creates a PBDOM_ATTRIBUTE object and set its name to a and
its prefix and URI to pre2 and http://www.pre.com. The
bVerifyNamespace argument is set to FALSE because this PBDOM_ATTRIBUTE
has not been assigned an owner PBDOM_ELEMENT yet, so that the
verification for a predeclared namespace would fail. The text value is
set to 456.

The child1 element already contains an attribute named a that
belongs to the namespace http://www.pre.com, as indicated by the prefix
pre1. The new PBDOM_ATTRIBUTE uses the prefix pre2, but it represents
the same namespace URI, so setting the new PBDOM_ATTRIBUTE to
child1 successfully replaces the existing pre1:a with the new
PBDOM_ATTRIBUTE pre2:a.

The XML output from SaveDocument looks like the following:


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