@@ -232,6 +232,10 @@ const TableFuncRoutine XmlTableRoutine =
232232 .DestroyOpaque = XmlTableDestroyOpaque
233233};
234234
235+ #ifdef USE_LIBXML
236+ openxml_set_namespaces_hook_type openxml_set_namespaces_hook = NULL ;
237+ #endif
238+
235239#define NO_XML_SUPPORT () \
236240 ereport(ERROR, \
237241 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
@@ -4797,6 +4801,10 @@ XmlTableSetNamespace(TableFuncScanState *state, const char *name, const char *ur
47974801 errmsg ("DEFAULT namespace is not supported" )));
47984802 xtCxt = GetXmlTableBuilderPrivateData (state , "XmlTableSetNamespace" );
47994803
4804+ /* For TSQL OPENXML, following hook will fetch and register namespaces in Xpath context. */
4805+ if (openxml_set_namespaces_hook )
4806+ return openxml_set_namespaces_hook (xtCxt -> xpathcxt , xtCxt -> xmlerrcxt , uri );
4807+
48004808 if (xmlXPathRegisterNs (xtCxt -> xpathcxt ,
48014809 pg_xmlCharStrndup (name , strlen (name )),
48024810 pg_xmlCharStrndup (uri , strlen (uri ))))
@@ -5116,3 +5124,28 @@ XmlTableDestroyOpaque(TableFuncScanState *state)
51165124 NO_XML_SUPPORT ();
51175125#endif /* not USE_LIBXML */
51185126}
5127+
5128+ #ifdef USE_LIBXML
5129+ xmlDocPtr
5130+ xml_parse_wrapper (text * data , XmlOptionType xmloption_arg ,
5131+ bool preserve_whitespace , int encoding ,
5132+ XmlOptionType * parsed_xmloptiontype , xmlNodePtr * parsed_nodes ,
5133+ Node * escontext )
5134+ {
5135+ return xml_parse (data , xmloption_arg , preserve_whitespace ,
5136+ encoding , parsed_xmloptiontype , parsed_nodes , escontext );
5137+ }
5138+
5139+ xmlChar *
5140+ pg_xmlCharStrndup_wrapper (const char * str , size_t len )
5141+ {
5142+ return pg_xmlCharStrndup (str , len );
5143+ }
5144+
5145+ int
5146+ parse_xml_decl_wrapper (const xmlChar * str , size_t * lenp ,
5147+ xmlChar * * version , xmlChar * * encoding , int * standalone )
5148+ {
5149+ return parse_xml_decl (str , lenp , version , encoding , standalone );
5150+ }
5151+ #endif /* USE_LIBXML */
0 commit comments