      result._c_node = c_node
      result._proxy_type = PROXY_ATTRIB
      registerProxy(result, PROXY_ATTRIB)
-@@ -899,14 +944,14 @@
+@@ -899,14 +945,14 @@
          registerProxy(self, PROXY_ATTRIB_ITER)
          return funicode(c_node.name)
      

+        doc = etree._doc
+        parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(doc._c_doc)
         if parser_ctxt is NULL:
             raise XMLSchemaParseError, "Document is not valid XML Schema"
         self._c_schema = xmlschema.xmlSchemaParse(parser_ctxt)
@@ -1513,13 +1729,15 @@
     def __dealloc__(self):
         xmlschema.xmlSchemaFree(self._c_schema)
 

 cdef _dumpToFile(f, xmlDoc* c_doc, xmlNode* c_node):
     cdef tree.PyObject* o
     cdef tree.xmlOutputBuffer* c_buffer
@@ -1940,7 +2316,7 @@
 
 
 cdef void changeDocumentBelow(_NodeBase node,
