Re: [xml] Questions about xml:id

On Mon, Mar 21, 2005 at 09:48:39AM -0500, Bruce Miller wrote:
Hi all;


 a set of good questions ...

 libxml2 apparently supports xml:id
[ ]
but I'm a little unclear on how it works, particularly
since I'm using libxml2 via XML::LibXML, rather than the C API.

It seems that libxml2 only gives an attribute that magic ID-ness
if the attribute's local-name is "xml:id"
 [in perl:  $node->setAttribute('xml:id','someid'); ]
rather than an "id" attribute in xml namespace
 [in perl: 
 $node->setAttributeNS('','id','someid'); ]
Is this the intention?

  Well the focus so far has mostly been toward parsing xml:id and handling
it only from a serialization. I didn't really looked at it from an API
perspective. But the behaviour exposed sounds like a bug. 

Second question: It appears that libxml2 creates an index of these ID's
that is used by the xpath function id().  The index gets created


when a document gets parsed and/or validated.  Apparently, the index
does not get `maintained' when a document is created or manipulated by hand.

  it's not complete probably. Removal of the attribute generate removal
from the ID table, but modification are not tracked down apparently.
Sounds like a bug too.

Is there a `cheap' way to notice & update the association between ID & node
when the structure gets rearranged?

  The functions used are xmlAddID() and xmlFreeID(), there is no mutation
callback associated.

Alternatively a call (short of 
I can use when I _know_ the association has changed?

  yes, xmlGetID:


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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