Re: [xml] xmlCopyNode that doesn't copy a namespace?
- From: cazic gmx net
- To: "Theodore H. Smith" <delete elfdata com>
- Cc: xml gnome org
- Subject: Re: [xml] xmlCopyNode that doesn't copy a namespace?
- Date: Sat, 31 Dec 2005 18:50:07 +0100 (MET)
Von: "Theodore H. Smith" <delete elfdata com>
Datum: Fri, 30 Dec 2005 15:10:08 +0000
So, I got this problem with xmlCopyNode, it's putting a namespace
into the XML, when I don't actually want one there.
before I had this:
then I end up with this:
Is there some way to disable this behaviour?
I don't think there's a public function in Libxml2 which does
what you want.
What I currently use to avoid creation of namespace declarations
is the following:
- Walk the tree to be copied on your side.
- Build the resulting tree-copy on your side.
- Use xmlDocCopyNode() with an @extended argument of 0. Doing this
will only copy the rudimental element node; i.e. no ns-decls, no
children and no attributes.
- Copy the already existent ns-decls on your side.
- Copy attribute nodes on your side.
- Finally use xmlDOMWrapReconcileNamespaces() to ensure that
node->ns entries point to in-scope ns-decls.
Actually a public version of xmlStaticCopyNode() would do the
job you want if you have a @parent argument at hand. It would
search the ns-decls of the destination tree as well, thus would
avoid creation of redundant ns-decls.
Does anyone see problems wrt adding a public wrapper for
xmlStaticCopyNode() which also takes a @parent argument?
However, in the long term I would like to add a function
similar to xmlDOMWrapAdoptNode(), which does a copy of the
tree and provides customizable handling of ns-references.
][Date Next] [Thread Prev