documents for processing in client applications.
+
+
xmltext
+
+
+
+
+
+xmltext ( text ) xml
+
+
+ The function xmltext returns an XML value with a single
+ text node containing the input argument as its content. Predefined entities
+ like ampersand (), left and right angle brackets
+ (]]>), and quotation marks ()
+ are escaped.
+
+
+ Example:
+
+SELECT xmltext('< foo & bar >');
+ xmltext
+-------------------------
+ < foo & bar >
+]]>
+
+
+
xmlcomment
X035 XMLAgg: ORDER BY option YES
X036 XMLComment YES
X037 XMLPI YES
-X038 XMLText NO
+X038 XMLText YES supported except for RETURNING
X040 Basic table mapping YES
X041 Basic table mapping: null absent YES
X042 Basic table mapping: null as nil YES
#ifdef USE_LIBXML
#include
+#include
#include
#include
#include
}
+Datum
+xmltext(PG_FUNCTION_ARGS)
+{
+#ifdef USE_LIBXML
+ text *arg = PG_GETARG_TEXT_PP(0);
+ text *result;
+ xmlChar *xmlbuf = NULL;
+
+ xmlbuf = xmlEncodeSpecialChars(NULL, xml_text2xmlChar(arg));
+
+ Assert(xmlbuf);
+
+ result = cstring_to_text_with_len((const char *) xmlbuf, xmlStrlen(xmlbuf));
+ xmlFree(xmlbuf);
+ PG_RETURN_XML_P(result);
+#else
+ NO_XML_SUPPORT();
+ return 0;
+#endif /* not USE_LIBXML */
+}
+
/*
* TODO: xmlconcat needs to merge the notations and unparsed entities
{ oid => '2922', descr => 'serialize an XML value to a character string',
proname => 'text', prorettype => 'text', proargtypes => 'xml',
prosrc => 'xmltotext' },
+{ oid => '3813', descr => 'generate XML text node',
+ proname => 'xmltext', proisstrict => 't', prorettype => 'xml',
+ proargtypes => 'text', prosrc => 'xmltext' },
{ oid => '2923', descr => 'map table contents to XML',
proname => 'table_to_xml', procost => '100', provolatile => 's',
| <foo/>
(1 row)
+SELECT xmltext(NULL);
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext('');
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext(' ');
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext('foo `$_-+?=*^%!|/\()[]{}');
+ xmltext
+--------------------------
+ foo `$_-+?=*^%!|/\()[]{}
+(1 row)
+
+SELECT xmltext('foo & <"bar">');
+ xmltext
+-----------------------------------
+ foo & <"bar">
+(1 row)
+
+SELECT xmltext('x'|| '
73
'::xml || .42 || true || 'j'::char);
+ xmltext
+---------------------------------
+ x<P>73</P>0.42truej
+(1 row)
+
SELECT * FROM XMLTABLE('.' PASSING XMLELEMENT(NAME a) columns a varchar(20) PATH '""', b xml PATH '""');
ERROR: unsupported XML feature
DETAIL: This functionality requires the server to be built with libxml support.
+SELECT xmltext(NULL);
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext('');
+ERROR: unsupported XML feature
+DETAIL: This functionality requires the server to be built with libxml support.
+SELECT xmltext(' ');
+ERROR: unsupported XML feature
+DETAIL: This functionality requires the server to be built with libxml support.
+SELECT xmltext('foo `$_-+?=*^%!|/\()[]{}');
+ERROR: unsupported XML feature
+DETAIL: This functionality requires the server to be built with libxml support.
+SELECT xmltext('foo & <"bar">');
+ERROR: unsupported XML feature
+DETAIL: This functionality requires the server to be built with libxml support.
+SELECT xmltext('x'|| '
73
'::xml || .42 || true || 'j'::char);
+ERROR: unsupported XML feature
+LINE 1: SELECT xmltext('x'|| '
73
'::xml || .42 || true || 'j':...
+ ^
+DETAIL: This functionality requires the server to be built with libxml support.
| <foo/>
(1 row)
+SELECT xmltext(NULL);
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext('');
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext(' ');
+ xmltext
+---------
+
+(1 row)
+
+SELECT xmltext('foo `$_-+?=*^%!|/\()[]{}');
+ xmltext
+--------------------------
+ foo `$_-+?=*^%!|/\()[]{}
+(1 row)
+
+SELECT xmltext('foo & <"bar">');
+ xmltext
+-----------------------------------
+ foo & <"bar">
+(1 row)
+
+SELECT xmltext('x'|| '
73
'::xml || .42 || true || 'j'::char);
+ xmltext
+---------------------------------
+ x<P>73</P>0.42truej
+(1 row)
+
\x
SELECT * FROM XMLTABLE('.' PASSING XMLELEMENT(NAME a) columns a varchar(20) PATH '""', b xml PATH '""');
+
+SELECT xmltext(NULL);
+SELECT xmltext('');
+SELECT xmltext(' ');
+SELECT xmltext('foo `$_-+?=*^%!|/\()[]{}');
+SELECT xmltext('foo & <"bar">');
+SELECT xmltext('x'|| '
73
'::xml || .42 || true || 'j'::char);
\ No newline at end of file