Re: [xml] how to set or reset a namespace prefix?



On Thu, Jan 12, 2006 at 11:31:43PM -0500, Krepis P. wrote:
I need to either set or change a prefix for a namespace on an existing
document tree. There's plenty of ways to get the information on the
namespace, but I'm not sure how best to change the namespace prefix.
Do I just assign a new xmlChar * to xmlNsPtr->prefix, or do I need to
use a function for that (or do anything else along with it)?

  yes replace the prefix in the xmlNs. Check if it doesn't come from the
document dictionnary, if no xmlFree() it, and then replace it by a new
xmlMalloc'ed string or by a string from the dictionnary.
  The operation has no public entry point, usually namespaces are immutable
as the prefix should not be important and changing the namespace name affects
all referencing nodes in the document.

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]