[XML-SIG] managing ID attributes in an XML document
Andrew Clover
and-xml at doxdesk.com
Sun Oct 24 21:35:16 CEST 2004
Lloyd Kvam <pythonTutor at venix.com> wrote:
> I need to create ID attributes while manipulating an XML document.
Minidom and pxdom both support the DOM Level 3 Core ID functionality
(Attr.isId, Element.setIdAttribute etc.), and will automatically make an
attribute have IDness when it is added to a document whose DTD states
that element+attribute is of type ID.
> Is there a Python XML package with a getIDList type of function built in?
Not to my knowledge. Minidom maintains a cache of previously-looked-up
IDs, but that's internal and not really what you want. Assuming you're
manipulating the document with DOM tools, there's probably no shortcut
to just walking the entire document noting the value of every attribute
where Attr.isId is True.
If you're just checking each IDREF attribute matches something, is the
test 'document.getElementById(idrefAttr.value) is not None' too slow?
--
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/
More information about the XML-SIG
mailing list