1 /*------------------------------------------------------------------------- 2 * 3 * xml.h 4 * Declarations for XML data type support. 5 * 6 * 7 * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group 8 * Portions Copyright (c) 1994, Regents of the University of California 9 * 10 * src/include/utils/xml.h 11 * 12 *------------------------------------------------------------------------- 13 */ 14 15 #ifndef XML_H 16 #define XML_H 17 18 #include "fmgr.h" 19 #include "nodes/execnodes.h" 20 #include "nodes/primnodes.h" 21 22 typedef struct varlena xmltype; 23 24 typedef enum 25 { 26 XML_STANDALONE_YES, 27 XML_STANDALONE_NO, 28 XML_STANDALONE_NO_VALUE, 29 XML_STANDALONE_OMITTED 30 } XmlStandaloneType; 31 32 typedef enum 33 { 34 XMLBINARY_BASE64, 35 XMLBINARY_HEX 36 } XmlBinaryType; 37 38 typedef enum 39 { 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 */ 44 } PgXmlStrictness; 45 46 /* struct PgXmlErrorContext is private to xml.c */ 47 typedef struct PgXmlErrorContext PgXmlErrorContext; 48 49 #define DatumGetXmlP(X) ((xmltype *) PG_DETOAST_DATUM(X)) 50 #define XmlPGetDatum(X) PointerGetDatum(X) 51 52 #define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n)) 53 #define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x) 54 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); 70 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); 79 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); 83 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); 87 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, 93 const char *msg); 94 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); 103 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); 107 108 extern int xmlbinary; /* XmlBinaryType, but int for guc enum */ 109 110 extern int xmloption; /* XmlOptionType, but int for guc enum */ 111 112 #endif /* XML_H */ 113