Re: [xml] xmlSearchNsByHref

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Sat Nov 18 2000 - 11:47:25 EST


On Sat, Nov 18, 2000 at 03:37:18PM +0000, Bjorn Reese wrote:
>
> I am trying to determine whether an element is part of a namespace
> or not. Consider the following example:
>
> <root xmlns:ns="urn:ns">
> <ns:first>
> <second/>
> </ns:first>
> </root>
>
> I parse this document and use xmlSearchNsByHref(doc, node, "urn:ns");
> to determine the namespace.
>
> As expected, this returns the ns namespace for <ns:first>.
>
> However, xmlSearchNsByHref() also returns the ns namespace for
> <second/>. I would expect it only to return the default namespace
> (of which there is none in the document). Is this an error in
> xmlSearchNsByHref(), or have I misinterpreted the purpose of that
> function?

  xmlSearchNsByHref() search the namespace in scope for node...
the declaration on <root> is still in scope on <second>, so searching
with node=<second> will return the same result as node=<first>.
  The namespace of a node (if any) is node->ns, this is a pointer to
the namespace declaration (available from the nsDef list of the element
declaring it).

   hope this clarifies the situation,

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | libxml Gnome XML toolkit
Tel : +33 476 615 257  | 655, avenue de l'Europe | http://xmlsoft.org/
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Rpmfind search site
 http://www.w3.org/People/all#veillard%40w3.org  | http://rpmfind.net/
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Nov 18 2000 - 14:43:22 EST