You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2005/09/30 14:00:00 UTC

svn commit: r292712 - in /webservices/axis2/trunk/c: include/axis2c_node.h modules/xml/guththila/src/stack.h modules/xml/om/project.properties modules/xml/om/src/axis2c_node.c modules/xml/om/src/axis2c_om_element.c modules/xml/om/test/om_test.c

Author: samisa
Date: Fri Sep 30 04:59:48 2005
New Revision: 292712

URL: http://svn.apache.org/viewcvs?rev=292712&view=rev
Log: (empty)

Modified:
    webservices/axis2/trunk/c/include/axis2c_node.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/stack.h
    webservices/axis2/trunk/c/modules/xml/om/project.properties
    webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c
    webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c
    webservices/axis2/trunk/c/modules/xml/om/test/om_test.c

Modified: webservices/axis2/trunk/c/include/axis2c_node.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2c_node.h?rev=292712&r1=292711&r2=292712&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2c_node.h (original)
+++ webservices/axis2/trunk/c/include/axis2c_node.h Fri Sep 30 04:59:48 2005
@@ -21,7 +21,7 @@
 #include <apr_pools.h>
 #include <xmlpullparser.h>
 
-static apr_pool_t *om_pool; // a memory pool to be used for this module
+//static apr_pool_t *om_pool; // a memory pool to be used for this module
 
 typedef struct axis2c_stax_om_builder_s  axis2c_stax_om_builder_t;
 

Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/stack.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/stack.h?rev=292712&r1=292711&r2=292712&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/stack.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/stack.h Fri Sep 30 04:59:48 2005
@@ -34,7 +34,7 @@
 
 typedef struct element ELEMENT;
 
