XML Value Encoding and the Encoding Declaration - Analytics Database - Teradata Vantage

XML Data Type

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
tkc1628112506748.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
dgs1472251600184
lifecycle
latest
Product Category
Teradata Vantage™

This table shows what the encoding and encoding declaration will be based on the return data type of the XML value.

Return Type of XML Value Encoding Encoding Declaration
XML type 
(in record/indicator mode) UTF-8
  • If a document is retrieved in its entirety, and if it originally had an encoding declaration, the encoding declaration is preserved.
  • If there was no original encoding declaration, none is added (no encoding declaration is interpreted as UTF-8 by the parser according to the standard).
CLOB or VARCHAR
(in field mode, or when XMLSERIALIZE is called with CLOB or VARCHAR target type) The encoding of the document received will match the session character set in use.
  • If a document is retrieved in its entirety, and if it originally had an encoding declaration, the encoding declaration is preserved.
  • If there was no original encoding declaration, none is added.
BLOB or VARBYTE 
(when XMLSERIALIZE is called with BLOB or VARBYTE target type) The encoding of the XML value will be as specified by the user via the ENCODING clause in the XMLSERIALIZE function call. It is UTF-8 if an encoding is not specified. The encoding declaration is as specified by user via the ENCODING clause or none.

If the XML values are returned as XML, CLOB, or VARCHAR values, there is potential for mismatch between the actual encoding of the XML value and its encoding declaration. You can instruct the parser via parser-provided APIs to override the encoding declaration in the XML document based on external knowledge, such as knowing the session character set in use.