Re: xmlconcat (was 9.0 release notes done)
От | Andrew Dunstan |
---|---|
Тема | Re: xmlconcat (was 9.0 release notes done) |
Дата | |
Msg-id | 4BAA8D54.7080507@dunslane.net обсуждение исходный текст |
Ответ на | Re: xmlconcat (was 9.0 release notes done) (Peter Eisentraut <peter_e@gmx.net>) |
Ответы |
Re: xmlconcat (was 9.0 release notes done)
(Tom Lane <tgl@sss.pgh.pa.us>)
Re: xmlconcat (was 9.0 release notes done) (Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>) |
Список | pgsql-hackers |
Peter Eisentraut wrote: > Our version of SQL/XML support references SQL:2003 which references XML > 1.0, where omitting the XMLDecl is legal. You can't omit the XMLDecl in > XML 1.1, because you need it to communicate the fact that it's version > 1.1. > > > Hmm. OK. Well here is a patch that tries to fix the xmlconcat error, anyway. It seems to work, but maybe could stand a little tightening. cheers andrew Index: src/backend/utils/adt/xml.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/xml.c,v retrieving revision 1.97 diff -c -r1.97 xml.c *** src/backend/utils/adt/xml.c 3 Mar 2010 17:29:45 -0000 1.97 --- src/backend/utils/adt/xml.c 24 Mar 2010 22:05:19 -0000 *************** *** 418,424 **** --- 418,466 ---- #endif } + #ifdef USE_LIBXML + static inline void + strip_dtd(char ** xmlstr) + { + + xmlDocPtr doc; + xmlChar *xmlbuff; + int buffersize; + bool dtd_found = false; + xmlNodePtr child; + char * skip_xmldecl; + + if (strstr(*xmlstr,"<!DOCTYPE") == NULL) + return ; + + doc = xml_parse(cstring_to_text(*xmlstr), XMLOPTION_DOCUMENT, true, GetDatabaseEncoding()); + + for (child = doc->children; child != NULL; child = child->next) + { + if (child->type == XML_DOCUMENT_TYPE_NODE || + child->type == XML_DTD_NODE) + { + xmlUnlinkNode(child); + xmlFreeNode(child); + dtd_found = true; + } + } + if (dtd_found) + { + pfree(*xmlstr); + xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 0); + if (strncmp((char *)xmlbuff,"<?xml",5) == 0) + skip_xmldecl = strstr((char *)xmlbuff,"?>\n") + 3; + else + skip_xmldecl = (char *) xmlbuff; + *xmlstr = pstrdup(skip_xmldecl); + xmlFree(xmlbuff); + + } + xmlFreeDoc(doc); + } + #endif /* * TODO: xmlconcat needs to merge the notations and unparsed entities *************** *** 460,465 **** --- 502,509 ---- else if (xmlStrcmp(version, global_version) != 0) global_version_no_value = true; + strip_dtd(&str); + appendStringInfoString(&buf, str + len); pfree(str); }
В списке pgsql-hackers по дате отправления: