str = xmlXPathCastNodeToString(cur);
PG_TRY();
{
- result = (xmltype *) cstring_to_text((char *) str);
+ /* Here we rely on XML having the same representation as TEXT */
+ char *escaped = escape_xml((char *) str);
+
+ result = (xmltype *) cstring_to_text(escaped);
+ pfree(escaped);
}
PG_CATCH();
{
{two,etc}
(1 row)
+SELECT xpath('//text()', '<');
+ xpath
+--------
+ {<}
+(1 row)
+
+SELECT xpath('//@value', '');
+ xpath
+--------
+ {<}
+(1 row)
+
-- Test xmlexists and xpath_exists
SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol');
xmlexists
^
DETAIL: This functionality requires the server to be built with libxml support.
HINT: You need to rebuild PostgreSQL using --with-libxml.
+SELECT xpath('//text()', '<');
+ERROR: unsupported XML feature
+LINE 1: SELECT xpath('//text()', '<');
+ ^
+DETAIL: This functionality requires the server to be built with libxml support.
+HINT: You need to rebuild PostgreSQL using --with-libxml.
+SELECT xpath('//@value', '');
+ERROR: unsupported XML feature
+LINE 1: SELECT xpath('//@value', '');
+ ^
+DETAIL: This functionality requires the server to be built with libxml support.
+HINT: You need to rebuild PostgreSQL using --with-libxml.
-- Test xmlexists and xpath_exists
SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol');
ERROR: unsupported XML feature
SELECT xpath('//text()', 'number one');
SELECT xpath('//loc:piece/@id', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
+SELECT xpath('//text()', '<');
+SELECT xpath('//@value', '');
-- Test xmlexists and xpath_exists
SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol');