1 /*-------------------------------------------------------------------------
4 * Declarations for XML data type support.
7 * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/utils/xml.h
12 *-------------------------------------------------------------------------
19 #include "nodes/execnodes.h"
20 #include "nodes/primnodes.h"
22 typedef struct varlena xmltype;
28 XML_STANDALONE_NO_VALUE,
29 XML_STANDALONE_OMITTED
40 PG_XML_STRICTNESS_LEGACY, /* ignore errors unless function result
41 * indicates error condition */
42 PG_XML_STRICTNESS_WELLFORMED, /* ignore non-parser messages */
43 PG_XML_STRICTNESS_ALL /* report all notices/warnings/errors */
46 /* struct PgXmlErrorContext is private to xml.c */
47 typedef struct PgXmlErrorContext PgXmlErrorContext;
49 #define DatumGetXmlP(X) ((xmltype *) PG_DETOAST_DATUM(X))
50 #define XmlPGetDatum(X) PointerGetDatum(X)
52 #define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
53 #define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
55 extern Datum xml_in(PG_FUNCTION_ARGS);
56 extern Datum xml_out(PG_FUNCTION_ARGS);
57 extern Datum xml_recv(PG_FUNCTION_ARGS);
58 extern Datum xml_send(PG_FUNCTION_ARGS);
59 extern Datum xmlcomment(PG_FUNCTION_ARGS);
60 extern Datum xmlconcat2(PG_FUNCTION_ARGS);
61 extern Datum texttoxml(PG_FUNCTION_ARGS);
62 extern Datum xmltotext(PG_FUNCTION_ARGS);
63 extern Datum xmlvalidate(PG_FUNCTION_ARGS);
64 extern Datum xpath(PG_FUNCTION_ARGS);
65 extern Datum xpath_exists(PG_FUNCTION_ARGS);
66 extern Datum xmlexists(PG_FUNCTION_ARGS);
67 extern Datum xml_is_well_formed(PG_FUNCTION_ARGS);
68 extern Datum xml_is_well_formed_document(PG_FUNCTION_ARGS);
69 extern Datum xml_is_well_formed_content(PG_FUNCTION_ARGS);
71 extern Datum table_to_xml(PG_FUNCTION_ARGS);
72 extern Datum query_to_xml(PG_FUNCTION_ARGS);
73 extern Datum cursor_to_xml(PG_FUNCTION_ARGS);
74 extern Datum table_to_xmlschema(PG_FUNCTION_ARGS);
75 extern Datum query_to_xmlschema(PG_FUNCTION_ARGS);
76 extern Datum cursor_to_xmlschema(PG_FUNCTION_ARGS);
77 extern Datum table_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
78 extern Datum query_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
80 extern Datum schema_to_xml(PG_FUNCTION_ARGS);
81 extern Datum schema_to_xmlschema(PG_FUNCTION_ARGS);
82 extern Datum schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
84 extern Datum database_to_xml(PG_FUNCTION_ARGS);
85 extern Datum database_to_xmlschema(PG_FUNCTION_ARGS);
86 extern Datum database_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
88 extern void pg_xml_init_library(void);
89 extern PgXmlErrorContext *pg_xml_init(PgXmlStrictness strictness);
90 extern void pg_xml_done(PgXmlErrorContext *errcxt, bool isError);
91 extern bool pg_xml_error_occurred(PgXmlErrorContext *errcxt);
92 extern void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode,
95 extern xmltype *xmlconcat(List *args);
96 extern xmltype *xmlelement(XmlExprState *xmlExpr, ExprContext *econtext);
97 extern xmltype *xmlparse(text *data, XmlOptionType xmloption, bool preserve_whitespace);
98 extern xmltype *xmlpi(char *target, text *arg, bool arg_is_null, bool *result_is_null);
99 extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
100 extern bool xml_is_document(xmltype *arg);
101 extern text *xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg);
102 extern char *escape_xml(const char *str);
104 extern char *map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, bool escape_period);
105 extern char *map_xml_name_to_sql_identifier(char *name);
106 extern char *map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings);
108 extern int xmlbinary; /* XmlBinaryType, but int for guc enum */
110 extern int xmloption; /* XmlOptionType, but int for guc enum */