[XML-SIG] Likely Newbie Problem

Jeremy J. Sydik jsydik@virtualparadigm.com
Mon, 13 Mar 2000 22:31:30 -0600


I'm trying to write the handler for an <include obj="..."> tag to
simplify a process at work.  I'm sure there's something in the standard
or the dom tools that i'm forgetting/missing/never got.  When I use:

def doInclude(node):
    type = node.get_nodeType()
    if type == DOCUMENT_NODE:
        child=node.get_documentElement()
        doInclude(child)
    if type == ELEMENT_NODE:
        includeParent=node.get_parentNode()
        if node.name=="include":
            subreader=FileReader(node.getAttribute('obj')+'.xml')
            subdoc=subreader.document
            collapse_whitespace(subdoc)
            strip_whitespace(subdoc)
            for all in subdoc.get_documentElement().get_childNodes():
                includeParent.insertBefore(all,node)
            includeParent.removeChild(node)
        else:
            for child in node.get_childNodes():
                doInclude(child)

I get the following:
Traceback (innermost last):
  File "./test.cgi", line 64, in ?
    doInclude(doc)
  File "./test.cgi", line 35, in doInclude
    doInclude(child)
  File "./test.cgi", line 48, in doInclude
    doInclude(child)
  File "./test.cgi", line 48, in doInclude
    doInclude(child)
  File "./test.cgi", line 44, in doInclude
    includeParent.insertBefore(all,node)
  File "/usr/lib/python1.5/xml/dom/core.py", line 456, in insertBefore
    raise WrongDocumentException("newChild %s created from a "
xml.dom.core.WrongDocumentException: newChild <Element 'sect'> created
from a di
fferent document

The problem is, I KNOW i'm pulling part of another tree, but the second
contains information to pull into the first
Any thoughts what i'm doing wrong?

   Thanks
        --Jeremy J. Sydik
          (jsydik@virtualparadigm.com)