<result><item><author>test</author></item><item><pages>37</pages></item></result>
(1 row)
+-- namespace node
+SELECT xpath_nodeset('<root xmlns:foo="http://icl.com/saxon"/>',
+ '//namespace::foo');
+ xpath_nodeset
+----------------------
+ http://icl.com/saxon
+(1 row)
+
-- xpath_list()
SELECT xpath_list(article_xml::text, '/article/author|/article/pages')
FROM articles;
<result><item><author>test</author></item><item><pages>37</pages></item></result>
(1 row)
+-- namespace node
+SELECT xpath_nodeset('<root xmlns:foo="http://icl.com/saxon"/>',
+ '//namespace::foo');
+ xpath_nodeset
+----------------------
+ http://icl.com/saxon
+(1 row)
+
-- xpath_list()
SELECT xpath_list(article_xml::text, '/article/author|/article/pages')
FROM articles;
SELECT xpath_nodeset(article_xml::text, '/article/author|/article/pages',
'result', 'item')
FROM articles;
+-- namespace node
+SELECT xpath_nodeset('<root xmlns:foo="http://icl.com/saxon"/>',
+ '//namespace::foo');
-- xpath_list()
SELECT xpath_list(article_xml::text, '/article/author|/article/pages')
}
else
{
+ xmlNodePtr node = nodeset->nodeTab[i];
+
if ((septagname != NULL) && (xmlStrlen(septagname) > 0))
{
xmlBufferWriteChar(buf, "<");
xmlBufferWriteCHAR(buf, septagname);
xmlBufferWriteChar(buf, ">");
}
- xmlNodeDump(buf,
- nodeset->nodeTab[i]->doc,
- nodeset->nodeTab[i],
- 1, 0);
+
+ /*
+ * XML_NAMESPACE_DECL nodes are xmlNs structs, that cannot
+ * be processed by xmlNodeDump().
+ */
+ if (node->type == XML_NAMESPACE_DECL)
+ {
+ str = xmlXPathCastNodeToString(node);
+ if (str == NULL || pg_xml_error_occurred(xmlerrcxt))
+ xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY,
+ "could not allocate node text");
+ xmlBufferWriteCHAR(buf, str);
+ xmlFree(str);
+ str = NULL;
+ }
+ else
+ xmlNodeDump(buf, node->doc, node, 1, 0);
if ((septagname != NULL) && (xmlStrlen(septagname) > 0))
{