On Mon, Mar 21, 2005 at 09:48:39AM -0500, Bruce Miller wrote: > Hi all; Hi,
a set of good questions ... > libxml2 apparently supports xml:id > [ http://www.w3.org/TR/2004/WD-xml-id-20040407/ ] > 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('http://www.w3.org/XML/1998/namespace','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 right > 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 > validation) > I can use when I _know_ the association has changed? yes, xmlGetID: http://xmlsoft.org/html/libxml-valid.html#xmlGetID Daniel -- Daniel Veillard | Red Hat Desktop team http://redhat.com/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
