[XML-SIG] Can anyone recommend a sensible XML parser for Python?

Fred L. Drake, Jr. fdrake@acm.org
Tue, 10 Sep 2002 14:11:40 -0400


Uche Ogbuji writes:
 > So you think it should do what I mentioned before?
 > 
 > 1) Create a new documenType and document node
 > 2) clone all child nodes
 > 3) set the ownerDocument of each of the new nodes to the new document?

If deep==True, yes.  See table below for deep==False.

 > If we have it do that, then let us please
 > 
 > 1) Document it properly
 > 2) Point out that it is not standard DOM behavior

I'm glad to document it carefully; that's entirely reasonable.  It
certainly falls within the space of "implementation dependent", which
the DOM spec says this is.

I think this is the right set of behaviors:

        \   cloneNode(0) | cloneNode(1) | importNode(n,0) | importNode(n,1)
nodeType \               |              |                 |
          +--------------|--------------|-----------------|-----------------
document  | return None  | new document | NotSupportedErr | NotSupportedErr
          +--------------|--------------|-----------------|-----------------
doctype   | new doctype, | new doctype, | new doctype if  | new doctype if
          | no entities  | w/ entities  | new parent has  | new parent has
          | or notations | and notations| doctype==None,  | doctype==None,
          |              |              | else NotSuppErr,| w/ entities
          |              |              | no entities or  | and notations
          |              |              | notations       |

Document.cloneNode(0) returns None since it's not allowed to raise an
exception according to the DOM spec.



  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation