2200N — invalid_xml_content
This member covers invalid XML content. PostgreSQL 18.6’s core XML parser has a content-mode declaration guard and content-parse guards that report 2200N; the original XML option determines whether a document parse failure is instead reported as 2200M.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Data Exception
- condition name
- invalid_xml_content
- lang
- en
- sqlstate
- 2200N
Definition PG 18
2200N
At a glance {#at-a-glance}
This member covers invalid XML content. PostgreSQL 18.6’s core XML parser has a content-mode declaration guard and content-parse guards that report 2200N; the original XML option determines whether a document parse failure is instead reported as 2200M.
Meaning {#meaning}
This member names invalid XML content at the parser’s CONTENT boundary. In content mode, an invalid XML declaration raises invalid XML content: invalid XML declaration with a detail produced by errdetail_for_xml_code(res_code). A failed balanced-content parse raises invalid XML content; if CONTENT input contains a DOCTYPE and is parsed as a document, the failed document parse still uses the original option to select 2200N. The same failed parser call uses 2200M when the original option was DOCUMENT. The declaration branch calls errsave and the content branches call xml_errsave: with an ErrorSaveContext these errors are saved and returned to the caller, while an ordinary context throws ERROR; that distinction is separate from the dynamic DETAIL text.
Messages {#messages}
The cited branches raise ERROR with primary invalid XML content: invalid XML declaration for the declaration guard, with dynamic DETAIL from errdetail_for_xml_code(res_code), or primary invalid XML content for the later content/document parse failures. The declaration variant’s evidence template is dynamic errdetail_for_xml_code(res_code), not a fixed DETAIL string. No fixed universal DETAIL or HINT should be invented for those parser failures. 2200L is the outer document-option wrapper, while 2200S and 2200T identify comment and processing-instruction syntax.
Diagnosis {#diagnosis}
Read the complete parser message and the XML fragment or value it identifies. Check element names, character data, encoding, and the operation’s expected XML level. Follow a reported 2200L, 2200M, 2200S, or 2200T directly when the server emits one of those codes; do not choose 2200N from the word “invalid” alone.
Response {#response}
Correct the XML content at the element, character, or encoding boundary named by the diagnostic, and retain the actual code when validating the fix.
When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.
Versions {#versions}
The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.
Related {#related}
Sources {#sources}
Fixed core source: src/backend/utils/adt/xml.c#L1780-1894. The shared xml_errsave/errsave helper defines the soft-error versus ordinary-throw behavior. The structured evidence record retains the declaration and content-parse guards, dynamic-detail boundary, and scope limits. Core availability depends on USE_LIBXML; no natural XML case was run for this page.
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read fixed definition.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2200N is invalid_xml_content in SQLSTATE Class 22."
}claims · mechanism.content-parse
{
"claim_id": "mechanism.content-parse",
"limits": "The XML declaration path adds a dynamic errdetail_for_xml_code result; do not publish a fabricated fixed DETAIL.",
"method": "Read both content-mode branches.",
"position": 1,
"runtime": [],
"sources": [
"src.path.xml-invalid-content",
"src.path.xml-content-parse"
],
"statement": "The core XML parser uses 2200N for failed content parsing and for an invalid XML declaration in content mode."
}claims · mechanism.error-save
{
"claim_id": "mechanism.error-save",
"limits": "The soft-error propagation distinction is separate from the dynamic DETAIL produced for XML declaration failures.",
"method": "Read the declaration/content calls and the xml_errsave helper.",
"position": 2,
"runtime": [],
"sources": [],
"statement": "The XML declaration branch calls errsave and the content branches call xml_errsave; with an ErrorSaveContext these errors are saved and returned to the caller, while an ordinary context throws ERROR."
}claims · build-boundary
{
"claim_id": "build-boundary",
"limits": "Source confirmation is not a natural runtime observation.",
"method": "Read surrounding fixed source guards.",
"position": 3,
"runtime": [],
"sources": [
"src.path.xml-content-parse"
],
"statement": "Core XML content parsing is compiled under the USE_LIBXML feature guard; build support and parser version affect availability and detail text."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue boundary.",
"position": 4,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 2200N from 8.3.0 without proving an exact implementation introduction date."
}messages · message.invalid-content
{
"limits": "",
"message_id": "message.invalid-content",
"path": "",
"position": 0,
"raw": {
"id": "message.invalid-content",
"primary_template": "invalid XML content",
"severity_source": "ERROR",
"sources": [
"src.path.xml-content-parse"
],
"sqlstate": "2200N"
},
"severity": "ERROR",
"sources": [
"src.path.xml-content-parse"
],
"templates": [
{
"kind": "primary",
"literal": "invalid XML content",
"position": 0,
"role": "",
"template": "invalid XML content"
}
]
}messages · message.invalid-declaration
{
"limits": "",
"message_id": "message.invalid-declaration",
"path": "",
"position": 1,
"raw": {
"detail_template": "dynamic errdetail_for_xml_code(res_code)",
"id": "message.invalid-declaration",
"primary_template": "invalid XML content: invalid XML declaration",
"severity_source": "ERROR",
"sources": [
"src.path.xml-invalid-content"
],
"sqlstate": "2200N"
},
"severity": "ERROR",
"sources": [
"src.path.xml-invalid-content"
],
"templates": [
{
"kind": "primary",
"literal": "invalid XML content: invalid XML declaration",
"position": 0,
"role": "",
"template": "invalid XML content: invalid XML declaration"
},
{
"kind": "detail",
"literal": "dynamic errdetail_for_xml_code(res_code)",
"position": 1,
"role": "",
"template": "dynamic errdetail_for_xml_code(res_code)"
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L212"
}sources · src.calls.REL_18_6
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 1,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6",
"tag": "",
"url": ""
}sources · src.path.xml-invalid-content
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 2,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-invalid-content",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1801-L1810"
}sources · src.path.xml-content-parse
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 3,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-content-parse",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1851-L1894"
}sources · src.path.xml-error-save
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 4,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-error-save",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L2047-L2082"
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:b7dd82b3579b0f5634b813729ad1b80fa1eda6c19f8690386ff7e5247e7b06a9
Text language: en · english-manuals:b7dd82b3579b0f5634b813729ad1b80fa1eda6c19f8690386ff7e5247e7b06a9