[XML-SIG] DOM API

Paul Prescod paul@prescod.net
Mon, 19 Apr 1999 13:51:46 -0500


Fredrik Lundh wrote:
> 
> perhaps the "qp API" could be turned into a "standard
> python light-weight dom-like interface"?  and to get that
> process started, maybe you could post an interface
> summary?

I'm going to propose instead a light-weight DOM subset. I would rather not
require PyXML users to memorize two different APIs depending on whether
they doing light-weight work or heavy-weight work. Apart from my decision
to suggest a DOM subset, I have made my subset a little more functional in
some places and a little less in others. My bias is to expose *more* of
the underlying XML structure (processing instructions, attributes) and
relegate handling for lang and namespace to the more complex APIs (or
extensions to this API).

--

error (like qp_xml.error)
Parser (like qp_xml.Parser)

Parser.parse(input) (like qp_xml.parse but returns a document object)

Node.ChildNodes (a sequence of nodes property)
Node.NodeType (an integer a la DOM property)

Document.DocumentElement (an element node property)

Element.Attributes (a map of names to attribute objects property)
Element.GetAttribute (returns an attribute's value)
Element.TagName 
Element.PreviousSibling 
Element.NextSibing 

CharacterData.Data (a PyString property)

Attribute.Name
Attribute.Value

ProcessingInstruction.Target (string property)
ProcessingInstruction.Data (string property)

--

Note that I use the words "sequence" and "map" in their Python sense
above. Either a PyList or a NodeList Object could both be a sequence.
Either a PyDict or a NamedNodeList Object could be a map.

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for only himself
 http://itrc.uwaterloo.ca/~papresco

"The Excursion [Sport Utility Vehicle] is so large that it will come
equipped with adjustable pedals to fit smaller drivers and sensor 
devices that warn the driver when he or she is about to back into a
Toyota or some other object." -- Dallas Morning News