PG
PRO
2200TERRORTier 3 — Handle with care✅ HIGH confidence

invalid XML processing instruction

Category: Data ExceptionVersions: All Postgres versions (XML support must be compiled in)

What this means

SQLSTATE 2200T is raised when an XML processing instruction is syntactically invalid or uses the reserved name "xml" (case-insensitive).

Why it happens

  1. 1An XML processing instruction uses the reserved target name xml or XML
  2. 2A processing instruction is syntactically malformed

How to reproduce

XML with an invalid processing instruction.

trigger — this will ERROR
SELECT XMLPARSE(DOCUMENT '<?xml-stylesheet type="text/xsl" href="style.xsl"?><r/>');
ERROR: invalid XML processing instruction

Fix 1: Avoid using xml as the processing instruction target name

When generating XML with processing instructions.

fix

Why this works

The XML specification reserves the name xml (case-insensitive) for the XML declaration. Use a different target name for custom processing instructions.

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class 22 — Data Exception

Confidence assessment

✅ HIGH confidence

Standard SQLSTATE. Stable across versions.

See also

📄 Reference pages

XML FunctionsXMLPARSE
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →