CreateAttribute Method (XDATA)


9.8A

 

The CreateAttribute method generates an attribute node at a specified position. The method uses the following format:

 

[label]

{object}.CreateAttribute

[GIVING {return}] USING *Position={position}:

 

 

*Label={label},*Text={text][,*JSONType={type}][:

 

 

*Options={mask}]

Where:

label
Optional. A Program Execution Label.
object
Required. An XDATA object.
return
Optional. A Numeric Variable that receives a value to signify a pass or fail condition for the method execution.
position
Required. A Numeric Variable or decimal number that specifies the position in the node tree where the attribute is inserted.
label
Required. A Character String Variable or literal that specifies the label string value of the node.
text
Required. A Character String Variable or literal that specifies the text string value of the node.
type
Optional. A Numeric Variable or decimal number that specifies the a jsontype value used when outputing a document for JSON.
mask
Optional. A Numeric Variable or decimal number thatspecifies a bit mask value to control the operations of this method.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. After the create operation, the node tree position does not move to the newly created node unless the OPTIONS parameter is used.

  2. The {type} parameter is only used for JSON output which causes the {text} data to be enclosed in double quotes when the JSON_TYPE_STRING is used. Otherwise, the JSON {text} is not enclosed by double quotes for any other JSON type value. If this parameter is not used, the JSON output defaults to use JSON_TYPE_STRING.

  3. The ZERO flag is set if the {return} value is zero.

  4. The OVER flag is set TRUE if the {return} variable is too small where the returned value is truncated.

  5. The EOS flag is always cleared.

  6. The {position} values are defined as follows:

  7.  

    Keyword

    Value

    Meaning...

    CREATE_AS_CURRENT_NODE

    0

    Replace the current node.

    CREATE_AS_PARENT_NODE

    1

    Insert node as the parent.

    CREATE_AS_FIRST_CHILD

    2

    Insert node as first child node.

    CREATE_AS_LAST_CHILD

    3

    Insert node as last child node.

    CREATE_AS_PREVIOUS_SIBLING

    4

    Insert node as previous sibling node.

    CREATE_AS_NEXT_SIBLING

    5

    Insert node as next sibling node.

     

  8. The *OPTIONS {mask} values are defined as follows:

  9.  

    Value

    Description

    0x1

    This bit value causes the current node tree position to be changed to the newly created node position of the attribute. See the MOVE_TO_CREATE_NODE value.

     

  10. The {return} value is a zero if the method execution is successful. Otherwise, a non-zero value is returned to indicate an error has occurred. See the XDATA Method Return Values for more details.

  11. This method can return these values:

  12.  

    Value

    Meaning

    0

    XDATA_ERR_NONE (Success)

    1

    XDATA_ERR_NO_MEM

    2

    XDATA_ERR_INVALID_POSITION_TYPE

    11

    XDATA_ERR_INVALID_POSITION

 

 

See Also: XDATA, XDATA Methods, Method Syntax



PL/B Language Reference ChildCount Method (XDATA) CreateComment Method (XDATA)