summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2008-02-01 11:20:37 +0000
committerFrederic Peters <fpeters@entrouvert.com>2008-02-01 11:20:37 +0000
commit9755fdd10810c6c8df1383bb4dc6ed1522a279d6 (patch)
tree54422495212a4d8c5221ee71651389251256a436
parent6d2d5b504882761b8b07e33df77a2930644fb3ff (diff)
downloadlasso-9755fdd10810c6c8df1383bb4dc6ed1522a279d6.tar.gz
lasso-9755fdd10810c6c8df1383bb4dc6ed1522a279d6.tar.xz
lasso-9755fdd10810c6c8df1383bb4dc6ed1522a279d6.zip
register all known prefixes to xpath context
-rw-r--r--lasso/id-wsf-2.0/data_service.c27
-rw-r--r--lasso/id-wsf/data_service.c31
2 files changed, 50 insertions, 8 deletions
diff --git a/lasso/id-wsf-2.0/data_service.c b/lasso/id-wsf-2.0/data_service.c
index 6fb8852e..dfab152f 100644
--- a/lasso/id-wsf-2.0/data_service.c
+++ b/lasso/id-wsf-2.0/data_service.c
@@ -47,6 +47,10 @@ struct _LassoIdWsf2DataServicePrivate
GList *credentials;
};
+extern GHashTable *idwsf2_dst_services_by_prefix; /* cf xml/xml.c */
+
+static void lasso_register_idwsf2_xpath_namespaces(xmlXPathContext *xpathCtx);
+
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
@@ -220,8 +224,7 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service)
doc = xmlNewDoc((xmlChar*)"1.0");
xmlDocSetRootElement(doc, service->data);
xpathCtx = xmlXPathNewContext(doc);
- xmlXPathRegisterNs(xpathCtx, (xmlChar*)response->prefixServiceType,
- (xmlChar*)response->hrefServiceType);
+ lasso_register_idwsf2_xpath_namespaces(xpathCtx);
/* Parse request QueryItems and fill response Data accordingly */
/* XXX: needs another level, since there may be more than one <dst:Query> */
@@ -696,8 +699,7 @@ lasso_idwsf2_data_service_parse_modify_items(LassoIdWsf2DataService *service)
cur_doc = xmlNewDoc((xmlChar*)"1.0");
xmlDocSetRootElement(cur_doc, cur_data);
cur_xpathCtx = xmlXPathNewContext(cur_doc);
- xmlXPathRegisterNs(cur_xpathCtx, (xmlChar*)response->prefixServiceType,
- (xmlChar*)response->hrefServiceType);
+ lasso_register_idwsf2_xpath_namespaces(cur_xpathCtx);
/* Parse request ModifyItems and modify user current data accordingly */
/* XXX: needs another level, since there may be more than one <dst:Modify> */
@@ -775,6 +777,23 @@ lasso_idwsf2_data_service_process_modify_response_msg(LassoIdWsf2DataService *se
static LassoNodeClass *parent_class = NULL;
+static void
+register_xpath_namespace(gchar *prefix, gchar *href, xmlXPathContext *xpathCtx)
+{
+ xmlXPathRegisterNs(xpathCtx, (xmlChar*)prefix, (xmlChar*)href);
+}
+
+static void
+lasso_register_idwsf2_xpath_namespaces(xmlXPathContext *xpathCtx)
+{
+ if (idwsf2_dst_services_by_prefix == NULL)
+ return;
+ g_hash_table_foreach(idwsf2_dst_services_by_prefix,
+ (GHFunc)register_xpath_namespace, xpathCtx);
+}
+
+
+
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
diff --git a/lasso/id-wsf/data_service.c b/lasso/id-wsf/data_service.c
index 1bcbc401..3dca35d3 100644
--- a/lasso/id-wsf/data_service.c
+++ b/lasso/id-wsf/data_service.c
@@ -41,6 +41,7 @@
#include <xmlsec/templates.h>
#include <xmlsec/crypto.h>
+extern GHashTable *dst_services_by_prefix; /* cf xml/xml.c */
struct _LassoDataServicePrivate
{
@@ -50,6 +51,8 @@ struct _LassoDataServicePrivate
LassoSoapFault *fault;
};
+static void lasso_register_idwsf_xpath_namespaces(xmlXPathContext *xpathCtx);
+
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
@@ -323,8 +326,7 @@ lasso_data_service_build_response_msg(LassoDataService *service)
doc = xmlNewDoc((xmlChar*)"1.0");
xmlDocSetRootElement(doc, service->resource_data);
xpathCtx = xmlXPathNewContext(doc);
- xmlXPathRegisterNs(xpathCtx, (xmlChar*)response->prefixServiceType,
- (xmlChar*)response->hrefServiceType);
+ lasso_register_idwsf_xpath_namespaces(xpathCtx);
/* XXX: needs another level, since there may be more than one <dst:Query> */
iter = request->QueryItem;
@@ -715,8 +717,7 @@ lasso_data_service_build_modify_response_msg(LassoDataService *service)
doc = xmlNewDoc((xmlChar*)"1.0");
xmlDocSetRootElement(doc, cur_data);
xpathCtx = xmlXPathNewContext(doc);
- xmlXPathRegisterNs(xpathCtx, (xmlChar*)response->prefixServiceType,
- (xmlChar*)response->hrefServiceType);
+ lasso_register_idwsf_xpath_namespaces(xpathCtx);
for (iter = request->Modification; iter != NULL; iter = g_list_next(iter)) {
LassoDstModification *modification = iter->data;
@@ -853,6 +854,28 @@ lasso_data_service_set_offering(LassoDataService *service, LassoDiscoResourceOff
service->abstract_description = g_strdup(offering->Abstract);
}
+static void
+register_xpath_namespace(gchar *prefix, gchar *href, xmlXPathContext *xpathCtx)
+{
+ xmlXPathRegisterNs(xpathCtx, (xmlChar*)prefix, (xmlChar*)href);
+}
+
+static void
+lasso_register_idwsf_xpath_namespaces(xmlXPathContext *xpathCtx)
+{
+ xmlXPathRegisterNs(xpathCtx, (xmlChar*)LASSO_PP_PREFIX,
+ (xmlChar*)LASSO_PP_HREF);
+ xmlXPathRegisterNs(xpathCtx, (xmlChar*)LASSO_EP_PREFIX,
+ (xmlChar*)LASSO_EP_HREF);
+ if (dst_services_by_prefix == NULL)
+ return;
+ g_hash_table_foreach(dst_services_by_prefix,
+ (GHFunc)register_xpath_namespace, xpathCtx);
+}
+
+
+
+
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/