XMLPI scalar function

The XMLPI function returns an XML value with a single XQuery processing instruction node.

Read syntax diagramSkip visual syntax diagramXMLPI( NAMEpi-name ,string-expression )

The schema is SYSIBM. The function name cannot be specified as a qualified name.

NAME pi-name
Specifies the name of a processing instruction. The name is an SQL identifier that must be in the form of an XML NCName (SQLSTATE 42634). See the W3C XML namespace specifications for more details on valid names. The name cannot be the word 'xml' in any case combination (SQLSTATE 42634).
string-expression
An expression that returns a value that is a character string. The resulting string is converted to UTF-8 and must conform to the content of an XML processing instruction as specified in XML 1.0 rules (SQLSTATE 2200T):
  • The string must not contain the substring '?>' since this substring terminates a processing instruction
  • Each character of the string can be any Unicode character excluding the surrogate blocks, X'FFFE' and X'FFFF'.

The resulting string becomes the content of the constructed processing instruction node.

The data type of the result is XML. If the result of string-expression can be null, the result can be null; if the result of string-expression is null, the result is the null value. If string-expression is an empty string or is not specified, an empty processing instruction node is returned.

Examples

  • Example 1: Generate an XML processing instruction node.
       SELECT XMLPI(
         NAME "Instruction", 'Push the red button'
       )
       FROM SYSIBM.SYSDUMMY1
    This query produces the following result:
    <?Instruction Push the red button?>
  • Example 2: Generate an empty XML processing instruction node.
       SELECT XMLPI(
         NAME "Warning"
       )
       FROM SYSIBM.SYSDUMMY1
    This query produces the following result:
    <?Warning ?>