Re: [xml] Potential wrong usage of xmlIsID() in tree.c



Daniel Veillard wrote:
Daniel, from a non-DOM perspective, what's your view on adding auto ID-ness detection to functions like addchild, addsibling, etc... In the

  I'm undecided. On one side the fact of adding an attribute to a document
may potentially make the parent an ID for that document. On the other side
you have the XML Infoset spec which state that IDness is a property of the
attribute (set at parse time or creation time)
  http://www.w3.org/TR/xml-infoset/#infoitem.attribute
  [attribute type] == ID
and well when you copy this attribute you copy its infoset and hence its
properties.
See comments below.
patch I'm working on I removed my original code for those and only fixed up some other issues, but do you want the ID stuff added there as well for consistency with the newprop, setprop functions or should detection just be left in the state it is in now? If you do think it should go in, the last question I have is creating a xml:id attribute without a parent element. Right now it marks it as an ID, but I think xmlNewPropInternal should be changed to check for a parent element first.

  To me creating a new attribute should definitely make the lookup and
set the attribute type, but if you copy an existing one I think the existing
type should be maintained, it may differ if you reserialize and reparse
but that's a different document.
I see the creation of the infoset (non-parse time) as falling under the synthetic infoset category. To me this encompasses node creation, unlinking, appending, etc.. Based on a DTD or the xml:id spec, an attribute must have an element to be considered an ID. As far as the copying goes, if a lone attribute is copied, the type should be modified as it breaks the element/attribute relationship for IDs. Once added back to a an element then the IDness would be updated appropriately.

The closest API the Information Set spec even mentions for manually building an infoset is the DOM API (though it does't limit what API can be used), which we have seen has completely different rules for handling building IDness. From the non-DOM perspective if IDness is going to be determined from checking the DTD when manually creating an attribute, then it should also take care of it when inserting attributes as well. Which leads to my perspective on unlinking and copying.

Rob



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