-typedef struct element
+struct element
 {
   TOKEN *token;
   ATTRIBUTE *attribute;

Modified: webservices/axis2/trunk/c/modules/xml/om/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/project.properties?rev=292712&r1=292711&r2=292712&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/project.properties (original)
+++ webservices/axis2/trunk/c/modules/xml/om/project.properties Fri Sep 30 04:59:48 2005
@@ -17,5 +17,5 @@
 freehep.nar.src=src
 freehep.nar.outtype=shared
 freehep.nar.test.src=test
-freehep.nar.tests=
+freehep.nar.tests=om_test
 freehep.nar.linker.test.arg.end=-Ltarget/nar/lib/i386-Linux-g++ -laxis2c-xml-om-nar-0.0

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c?rev=292712&r1=292711&r2=292712&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_node.c Fri Sep 30 04:59:48 2005
@@ -19,10 +19,12 @@
 axis2c_node_t *axis2c_create_node()
 {
     axis2c_node_t *node = (axis2c_node_t *) malloc(sizeof(axis2c_node_t));
-    if (!node)
+   
+   if (!node)
     {
-	return NULL;
+    	return NULL;
     }
+    
     node->first_child = NULL;
     node->last_child = NULL;
     node->next_sibling = NULL;
@@ -40,23 +42,28 @@
 {
     if (!node)
 	return;
-    //if(node->
+    
+    
 }
 
 void axis2c_node_add_child(axis2c_node_t * parent, axis2c_node_t * child)
 {
     if (!parent || !child)
 	return;
+    
     if (parent->first_child == NULL)
     {
-	parent->first_child = child;
-    } else
+	    parent->first_child = child;
+    }
+    else
     {
-	parent->last_child->next_sibling = child;
-	child->prev_sibling = parent->last_child;
+	    parent->last_child->next_sibling = child;
+	    child->prev_sibling = parent->last_child;
     }
+    
     child->parent = parent;
     parent->last_child = child;
+
 }
 
 
@@ -64,7 +71,7 @@
 axis2c_node_t *axis2c_node_detach(axis2c_node_t * node_to_detach)
 {
     axis2c_node_t *parent = NULL;
-    axis2c_node_t *next_sibling = NULL;
+
     if (!node_to_detach)
     {
 	    return NULL;
@@ -72,10 +79,10 @@
 
     if (!(node_to_detach->parent))
     {
-	/* nodes that do not have a parent can't be detached
-	 */
+	    /* nodes that do not have a parent can't be detached  */
     	return NULL;
     }
+    
     parent = node_to_detach->parent;
     
     if ((node_to_detach->prev_sibling) == NULL)
@@ -118,11 +125,13 @@
 	}
 	node->parent = parent;
 }
+
 /**
  * This will insert a sibling just after the current information item
  *@param node the node in consideration
  *@param nodeto_insert the node that will be inserted
  */
+ 
 void axis2c_node_insert_sibling_after(axis2c_node_t *node,axis2c_node_t *nodeto_insert)
 {
 	if(!node || !nodeto_insert )
@@ -136,7 +145,8 @@
 	{
 		node->next_sibling->prev_sibling = nodeto_insert;
 	}
-	nodeto_insert->next_sibling = node->next_sibling;
+
+    nodeto_insert->next_sibling = node->next_sibling;
 	node->next_sibling = nodeto_insert;
 }
 

Modified: webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c?rev=292712&r1=292711&r2=292712&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/src/axis2c_om_element.c Fri Sep 30 04:59:48 2005
@@ -18,6 +18,8 @@
 #include <axis2c_om_attribute.h>
 #include <stdlib.h>
 
+static apr_pool_t *om_pool;
+
 axis2c_node_t *axis2c_create_om_element(const char *localname,
 					axis2c_om_namespace_t * ns)
 {
@@ -168,8 +170,11 @@
 {
     axis2c_om_namespace_t *nsp = NULL;
     nsp = axis2c_create_om_namespace(uri, prefix);
+  
     if (nsp)
-	return axis2c_om_element_declare_namespace(element_node, nsp);
+	
+    return axis2c_om_element_declare_namespace(element_node, nsp);
+    
     return NULL;
 }
 
@@ -185,20 +190,27 @@
 					       const char *prefix)
 {
     void *ns = NULL;
+    apr_hash_index_t *hashindex;
     axis2c_om_element_t *element = NULL;
+    
     if (!element_node || !ns || element_node->element_type != AXIS2C_OM_ELEMENT)
     {
-	return NULL;
+	    return NULL;
     }
+
     element = (axis2c_om_element_t *) (element_node->data_element);
     if (!prefix || strcmp(prefix, "") == 0)
     {
-	// should traverse through the namespaces 
-
-
+	     for(hashindex = apr_hash_first(om_pool,element->namespaces);hashindex;hashindex = apr_hash_next(hashindex))
+         {
+            apr_hash_this(hashindex,NULL,NULL,&ns);
+            if(strcmp(((axis2c_om_namespace_t*)(ns))->uri,uri))
+                return (axis2c_om_namespace_t*)(ns);
+         
+         }
     }
     ns = apr_hash_get(element->namespaces, prefix, APR_HASH_KEY_STRING);
-    return (void *) ns;
+    return (axis2c_om_namespace_t *) ns;
 }
 
 /*
@@ -252,8 +264,7 @@
     axis2c_om_namespace_t *ns1 = NULL;
     if (!ns || !element_node)
     {
-	// namespace null handle condition
-
+	    
     }
     ns1 =
 	axis2c_om_element_find_namespace(element_node, ns->uri,

Modified: webservices/axis2/trunk/c/modules/xml/om/test/om_test.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/om/test/om_test.c?rev=292712&r1=292711&r2=292712&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/om/test/om_test.c (original)
+++ webservices/axis2/trunk/c/modules/xml/om/test/om_test.c Fri Sep 30 04:59:48 2005
@@ -1,47 +1,46 @@
-#include <CuTest.h>
-#include <string.h>
 #include <stdio.h>
+#include <axis2c_om_element.h>
+#include <axis2c_om_namespace.h>
 #include <axis2c_node.h>
+#include <apr.h>
 
-void Testdetach_node(CuTest *tc) {
-	node_t* parent = create_node();
-        node_t* prev_sibling = create_node();
-        node_add_child(parent, prev_sibling);
-        node_t* test_node = create_node();
-        node_add_child(parent, test_node);
-        node_t* next_sibling = create_node();
-        node_add_child(parent, next_sibling);
-        
-        node_t* temp_parent = detach_node(test_node);
-        puts("came");
-        if(0 == temp_parent) puts("parent is null\n");
-        node_t* expected = temp_parent->first_child;
-        printf("came2");
-        if(0 == expected) puts("expected is null\n");
-        node_t* actual = next_sibling;
-
-        CuAssertPtrEquals(tc, expected, actual); 
-    }
-
-    CuSuite* detach_nodeGetSuite() {
-        CuSuite* suite = CuSuiteNew();
-        SUITE_ADD_TEST(suite, Testdetach_node);
-        return suite;
-    }
-
- void RunAllTests(void) {
-        CuString *output = CuStringNew();
-        CuSuite* suite = CuSuiteNew();
-
-        CuSuiteAddSuite(suite, detach_nodeGetSuite());
-
-        CuSuiteRun(suite);
-        CuSuiteSummary(suite, output);
-        CuSuiteDetails(suite, output);
-        printf("%s\n", output->buffer);
-    }
-
-    int main(void) {
-        RunAllTests();
-        return 0;
-    }
+/**
+ *  This code shows how the currently implemented code support building of om tree programmtically
+ *
+ */
+
+
+
+
+
+int main()
+{
+    axis2c_om_attribute_t *attr1;
+	axis2c_om_namespace_t *ns1;
+	axis2c_node_t *root,*ele1,*ele2;
+	
+	if(apr_initialize()!= APR_SUCCESS)
+	{
+		return -1;
+	}
+
+
+	ns1  = axis2c_create_om_namespace("ns1","test");
+	
+	root = axis2c_create_om_element("root",ns1);
+	ele1 = axis2c_create_om_element_with_parent("ele1",ns1,root);
+	ele2 = axis2c_create_om_element("ele2",ns1);
+
+	axis2c_node_add_child(ele1,ele2);
+
+	attr1 = axis2c_create_om_attribute("attribute1","x",ns1);
+
+	axis2c_om_element_add_attribute(ele2,attr1);
+	
+
+	printf("%s",axis2c_om_element_get_localname(ele2->parent->parent));
+    
+    getchar();
+    
+    return 0;
+}