CreatePI Method (XDATA)


9.8A

 

The CreatePI method generates a DOM_PROCESSING_INSTRUCTION node at a specified position. The method uses the following format:

 

[label]

{object}.CreatePI

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

 

 

*Target={target},*Data={data}[:

 

 

*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 where the processing instruction node is inserted.
target
Required. A Character String Variable or literal that specifies the target string value of the node.
data
Optional. A Character String Variable or literal that specifies the data value of the node.
mask
Optional. A Numeric Variable or decimal number that specifies a bit mask value to control the operations of this method.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. The {target} string value replaces the %target% field in the PI.

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

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

  4. The EOS flag is always cleared.

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

  6.  

    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.

     

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

  8.  

    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.

     

  9. 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.

  10. This method can return these values:

  11.  

    Value

    Meaning

    0

    XDATA_ERR_NONE (Success)

    1

    XDATA_ERR_NO_MEM

    2

    XDATA_ERR_INVALID_POSITION_TYPE

    11

    XDATA_ERR_INVALID_POSITION

     

  12. The DOM_PROCESSING_INSTRUCTION node is only used to generate XML with the following format:

  13.  

    <?%target% %data%?>

    Where:

     

    %target%
    The name that immediately follows the leading '?' is the name of the Processing Instruction (PI). The target string must be followed by a space.
    %data%
    Any %data% following the %target% is the content of the PI up to the trailing '?' character.

Example:

 

<?xml-stylesheet href="mystyle.css" type="text/css"?>

 

%Target% --> xml-stylesheet

  

%Data% --> href="mystyle.css" type="text/css"

 

 

 

xData

XDATA

 

xTarget

INIT

"xml-stylesheet"

xData

INIT

"href=#"mystyle.css#" type=#"text/css#""

.

 

 

 

xData.CreatePI GIVING result:

 

 

USING *POSITION=CREATE_AS_PARENT_NODE:

 

 

*TARGET=xTarget:

 

 

*DATA=xData:

 

 

*OPTIONS=MOVE_TO_CREATED_NODE

 

In this example code, the following simple XML string is created by the previous XDATA CreatePI method:

 

<?xml-stylesheet href="mystyle.css" type="text/css"?>

 

 

See Also: XDATA, XDATA Methods, Method Syntax



PL/B Language Reference CreateElement Method (XDATA) CreateText Method (XDATA)