summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2007-09-12 15:33:35 +0000
committerFrederic Peters <fpeters@entrouvert.com>2007-09-12 15:33:35 +0000
commita7c3eed730a42ea055b3a05fa94e07ab0c50d9f1 (patch)
treede4498fab5f7304aa78474a104afae77568de1ef
parentd35f0c98674ca1cddb1e9b7231ef4787fe5fd9e4 (diff)
adds support for text as answer to dst queries (instead of forcing answers to
be full nodes)
-rw-r--r--lasso/id-wsf-2.0/data_service.c30
-rw-r--r--lasso/id-wsf/data_service.c19
2 files changed, 34 insertions, 15 deletions
diff --git a/lasso/id-wsf-2.0/data_service.c b/lasso/id-wsf-2.0/data_service.c
index d8a67f86..9e4d8c1f 100644
--- a/lasso/id-wsf-2.0/data_service.c
+++ b/lasso/id-wsf-2.0/data_service.c
@@ -242,17 +242,12 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service)
LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any = g_list_append(
LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any,
xmlCopyNode(node, 1));
- if (item_result_query_base->itemID != NULL) {
- data_item->itemIDRef = g_strdup(item_result_query_base->itemID);
- }
- response->Data = g_list_append(response->Data, data);
- /* Success : change status code to OK */
- if (strcmp(response2->Status->code, LASSO_DST_STATUS_CODE_FAILED) == 0) {
- g_free(response2->Status->code);
- response2->Status->code = g_strdup(LASSO_DST_STATUS_CODE_OK);
- }
- xmlXPathFreeObject(xpathObj);
- xpathObj = NULL;
+ } else if (xpathObj && xpathObj->type == XPATH_STRING) {
+ data = lasso_idwsf2_dstref_data_new();
+ data_item = LASSO_IDWSF2_DSTREF_ITEM_DATA(data);
+ LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any = g_list_append(
+ LASSO_IDWSF2_DSTREF_APP_DATA(data_item)->any,
+ xmlNewText(xpathObj->stringval));
} else {
/* If status was OK, change it to Partial */
if (strcmp(response2->Status->code, LASSO_DST_STATUS_CODE_OK) == 0) {
@@ -268,6 +263,19 @@ lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataService *service)
/* Stop processing at first error */
break;
}
+
+
+ if (item_result_query_base->itemID != NULL) {
+ data_item->itemIDRef = g_strdup(item_result_query_base->itemID);
+ }
+ response->Data = g_list_append(response->Data, data);
+ /* Success : change status code to OK */
+ if (strcmp(response2->Status->code, LASSO_DST_STATUS_CODE_FAILED) == 0) {
+ g_free(response2->Status->code);
+ response2->Status->code = g_strdup(LASSO_DST_STATUS_CODE_OK);
+ }
+ xmlXPathFreeObject(xpathObj);
+ xpathObj = NULL;
}
/* Free XML parsing objects */
diff --git a/lasso/id-wsf/data_service.c b/lasso/id-wsf/data_service.c
index 8cd166a5..cbcad496 100644
--- a/lasso/id-wsf/data_service.c
+++ b/lasso/id-wsf/data_service.c
@@ -459,18 +459,29 @@ lasso_data_service_build_response_msg(LassoDataService *service)
iter = request->QueryItem;
while (iter) {
LassoDstQueryItem *item = iter->data;
+ LassoDstData *data;
+
xpathObj = xmlXPathEvalExpression((xmlChar*)item->Select, xpathCtx);
if (xpathObj && xpathObj->nodesetval && xpathObj->nodesetval->nodeNr) {
- LassoDstData *data;
xmlNode *node = xpathObj->nodesetval->nodeTab[0];
/* XXX: assuming there is only one matching node */
data = lasso_dst_data_new();
data->any = g_list_append(data->any, xmlCopyNode(node, 1));
- if (item->itemID) {
- data->itemIDRef = g_strdup(item->itemID);
+ } else if (xpathObj && xpathObj->type == XPATH_STRING) {
+ data = lasso_dst_data_new();
+ data->any = g_list_append(data->any,
+ xmlNewText(xpathObj->stringval));
+ } else {
+ /* no response was found, break here */
+ if (xpathObj) {
+ xmlXPathFreeObject(xpathObj);
}
- response->Data = g_list_append(response->Data, data);
+ break;
+ }
+ if (item->itemID) {
+ data->itemIDRef = g_strdup(item->itemID);
}
+ response->Data = g_list_append(response->Data, data);
xmlXPathFreeObject(xpathObj);
xpathObj = NULL;
iter = g_list_next(iter);