XMLPI builds an XML processing instruction (PI), a special node that begins with ''. In SQL/XML it lets you embed instructions (for example, style-sheet references or application hints) inside an XML document generated by SQL. The keyword accepts a required target identifier (the PI name) and an optional character expression for the body. If the body is omitted the PI is empty except for the target. The result is of the XML data type. New-line, question-mark, or the sequence '?>' inside the content is automatically escaped or raises an error, depending on the database. Because a PI belongs to the XML value space, result aggregation with other XML constructors (XMLELEMENT, XMLFOREST, etc.) is seamless. XMLPI is part of the SQL:2006 SQL/XML standard and is fully supported in PostgreSQL and several other engines that implement SQL/XML.
target_identifier
(identifier) - Required processing-instruction target (cannot contain whitespace, '|||' or 'xml' in any casing)content_expression
(string or character expression) - Optional text that becomes the body of the PI; must not include the sequence '?>'XMLELEMENT, XMLFOREST, XMLCONCAT, XMLPARSE, XMLSERIALIZE, XMLEXISTS
SQL:2006 (SQL/XML) standard; PostgreSQL 8.3
XMLPI stands for XML Processing Instruction, a node type used to carry parser directives within an XML document.
The SQL/XML standard requires the NAME keyword to clearly distinguish the target identifier from the optional content argument.
Escape or remove the sequence '?
>' and ensure the content does not contain illegal control characters. Standard string escaping rules apply.
Yes in the SELECT list to construct XML output. In a WHERE clause it makes little sense because it always returns a new XML value rather than filtering rows.