Re: Naespaces of attributes in python API
Daniel Veillard <[email protected]> Wed, 19 Jun 2002 13:30:44 -0400
| Newsgroups | gmane.comp.gnome.lib.xml.bindings |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Jun 19, 2002 at 07:37:07PM +0200, [email protected] wrote: > On Wed, Jun 19, 2002 at 01:26:16PM -0400, Daniel Veillard wrote: > > On Wed, Jun 19, 2002 at 07:23:01PM +0200, [email protected] wrote: > > > Just a quick question: > > > > > > how can i specify the naespace of an attribute that i want > > > to add to an existing node with node.setProp('x', 'y') ? > > > > Find the namespace node profinding the declaration for that namespace > > > > def searchNsByHref(self, doc, href): > > """Search a Ns aliasing a given URI. Recurse on the parents > > until it finds the defined namespace or return None > > otherwise.""" > > > > and then use it to make a namespaced attribute > > > > def setNsProp(self, ns, name, value): > > """Set (or reset) an attribute carried by a node. The ns > > structure must be in scope, this is not checked.""" > > Ah, ok. So, if i insert attributes with a naespace that probably doesn't > exist in the document in need to add a namespace node to the document > first. yes, that's how libxml2 API work :-) def newNs(self, href, prefix): """Creation of a new Namespace. This function will refuse to create a namespace with a similar prefix than an existing one present on this node. We use href==None in the case of an element creation where the namespace was not defined.""" Daniel -- Daniel Veillard | Red Hat Network https://rhn.redhat.com/ [email protected] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/