axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Mitchell" <bmitch...@austin.rr.com>
Subject RE: Cloning a portion of a XML tree using axiom
Date Tue, 05 Feb 2008 15:09:10 GMT
Hi Kasun,

 

In my application I found I had a similar need to clone all of an axiom
sub-tree.  Unlike the Xerces C++ package, the Axiom C package doesn't have a
built-in clone method.  Axiom does have all the underlying methods, though,
to traverse the tree and build new nodes that replicate the old nodes, so I
wrote my own clone.  Along the way I discovered that I needed something more
specialized than a general clone, to conditionally keep or discard
attributes and text associated with elements.  As well, I had to avoid some
of the Axiom methods, particularly the iterator methods, as I am sometimes
sharing the one source document across multiple threads.

 

As I was writing in C++, the end result isn't suitable to be a contribution
to Axiom.  The code throws exceptions to handle errors, instead of the
Axis/Axiom C technique of returning status codes.  Recursively traversing
the tree to clone each subtree is pretty straightforward, but looking at my
code could give you a jump start on handling namespaces and attributes as
the nodes and elements are reached along the way.  If you want a copy of the
routines I wrote, I can send them to you as an attachment off-list.  If you
are going to a C environment, you will need to replace all the error
handling and the C++ style comments; if you are in a C++ environment,
replacing the exceptions with something from your environment will be
straightforward.  

 

Bill Mitchell

wtmitchell3@acm.org

 

From: Kasun Indrasiri [mailto:kasun147@gmail.com] 
Sent: Tuesday, February 05, 2008 5:32 AM
To: Apache AXIS C Developers List
Subject: Re: Cloning a portion of a XML tree using axiom

 


Hi,

In the case of using  axiom_element_get_children_with_qname(...) method,
once the initial axiom_node is freed (say sec-policy is freed in above
example) then the node that we extracted through the iterator (which is to
be used for WS-Trust ) will be also freed.
 
What I really want to acheive is this.
- Initially I got an axiom_node which contains <sp:IssuedToken> ......  and
I want to get a new copy (separate memory allocation) of a content of that
node (say things with the <RequestSecurityTokenTemplate>  qname ).
- And also once the main node is freed, the extracted part should not be
freed. 
- I wonder whether Jimmy's solution would work with axiom. 

Thanks,
Kasun.




Mime
View raw message