From de149fd796ade794bd74a52c1a2d79d3e472207f Mon Sep 17 00:00:00 2001 From: Nicolas Clapies Date: Tue, 7 Dec 2004 11:12:24 +0000 Subject: Added support of specific service : now Query element can be used by services and inherits their name space. --- lasso/xml/dst_query.c | 36 ++++++++++++++++++++++++++++++++++++ lasso/xml/dst_query.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/lasso/xml/dst_query.c b/lasso/xml/dst_query.c index 0641a9b9..b89de12f 100644 --- a/lasso/xml/dst_query.c +++ b/lasso/xml/dst_query.c @@ -55,6 +55,39 @@ static struct XmlSnippet schema_snippets[] = { static LassoNodeClass *parent_class = NULL; +static void +insure_namespace(xmlNode *xmlnode, xmlNs *ns) +{ + /* insure children are kept in same namespace */ + xmlNode *t; + + t = xmlnode->children; + while (t) { + if (t->type != XML_ELEMENT_NODE) { + t = t->next; + continue; + } + xmlSetNs(xmlnode, ns); + insure_namespace(t, ns); + t = t->next; + } +} + +static xmlNode* +get_xmlNode(LassoNode *node) +{ + xmlNode *xmlnode; + xmlNs *ns; + + xmlnode = parent_class->get_xmlNode(node); + ns = xmlNewNs(xmlnode, LASSO_DST_QUERY(node)->hrefServiceType, + LASSO_DST_QUERY(node)->prefixServiceType); + xmlSetNs(xmlnode, ns); + insure_namespace(xmlnode, ns); + + return xmlnode; +} + /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ @@ -67,6 +100,8 @@ instance_init(LassoDstQuery *node) node->QueryItem = NULL; node->id = NULL; node->itemID = NULL; + node->prefixServiceType = NULL; + node->hrefServiceType = NULL; } static void @@ -75,6 +110,7 @@ class_init(LassoDstQueryClass *klass) LassoNodeClass *nodeClass = LASSO_NODE_CLASS(klass); parent_class = g_type_class_peek_parent(klass); + nodeClass->get_xmlNode = get_xmlNode; nodeClass->node_data = g_new0(LassoNodeClassData, 1); lasso_node_class_set_nodename(nodeClass, "Query"); lasso_node_class_add_snippets(nodeClass, schema_snippets); diff --git a/lasso/xml/dst_query.h b/lasso/xml/dst_query.h index dfd65af6..b89fe704 100644 --- a/lasso/xml/dst_query.h +++ b/lasso/xml/dst_query.h @@ -56,6 +56,9 @@ struct _LassoDstQuery { char *id; char *itemID; + + char *prefixServiceType; + char *hrefServiceType; }; struct _LassoDstQueryClass { -- cgit