/* Generated by Cython 0.10 on Mon Nov 17 22:06:29 2008 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
       void *buf;
       PyObject *obj;
       Py_ssize_t len;
       Py_ssize_t itemsize;
       int readonly;
       int ndim;
       char *format;
       Py_ssize_t *shape;
       Py_ssize_t *strides;
       Py_ssize_t *suboffsets;
       void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_LOCK 0x0002
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyString_Type                PyBytes_Type
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define PyBytes_Type                 PyString_Type
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#else
  #define _USE_MATH_DEFINES
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#define __PYX_HAVE_API__lxml__etree
#include "etree_defs.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "stdarg.h"
#include "lxml-version.h"
#include "libxml/xmlversion.h"
#include "libxml/encoding.h"
#include "libxml/chvalid.h"
#include "libxml/hash.h"
#include "libxml/tree.h"
#include "libxml/HTMLtree.h"
#include "libxml/valid.h"
#include "libxml/xmlIO.h"
#include "libxml/xmlsave.h"
#include "libxml/globals.h"
#include "libxml/xmlstring.h"
#include "libxml/xmlmemory.h"
#include "pythread.h"
#include "libxml/xmlerror.h"
#include "libxml/xpath.h"
#include "libxml/xpathInternals.h"
#include "libxml/c14n.h"
#include "libxml/parser.h"
#include "libxml/parserInternals.h"
#include "libxml/HTMLparser.h"
#include "libxml/xinclude.h"
#include "libxslt/xslt.h"
#include "libxslt/xsltconfig.h"
#include "libxslt/xsltInternals.h"
#include "libxslt/extensions.h"
#include "libxslt/documents.h"
#include "libxslt/transform.h"
#include "libxslt/xsltutils.h"
#include "libxslt/security.h"
#include "libxslt/extra.h"
#include "libexslt/exslt.h"
#include "libxml/relaxng.h"
#include "libxml/xmlschemas.h"
#include "libxml/schematron.h"


#ifdef __GNUC__
#define INLINE __inline__
#elif _WIN32
#define INLINE __inline
#else
#define INLINE 
#endif

typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/



static int __pyx_skip_dispatch = 0;


/* Type Conversion Predeclarations */

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyBytes_FromString PyString_FromString
#define __Pyx_PyBytes_AsString   PyString_AsString
#else
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_AsString   PyBytes_AsString
#endif

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x);
static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b);

#define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x))
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))

static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x);
static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x);
static INLINE char __pyx_PyInt_char(PyObject* x);
static INLINE short __pyx_PyInt_short(PyObject* x);
static INLINE int __pyx_PyInt_int(PyObject* x);
static INLINE long __pyx_PyInt_long(PyObject* x);
static INLINE signed char __pyx_PyInt_signed_char(PyObject* x);
static INLINE signed short __pyx_PyInt_signed_short(PyObject* x);
static INLINE signed int __pyx_PyInt_signed_int(PyObject* x);
static INLINE signed long __pyx_PyInt_signed_long(PyObject* x);
static INLINE long double __pyx_PyInt_long_double(PyObject* x);
#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char **__pyx_f;

static char __pyx_mdoc[] = "The ``lxml.etree`` module implements the extended ElementTree API\nfor XML.\n";

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
    PyObject *r;
    if (PyList_CheckExact(o) && 0 <= i && i < PyList_GET_SIZE(o)) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && 0 <= i && i < PyTuple_GET_SIZE(o)) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0) || !is_unsigned))
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

static INLINE int __Pyx_DelItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
    int r;
    if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0) || !is_unsigned))
        r = PySequence_DelItem(o, i);
    else {
        PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) : PyLong_FromUnsignedLongLong((sizeof(unsigned long long) > sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i);
        if (!j)
            return -1;
        r = PyObject_DelItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/

static int __Pyx_Print(PyObject *, int); /*proto*/
#if PY_MAJOR_VERSION >= 3
static PyObject* __pyx_print = 0;
static PyObject* __pyx_print_kwargs = 0;
#endif

static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (PyList_Append(L, x) < 0) return NULL;
        Py_INCREF(Py_None);
        return Py_None; // this is just to have an accurate signature
    }
    else {
        return PyObject_CallMethod(L, "append", "(O)", x);
    }
}

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/

static void __Pyx_WriteUnraisable(const char *name); /*proto*/

static int __Pyx_ExportFunction(char *name, void *f, char *sig); /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

/* Type declarations */

typedef xmlNode *(*_node_to_node_function)(xmlNode *);

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":214
 *         c_parent = c_parent.parent
 * 
 * ctypedef struct _nscache:             # <<<<<<<<<<<<<<
 *     xmlNs** new
 *     xmlNs** old
 */

typedef struct {
  xmlNs **new;
  xmlNs **old;
  size_t size;
  size_t last;
} __pyx_t_4lxml_5etree__nscache;

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":255
 *                                   _cstr(attr_name_utf), _cstr(value_utf))
 * 
 * ctypedef struct _ns_node_ref:             # <<<<<<<<<<<<<<
 *     xmlNs* ns
 *     xmlNode* node
 */

typedef struct {
  xmlNs *ns;
  xmlNode *node;
} __pyx_t_4lxml_5etree__ns_node_ref;

typedef PyObject *(*_element_class_lookup_function)(PyObject *, struct LxmlDocument *, xmlNode *);

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":3
 * # Custom resolver API
 * 
 * ctypedef enum _InputDocumentDataType:             # <<<<<<<<<<<<<<
 *     PARSER_DATA_EMPTY
 *     PARSER_DATA_STRING
 */

typedef enum {
  __pyx_e_4lxml_5etree_PARSER_DATA_EMPTY,
  __pyx_e_4lxml_5etree_PARSER_DATA_STRING,
  __pyx_e_4lxml_5etree_PARSER_DATA_FILENAME,
  __pyx_e_4lxml_5etree_PARSER_DATA_FILE
} __pyx_t_4lxml_5etree__InputDocumentDataType;

typedef enum {
  __pyx_e_4lxml_5etree_SAX_EVENT_START = 1,
  __pyx_e_4lxml_5etree_SAX_EVENT_END = 2,
  __pyx_e_4lxml_5etree_SAX_EVENT_DATA = 4,
  __pyx_e_4lxml_5etree_SAX_EVENT_DOCTYPE = 8,
  __pyx_e_4lxml_5etree_SAX_EVENT_PI = 16,
  __pyx_e_4lxml_5etree_SAX_EVENT_COMMENT = 32
} __pyx_t_4lxml_5etree__SaxParserEvents;

enum __pyx_t_4lxml_5etree__OutputMethods {
  __pyx_e_4lxml_5etree_OUTPUT_METHOD_XML,
  __pyx_e_4lxml_5etree_OUTPUT_METHOD_HTML,
  __pyx_e_4lxml_5etree_OUTPUT_METHOD_TEXT
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":5
 * DEF __ITERPARSE_CHUNK_SIZE = 32768
 * 
 * ctypedef enum _IterparseEventFilter:             # <<<<<<<<<<<<<<
 *     ITERPARSE_FILTER_START     =  1
 *     ITERPARSE_FILTER_END       =  2
 */

typedef enum {
  __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START = 1,
  __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END = 2,
  __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS = 4,
  __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS = 8,
  __pyx_e_4lxml_5etree_ITERPARSE_FILTER_COMMENT = 16,
  __pyx_e_4lxml_5etree_ITERPARSE_FILTER_PI = 32
} __pyx_t_4lxml_5etree__IterparseEventFilter;

typedef int (*__pyx_t_4lxml_5etree__register_function)(void *, PyObject *, PyObject *);

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":275
 * 
 * # forward declaration of _BaseParser, see parser.pxi
 * cdef class _BaseParser             # <<<<<<<<<<<<<<
 * 
 * ctypedef public xmlNode* (*_node_to_node_function)(xmlNode*)
 */

struct __pyx_obj_4lxml_5etree__BaseParser {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__BaseParser *__pyx_vtab;
  struct LxmlElementClassLookup *_class_lookup;
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *_resolvers;
  struct __pyx_obj_4lxml_5etree__ParserContext *_parser_context;
  struct __pyx_obj_4lxml_5etree__ParserContext *_push_parser_context;
  int _parse_options;
  int _for_html;
  int _remove_comments;
  int _remove_pis;
  int _strip_cdata;
  struct __pyx_obj_4lxml_5etree_XMLSchema *_schema;
  PyObject *_filename;
  PyObject *_target;
  PyObject *_default_encoding;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":999
 * ############################################################
 * 
 * cdef class _FeedParser(_BaseParser):             # <<<<<<<<<<<<<<
 *     cdef bint _feed_parser_running
 * 
 */

struct __pyx_obj_4lxml_5etree__FeedParser {
  struct __pyx_obj_4lxml_5etree__BaseParser __pyx_base;
  int _feed_parser_running;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1169
 *     )
 * 
 * cdef class XMLParser(_FeedParser):             # <<<<<<<<<<<<<<
 *     u"""XMLParser(self, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, remove_blank_text=False, compact=True, resolve_entities=True, remove_comments=False, remove_pis=False, target=None, encoding=None, schema=None)
 *     The XML parser.
 */

struct __pyx_obj_4lxml_5etree_XMLParser {
  struct __pyx_obj_4lxml_5etree__FeedParser __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1243
 *                              target, None, encoding)
 * 
 * cdef class ETCompatXMLParser(XMLParser):             # <<<<<<<<<<<<<<
 *     u"""ETCompatXMLParser(self, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, remove_blank_text=False, compact=True, resolve_entities=True, remove_comments=True, remove_pis=True, target=None, encoding=None, schema=None)
 *     An XML parser with an ElementTree compatible default setup.
 */

struct __pyx_obj_4lxml_5etree_ETCompatXMLParser {
  struct __pyx_obj_4lxml_5etree_XMLParser __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":14
 * 
 * 
 * cdef class _NamespaceRegistry:             # <<<<<<<<<<<<<<
 *     u"Dictionary-like namespace registry"
 *     cdef object _ns_uri
 */

struct __pyx_obj_4lxml_5etree__NamespaceRegistry {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry *__pyx_vtab;
  PyObject *_ns_uri;
  PyObject *_ns_uri_utf;
  PyObject *_entries;
  char *_c_ns_uri_utf;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":186
 *         return registry
 * 
 * cdef class _FunctionNamespaceRegistry(_NamespaceRegistry):             # <<<<<<<<<<<<<<
 *     def __setitem__(self, name, item):
 *         if not callable(item):
 */

struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry {
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":199
 *         return u"FunctionNamespace(%r)" % self._ns_uri
 * 
 * cdef class _XPathFunctionNamespaceRegistry(_FunctionNamespaceRegistry):             # <<<<<<<<<<<<<<
 *     cdef object _prefix
 *     cdef object _prefix_utf
 */

struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry {
  struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry __pyx_base;
  PyObject *_prefix;
  PyObject *_prefix_utf;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":11
 *     SAX_EVENT_COMMENT = 32
 * 
 * cdef class _SaxParserTarget:             # <<<<<<<<<<<<<<
 *     cdef int _sax_event_filter
 *     cdef int _sax_event_propagate
 */

struct __pyx_obj_4lxml_5etree__SaxParserTarget {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *__pyx_vtab;
  int _sax_event_filter;
  int _sax_event_propagate;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":97
 *             return ErrorLevels._getName(self.level, u"unknown")
 * 
 * cdef class _BaseErrorLog:             # <<<<<<<<<<<<<<
 *     cdef _LogEntry _first_error
 *     cdef readonly object last_error
 */

struct __pyx_obj_4lxml_5etree__BaseErrorLog {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog *__pyx_vtab;
  struct __pyx_obj_4lxml_5etree__LogEntry *_first_error;
  PyObject *last_error;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2012
 * 
 * 
 * cdef public class _ElementTagMatcher [ object LxmlElementTagMatcher,             # <<<<<<<<<<<<<<
 *                                        type LxmlElementTagMatcherType ]:
 *     cdef object _pystrings
 */

struct LxmlElementTagMatcher {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher *__pyx_vtab;
  PyObject *_pystrings;
  int _node_type;
  char *_href;
  char *_name;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":324
 * 
 * 
 * cdef class XSLT:             # <<<<<<<<<<<<<<
 *     u"""XSLT(self, xslt_input, extensions=None, regexp=True, access_control=None)
 * 
 */

struct __pyx_obj_4lxml_5etree_XSLT {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree_XSLT *__pyx_vtab;
  struct __pyx_obj_4lxml_5etree__XSLTContext *_context;
  xsltStylesheet *_c_style;
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *_xslt_resolver_context;
  struct __pyx_obj_4lxml_5etree_XSLTAccessControl *_access_control;
  struct __pyx_obj_4lxml_5etree__ErrorLog *_error_log;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2118
 *         self._storeNext(node)
 * 
 * cdef class ElementDepthFirstIterator(_ElementTagMatcher):             # <<<<<<<<<<<<<<
 *     u"""ElementDepthFirstIterator(self, node, tag=None, inclusive=True)
 *     Iterates over an element and its sub-elements in document order (depth
 */

struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator {
  struct LxmlElementTagMatcher __pyx_base;
  struct LxmlElement *_next_node;
  struct LxmlElement *_top_node;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":95
 *         return doc_ref
 * 
 * cdef class _ResolverRegistry:             # <<<<<<<<<<<<<<
 *     cdef object _resolvers
 *     cdef Resolver _default_resolver
 */

struct __pyx_obj_4lxml_5etree__ResolverRegistry {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ResolverRegistry *__pyx_vtab;
  PyObject *_resolvers;
  struct __pyx_obj_4lxml_5etree_Resolver *_default_resolver;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":331
 * ############################################################
 * 
 * cdef class TreeBuilder(_SaxParserTarget):             # <<<<<<<<<<<<<<
 *     u"""TreeBuilder(self, element_factory=None, parser=None)
 *     Parser target that builds a tree.
 */

struct __pyx_obj_4lxml_5etree_TreeBuilder {
  struct __pyx_obj_4lxml_5etree__SaxParserTarget __pyx_base;
  struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
  PyObject *_factory;
  PyObject *_data;
  PyObject *_element_stack;
  PyObject *_element_stack_pop;
  struct LxmlElement *_last;
  int _in_tail;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":102
 *     _XPATH_VERSION_WARNING_REQUIRED = 0
 * 
 * cdef class _XPathEvaluatorBase:             # <<<<<<<<<<<<<<
 *     cdef xpath.xmlXPathContext* _xpathCtxt
 *     cdef _XPathContext _context
 */

struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase *__pyx_vtab;
  xmlXPathContext *_xpathCtxt;
  struct __pyx_obj_4lxml_5etree__XPathContext *_context;
  PyThread_type_lock _eval_lock;
  struct __pyx_obj_4lxml_5etree__ErrorLog *_error_log;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":217
 * 
 * 
 * cdef class XPathElementEvaluator(_XPathEvaluatorBase):             # <<<<<<<<<<<<<<
 *     u"""XPathElementEvaluator(self, element, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 *     Create an XPath evaluator for an element.
 */

struct __pyx_obj_4lxml_5etree_XPathElementEvaluator {
  struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase __pyx_base;
  struct LxmlElement *_element;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":292
 * 
 * 
 * cdef class XPathDocumentEvaluator(XPathElementEvaluator):             # <<<<<<<<<<<<<<
 *     u"""XPathDocumentEvaluator(self, etree, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 *     Create an XPath evaluator for an ElementTree.
 */

struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator {
  struct __pyx_obj_4lxml_5etree_XPathElementEvaluator __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":520
 * 
 * 
 * cdef public class _Element [ type LxmlElementType, object LxmlElement ]:             # <<<<<<<<<<<<<<
 *     u"""Element class.
 * 
 */

struct LxmlElement {
  PyObject_HEAD
  PyObject *_gc_doc;
  struct LxmlDocument *_doc;
  xmlNode *_c_node;
  PyObject *_tag;
  PyObject *_attrib;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1368
 * 
 * 
 * cdef class __ContentOnlyElement(_Element):             # <<<<<<<<<<<<<<
 *     cdef int _raiseImmutable(self) except -1:
 *         raise TypeError, u"this element does not have children or attributes"
 */

struct __pyx_obj_4lxml_5etree___ContentOnlyElement {
  struct LxmlElement __pyx_base;
  struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement *__pyx_vtab;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1437
 *         return []
 * 
 * cdef class _Comment(__ContentOnlyElement):             # <<<<<<<<<<<<<<
 *     property tag:
 *         def __get__(self):
 */

struct __pyx_obj_4lxml_5etree__Comment {
  struct __pyx_obj_4lxml_5etree___ContentOnlyElement __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":372
 * 
 * 
 * cdef class XPath(_XPathEvaluatorBase):             # <<<<<<<<<<<<<<
 *     u"""XPath(self, path, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 *     A compiled XPath expression that can be called on Elements and ElementTrees.
 */

struct __pyx_obj_4lxml_5etree_XPath {
  struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase __pyx_base;
  xmlXPathCompExpr *_xpath;
  PyObject *path;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":445
 * _find_namespaces = re.compile('({[^}]+})').findall
 * 
 * cdef class ETXPath(XPath):             # <<<<<<<<<<<<<<
 *     u"""ETXPath(self, path, extensions=None, regexp=True)
 *     Special XPath class that supports the ElementTree {uri} notation for namespaces.
 */

struct __pyx_obj_4lxml_5etree_ETXPath {
  struct __pyx_obj_4lxml_5etree_XPath __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":70
 * 
 * # class to store element class lookup functions
 * cdef public class ElementClassLookup [ type LxmlElementClassLookupType,             # <<<<<<<<<<<<<<
 *                                        object LxmlElementClassLookup ]:
 *     u"""ElementClassLookup(self)
 */

struct LxmlElementClassLookup {
  PyObject_HEAD
  _element_class_lookup_function _lookup_function;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":79
 *         self._lookup_function = NULL # use default lookup
 * 
 * cdef public class FallbackElementClassLookup(ElementClassLookup) \             # <<<<<<<<<<<<<<
 *          [ type LxmlFallbackElementClassLookupType,
 *            object LxmlFallbackElementClassLookup ]:
 */

struct LxmlFallbackElementClassLookup {
  struct LxmlElementClassLookup __pyx_base;
  struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup *__pyx_vtab;
  struct LxmlElementClassLookup *fallback;
  _element_class_lookup_function _fallback_function;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":269
 * #  custom class lookup based on node type, namespace, name
 * 
 * cdef class CustomElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""CustomElementClassLookup(self, fallback=None)
 *     Element class lookup based on a subclass method.
 */

struct __pyx_obj_4lxml_5etree_CustomElementClassLookup {
  struct LxmlFallbackElementClassLookup __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":3
 * # read-only tree implementation
 * 
 * cdef class _ReadOnlyElementProxy:             # <<<<<<<<<<<<<<
 *     u"The main read-only Element proxy class (for internal use only!)."
 *     cdef bint _free_after_use
 */

struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *__pyx_vtab;
  int _free_after_use;
  xmlNode *_c_node;
  PyObject *_source_proxy;
  PyObject *_dependent_proxies;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":21
 *     """
 * 
 * cdef class CommentBase(_Comment):             # <<<<<<<<<<<<<<
 *     u"""All custom Comment classes must inherit from this one.
 * 
 */

struct __pyx_obj_4lxml_5etree_CommentBase {
  struct __pyx_obj_4lxml_5etree__Comment __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":31
 * # Base class for XSLT and XPath evaluation contexts: functions, namespaces, ...
 * 
 * cdef class _BaseContext:             # <<<<<<<<<<<<<<
 *     cdef xpath.xmlXPathContext* _xpathCtxt
 *     cdef _Document _doc
 */

struct __pyx_obj_4lxml_5etree__BaseContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__BaseContext *__pyx_vtab;
  xmlXPathContext *_xpathCtxt;
  struct LxmlDocument *_doc;
  PyObject *_extensions;
  PyObject *_namespaces;
  PyObject *_global_namespaces;
  PyObject *_utf_refs;
  PyObject *_function_cache;
  PyObject *_eval_context_dict;
  int _build_smart_strings;
  struct __pyx_obj_4lxml_5etree__TempStore *_temp_refs;
  struct __pyx_obj_4lxml_5etree__ExceptionContext *_exc;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":274
 * 
 * 
 * cdef class _XSLTContext(_BaseContext):             # <<<<<<<<<<<<<<
 *     cdef xslt.xsltTransformContext* _xsltCtxt
 *     cdef object _extension_elements
 */

struct __pyx_obj_4lxml_5etree__XSLTContext {
  struct __pyx_obj_4lxml_5etree__BaseContext __pyx_base;
  xsltTransformContext *_xsltCtxt;
  PyObject *_extension_elements;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *_extension_element_proxy;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":3
 * # XSLT extension elements
 * 
 * cdef class XSLTExtension:             # <<<<<<<<<<<<<<
 *     u"""Base class of an XSLT extension element.
 *     """
 */

struct __pyx_obj_4lxml_5etree_XSLTExtension {
  PyObject_HEAD
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":213
 * 
 * # class for temporarily storing exceptions raised in extensions
 * cdef class _ExceptionContext:             # <<<<<<<<<<<<<<
 *     cdef object _exc_info
 *     cdef void clear(self):
 */

struct __pyx_obj_4lxml_5etree__ExceptionContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *__pyx_vtab;
  PyObject *_exc_info;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":142
 *         return repr(self._resolvers)
 * 
 * cdef class _ResolverContext(_ExceptionContext):             # <<<<<<<<<<<<<<
 *     cdef _ResolverRegistry _resolvers
 *     cdef _TempStore _storage
 */

struct __pyx_obj_4lxml_5etree__ResolverContext {
  struct __pyx_obj_4lxml_5etree__ExceptionContext __pyx_base;
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *_resolvers;
  struct __pyx_obj_4lxml_5etree__TempStore *_storage;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":6
 * cimport htmlparser
 * 
 * cdef class _ParserContext(_ResolverContext)             # <<<<<<<<<<<<<<
 * cdef class _SaxParserContext(_ParserContext)
 * cdef class _TargetParserContext(_SaxParserContext)
 */

struct __pyx_obj_4lxml_5etree__ParserContext {
  struct __pyx_obj_4lxml_5etree__ResolverContext __pyx_base;
  struct __pyx_obj_4lxml_5etree__ErrorLog *_error_log;
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *_validator;
  xmlParserCtxt *_c_ctxt;
  PyThread_type_lock _lock;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":7
 * 
 * cdef class _ParserContext(_ResolverContext)
 * cdef class _SaxParserContext(_ParserContext)             # <<<<<<<<<<<<<<
 * cdef class _TargetParserContext(_SaxParserContext)
 * cdef class _ParserSchemaValidationContext
 */

struct __pyx_obj_4lxml_5etree__SaxParserContext {
  struct __pyx_obj_4lxml_5etree__ParserContext __pyx_base;
  struct __pyx_obj_4lxml_5etree__SaxParserTarget *_target;
  startElementNsSAX2Func _origSaxStart;
  endElementNsSAX2Func _origSaxEnd;
  startElementSAXFunc _origSaxStartNoNs;
  endElementSAXFunc _origSaxEndNoNs;
  charactersSAXFunc _origSaxData;
  cdataBlockSAXFunc _origSaxCData;
  internalSubsetSAXFunc _origSaxDoctype;
  commentSAXFunc _origSaxComment;
  processingInstructionSAXFunc _origSaxPi;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":8
 * cdef class _ParserContext(_ResolverContext)
 * cdef class _SaxParserContext(_ParserContext)
 * cdef class _TargetParserContext(_SaxParserContext)             # <<<<<<<<<<<<<<
 * cdef class _ParserSchemaValidationContext
 * cdef class _Validator
 */

struct __pyx_obj_4lxml_5etree__TargetParserContext {
  struct __pyx_obj_4lxml_5etree__SaxParserContext __pyx_base;
  PyObject *_python_target;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":15
 *     cdef object _file
 * 
 * cdef class Resolver:             # <<<<<<<<<<<<<<
 *     u"This is the base class of all resolvers."
 *     def resolve(self, system_url, public_id, context):
 */

struct __pyx_obj_4lxml_5etree_Resolver {
  PyObject_HEAD
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1494
 * 
 * 
 * cdef public class _ElementTree [ type LxmlElementTreeType,             # <<<<<<<<<<<<<<
 *                                  object LxmlElementTree ]:
 *     cdef _Document _doc
 */

struct LxmlElementTree {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ElementTree *__pyx_vtab;
  struct LxmlDocument *_doc;
  struct LxmlElement *_context_node;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":627
 *     return new_xslt
 * 
 * cdef class _XSLTResultTree(_ElementTree):             # <<<<<<<<<<<<<<
 *     cdef XSLT _xslt
 *     cdef _Document _profile
 */

struct __pyx_obj_4lxml_5etree__XSLTResultTree {
  struct LxmlElementTree __pyx_base;
  struct __pyx_obj_4lxml_5etree_XSLT *_xslt;
  struct LxmlDocument *_profile;
  char *_buffer;
  Py_ssize_t _buffer_len;
  Py_ssize_t _buffer_refcnt;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1467
 *             return u"<?%s?>" % self.target
 * 
 * cdef class _Entity(__ContentOnlyElement):             # <<<<<<<<<<<<<<
 *     property tag:
 *         def __get__(self):
 */

struct __pyx_obj_4lxml_5etree__Entity {
  struct __pyx_obj_4lxml_5etree___ContentOnlyElement __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":49
 *     """
 * 
 * cdef class EntityBase(_Entity):             # <<<<<<<<<<<<<<
 *     u"""All custom Entity classes must inherit from this one.
 * 
 */

struct __pyx_obj_4lxml_5etree_EntityBase {
  struct __pyx_obj_4lxml_5etree__Entity __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":10
 *     pass
 * 
 * cdef class XInclude:             # <<<<<<<<<<<<<<
 *     u"""XInclude(self)
 *     XInclude processor.
 */

struct __pyx_obj_4lxml_5etree_XInclude {
  PyObject_HEAD
  struct __pyx_obj_4lxml_5etree__ErrorLog *_error_log;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":280
 * 
 * 
 * cdef public class _Document [ type LxmlDocumentType, object LxmlDocument ]:             # <<<<<<<<<<<<<<
 *     u"""Internal base class to reference a libxml document.
 * 
 */

struct LxmlDocument {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__Document *__pyx_vtab;
  int _ns_counter;
  PyObject *_prefix_tail;
  xmlDoc *_c_doc;
  struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":9
 *     PARSER_DATA_FILE
 * 
 * cdef class _InputDocument:             # <<<<<<<<<<<<<<
 *     cdef _InputDocumentDataType _type
 *     cdef object _data_bytes
 */

struct __pyx_obj_4lxml_5etree__InputDocument {
  PyObject_HEAD
  __pyx_t_4lxml_5etree__InputDocumentDataType _type;
  PyObject *_data_bytes;
  PyObject *_filename;
  PyObject *_file;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1445
 *         return u"<!--%s-->" % self.text
 * 
 * cdef class _ProcessingInstruction(__ContentOnlyElement):             # <<<<<<<<<<<<<<
 *     property tag:
 *         def __get__(self):
 */

struct __pyx_obj_4lxml_5etree__ProcessingInstruction {
  struct __pyx_obj_4lxml_5etree___ContentOnlyElement __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":35
 *     """
 * 
 * cdef class PIBase(_ProcessingInstruction):             # <<<<<<<<<<<<<<
 *     u"""All custom Processing Instruction classes must inherit from this one.
 * 
 */

struct __pyx_obj_4lxml_5etree_PIBase {
  struct __pyx_obj_4lxml_5etree__ProcessingInstruction __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":784
 *     return __findStylesheetByID(doc, id=id)
 * 
 * cdef class _XSLTProcessingInstruction(PIBase):             # <<<<<<<<<<<<<<
 *     def parseXSL(self, parser=None):
 *         u"""Try to parse the stylesheet referenced by this PI and return an
 */

struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction {
  struct __pyx_obj_4lxml_5etree_PIBase __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":252
 * #  per-parser lookup scheme
 * 
 * cdef class ParserBasedElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""ParserBasedElementClassLookup(self, fallback=None)
 *     Element class lookup based on the XML parser.
 */

struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup {
  struct LxmlFallbackElementClassLookup __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":10
 * cdef class _TargetParserContext(_SaxParserContext)
 * cdef class _ParserSchemaValidationContext
 * cdef class _Validator             # <<<<<<<<<<<<<<
 * cdef class XMLSchema(_Validator)
 * 
 */

struct __pyx_obj_4lxml_5etree__Validator {
  PyObject_HEAD
  struct __pyx_obj_4lxml_5etree__ErrorLog *_error_log;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":22
 * # RelaxNG
 * 
 * cdef class RelaxNG(_Validator):             # <<<<<<<<<<<<<<
 *     u"""RelaxNG(self, etree=None, file=None)
 *     Turn a document into a Relax NG validator.
 */

struct __pyx_obj_4lxml_5etree_RelaxNG {
  struct __pyx_obj_4lxml_5etree__Validator __pyx_base;
  xmlRelaxNG *_c_schema;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":37
 * # Logging classes
 * 
 * cdef class _LogEntry:             # <<<<<<<<<<<<<<
 *     cdef readonly object domain
 *     cdef readonly object type
 */

struct __pyx_obj_4lxml_5etree__LogEntry {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__LogEntry *__pyx_vtab;
  PyObject *domain;
  PyObject *type;
  PyObject *level;
  PyObject *line;
  PyObject *column;
  PyObject *message;
  PyObject *filename;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":263
 * ############################################################
 * 
 * cdef class _FileReaderContext:             # <<<<<<<<<<<<<<
 *     cdef object _filelike
 *     cdef object _encoding
 */

struct __pyx_obj_4lxml_5etree__FileReaderContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *__pyx_vtab;
  PyObject *_filelike;
  PyObject *_encoding;
  PyObject *_url;
  PyObject *_bytes;
  struct __pyx_obj_4lxml_5etree__ExceptionContext *_exc_context;
  Py_ssize_t _bytes_read;
  char *_c_url;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":13
 *         self.result = result
 * 
 * cdef class _PythonSaxParserTarget(_SaxParserTarget):             # <<<<<<<<<<<<<<
 *     cdef object _target_start
 *     cdef object _target_end
 */

struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget {
  struct __pyx_obj_4lxml_5etree__SaxParserTarget __pyx_base;
  PyObject *_target_start;
  PyObject *_target_end;
  PyObject *_target_data;
  PyObject *_target_doctype;
  PyObject *_target_pi;
  PyObject *_target_comment;
  int _start_takes_nsmap;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2302
 * PI = ProcessingInstruction
 * 
 * cdef class CDATA:             # <<<<<<<<<<<<<<
 *     u"""CDATA(data)
 * 
 */

struct __pyx_obj_4lxml_5etree_CDATA {
  PyObject_HEAD
  PyObject *_utf8_data;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":62
 *     return count
 * 
 * cdef class _IterparseContext(_ParserContext):             # <<<<<<<<<<<<<<
 *     cdef xmlparser.startElementNsSAX2Func _origSaxStart
 *     cdef xmlparser.endElementNsSAX2Func   _origSaxEnd
 */

struct __pyx_obj_4lxml_5etree__IterparseContext {
  struct __pyx_obj_4lxml_5etree__ParserContext __pyx_base;
  startElementNsSAX2Func _origSaxStart;
  endElementNsSAX2Func _origSaxEnd;
  startElementSAXFunc _origSaxStartNoNs;
  endElementSAXFunc _origSaxEndNoNs;
  commentSAXFunc _origSaxComment;
  processingInstructionSAXFunc _origSaxPI;
  struct LxmlElement *_root;
  struct LxmlDocument *_doc;
  int _event_filter;
  PyObject *_events;
  int _event_index;
  PyObject *_ns_stack;
  PyObject *_pop_ns;
  PyObject *_node_stack;
  PyObject *_pop_node;
  PyObject *_tag_tuple;
  char *_tag_href;
  char *_tag_name;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":180
 *         return message
 * 
 * cdef class _ListErrorLog(_BaseErrorLog):             # <<<<<<<<<<<<<<
 *     u"Immutable base version of a list based error log."
 *     cdef object _entries
 */

struct __pyx_obj_4lxml_5etree__ListErrorLog {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog __pyx_base;
  PyObject *_entries;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":300
 *         return self.filter_from_level(ErrorLevels.WARNING)
 * 
 * cdef class _ErrorLog(_ListErrorLog):             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         _ListErrorLog.__init__(self, [], None, None)
 */

struct __pyx_obj_4lxml_5etree__ErrorLog {
  struct __pyx_obj_4lxml_5etree__ListErrorLog __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":50
 * 
 * 
 * cdef class _XPathContext(_BaseContext):             # <<<<<<<<<<<<<<
 *     cdef object _variables
 *     def __init__(self, namespaces, extensions, enable_regexp, variables,
 */

struct __pyx_obj_4lxml_5etree__XPathContext {
  struct __pyx_obj_4lxml_5etree__BaseContext __pyx_base;
  PyObject *_variables;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2196
 *         return NULL
 * 
 * cdef class ElementTextIterator:             # <<<<<<<<<<<<<<
 *     u"""ElementTextIterator(self, element, tag=None, with_tail=True)
 *     Iterates over the text content of a subtree.
 */

struct __pyx_obj_4lxml_5etree_ElementTextIterator {
  PyObject_HEAD
  PyObject *_nextEvent;
  struct LxmlElement *_start_element;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2040
 *                 self._name = NULL
 * 
 * cdef public class _ElementIterator(_ElementTagMatcher) [             # <<<<<<<<<<<<<<
 *     object LxmlElementIterator, type LxmlElementIteratorType ]:
 *     # we keep Python references here to control GC
 */

struct LxmlElementIterator {
  struct LxmlElementTagMatcher __pyx_base;
  struct LxmlElement *_node;
  _node_to_node_function _next_element;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":6
 * # Custom Element classes
 * 
 * cdef public class ElementBase(_Element) [ type LxmlElementBaseType,             # <<<<<<<<<<<<<<
 *                                           object LxmlElementBase ]:
 *     u"""All custom Element classes must inherit from this one.
 */

struct LxmlElementBase {
  struct LxmlElement __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":351
 *         python.PyList_Append(entries, entry)
 * 
 * cdef class PyErrorLog(_BaseErrorLog):             # <<<<<<<<<<<<<<
 *     u"""PyErrorLog(self, logger_name=None)
 *     A global error log that connects to the Python stdlib logging package.
 */

struct __pyx_obj_4lxml_5etree_PyErrorLog {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog __pyx_base;
  PyObject *level_map;
  PyObject *_map_level;
  PyObject *_log;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":22
 * # DTD
 * 
 * cdef class DTD(_Validator):             # <<<<<<<<<<<<<<
 *     u"""DTD(self, file=None, external_id=None)
 *     A DTD validator.
 */

struct __pyx_obj_4lxml_5etree_DTD {
  struct __pyx_obj_4lxml_5etree__Validator __pyx_base;
  xmlDtd *_c_dtd;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":311
 *         return c_ctxt.node.next
 * 
 * cdef class iterparse(_BaseParser):             # <<<<<<<<<<<<<<
 *     u"""iterparse(self, source, events=("end",), tag=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, remove_blank_text=False, remove_comments=False, remove_pis=False, encoding=None, html=False, schema=None)
 * 
 */

struct __pyx_obj_4lxml_5etree_iterparse {
  struct __pyx_obj_4lxml_5etree__BaseParser __pyx_base;
  PyObject *_tag;
  PyObject *_events;
  PyObject *root;
  PyObject *_source;
  PyObject *_buffer;
  int (*_parse_chunk)(xmlParserCtxt *, char *, int, int);
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":50
 * # XSLT document loaders
 * 
 * cdef class _XSLTResolverContext(_ResolverContext):             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* _c_style_doc
 *     cdef _BaseParser _parser
 */

struct __pyx_obj_4lxml_5etree__XSLTResolverContext {
  struct __pyx_obj_4lxml_5etree__ResolverContext __pyx_base;
  xmlDoc *_c_style_doc;
  struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":40
 *     pass
 * 
 * cdef class _ParserDictionaryContext:             # <<<<<<<<<<<<<<
 *     # Global parser context to share the string dictionary.
 *     #
 */

struct __pyx_obj_4lxml_5etree__ParserDictionaryContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *__pyx_vtab;
  xmlDict *_c_dict;
  struct __pyx_obj_4lxml_5etree__BaseParser *_default_parser;
  PyObject *_implied_parser_contexts;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":523
 * 
 * 
 * cdef class iterwalk:             # <<<<<<<<<<<<<<
 *     u"""iterwalk(self, element_or_tree, events=("end",), tag=None)
 * 
 */

struct __pyx_obj_4lxml_5etree_iterwalk {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree_iterwalk *__pyx_vtab;
  PyObject *_node_stack;
  PyObject *_pop_node;
  int _index;
  PyObject *_events;
  PyObject *_pop_event;
  int _event_filter;
  PyObject *_tag_tuple;
  char *_tag_href;
  char *_tag_name;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":330
 *         python.PyList_Append(self._entries, entry)
 * 
 * cdef class _DomainErrorLog(_ErrorLog):             # <<<<<<<<<<<<<<
 *     def __init__(self, domains):
 *         _ErrorLog.__init__(self)
 */

struct __pyx_obj_4lxml_5etree__DomainErrorLog {
  struct __pyx_obj_4lxml_5etree__ErrorLog __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":202
 * # attribute based lookup scheme
 * 
 * cdef class AttributeBasedElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""AttributeBasedElementClassLookup(self, attribute_name, class_mapping, fallback=None)
 *     Checks an attribute of an Element and looks up the value in a
 */

struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup {
  struct LxmlFallbackElementClassLookup __pyx_base;
  PyObject *_class_mapping;
  PyObject *_pytag;
  char *_c_ns;
  char *_c_name;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":433
 * 
 * 
 * cdef class DocInfo:             # <<<<<<<<<<<<<<
 *     u"Document information provided by parser and DTD."
 *     cdef _Document _doc
 */

struct __pyx_obj_4lxml_5etree_DocInfo {
  PyObject_HEAD
  struct LxmlDocument *_doc;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":11
 * cdef class _ParserSchemaValidationContext
 * cdef class _Validator
 * cdef class XMLSchema(_Validator)             # <<<<<<<<<<<<<<
 * 
 * class ParseError(LxmlSyntaxError):
 */

struct __pyx_obj_4lxml_5etree_XMLSchema {
  struct __pyx_obj_4lxml_5etree__Validator __pyx_base;
  struct __pyx_vtabstruct_4lxml_5etree_XMLSchema *__pyx_vtab;
  xmlSchema *_c_schema;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2109
 *         self._storeNext(node)
 * 
 * cdef class AncestorsIterator(_ElementIterator):             # <<<<<<<<<<<<<<
 *     u"""AncestorsIterator(self, node, tag=None)
 *     Iterates over the ancestors of an element (from parent to parent).
 */

struct __pyx_obj_4lxml_5etree_AncestorsIterator {
  struct LxmlElementIterator __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":57
 *     return (_elementTreeFactory(doc, None), _IDDict(doc))
 * 
 * cdef class _IDDict:             # <<<<<<<<<<<<<<
 *     u"""IDDict(self, etree)
 *     A dictionary-like proxy class that mapps ID attributes to elements.
 */

struct __pyx_obj_4lxml_5etree__IDDict {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__IDDict *__pyx_vtab;
  struct LxmlDocument *_doc;
  PyObject *_keys;
  PyObject *_items;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":95
 * 
 * 
 * cdef class ElementNamespaceClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""ElementNamespaceClassLookup(self, fallback=None)
 * 
 */

struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup {
  struct LxmlFallbackElementClassLookup __pyx_base;
  PyObject *_namespace_registries;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":280
 *     del sourceProxy._dependent_proxies[:]
 * 
 * cdef class _AppendOnlyElementProxy(_ReadOnlyElementProxy):             # <<<<<<<<<<<<<<
 *     u"""A read-only element that allows adding children and changing the
 *     text content (i.e. everything that adds to the subtree).
 */

struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy {
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1845
 * 
 * 
 * cdef class _Attrib:             # <<<<<<<<<<<<<<
 *     u"""A dict-like proxy for the ``Element.attrib`` property.
 *     """
 */

struct __pyx_obj_4lxml_5etree__Attrib {
  PyObject_HEAD
  struct LxmlElement *_element;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":121
 * # default lookup scheme
 * 
 * cdef class ElementDefaultClassLookup(ElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""ElementDefaultClassLookup(self, element=None, comment=None, pi=None, entity=None)
 *     Element class lookup scheme that always returns the default Element
 */

struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup {
  struct LxmlElementClassLookup __pyx_base;
  PyObject *element_class;
  PyObject *comment_class;
  PyObject *pi_class;
  PyObject *entity_class;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":573
 * # special str/unicode subclasses
 * 
 * cdef class _ElementUnicodeResult(python.unicode):             # <<<<<<<<<<<<<<
 *     cdef _Element _parent
 *     cdef readonly object is_tail
 */

struct __pyx_obj_4lxml_5etree__ElementUnicodeResult {
  PyUnicodeObject __pyx_base;
  struct LxmlElement *_parent;
  PyObject *is_tail;
  PyObject *is_text;
  PyObject *is_attribute;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":26
 * 
 * ctypedef int (*_register_function)(void* ctxt, name_utf, ns_uri_utf)
 * cdef class _ExsltRegExp             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */

struct __pyx_obj_4lxml_5etree__ExsltRegExp {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *__pyx_vtab;
  PyObject *_compile_map;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":238
 * 
 * 
 * cdef class QName:             # <<<<<<<<<<<<<<
 *     u"""QName(text_or_uri, tag=None)
 * 
 */

struct __pyx_obj_4lxml_5etree_QName {
  PyObject_HEAD
  PyObject *text;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":199
 * 
 * # class for temporary storage of Python references
 * cdef class _TempStore:             # <<<<<<<<<<<<<<
 *     cdef object _storage
 *     def __init__(self):
 */

struct __pyx_obj_4lxml_5etree__TempStore {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__TempStore *__pyx_vtab;
  PyObject *_storage;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":264
 * # output to file-like objects
 * 
 * cdef class _FilelikeWriter:             # <<<<<<<<<<<<<<
 *     cdef object _filelike
 *     cdef _ExceptionContext _exc_context
 */

struct __pyx_obj_4lxml_5etree__FilelikeWriter {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter *__pyx_vtab;
  PyObject *_filelike;
  struct __pyx_obj_4lxml_5etree__ExceptionContext *_exc_context;
  struct __pyx_obj_4lxml_5etree__ErrorLog *error_log;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":22
 * # Schematron
 * 
 * cdef class Schematron(_Validator):             # <<<<<<<<<<<<<<
 *     u"""Schematron(self, etree=None, file=None)
 *     A Schematron validator.
 */

struct __pyx_obj_4lxml_5etree_Schematron {
  struct __pyx_obj_4lxml_5etree__Validator __pyx_base;
  xmlSchematron *_c_schema;
  xmlDoc *_c_schema_doc;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":172
 * # XSLT file/network access control
 * 
 * cdef class XSLTAccessControl:             # <<<<<<<<<<<<<<
 *     u"""XSLTAccessControl(self, read_file=True, write_file=True, create_dir=True, read_network=True, write_network=True)
 * 
 */

struct __pyx_obj_4lxml_5etree_XSLTAccessControl {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *__pyx_vtab;
  xsltSecurityPrefs *_prefs;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2095
 *             self._node = _elementFactory(node._doc, c_node)
 * 
 * cdef class SiblingsIterator(_ElementIterator):             # <<<<<<<<<<<<<<
 *     u"""SiblingsIterator(self, node, tag=None, preceding=False)
 *     Iterates over the siblings of an element.
 */

struct __pyx_obj_4lxml_5etree_SiblingsIterator {
  struct LxmlElementIterator __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1312
 *     )
 * 
 * cdef class HTMLParser(_FeedParser):             # <<<<<<<<<<<<<<
 *     u"""HTMLParser(self, recover=True, no_network=True, remove_blank_text=False, compact=True, remove_comments=False, remove_pis=False, target=None, encoding=None, schema=None)
 *     The HTML parser.
 */

struct __pyx_obj_4lxml_5etree_HTMLParser {
  struct __pyx_obj_4lxml_5etree__FeedParser __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":81
 *         python.PyDict_Clear(self._entries)
 * 
 * cdef class _ClassNamespaceRegistry(_NamespaceRegistry):             # <<<<<<<<<<<<<<
 *     u"Dictionary-like registry for namespace implementation classes"
 *     def __setitem__(self, name, item):
 */

struct __pyx_obj_4lxml_5etree__ClassNamespaceRegistry {
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":9
 * cdef class _SaxParserContext(_ParserContext)
 * cdef class _TargetParserContext(_SaxParserContext)
 * cdef class _ParserSchemaValidationContext             # <<<<<<<<<<<<<<
 * cdef class _Validator
 * cdef class XMLSchema(_Validator)
 */

struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *__pyx_vtab;
  struct __pyx_obj_4lxml_5etree_XMLSchema *_schema;
  xmlSchemaValidCtxt *_valid_ctxt;
  xmlSchemaSAXPlugStruct *_sax_plug;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1971
 *         return python.PyObject_RichCompare(one, other, op)
 * 
 * cdef class _AttribIterator:             # <<<<<<<<<<<<<<
 *     u"""Attribute iterator - for internal use only!
 *     """
 */

struct __pyx_obj_4lxml_5etree__AttribIterator {
  PyObject_HEAD
  struct LxmlElement *_node;
  xmlAttr *_c_attr;
  int _keysvalues;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":327
 * # read-only tree based class lookup
 * 
 * cdef class PythonElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""PythonElementClassLookup(self, fallback=None)
 *     Element class lookup based on a subclass method.
 */

struct __pyx_obj_4lxml_5etree_PythonElementClassLookup {
  struct LxmlFallbackElementClassLookup __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2072
 *         return current_node
 * 
 * cdef class ElementChildIterator(_ElementIterator):             # <<<<<<<<<<<<<<
 *     u"""ElementChildIterator(self, node, tag=None, reversed=False)
 *     Iterates over the children of an element.
 */

struct __pyx_obj_4lxml_5etree_ElementChildIterator {
  struct LxmlElementIterator __pyx_base;
};

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":339
 *             _ErrorLog.receive(self, entry)
 * 
 * cdef class _RotatingErrorLog(_ErrorLog):             # <<<<<<<<<<<<<<
 *     cdef int _max_len
 *     def __init__(self, max_len):
 */

struct __pyx_obj_4lxml_5etree__RotatingErrorLog {
  struct __pyx_obj_4lxml_5etree__ErrorLog __pyx_base;
  int _max_len;
};


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":95
 *         return doc_ref
 * 
 * cdef class _ResolverRegistry:             # <<<<<<<<<<<<<<
 *     cdef object _resolvers
 *     cdef Resolver _default_resolver
 */

struct __pyx_vtabstruct_4lxml_5etree__ResolverRegistry {
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *(*_copy)(struct __pyx_obj_4lxml_5etree__ResolverRegistry *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ResolverRegistry *__pyx_vtabptr_4lxml_5etree__ResolverRegistry;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":213
 * 
 * # class for temporarily storing exceptions raised in extensions
 * cdef class _ExceptionContext:             # <<<<<<<<<<<<<<
 *     cdef object _exc_info
 *     cdef void clear(self):
 */

struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext {
  void (*clear)(struct __pyx_obj_4lxml_5etree__ExceptionContext *);
  void (*_store_raised)(struct __pyx_obj_4lxml_5etree__ExceptionContext *);
  void (*_store_exception)(struct __pyx_obj_4lxml_5etree__ExceptionContext *, PyObject *);
  int (*_has_raised)(struct __pyx_obj_4lxml_5etree__ExceptionContext *);
  int (*_raise_if_stored)(struct __pyx_obj_4lxml_5etree__ExceptionContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *__pyx_vtabptr_4lxml_5etree__ExceptionContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":142
 *         return repr(self._resolvers)
 * 
 * cdef class _ResolverContext(_ExceptionContext):             # <<<<<<<<<<<<<<
 *     cdef _ResolverRegistry _resolvers
 *     cdef _TempStore _storage
 */

struct __pyx_vtabstruct_4lxml_5etree__ResolverContext {
  struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__ResolverContext *__pyx_vtabptr_4lxml_5etree__ResolverContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":671
 *     return 0
 * 
 * cdef class _BaseParser:             # <<<<<<<<<<<<<<
 *     cdef ElementClassLookup _class_lookup
 *     cdef _ResolverRegistry _resolvers
 */

struct __pyx_vtabstruct_4lxml_5etree__BaseParser {
  struct __pyx_obj_4lxml_5etree__ParserContext *(*_getParserContext)(struct __pyx_obj_4lxml_5etree__BaseParser *);
  struct __pyx_obj_4lxml_5etree__ParserContext *(*_getPushParserContext)(struct __pyx_obj_4lxml_5etree__BaseParser *);
  struct __pyx_obj_4lxml_5etree__ParserContext *(*_createContext)(struct __pyx_obj_4lxml_5etree__BaseParser *, PyObject *);
  xmlParserCtxt *(*_newParserCtxt)(struct __pyx_obj_4lxml_5etree__BaseParser *);
  xmlParserCtxt *(*_newPushParserCtxt)(struct __pyx_obj_4lxml_5etree__BaseParser *);
  struct __pyx_obj_4lxml_5etree__BaseParser *(*_copy)(struct __pyx_obj_4lxml_5etree__BaseParser *);
  xmlDoc *(*_parseUnicodeDoc)(struct __pyx_obj_4lxml_5etree__BaseParser *, PyObject *, char *);
  xmlDoc *(*_parseDoc)(struct __pyx_obj_4lxml_5etree__BaseParser *, char *, Py_ssize_t, char *);
  xmlDoc *(*_parseDocFromFile)(struct __pyx_obj_4lxml_5etree__BaseParser *, char *);
  xmlDoc *(*_parseDocFromFilelike)(struct __pyx_obj_4lxml_5etree__BaseParser *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__BaseParser *__pyx_vtabptr_4lxml_5etree__BaseParser;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":999
 * ############################################################
 * 
 * cdef class _FeedParser(_BaseParser):             # <<<<<<<<<<<<<<
 *     cdef bint _feed_parser_running
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree__FeedParser {
  struct __pyx_vtabstruct_4lxml_5etree__BaseParser __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__FeedParser *__pyx_vtabptr_4lxml_5etree__FeedParser;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1169
 *     )
 * 
 * cdef class XMLParser(_FeedParser):             # <<<<<<<<<<<<<<
 *     u"""XMLParser(self, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, remove_blank_text=False, compact=True, resolve_entities=True, remove_comments=False, remove_pis=False, target=None, encoding=None, schema=None)
 *     The XML parser.
 */

struct __pyx_vtabstruct_4lxml_5etree_XMLParser {
  struct __pyx_vtabstruct_4lxml_5etree__FeedParser __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_XMLParser *__pyx_vtabptr_4lxml_5etree_XMLParser;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlElementTagMatcherType;

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2012
 * 
 * 
 * cdef public class _ElementTagMatcher [ object LxmlElementTagMatcher,             # <<<<<<<<<<<<<<
 *                                        type LxmlElementTagMatcherType ]:
 *     cdef object _pystrings
 */

struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher {
  PyObject *(*_initTagMatch)(struct LxmlElementTagMatcher *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher *__pyx_vtabptr_4lxml_5etree__ElementTagMatcher;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1368
 * 
 * 
 * cdef class __ContentOnlyElement(_Element):             # <<<<<<<<<<<<<<
 *     cdef int _raiseImmutable(self) except -1:
 *         raise TypeError, u"this element does not have children or attributes"
 */

struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement {
  int (*_raiseImmutable)(struct __pyx_obj_4lxml_5etree___ContentOnlyElement *);
};
static struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement *__pyx_vtabptr_4lxml_5etree___ContentOnlyElement;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1467
 *             return u"<?%s?>" % self.target
 * 
 * cdef class _Entity(__ContentOnlyElement):             # <<<<<<<<<<<<<<
 *     property tag:
 *         def __get__(self):
 */

struct __pyx_vtabstruct_4lxml_5etree__Entity {
  struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__Entity *__pyx_vtabptr_4lxml_5etree__Entity;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":49
 *     """
 * 
 * cdef class EntityBase(_Entity):             # <<<<<<<<<<<<<<
 *     u"""All custom Entity classes must inherit from this one.
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_EntityBase {
  struct __pyx_vtabstruct_4lxml_5etree__Entity __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_EntityBase *__pyx_vtabptr_4lxml_5etree_EntityBase;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":31
 * # Base class for XSLT and XPath evaluation contexts: functions, namespaces, ...
 * 
 * cdef class _BaseContext:             # <<<<<<<<<<<<<<
 *     cdef xpath.xmlXPathContext* _xpathCtxt
 *     cdef _Document _doc
 */

struct __pyx_vtabstruct_4lxml_5etree__BaseContext {
  struct __pyx_obj_4lxml_5etree__BaseContext *(*_copy)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  PyObject *(*_to_utf)(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *);
  void (*_set_xpath_context)(struct __pyx_obj_4lxml_5etree__BaseContext *, xmlXPathContext *);
  PyObject *(*_register_context)(struct __pyx_obj_4lxml_5etree__BaseContext *, struct LxmlDocument *);
  PyObject *(*_cleanup_context)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  PyObject *(*_release_context)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  PyObject *(*addNamespace)(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *, PyObject *);
  PyObject *(*registerNamespace)(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *, PyObject *);
  PyObject *(*registerLocalNamespaces)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  PyObject *(*registerGlobalNamespaces)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  PyObject *(*unregisterGlobalNamespaces)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  void (*_unregisterNamespace)(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *);
  void (*_addLocalExtensionFunction)(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *, PyObject *, PyObject *);
  void (*registerGlobalFunctions)(struct __pyx_obj_4lxml_5etree__BaseContext *, void *, __pyx_t_4lxml_5etree__register_function);
  void (*registerLocalFunctions)(struct __pyx_obj_4lxml_5etree__BaseContext *, void *, __pyx_t_4lxml_5etree__register_function);
  PyObject *(*unregisterAllFunctions)(struct __pyx_obj_4lxml_5etree__BaseContext *, void *, __pyx_t_4lxml_5etree__register_function);
  PyObject *(*unregisterGlobalFunctions)(struct __pyx_obj_4lxml_5etree__BaseContext *, void *, __pyx_t_4lxml_5etree__register_function);
  PyObject *(*_find_cached_function)(struct __pyx_obj_4lxml_5etree__BaseContext *, char *, char *);
  PyObject *(*_release_temp_refs)(struct __pyx_obj_4lxml_5etree__BaseContext *);
  PyObject *(*_hold)(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__BaseContext *__pyx_vtabptr_4lxml_5etree__BaseContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":50
 * 
 * 
 * cdef class _XPathContext(_BaseContext):             # <<<<<<<<<<<<<<
 *     cdef object _variables
 *     def __init__(self, namespaces, extensions, enable_regexp, variables,
 */

struct __pyx_vtabstruct_4lxml_5etree__XPathContext {
  struct __pyx_vtabstruct_4lxml_5etree__BaseContext __pyx_base;
  PyObject *(*set_context)(struct __pyx_obj_4lxml_5etree__XPathContext *, xmlXPathContext *);
  PyObject *(*register_context)(struct __pyx_obj_4lxml_5etree__XPathContext *, struct LxmlDocument *);
  PyObject *(*unregister_context)(struct __pyx_obj_4lxml_5etree__XPathContext *);
  PyObject *(*registerVariables)(struct __pyx_obj_4lxml_5etree__XPathContext *, PyObject *);
  PyObject *(*registerVariable)(struct __pyx_obj_4lxml_5etree__XPathContext *, PyObject *, PyObject *);
  void (*_registerVariable)(struct __pyx_obj_4lxml_5etree__XPathContext *, PyObject *, PyObject *);
  void (*_setupDict)(struct __pyx_obj_4lxml_5etree__XPathContext *, xmlXPathContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__XPathContext *__pyx_vtabptr_4lxml_5etree__XPathContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":22
 * # XMLSchema
 * 
 * cdef class XMLSchema(_Validator):             # <<<<<<<<<<<<<<
 *     u"""XMLSchema(self, etree=None, file=None)
 *     Turn a document into an XML Schema validator.
 */

struct __pyx_vtabstruct_4lxml_5etree_XMLSchema {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *(*_newSaxValidator)(struct __pyx_obj_4lxml_5etree_XMLSchema *);
};
static struct __pyx_vtabstruct_4lxml_5etree_XMLSchema *__pyx_vtabptr_4lxml_5etree_XMLSchema;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":523
 * 
 * 
 * cdef class iterwalk:             # <<<<<<<<<<<<<<
 *     u"""iterwalk(self, element_or_tree, events=("end",), tag=None)
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_iterwalk {
  void (*_setTagFilter)(struct __pyx_obj_4lxml_5etree_iterwalk *, PyObject *);
  int (*_start_node)(struct __pyx_obj_4lxml_5etree_iterwalk *, struct LxmlElement *);
  struct LxmlElement *(*_end_node)(struct __pyx_obj_4lxml_5etree_iterwalk *);
};
static struct __pyx_vtabstruct_4lxml_5etree_iterwalk *__pyx_vtabptr_4lxml_5etree_iterwalk;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlFallbackElementClassLookupType;

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":79
 *         self._lookup_function = NULL # use default lookup
 * 
 * cdef public class FallbackElementClassLookup(ElementClassLookup) \             # <<<<<<<<<<<<<<
 *          [ type LxmlFallbackElementClassLookupType,
 *            object LxmlFallbackElementClassLookup ]:
 */

struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup {
  void (*_setFallback)(struct LxmlFallbackElementClassLookup *, struct LxmlElementClassLookup *);
};
static struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup *__pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":202
 * # attribute based lookup scheme
 * 
 * cdef class AttributeBasedElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""AttributeBasedElementClassLookup(self, attribute_name, class_mapping, fallback=None)
 *     Checks an attribute of an Element and looks up the value in a
 */

struct __pyx_vtabstruct_4lxml_5etree_AttributeBasedElementClassLookup {
  struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_AttributeBasedElementClassLookup *__pyx_vtabptr_4lxml_5etree_AttributeBasedElementClassLookup;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":97
 *             return ErrorLevels._getName(self.level, u"unknown")
 * 
 * cdef class _BaseErrorLog:             # <<<<<<<<<<<<<<
 *     cdef _LogEntry _first_error
 *     cdef readonly object last_error
 */

struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog {
  void (*_receive)(struct __pyx_obj_4lxml_5etree__BaseErrorLog *, xmlError *);
  void (*_receiveGeneric)(struct __pyx_obj_4lxml_5etree__BaseErrorLog *, int, int, int, int, PyObject *, PyObject *);
  PyObject *(*_buildParseException)(struct __pyx_obj_4lxml_5etree__BaseErrorLog *, PyObject *, PyObject *);
  PyObject *(*_buildExceptionMessage)(struct __pyx_obj_4lxml_5etree__BaseErrorLog *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog *__pyx_vtabptr_4lxml_5etree__BaseErrorLog;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":180
 *         return message
 * 
 * cdef class _ListErrorLog(_BaseErrorLog):             # <<<<<<<<<<<<<<
 *     u"Immutable base version of a list based error log."
 *     cdef object _entries
 */

struct __pyx_vtabstruct_4lxml_5etree__ListErrorLog {
  struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__ListErrorLog *__pyx_vtabptr_4lxml_5etree__ListErrorLog;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":300
 *         return self.filter_from_level(ErrorLevels.WARNING)
 * 
 * cdef class _ErrorLog(_ListErrorLog):             # <<<<<<<<<<<<<<
 *     def __init__(self):
 *         _ListErrorLog.__init__(self, [], None, None)
 */

struct __pyx_vtabstruct_4lxml_5etree__ErrorLog {
  struct __pyx_vtabstruct_4lxml_5etree__ListErrorLog __pyx_base;
  void (*connect)(struct __pyx_obj_4lxml_5etree__ErrorLog *);
  void (*disconnect)(struct __pyx_obj_4lxml_5etree__ErrorLog *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *__pyx_vtabptr_4lxml_5etree__ErrorLog;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":330
 *         python.PyList_Append(self._entries, entry)
 * 
 * cdef class _DomainErrorLog(_ErrorLog):             # <<<<<<<<<<<<<<
 *     def __init__(self, domains):
 *         _ErrorLog.__init__(self)
 */

struct __pyx_vtabstruct_4lxml_5etree__DomainErrorLog {
  struct __pyx_vtabstruct_4lxml_5etree__ErrorLog __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__DomainErrorLog *__pyx_vtabptr_4lxml_5etree__DomainErrorLog;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":311
 *         return c_ctxt.node.next
 * 
 * cdef class iterparse(_BaseParser):             # <<<<<<<<<<<<<<
 *     u"""iterparse(self, source, events=("end",), tag=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, remove_blank_text=False, remove_comments=False, remove_pis=False, encoding=None, html=False, schema=None)
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_iterparse {
  struct __pyx_vtabstruct_4lxml_5etree__BaseParser __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_iterparse *__pyx_vtabptr_4lxml_5etree_iterparse;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":263
 * ############################################################
 * 
 * cdef class _FileReaderContext:             # <<<<<<<<<<<<<<
 *     cdef object _filelike
 *     cdef object _encoding
 */

struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext {
  xmlParserInputBuffer *(*_createParserInputBuffer)(struct __pyx_obj_4lxml_5etree__FileReaderContext *);
  xmlParserInput *(*_createParserInput)(struct __pyx_obj_4lxml_5etree__FileReaderContext *, xmlParserCtxt *);
  xmlDtd *(*_readDtd)(struct __pyx_obj_4lxml_5etree__FileReaderContext *);
  xmlDoc *(*_readDoc)(struct __pyx_obj_4lxml_5etree__FileReaderContext *, xmlParserCtxt *, int);
  int (*copyToBuffer)(struct __pyx_obj_4lxml_5etree__FileReaderContext *, char *, int);
};
static struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *__pyx_vtabptr_4lxml_5etree__FileReaderContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":11
 *     SAX_EVENT_COMMENT = 32
 * 
 * cdef class _SaxParserTarget:             # <<<<<<<<<<<<<<
 *     cdef int _sax_event_filter
 *     cdef int _sax_event_propagate
 */

struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget {
  PyObject *(*_handleSaxStart)(struct __pyx_obj_4lxml_5etree__SaxParserTarget *, PyObject *, PyObject *, PyObject *);
  PyObject *(*_handleSaxEnd)(struct __pyx_obj_4lxml_5etree__SaxParserTarget *, PyObject *);
  int (*_handleSaxData)(struct __pyx_obj_4lxml_5etree__SaxParserTarget *, PyObject *);
  int (*_handleSaxDoctype)(struct __pyx_obj_4lxml_5etree__SaxParserTarget *, PyObject *, PyObject *, PyObject *);
  PyObject *(*_handleSaxPi)(struct __pyx_obj_4lxml_5etree__SaxParserTarget *, PyObject *, PyObject *);
  PyObject *(*_handleSaxComment)(struct __pyx_obj_4lxml_5etree__SaxParserTarget *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *__pyx_vtabptr_4lxml_5etree__SaxParserTarget;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":331
 * ############################################################
 * 
 * cdef class TreeBuilder(_SaxParserTarget):             # <<<<<<<<<<<<<<
 *     u"""TreeBuilder(self, element_factory=None, parser=None)
 *     Parser target that builds a tree.
 */

struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder {
  struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget __pyx_base;
  int (*_flush)(struct __pyx_obj_4lxml_5etree_TreeBuilder *);
};
static struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *__pyx_vtabptr_4lxml_5etree_TreeBuilder;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1437
 *         return []
 * 
 * cdef class _Comment(__ContentOnlyElement):             # <<<<<<<<<<<<<<
 *     property tag:
 *         def __get__(self):
 */

struct __pyx_vtabstruct_4lxml_5etree__Comment {
  struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__Comment *__pyx_vtabptr_4lxml_5etree__Comment;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":50
 * # XSLT document loaders
 * 
 * cdef class _XSLTResolverContext(_ResolverContext):             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* _c_style_doc
 *     cdef _BaseParser _parser
 */

struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext {
  struct __pyx_vtabstruct_4lxml_5etree__ResolverContext __pyx_base;
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *(*_copy)(struct __pyx_obj_4lxml_5etree__XSLTResolverContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *__pyx_vtabptr_4lxml_5etree__XSLTResolverContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":199
 * 
 * # class for temporary storage of Python references
 * cdef class _TempStore:             # <<<<<<<<<<<<<<
 *     cdef object _storage
 *     def __init__(self):
 */

struct __pyx_vtabstruct_4lxml_5etree__TempStore {
  int (*add)(struct __pyx_obj_4lxml_5etree__TempStore *, PyObject *);
  int (*clear)(struct __pyx_obj_4lxml_5etree__TempStore *);
};
static struct __pyx_vtabstruct_4lxml_5etree__TempStore *__pyx_vtabptr_4lxml_5etree__TempStore;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlElementIteratorType;

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2040
 *                 self._name = NULL
 * 
 * cdef public class _ElementIterator(_ElementTagMatcher) [             # <<<<<<<<<<<<<<
 *     object LxmlElementIterator, type LxmlElementIteratorType ]:
 *     # we keep Python references here to control GC
 */

struct __pyx_vtabstruct_4lxml_5etree__ElementIterator {
  struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher __pyx_base;
  void (*_storeNext)(struct LxmlElementIterator *, struct LxmlElement *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ElementIterator *__pyx_vtabptr_4lxml_5etree__ElementIterator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2095
 *             self._node = _elementFactory(node._doc, c_node)
 * 
 * cdef class SiblingsIterator(_ElementIterator):             # <<<<<<<<<<<<<<
 *     u"""SiblingsIterator(self, node, tag=None, preceding=False)
 *     Iterates over the siblings of an element.
 */

struct __pyx_vtabstruct_4lxml_5etree_SiblingsIterator {
  struct __pyx_vtabstruct_4lxml_5etree__ElementIterator __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_SiblingsIterator *__pyx_vtabptr_4lxml_5etree_SiblingsIterator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":264
 * # output to file-like objects
 * 
 * cdef class _FilelikeWriter:             # <<<<<<<<<<<<<<
 *     cdef object _filelike
 *     cdef _ExceptionContext _exc_context
 */

struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter {
  xmlOutputBuffer *(*_createOutputBuffer)(struct __pyx_obj_4lxml_5etree__FilelikeWriter *, xmlCharEncodingHandler *);
  int (*write)(struct __pyx_obj_4lxml_5etree__FilelikeWriter *, char *, int);
  int (*close)(struct __pyx_obj_4lxml_5etree__FilelikeWriter *);
};
static struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter *__pyx_vtabptr_4lxml_5etree__FilelikeWriter;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1445
 *         return u"<!--%s-->" % self.text
 * 
 * cdef class _ProcessingInstruction(__ContentOnlyElement):             # <<<<<<<<<<<<<<
 *     property tag:
 *         def __get__(self):
 */

struct __pyx_vtabstruct_4lxml_5etree__ProcessingInstruction {
  struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__ProcessingInstruction *__pyx_vtabptr_4lxml_5etree__ProcessingInstruction;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":35
 *     """
 * 
 * cdef class PIBase(_ProcessingInstruction):             # <<<<<<<<<<<<<<
 *     u"""All custom Processing Instruction classes must inherit from this one.
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_PIBase {
  struct __pyx_vtabstruct_4lxml_5etree__ProcessingInstruction __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_PIBase *__pyx_vtabptr_4lxml_5etree_PIBase;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":274
 * 
 * 
 * cdef class _XSLTContext(_BaseContext):             # <<<<<<<<<<<<<<
 *     cdef xslt.xsltTransformContext* _xsltCtxt
 *     cdef object _extension_elements
 */

struct __pyx_vtabstruct_4lxml_5etree__XSLTContext {
  struct __pyx_vtabstruct_4lxml_5etree__BaseContext __pyx_base;
  PyObject *(*register_context)(struct __pyx_obj_4lxml_5etree__XSLTContext *, xsltTransformContext *, struct LxmlDocument *);
  PyObject *(*free_context)(struct __pyx_obj_4lxml_5etree__XSLTContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *__pyx_vtabptr_4lxml_5etree__XSLTContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":324
 * 
 * 
 * cdef class XSLT:             # <<<<<<<<<<<<<<
 *     u"""XSLT(self, xslt_input, extensions=None, regexp=True, access_control=None)
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_XSLT {
  xmlDoc *(*_run_transform)(struct __pyx_obj_4lxml_5etree_XSLT *, xmlDoc *, PyObject *, struct __pyx_obj_4lxml_5etree__XSLTContext *, xsltTransformContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree_XSLT *__pyx_vtabptr_4lxml_5etree_XSLT;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":339
 *             _ErrorLog.receive(self, entry)
 * 
 * cdef class _RotatingErrorLog(_ErrorLog):             # <<<<<<<<<<<<<<
 *     cdef int _max_len
 *     def __init__(self, max_len):
 */

struct __pyx_vtabstruct_4lxml_5etree__RotatingErrorLog {
  struct __pyx_vtabstruct_4lxml_5etree__ErrorLog __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__RotatingErrorLog *__pyx_vtabptr_4lxml_5etree__RotatingErrorLog;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":13
 *         self.result = result
 * 
 * cdef class _PythonSaxParserTarget(_SaxParserTarget):             # <<<<<<<<<<<<<<
 *     cdef object _target_start
 *     cdef object _target_end
 */

struct __pyx_vtabstruct_4lxml_5etree__PythonSaxParserTarget {
  struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__PythonSaxParserTarget *__pyx_vtabptr_4lxml_5etree__PythonSaxParserTarget;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":14
 * 
 * 
 * cdef class _NamespaceRegistry:             # <<<<<<<<<<<<<<
 *     u"Dictionary-like namespace registry"
 *     cdef object _ns_uri
 */

struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry {
  PyObject *(*_get)(struct __pyx_obj_4lxml_5etree__NamespaceRegistry *, PyObject *);
  PyObject *(*_getForString)(struct __pyx_obj_4lxml_5etree__NamespaceRegistry *, char *);
};
static struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry *__pyx_vtabptr_4lxml_5etree__NamespaceRegistry;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":186
 *         return registry
 * 
 * cdef class _FunctionNamespaceRegistry(_NamespaceRegistry):             # <<<<<<<<<<<<<<
 *     def __setitem__(self, name, item):
 *         if not callable(item):
 */

struct __pyx_vtabstruct_4lxml_5etree__FunctionNamespaceRegistry {
  struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__FunctionNamespaceRegistry *__pyx_vtabptr_4lxml_5etree__FunctionNamespaceRegistry;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":37
 * # Logging classes
 * 
 * cdef class _LogEntry:             # <<<<<<<<<<<<<<
 *     cdef readonly object domain
 *     cdef readonly object type
 */

struct __pyx_vtabstruct_4lxml_5etree__LogEntry {
  PyObject *(*_setError)(struct __pyx_obj_4lxml_5etree__LogEntry *, xmlError *);
  PyObject *(*_setGeneric)(struct __pyx_obj_4lxml_5etree__LogEntry *, int, int, int, int, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__LogEntry *__pyx_vtabptr_4lxml_5etree__LogEntry;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":473
 * ############################################################
 * 
 * cdef class _ParserContext(_ResolverContext):             # <<<<<<<<<<<<<<
 *     cdef _ErrorLog _error_log
 *     cdef _ParserSchemaValidationContext _validator
 */

struct __pyx_vtabstruct_4lxml_5etree__ParserContext {
  struct __pyx_vtabstruct_4lxml_5etree__ResolverContext __pyx_base;
  struct __pyx_obj_4lxml_5etree__ParserContext *(*_copy)(struct __pyx_obj_4lxml_5etree__ParserContext *);
  void (*_initParserContext)(struct __pyx_obj_4lxml_5etree__ParserContext *, xmlParserCtxt *);
  void (*_resetParserContext)(struct __pyx_obj_4lxml_5etree__ParserContext *);
  int (*prepare)(struct __pyx_obj_4lxml_5etree__ParserContext *);
  int (*cleanup)(struct __pyx_obj_4lxml_5etree__ParserContext *);
  PyObject *(*_handleParseResult)(struct __pyx_obj_4lxml_5etree__ParserContext *, struct __pyx_obj_4lxml_5etree__BaseParser *, xmlDoc *, PyObject *);
  xmlDoc *(*_handleParseResultDoc)(struct __pyx_obj_4lxml_5etree__ParserContext *, struct __pyx_obj_4lxml_5etree__BaseParser *, xmlDoc *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ParserContext *__pyx_vtabptr_4lxml_5etree__ParserContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":102
 *     _XPATH_VERSION_WARNING_REQUIRED = 0
 * 
 * cdef class _XPathEvaluatorBase:             # <<<<<<<<<<<<<<
 *     cdef xpath.xmlXPathContext* _xpathCtxt
 *     cdef _XPathContext _context
 */

struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase {
  PyObject *(*set_context)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *, xmlXPathContext *);
  int (*_checkAbsolutePath)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *, char *);
  int (*_lock)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *);
  void (*_unlock)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *);
  PyObject *(*_raise_parse_error)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *);
  PyObject *(*_raise_eval_error)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *);
  PyObject *(*_handle_result)(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *, xmlXPathObject *, struct LxmlDocument *);
};
static struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase *__pyx_vtabptr_4lxml_5etree__XPathEvaluatorBase;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":217
 * 
 * 
 * cdef class XPathElementEvaluator(_XPathEvaluatorBase):             # <<<<<<<<<<<<<<
 *     u"""XPathElementEvaluator(self, element, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 *     Create an XPath evaluator for an element.
 */

struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator {
  struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator *__pyx_vtabptr_4lxml_5etree_XPathElementEvaluator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":21
 *     """
 * 
 * cdef class CommentBase(_Comment):             # <<<<<<<<<<<<<<
 *     u"""All custom Comment classes must inherit from this one.
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_CommentBase {
  struct __pyx_vtabstruct_4lxml_5etree__Comment __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_CommentBase *__pyx_vtabptr_4lxml_5etree_CommentBase;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":140
 *         return context
 * 
 * cdef class _ParserSchemaValidationContext:             # <<<<<<<<<<<<<<
 *     cdef XMLSchema _schema
 *     cdef xmlschema.xmlSchemaValidCtxt* _valid_ctxt
 */

struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *(*copy)(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *);
  int (*connect)(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *, xmlParserCtxt *);
  void (*disconnect)(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *);
  int (*isvalid)(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *__pyx_vtabptr_4lxml_5etree__ParserSchemaValidationContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2072
 *         return current_node
 * 
 * cdef class ElementChildIterator(_ElementIterator):             # <<<<<<<<<<<<<<
 *     u"""ElementChildIterator(self, node, tag=None, reversed=False)
 *     Iterates over the children of an element.
 */

struct __pyx_vtabstruct_4lxml_5etree_ElementChildIterator {
  struct __pyx_vtabstruct_4lxml_5etree__ElementIterator __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_ElementChildIterator *__pyx_vtabptr_4lxml_5etree_ElementChildIterator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":252
 * #  per-parser lookup scheme
 * 
 * cdef class ParserBasedElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""ParserBasedElementClassLookup(self, fallback=None)
 *     Element class lookup based on the XML parser.
 */

struct __pyx_vtabstruct_4lxml_5etree_ParserBasedElementClassLookup {
  struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_ParserBasedElementClassLookup *__pyx_vtabptr_4lxml_5etree_ParserBasedElementClassLookup;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":31
 *         return None
 * 
 * cdef class _SaxParserContext(_ParserContext):             # <<<<<<<<<<<<<<
 *     u"""This class maps SAX2 events to method calls.
 *     """
 */

struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext {
  struct __pyx_vtabstruct_4lxml_5etree__ParserContext __pyx_base;
  void (*_setSaxParserTarget)(struct __pyx_obj_4lxml_5etree__SaxParserContext *, struct __pyx_obj_4lxml_5etree__SaxParserTarget *);
  void (*_handleSaxException)(struct __pyx_obj_4lxml_5etree__SaxParserContext *, xmlParserCtxt *);
};
static struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *__pyx_vtabptr_4lxml_5etree__SaxParserContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":784
 *     return __findStylesheetByID(doc, id=id)
 * 
 * cdef class _XSLTProcessingInstruction(PIBase):             # <<<<<<<<<<<<<<
 *     def parseXSL(self, parser=None):
 *         u"""Try to parse the stylesheet referenced by this PI and return an
 */

struct __pyx_vtabstruct_4lxml_5etree__XSLTProcessingInstruction {
  struct __pyx_vtabstruct_4lxml_5etree_PIBase __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTProcessingInstruction *__pyx_vtabptr_4lxml_5etree__XSLTProcessingInstruction;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":62
 *     return count
 * 
 * cdef class _IterparseContext(_ParserContext):             # <<<<<<<<<<<<<<
 *     cdef xmlparser.startElementNsSAX2Func _origSaxStart
 *     cdef xmlparser.endElementNsSAX2Func   _origSaxEnd
 */

struct __pyx_vtabstruct_4lxml_5etree__IterparseContext {
  struct __pyx_vtabstruct_4lxml_5etree__ParserContext __pyx_base;
  PyObject *(*_setEventFilter)(struct __pyx_obj_4lxml_5etree__IterparseContext *, PyObject *, PyObject *);
  int (*startNode)(struct __pyx_obj_4lxml_5etree__IterparseContext *, xmlNode *);
  int (*endNode)(struct __pyx_obj_4lxml_5etree__IterparseContext *, xmlNode *);
  int (*pushEvent)(struct __pyx_obj_4lxml_5etree__IterparseContext *, PyObject *, xmlNode *);
  void (*_assureDocGetsFreed)(struct __pyx_obj_4lxml_5etree__IterparseContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *__pyx_vtabptr_4lxml_5etree__IterparseContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":372
 * 
 * 
 * cdef class XPath(_XPathEvaluatorBase):             # <<<<<<<<<<<<<<
 *     u"""XPath(self, path, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 *     A compiled XPath expression that can be called on Elements and ElementTrees.
 */

struct __pyx_vtabstruct_4lxml_5etree_XPath {
  struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_XPath *__pyx_vtabptr_4lxml_5etree_XPath;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":269
 * #  custom class lookup based on node type, namespace, name
 * 
 * cdef class CustomElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""CustomElementClassLookup(self, fallback=None)
 *     Element class lookup based on a subclass method.
 */

struct __pyx_vtabstruct_4lxml_5etree_CustomElementClassLookup {
  struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_CustomElementClassLookup *__pyx_vtabptr_4lxml_5etree_CustomElementClassLookup;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":3
 * # read-only tree implementation
 * 
 * cdef class _ReadOnlyElementProxy:             # <<<<<<<<<<<<<<
 *     u"The main read-only Element proxy class (for internal use only!)."
 *     cdef bint _free_after_use
 */

struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy {
  int (*_assertNode)(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *);
  void (*free_after_use)(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *);
  PyObject *(*getchildren)(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *__pyx_vtabptr_4lxml_5etree__ReadOnlyElementProxy;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":280
 *     del sourceProxy._dependent_proxies[:]
 * 
 * cdef class _AppendOnlyElementProxy(_ReadOnlyElementProxy):             # <<<<<<<<<<<<<<
 *     u"""A read-only element that allows adding children and changing the
 *     text content (i.e. everything that adds to the subtree).
 */

struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy {
  struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy __pyx_base;
  PyObject *(*append)(struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *__pyx_vtabptr_4lxml_5etree__AppendOnlyElementProxy;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":445
 * _find_namespaces = re.compile('({[^}]+})').findall
 * 
 * cdef class ETXPath(XPath):             # <<<<<<<<<<<<<<
 *     u"""ETXPath(self, path, extensions=None, regexp=True)
 *     Special XPath class that supports the ElementTree {uri} notation for namespaces.
 */

struct __pyx_vtabstruct_4lxml_5etree_ETXPath {
  struct __pyx_vtabstruct_4lxml_5etree_XPath __pyx_base;
  PyObject *(*_nsextract_path)(struct __pyx_obj_4lxml_5etree_ETXPath *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree_ETXPath *__pyx_vtabptr_4lxml_5etree_ETXPath;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":81
 *         python.PyDict_Clear(self._entries)
 * 
 * cdef class _ClassNamespaceRegistry(_NamespaceRegistry):             # <<<<<<<<<<<<<<
 *     u"Dictionary-like registry for namespace implementation classes"
 *     def __setitem__(self, name, item):
 */

struct __pyx_vtabstruct_4lxml_5etree__ClassNamespaceRegistry {
  struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__ClassNamespaceRegistry *__pyx_vtabptr_4lxml_5etree__ClassNamespaceRegistry;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":95
 * 
 * 
 * cdef class ElementNamespaceClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""ElementNamespaceClassLookup(self, fallback=None)
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_ElementNamespaceClassLookup {
  struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_ElementNamespaceClassLookup *__pyx_vtabptr_4lxml_5etree_ElementNamespaceClassLookup;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":327
 * # read-only tree based class lookup
 * 
 * cdef class PythonElementClassLookup(FallbackElementClassLookup):             # <<<<<<<<<<<<<<
 *     u"""PythonElementClassLookup(self, fallback=None)
 *     Element class lookup based on a subclass method.
 */

struct __pyx_vtabstruct_4lxml_5etree_PythonElementClassLookup {
  struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_PythonElementClassLookup *__pyx_vtabptr_4lxml_5etree_PythonElementClassLookup;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":292
 * 
 * 
 * cdef class XPathDocumentEvaluator(XPathElementEvaluator):             # <<<<<<<<<<<<<<
 *     u"""XPathDocumentEvaluator(self, etree, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 *     Create an XPath evaluator for an ElementTree.
 */

struct __pyx_vtabstruct_4lxml_5etree_XPathDocumentEvaluator {
  struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_XPathDocumentEvaluator *__pyx_vtabptr_4lxml_5etree_XPathDocumentEvaluator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":172
 * # XSLT file/network access control
 * 
 * cdef class XSLTAccessControl:             # <<<<<<<<<<<<<<
 *     u"""XSLTAccessControl(self, read_file=True, write_file=True, create_dir=True, read_network=True, write_network=True)
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl {
  PyObject *(*_setAccess)(struct __pyx_obj_4lxml_5etree_XSLTAccessControl *, xsltSecurityOption, PyObject *);
  void (*_register_in_context)(struct __pyx_obj_4lxml_5etree_XSLTAccessControl *, xsltTransformContext *);
  PyObject *(*_optval)(struct __pyx_obj_4lxml_5etree_XSLTAccessControl *, xsltSecurityOption);
};
static struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *__pyx_vtabptr_4lxml_5etree_XSLTAccessControl;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlElementTreeType;

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1494
 * 
 * 
 * cdef public class _ElementTree [ type LxmlElementTreeType,             # <<<<<<<<<<<<<<
 *                                  object LxmlElementTree ]:
 *     cdef _Document _doc
 */

struct __pyx_vtabstruct_4lxml_5etree__ElementTree {
  PyObject *(*_assertHasRoot)(struct LxmlElementTree *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ElementTree *__pyx_vtabptr_4lxml_5etree__ElementTree;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":627
 *     return new_xslt
 * 
 * cdef class _XSLTResultTree(_ElementTree):             # <<<<<<<<<<<<<<
 *     cdef XSLT _xslt
 *     cdef _Document _profile
 */

struct __pyx_vtabstruct_4lxml_5etree__XSLTResultTree {
  struct __pyx_vtabstruct_4lxml_5etree__ElementTree __pyx_base;
  PyObject *(*_saveToStringAndSize)(struct __pyx_obj_4lxml_5etree__XSLTResultTree *, char **, int *);
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTResultTree *__pyx_vtabptr_4lxml_5etree__XSLTResultTree;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":360
 * # EXSLT regexp implementation
 * 
 * cdef class _ExsltRegExp:             # <<<<<<<<<<<<<<
 *     cdef object _compile_map
 *     def __init__(self):
 */

struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp {
  PyObject *(*_make_string)(struct __pyx_obj_4lxml_5etree__ExsltRegExp *, PyObject *);
  PyObject *(*_compile)(struct __pyx_obj_4lxml_5etree__ExsltRegExp *, PyObject *, PyObject *);
  PyObject *(*_register_in_context)(struct __pyx_obj_4lxml_5etree__ExsltRegExp *, struct __pyx_obj_4lxml_5etree__BaseContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *__pyx_vtabptr_4lxml_5etree__ExsltRegExp;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2109
 *         self._storeNext(node)
 * 
 * cdef class AncestorsIterator(_ElementIterator):             # <<<<<<<<<<<<<<
 *     u"""AncestorsIterator(self, node, tag=None)
 *     Iterates over the ancestors of an element (from parent to parent).
 */

struct __pyx_vtabstruct_4lxml_5etree_AncestorsIterator {
  struct __pyx_vtabstruct_4lxml_5etree__ElementIterator __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_AncestorsIterator *__pyx_vtabptr_4lxml_5etree_AncestorsIterator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":351
 *         python.PyList_Append(entries, entry)
 * 
 * cdef class PyErrorLog(_BaseErrorLog):             # <<<<<<<<<<<<<<
 *     u"""PyErrorLog(self, logger_name=None)
 *     A global error log that connects to the Python stdlib logging package.
 */

struct __pyx_vtabstruct_4lxml_5etree_PyErrorLog {
  struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_PyErrorLog *__pyx_vtabptr_4lxml_5etree_PyErrorLog;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2118
 *         self._storeNext(node)
 * 
 * cdef class ElementDepthFirstIterator(_ElementTagMatcher):             # <<<<<<<<<<<<<<
 *     u"""ElementDepthFirstIterator(self, node, tag=None, inclusive=True)
 *     Iterates over an element and its sub-elements in document order (depth
 */

struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator {
  struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher __pyx_base;
  xmlNode *(*_nextNodeAnyTag)(struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *, xmlNode *);
  xmlNode *(*_nextNodeMatchTag)(struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *, xmlNode *);
};
static struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator *__pyx_vtabptr_4lxml_5etree_ElementDepthFirstIterator;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":199
 *         return u"FunctionNamespace(%r)" % self._ns_uri
 * 
 * cdef class _XPathFunctionNamespaceRegistry(_FunctionNamespaceRegistry):             # <<<<<<<<<<<<<<
 *     cdef object _prefix
 *     cdef object _prefix_utf
 */

struct __pyx_vtabstruct_4lxml_5etree__XPathFunctionNamespaceRegistry {
  struct __pyx_vtabstruct_4lxml_5etree__FunctionNamespaceRegistry __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree__XPathFunctionNamespaceRegistry *__pyx_vtabptr_4lxml_5etree__XPathFunctionNamespaceRegistry;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":57
 *     return (_elementTreeFactory(doc, None), _IDDict(doc))
 * 
 * cdef class _IDDict:             # <<<<<<<<<<<<<<
 *     u"""IDDict(self, etree)
 *     A dictionary-like proxy class that mapps ID attributes to elements.
 */

struct __pyx_vtabstruct_4lxml_5etree__IDDict {
  PyObject *(*_build_keys)(struct __pyx_obj_4lxml_5etree__IDDict *);
  PyObject *(*_build_items)(struct __pyx_obj_4lxml_5etree__IDDict *);
};
static struct __pyx_vtabstruct_4lxml_5etree__IDDict *__pyx_vtabptr_4lxml_5etree__IDDict;

__PYX_EXTERN_C DL_EXPORT(PyTypeObject) LxmlDocumentType;

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":280
 * 
 * 
 * cdef public class _Document [ type LxmlDocumentType, object LxmlDocument ]:             # <<<<<<<<<<<<<<
 *     u"""Internal base class to reference a libxml document.
 * 
 */

struct __pyx_vtabstruct_4lxml_5etree__Document {
  PyObject *(*getroot)(struct LxmlDocument *);
  int (*hasdoctype)(struct LxmlDocument *);
  PyObject *(*getdoctype)(struct LxmlDocument *);
  PyObject *(*getxmlinfo)(struct LxmlDocument *);
  PyObject *(*buildNewPrefix)(struct LxmlDocument *);
  xmlNs *(*_findOrBuildNodeNs)(struct LxmlDocument *, xmlNode *, char *, char *);
  int (*_setNodeNs)(struct LxmlDocument *, xmlNode *, char *);
};
static struct __pyx_vtabstruct_4lxml_5etree__Document *__pyx_vtabptr_4lxml_5etree__Document;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":40
 *     pass
 * 
 * cdef class _ParserDictionaryContext:             # <<<<<<<<<<<<<<
 *     # Global parser context to share the string dictionary.
 *     #
 */

struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext {
  void (*initMainParserContext)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *);
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *(*_findThreadParserContext)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *);
  void (*setDefaultParser)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, struct __pyx_obj_4lxml_5etree__BaseParser *);
  struct __pyx_obj_4lxml_5etree__BaseParser *(*getDefaultParser)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *);
  xmlDict *(*_getThreadDict)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, xmlDict *);
  void (*initThreadDictRef)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, xmlDict **);
  void (*initParserDict)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, xmlParserCtxt *);
  void (*initXPathParserDict)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, xmlXPathContext *);
  void (*initDocDict)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, xmlDoc *);
  struct __pyx_obj_4lxml_5etree__ParserContext *(*findImpliedContext)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *);
  void (*pushImpliedContextFromParser)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, struct __pyx_obj_4lxml_5etree__BaseParser *);
  void (*pushImpliedContext)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *, struct __pyx_obj_4lxml_5etree__ParserContext *);
  void (*popImpliedContext)(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *);
};
static struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *__pyx_vtabptr_4lxml_5etree__ParserDictionaryContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1243
 *                              target, None, encoding)
 * 
 * cdef class ETCompatXMLParser(XMLParser):             # <<<<<<<<<<<<<<
 *     u"""ETCompatXMLParser(self, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, remove_blank_text=False, compact=True, resolve_entities=True, remove_comments=True, remove_pis=True, target=None, encoding=None, schema=None)
 *     An XML parser with an ElementTree compatible default setup.
 */

struct __pyx_vtabstruct_4lxml_5etree_ETCompatXMLParser {
  struct __pyx_vtabstruct_4lxml_5etree_XMLParser __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_ETCompatXMLParser *__pyx_vtabptr_4lxml_5etree_ETCompatXMLParser;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":93
 * 
 * 
 * cdef class _TargetParserContext(_SaxParserContext):             # <<<<<<<<<<<<<<
 *     u"""This class maps SAX2 events to the ET parser target interface.
 *     """
 */

struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext {
  struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext __pyx_base;
  int (*_setTarget)(struct __pyx_obj_4lxml_5etree__TargetParserContext *, PyObject *);
};
static struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext *__pyx_vtabptr_4lxml_5etree__TargetParserContext;


/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1312
 *     )
 * 
 * cdef class HTMLParser(_FeedParser):             # <<<<<<<<<<<<<<
 *     u"""HTMLParser(self, recover=True, no_network=True, remove_blank_text=False, compact=True, remove_comments=False, remove_pis=False, target=None, encoding=None, schema=None)
 *     The HTML parser.
 */

struct __pyx_vtabstruct_4lxml_5etree_HTMLParser {
  struct __pyx_vtabstruct_4lxml_5etree__FeedParser __pyx_base;
};
static struct __pyx_vtabstruct_4lxml_5etree_HTMLParser *__pyx_vtabptr_4lxml_5etree_HTMLParser;
/* Module declarations from lxml.cstd */

/* Module declarations from lxml.tree */

/* Module declarations from __builtin__ */

/* Module declarations from lxml.python */

static PyTypeObject *__pyx_ptype_4lxml_6python_slice = 0;
static PyTypeObject *__pyx_ptype_4lxml_6python_unicode = 0;
/* Module declarations from lxml.config */

/* Module declarations from lxml.xmlerror */

/* Module declarations from lxml.xpath */

/* Module declarations from lxml.c14n */

/* Module declarations from lxml.xmlparser */

/* Module declarations from lxml.htmlparser */

/* Module declarations from lxml.xinclude */

/* Module declarations from lxml.xslt */

/* Module declarations from lxml.dtdvalid */

/* Module declarations from lxml.relaxng */

/* Module declarations from lxml.xmlschema */

/* Module declarations from lxml.schematron */

/* Module declarations from lxml.etree */

static PyTypeObject *__pyx_ptype_4lxml_5etree__TempStore = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ExceptionContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_QName = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__BaseParser = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__Document = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_DocInfo = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__Element = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree___ContentOnlyElement = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__Comment = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ProcessingInstruction = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__Entity = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ElementTree = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__Attrib = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__AttribIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ElementTagMatcher = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ElementIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementChildIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_SiblingsIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_AncestorsIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementDepthFirstIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementTextIterator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_CDATA = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__LogEntry = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__BaseErrorLog = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ListErrorLog = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ErrorLog = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__DomainErrorLog = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__RotatingErrorLog = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_PyErrorLog = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ReadOnlyElementProxy = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__AppendOnlyElementProxy = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementBase = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_CommentBase = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_PIBase = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_EntityBase = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_FallbackElementClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementDefaultClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_AttributeBasedElementClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ParserBasedElementClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_CustomElementClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_PythonElementClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__NamespaceRegistry = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ClassNamespaceRegistry = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ElementNamespaceClassLookup = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__FunctionNamespaceRegistry = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XPathFunctionNamespaceRegistry = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__InputDocument = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_Resolver = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ResolverRegistry = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ResolverContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ParserContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__SaxParserContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__TargetParserContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ParserSchemaValidationContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__Validator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XMLSchema = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ParserDictionaryContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__FileReaderContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__FeedParser = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XMLParser = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ETCompatXMLParser = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_HTMLParser = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__SaxParserTarget = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_TreeBuilder = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__PythonSaxParserTarget = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__FilelikeWriter = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__IterparseContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_iterparse = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_iterwalk = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__IDDict = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XInclude = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ExsltRegExp = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__BaseContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__ElementUnicodeResult = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XPathContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XPathEvaluatorBase = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XPathElementEvaluator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XPathDocumentEvaluator = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XPath = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_ETXPath = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XSLTResolverContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XSLTAccessControl = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XSLTContext = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XSLT = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XSLTResultTree = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree__XSLTProcessingInstruction = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_XSLTExtension = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_DTD = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_RelaxNG = 0;
static PyTypeObject *__pyx_ptype_4lxml_5etree_Schematron = 0;
static PyObject *__pyx_v_4lxml_5etree_set = 0;
static PyObject *__pyx_v_4lxml_5etree__unicode = 0;
static PyObject *__pyx_v_4lxml_5etree_os_path_abspath = 0;
static PyObject *__pyx_v_4lxml_5etree_os_path_join = 0;
static PyObject *__pyx_v_4lxml_5etree_BytesIO = 0;
static PyObject *__pyx_v_4lxml_5etree_StringIO = 0;
static PyObject *__pyx_v_4lxml_5etree__elementpath = 0;
static PyObject *__pyx_v_4lxml_5etree_sys = 0;
static PyObject *__pyx_v_4lxml_5etree_re = 0;
static PyObject *__pyx_v_4lxml_5etree_ITER_EMPTY = 0;
static PyObject *__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT = 0;
static PyObject *__pyx_v_4lxml_5etree__FILENAME_ENCODING = 0;
static char *__pyx_v_4lxml_5etree__C_FILENAME_ENCODING;
static PyObject *__pyx_v_4lxml_5etree__DEFAULT_NAMESPACE_PREFIXES = 0;
static PyObject *__pyx_v_4lxml_5etree__LxmlError = 0;
static PyObject *__pyx_v_4lxml_5etree_error_super_init = 0;
static int __pyx_v_4lxml_5etree__LIBXML_VERSION_INT;
static PyObject *__pyx_v_4lxml_5etree__PREFIX_CACHE = 0;
static PyObject *__pyx_v_4lxml_5etree___RE_XML_ENCODING = 0;
static PyObject *__pyx_v_4lxml_5etree___REPLACE_XML_ENCODING = 0;
static PyObject *__pyx_v_4lxml_5etree___HAS_XML_ENCODING = 0;
static struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG = 0;
static PyObject *__pyx_v_4lxml_5etree___ERROR_LEVELS = 0;
static PyObject *__pyx_v_4lxml_5etree___ERROR_DOMAINS = 0;
static PyObject *__pyx_v_4lxml_5etree___PARSER_ERROR_TYPES = 0;
static PyObject *__pyx_v_4lxml_5etree___RELAXNG_ERROR_TYPES = 0;
static _element_class_lookup_function __pyx_v_4lxml_5etree_LOOKUP_ELEMENT_CLASS;
static PyObject *__pyx_v_4lxml_5etree_ELEMENT_CLASS_LOOKUP_STATE = 0;
static struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup *__pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP = 0;
static PyObject *__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES = 0;
static PyObject *__pyx_v_4lxml_5etree__XMLSyntaxError = 0;
static struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT = 0;
static char *__pyx_v_4lxml_5etree__UNICODE_ENCODING;
static xmlExternalEntityLoader __pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER;
static int __pyx_v_4lxml_5etree__XML_DEFAULT_PARSE_OPTIONS;
static struct __pyx_obj_4lxml_5etree_XMLParser *__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER = 0;
static int __pyx_v_4lxml_5etree__HTML_DEFAULT_PARSE_OPTIONS;
static struct __pyx_obj_4lxml_5etree_HTMLParser *__pyx_v_4lxml_5etree___DEFAULT_HTML_PARSER = 0;
static PyObject *__pyx_v_4lxml_5etree_inspect_getargspec = 0;
static PyObject *__pyx_v_4lxml_5etree__find_id_attributes = 0;
static PyObject *__pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS = 0;
static PyObject *__pyx_v_4lxml_5etree__XPATH_EVAL_ERRORS = 0;
static int __pyx_v_4lxml_5etree__XPATH_VERSION_WARNING_REQUIRED;
static PyObject *__pyx_v_4lxml_5etree__replace_strings = 0;
static PyObject *__pyx_v_4lxml_5etree__find_namespaces = 0;
static xsltDocLoaderFunc __pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER;
static PyObject *__pyx_v_4lxml_5etree__FIND_PI_ATTRIBUTES = 0;
static PyObject *__pyx_v_4lxml_5etree__RE_PI_HREF = 0;
static PyObject *__pyx_v_4lxml_5etree__FIND_PI_HREF = 0;
static PyObject *__pyx_v_4lxml_5etree__REPLACE_PI_HREF = 0;
static struct __pyx_obj_4lxml_5etree_XPath *__pyx_v_4lxml_5etree___findStylesheetByID = 0;
static PyObject *__pyx_k_67;
static PyObject *__pyx_k_68;
static PyObject *__pyx_k_69;
static PyObject *__pyx_k_70;
static PyObject *__pyx_k_72;
static PyObject *__pyx_k_73;
static PyObject *__pyx_k_74;
static PyObject *__pyx_k_75;
static PyObject *__pyx_k_76;
static PyObject *__pyx_k_77;
static PyObject *__pyx_k_78;
static PyObject *__pyx_k_80;
static PyObject *__pyx_k_81;
static PyObject *__pyx_k_83;
static PyObject *__pyx_k_84;
static PyObject *__pyx_k_86;
static PyObject *__pyx_k_87;
static PyObject *__pyx_k_106;
static PyObject *__pyx_k_113;
static PyObject *__pyx_k_114;
static PyObject *__pyx_k_115;
static PyObject *__pyx_k_116;
static PyObject *__pyx_k_117;
static PyObject *__pyx_k_118;
static PyObject *__pyx_k_119;
static PyObject *__pyx_k_120;
static PyObject *__pyx_k_121;
static PyObject *__pyx_k_122;
static PyObject *__pyx_k_123;
static PyObject *__pyx_k_124;
static PyObject *__pyx_k_125;
static PyObject *__pyx_k_126;
static PyObject *__pyx_k_127;
static PyObject *__pyx_k_128;
static PyObject *__pyx_k_129;
static PyObject *__pyx_k_130;
static PyObject *__pyx_k_131;
static PyObject *__pyx_k_132;
static PyObject *__pyx_k_133;
static PyObject *__pyx_k_134;
static PyObject *__pyx_k_135;
static PyObject *__pyx_k_136;
static PyObject *__pyx_k_137;
static PyObject *__pyx_k_138;
static PyObject *__pyx_k_139;
static PyObject *__pyx_k_140;
static PyObject *__pyx_k_141;
static PyObject *__pyx_k_142;
static PyObject *__pyx_k_143;
static PyObject *__pyx_k_145;
static PyObject *__pyx_k_146;
static PyObject *__pyx_k_147;
static PyObject *__pyx_k_148;
static PyObject *__pyx_k_149;
static PyObject *__pyx_k_150;
static PyObject *__pyx_k_151;
static PyObject *__pyx_k_152;
static PyObject *__pyx_k_153;
static PyObject *__pyx_k_154;
static PyObject *__pyx_k_155;
static PyObject *__pyx_k_156;
static PyObject *__pyx_k_158;
static PyObject *__pyx_k_167;
static PyObject *__pyx_k_168;
static PyObject *__pyx_k_169;
static PyObject *__pyx_k_170;
static PyObject *__pyx_k_171;
static PyObject *__pyx_k_172;
static PyObject *__pyx_k_173;
static PyObject *__pyx_k_174;
static PyObject *__pyx_k_177;
static PyObject *__pyx_k_178;
static PyObject *__pyx_k_185;
static PyObject *__pyx_k_186;
static PyObject *__pyx_k_187;
static PyObject *__pyx_k_188;
static PyObject *__pyx_k_189;
static PyObject *__pyx_k_190;
static PyObject *__pyx_k_191;
static PyObject *__pyx_k_192;
static PyObject *__pyx_f_4lxml_5etree___unpackDottedVersion(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree___unpackIntVersion(int); /*proto*/
static PyObject *__pyx_f_4lxml_5etree___initPrefixCache(void); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__documentFactory(xmlDoc *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree__elementFactory(struct LxmlDocument *, xmlNode *); /*proto*/
static struct LxmlElementTree *__pyx_f_4lxml_5etree__elementTreeFactory(struct LxmlDocument *, struct LxmlElement *); /*proto*/
static struct LxmlElementTree *__pyx_f_4lxml_5etree__newElementTree(struct LxmlDocument *, struct LxmlElement *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__attributeIteratorFactory(struct LxmlElement *, int); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__createElement(xmlDoc *, PyObject *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__createComment(xmlDoc *, char *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__createPI(xmlDoc *, char *, char *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__createEntity(xmlDoc *, char *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree_getProxy(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree_hasProxy(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__registerProxy(struct LxmlElement *); /*proto*/
static int __pyx_f_4lxml_5etree__unregisterProxy(struct LxmlElement *); /*proto*/
static void __pyx_f_4lxml_5etree__releaseProxy(struct LxmlElement *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__updateProxyDocument(xmlNode *, struct LxmlDocument *); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__fakeRootDoc(xmlDoc *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__destroyFakeDoc(xmlDoc *, xmlDoc *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree__fakeDocElementFactory(struct LxmlDocument *, xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree_attemptDeallocation(xmlNode *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree_getDeallocationTop(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree_canDeallocateChildNodes(xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__copyParentNamespaces(xmlNode *, xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__growNsCache(__pyx_t_4lxml_5etree__nscache *); /*proto*/
static int __pyx_f_4lxml_5etree__appendToNsCache(__pyx_t_4lxml_5etree__nscache *, xmlNs *, xmlNs *); /*proto*/
static int __pyx_f_4lxml_5etree__stripRedundantNamespaceDeclarations(xmlNode *, __pyx_t_4lxml_5etree__nscache *, xmlNs **); /*proto*/
static int __pyx_f_4lxml_5etree_moveNodeToDocument(struct LxmlDocument *, xmlDoc *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree_fixThreadDictNames(xmlNode *, xmlDict *, xmlDict *); /*proto*/
static void __pyx_f_4lxml_5etree_fixThreadDictNamesForAttributes(xmlAttr *, xmlDict *, xmlDict *); /*proto*/
static void __pyx_f_4lxml_5etree_fixThreadDictNameForNode(xmlNode *, xmlDict *); /*proto*/
static void __pyx_f_4lxml_5etree_fixThreadDictContentForNode(xmlNode *, xmlDict *, xmlDict *); /*proto*/
static void __pyx_f_4lxml_5etree_fixThreadDictNsForNode(xmlNode *, xmlDict *, xmlDict *); /*proto*/
static void __pyx_f_4lxml_5etree_displayNode(xmlNode *, PyObject *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__documentOrRaise(PyObject *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree__rootNodeOrRaise(PyObject *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__documentOf(PyObject *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree__rootNodeOf(PyObject *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree__makeElement(PyObject *, xmlDoc *, struct LxmlDocument *, struct __pyx_obj_4lxml_5etree__BaseParser *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static struct LxmlElement *__pyx_f_4lxml_5etree__makeSubElement(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__initNodeNamespaces(xmlNode *, struct LxmlDocument *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__initNodeAttributes(xmlNode *, struct LxmlDocument *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__removeUnusedNamespaceDeclarations(xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__attributeValue(xmlNode *, xmlAttr *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__attributeValueFromNsName(xmlNode *, char *, char *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__getNodeAttributeValue(xmlNode *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__getAttributeValue(struct LxmlElement *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__setAttributeValue(struct LxmlElement *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__delAttribute(struct LxmlElement *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__delAttributeFromNsName(xmlNode *, char *, char *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__collectAttributes(xmlNode *, int); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__stripEncodingDeclaration(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__hasEncodingDeclaration(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__stripDeclaration(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__hasText(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__hasTail(xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__collectText(xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__removeText(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__setNodeText(xmlNode *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__setTailText(xmlNode *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__resolveQNameText(struct LxmlElement *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__hasChild(xmlNode *); /*proto*/
static Py_ssize_t __pyx_f_4lxml_5etree__countElements(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__findChildSlice(PySliceObject *, xmlNode *, xmlNode **, Py_ssize_t *, Py_ssize_t *); /*proto*/
static int __pyx_f_4lxml_5etree__isFullSlice(PySliceObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__collectChildren(struct LxmlElement *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__findChild(xmlNode *, Py_ssize_t); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__findChildForwards(xmlNode *, Py_ssize_t); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__findChildBackwards(xmlNode *, Py_ssize_t); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__textNodeOrSkip(xmlNode *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__nextElement(xmlNode *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__previousElement(xmlNode *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__parentElement(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__tagMatches(xmlNode *, char *, char *); /*proto*/
static int __pyx_f_4lxml_5etree__removeNode(struct LxmlDocument *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__moveTail(xmlNode *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__copyTail(xmlNode *, xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__deleteSlice(struct LxmlDocument *, xmlNode *, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_f_4lxml_5etree__replaceSlice(struct LxmlElement *, xmlNode *, Py_ssize_t, Py_ssize_t, int, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__appendChild(struct LxmlElement *, struct LxmlElement *); /*proto*/
static int __pyx_f_4lxml_5etree__prependChild(struct LxmlElement *, struct LxmlElement *); /*proto*/
static int __pyx_f_4lxml_5etree__appendSibling(struct LxmlElement *, struct LxmlElement *); /*proto*/
static int __pyx_f_4lxml_5etree__prependSibling(struct LxmlElement *, struct LxmlElement *); /*proto*/
static int __pyx_f_4lxml_5etree_isutf8(char *); /*proto*/
static int __pyx_f_4lxml_5etree_isutf8py(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree_funicode(char *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__utf8(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__isFilePath(char *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__encodeFilename(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__decodeFilename(char *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__encodeFilenameUTF8(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__getNsTag(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__pyXmlNameIsValid(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__pyHtmlNameIsValid(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__xmlNameIsValid(char *); /*proto*/
static int __pyx_f_4lxml_5etree__htmlNameIsValid(char *); /*proto*/
static int __pyx_f_4lxml_5etree__characterReferenceIsValid(char *); /*proto*/
static int __pyx_f_4lxml_5etree__tagValidOrRaise(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__htmlTagValidOrRaise(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__attributeValidOrRaise(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__prefixValidOrRaise(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__namespacedName(xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__namespacedNameFromNsName(char *, char *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__getFilenameForFile(PyObject *); /*proto*/
static void __pyx_f_4lxml_5etree__nullGenericErrorFunc(void *, char *, ...); /*proto*/
static void __pyx_f_4lxml_5etree__initThreadLogging(void); /*proto*/
static void __pyx_f_4lxml_5etree_connectErrorLog(void *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree___copyGlobalErrorLog(void); /*proto*/
static void __pyx_f_4lxml_5etree__forwardError(void *, xmlError *); /*proto*/
static void __pyx_f_4lxml_5etree__receiveError(void *, xmlError *); /*proto*/
static void __pyx_f_4lxml_5etree__receiveXSLTError(void *, char *, ...); /*proto*/
static void __pyx_f_4lxml_5etree___initErrorConstants(void); /*proto*/
static struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_f_4lxml_5etree__newReadOnlyProxy(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__initReadOnlyProxy(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *, struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__freeReadOnlyProxies(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *); /*proto*/
static struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *__pyx_f_4lxml_5etree__newAppendOnlyProxy(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *, xmlNode *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__roNodeOf(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__callLookupFallback(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__lookupDefaultElementClass(PyObject *, struct LxmlDocument *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__attribute_class_lookup(PyObject *, struct LxmlDocument *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__parser_class_lookup(PyObject *, struct LxmlDocument *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__custom_class_lookup(PyObject *, struct LxmlDocument *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__python_class_lookup(PyObject *, struct LxmlDocument *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__setElementClassLookupFunction(_element_class_lookup_function, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__find_nselement_class(PyObject *, struct LxmlDocument *, xmlNode *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__find_all_extension_prefixes(void); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__iter_ns_extension_functions(void); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__find_extension(PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__initResolverContext(struct __pyx_obj_4lxml_5etree__ResolverContext *, struct __pyx_obj_4lxml_5etree__ResolverRegistry *); /*proto*/
static int __pyx_f_4lxml_5etree__checkThreadDict(xmlDict *); /*proto*/
static void __pyx_f_4lxml_5etree__setupPythonUnicode(void); /*proto*/
static char *__pyx_f_4lxml_5etree__findEncodingName(char *, int); /*proto*/
static int __pyx_f_4lxml_5etree__readFilelikeParser(void *, char *, int); /*proto*/
static int __pyx_f_4lxml_5etree__readFileParser(void *, char *, int); /*proto*/
static xmlParserInput *__pyx_f_4lxml_5etree__local_resolver(char *, char *, xmlParserCtxt *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__initParserContext(struct __pyx_obj_4lxml_5etree__ParserContext *, struct __pyx_obj_4lxml_5etree__ResolverRegistry *, xmlParserCtxt *); /*proto*/
static int __pyx_f_4lxml_5etree__raiseParseError(xmlParserCtxt *, PyObject *, struct __pyx_obj_4lxml_5etree__ErrorLog *); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__handleParseResult(struct __pyx_obj_4lxml_5etree__ParserContext *, xmlParserCtxt *, xmlDoc *, PyObject *, int); /*proto*/
static int __pyx_f_4lxml_5etree__fixHtmlDictNames(xmlDict *, xmlDoc *); /*proto*/
static int __pyx_f_4lxml_5etree__fixHtmlDictNodeNames(xmlDict *, xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__htmlCtxtResetPush(xmlParserCtxt *, char *, int, char *, int); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__parseDoc(PyObject *, PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__parseDocFromFile(PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__parseDocFromFilelike(PyObject *, PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__newXMLDoc(void); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__newHTMLDoc(void); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__copyDoc(xmlDoc *, int); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__copyDocRoot(xmlDoc *, xmlNode *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__copyNodeToDoc(xmlNode *, xmlDoc *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__parseDocument(PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *, PyObject *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__parseDocumentFromURL(PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__parseMemoryDocument(PyObject *, PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static struct LxmlDocument *__pyx_f_4lxml_5etree__parseFilelikeDocument(PyObject *, PyObject *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxStart(void *, char *, char *, char *, int, char **, int, int, char **); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxStartNoNs(void *, char *, char **); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxEnd(void *, char *, char *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxEndNoNs(void *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxData(void *, char *, int); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxCData(void *, char *, int); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxDoctype(void *, char *, char *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxPI(void *, char *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__handleSaxComment(void *, char *); /*proto*/
static int __pyx_f_4lxml_5etree__findOutputMethod(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__textToString(xmlNode *, PyObject *, int); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__tostring(struct LxmlElement *, PyObject *, PyObject *, int, int, int, int); /*proto*/
static void __pyx_f_4lxml_5etree__writeNodeToBuffer(xmlOutputBuffer *, xmlNode *, char *, int, int, int, int, int); /*proto*/
static void __pyx_f_4lxml_5etree__writeDeclarationToBuffer(xmlOutputBuffer *, char *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__writeDtdToBuffer(xmlOutputBuffer *, xmlDoc *, char *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__writeTail(xmlOutputBuffer *, xmlNode *, char *, int); /*proto*/
static void __pyx_f_4lxml_5etree__writePrevSiblings(xmlOutputBuffer *, xmlNode *, char *, int); /*proto*/
static void __pyx_f_4lxml_5etree__writeNextSiblings(xmlOutputBuffer *, xmlNode *, char *, int); /*proto*/
static int __pyx_f_4lxml_5etree__writeFilelikeWriter(void *, char *, int); /*proto*/
static int __pyx_f_4lxml_5etree__closeFilelikeWriter(void *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__tofilelike(PyObject *, struct LxmlElement *, PyObject *, PyObject *, int, int, int, int); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__tofilelikeC14N(PyObject *, struct LxmlElement *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__dumpToFile(PyObject *, xmlNode *, int, int); /*proto*/
static int __pyx_f_4lxml_5etree__buildIterparseEventFilter(PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__countNsDefs(xmlNode *); /*proto*/
static int __pyx_f_4lxml_5etree__appendStartNsEvents(xmlNode *, PyObject *); /*proto*/
static void __pyx_f_4lxml_5etree__pushSaxStartEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__pushSaxEndEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__pushSaxEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *, PyObject *, xmlNode *); /*proto*/
static void __pyx_f_4lxml_5etree__iterparseSaxStart(void *, char *, char *, char *, int, char **, int, int, char **); /*proto*/
static void __pyx_f_4lxml_5etree__iterparseSaxEnd(void *, char *, char *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__iterparseSaxStartNoNs(void *, char *, char **); /*proto*/
static void __pyx_f_4lxml_5etree__iterparseSaxEndNoNs(void *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__iterparseSaxComment(void *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__iterparseSaxPI(void *, char *, char *); /*proto*/
static xmlNode *__pyx_f_4lxml_5etree__iterparseFindLastNode(xmlParserCtxt *); /*proto*/
static void __pyx_f_4lxml_5etree__collectIdHashItemDict(void *, void *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__collectIdHashItemList(void *, void *, char *); /*proto*/
static void __pyx_f_4lxml_5etree__collectIdHashKeys(void *, void *, char *); /*proto*/
static xmlXPathObject *__pyx_f_4lxml_5etree__wrapXPathObject(PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__unwrapXPathObject(xmlXPathObject *, struct LxmlDocument *, int); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__createNodeSetResult(xmlXPathObject *, struct LxmlDocument *, int); /*proto*/
static void __pyx_f_4lxml_5etree__freeXPathObject(xmlXPathObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__elementStringResultFactory(PyObject *, struct LxmlElement *, int, int); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__buildElementStringResult(struct LxmlDocument *, xmlNode *, int); /*proto*/
static void __pyx_f_4lxml_5etree__extension_function_call(struct __pyx_obj_4lxml_5etree__BaseContext *, PyObject *, xmlXPathParserContext *, int); /*proto*/
static void __pyx_f_4lxml_5etree__xpath_function_call(xmlXPathParserContext *, int); /*proto*/
static int __pyx_f_4lxml_5etree__register_xpath_function(void *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__unregister_xpath_function(void *, PyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__initXSLTResolverContext(struct __pyx_obj_4lxml_5etree__XSLTResolverContext *, struct __pyx_obj_4lxml_5etree__BaseParser *); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__xslt_resolve_from_python(char *, void *, int, int *); /*proto*/
static void __pyx_f_4lxml_5etree__xslt_store_resolver_exception(char *, void *, xsltLoadType); /*proto*/
static xmlDoc *__pyx_f_4lxml_5etree__xslt_doc_loader(char *, xmlDict *, int, void *, xsltLoadType); /*proto*/
static int __pyx_f_4lxml_5etree__register_xslt_function(void *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_4lxml_5etree__unregister_xslt_function(void *, PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4lxml_5etree_XSLT *__pyx_f_4lxml_5etree__copyXSLT(struct __pyx_obj_4lxml_5etree_XSLT *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__xsltResultTreeFactory(struct LxmlDocument *, struct __pyx_obj_4lxml_5etree_XSLT *, struct LxmlDocument *); /*proto*/
static void __pyx_f_4lxml_5etree_initTransformDict(xsltTransformContext *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__findStylesheetByID(struct LxmlDocument *, PyObject *); /*proto*/
static PyObject *__pyx_f_4lxml_5etree__registerXSLTExtensions(xsltTransformContext *, PyObject *); /*proto*/
static void __pyx_f_4lxml_5etree__callExtensionElement(xsltTransformContext *, xmlNode *, xmlNode *, void *); /*proto*/
static xmlDtd *__pyx_f_4lxml_5etree__parseDtdFromFilelike(PyObject *); /*proto*/
static struct __pyx_obj_4lxml_5etree_DTD *__pyx_f_4lxml_5etree__dtdFactory(xmlDtd *); /*proto*/
DL_EXPORT(struct LxmlElement) *deepcopyNodeToDocument(struct LxmlDocument *, xmlNode *); /*proto*/
DL_EXPORT(struct LxmlElementTree) *elementTreeFactory(struct LxmlElement *); /*proto*/
DL_EXPORT(struct LxmlElementTree) *newElementTree(struct LxmlElement *, PyObject *); /*proto*/
DL_EXPORT(struct LxmlElement) *elementFactory(struct LxmlDocument *, xmlNode *); /*proto*/
DL_EXPORT(struct LxmlElement) *makeElement(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
DL_EXPORT(struct LxmlElement) *makeSubElement(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
DL_EXPORT(void) setElementClassLookupFunction(_element_class_lookup_function, PyObject *); /*proto*/
DL_EXPORT(PyObject) *lookupDefaultElementClass(PyObject *, PyObject *, xmlNode *); /*proto*/
DL_EXPORT(PyObject) *lookupNamespaceElementClass(PyObject *, PyObject *, xmlNode *); /*proto*/
DL_EXPORT(PyObject) *callLookupFallback(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *); /*proto*/
DL_EXPORT(int) tagMatches(xmlNode *, char *, char *); /*proto*/
DL_EXPORT(struct LxmlDocument) *documentOrRaise(PyObject *); /*proto*/
DL_EXPORT(struct LxmlElement) *rootNodeOrRaise(PyObject *); /*proto*/
DL_EXPORT(int) hasText(xmlNode *); /*proto*/
DL_EXPORT(int) hasTail(xmlNode *); /*proto*/
DL_EXPORT(PyObject) *textOf(xmlNode *); /*proto*/
DL_EXPORT(PyObject) *tailOf(xmlNode *); /*proto*/
DL_EXPORT(int) setNodeText(xmlNode *, PyObject *); /*proto*/
DL_EXPORT(int) setTailText(xmlNode *, PyObject *); /*proto*/
DL_EXPORT(PyObject) *attributeValue(xmlNode *, xmlAttr *); /*proto*/
DL_EXPORT(PyObject) *attributeValueFromNsName(xmlNode *, char *, char *); /*proto*/
DL_EXPORT(PyObject) *getAttributeValue(struct LxmlElement *, PyObject *, PyObject *); /*proto*/
DL_EXPORT(PyObject) *iterattributes(struct LxmlElement *, int); /*proto*/
DL_EXPORT(PyObject) *collectAttributes(xmlNode *, int); /*proto*/
DL_EXPORT(int) setAttributeValue(struct LxmlElement *, PyObject *, PyObject *); /*proto*/
DL_EXPORT(int) delAttribute(struct LxmlElement *, PyObject *); /*proto*/
DL_EXPORT(int) delAttributeFromNsName(xmlNode *, char *, char *); /*proto*/
DL_EXPORT(int) hasChild(xmlNode *); /*proto*/
DL_EXPORT(xmlNode) *findChild(xmlNode *, Py_ssize_t); /*proto*/
DL_EXPORT(xmlNode) *findChildForwards(xmlNode *, Py_ssize_t); /*proto*/
DL_EXPORT(xmlNode) *findChildBackwards(xmlNode *, Py_ssize_t); /*proto*/
DL_EXPORT(xmlNode) *nextElement(xmlNode *); /*proto*/
DL_EXPORT(xmlNode) *previousElement(xmlNode *); /*proto*/
DL_EXPORT(void) appendChild(struct LxmlElement *, struct LxmlElement *); /*proto*/
DL_EXPORT(PyObject) *pyunicode(char *); /*proto*/
DL_EXPORT(PyObject) *utf8(PyObject *); /*proto*/
DL_EXPORT(PyObject) *getNsTag(PyObject *); /*proto*/
DL_EXPORT(PyObject) *namespacedName(xmlNode *); /*proto*/
DL_EXPORT(PyObject) *namespacedNameFromNsName(char *, char *); /*proto*/
DL_EXPORT(void) iteratorStoreNext(struct LxmlElementIterator *, struct LxmlElement *); /*proto*/
DL_EXPORT(void) initTagMatch(struct LxmlElementTagMatcher *, PyObject *); /*proto*/
DL_EXPORT(xmlNs) *findOrBuildNodeNsPrefix(struct LxmlDocument *, xmlNode *, char *, char *); /*proto*/


/* Implementation of lxml.etree */
static char __pyx_k_1[] = "Returns the name of the root node as defined by the DOCTYPE.";
static char __pyx_k_2[] = "Returns the public ID of the DOCTYPE.";
static char __pyx_k_3[] = "Returns the system ID of the DOCTYPE.";
static char __pyx_k_4[] = "Returns the XML version as declared by the document.";
static char __pyx_k_5[] = "Returns the encoding name as declared by the document.";
static char __pyx_k_6[] = "The source URL of the document (or None if unknown).";
static char __pyx_k_7[] = "Returns a DOCTYPE declaration string for the document.";
static char __pyx_k_8[] = "Returns a DTD validator based on the internal subset of the document.";
static char __pyx_k_9[] = "Returns a DTD validator based on the external subset of the document.";
static char __pyx_k_10[] = "Element tag\n        ";
static char __pyx_k_11[] = "Element attribute dictionary. Where possible, use get(), set(),\n        keys(), values() and items() to access element attributes.\n        ";
static char __pyx_k_12[] = "Text before the first subelement. This is either a string or \n        the value None, if there was no text.\n        ";
static char __pyx_k_13[] = "Text after this element's end tag, but before the next sibling\n        element's start tag. This is either a string or the value None, if\n        there was no text.\n        ";
static char __pyx_k_14[] = "Namespace prefix or None.\n        ";
static char __pyx_k_15[] = "Original line number as found by the parser or None if unknown.\n        ";
static char __pyx_k_16[] = "Namespace prefix->URI mapping known in the context of this Element.\n        ";
static char __pyx_k_17[] = "The base URI of the Element (xml:base or HTML base URL).\n        None if the base URI is unknown.\n\n        Note that the value depends on the URL of the document that\n        holds the Element if there is no xml:base attribute on the\n        Element or its ancestors.\n\n        Setting this property will set an xml:base attribute on the\n        Element, regardless of the document type (XML or HTML).\n        ";
static char __pyx_k_18[] = "Information about the document provided by parser and DTD.  This\n        value is only defined for ElementTree objects based on the root node\n        of a parsed document (e.g.  those returned by the parse functions).\n        ";
static char __pyx_k_19[] = "The parser that was used to parse the document in this ElementTree.\n        ";
static char __pyx_k_22[] = "Text before the first subelement. This is either a string or the\n        value None, if there was no text.\n        ";
static char __pyx_k_23[] = "Namespace prefix for extension functions.";
static char __pyx_k_24[] = "The error log of the last parser run.\n        ";
static char __pyx_k_25[] = "The custom resolver registry of this parser.";
static char __pyx_k_26[] = "The version of the underlying XML parser.";
static char __pyx_k_29[] = "The error log of the last (or current) run of the feed parser.\n\n        Note that this is local to the feed parser and thus is\n        different from what the ``error_log`` property returns.\n        ";
static char __pyx_k_30[] = "The error log of the last (or current) parser run.\n        ";
static char __pyx_k_31[] = "The access control configuration as a map of options.";
static char __pyx_k_32[] = "The log of errors and warnings of an XSLT execution.";
static char __pyx_k_33[] = "Return an ElementTree with profiling data for the stylesheet run.\n        ";
static char __pyx_k_34[] = "The log of validation errors and warnings.";
static char __pyx_k_36[] = "restructuredtext en";
static char __pyx_k_40[] = "UTF-8";
static char __pyx_k_41[] = "http://www.w3.org/1999/xhtml";
static char __pyx_k_43[] = "http://www.w3.org/1999/XSL/Transform";
static char __pyx_k_45[] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
static char __pyx_k_47[] = "http://schemas.xmlsoap.org/wsdl/";
static char __pyx_k_49[] = "http://www.w3.org/2001/XMLSchema";
static char __pyx_k_51[] = "http://www.w3.org/2001/XMLSchema-instance";
static char __pyx_k_53[] = "http://purl.org/dc/elements/1.1/";
static char __pyx_k_55[] = "http://codespeak.net/lxml/objectify/pytype";
static char __pyx_k_57[] = "Main exception base class for lxml.  All other exceptions inherit from\n    this one.\n    ";
static char __pyx_k_58[] = "Base class for all syntax errors.\n    ";
static char __pyx_k_60[] = "Error during C14N serialisation.\n    ";
static char __pyx_k_61[] = "[0-9]+";
static char __pyx_k_63[] = "Unknown libxml2 version: %s";
static char __pyx_k_88[] = "^(\\s*<\\?\\s*xml[^>]+)\\s+encoding\\s*=\\s*\"[^\"]*\"\\s*";
static char __pyx_k_89[] = "Libxml2 error levels";
static char __pyx_k_90[] = "Libxml2 error domains";
static char __pyx_k_91[] = "Libxml2 error types";
static char __pyx_k_92[] = "Libxml2 RelaxNG error types";
static char __pyx_k_93[] = "NONE=0\nWARNING=1\nERROR=2\nFATAL=3\n";
static char __pyx_k_94[] = "NONE=0\nPARSER=1\nTREE=2\nNAMESPACE=3\nDTD=4\nHTML=5\nMEMORY=6\nOUTPUT=7\nIO=8\nFTP=9\nHTTP=10\nXINCLUDE=11\nXPATH=12\nXPOINTER=13\nREGEXP=14\nDATATYPE=15\nSCHEMASP=16\nSCHEMASV=17\nRELAXNGP=18\nRELAXNGV=19\nCATALOG=20\nC14N=21\nXSLT=22\nVALID=23\nCHECK=24\nWRITER=25\nMODULE=26\nI18N=27\nSCHEMATRONV=28\n";
static char __pyx_k_95[] = "ERR_OK=0\nERR_INTERNAL_ERROR=1\nERR_NO_MEMORY=2\nERR_DOCUMENT_START=3\nERR_DOCUMENT_EMPTY=4\nERR_DOCUMENT_END=5\nERR_INVALID_HEX_CHARREF=6\nERR_INVALID_DEC_CHARREF=7\nERR_INVALID_CHARREF=8\nERR_INVALID_CHAR=9\nERR_CHARREF_AT_EOF=10\nERR_CHARREF_IN_PROLOG=11\nERR_CHARREF_IN_EPILOG=12\nERR_CHARREF_IN_DTD=13\nERR_ENTITYREF_AT_EOF=14\nERR_ENTITYREF_IN_PROLOG=15\nERR_ENTITYREF_IN_EPILOG=16\nERR_ENTITYREF_IN_DTD=17\nERR_PEREF_AT_EOF=18\nERR_PEREF_IN_PROLOG=19\nERR_PEREF_IN_EPILOG=20\nERR_PEREF_IN_INT_SUBSET=21\nERR_ENTITYREF_NO_NAME=22\nERR_ENTITYREF_SEMICOL_MISSING=23\nERR_PEREF_NO_NAME=24\nERR_PEREF_SEMICOL_MISSING=25\nERR_UNDECLARED_ENTITY=26\nWAR_UNDECLARED_ENTITY=27\nERR_UNPARSED_ENTITY=28\nERR_ENTITY_IS_EXTERNAL=29\nERR_ENTITY_IS_PARAMETER=30\nERR_UNKNOWN_ENCODING=31\nERR_UNSUPPORTED_ENCODING=32\nERR_STRING_NOT_STARTED=33\nERR_STRING_NOT_CLOSED=34\nERR_NS_DECL_ERROR=35\nERR_ENTITY_NOT_STARTED=36\nERR_ENTITY_NOT_FINISHED=37\nERR_LT_IN_ATTRIBUTE=38\nERR_ATTRIBUTE_NOT_STARTED=39\nERR_ATTRIBUTE_NOT_FINISHED=40\nERR_ATTRIBUTE_WITHOUT_VALUE=41\nERR_ATTRIBUTE_REDEFINED=42\nERR_LITERAL_NOT_STARTED=43\nERR_LITERAL_NOT_FINISHED=44\nERR_COMMENT_NOT_FINISHED=45\nERR_PI_NOT_STARTED=46\nERR_PI_NOT_FINISHED=47\nERR_NOTATION_NOT_STARTED=48\nERR_NOTATION_NOT_FINISHED=49\nERR_ATTLIST_NOT_STARTED=50\nERR_ATTLIST_NOT_FINISHED=51\nERR_MIXED_NOT_STARTED=52\nERR_MIXED_NOT_FINISHED=53\nERR_ELEMCONTENT_NOT_STARTED=54\nERR_ELEMCONTENT_NOT_FINISHED=55\nERR_XMLDECL_NOT_STARTED=56\nERR_XMLDECL_NOT_FINISHED=57\nERR_CONDSEC_NOT_STARTED=58\nERR_CONDSEC_NOT_FINISHED=59\nERR_EXT_SUBSET_NOT_FINISHED=60\nERR_DOCTYPE_NOT_FINISHED=61\nERR_MISPLACED_CDATA_END=62\nERR_CDATA_NOT_FINISHED=63\nERR_RESERVED_XML_NAME=64\nERR_SPACE_REQUIRED=65\nERR_SEPARATOR_REQUIRED=66\nERR_NMTOKEN_REQUIRED=67\nERR_NAME_REQUIRED=68\nERR_PCDATA_REQUIRED=69\nERR_URI_REQUIRED=70\nERR_PUBID_REQUIRED=71\nERR_LT_REQUIRED=72\nERR_GT_REQUIRED=73\nERR_LTSLASH_REQUIRED=74\nERR_EQUAL_REQUIRED=75\nERR_TAG_NAME_MISMATCH=76\nERR_TAG_NOT_FINISHED=77\nERR_STANDALONE_VALUE=78\n";
static char __pyx_k_96[] = "ERR_ENCODING_NAME=79\nERR_HYPHEN_IN_COMMENT=80\nERR_INVALID_ENCODING=81\nERR_EXT_ENTITY_STANDALONE=82\nERR_CONDSEC_INVALID=83\nERR_VALUE_REQUIRED=84\nERR_NOT_WELL_BALANCED=85\nERR_EXTRA_CONTENT=86\nERR_ENTITY_CHAR_ERROR=87\nERR_ENTITY_PE_INTERNAL=88\nERR_ENTITY_LOOP=89\nERR_ENTITY_BOUNDARY=90\nERR_INVALID_URI=91\nERR_URI_FRAGMENT=92\nWAR_CATALOG_PI=93\nERR_NO_DTD=94\nERR_CONDSEC_INVALID_KEYWORD=95\nERR_VERSION_MISSING=96\nWAR_UNKNOWN_VERSION=97\nWAR_LANG_VALUE=98\nWAR_NS_URI=99\nWAR_NS_URI_RELATIVE=100\nERR_MISSING_ENCODING=101\nWAR_SPACE_VALUE=102\nERR_NOT_STANDALONE=103\nERR_ENTITY_PROCESSING=104\nERR_NOTATION_PROCESSING=105\nWAR_NS_COLUMN=106\nWAR_ENTITY_REDEFINED=107\nNS_ERR_XML_NAMESPACE=200\nNS_ERR_UNDEFINED_NAMESPACE=201\nNS_ERR_QNAME=202\nNS_ERR_ATTRIBUTE_REDEFINED=203\nNS_ERR_EMPTY=204\nDTD_ATTRIBUTE_DEFAULT=500\nDTD_ATTRIBUTE_REDEFINED=501\nDTD_ATTRIBUTE_VALUE=502\nDTD_CONTENT_ERROR=503\nDTD_CONTENT_MODEL=504\nDTD_CONTENT_NOT_DETERMINIST=505\nDTD_DIFFERENT_PREFIX=506\nDTD_ELEM_DEFAULT_NAMESPACE=507\nDTD_ELEM_NAMESPACE=508\nDTD_ELEM_REDEFINED=509\nDTD_EMPTY_NOTATION=510\nDTD_ENTITY_TYPE=511\nDTD_ID_FIXED=512\nDTD_ID_REDEFINED=513\nDTD_ID_SUBSET=514\nDTD_INVALID_CHILD=515\nDTD_INVALID_DEFAULT=516\nDTD_LOAD_ERROR=517\nDTD_MISSING_ATTRIBUTE=518\nDTD_MIXED_CORRUPT=519\nDTD_MULTIPLE_ID=520\nDTD_NO_DOC=521\nDTD_NO_DTD=522\nDTD_NO_ELEM_NAME=523\nDTD_NO_PREFIX=524\nDTD_NO_ROOT=525\nDTD_NOTATION_REDEFINED=526\nDTD_NOTATION_VALUE=527\nDTD_NOT_EMPTY=528\nDTD_NOT_PCDATA=529\nDTD_NOT_STANDALONE=530\nDTD_ROOT_NAME=531\nDTD_STANDALONE_WHITE_SPACE=532\nDTD_UNKNOWN_ATTRIBUTE=533\nDTD_UNKNOWN_ELEM=534\nDTD_UNKNOWN_ENTITY=535\nDTD_UNKNOWN_ID=536\nDTD_UNKNOWN_NOTATION=537\nDTD_STANDALONE_DEFAULTED=538\nDTD_XMLID_VALUE=539\nDTD_XMLID_TYPE=540\nHTML_STRUCURE_ERROR=800\nHTML_UNKNOWN_TAG=801\nRNGP_ANYNAME_ATTR_ANCESTOR=1000\nRNGP_ATTR_CONFLICT=1001\nRNGP_ATTRIBUTE_CHILDREN=1002\nRNGP_ATTRIBUTE_CONTENT=1003\nRNGP_ATTRIBUTE_EMPTY=1004\nRNGP_ATTRIBUTE_NOOP=1005\nRNGP_CHOICE_CONTENT=1006\nRNGP_CHOICE_EMPTY=1007\n";
static char __pyx_k_97[] = "RNGP_CREATE_FAILURE=1008\nRNGP_DATA_CONTENT=1009\nRNGP_DEF_CHOICE_AND_INTERLEAVE=1010\nRNGP_DEFINE_CREATE_FAILED=1011\nRNGP_DEFINE_EMPTY=1012\nRNGP_DEFINE_MISSING=1013\nRNGP_DEFINE_NAME_MISSING=1014\nRNGP_ELEM_CONTENT_EMPTY=1015\nRNGP_ELEM_CONTENT_ERROR=1016\nRNGP_ELEMENT_EMPTY=1017\nRNGP_ELEMENT_CONTENT=1018\nRNGP_ELEMENT_NAME=1019\nRNGP_ELEMENT_NO_CONTENT=1020\nRNGP_ELEM_TEXT_CONFLICT=1021\nRNGP_EMPTY=1022\nRNGP_EMPTY_CONSTRUCT=1023\nRNGP_EMPTY_CONTENT=1024\nRNGP_EMPTY_NOT_EMPTY=1025\nRNGP_ERROR_TYPE_LIB=1026\nRNGP_EXCEPT_EMPTY=1027\nRNGP_EXCEPT_MISSING=1028\nRNGP_EXCEPT_MULTIPLE=1029\nRNGP_EXCEPT_NO_CONTENT=1030\nRNGP_EXTERNALREF_EMTPY=1031\nRNGP_EXTERNAL_REF_FAILURE=1032\nRNGP_EXTERNALREF_RECURSE=1033\nRNGP_FORBIDDEN_ATTRIBUTE=1034\nRNGP_FOREIGN_ELEMENT=1035\nRNGP_GRAMMAR_CONTENT=1036\nRNGP_GRAMMAR_EMPTY=1037\nRNGP_GRAMMAR_MISSING=1038\nRNGP_GRAMMAR_NO_START=1039\nRNGP_GROUP_ATTR_CONFLICT=1040\nRNGP_HREF_ERROR=1041\nRNGP_INCLUDE_EMPTY=1042\nRNGP_INCLUDE_FAILURE=1043\nRNGP_INCLUDE_RECURSE=1044\nRNGP_INTERLEAVE_ADD=1045\nRNGP_INTERLEAVE_CREATE_FAILED=1046\nRNGP_INTERLEAVE_EMPTY=1047\nRNGP_INTERLEAVE_NO_CONTENT=1048\nRNGP_INVALID_DEFINE_NAME=1049\nRNGP_INVALID_URI=1050\nRNGP_INVALID_VALUE=1051\nRNGP_MISSING_HREF=1052\nRNGP_NAME_MISSING=1053\nRNGP_NEED_COMBINE=1054\nRNGP_NOTALLOWED_NOT_EMPTY=1055\nRNGP_NSNAME_ATTR_ANCESTOR=1056\nRNGP_NSNAME_NO_NS=1057\nRNGP_PARAM_FORBIDDEN=1058\nRNGP_PARAM_NAME_MISSING=1059\nRNGP_PARENTREF_CREATE_FAILED=1060\nRNGP_PARENTREF_NAME_INVALID=1061\nRNGP_PARENTREF_NO_NAME=1062\nRNGP_PARENTREF_NO_PARENT=1063\nRNGP_PARENTREF_NOT_EMPTY=1064\nRNGP_PARSE_ERROR=1065\nRNGP_PAT_ANYNAME_EXCEPT_ANYNAME=1066\nRNGP_PAT_ATTR_ATTR=1067\nRNGP_PAT_ATTR_ELEM=1068\nRNGP_PAT_DATA_EXCEPT_ATTR=1069\nRNGP_PAT_DATA_EXCEPT_ELEM=1070\nRNGP_PAT_DATA_EXCEPT_EMPTY=1071\nRNGP_PAT_DATA_EXCEPT_GROUP=1072\nRNGP_PAT_DATA_EXCEPT_INTERLEAVE=1073\nRNGP_PAT_DATA_EXCEPT_LIST=1074\nRNGP_PAT_DATA_EXCEPT_ONEMORE=1075\nRNGP_PAT_DATA_EXCEPT_REF=1076\nRNGP_PAT_DATA_EXCEPT_TEXT=1077\nRNGP_PAT_LIST_ATTR=1078\n";
static char __pyx_k_98[] = "RNGP_PAT_LIST_ELEM=1079\nRNGP_PAT_LIST_INTERLEAVE=1080\nRNGP_PAT_LIST_LIST=1081\nRNGP_PAT_LIST_REF=1082\nRNGP_PAT_LIST_TEXT=1083\nRNGP_PAT_NSNAME_EXCEPT_ANYNAME=1084\nRNGP_PAT_NSNAME_EXCEPT_NSNAME=1085\nRNGP_PAT_ONEMORE_GROUP_ATTR=1086\nRNGP_PAT_ONEMORE_INTERLEAVE_ATTR=1087\nRNGP_PAT_START_ATTR=1088\nRNGP_PAT_START_DATA=1089\nRNGP_PAT_START_EMPTY=1090\nRNGP_PAT_START_GROUP=1091\nRNGP_PAT_START_INTERLEAVE=1092\nRNGP_PAT_START_LIST=1093\nRNGP_PAT_START_ONEMORE=1094\nRNGP_PAT_START_TEXT=1095\nRNGP_PAT_START_VALUE=1096\nRNGP_PREFIX_UNDEFINED=1097\nRNGP_REF_CREATE_FAILED=1098\nRNGP_REF_CYCLE=1099\nRNGP_REF_NAME_INVALID=1100\nRNGP_REF_NO_DEF=1101\nRNGP_REF_NO_NAME=1102\nRNGP_REF_NOT_EMPTY=1103\nRNGP_START_CHOICE_AND_INTERLEAVE=1104\nRNGP_START_CONTENT=1105\nRNGP_START_EMPTY=1106\nRNGP_START_MISSING=1107\nRNGP_TEXT_EXPECTED=1108\nRNGP_TEXT_HAS_CHILD=1109\nRNGP_TYPE_MISSING=1110\nRNGP_TYPE_NOT_FOUND=1111\nRNGP_TYPE_VALUE=1112\nRNGP_UNKNOWN_ATTRIBUTE=1113\nRNGP_UNKNOWN_COMBINE=1114\nRNGP_UNKNOWN_CONSTRUCT=1115\nRNGP_UNKNOWN_TYPE_LIB=1116\nRNGP_URI_FRAGMENT=1117\nRNGP_URI_NOT_ABSOLUTE=1118\nRNGP_VALUE_EMPTY=1119\nRNGP_VALUE_NO_CONTENT=1120\nRNGP_XMLNS_NAME=1121\nRNGP_XML_NS=1122\nXPATH_EXPRESSION_OK=1200\nXPATH_NUMBER_ERROR=1201\nXPATH_UNFINISHED_LITERAL_ERROR=1202\nXPATH_START_LITERAL_ERROR=1203\nXPATH_VARIABLE_REF_ERROR=1204\nXPATH_UNDEF_VARIABLE_ERROR=1205\nXPATH_INVALID_PREDICATE_ERROR=1206\nXPATH_EXPR_ERROR=1207\nXPATH_UNCLOSED_ERROR=1208\nXPATH_UNKNOWN_FUNC_ERROR=1209\nXPATH_INVALID_OPERAND=1210\nXPATH_INVALID_TYPE=1211\nXPATH_INVALID_ARITY=1212\nXPATH_INVALID_CTXT_SIZE=1213\nXPATH_INVALID_CTXT_POSITION=1214\nXPATH_MEMORY_ERROR=1215\nXPTR_SYNTAX_ERROR=1216\nXPTR_RESOURCE_ERROR=1217\nXPTR_SUB_RESOURCE_ERROR=1218\nXPATH_UNDEF_PREFIX_ERROR=1219\nXPATH_ENCODING_ERROR=1220\nXPATH_INVALID_CHAR_ERROR=1221\nTREE_INVALID_HEX=1300\nTREE_INVALID_DEC=1301\nTREE_UNTERMINATED_ENTITY=1302\nTREE_NOT_UTF8=1303\nSAVE_NOT_UTF8=1400\nSAVE_CHAR_INVALID=1401\nSAVE_NO_DOCTYPE=1402\nSAVE_UNKNOWN_ENCODING=1403\n";
static char __pyx_k_99[] = "REGEXP_COMPILE_ERROR=1450\nIO_UNKNOWN=1500\nIO_EACCES=1501\nIO_EAGAIN=1502\nIO_EBADF=1503\nIO_EBADMSG=1504\nIO_EBUSY=1505\nIO_ECANCELED=1506\nIO_ECHILD=1507\nIO_EDEADLK=1508\nIO_EDOM=1509\nIO_EEXIST=1510\nIO_EFAULT=1511\nIO_EFBIG=1512\nIO_EINPROGRESS=1513\nIO_EINTR=1514\nIO_EINVAL=1515\nIO_EIO=1516\nIO_EISDIR=1517\nIO_EMFILE=1518\nIO_EMLINK=1519\nIO_EMSGSIZE=1520\nIO_ENAMETOOLONG=1521\nIO_ENFILE=1522\nIO_ENODEV=1523\nIO_ENOENT=1524\nIO_ENOEXEC=1525\nIO_ENOLCK=1526\nIO_ENOMEM=1527\nIO_ENOSPC=1528\nIO_ENOSYS=1529\nIO_ENOTDIR=1530\nIO_ENOTEMPTY=1531\nIO_ENOTSUP=1532\nIO_ENOTTY=1533\nIO_ENXIO=1534\nIO_EPERM=1535\nIO_EPIPE=1536\nIO_ERANGE=1537\nIO_EROFS=1538\nIO_ESPIPE=1539\nIO_ESRCH=1540\nIO_ETIMEDOUT=1541\nIO_EXDEV=1542\nIO_NETWORK_ATTEMPT=1543\nIO_ENCODER=1544\nIO_FLUSH=1545\nIO_WRITE=1546\nIO_NO_INPUT=1547\nIO_BUFFER_FULL=1548\nIO_LOAD_ERROR=1549\nIO_ENOTSOCK=1550\nIO_EISCONN=1551\nIO_ECONNREFUSED=1552\nIO_ENETUNREACH=1553\nIO_EADDRINUSE=1554\nIO_EALREADY=1555\nIO_EAFNOSUPPORT=1556\nXINCLUDE_RECURSION=1600\nXINCLUDE_PARSE_VALUE=1601\nXINCLUDE_ENTITY_DEF_MISMATCH=1602\nXINCLUDE_NO_HREF=1603\nXINCLUDE_NO_FALLBACK=1604\nXINCLUDE_HREF_URI=1605\nXINCLUDE_TEXT_FRAGMENT=1606\nXINCLUDE_TEXT_DOCUMENT=1607\nXINCLUDE_INVALID_CHAR=1608\nXINCLUDE_BUILD_FAILED=1609\nXINCLUDE_UNKNOWN_ENCODING=1610\nXINCLUDE_MULTIPLE_ROOT=1611\nXINCLUDE_XPTR_FAILED=1612\nXINCLUDE_XPTR_RESULT=1613\nXINCLUDE_INCLUDE_IN_INCLUDE=1614\nXINCLUDE_FALLBACKS_IN_INCLUDE=1615\nXINCLUDE_FALLBACK_NOT_IN_INCLUDE=1616\nXINCLUDE_DEPRECATED_NS=1617\nXINCLUDE_FRAGMENT_ID=1618\nCATALOG_MISSING_ATTR=1650\nCATALOG_ENTRY_BROKEN=1651\nCATALOG_PREFER_VALUE=1652\nCATALOG_NOT_CATALOG=1653\nCATALOG_RECURSION=1654\nSCHEMAP_PREFIX_UNDEFINED=1700\nSCHEMAP_ATTRFORMDEFAULT_VALUE=1701\nSCHEMAP_ATTRGRP_NONAME_NOREF=1702\nSCHEMAP_ATTR_NONAME_NOREF=1703\nSCHEMAP_COMPLEXTYPE_NONAME_NOREF=1704\nSCHEMAP_ELEMFORMDEFAULT_VALUE=1705\nSCHEMAP_ELEM_NONAME_NOREF=1706\nSCHEMAP_EXTENSION_NO_BASE=1707\nSCHEMAP_FACET_NO_VALUE=1708\nSCHEMAP_FAILED_BUILD_IMPORT=1709\n";
static char __pyx_k_100[] = "SCHEMAP_GROUP_NONAME_NOREF=1710\nSCHEMAP_IMPORT_NAMESPACE_NOT_URI=1711\nSCHEMAP_IMPORT_REDEFINE_NSNAME=1712\nSCHEMAP_IMPORT_SCHEMA_NOT_URI=1713\nSCHEMAP_INVALID_BOOLEAN=1714\nSCHEMAP_INVALID_ENUM=1715\nSCHEMAP_INVALID_FACET=1716\nSCHEMAP_INVALID_FACET_VALUE=1717\nSCHEMAP_INVALID_MAXOCCURS=1718\nSCHEMAP_INVALID_MINOCCURS=1719\nSCHEMAP_INVALID_REF_AND_SUBTYPE=1720\nSCHEMAP_INVALID_WHITE_SPACE=1721\nSCHEMAP_NOATTR_NOREF=1722\nSCHEMAP_NOTATION_NO_NAME=1723\nSCHEMAP_NOTYPE_NOREF=1724\nSCHEMAP_REF_AND_SUBTYPE=1725\nSCHEMAP_RESTRICTION_NONAME_NOREF=1726\nSCHEMAP_SIMPLETYPE_NONAME=1727\nSCHEMAP_TYPE_AND_SUBTYPE=1728\nSCHEMAP_UNKNOWN_ALL_CHILD=1729\nSCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD=1730\nSCHEMAP_UNKNOWN_ATTR_CHILD=1731\nSCHEMAP_UNKNOWN_ATTRGRP_CHILD=1732\nSCHEMAP_UNKNOWN_ATTRIBUTE_GROUP=1733\nSCHEMAP_UNKNOWN_BASE_TYPE=1734\nSCHEMAP_UNKNOWN_CHOICE_CHILD=1735\nSCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD=1736\nSCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD=1737\nSCHEMAP_UNKNOWN_ELEM_CHILD=1738\nSCHEMAP_UNKNOWN_EXTENSION_CHILD=1739\nSCHEMAP_UNKNOWN_FACET_CHILD=1740\nSCHEMAP_UNKNOWN_FACET_TYPE=1741\nSCHEMAP_UNKNOWN_GROUP_CHILD=1742\nSCHEMAP_UNKNOWN_IMPORT_CHILD=1743\nSCHEMAP_UNKNOWN_LIST_CHILD=1744\nSCHEMAP_UNKNOWN_NOTATION_CHILD=1745\nSCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD=1746\nSCHEMAP_UNKNOWN_REF=1747\nSCHEMAP_UNKNOWN_RESTRICTION_CHILD=1748\nSCHEMAP_UNKNOWN_SCHEMAS_CHILD=1749\nSCHEMAP_UNKNOWN_SEQUENCE_CHILD=1750\nSCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD=1751\nSCHEMAP_UNKNOWN_SIMPLETYPE_CHILD=1752\nSCHEMAP_UNKNOWN_TYPE=1753\nSCHEMAP_UNKNOWN_UNION_CHILD=1754\nSCHEMAP_ELEM_DEFAULT_FIXED=1755\nSCHEMAP_REGEXP_INVALID=1756\nSCHEMAP_FAILED_LOAD=1757\nSCHEMAP_NOTHING_TO_PARSE=1758\nSCHEMAP_NOROOT=1759\nSCHEMAP_REDEFINED_GROUP=1760\nSCHEMAP_REDEFINED_TYPE=1761\nSCHEMAP_REDEFINED_ELEMENT=1762\nSCHEMAP_REDEFINED_ATTRGROUP=1763\nSCHEMAP_REDEFINED_ATTR=1764\nSCHEMAP_REDEFINED_NOTATION=1765\nSCHEMAP_FAILED_PARSE=1766\nSCHEMAP_UNKNOWN_PREFIX=1767\nSCHEMAP_DEF_AND_PREFIX=1768\nSCHEMAP_UNKNOWN_INCLUDE_CHILD=1769\nSCHEMAP_INCLUDE_SCHEMA_NOT_URI=1770\n";
static char __pyx_k_101[] = "SCHEMAP_INCLUDE_SCHEMA_NO_URI=1771\nSCHEMAP_NOT_SCHEMA=1772\nSCHEMAP_UNKNOWN_MEMBER_TYPE=1773\nSCHEMAP_INVALID_ATTR_USE=1774\nSCHEMAP_RECURSIVE=1775\nSCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE=1776\nSCHEMAP_INVALID_ATTR_COMBINATION=1777\nSCHEMAP_INVALID_ATTR_INLINE_COMBINATION=1778\nSCHEMAP_MISSING_SIMPLETYPE_CHILD=1779\nSCHEMAP_INVALID_ATTR_NAME=1780\nSCHEMAP_REF_AND_CONTENT=1781\nSCHEMAP_CT_PROPS_CORRECT_1=1782\nSCHEMAP_CT_PROPS_CORRECT_2=1783\nSCHEMAP_CT_PROPS_CORRECT_3=1784\nSCHEMAP_CT_PROPS_CORRECT_4=1785\nSCHEMAP_CT_PROPS_CORRECT_5=1786\nSCHEMAP_DERIVATION_OK_RESTRICTION_1=1787\nSCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1=1788\nSCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2=1789\nSCHEMAP_DERIVATION_OK_RESTRICTION_2_2=1790\nSCHEMAP_DERIVATION_OK_RESTRICTION_3=1791\nSCHEMAP_WILDCARD_INVALID_NS_MEMBER=1792\nSCHEMAP_INTERSECTION_NOT_EXPRESSIBLE=1793\nSCHEMAP_UNION_NOT_EXPRESSIBLE=1794\nSCHEMAP_SRC_IMPORT_3_1=1795\nSCHEMAP_SRC_IMPORT_3_2=1796\nSCHEMAP_DERIVATION_OK_RESTRICTION_4_1=1797\nSCHEMAP_DERIVATION_OK_RESTRICTION_4_2=1798\nSCHEMAP_DERIVATION_OK_RESTRICTION_4_3=1799\nSCHEMAP_COS_CT_EXTENDS_1_3=1800\nSCHEMAV_NOROOT=1801\nSCHEMAV_UNDECLAREDELEM=1802\nSCHEMAV_NOTTOPLEVEL=1803\nSCHEMAV_MISSING=1804\nSCHEMAV_WRONGELEM=1805\nSCHEMAV_NOTYPE=1806\nSCHEMAV_NOROLLBACK=1807\nSCHEMAV_ISABSTRACT=1808\nSCHEMAV_NOTEMPTY=1809\nSCHEMAV_ELEMCONT=1810\nSCHEMAV_HAVEDEFAULT=1811\nSCHEMAV_NOTNILLABLE=1812\nSCHEMAV_EXTRACONTENT=1813\nSCHEMAV_INVALIDATTR=1814\nSCHEMAV_INVALIDELEM=1815\nSCHEMAV_NOTDETERMINIST=1816\nSCHEMAV_CONSTRUCT=1817\nSCHEMAV_INTERNAL=1818\nSCHEMAV_NOTSIMPLE=1819\nSCHEMAV_ATTRUNKNOWN=1820\nSCHEMAV_ATTRINVALID=1821\nSCHEMAV_VALUE=1822\nSCHEMAV_FACET=1823\nSCHEMAV_CVC_DATATYPE_VALID_1_2_1=1824\nSCHEMAV_CVC_DATATYPE_VALID_1_2_2=1825\nSCHEMAV_CVC_DATATYPE_VALID_1_2_3=1826\nSCHEMAV_CVC_TYPE_3_1_1=1827\nSCHEMAV_CVC_TYPE_3_1_2=1828\nSCHEMAV_CVC_FACET_VALID=1829\nSCHEMAV_CVC_LENGTH_VALID=1830\nSCHEMAV_CVC_MINLENGTH_VALID=1831\nSCHEMAV_CVC_MAXLENGTH_VALID=1832\nSCHEMAV_CVC_MININCLUSIVE_VALID=1833\n";
static char __pyx_k_102[] = "SCHEMAV_CVC_MAXINCLUSIVE_VALID=1834\nSCHEMAV_CVC_MINEXCLUSIVE_VALID=1835\nSCHEMAV_CVC_MAXEXCLUSIVE_VALID=1836\nSCHEMAV_CVC_TOTALDIGITS_VALID=1837\nSCHEMAV_CVC_FRACTIONDIGITS_VALID=1838\nSCHEMAV_CVC_PATTERN_VALID=1839\nSCHEMAV_CVC_ENUMERATION_VALID=1840\nSCHEMAV_CVC_COMPLEX_TYPE_2_1=1841\nSCHEMAV_CVC_COMPLEX_TYPE_2_2=1842\nSCHEMAV_CVC_COMPLEX_TYPE_2_3=1843\nSCHEMAV_CVC_COMPLEX_TYPE_2_4=1844\nSCHEMAV_CVC_ELT_1=1845\nSCHEMAV_CVC_ELT_2=1846\nSCHEMAV_CVC_ELT_3_1=1847\nSCHEMAV_CVC_ELT_3_2_1=1848\nSCHEMAV_CVC_ELT_3_2_2=1849\nSCHEMAV_CVC_ELT_4_1=1850\nSCHEMAV_CVC_ELT_4_2=1851\nSCHEMAV_CVC_ELT_4_3=1852\nSCHEMAV_CVC_ELT_5_1_1=1853\nSCHEMAV_CVC_ELT_5_1_2=1854\nSCHEMAV_CVC_ELT_5_2_1=1855\nSCHEMAV_CVC_ELT_5_2_2_1=1856\nSCHEMAV_CVC_ELT_5_2_2_2_1=1857\nSCHEMAV_CVC_ELT_5_2_2_2_2=1858\nSCHEMAV_CVC_ELT_6=1859\nSCHEMAV_CVC_ELT_7=1860\nSCHEMAV_CVC_ATTRIBUTE_1=1861\nSCHEMAV_CVC_ATTRIBUTE_2=1862\nSCHEMAV_CVC_ATTRIBUTE_3=1863\nSCHEMAV_CVC_ATTRIBUTE_4=1864\nSCHEMAV_CVC_COMPLEX_TYPE_3_1=1865\nSCHEMAV_CVC_COMPLEX_TYPE_3_2_1=1866\nSCHEMAV_CVC_COMPLEX_TYPE_3_2_2=1867\nSCHEMAV_CVC_COMPLEX_TYPE_4=1868\nSCHEMAV_CVC_COMPLEX_TYPE_5_1=1869\nSCHEMAV_CVC_COMPLEX_TYPE_5_2=1870\nSCHEMAV_ELEMENT_CONTENT=1871\nSCHEMAV_DOCUMENT_ELEMENT_MISSING=1872\nSCHEMAV_CVC_COMPLEX_TYPE_1=1873\nSCHEMAV_CVC_AU=1874\nSCHEMAV_CVC_TYPE_1=1875\nSCHEMAV_CVC_TYPE_2=1876\nSCHEMAV_CVC_IDC=1877\nSCHEMAV_CVC_WILDCARD=1878\nSCHEMAV_MISC=1879\nXPTR_UNKNOWN_SCHEME=1900\nXPTR_CHILDSEQ_START=1901\nXPTR_EVAL_FAILED=1902\nXPTR_EXTRA_OBJECTS=1903\nC14N_CREATE_CTXT=1950\nC14N_REQUIRES_UTF8=1951\nC14N_CREATE_STACK=1952\nC14N_INVALID_NODE=1953\nC14N_UNKNOW_NODE=1954\nC14N_RELATIVE_NAMESPACE=1955\nFTP_PASV_ANSWER=2000\nFTP_EPSV_ANSWER=2001\nFTP_ACCNT=2002\nFTP_URL_SYNTAX=2003\nHTTP_URL_SYNTAX=2020\nHTTP_USE_IP=2021\nHTTP_UNKNOWN_HOST=2022\nSCHEMAP_SRC_SIMPLE_TYPE_1=3000\nSCHEMAP_SRC_SIMPLE_TYPE_2=3001\nSCHEMAP_SRC_SIMPLE_TYPE_3=3002\nSCHEMAP_SRC_SIMPLE_TYPE_4=3003\nSCHEMAP_SRC_RESOLVE=3004\nSCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE=3005\n";
static char __pyx_k_103[] = "SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE=3006\nSCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES=3007\nSCHEMAP_ST_PROPS_CORRECT_1=3008\nSCHEMAP_ST_PROPS_CORRECT_2=3009\nSCHEMAP_ST_PROPS_CORRECT_3=3010\nSCHEMAP_COS_ST_RESTRICTS_1_1=3011\nSCHEMAP_COS_ST_RESTRICTS_1_2=3012\nSCHEMAP_COS_ST_RESTRICTS_1_3_1=3013\nSCHEMAP_COS_ST_RESTRICTS_1_3_2=3014\nSCHEMAP_COS_ST_RESTRICTS_2_1=3015\nSCHEMAP_COS_ST_RESTRICTS_2_3_1_1=3016\nSCHEMAP_COS_ST_RESTRICTS_2_3_1_2=3017\nSCHEMAP_COS_ST_RESTRICTS_2_3_2_1=3018\nSCHEMAP_COS_ST_RESTRICTS_2_3_2_2=3019\nSCHEMAP_COS_ST_RESTRICTS_2_3_2_3=3020\nSCHEMAP_COS_ST_RESTRICTS_2_3_2_4=3021\nSCHEMAP_COS_ST_RESTRICTS_2_3_2_5=3022\nSCHEMAP_COS_ST_RESTRICTS_3_1=3023\nSCHEMAP_COS_ST_RESTRICTS_3_3_1=3024\nSCHEMAP_COS_ST_RESTRICTS_3_3_1_2=3025\nSCHEMAP_COS_ST_RESTRICTS_3_3_2_2=3026\nSCHEMAP_COS_ST_RESTRICTS_3_3_2_1=3027\nSCHEMAP_COS_ST_RESTRICTS_3_3_2_3=3028\nSCHEMAP_COS_ST_RESTRICTS_3_3_2_4=3029\nSCHEMAP_COS_ST_RESTRICTS_3_3_2_5=3030\nSCHEMAP_COS_ST_DERIVED_OK_2_1=3031\nSCHEMAP_COS_ST_DERIVED_OK_2_2=3032\nSCHEMAP_S4S_ELEM_NOT_ALLOWED=3033\nSCHEMAP_S4S_ELEM_MISSING=3034\nSCHEMAP_S4S_ATTR_NOT_ALLOWED=3035\nSCHEMAP_S4S_ATTR_MISSING=3036\nSCHEMAP_S4S_ATTR_INVALID_VALUE=3037\nSCHEMAP_SRC_ELEMENT_1=3038\nSCHEMAP_SRC_ELEMENT_2_1=3039\nSCHEMAP_SRC_ELEMENT_2_2=3040\nSCHEMAP_SRC_ELEMENT_3=3041\nSCHEMAP_P_PROPS_CORRECT_1=3042\nSCHEMAP_P_PROPS_CORRECT_2_1=3043\nSCHEMAP_P_PROPS_CORRECT_2_2=3044\nSCHEMAP_E_PROPS_CORRECT_2=3045\nSCHEMAP_E_PROPS_CORRECT_3=3046\nSCHEMAP_E_PROPS_CORRECT_4=3047\nSCHEMAP_E_PROPS_CORRECT_5=3048\nSCHEMAP_E_PROPS_CORRECT_6=3049\nSCHEMAP_SRC_INCLUDE=3050\nSCHEMAP_SRC_ATTRIBUTE_1=3051\nSCHEMAP_SRC_ATTRIBUTE_2=3052\nSCHEMAP_SRC_ATTRIBUTE_3_1=3053\nSCHEMAP_SRC_ATTRIBUTE_3_2=3054\nSCHEMAP_SRC_ATTRIBUTE_4=3055\nSCHEMAP_NO_XMLNS=3056\nSCHEMAP_NO_XSI=3057\nSCHEMAP_COS_VALID_DEFAULT_1=3058\nSCHEMAP_COS_VALID_DEFAULT_2_1=3059\nSCHEMAP_COS_VALID_DEFAULT_2_2_1=3060\nSCHEMAP_COS_VALID_DEFAULT_2_2_2=3061\nSCHEMAP_CVC_SIMPLE_TYPE=3062\nSCHEMAP_COS_CT_EXTENDS_1_1=3063\nSCHEMAP_SRC_IMPORT_1_1=3064\n";
static char __pyx_k_104[] = "SCHEMAP_SRC_IMPORT_1_2=3065\nSCHEMAP_SRC_IMPORT_2=3066\nSCHEMAP_SRC_IMPORT_2_1=3067\nSCHEMAP_SRC_IMPORT_2_2=3068\nSCHEMAP_INTERNAL=3069\nSCHEMAP_NOT_DETERMINISTIC=3070\nSCHEMAP_SRC_ATTRIBUTE_GROUP_1=3071\nSCHEMAP_SRC_ATTRIBUTE_GROUP_2=3072\nSCHEMAP_SRC_ATTRIBUTE_GROUP_3=3073\nSCHEMAP_MG_PROPS_CORRECT_1=3074\nSCHEMAP_MG_PROPS_CORRECT_2=3075\nSCHEMAP_SRC_CT_1=3076\nSCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3=3077\nSCHEMAP_AU_PROPS_CORRECT_2=3078\nSCHEMAP_A_PROPS_CORRECT_2=3079\nSCHEMAP_C_PROPS_CORRECT=3080\nSCHEMAP_SRC_REDEFINE=3081\nSCHEMAP_SRC_IMPORT=3082\nSCHEMAP_WARN_SKIP_SCHEMA=3083\nSCHEMAP_WARN_UNLOCATED_SCHEMA=3084\nSCHEMAP_WARN_ATTR_REDECL_PROH=3085\nSCHEMAP_WARN_ATTR_POINTLESS_PROH=3086\nSCHEMAP_AG_PROPS_CORRECT=3087\nSCHEMAP_COS_CT_EXTENDS_1_2=3088\nSCHEMAP_AU_PROPS_CORRECT=3089\nSCHEMAP_A_PROPS_CORRECT_3=3090\nSCHEMAP_COS_ALL_LIMITED=3091\nSCHEMATRONV_ASSERT=4000\nSCHEMATRONV_REPORT=4001\nMODULE_OPEN=4900\nMODULE_CLOSE=4901\nCHECK_FOUND_ELEMENT=5000\nCHECK_FOUND_ATTRIBUTE=5001\nCHECK_FOUND_TEXT=5002\nCHECK_FOUND_CDATA=5003\nCHECK_FOUND_ENTITYREF=5004\nCHECK_FOUND_ENTITY=5005\nCHECK_FOUND_PI=5006\nCHECK_FOUND_COMMENT=5007\nCHECK_FOUND_DOCTYPE=5008\nCHECK_FOUND_FRAGMENT=5009\nCHECK_FOUND_NOTATION=5010\nCHECK_UNKNOWN_NODE=5011\nCHECK_ENTITY_TYPE=5012\nCHECK_NO_PARENT=5013\nCHECK_NO_DOC=5014\nCHECK_NO_NAME=5015\nCHECK_NO_ELEM=5016\nCHECK_WRONG_DOC=5017\nCHECK_NO_PREV=5018\nCHECK_WRONG_PREV=5019\nCHECK_NO_NEXT=5020\nCHECK_WRONG_NEXT=5021\nCHECK_NOT_DTD=5022\nCHECK_NOT_ATTR=5023\nCHECK_NOT_ATTR_DECL=5024\nCHECK_NOT_ELEM_DECL=5025\nCHECK_NOT_ENTITY_DECL=5026\nCHECK_NOT_NS_DECL=5027\nCHECK_NO_HREF=5028\nCHECK_WRONG_PARENT=5029\nCHECK_NS_SCOPE=5030\nCHECK_NS_ANCESTOR=5031\nCHECK_NOT_UTF8=5032\nCHECK_NO_DICT=5033\nCHECK_NOT_NCNAME=5034\nCHECK_OUTSIDE_DICT=5035\nCHECK_WRONG_NAME=5036\nCHECK_NAME_NOT_NULL=5037\nI18N_NO_NAME=6000\nI18N_NO_HANDLER=6001\nI18N_EXCESS_HANDLER=6002\nI18N_CONV_FAILED=6003\nI18N_NO_OUTPUT=6004\nCHECK_=6005\nCHECK_X=6006\n";
static char __pyx_k_105[] = "RELAXNG_OK=0\nRELAXNG_ERR_MEMORY=1\nRELAXNG_ERR_TYPE=2\nRELAXNG_ERR_TYPEVAL=3\nRELAXNG_ERR_DUPID=4\nRELAXNG_ERR_TYPECMP=5\nRELAXNG_ERR_NOSTATE=6\nRELAXNG_ERR_NODEFINE=7\nRELAXNG_ERR_LISTEXTRA=8\nRELAXNG_ERR_LISTEMPTY=9\nRELAXNG_ERR_INTERNODATA=10\nRELAXNG_ERR_INTERSEQ=11\nRELAXNG_ERR_INTEREXTRA=12\nRELAXNG_ERR_ELEMNAME=13\nRELAXNG_ERR_ATTRNAME=14\nRELAXNG_ERR_ELEMNONS=15\nRELAXNG_ERR_ATTRNONS=16\nRELAXNG_ERR_ELEMWRONGNS=17\nRELAXNG_ERR_ATTRWRONGNS=18\nRELAXNG_ERR_ELEMEXTRANS=19\nRELAXNG_ERR_ATTREXTRANS=20\nRELAXNG_ERR_ELEMNOTEMPTY=21\nRELAXNG_ERR_NOELEM=22\nRELAXNG_ERR_NOTELEM=23\nRELAXNG_ERR_ATTRVALID=24\nRELAXNG_ERR_CONTENTVALID=25\nRELAXNG_ERR_EXTRACONTENT=26\nRELAXNG_ERR_INVALIDATTR=27\nRELAXNG_ERR_DATAELEM=28\nRELAXNG_ERR_VALELEM=29\nRELAXNG_ERR_LISTELEM=30\nRELAXNG_ERR_DATATYPE=31\nRELAXNG_ERR_VALUE=32\nRELAXNG_ERR_LIST=33\nRELAXNG_ERR_NOGRAMMAR=34\nRELAXNG_ERR_EXTRADATA=35\nRELAXNG_ERR_LACKDATA=36\nRELAXNG_ERR_INTERNAL=37\nRELAXNG_ERR_ELEMWRONG=38\nRELAXNG_ERR_TEXTWRONG=39\n";
static char __pyx_k_107[] = "Base class of lxml registry errors.\n    ";
static char __pyx_k_109[] = "Error registering a namespace extension.\n    ";
static char __pyx_k_110[] = "Syntax error while parsing an XML document.\n\n    For compatibility with ElementTree 1.3 and later.\n    ";
static char __pyx_k_111[] = "Syntax error while parsing an XML document.\n    ";
static char __pyx_k_112[] = "Internal lxml parser error.\n    ";
static char __pyx_k_159[] = "Error during XInclude processing.\n    ";
static char __pyx_k_160[] = "Base class of all XPath errors.\n    ";
static char __pyx_k_161[] = "Error during XPath evaluation.\n    ";
static char __pyx_k_162[] = "Internal error looking up an XPath extension function.\n    ";
static char __pyx_k_163[] = "Error handling an XPath result.\n    ";
static char __pyx_k_164[] = "";
static char __pyx_k_165[] = "";
static char __pyx_k_175[] = "(\"[^\"]*\")|('[^']*')";
static char __pyx_k_176[] = "({[^}]+})";
static char __pyx_k_179[] = "Base class of all XSLT errors.\n    ";
static char __pyx_k_180[] = "Error parsing a stylesheet document.\n    ";
static char __pyx_k_181[] = "Error running an XSL transformation.\n    ";
static char __pyx_k_182[] = "Error serialising an XSLT result.\n    ";
static char __pyx_k_183[] = "Error registering an XSLT extension.\n    ";
static char __pyx_k_193[] = "\\s+(\\w+)\\s*=\\s*[\"']([^\"']+)[\"']";
static char __pyx_k_194[] = "\\s+href\\s*=\\s*[\"']([^\"']+)[\"']";
static char __pyx_k_195[] = "Validation error.\n\n    Raised by all document validators when their ``assertValid(tree)``\n    method fails.\n    ";
static char __pyx_k_196[] = "Base class for DTD errors.\n    ";
static char __pyx_k_197[] = "Error while parsing a DTD.\n    ";
static char __pyx_k_198[] = "Error while validating an XML document with a DTD.\n    ";
static char __pyx_k_199[] = "Base class for RelaxNG errors.\n    ";
static char __pyx_k_200[] = "Error while parsing an XML document as RelaxNG.\n    ";
static char __pyx_k_202[] = "Error while validating an XML document with a RelaxNG schema.\n    ";
static char __pyx_k_203[] = "Base class of all XML Schema errors\n    ";
static char __pyx_k_204[] = "Error while parsing an XML document as XML Schema.\n    ";
static char __pyx_k_206[] = "Error while validating an XML document with an XML Schema.\n    ";
static char __pyx_k_207[] = "Base class of all Schematron errors.\n    ";
static char __pyx_k_209[] = "Error while parsing an XML document as Schematron schema.\n    ";
static char __pyx_k_211[] = "Error while validating an XML document with a Schematron schema.\n    ";
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_100;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_neg_300;
static PyObject *__pyx_int_neg_200;
static PyObject *__pyx_int_neg_100;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_32768;
static char __pyx_k___init__[] = "__init__";
static PyObject *__pyx_kp___init__;
static char __pyx_k___str__[] = "__str__";
static PyObject *__pyx_kp___str__;
static char __pyx_k___hash__[] = "__hash__";
static PyObject *__pyx_kp___hash__;
static char __pyx_k___richcmp__[] = "__richcmp__";
static PyObject *__pyx_kp___richcmp__;
static char __pyx_k___dealloc__[] = "__dealloc__";
static PyObject *__pyx_kp___dealloc__;
static char __pyx_k__init[] = "_init";
static PyObject *__pyx_kp__init;
static char __pyx_k___setitem__[] = "__setitem__";
static PyObject *__pyx_kp___setitem__;
static char __pyx_k___delitem__[] = "__delitem__";
static PyObject *__pyx_kp___delitem__;
static char __pyx_k___deepcopy__[] = "__deepcopy__";
static PyObject *__pyx_kp___deepcopy__;
static char __pyx_k___copy__[] = "__copy__";
static PyObject *__pyx_kp___copy__;
static char __pyx_k_set[] = "set";
static PyObject *__pyx_kp_set;
static char __pyx_k_append[] = "append";
static PyObject *__pyx_kp_append;
static char __pyx_k_addnext[] = "addnext";
static PyObject *__pyx_kp_addnext;
static char __pyx_k_addprevious[] = "addprevious";
static PyObject *__pyx_kp_addprevious;
static char __pyx_k_extend[] = "extend";
static PyObject *__pyx_kp_extend;
static char __pyx_k_clear[] = "clear";
static PyObject *__pyx_kp_clear;
static char __pyx_k_insert[] = "insert";
static PyObject *__pyx_kp_insert;
static char __pyx_k_remove[] = "remove";
static PyObject *__pyx_kp_remove;
static char __pyx_k_replace[] = "replace";
static PyObject *__pyx_kp_replace;
static char __pyx_k___repr__[] = "__repr__";
static PyObject *__pyx_kp___repr__;
static char __pyx_k___getitem__[] = "__getitem__";
static PyObject *__pyx_kp___getitem__;
static char __pyx_k___len__[] = "__len__";
static PyObject *__pyx_kp___len__;
static char __pyx_k___nonzero__[] = "__nonzero__";
static PyObject *__pyx_kp___nonzero__;
static char __pyx_k___contains__[] = "__contains__";
static PyObject *__pyx_kp___contains__;
static char __pyx_k___iter__[] = "__iter__";
static PyObject *__pyx_kp___iter__;
static char __pyx_k___reversed__[] = "__reversed__";
static PyObject *__pyx_kp___reversed__;
static char __pyx_k_index[] = "index";
static PyObject *__pyx_kp_index;
static char __pyx_k_get[] = "get";
static PyObject *__pyx_kp_get;
static char __pyx_k_keys[] = "keys";
static PyObject *__pyx_kp_keys;
static char __pyx_k_values[] = "values";
static PyObject *__pyx_kp_values;
static char __pyx_k_items[] = "items";
static PyObject *__pyx_kp_items;
static char __pyx_k_getchildren[] = "getchildren";
static PyObject *__pyx_kp_getchildren;
static char __pyx_k_getparent[] = "getparent";
static PyObject *__pyx_kp_getparent;
static char __pyx_k_getnext[] = "getnext";
static PyObject *__pyx_kp_getnext;
static char __pyx_k_getprevious[] = "getprevious";
static PyObject *__pyx_kp_getprevious;
static char __pyx_k_itersiblings[] = "itersiblings";
static PyObject *__pyx_kp_itersiblings;
static char __pyx_k_iterancestors[] = "iterancestors";
static PyObject *__pyx_kp_iterancestors;
static char __pyx_k_iterdescendants[] = "iterdescendants";
static PyObject *__pyx_kp_iterdescendants;
static char __pyx_k_iterchildren[] = "iterchildren";
static PyObject *__pyx_kp_iterchildren;
static char __pyx_k_getroottree[] = "getroottree";
static PyObject *__pyx_kp_getroottree;
static char __pyx_k_getiterator[] = "getiterator";
static PyObject *__pyx_kp_getiterator;
static char __pyx_k_iter[] = "iter";
static PyObject *__pyx_kp_iter;
static char __pyx_k_itertext[] = "itertext";
static PyObject *__pyx_kp_itertext;
static char __pyx_k_makeelement[] = "makeelement";
static PyObject *__pyx_kp_makeelement;
static char __pyx_k_find[] = "find";
static PyObject *__pyx_kp_find;
static char __pyx_k_findtext[] = "findtext";
static PyObject *__pyx_kp_findtext;
static char __pyx_k_findall[] = "findall";
static PyObject *__pyx_kp_findall;
static char __pyx_k_iterfind[] = "iterfind";
static PyObject *__pyx_kp_iterfind;
static char __pyx_k_xpath[] = "xpath";
static PyObject *__pyx_kp_xpath;
static char __pyx_k_parse[] = "parse";
static PyObject *__pyx_kp_parse;
static char __pyx_k__setroot[] = "_setroot";
static PyObject *__pyx_kp__setroot;
static char __pyx_k_getroot[] = "getroot";
static PyObject *__pyx_kp_getroot;
static char __pyx_k_write[] = "write";
static PyObject *__pyx_kp_write;
static char __pyx_k_getpath[] = "getpath";
static PyObject *__pyx_kp_getpath;
static char __pyx_k_xslt[] = "xslt";
static PyObject *__pyx_kp_xslt;
static char __pyx_k_relaxng[] = "relaxng";
static PyObject *__pyx_kp_relaxng;
static char __pyx_k_xmlschema[] = "xmlschema";
static PyObject *__pyx_kp_xmlschema;
static char __pyx_k_xinclude[] = "xinclude";
static PyObject *__pyx_kp_xinclude;
static char __pyx_k_20[] = "write_c14n";
static PyObject *__pyx_kp_20;
static char __pyx_k_update[] = "update";
static PyObject *__pyx_kp_update;
static char __pyx_k_pop[] = "pop";
static PyObject *__pyx_kp_pop;
static char __pyx_k_iterkeys[] = "iterkeys";
static PyObject *__pyx_kp_iterkeys;
static char __pyx_k_itervalues[] = "itervalues";
static PyObject *__pyx_kp_itervalues;
static char __pyx_k_iteritems[] = "iteritems";
static PyObject *__pyx_kp_iteritems;
static char __pyx_k_has_key[] = "has_key";
static PyObject *__pyx_kp_has_key;
static char __pyx_k___next__[] = "__next__";
static PyObject *__pyx_kp___next__;
static char __pyx_k_copy[] = "copy";
static PyObject *__pyx_kp_copy;
static char __pyx_k_filter_domains[] = "filter_domains";
static PyObject *__pyx_kp_filter_domains;
static char __pyx_k_filter_types[] = "filter_types";
static PyObject *__pyx_kp_filter_types;
static char __pyx_k_filter_levels[] = "filter_levels";
static PyObject *__pyx_kp_filter_levels;
static char __pyx_k_filter_from_level[] = "filter_from_level";
static PyObject *__pyx_kp_filter_from_level;
static char __pyx_k_filter_from_fatals[] = "filter_from_fatals";
static PyObject *__pyx_kp_filter_from_fatals;
static char __pyx_k_filter_from_errors[] = "filter_from_errors";
static PyObject *__pyx_kp_filter_from_errors;
static char __pyx_k_21[] = "filter_from_warnings";
static PyObject *__pyx_kp_21;
static char __pyx_k_receive[] = "receive";
static PyObject *__pyx_kp_receive;
static char __pyx_k_log[] = "log";
static PyObject *__pyx_kp_log;
static char __pyx_k___cinit__[] = "__cinit__";
static PyObject *__pyx_kp___cinit__;
static char __pyx_k_set_fallback[] = "set_fallback";
static PyObject *__pyx_kp_set_fallback;
static char __pyx_k_lookup[] = "lookup";
static PyObject *__pyx_kp_lookup;
static char __pyx_k_get_namespace[] = "get_namespace";
static PyObject *__pyx_kp_get_namespace;
static char __pyx_k_resolve[] = "resolve";
static PyObject *__pyx_kp_resolve;
static char __pyx_k_resolve_empty[] = "resolve_empty";
static PyObject *__pyx_kp_resolve_empty;
static char __pyx_k_resolve_string[] = "resolve_string";
static PyObject *__pyx_kp_resolve_string;
static char __pyx_k_resolve_filename[] = "resolve_filename";
static PyObject *__pyx_kp_resolve_filename;
static char __pyx_k_resolve_file[] = "resolve_file";
static PyObject *__pyx_kp_resolve_file;
static char __pyx_k_add[] = "add";
static PyObject *__pyx_kp_add;
static char __pyx_k_27[] = "setElementClassLookup";
static PyObject *__pyx_kp_27;
static char __pyx_k_28[] = "set_element_class_lookup";
static PyObject *__pyx_kp_28;
static char __pyx_k_feed[] = "feed";
static PyObject *__pyx_kp_feed;
static char __pyx_k_close[] = "close";
static PyObject *__pyx_kp_close;
static char __pyx_k_data[] = "data";
static PyObject *__pyx_kp_data;
static char __pyx_k_start[] = "start";
static PyObject *__pyx_kp_start;
static char __pyx_k_end[] = "end";
static PyObject *__pyx_kp_end;
static char __pyx_k_pi[] = "pi";
static PyObject *__pyx_kp_pi;
static char __pyx_k_comment[] = "comment";
static PyObject *__pyx_kp_comment;
static char __pyx_k___cmp__[] = "__cmp__";
static PyObject *__pyx_kp___cmp__;
static char __pyx_k___call__[] = "__call__";
static PyObject *__pyx_kp___call__;
static char __pyx_k_test[] = "test";
static PyObject *__pyx_kp_test;
static char __pyx_k_match[] = "match";
static PyObject *__pyx_kp_match;
static char __pyx_k_evaluate[] = "evaluate";
static PyObject *__pyx_kp_evaluate;
static char __pyx_k_register_namespace[] = "register_namespace";
static PyObject *__pyx_kp_register_namespace;
static char __pyx_k_register_namespaces[] = "register_namespaces";
static PyObject *__pyx_kp_register_namespaces;
static char __pyx_k_DENY_ALL[] = "DENY_ALL";
static PyObject *__pyx_kp_DENY_ALL;
static char __pyx_k_DENY_WRITE[] = "DENY_WRITE";
static PyObject *__pyx_kp_DENY_WRITE;
static char __pyx_k_apply[] = "apply";
static PyObject *__pyx_kp_apply;
static char __pyx_k_tostring[] = "tostring";
static PyObject *__pyx_kp_tostring;
static char __pyx_k___unicode__[] = "__unicode__";
static PyObject *__pyx_kp___unicode__;
static char __pyx_k___getbuffer__[] = "__getbuffer__";
static PyObject *__pyx_kp___getbuffer__;
static char __pyx_k___releasebuffer__[] = "__releasebuffer__";
static PyObject *__pyx_kp___releasebuffer__;
static char __pyx_k_parseXSL[] = "parseXSL";
static PyObject *__pyx_kp_parseXSL;
static char __pyx_k_execute[] = "execute";
static PyObject *__pyx_kp_execute;
static char __pyx_k_apply_templates[] = "apply_templates";
static PyObject *__pyx_kp_apply_templates;
static char __pyx_k_validate[] = "validate";
static PyObject *__pyx_kp_validate;
static char __pyx_k_assertValid[] = "assertValid";
static PyObject *__pyx_kp_assertValid;
static char __pyx_k_assert_[] = "assert_";
static PyObject *__pyx_kp_assert_;
static char __pyx_k_self[] = "self";
static PyObject *__pyx_kp_self;
static char __pyx_k_message[] = "message";
static PyObject *__pyx_kp_message;
static char __pyx_k_error_log[] = "error_log";
static PyObject *__pyx_kp_error_log;
static char __pyx_k_text_or_uri[] = "text_or_uri";
static PyObject *__pyx_kp_text_or_uri;
static char __pyx_k_tag[] = "tag";
static PyObject *__pyx_kp_tag;
static char __pyx_k_one[] = "one";
static PyObject *__pyx_kp_one;
static char __pyx_k_other[] = "other";
static PyObject *__pyx_kp_other;
static char __pyx_k_op[] = "op";
static PyObject *__pyx_kp_op;
static char __pyx_k_tree[] = "tree";
static PyObject *__pyx_kp_tree;
static char __pyx_k_url[] = "url";
static PyObject *__pyx_kp_url;
static char __pyx_k_x[] = "x";
static PyObject *__pyx_kp_x;
static char __pyx_k_value[] = "value";
static PyObject *__pyx_kp_value;
static char __pyx_k_memo[] = "memo";
static PyObject *__pyx_kp_memo;
static char __pyx_k_key[] = "key";
static PyObject *__pyx_kp_key;
static char __pyx_k_element[] = "element";
static PyObject *__pyx_kp_element;
static char __pyx_k_elements[] = "elements";
static PyObject *__pyx_kp_elements;
static char __pyx_k_old_element[] = "old_element";
static PyObject *__pyx_kp_old_element;
static char __pyx_k_new_element[] = "new_element";
static PyObject *__pyx_kp_new_element;
static char __pyx_k_line[] = "line";
static PyObject *__pyx_kp_line;
static char __pyx_k_child[] = "child";
static PyObject *__pyx_kp_child;
static char __pyx_k_stop[] = "stop";
static PyObject *__pyx_kp_stop;
static char __pyx_k_default[] = "default";
static PyObject *__pyx_kp_default;
static char __pyx_k_preceding[] = "preceding";
static PyObject *__pyx_kp_preceding;
static char __pyx_k_reversed[] = "reversed";
static PyObject *__pyx_kp_reversed;
static char __pyx_k_with_tail[] = "with_tail";
static PyObject *__pyx_kp_with_tail;
static char __pyx_k__tag[] = "_tag";
static PyObject *__pyx_kp__tag;
static char __pyx_k_attrib[] = "attrib";
static PyObject *__pyx_kp_attrib;
static char __pyx_k_nsmap[] = "nsmap";
static PyObject *__pyx_kp_nsmap;
static char __pyx_k_path[] = "path";
static PyObject *__pyx_kp_path;
static char __pyx_k__path[] = "_path";
static PyObject *__pyx_kp__path;
static char __pyx_k_namespaces[] = "namespaces";
static PyObject *__pyx_kp_namespaces;
static char __pyx_k_extensions[] = "extensions";
static PyObject *__pyx_kp_extensions;
static char __pyx_k_smart_strings[] = "smart_strings";
static PyObject *__pyx_kp_smart_strings;
static char __pyx_k_source[] = "source";
static PyObject *__pyx_kp_source;
static char __pyx_k_parser[] = "parser";
static PyObject *__pyx_kp_parser;
static char __pyx_k_base_url[] = "base_url";
static PyObject *__pyx_kp_base_url;
static char __pyx_k_root[] = "root";
static PyObject *__pyx_kp_root;
static char __pyx_k_file[] = "file";
static PyObject *__pyx_kp_file;
static char __pyx_k_encoding[] = "encoding";
static PyObject *__pyx_kp_encoding;
static char __pyx_k_method[] = "method";
static PyObject *__pyx_kp_method;
static char __pyx_k_pretty_print[] = "pretty_print";
static PyObject *__pyx_kp_pretty_print;
static char __pyx_k_xml_declaration[] = "xml_declaration";
static PyObject *__pyx_kp_xml_declaration;
static char __pyx_k__xslt[] = "_xslt";
static PyObject *__pyx_kp__xslt;
static char __pyx_k_access_control[] = "access_control";
static PyObject *__pyx_kp_access_control;
static char __pyx_k_sequence_or_dict[] = "sequence_or_dict";
static PyObject *__pyx_kp_sequence_or_dict;
static char __pyx_k_node[] = "node";
static PyObject *__pyx_kp_node;
static char __pyx_k_inclusive[] = "inclusive";
static PyObject *__pyx_kp_inclusive;
static char __pyx_k_text[] = "text";
static PyObject *__pyx_kp_text;
static char __pyx_k_target[] = "target";
static PyObject *__pyx_kp_target;
static char __pyx_k_name[] = "name";
static PyObject *__pyx_kp_name;
static char __pyx_k__parent[] = "_parent";
static PyObject *__pyx_kp__parent;
static char __pyx_k_strings[] = "strings";
static PyObject *__pyx_kp_strings;
static char __pyx_k_elem[] = "elem";
static PyObject *__pyx_kp_elem;
static char __pyx_k_element_or_tree[] = "element_or_tree";
static PyObject *__pyx_kp_element_or_tree;
static char __pyx_k_tree_or_element[] = "tree_or_element";
static PyObject *__pyx_kp_tree_or_element;
static char __pyx_k_first_error[] = "first_error";
static PyObject *__pyx_kp_first_error;
static char __pyx_k_last_error[] = "last_error";
static PyObject *__pyx_kp_last_error;
static char __pyx_k_entries[] = "entries";
static PyObject *__pyx_kp_entries;
static char __pyx_k_error_type[] = "error_type";
static PyObject *__pyx_kp_error_type;
static char __pyx_k_domains[] = "domains";
static PyObject *__pyx_kp_domains;
static char __pyx_k_types[] = "types";
static PyObject *__pyx_kp_types;
static char __pyx_k_levels[] = "levels";
static PyObject *__pyx_kp_levels;
static char __pyx_k_level[] = "level";
static PyObject *__pyx_kp_level;
static char __pyx_k_entry[] = "entry";
static PyObject *__pyx_kp_entry;
static char __pyx_k_max_len[] = "max_len";
static PyObject *__pyx_kp_max_len;
static char __pyx_k_logger_name[] = "logger_name";
static PyObject *__pyx_kp_logger_name;
static char __pyx_k_35[] = "message_format_string";
static PyObject *__pyx_kp_35;
static char __pyx_k_other_element[] = "other_element";
static PyObject *__pyx_kp_other_element;
static char __pyx_k_fallback[] = "fallback";
static PyObject *__pyx_kp_fallback;
static char __pyx_k_entity[] = "entity";
static PyObject *__pyx_kp_entity;
static char __pyx_k_attribute_name[] = "attribute_name";
static PyObject *__pyx_kp_attribute_name;
static char __pyx_k_class_mapping[] = "class_mapping";
static PyObject *__pyx_kp_class_mapping;
static char __pyx_k_type[] = "type";
static PyObject *__pyx_kp_type;
static char __pyx_k_doc[] = "doc";
static PyObject *__pyx_kp_doc;
static char __pyx_k_namespace[] = "namespace";
static PyObject *__pyx_kp_namespace;
static char __pyx_k_ns_uri[] = "ns_uri";
static PyObject *__pyx_kp_ns_uri;
static char __pyx_k_class_dict_iterable[] = "class_dict_iterable";
static PyObject *__pyx_kp_class_dict_iterable;
static char __pyx_k_item[] = "item";
static PyObject *__pyx_kp_item;
static char __pyx_k_prefix[] = "prefix";
static PyObject *__pyx_kp_prefix;
static char __pyx_k_system_url[] = "system_url";
static PyObject *__pyx_kp_system_url;
static char __pyx_k_public_id[] = "public_id";
static PyObject *__pyx_kp_public_id;
static char __pyx_k_context[] = "context";
static PyObject *__pyx_kp_context;
static char __pyx_k_string[] = "string";
static PyObject *__pyx_kp_string;
static char __pyx_k_filename[] = "filename";
static PyObject *__pyx_kp_filename;
static char __pyx_k_f[] = "f";
static PyObject *__pyx_kp_f;
static char __pyx_k_default_resolver[] = "default_resolver";
static PyObject *__pyx_kp_default_resolver;
static char __pyx_k_resolver[] = "resolver";
static PyObject *__pyx_kp_resolver;
static char __pyx_k_code[] = "code";
static PyObject *__pyx_kp_code;
static char __pyx_k_column[] = "column";
static PyObject *__pyx_kp_column;
static char __pyx_k_filelike[] = "filelike";
static PyObject *__pyx_kp_filelike;
static char __pyx_k_exc_context[] = "exc_context";
static PyObject *__pyx_kp_exc_context;
static char __pyx_k_parse_options[] = "parse_options";
static PyObject *__pyx_kp_parse_options;
static char __pyx_k_for_html[] = "for_html";
static PyObject *__pyx_kp_for_html;
static char __pyx_k_schema[] = "schema";
static PyObject *__pyx_kp_schema;
static char __pyx_k_remove_comments[] = "remove_comments";
static PyObject *__pyx_kp_remove_comments;
static char __pyx_k_remove_pis[] = "remove_pis";
static PyObject *__pyx_kp_remove_pis;
static char __pyx_k_strip_cdata[] = "strip_cdata";
static PyObject *__pyx_kp_strip_cdata;
static char __pyx_k_attribute_defaults[] = "attribute_defaults";
static PyObject *__pyx_kp_attribute_defaults;
static char __pyx_k_dtd_validation[] = "dtd_validation";
static PyObject *__pyx_kp_dtd_validation;
static char __pyx_k_load_dtd[] = "load_dtd";
static PyObject *__pyx_kp_load_dtd;
static char __pyx_k_no_network[] = "no_network";
static PyObject *__pyx_kp_no_network;
static char __pyx_k_ns_clean[] = "ns_clean";
static PyObject *__pyx_kp_ns_clean;
static char __pyx_k_recover[] = "recover";
static PyObject *__pyx_kp_recover;
static char __pyx_k_remove_blank_text[] = "remove_blank_text";
static PyObject *__pyx_kp_remove_blank_text;
static char __pyx_k_compact[] = "compact";
static PyObject *__pyx_kp_compact;
static char __pyx_k_resolve_entities[] = "resolve_entities";
static PyObject *__pyx_kp_resolve_entities;
static char __pyx_k_element_factory[] = "element_factory";
static PyObject *__pyx_kp_element_factory;
static char __pyx_k_attrs[] = "attrs";
static PyObject *__pyx_kp_attrs;
static char __pyx_k_result[] = "result";
static PyObject *__pyx_kp_result;
static char __pyx_k_events[] = "events";
static PyObject *__pyx_kp_events;
static char __pyx_k_html[] = "html";
static PyObject *__pyx_kp_html;
static char __pyx_k_etree[] = "etree";
static PyObject *__pyx_kp_etree;
static char __pyx_k_id_name[] = "id_name";
static PyObject *__pyx_kp_id_name;
static char __pyx_k_enable_regexp[] = "enable_regexp";
static PyObject *__pyx_kp_enable_regexp;
static char __pyx_k_build_smart_strings[] = "build_smart_strings";
static PyObject *__pyx_kp_build_smart_strings;
static char __pyx_k_module[] = "module";
static PyObject *__pyx_kp_module;
static char __pyx_k_function_mapping[] = "function_mapping";
static PyObject *__pyx_kp_function_mapping;
static char __pyx_k_ns[] = "ns";
static PyObject *__pyx_kp_ns;
static char __pyx_k_ctxt[] = "ctxt";
static PyObject *__pyx_kp_ctxt;
static char __pyx_k_s[] = "s";
static PyObject *__pyx_kp_s;
static char __pyx_k_rexp[] = "rexp";
static PyObject *__pyx_kp_rexp;
static char __pyx_k_flags[] = "flags";
static PyObject *__pyx_kp_flags;
static char __pyx_k_replacement[] = "replacement";
static PyObject *__pyx_kp_replacement;
static char __pyx_k_variables[] = "variables";
static PyObject *__pyx_kp_variables;
static char __pyx_k__eval_arg[] = "_eval_arg";
static PyObject *__pyx_kp__eval_arg;
static char __pyx_k_regexp[] = "regexp";
static PyObject *__pyx_kp_regexp;
static char __pyx_k_uri[] = "uri";
static PyObject *__pyx_kp_uri;
static char __pyx_k_etree_or_element[] = "etree_or_element";
static PyObject *__pyx_kp_etree_or_element;
static char __pyx_k__etree_or_element[] = "_etree_or_element";
static PyObject *__pyx_kp__etree_or_element;
static char __pyx_k_read_file[] = "read_file";
static PyObject *__pyx_kp_read_file;
static char __pyx_k_write_file[] = "write_file";
static PyObject *__pyx_kp_write_file;
static char __pyx_k_create_dir[] = "create_dir";
static PyObject *__pyx_kp_create_dir;
static char __pyx_k_read_network[] = "read_network";
static PyObject *__pyx_kp_read_network;
static char __pyx_k_write_network[] = "write_network";
static PyObject *__pyx_kp_write_network;
static char __pyx_k_xslt_input[] = "xslt_input";
static PyObject *__pyx_kp_xslt_input;
static char __pyx_k__input[] = "_input";
static PyObject *__pyx_kp__input;
static char __pyx_k_profile_run[] = "profile_run";
static PyObject *__pyx_kp_profile_run;
static char __pyx_k_result_tree[] = "result_tree";
static PyObject *__pyx_kp_result_tree;
static char __pyx_k_buffer[] = "buffer";
static PyObject *__pyx_kp_buffer;
static char __pyx_k_self_node[] = "self_node";
static PyObject *__pyx_kp_self_node;
static char __pyx_k_input_node[] = "input_node";
static PyObject *__pyx_kp_input_node;
static char __pyx_k_output_parent[] = "output_parent";
static PyObject *__pyx_kp_output_parent;
static char __pyx_k_external_id[] = "external_id";
static PyObject *__pyx_kp_external_id;
static char __pyx_k___docformat__[] = "__docformat__";
static PyObject *__pyx_kp___docformat__;
static char __pyx_k___builtin__[] = "__builtin__";
static PyObject *__pyx_kp___builtin__;
static char __pyx_k_ImportError[] = "ImportError";
static PyObject *__pyx_kp_ImportError;
static char __pyx_k_builtins[] = "builtins";
static PyObject *__pyx_kp_builtins;
static char __pyx_k_AttributeError[] = "AttributeError";
static PyObject *__pyx_kp_AttributeError;
static char __pyx_k_sets[] = "sets";
static PyObject *__pyx_kp_sets;
static char __pyx_k_Set[] = "Set";
static PyObject *__pyx_kp_Set;
static char __pyx_k_unicode[] = "unicode";
static PyObject *__pyx_kp_unicode;
static char __pyx_k_str[] = "str";
static PyObject *__pyx_kp_str;
static char __pyx_k_37[] = "os.path";
static PyObject *__pyx_kp_37;
static char __pyx_k_abspath[] = "abspath";
static PyObject *__pyx_kp_abspath;
static char __pyx_k_join[] = "join";
static PyObject *__pyx_kp_join;
static char __pyx_k_io[] = "io";
static PyObject *__pyx_kp_io;
static char __pyx_k_BytesIO[] = "BytesIO";
static PyObject *__pyx_kp_BytesIO;
static char __pyx_k_StringIO[] = "StringIO";
static PyObject *__pyx_kp_StringIO;
static char __pyx_k__elementpath[] = "_elementpath";
static PyObject *__pyx_kp__elementpath;
static char __pyx_k_sys[] = "sys";
static PyObject *__pyx_kp_sys;
static char __pyx_k_re[] = "re";
static PyObject *__pyx_kp_re;
static char __pyx_k_DEBUG[] = "DEBUG";
static PyObject *__pyx_kp_DEBUG;
static char __pyx_k_38[] = "getfilesystemencoding";
static PyObject *__pyx_kp_38;
static char __pyx_k_getdefaultencoding[] = "getdefaultencoding";
static PyObject *__pyx_kp_getdefaultencoding;
static char __pyx_k_39[] = "ascii";
static PyObject *__pyx_kp_39;
static char __pyx_k_encode[] = "encode";
static PyObject *__pyx_kp_encode;
static char __pyx_k_42[] = "html";
static PyObject *__pyx_kp_42;
static char __pyx_k_44[] = "xsl";
static PyObject *__pyx_kp_44;
static char __pyx_k_46[] = "rdf";
static PyObject *__pyx_kp_46;
static char __pyx_k_48[] = "wsdl";
static PyObject *__pyx_kp_48;
static char __pyx_k_50[] = "xs";
static PyObject *__pyx_kp_50;
static char __pyx_k_52[] = "xsi";
static PyObject *__pyx_kp_52;
static char __pyx_k_54[] = "dc";
static PyObject *__pyx_kp_54;
static char __pyx_k_56[] = "py";
static PyObject *__pyx_kp_56;
static char __pyx_k_Error[] = "Error";
static PyObject *__pyx_kp_Error;
static char __pyx_k_Exception[] = "Exception";
static PyObject *__pyx_kp_Exception;
static char __pyx_k_LxmlError[] = "LxmlError";
static PyObject *__pyx_kp_LxmlError;
static char __pyx_k_LxmlSyntaxError[] = "LxmlSyntaxError";
static PyObject *__pyx_kp_LxmlSyntaxError;
static char __pyx_k_SyntaxError[] = "SyntaxError";
static PyObject *__pyx_kp_SyntaxError;
static char __pyx_k_59[] = "C14NError";
static PyObject *__pyx_kp_59;
static char __pyx_k_decode[] = "decode";
static PyObject *__pyx_kp_decode;
static char __pyx_k_62[] = "ASCII";
static PyObject *__pyx_kp_62;
static char __pyx_k_group[] = "group";
static PyObject *__pyx_kp_group;
static char __pyx_k_64[] = "ASCII";
static PyObject *__pyx_kp_64;
static char __pyx_k_LIBXML_VERSION[] = "LIBXML_VERSION";
static PyObject *__pyx_kp_LIBXML_VERSION;
static char __pyx_k_65[] = "LIBXML_COMPILED_VERSION";
static PyObject *__pyx_kp_65;
static char __pyx_k_LXML_VERSION[] = "LXML_VERSION";
static PyObject *__pyx_kp_LXML_VERSION;
static char __pyx_k_66[] = "ASCII";
static PyObject *__pyx_kp_66;
static char __pyx_k___version__[] = "__version__";
static PyObject *__pyx_kp___version__;
static char __pyx_k_71[] = "xml";
static PyObject *__pyx_kp_71;
static char __pyx_k_79[] = "ProcessingInstruction";
static PyObject *__pyx_kp_79;
static char __pyx_k_PI[] = "PI";
static PyObject *__pyx_kp_PI;
static char __pyx_k_82[] = "xml";
static PyObject *__pyx_kp_82;
static char __pyx_k_85[] = "xml";
static PyObject *__pyx_kp_85;
static char __pyx_k_compile[] = "compile";
static PyObject *__pyx_kp_compile;
static char __pyx_k_U[] = "U";
static PyObject *__pyx_kp_U;
static char __pyx_k_sub[] = "sub";
static PyObject *__pyx_kp_sub;
static char __pyx_k_ErrorLevels[] = "ErrorLevels";
static PyObject *__pyx_kp_ErrorLevels;
static char __pyx_k_ErrorDomains[] = "ErrorDomains";
static PyObject *__pyx_kp_ErrorDomains;
static char __pyx_k_ErrorTypes[] = "ErrorTypes";
static PyObject *__pyx_kp_ErrorTypes;
static char __pyx_k_RelaxNGErrorTypes[] = "RelaxNGErrorTypes";
static PyObject *__pyx_kp_RelaxNGErrorTypes;
static char __pyx_k_LxmlRegistryError[] = "LxmlRegistryError";
static PyObject *__pyx_kp_LxmlRegistryError;
static char __pyx_k_108[] = "NamespaceRegistryError";
static PyObject *__pyx_kp_108;
static char __pyx_k_ParseError[] = "ParseError";
static PyObject *__pyx_kp_ParseError;
static char __pyx_k_XMLSyntaxError[] = "XMLSyntaxError";
static PyObject *__pyx_kp_XMLSyntaxError;
static char __pyx_k_ParserError[] = "ParserError";
static PyObject *__pyx_kp_ParserError;
static char __pyx_k_inspect[] = "inspect";
static PyObject *__pyx_kp_inspect;
static char __pyx_k_getargspec[] = "getargspec";
static PyObject *__pyx_kp_getargspec;
static char __pyx_k__TargetParserResult[] = "_TargetParserResult";
static PyObject *__pyx_kp__TargetParserResult;
static char __pyx_k_144[] = "end";
static PyObject *__pyx_kp_144;
static char __pyx_k_157[] = "end";
static PyObject *__pyx_kp_157;
static char __pyx_k_XIncludeError[] = "XIncludeError";
static PyObject *__pyx_kp_XIncludeError;
static char __pyx_k_XPathError[] = "XPathError";
static PyObject *__pyx_kp_XPathError;
static char __pyx_k_XPathEvalError[] = "XPathEvalError";
static PyObject *__pyx_kp_XPathEvalError;
static char __pyx_k_XPathFunctionError[] = "XPathFunctionError";
static PyObject *__pyx_kp_XPathFunctionError;
static char __pyx_k_XPathResultError[] = "XPathResultError";
static PyObject *__pyx_kp_XPathResultError;
static char __pyx_k_166[] = "_ElementStringResult";
static PyObject *__pyx_kp_166;
static char __pyx_k_XPathSyntaxError[] = "XPathSyntaxError";
static PyObject *__pyx_kp_XPathSyntaxError;
static char __pyx_k_XSLTError[] = "XSLTError";
static PyObject *__pyx_kp_XSLTError;
static char __pyx_k_XSLTParseError[] = "XSLTParseError";
static PyObject *__pyx_kp_XSLTParseError;
static char __pyx_k_XSLTApplyError[] = "XSLTApplyError";
static PyObject *__pyx_kp_XSLTApplyError;
static char __pyx_k_XSLTSaveError[] = "XSLTSaveError";
static PyObject *__pyx_kp_XSLTSaveError;
static char __pyx_k_XSLTExtensionError[] = "XSLTExtensionError";
static PyObject *__pyx_kp_XSLTExtensionError;
static char __pyx_k_184[] = "LIBXSLT_COMPILED_VERSION";
static PyObject *__pyx_kp_184;
static char __pyx_k_LIBXSLT_VERSION[] = "LIBXSLT_VERSION";
static PyObject *__pyx_kp_LIBXSLT_VERSION;
static char __pyx_k_DocumentInvalid[] = "DocumentInvalid";
static PyObject *__pyx_kp_DocumentInvalid;
static char __pyx_k_DTDError[] = "DTDError";
static PyObject *__pyx_kp_DTDError;
static char __pyx_k_DTDParseError[] = "DTDParseError";
static PyObject *__pyx_kp_DTDParseError;
static char __pyx_k_DTDValidateError[] = "DTDValidateError";
static PyObject *__pyx_kp_DTDValidateError;
static char __pyx_k_RelaxNGError[] = "RelaxNGError";
static PyObject *__pyx_kp_RelaxNGError;
static char __pyx_k_RelaxNGParseError[] = "RelaxNGParseError";
static PyObject *__pyx_kp_RelaxNGParseError;
static char __pyx_k_201[] = "RelaxNGValidateError";
static PyObject *__pyx_kp_201;
static char __pyx_k_XMLSchemaError[] = "XMLSchemaError";
static PyObject *__pyx_kp_XMLSchemaError;
static char __pyx_k_XMLSchemaParseError[] = "XMLSchemaParseError";
static PyObject *__pyx_kp_XMLSchemaParseError;
static char __pyx_k_205[] = "XMLSchemaValidateError";
static PyObject *__pyx_kp_205;
static char __pyx_k_SchematronError[] = "SchematronError";
static PyObject *__pyx_kp_SchematronError;
static char __pyx_k_208[] = "SchematronParseError";
static PyObject *__pyx_kp_208;
static char __pyx_k_210[] = "SchematronValidateError";
static PyObject *__pyx_kp_210;
static char __pyx_k_super[] = "super";
static PyObject *__pyx_kp_super;
static char __pyx_k_212[] = "ASCII";
static PyObject *__pyx_kp_212;
static char __pyx_k_split[] = "split";
static PyObject *__pyx_kp_split;
static char __pyx_k_ValueError[] = "ValueError";
static PyObject *__pyx_kp_ValueError;
static char __pyx_k_startswith[] = "startswith";
static PyObject *__pyx_kp_startswith;
static char __pyx_k_216[] = "dev";
static PyObject *__pyx_kp_216;
static char __pyx_k_217[] = "alpha";
static PyObject *__pyx_kp_217;
static char __pyx_k_218[] = "beta";
static PyObject *__pyx_kp_218;
static char __pyx_k_exc_info[] = "exc_info";
static PyObject *__pyx_kp_exc_info;
static char __pyx_k_221[] = "A";
static PyObject *__pyx_kp_221;
static char __pyx_k_222[] = "A";
static PyObject *__pyx_kp_222;
static char __pyx_k_IndexError[] = "IndexError";
static PyObject *__pyx_kp_IndexError;
static char __pyx_k_TypeError[] = "TypeError";
static PyObject *__pyx_kp_TypeError;
static char __pyx_k_tail[] = "tail";
static PyObject *__pyx_kp_tail;
static char __pyx_k_id[] = "id";
static PyObject *__pyx_kp_id;
static char __pyx_k_warnings[] = "warnings";
static PyObject *__pyx_kp_warnings;
static char __pyx_k_warn[] = "warn";
static PyObject *__pyx_kp_warn;
static char __pyx_k_FutureWarning[] = "FutureWarning";
static PyObject *__pyx_kp_FutureWarning;
static char __pyx_k_Comment[] = "Comment";
static PyObject *__pyx_kp_Comment;
static char __pyx_k_Entity[] = "Entity";
static PyObject *__pyx_kp_Entity;
static char __pyx_k_262[] = "ASCII";
static PyObject *__pyx_kp_262;
static char __pyx_k_263[] = "ASCII";
static PyObject *__pyx_kp_263;
static char __pyx_k_upper[] = "upper";
static PyObject *__pyx_kp_upper;
static char __pyx_k_265[] = "ASCII";
static PyObject *__pyx_kp_265;
static char __pyx_k_266[] = "UTF8";
static PyObject *__pyx_kp_266;
static char __pyx_k_KeyError[] = "KeyError";
static PyObject *__pyx_kp_KeyError;
static char __pyx_k_StopIteration[] = "StopIteration";
static PyObject *__pyx_kp_StopIteration;
static char __pyx_k_Element[] = "Element";
static PyObject *__pyx_kp_Element;
static char __pyx_k_286[] = "start";
static PyObject *__pyx_kp_286;
static char __pyx_k_287[] = "end";
static PyObject *__pyx_kp_287;
static char __pyx_k_288[] = "start";
static PyObject *__pyx_kp_288;
static char __pyx_k_289[] = "start";
static PyObject *__pyx_kp_289;
static char __pyx_k_stdout[] = "stdout";
static PyObject *__pyx_kp_stdout;
static char __pyx_k_295[] = "ASCII";
static PyObject *__pyx_kp_295;
static char __pyx_k_297[] = "UTF8";
static PyObject *__pyx_kp_297;
static char __pyx_k_299[] = "ASCII";
static PyObject *__pyx_kp_299;
static char __pyx_k_309[] = "items";
static PyObject *__pyx_kp_309;
static char __pyx_k_strip[] = "strip";
static PyObject *__pyx_kp_strip;
static char __pyx_k_UnicodeEncodeError[] = "UnicodeEncodeError";
static PyObject *__pyx_kp_UnicodeEncodeError;
static char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
static PyObject *__pyx_kp_UnicodeDecodeError;
static char __pyx_k_347[] = "name";
static PyObject *__pyx_kp_347;
static char __pyx_k_348[] = "geturl";
static PyObject *__pyx_kp_348;
static char __pyx_k_349[] = "filename";
static PyObject *__pyx_kp_349;
static char __pyx_k_level_name[] = "level_name";
static PyObject *__pyx_kp_level_name;
static char __pyx_k_domain_name[] = "domain_name";
static PyObject *__pyx_kp_domain_name;
static char __pyx_k_type_name[] = "type_name";
static PyObject *__pyx_kp_type_name;
static char __pyx_k__getName[] = "_getName";
static PyObject *__pyx_kp__getName;
static char __pyx_k_352[] = "unknown";
static PyObject *__pyx_kp_352;
static char __pyx_k_RELAXNGV[] = "RELAXNGV";
static PyObject *__pyx_kp_RELAXNGV;
static char __pyx_k_353[] = "unknown";
static PyObject *__pyx_kp_353;
static char __pyx_k_354[] = "unknown";
static PyObject *__pyx_kp_354;
static char __pyx_k_FATAL[] = "FATAL";
static PyObject *__pyx_kp_FATAL;
static char __pyx_k_ERROR[] = "ERROR";
static PyObject *__pyx_kp_ERROR;
static char __pyx_k_WARNING[] = "WARNING";
static PyObject *__pyx_kp_WARNING;
static char __pyx_k__accepted_domains[] = "_accepted_domains";
static PyObject *__pyx_kp__accepted_domains;
static char __pyx_k_domain[] = "domain";
static PyObject *__pyx_kp_domain;
static char __pyx_k_logging[] = "logging";
static PyObject *__pyx_kp_logging;
static char __pyx_k_CRITICAL[] = "CRITICAL";
static PyObject *__pyx_kp_CRITICAL;
static char __pyx_k_getLogger[] = "getLogger";
static PyObject *__pyx_kp_getLogger;
static char __pyx_k__names[] = "_names";
static PyObject *__pyx_kp__names;
static char __pyx_k__doc[] = "_doc";
static PyObject *__pyx_kp__doc;
static char __pyx_k_385[] = "element";
static PyObject *__pyx_kp_385;
static char __pyx_k_386[] = "comment";
static PyObject *__pyx_kp_386;
static char __pyx_k_387[] = "PI";
static PyObject *__pyx_kp_387;
static char __pyx_k_388[] = "entity";
static PyObject *__pyx_kp_388;
static char __pyx_k_389[] = "element";
static PyObject *__pyx_kp_389;
static char __pyx_k_390[] = "items";
static PyObject *__pyx_kp_390;
static char __pyx_k_391[] = "_";
static PyObject *__pyx_kp_391;
static char __pyx_k_read[] = "read";
static PyObject *__pyx_kp_read;
static char __pyx_k_discard[] = "discard";
static PyObject *__pyx_kp_discard;
static char __pyx_k_position[] = "position";
static PyObject *__pyx_kp_position;
static char __pyx_k_403[] = "_ParserDictionaryContext";
static PyObject *__pyx_kp_403;
static char __pyx_k_404[] = "_ParserDictionaryContext";
static PyObject *__pyx_kp_404;
static char __pyx_k_405[] = "_ParserDictionaryContext";
static PyObject *__pyx_kp_405;
static char __pyx_k___class__[] = "__class__";
static PyObject *__pyx_kp___class__;
static char __pyx_k_IOError[] = "IOError";
static PyObject *__pyx_kp_IOError;
static char __pyx_k_420[] = "WAR_UNDECLARED_ENTITY";
static PyObject *__pyx_kp_420;
static char __pyx_k_421[] = "ERR_UNDECLARED_ENTITY";
static PyObject *__pyx_kp_421;
static char __pyx_k_LookupError[] = "LookupError";
static PyObject *__pyx_kp_LookupError;
static char __pyx_k_432[] = "getvalue";
static PyObject *__pyx_kp_432;
static char __pyx_k_433[] = "tell";
static PyObject *__pyx_kp_433;
static char __pyx_k_tell[] = "tell";
static PyObject *__pyx_kp_tell;
static char __pyx_k_getvalue[] = "getvalue";
static PyObject *__pyx_kp_getvalue;
static char __pyx_k_434[] = "read";
static PyObject *__pyx_kp_434;
static char __pyx_k_doctype[] = "doctype";
static PyObject *__pyx_kp_doctype;
static char __pyx_k_449[] = "__dict__";
static PyObject *__pyx_kp_449;
static char __pyx_k_lower[] = "lower";
static PyObject *__pyx_kp_lower;
static char __pyx_k_450[] = "xml";
static PyObject *__pyx_kp_450;
static char __pyx_k_451[] = "html";
static PyObject *__pyx_kp_451;
static char __pyx_k_452[] = "text";
static PyObject *__pyx_kp_452;
static char __pyx_k_455[] = "ASCII";
static PyObject *__pyx_kp_455;
static char __pyx_k_open[] = "open";
static PyObject *__pyx_kp_open;
static char __pyx_k_478[] = "wb";
static PyObject *__pyx_kp_478;
static char __pyx_k_481[] = "write";
static PyObject *__pyx_kp_481;
static char __pyx_k_483[] = "write";
static PyObject *__pyx_kp_483;
static char __pyx_k_488[] = "start";
static PyObject *__pyx_kp_488;
static char __pyx_k_489[] = "end";
static PyObject *__pyx_kp_489;
static char __pyx_k_492[] = "comment";
static PyObject *__pyx_kp_492;
static char __pyx_k_493[] = "pi";
static PyObject *__pyx_kp_493;
static char __pyx_k_501[] = "start";
static PyObject *__pyx_kp_501;
static char __pyx_k_502[] = "end";
static PyObject *__pyx_kp_502;
static char __pyx_k_504[] = "comment";
static PyObject *__pyx_kp_504;
static char __pyx_k_505[] = "pi";
static PyObject *__pyx_kp_505;
static char __pyx_k_506[] = "read";
static PyObject *__pyx_kp_506;
static char __pyx_k_507[] = "rb";
static PyObject *__pyx_kp_507;
static char __pyx_k_515[] = "start";
static PyObject *__pyx_kp_515;
static char __pyx_k_516[] = "end";
static PyObject *__pyx_kp_516;
static char __pyx_k_XML[] = "XML";
static PyObject *__pyx_kp_XML;
static char __pyx_k_519[] = "id";
static PyObject *__pyx_kp_519;
static char __pyx_k_cmp[] = "cmp";
static PyObject *__pyx_kp_cmp;
static char __pyx_k_533[] = "_";
static PyObject *__pyx_kp_533;
static char __pyx_k_UNICODE[] = "UNICODE";
static PyObject *__pyx_kp_UNICODE;
static char __pyx_k_IGNORECASE[] = "IGNORECASE";
static PyObject *__pyx_kp_IGNORECASE;
static char __pyx_k_535[] = "i";
static PyObject *__pyx_kp_535;
static char __pyx_k_search[] = "search";
static PyObject *__pyx_kp_search;
static char __pyx_k_536[] = "i";
static PyObject *__pyx_kp_536;
static char __pyx_k_537[] = "g";
static PyObject *__pyx_kp_537;
static char __pyx_k_groups[] = "groups";
static PyObject *__pyx_kp_groups;
static char __pyx_k_539[] = "matches";
static PyObject *__pyx_kp_539;
static char __pyx_k_SubElement[] = "SubElement";
static PyObject *__pyx_kp_SubElement;
static char __pyx_k_541[] = "match";
static PyObject *__pyx_kp_541;
static char __pyx_k_542[] = "i";
static PyObject *__pyx_kp_542;
static char __pyx_k_543[] = "g";
static PyObject *__pyx_kp_543;
static char __pyx_k_545[] = "test";
static PyObject *__pyx_kp_545;
static char __pyx_k_546[] = "match";
static PyObject *__pyx_kp_546;
static char __pyx_k_547[] = "replace";
static PyObject *__pyx_kp_547;
static char __pyx_k_NotImplementedError[] = "NotImplementedError";
static PyObject *__pyx_kp_NotImplementedError;
static char __pyx_k_is_attribute[] = "is_attribute";
static PyObject *__pyx_kp_is_attribute;
static char __pyx_k_is_tail[] = "is_tail";
static PyObject *__pyx_kp_is_tail;
static char __pyx_k_is_text[] = "is_text";
static PyObject *__pyx_kp_is_text;
static char __pyx_k_resolvers[] = "resolvers";
static PyObject *__pyx_kp_resolvers;
static char __pyx_k_573[] = "read_file";
static PyObject *__pyx_kp_573;
static char __pyx_k_574[] = "write_file";
static PyObject *__pyx_kp_574;
static char __pyx_k_575[] = "create_dir";
static PyObject *__pyx_kp_575;
static char __pyx_k_576[] = "read_network";
static PyObject *__pyx_kp_576;
static char __pyx_k_577[] = "write_network";
static PyObject *__pyx_kp_577;
static char __pyx_k_options[] = "options";
static PyObject *__pyx_kp_options;
static char __pyx_k_sort[] = "sort";
static PyObject *__pyx_kp_sort;
static char __pyx_k_ElementTree[] = "ElementTree";
static PyObject *__pyx_kp_ElementTree;
static char __pyx_k_594[] = "xsl";
static PyObject *__pyx_kp_594;
static char __pyx_k_601[] = "href";
static PyObject *__pyx_kp_601;
static char __pyx_k_AssertionError[] = "AssertionError";
static PyObject *__pyx_kp_AssertionError;
static char __pyx_k_618[] = "read";
static PyObject *__pyx_kp_618;
static PyObject *__pyx_kp_36;
static PyObject *__pyx_kp_40;
static PyObject *__pyx_kp_41;
static PyObject *__pyx_kp_43;
static PyObject *__pyx_kp_45;
static PyObject *__pyx_kp_47;
static PyObject *__pyx_kp_49;
static PyObject *__pyx_kp_51;
static PyObject *__pyx_kp_53;
static PyObject *__pyx_kp_55;
static PyObject *__pyx_kp_57;
static PyObject *__pyx_kp_58;
static PyObject *__pyx_kp_60;
static PyObject *__pyx_kp_61;
static PyObject *__pyx_kp_63;
static PyObject *__pyx_kp_88;
static PyObject *__pyx_kp_89;
static PyObject *__pyx_kp_90;
static PyObject *__pyx_kp_91;
static PyObject *__pyx_kp_92;
static PyObject *__pyx_kp_93;
static PyObject *__pyx_kp_94;
static PyObject *__pyx_kp_95;
static PyObject *__pyx_kp_96;
static PyObject *__pyx_kp_97;
static PyObject *__pyx_kp_98;
static PyObject *__pyx_kp_99;
static PyObject *__pyx_kp_100;
static PyObject *__pyx_kp_101;
static PyObject *__pyx_kp_102;
static PyObject *__pyx_kp_103;
static PyObject *__pyx_kp_104;
static PyObject *__pyx_kp_105;
static PyObject *__pyx_kp_107;
static PyObject *__pyx_kp_109;
static PyObject *__pyx_kp_110;
static PyObject *__pyx_kp_111;
static PyObject *__pyx_kp_112;
static PyObject *__pyx_kp_159;
static PyObject *__pyx_kp_160;
static PyObject *__pyx_kp_161;
static PyObject *__pyx_kp_162;
static PyObject *__pyx_kp_163;
static PyObject *__pyx_kp_175;
static PyObject *__pyx_kp_176;
static PyObject *__pyx_kp_179;
static PyObject *__pyx_kp_180;
static PyObject *__pyx_kp_181;
static PyObject *__pyx_kp_182;
static PyObject *__pyx_kp_183;
static PyObject *__pyx_kp_193;
static PyObject *__pyx_kp_194;
static PyObject *__pyx_kp_195;
static PyObject *__pyx_kp_196;
static PyObject *__pyx_kp_197;
static PyObject *__pyx_kp_198;
static PyObject *__pyx_kp_199;
static PyObject *__pyx_kp_200;
static PyObject *__pyx_kp_202;
static PyObject *__pyx_kp_203;
static PyObject *__pyx_kp_204;
static PyObject *__pyx_kp_206;
static PyObject *__pyx_kp_207;
static PyObject *__pyx_kp_209;
static PyObject *__pyx_kp_211;
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_SyntaxError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_FutureWarning;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_UnicodeEncodeError;
static PyObject *__pyx_builtin_UnicodeDecodeError;
static PyObject *__pyx_builtin_IOError;
static PyObject *__pyx_builtin_LookupError;
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_cmp;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_AssertionError;
static PyObject *__pyx_kp_213;
static PyObject *__pyx_kp_214;
static PyObject *__pyx_kp_215;
static char __pyx_k_213[] = "-";
static char __pyx_k_214[] = ".";
static char __pyx_k_215[] = ".";
static PyObject *__pyx_kp_219;
static char __pyx_k_219[] = "{%s}%s";
static char __pyx_k_220[] = "ns%d";
static PyObject *__pyx_kp_223;
static char __pyx_k_223[] = "invalid node type %d, expected %d";
static char __pyx_k_224[] = "ns%d";
static PyObject *__pyx_kp_225;
static char __pyx_k_225[] = "Could not find root node";
static PyObject *__pyx_kp_226;
static PyObject *__pyx_kp_227;
static PyObject *__pyx_kp_228;
static PyObject *__pyx_kp_229;
static PyObject *__pyx_kp_230;
static char __pyx_k_226[] = "<!DOCTYPE %s PUBLIC \"%s\" \"%s\">";
static char __pyx_k_227[] = "<!DOCTYPE %s PUBLIC \"%s\">";
static char __pyx_k_228[] = "<!DOCTYPE %s SYSTEM \"%s\">";
static char __pyx_k_229[] = "<!DOCTYPE %s>";
static char __pyx_k_230[] = "";
static PyObject *__pyx_kp_231;
static PyObject *__pyx_kp_232;
static char __pyx_k_231[] = "cannot assign None";
static char __pyx_k_232[] = "list index out of range";
static PyObject *__pyx_kp_233;
static char __pyx_k_233[] = "index out of range: %d";
static PyObject *__pyx_kp_234;
static char __pyx_k_234[] = "Only processing instructions and comments can be siblings of the root element";
static PyObject *__pyx_kp_235;
static char __pyx_k_235[] = "Only processing instructions and comments can be siblings of the root element";
static PyObject *__pyx_kp_236;
static char __pyx_k_236[] = "Element is not a child of this node.";
static PyObject *__pyx_kp_237;
static char __pyx_k_237[] = "Element is not a child of this node.";
static char __pyx_k_238[] = "UTF-8";
static char __pyx_k_239[] = "strict";
static PyObject *__pyx_kp_240;
static char __pyx_k_240[] = "<Element %s at %x>";
static PyObject *__pyx_kp_241;
static char __pyx_k_241[] = "list index out of range";
static PyObject *__pyx_kp_242;
static char __pyx_k_242[] = "The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.";
static PyObject *__pyx_kp_243;
static PyObject *__pyx_kp_244;
static PyObject *__pyx_kp_245;
static PyObject *__pyx_kp_246;
static PyObject *__pyx_kp_247;
static PyObject *__pyx_kp_248;
static char __pyx_k_243[] = "Element is not a child of this node.";
static char __pyx_k_244[] = "list.index(x): x not in slice";
static char __pyx_k_245[] = "list.index(x): x not in slice";
static char __pyx_k_246[] = "list.index(x): x not in slice";
static char __pyx_k_247[] = "list.index(x): x not in slice";
static char __pyx_k_248[] = "list.index(x): x not in list";
static PyObject *__pyx_kp_249;
static char __pyx_k_249[] = "this element does not have children or attributes";
static PyObject *__pyx_kp_250;
static char __pyx_k_250[] = "";
static PyObject *__pyx_kp_251;
static char __pyx_k_251[] = "list index out of range";
static PyObject *__pyx_kp_252;
static char __pyx_k_252[] = "<!--%s-->";
static PyObject *__pyx_kp_253;
static PyObject *__pyx_kp_254;
static char __pyx_k_253[] = "<?%s %s?>";
static char __pyx_k_254[] = "<?%s?>";
static PyObject *__pyx_kp_255;
static PyObject *__pyx_kp_256;
static PyObject *__pyx_kp_257;
static char __pyx_k_255[] = "&";
static char __pyx_k_256[] = ";";
static char __pyx_k_257[] = "Invalid entity name '%s'";
static PyObject *__pyx_kp_258;
static char __pyx_k_258[] = "&%s;";
static PyObject *__pyx_kp_259;
static char __pyx_k_259[] = "&%s;";
static PyObject *__pyx_kp_260;
static char __pyx_k_260[] = "ElementTree not initialized, missing root";
static PyObject *__pyx_kp_261;
static char __pyx_k_261[] = "Only elements can be the root of an ElementTree";
static PyObject *__pyx_kp_264;
static PyObject *__pyx_kp_267;
static char __pyx_k_264[] = "US-ASCII";
static char __pyx_k_267[] = "UTF-8";
static PyObject *__pyx_kp_268;
static char __pyx_k_268[] = "Element is not in this tree.";
static PyObject *__pyx_kp_269;
static PyObject *__pyx_kp_270;
static PyObject *__pyx_kp_271;
static PyObject *__pyx_kp_272;
static char __pyx_k_269[] = "/";
static char __pyx_k_270[] = ".";
static char __pyx_k_271[] = "/";
static char __pyx_k_272[] = ".";
static PyObject *__pyx_kp_273;
static PyObject *__pyx_kp_274;
static PyObject *__pyx_kp_275;
static PyObject *__pyx_kp_276;
static char __pyx_k_273[] = "/";
static char __pyx_k_274[] = ".";
static char __pyx_k_275[] = "/";
static char __pyx_k_276[] = ".";
static PyObject *__pyx_kp_277;
static PyObject *__pyx_kp_278;
static PyObject *__pyx_kp_279;
static PyObject *__pyx_kp_280;
static char __pyx_k_277[] = "/";
static char __pyx_k_278[] = ".";
static char __pyx_k_279[] = "/";
static char __pyx_k_280[] = ".";
static PyObject *__pyx_kp_281;
static PyObject *__pyx_kp_282;
static PyObject *__pyx_kp_283;
static PyObject *__pyx_kp_284;
static char __pyx_k_281[] = "/";
static char __pyx_k_282[] = ".";
static char __pyx_k_283[] = "/";
static char __pyx_k_284[] = ".";
static PyObject *__pyx_kp_285;
static char __pyx_k_285[] = "pop expected at most 2 arguments, got %d";
static PyObject *__pyx_kp_290;
static char __pyx_k_290[] = "";
static PyObject *__pyx_kp_291;
static char __pyx_k_291[] = "";
static PyObject *__pyx_kp_292;
static PyObject *__pyx_kp_293;
static char __pyx_k_292[] = "Invalid character reference: '%s'";
static char __pyx_k_293[] = "Invalid entity reference: '%s'";
static PyObject *__pyx_kp_294;
static PyObject *__pyx_kp_296;
static PyObject *__pyx_kp_298;
static PyObject *__pyx_kp_300;
static char __pyx_k_294[] = "Serialisation to unicode must not request an XML declaration";
static char __pyx_k_296[] = "UTF-8";
static char __pyx_k_298[] = "US-ASCII";
static char __pyx_k_300[] = "Type '%s' cannot be serialized.";
static PyObject *__pyx_kp_301;
static char __pyx_k_301[] = "Type '%s' cannot be serialized.";
static PyObject *__pyx_kp_302;
static char __pyx_k_302[] = "double registering proxy!";
static PyObject *__pyx_kp_303;
static char __pyx_k_303[] = "Tried to unregister unknown proxy";
static PyObject *__pyx_kp_304;
static char __pyx_k_304[] = " ";
static PyObject *__pyx_kp_305;
static PyObject *__pyx_kp_306;
static char __pyx_k_305[] = "Invalid input object: %s";
static char __pyx_k_306[] = "Input object has no document: %s";
static PyObject *__pyx_kp_307;
static PyObject *__pyx_kp_308;
static char __pyx_k_307[] = "Invalid input object: %s";
static char __pyx_k_308[] = "Input object has no element: %s";
static PyObject *__pyx_kp_310;
static char __pyx_k_310[] = "Invalid attribute dictionary: %s";
static PyObject *__pyx_kp_311;
static char __pyx_k_311[] = "\\g<1>";
static PyObject *__pyx_kp_312;
static PyObject *__pyx_kp_313;
static PyObject *__pyx_kp_314;
static char __pyx_k_312[] = "<?xml";
static char __pyx_k_313[] = "?>";
static char __pyx_k_314[] = "\n\r ";
static PyObject *__pyx_kp_315;
static PyObject *__pyx_kp_316;
static PyObject *__pyx_kp_317;
static char __pyx_k_315[] = "";
static char __pyx_k_316[] = "";
static char __pyx_k_317[] = "";
static char __pyx_k_318[] = "%s:%s";
static PyObject *__pyx_kp_319;
static PyObject *__pyx_kp_320;
static PyObject *__pyx_kp_321;
static PyObject *__pyx_kp_322;
static PyObject *__pyx_kp_323;
static PyObject *__pyx_kp_324;
static PyObject *__pyx_kp_325;
static char __pyx_k_319[] = "attempt to assign sequence of size %d to extended slice of size %d";
static char __pyx_k_320[] = "Node must not be None";
static char __pyx_k_321[] = "Node must not be None";
static char __pyx_k_322[] = "Node must not be None";
static char __pyx_k_323[] = "Node must not be None";
static char __pyx_k_324[] = "Node must not be None";
static char __pyx_k_325[] = "Node must not be None";
static PyObject *__pyx_kp_326;
static PyObject *__pyx_kp_327;
static PyObject *__pyx_kp_328;
static char __pyx_k_326[] = "All strings must be XML compatible: Unicode or ASCII, no NULL bytes";
static char __pyx_k_327[] = "All strings must be XML compatible: Unicode or ASCII, no NULL bytes";
static char __pyx_k_328[] = "Argument must be string or unicode.";
static PyObject *__pyx_kp_330;
static char __pyx_k_329[] = "UTF-8";
static char __pyx_k_330[] = "Argument must be string or unicode.";
static char __pyx_k_331[] = "replace";
static PyObject *__pyx_kp_332;
static char __pyx_k_332[] = "Argument must be string or unicode.";
static PyObject *__pyx_kp_333;
static PyObject *__pyx_kp_334;
static PyObject *__pyx_kp_335;
static char __pyx_k_333[] = "Invalid tag name";
static char __pyx_k_334[] = "Empty tag name";
static char __pyx_k_335[] = "Empty tag name";
static PyObject *__pyx_kp_336;
static char __pyx_k_336[] = "Invalid tag name %r";
static char __pyx_k_337[] = "UTF-8";
static PyObject *__pyx_kp_338;
static char __pyx_k_338[] = "Invalid HTML tag name %r";
static char __pyx_k_339[] = "UTF-8";
static PyObject *__pyx_kp_340;
static char __pyx_k_340[] = "Invalid attribute name %r";
static char __pyx_k_341[] = "UTF-8";
static PyObject *__pyx_kp_342;
static char __pyx_k_342[] = "Invalid namespace prefix %r";
static char __pyx_k_343[] = "UTF-8";
static char __pyx_k_344[] = "{%s}%s";
static char __pyx_k_345[] = "{%s}%s";
static char __pyx_k_346[] = "UTF-8";
static PyObject *__pyx_kp_350;
static char __pyx_k_350[] = "<string>";
static PyObject *__pyx_kp_351;
static char __pyx_k_351[] = "%s:%d:%d:%s:%s:%s: %s";
static PyObject *__pyx_kp_355;
static char __pyx_k_355[] = "";
static PyObject *__pyx_kp_356;
static PyObject *__pyx_kp_357;
static char __pyx_k_356[] = "%s, line %d, column %d";
static char __pyx_k_357[] = "%s, line %d";
static PyObject *__pyx_kp_358;
static PyObject *__pyx_kp_359;
static char __pyx_k_358[] = "%s, line %d, column %d";
static char __pyx_k_359[] = "%s, line %d";
static PyObject *__pyx_kp_360;
static char __pyx_k_360[] = "\n";
static char __pyx_k_361[] = "file %s";
static char __pyx_k_362[] = "string://__STRING__XSLT";
static char __pyx_k_363[] = "<xslt>";
static char __pyx_k_364[] = "line %d";
static char __pyx_k_365[] = "element %s";
static char __pyx_k_366[] = "";
static char __pyx_k_367[] = "%s, element '%s'";
static PyObject *__pyx_kp_368;
static char __pyx_k_368[] = "\\s*([a-zA-Z0-9_]+)\\s*=\\s*([0-9]+)";
static PyObject *__pyx_kp_369;
static char __pyx_k_369[] = "Proxy invalidated!";
static PyObject *__pyx_kp_370;
static char __pyx_k_370[] = "<Element %s at %x>";
static PyObject *__pyx_kp_371;
static char __pyx_k_371[] = "list index out of range";
static PyObject *__pyx_kp_372;
static char __pyx_k_372[] = "*";
static char __pyx_k_373[] = "UTF-8";
static char __pyx_k_374[] = "strict";
static PyObject *__pyx_kp_375;
static PyObject *__pyx_kp_376;
static char __pyx_k_375[] = "invalid value to append()";
static char __pyx_k_376[] = "invalid element";
static PyObject *__pyx_kp_377;
static PyObject *__pyx_kp_378;
static PyObject *__pyx_kp_379;
static PyObject *__pyx_kp_380;
static char __pyx_k_377[] = "element class must be subclass of ElementBase";
static char __pyx_k_378[] = "comment class must be subclass of CommentBase";
static char __pyx_k_379[] = "Entity class must be subclass of EntityBase";
static char __pyx_k_380[] = "PI class must be subclass of PIBase";
static PyObject *__pyx_kp_384;
static char __pyx_k_381[] = "xml-stylesheet";
static char __pyx_k_382[] = "text/xsl";
static char __pyx_k_383[] = "text/xml";
static char __pyx_k_384[] = "Unknown node type: %s";
static PyObject *__pyx_kp_392;
static char __pyx_k_392[] = "Name not registered.";
static PyObject *__pyx_kp_393;
static char __pyx_k_393[] = "Name not registered.";
static PyObject *__pyx_kp_394;
static char __pyx_k_394[] = "Registered element classes must be subtypes of ElementBase";
static PyObject *__pyx_kp_395;
static char __pyx_k_395[] = "Namespace(%r)";
static PyObject *__pyx_kp_396;
static PyObject *__pyx_kp_397;
static char __pyx_k_396[] = "Registered functions must be callable.";
static char __pyx_k_397[] = "extensions must have non empty names";
static PyObject *__pyx_kp_398;
static char __pyx_k_398[] = "FunctionNamespace(%r)";
static PyObject *__pyx_kp_399;
static char __pyx_k_399[] = "";
static PyObject *__pyx_kp_400;
static char __pyx_k_400[] = "";
static PyObject *__pyx_kp_401;
static char __pyx_k_401[] = "argument must be a byte string or unicode string";
static PyObject *__pyx_kp_402;
static char __pyx_k_402[] = "Argument is not a file-like object";
static char __pyx_k_406[] = "<test/>";
static char __pyx_k_407[] = "UTF-16LE";
static char __pyx_k_408[] = "UTF-16BE";
static char __pyx_k_409[] = "UTF-16LE";
static char __pyx_k_410[] = "UTF-16BE";
static char __pyx_k_411[] = "UCS-4LE";
static char __pyx_k_412[] = "UCS-4BE";
static PyObject *__pyx_kp_413;
static char __pyx_k_413[] = "";
static PyObject *__pyx_kp_414;
static char __pyx_k_414[] = "reading from file-like objects must return byte strings or unicode strings";
static PyObject *__pyx_kp_415;
static char __pyx_k_415[] = "parser locking failed";
static PyObject *__pyx_kp_416;
static PyObject *__pyx_kp_417;
static PyObject *__pyx_kp_418;
static PyObject *__pyx_kp_419;
static char __pyx_k_416[] = "Error reading file '%s': %s";
static char __pyx_k_417[] = "Error reading '%s'";
static char __pyx_k_418[] = "Document is not well formed";
static char __pyx_k_419[] = "line %d: %s";
static char __pyx_k_422[] = "UTF-8";
static PyObject *__pyx_kp_423;
static PyObject *__pyx_kp_424;
static char __pyx_k_423[] = "This class cannot be instantiated";
static char __pyx_k_424[] = "unknown encoding: '%s'";
static char __pyx_k_425[] = "dummy";
static PyObject *__pyx_kp_426;
static char __pyx_k_426[] = "libxml2 %d.%d.%d";
static PyObject *__pyx_kp_427;
static char __pyx_k_427[] = "string is too long to parse it with libxml2";
static PyObject *__pyx_kp_428;
static PyObject *__pyx_kp_429;
static char __pyx_k_428[] = "Unicode parsing is not supported on this platform";
static char __pyx_k_429[] = "Parsing requires string data";
static PyObject *__pyx_kp_430;
static char __pyx_k_430[] = "no element found";
static char __pyx_k_431[] = "UTF-8";
static PyObject *__pyx_kp_435;
static char __pyx_k_435[] = "cannot parse from '%s'";
static PyObject *__pyx_kp_436;
static PyObject *__pyx_kp_437;
static char __pyx_k_436[] = "Unicode strings with encoding declaration are not supported.";
static char __pyx_k_437[] = "can only parse strings";
static PyObject *__pyx_kp_438;
static PyObject *__pyx_kp_439;
static char __pyx_k_438[] = "";
static char __pyx_k_439[] = "";
static char __pyx_k_440[] = "strict";
static PyObject *__pyx_kp_441;
static PyObject *__pyx_kp_442;
static char __pyx_k_441[] = "";
static char __pyx_k_442[] = "";
static PyObject *__pyx_kp_443;
static PyObject *__pyx_kp_444;
static PyObject *__pyx_kp_445;
static char __pyx_k_443[] = "";
static char __pyx_k_444[] = "internal error (tail)";
static char __pyx_k_445[] = "internal error (text)";
static PyObject *__pyx_kp_446;
static PyObject *__pyx_kp_447;
static char __pyx_k_446[] = "missing end tags";
static char __pyx_k_447[] = "missing toplevel element";
static PyObject *__pyx_kp_448;
static char __pyx_k_448[] = "end tag mismatch (expected %s, got %s)";
static PyObject *__pyx_kp_453;
static char __pyx_k_453[] = "unknown output method %r";
static PyObject *__pyx_kp_454;
static char __pyx_k_454[] = "UTF-8";
static char __pyx_k_456[] = "strict";
static char __pyx_k_457[] = "strict";
static PyObject *__pyx_kp_458;
static PyObject *__pyx_kp_459;
static char __pyx_k_458[] = "UTF-8";
static char __pyx_k_459[] = "unknown encoding: '%s'";
static char __pyx_k_460[] = "strict";
static char __pyx_k_461[] = "\n";
static char __pyx_k_462[] = "1.0";
static char __pyx_k_463[] = "<?xml version='";
static char __pyx_k_464[] = "' encoding='";
static char __pyx_k_465[] = "'?>\n";
static char __pyx_k_466[] = "<!DOCTYPE ";
static char __pyx_k_467[] = " PUBLIC \"";
static char __pyx_k_468[] = "\" \"";
static char __pyx_k_469[] = " SYSTEM \"";
static char __pyx_k_470[] = "\"";
static char __pyx_k_471[] = ">\n";
static char __pyx_k_472[] = " [\n";
static char __pyx_k_473[] = "]>\n";
static char __pyx_k_474[] = "\n";
static char __pyx_k_475[] = "\n";
static PyObject *__pyx_kp_476;
static char __pyx_k_476[] = "Could not create I/O writer context.";
static PyObject *__pyx_kp_477;
static char __pyx_k_477[] = "File is already closed";
static PyObject *__pyx_kp_479;
static PyObject *__pyx_kp_480;
static PyObject *__pyx_kp_482;
static char __pyx_k_479[] = "UTF-8";
static char __pyx_k_480[] = "unknown encoding: '%s'";
static char __pyx_k_482[] = "File or filename expected, got '%s'";
static PyObject *__pyx_kp_484;
static PyObject *__pyx_kp_485;
static char __pyx_k_484[] = "File or filename expected, got '%s'";
static char __pyx_k_485[] = "C14N failed";
static PyObject *__pyx_kp_486;
static char __pyx_k_486[] = "not a file";
static char __pyx_k_487[] = "\n";
static PyObject *__pyx_kp_490;
static PyObject *__pyx_kp_491;
static PyObject *__pyx_kp_494;
static char __pyx_k_490[] = "start-ns";
static char __pyx_k_491[] = "end-ns";
static char __pyx_k_494[] = "invalid event name '%s'";
static PyObject *__pyx_kp_495;
static PyObject *__pyx_kp_496;
static PyObject *__pyx_kp_497;
static char __pyx_k_495[] = "";
static char __pyx_k_496[] = "";
static char __pyx_k_497[] = "start-ns";
static PyObject *__pyx_kp_498;
static PyObject *__pyx_kp_499;
static PyObject *__pyx_kp_500;
static char __pyx_k_498[] = "*";
static char __pyx_k_499[] = "*";
static char __pyx_k_500[] = "*";
static PyObject *__pyx_kp_503;
static char __pyx_k_503[] = "end-ns";
static PyObject *__pyx_kp_508;
static PyObject *__pyx_kp_509;
static char __pyx_k_508[] = "start-ns";
static char __pyx_k_509[] = "end-ns";
static PyObject *__pyx_kp_510;
static char __pyx_k_510[] = "iterparse parsers cannot be copied";
static PyObject *__pyx_kp_511;
static char __pyx_k_511[] = "reading file objects must return plain strings";
static PyObject *__pyx_kp_512;
static PyObject *__pyx_kp_513;
static PyObject *__pyx_kp_514;
static char __pyx_k_512[] = "*";
static char __pyx_k_513[] = "*";
static char __pyx_k_514[] = "*";
static PyObject *__pyx_kp_517;
static char __pyx_k_517[] = "end-ns";
static PyObject *__pyx_kp_518;
static char __pyx_k_518[] = "//*[string(@id)]";
static PyObject *__pyx_kp_520;
static char __pyx_k_520[] = "No ID dictionary available.";
static PyObject *__pyx_kp_521;
static PyObject *__pyx_kp_522;
static char __pyx_k_521[] = "key not found.";
static char __pyx_k_522[] = "ID attribute not found.";
static PyObject *__pyx_kp_523;
static char __pyx_k_523[] = "XInclude processing failed";
static PyObject *__pyx_kp_164;
static PyObject *__pyx_kp_165;
static PyObject *__pyx_kp_524;
static PyObject *__pyx_kp_525;
static PyObject *__pyx_kp_526;
static char __pyx_k_524[] = "extensions must have non empty names";
static char __pyx_k_525[] = "empty namespace prefix is not supported in XPath";
static char __pyx_k_526[] = "setting default namespace is not supported in XPath";
static PyObject *__pyx_kp_527;
static char __pyx_k_527[] = "empty prefix is not supported in XPath";
static PyObject *__pyx_kp_528;
static char __pyx_k_528[] = "empty prefix is not supported in XPath";
static PyObject *__pyx_kp_529;
static PyObject *__pyx_kp_530;
static PyObject *__pyx_kp_531;
static PyObject *__pyx_kp_532;
static char __pyx_k_529[] = "XPath context is only usable during the evaluation";
static char __pyx_k_530[] = "no context node";
static char __pyx_k_531[] = "document-external context nodes are not supported";
static char __pyx_k_532[] = "document context is missing";
static PyObject *__pyx_kp_534;
static char __pyx_k_534[] = "";
static PyObject *__pyx_kp_538;
static PyObject *__pyx_kp_540;
static char __pyx_k_538[] = "";
static char __pyx_k_540[] = "";
static PyObject *__pyx_kp_544;
static char __pyx_k_544[] = "http://exslt.org/regular-expressions";
static PyObject *__pyx_kp_548;
static PyObject *__pyx_kp_549;
static char __pyx_k_548[] = "This is not a node: %r";
static char __pyx_k_549[] = "Unknown return type: %s";
static PyObject *__pyx_kp_550;
static PyObject *__pyx_kp_551;
static char __pyx_k_550[] = "Undefined xpath result";
static char __pyx_k_551[] = "Unknown xpath result %s";
static PyObject *__pyx_kp_552;
static char __pyx_k_552[] = "Not yet implemented result node type: %d";
static PyObject *__pyx_kp_553;
static PyObject *__pyx_kp_554;
static char __pyx_k_553[] = "{%s}%s";
static char __pyx_k_554[] = "XPath function '%s' not found";
static PyObject *__pyx_kp_555;
static PyObject *__pyx_kp_556;
static char __pyx_k_555[] = "This version of libxml2 has a known XPath bug. ";
static char __pyx_k_556[] = "Use it at your own risk.";
static PyObject *__pyx_kp_557;
static char __pyx_k_557[] = "parser locking failed";
static PyObject *__pyx_kp_558;
static char __pyx_k_558[] = "Error in xpath expression";
static PyObject *__pyx_kp_559;
static char __pyx_k_559[] = "Error in xpath expression";
static PyObject *__pyx_kp_560;
static PyObject *__pyx_kp_566;
static char __pyx_k_560[] = "";
static char __pyx_k_561[] = "__xpp%02d";
static char __pyx_k_562[] = "UTF-8";
static char __pyx_k_563[] = "strict";
static char __pyx_k_564[] = "UTF-8";
static char __pyx_k_565[] = "strict";
static char __pyx_k_566[] = ":";
static char __pyx_k_567[] = "UTF-8";
static char __pyx_k_568[] = "strict";
static char __pyx_k_569[] = "string://";
static char __pyx_k_570[] = "string://";
static char __pyx_k_571[] = "<string>";
static PyObject *__pyx_kp_572;
static char __pyx_k_572[] = "Cannot resolve URI %s";
static PyObject *__pyx_kp_578;
static PyObject *__pyx_kp_579;
static PyObject *__pyx_kp_580;
static PyObject *__pyx_kp_581;
static char __pyx_k_578[] = "%s(%s)";
static char __pyx_k_579[] = ".";
static char __pyx_k_580[] = ", ";
static char __pyx_k_581[] = "%s=%r";
static PyObject *__pyx_kp_582;
static char __pyx_k_582[] = "extensions must not have empty namespaces";
static PyObject *__pyx_kp_583;
static PyObject *__pyx_kp_584;
static char __pyx_k_583[] = "string://__STRING__XSLT__%d";
static char __pyx_k_584[] = "Cannot parse stylesheet";
static PyObject *__pyx_kp_585;
static PyObject *__pyx_kp_586;
static PyObject *__pyx_kp_587;
static char __pyx_k_585[] = "%s, line %d";
static char __pyx_k_586[] = "Error applying stylesheet, line %d";
static char __pyx_k_587[] = "Error applying stylesheet";
static PyObject *__pyx_kp_588;
static char __pyx_k_588[] = "";
static PyObject *__pyx_kp_589;
static char __pyx_k_589[] = "";
static char __pyx_k_590[] = "ascii";
static char __pyx_k_591[] = "strict";
static char __pyx_k_592[] = "B";
static PyObject *__pyx_kp_593;
static PyObject *__pyx_kp_595;
static char __pyx_k_593[] = "//xsl:stylesheet[@xml:id = $id]";
static char __pyx_k_595[] = "http://www.w3.org/1999/XSL/Transform";
static PyObject *__pyx_kp_596;
static PyObject *__pyx_kp_597;
static PyObject *__pyx_kp_598;
static PyObject *__pyx_kp_599;
static PyObject *__pyx_kp_600;
static char __pyx_k_596[] = "PI lacks content";
static char __pyx_k_597[] = " ";
static char __pyx_k_598[] = "malformed PI attributes";
static char __pyx_k_599[] = "reference to non-existing embedded stylesheet";
static char __pyx_k_600[] = "ambiguous reference to embedded stylesheet";
static PyObject *__pyx_kp_602;
static PyObject *__pyx_kp_603;
static PyObject *__pyx_kp_604;
static PyObject *__pyx_kp_605;
static PyObject *__pyx_kp_606;
static PyObject *__pyx_kp_607;
static PyObject *__pyx_kp_608;
static char __pyx_k_602[] = "only setting the 'href' attribute is supported on XSLT-PIs";
static char __pyx_k_603[] = "";
static char __pyx_k_604[] = "\"";
static char __pyx_k_605[] = ">";
static char __pyx_k_606[] = "Invalid URL, must not contain '\"' or '>'";
static char __pyx_k_607[] = " href=\"%s\"";
static char __pyx_k_608[] = " ";
static PyObject *__pyx_kp_609;
static char __pyx_k_609[] = " ";
static PyObject *__pyx_kp_611;
static char __pyx_k_610[] = "fake-parent";
static char __pyx_k_611[] = "unsupported XSLT result type: %d";
static PyObject *__pyx_kp_612;
static PyObject *__pyx_kp_613;
static char __pyx_k_612[] = "extension element %s not found";
static char __pyx_k_613[] = "UTF-8";
static char __pyx_k_614[] = "Error executing extension element '%s': %s";
static char __pyx_k_615[] = "Error executing extension element '%s'";
static PyObject *__pyx_kp_616;
static char __pyx_k_616[] = "Document does not comply with schema";
static PyObject *__pyx_kp_617;
static char __pyx_k_617[] = "Document does not comply with schema";
static PyObject *__pyx_kp_619;
static PyObject *__pyx_kp_620;
static PyObject *__pyx_kp_621;
static char __pyx_k_619[] = "file must be a filename or file-like object";
static char __pyx_k_620[] = "either filename or external ID required";
static char __pyx_k_621[] = "error parsing DTD";
static PyObject *__pyx_kp_622;
static PyObject *__pyx_kp_623;
static char __pyx_k_622[] = "Failed to create validation context";
static char __pyx_k_623[] = "Internal error in DTD validation";
static PyObject *__pyx_kp_624;
static char __pyx_k_624[] = "error parsing DTD";
static PyObject *__pyx_kp_626;
static PyObject *__pyx_kp_627;
static PyObject *__pyx_kp_628;
static PyObject *__pyx_kp_629;
static char __pyx_k_625[] = "http://relaxng.org/ns/structure/1.0";
static char __pyx_k_626[] = "Document is not Relax NG";
static char __pyx_k_627[] = "No tree or file given";
static char __pyx_k_628[] = "Document is not parsable as Relax NG";
static char __pyx_k_629[] = "Document is not valid Relax NG";
static PyObject *__pyx_kp_630;
static char __pyx_k_630[] = "Internal error in Relax NG validation";
static PyObject *__pyx_kp_632;
static PyObject *__pyx_kp_633;
static PyObject *__pyx_kp_634;
static char __pyx_k_631[] = "http://www.w3.org/2001/XMLSchema";
static char __pyx_k_632[] = "Document is not XML Schema";
static char __pyx_k_633[] = "No tree or file given";
static char __pyx_k_634[] = "Document is not valid XML Schema";
static PyObject *__pyx_kp_635;
static char __pyx_k_635[] = "Internal error in XML Schema validation.";
static PyObject *__pyx_kp_636;
static PyObject *__pyx_kp_637;
static PyObject *__pyx_kp_638;
static char __pyx_k_636[] = "lxml.etree was compiled without Schematron support.";
static char __pyx_k_637[] = "No tree or file given";
static char __pyx_k_638[] = "Document is not a valid Schematron schema";
static PyObject *__pyx_kp_639;
static char __pyx_k_639[] = "Internal error in Schematron validation";

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":123
 *     this one.
 *     """
 *     def __init__(self, message, error_log=None):             # <<<<<<<<<<<<<<
 *         if python.PY_VERSION_HEX >= 0x02050000:
 *             # Python >= 2.5 uses new style class exceptions
 */

static PyObject *__pyx_pf_4lxml_5etree_9LxmlError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4lxml_5etree_9LxmlError___init__ = {"__init__", (PyCFunction)__pyx_pf_4lxml_5etree_9LxmlError___init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pf_4lxml_5etree_9LxmlError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_error_log = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_self,&__pyx_kp_message,&__pyx_kp_error_log,0};
  __pyx_self = __pyx_self;
  __pyx_v_error_log = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_message);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_error_log = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_error_log = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_message = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.LxmlError.__init__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":124
 *     """
 *     def __init__(self, message, error_log=None):
 *         if python.PY_VERSION_HEX >= 0x02050000:             # <<<<<<<<<<<<<<
 *             # Python >= 2.5 uses new style class exceptions
 *             super(_LxmlError, self).__init__(message)
 */
  __pyx_1 = (PY_VERSION_HEX >= 0x02050000);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":126
 *         if python.PY_VERSION_HEX >= 0x02050000:
 *             # Python >= 2.5 uses new style class exceptions
 *             super(_LxmlError, self).__init__(message)             # <<<<<<<<<<<<<<
 *         else:
 *             error_super_init(self, message)
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_4lxml_5etree__LxmlError);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_4lxml_5etree__LxmlError);
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self);
    __pyx_3 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_kp___init__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":128
 *             super(_LxmlError, self).__init__(message)
 *         else:
 *             error_super_init(self, message)             # <<<<<<<<<<<<<<
 *         if error_log is None:
 *             self.error_log = __copyGlobalErrorLog()
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    Py_INCREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_message);
    __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree_error_super_init, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":129
 *         else:
 *             error_super_init(self, message)
 *         if error_log is None:             # <<<<<<<<<<<<<<
 *             self.error_log = __copyGlobalErrorLog()
 *         else:
 */
  __pyx_1 = (__pyx_v_error_log == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":130
 *             error_super_init(self, message)
 *         if error_log is None:
 *             self.error_log = __copyGlobalErrorLog()             # <<<<<<<<<<<<<<
 *         else:
 *             self.error_log = error_log.copy()
 */
    __pyx_4 = __pyx_f_4lxml_5etree___copyGlobalErrorLog(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_error_log, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":132
 *             self.error_log = __copyGlobalErrorLog()
 *         else:
 *             self.error_log = error_log.copy()             # <<<<<<<<<<<<<<
 * 
 * cdef object _LxmlError
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_error_log, __pyx_kp_copy); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_error_log, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L7:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.LxmlError.__init__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":153
 * 
 * # version information
 * cdef __unpackDottedVersion(version):             # <<<<<<<<<<<<<<
 *     version_list = []
 *     l = (version.decode(u"ASCII").replace(u'-', u'.').split(u'.') + [0]*4)[:4]
 */

static  PyObject *__pyx_f_4lxml_5etree___unpackDottedVersion(PyObject *__pyx_v_version) {
  PyObject *__pyx_v_version_list;
  PyObject *__pyx_v_l;
  PyObject *__pyx_v_item;
  PyObject *__pyx_v_count;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  int __pyx_10;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __pyx_v_version_list = Py_None; Py_INCREF(Py_None);
  __pyx_v_l = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);
  __pyx_v_count = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":154
 * # version information
 * cdef __unpackDottedVersion(version):
 *     version_list = []             # <<<<<<<<<<<<<<
 *     l = (version.decode(u"ASCII").replace(u'-', u'.').split(u'.') + [0]*4)[:4]
 *     for item in l:
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_version_list);
  __pyx_v_version_list = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":155
 * cdef __unpackDottedVersion(version):
 *     version_list = []
 *     l = (version.decode(u"ASCII").replace(u'-', u'.').split(u'.') + [0]*4)[:4]             # <<<<<<<<<<<<<<
 *     for item in l:
 *         try:
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_version, __pyx_kp_decode); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_212));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_212));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_kp_replace); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_213));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_213));
  Py_INCREF(((PyObject *)__pyx_kp_214));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_kp_214));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_kp_split); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_215));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_215));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_1 = PyList_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_int_0);
  __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_1), __pyx_int_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_2 = PySequence_GetSlice(__pyx_t_2, 0, 4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  Py_DECREF(__pyx_v_l);
  __pyx_v_l = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":156
 *     version_list = []
 *     l = (version.decode(u"ASCII").replace(u'-', u'.').split(u'.') + [0]*4)[:4]
 *     for item in l:             # <<<<<<<<<<<<<<
 *         try:
 *             item = int(item)
 */
  if (PyList_CheckExact(__pyx_v_l) || PyTuple_CheckExact(__pyx_v_l)) {
    __pyx_4 = 0; __pyx_1 = __pyx_v_l; Py_INCREF(__pyx_1);
  } else {
    __pyx_4 = -1; __pyx_1 = PyObject_GetIter(__pyx_v_l); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_4 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_1, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_1, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":157
 *     l = (version.decode(u"ASCII").replace(u'-', u'.').split(u'.') + [0]*4)[:4]
 *     for item in l:
 *         try:             # <<<<<<<<<<<<<<
 *             item = int(item)
 *         except ValueError:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":158
 *     for item in l:
 *         try:
 *             item = int(item)             # <<<<<<<<<<<<<<
 *         except ValueError:
 *             if item.startswith(u'dev'):
 */
        __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_INCREF(__pyx_v_item);
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_item);
        __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
        Py_DECREF(__pyx_v_item);
        __pyx_v_item = __pyx_3;
        __pyx_3 = 0;
      }
      Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L9_try;
      __pyx_L5_error:;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":159
 *         try:
 *             item = int(item)
 *         except ValueError:             # <<<<<<<<<<<<<<
 *             if item.startswith(u'dev'):
 *                 count = item[3:]
 */
      __pyx_5 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_5) {
        __Pyx_AddTraceback("lxml.etree.__unpackDottedVersion");
        if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":160
 *             item = int(item)
 *         except ValueError:
 *             if item.startswith(u'dev'):             # <<<<<<<<<<<<<<
 *                 count = item[3:]
 *                 item = -300
 */
        __pyx_7 = PyObject_GetAttr(__pyx_v_item, __pyx_kp_startswith); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __pyx_8 = PyTuple_New(1); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_INCREF(((PyObject *)__pyx_kp_216));
        PyTuple_SET_ITEM(__pyx_8, 0, ((PyObject *)__pyx_kp_216));
        __pyx_9 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_8), NULL); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(((PyObject *)__pyx_8)); __pyx_8 = 0;
        __pyx_10 = __Pyx_PyObject_IsTrue(__pyx_9); if (unlikely(__pyx_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_9); __pyx_9 = 0;
        if (__pyx_10) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":161
 *         except ValueError:
 *             if item.startswith(u'dev'):
 *                 count = item[3:]             # <<<<<<<<<<<<<<
 *                 item = -300
 *             elif item.startswith(u'alpha'):
 */
          __pyx_7 = PySequence_GetSlice(__pyx_v_item, 3, PY_SSIZE_T_MAX); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_DECREF(__pyx_v_count);
          __pyx_v_count = __pyx_7;
          __pyx_7 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":162
 *             if item.startswith(u'dev'):
 *                 count = item[3:]
 *                 item = -300             # <<<<<<<<<<<<<<
 *             elif item.startswith(u'alpha'):
 *                 count = item[5:]
 */
          Py_INCREF(__pyx_int_neg_300);
          Py_DECREF(__pyx_v_item);
          __pyx_v_item = __pyx_int_neg_300;
          goto __pyx_L10;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":163
 *                 count = item[3:]
 *                 item = -300
 *             elif item.startswith(u'alpha'):             # <<<<<<<<<<<<<<
 *                 count = item[5:]
 *                 item = -200
 */
        __pyx_8 = PyObject_GetAttr(__pyx_v_item, __pyx_kp_startswith); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __pyx_9 = PyTuple_New(1); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_INCREF(((PyObject *)__pyx_kp_217));
        PyTuple_SET_ITEM(__pyx_9, 0, ((PyObject *)__pyx_kp_217));
        __pyx_7 = PyObject_Call(__pyx_8, ((PyObject *)__pyx_9), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        Py_DECREF(((PyObject *)__pyx_9)); __pyx_9 = 0;
        __pyx_10 = __Pyx_PyObject_IsTrue(__pyx_7); if (unlikely(__pyx_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        if (__pyx_10) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":164
 *                 item = -300
 *             elif item.startswith(u'alpha'):
 *                 count = item[5:]             # <<<<<<<<<<<<<<
 *                 item = -200
 *             elif item.startswith(u'beta'):
 */
          __pyx_8 = PySequence_GetSlice(__pyx_v_item, 5, PY_SSIZE_T_MAX); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_DECREF(__pyx_v_count);
          __pyx_v_count = __pyx_8;
          __pyx_8 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":165
 *             elif item.startswith(u'alpha'):
 *                 count = item[5:]
 *                 item = -200             # <<<<<<<<<<<<<<
 *             elif item.startswith(u'beta'):
 *                 count = item[4:]
 */
          Py_INCREF(__pyx_int_neg_200);
          Py_DECREF(__pyx_v_item);
          __pyx_v_item = __pyx_int_neg_200;
          goto __pyx_L10;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":166
 *                 count = item[5:]
 *                 item = -200
 *             elif item.startswith(u'beta'):             # <<<<<<<<<<<<<<
 *                 count = item[4:]
 *                 item = -100
 */
        __pyx_9 = PyObject_GetAttr(__pyx_v_item, __pyx_kp_startswith); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_INCREF(((PyObject *)__pyx_kp_218));
        PyTuple_SET_ITEM(__pyx_7, 0, ((PyObject *)__pyx_kp_218));
        __pyx_8 = PyObject_Call(__pyx_9, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_9); __pyx_9 = 0;
        Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
        __pyx_10 = __Pyx_PyObject_IsTrue(__pyx_8); if (unlikely(__pyx_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        if (__pyx_10) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":167
 *                 item = -200
 *             elif item.startswith(u'beta'):
 *                 count = item[4:]             # <<<<<<<<<<<<<<
 *                 item = -100
 *             else:
 */
          __pyx_9 = PySequence_GetSlice(__pyx_v_item, 4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_DECREF(__pyx_v_count);
          __pyx_v_count = __pyx_9;
          __pyx_9 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":168
 *             elif item.startswith(u'beta'):
 *                 count = item[4:]
 *                 item = -100             # <<<<<<<<<<<<<<
 *             else:
 *                 count = 0
 */
          Py_INCREF(__pyx_int_neg_100);
          Py_DECREF(__pyx_v_item);
          __pyx_v_item = __pyx_int_neg_100;
          goto __pyx_L10;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":170
 *                 item = -100
 *             else:
 *                 count = 0             # <<<<<<<<<<<<<<
 *             if count:
 *                 item = item + int(count)
 */
          Py_INCREF(__pyx_int_0);
          Py_DECREF(__pyx_v_count);
          __pyx_v_count = __pyx_int_0;
        }
        __pyx_L10:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":171
 *             else:
 *                 count = 0
 *             if count:             # <<<<<<<<<<<<<<
 *                 item = item + int(count)
 *         version_list.append(item)
 */
        __pyx_10 = __Pyx_PyObject_IsTrue(__pyx_v_count); if (unlikely(__pyx_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        if (__pyx_10) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":172
 *                 count = 0
 *             if count:
 *                 item = item + int(count)             # <<<<<<<<<<<<<<
 *         version_list.append(item)
 *     return tuple(version_list)
 */
          __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_INCREF(__pyx_v_count);
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_count);
          __pyx_8 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
          __pyx_t_2 = PyNumber_Add(__pyx_v_item, __pyx_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_DECREF(__pyx_8); __pyx_8 = 0;
          Py_DECREF(__pyx_v_item);
          __pyx_v_item = __pyx_t_2;
          __pyx_t_2 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        goto __pyx_L6_exception_handled;
      }
      __pyx_L7_except_error:;
      Py_XDECREF(__pyx_save_exc_type);
      Py_XDECREF(__pyx_save_exc_value);
      Py_XDECREF(__pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L6_exception_handled:;
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L9_try:;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":173
 *             if count:
 *                 item = item + int(count)
 *         version_list.append(item)             # <<<<<<<<<<<<<<
 *     return tuple(version_list)
 * 
 */
    __pyx_9 = __Pyx_PyObject_Append(__pyx_v_version_list, __pyx_v_item); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_9); __pyx_9 = 0;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":174
 *                 item = item + int(count)
 *         version_list.append(item)
 *     return tuple(version_list)             # <<<<<<<<<<<<<<
 * 
 * cdef __unpackIntVersion(int c_version):
 */
  __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_version_list);
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_version_list);
  __pyx_8 = PyObject_Call(((PyObject *)((PyObject*)&PyTuple_Type)), ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
  __pyx_r = __pyx_8;
  __pyx_8 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("lxml.etree.__unpackDottedVersion");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_version_list);
  Py_DECREF(__pyx_v_l);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_count);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":176
 *     return tuple(version_list)
 * 
 * cdef __unpackIntVersion(int c_version):             # <<<<<<<<<<<<<<
 *     return (
 *         ((c_version / (100*100)) % 100),
 */

static  PyObject *__pyx_f_4lxml_5etree___unpackIntVersion(int __pyx_v_c_version) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":178
 * cdef __unpackIntVersion(int c_version):
 *     return (
 *         ((c_version / (100*100)) % 100),             # <<<<<<<<<<<<<<
 *         ((c_version / 100)       % 100),
 *         (c_version               % 100)
 */
  __pyx_1 = PyInt_FromLong(((__pyx_v_c_version / (100 * 100)) % 100)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":179
 *     return (
 *         ((c_version / (100*100)) % 100),
 *         ((c_version / 100)       % 100),             # <<<<<<<<<<<<<<
 *         (c_version               % 100)
 *         )
 */
  __pyx_2 = PyInt_FromLong(((__pyx_v_c_version / 100) % 100)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":180
 *         ((c_version / (100*100)) % 100),
 *         ((c_version / 100)       % 100),
 *         (c_version               % 100)             # <<<<<<<<<<<<<<
 *         )
 * 
 */
  __pyx_3 = PyInt_FromLong((__pyx_v_c_version % 100)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = ((PyObject *)__pyx_4);
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.__unpackIntVersion");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":201
 * cdef class _TempStore:
 *     cdef object _storage
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._storage = []
 * 
 */

static int __pyx_pf_4lxml_5etree_10_TempStore___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_10_TempStore___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":202
 *     cdef object _storage
 *     def __init__(self):
 *         self._storage = []             # <<<<<<<<<<<<<<
 * 
 *     cdef int add(self, obj) except -1:
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__TempStore *)__pyx_v_self)->_storage);
  ((struct __pyx_obj_4lxml_5etree__TempStore *)__pyx_v_self)->_storage = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._TempStore.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":204
 *         self._storage = []
 * 
 *     cdef int add(self, obj) except -1:             # <<<<<<<<<<<<<<
 *         python.PyList_Append(self._storage, obj)
 *         return 0
 */

static  int __pyx_f_4lxml_5etree_10_TempStore_add(struct __pyx_obj_4lxml_5etree__TempStore *__pyx_v_self, PyObject *__pyx_v_obj) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":205
 * 
 *     cdef int add(self, obj) except -1:
 *         python.PyList_Append(self._storage, obj)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_1 = PyList_Append(__pyx_v_self->_storage, __pyx_v_obj); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":206
 *     cdef int add(self, obj) except -1:
 *         python.PyList_Append(self._storage, obj)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int clear(self) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._TempStore.add");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":208
 *         return 0
 * 
 *     cdef int clear(self) except -1:             # <<<<<<<<<<<<<<
 *         del self._storage[:]
 *         return 0
 */

static  int __pyx_f_4lxml_5etree_10_TempStore_clear(struct __pyx_obj_4lxml_5etree__TempStore *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":209
 * 
 *     cdef int clear(self) except -1:
 *         del self._storage[:]             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  if (PySequence_DelSlice(__pyx_v_self->_storage, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":210
 *     cdef int clear(self) except -1:
 *         del self._storage[:]
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * # class for temporarily storing exceptions raised in extensions
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._TempStore.clear");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":215
 * cdef class _ExceptionContext:
 *     cdef object _exc_info
 *     cdef void clear(self):             # <<<<<<<<<<<<<<
 *         self._exc_info = None
 * 
 */

static  void __pyx_f_4lxml_5etree_17_ExceptionContext_clear(struct __pyx_obj_4lxml_5etree__ExceptionContext *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":216
 *     cdef object _exc_info
 *     cdef void clear(self):
 *         self._exc_info = None             # <<<<<<<<<<<<<<
 * 
 *     cdef void _store_raised(self):
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_self->_exc_info);
  __pyx_v_self->_exc_info = Py_None;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":218
 *         self._exc_info = None
 * 
 *     cdef void _store_raised(self):             # <<<<<<<<<<<<<<
 *         self._exc_info = sys.exc_info()
 * 
 */

static  void __pyx_f_4lxml_5etree_17_ExceptionContext__store_raised(struct __pyx_obj_4lxml_5etree__ExceptionContext *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":219
 * 
 *     cdef void _store_raised(self):
 *         self._exc_info = sys.exc_info()             # <<<<<<<<<<<<<<
 * 
 *     cdef void _store_exception(self, exception):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree_sys, __pyx_kp_exc_info); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->_exc_info);
  __pyx_v_self->_exc_info = __pyx_2;
  __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._ExceptionContext._store_raised");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":221
 *         self._exc_info = sys.exc_info()
 * 
 *     cdef void _store_exception(self, exception):             # <<<<<<<<<<<<<<
 *         self._exc_info = (exception, None, None)
 * 
 */

static  void __pyx_f_4lxml_5etree_17_ExceptionContext__store_exception(struct __pyx_obj_4lxml_5etree__ExceptionContext *__pyx_v_self, PyObject *__pyx_v_exception) {
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":222
 * 
 *     cdef void _store_exception(self, exception):
 *         self._exc_info = (exception, None, None)             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _has_raised(self):
 */
  __pyx_1 = PyTuple_New(3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_exception);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_exception);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_1, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_1, 2, Py_None);
  Py_DECREF(__pyx_v_self->_exc_info);
  __pyx_v_self->_exc_info = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("lxml.etree._ExceptionContext._store_exception");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":224
 *         self._exc_info = (exception, None, None)
 * 
 *     cdef bint _has_raised(self):             # <<<<<<<<<<<<<<
 *         return self._exc_info is not None
 * 
 */

static  int __pyx_f_4lxml_5etree_17_ExceptionContext__has_raised(struct __pyx_obj_4lxml_5etree__ExceptionContext *__pyx_v_self) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":225
 * 
 *     cdef bint _has_raised(self):
 *         return self._exc_info is not None             # <<<<<<<<<<<<<<
 * 
 *     cdef int _raise_if_stored(self) except -1:
 */
  __pyx_1 = (__pyx_v_self->_exc_info != Py_None);
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":227
 *         return self._exc_info is not None
 * 
 *     cdef int _raise_if_stored(self) except -1:             # <<<<<<<<<<<<<<
 *         if self._exc_info is None:
 *             return 0
 */

static  int __pyx_f_4lxml_5etree_17_ExceptionContext__raise_if_stored(struct __pyx_obj_4lxml_5etree__ExceptionContext *__pyx_v_self) {
  PyObject *__pyx_v_type;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_traceback;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_type = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);
  __pyx_v_traceback = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":228
 * 
 *     cdef int _raise_if_stored(self) except -1:
 *         if self._exc_info is None:             # <<<<<<<<<<<<<<
 *             return 0
 *         type, value, traceback = self._exc_info
 */
  __pyx_1 = (__pyx_v_self->_exc_info == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":229
 *     cdef int _raise_if_stored(self) except -1:
 *         if self._exc_info is None:
 *             return 0             # <<<<<<<<<<<<<<
 *         type, value, traceback = self._exc_info
 *         self._exc_info = None
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":230
 *         if self._exc_info is None:
 *             return 0
 *         type, value, traceback = self._exc_info             # <<<<<<<<<<<<<<
 *         self._exc_info = None
 *         if value is None and traceback is None:
 */
  if (PyTuple_CheckExact(__pyx_v_self->_exc_info) && PyTuple_GET_SIZE(__pyx_v_self->_exc_info) == 3) {
    PyObject* tuple = __pyx_v_self->_exc_info;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_type);
    __pyx_v_type = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 2);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_traceback);
    __pyx_v_traceback = __pyx_3;
    __pyx_3 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_v_self->_exc_info); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_type);
    __pyx_v_type = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_traceback);
    __pyx_v_traceback = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":231
 *             return 0
 *         type, value, traceback = self._exc_info
 *         self._exc_info = None             # <<<<<<<<<<<<<<
 *         if value is None and traceback is None:
 *             raise type
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_self->_exc_info);
  __pyx_v_self->_exc_info = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":232
 *         type, value, traceback = self._exc_info
 *         self._exc_info = None
 *         if value is None and traceback is None:             # <<<<<<<<<<<<<<
 *             raise type
 *         else:
 */
  __pyx_1 = (__pyx_v_value == Py_None);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_traceback == Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":233
 *         self._exc_info = None
 *         if value is None and traceback is None:
 *             raise type             # <<<<<<<<<<<<<<
 *         else:
 *             raise type, value, traceback
 */
    __Pyx_Raise(__pyx_v_type, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":235
 *             raise type
 *         else:
 *             raise type, value, traceback             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_Raise(__pyx_v_type, __pyx_v_value, __pyx_v_traceback);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ExceptionContext._raise_if_stored");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_type);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_traceback);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":252
 *     """
 *     cdef readonly object text
 *     def __init__(self, text_or_uri, tag=None):             # <<<<<<<<<<<<<<
 *         if tag is not None:
 *             _tagValidOrRaise(_utf8(tag))
 */

static int __pyx_pf_4lxml_5etree_5QName___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_5QName___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text_or_uri = 0;
  PyObject *__pyx_v_tag = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_text_or_uri,&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_text_or_uri);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_text_or_uri = values[0];
    if (values[1]) {
      __pyx_v_tag = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_text_or_uri = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.QName.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_text_or_uri);
  Py_INCREF(__pyx_v_tag);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":253
 *     cdef readonly object text
 *     def __init__(self, text_or_uri, tag=None):
 *         if tag is not None:             # <<<<<<<<<<<<<<
 *             _tagValidOrRaise(_utf8(tag))
 *             text_or_uri = u"{%s}%s" % (text_or_uri, tag)
 */
  __pyx_1 = (__pyx_v_tag != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":254
 *     def __init__(self, text_or_uri, tag=None):
 *         if tag is not None:
 *             _tagValidOrRaise(_utf8(tag))             # <<<<<<<<<<<<<<
 *             text_or_uri = u"{%s}%s" % (text_or_uri, tag)
 *         else:
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_tag); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__tagValidOrRaise(__pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":255
 *         if tag is not None:
 *             _tagValidOrRaise(_utf8(tag))
 *             text_or_uri = u"{%s}%s" % (text_or_uri, tag)             # <<<<<<<<<<<<<<
 *         else:
 *             if not _isString(text_or_uri):
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_text_or_uri);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_text_or_uri);
    Py_INCREF(__pyx_v_tag);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_tag);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_219), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_text_or_uri);
    __pyx_v_text_or_uri = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":257
 *             text_or_uri = u"{%s}%s" % (text_or_uri, tag)
 *         else:
 *             if not _isString(text_or_uri):             # <<<<<<<<<<<<<<
 *                 text_or_uri = unicode(text_or_uri)
 *             tag = _getNsTag(text_or_uri)[1]
 */
    __pyx_1 = (!_isString(__pyx_v_text_or_uri));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":258
 *         else:
 *             if not _isString(text_or_uri):
 *                 text_or_uri = unicode(text_or_uri)             # <<<<<<<<<<<<<<
 *             tag = _getNsTag(text_or_uri)[1]
 *             _tagValidOrRaise(tag)
 */
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_text_or_uri);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_text_or_uri);
      __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      Py_DECREF(__pyx_v_text_or_uri);
      __pyx_v_text_or_uri = __pyx_4;
      __pyx_4 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":259
 *             if not _isString(text_or_uri):
 *                 text_or_uri = unicode(text_or_uri)
 *             tag = _getNsTag(text_or_uri)[1]             # <<<<<<<<<<<<<<
 *             _tagValidOrRaise(tag)
 *         self.text = text_or_uri
 */
    __pyx_2 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_text_or_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_GetItemInt(__pyx_2, 1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":260
 *                 text_or_uri = unicode(text_or_uri)
 *             tag = _getNsTag(text_or_uri)[1]
 *             _tagValidOrRaise(tag)             # <<<<<<<<<<<<<<
 *         self.text = text_or_uri
 *     def __str__(self):
 */
    __pyx_3 = __pyx_f_4lxml_5etree__tagValidOrRaise(__pyx_v_tag); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":261
 *             tag = _getNsTag(text_or_uri)[1]
 *             _tagValidOrRaise(tag)
 *         self.text = text_or_uri             # <<<<<<<<<<<<<<
 *     def __str__(self):
 *         return self.text
 */
  Py_INCREF(__pyx_v_text_or_uri);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_self)->text);
  ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_self)->text = __pyx_v_text_or_uri;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.QName.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text_or_uri);
  Py_DECREF(__pyx_v_tag);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":262
 *             _tagValidOrRaise(tag)
 *         self.text = text_or_uri
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return self.text
 *     def __hash__(self):
 */

static PyObject *__pyx_pf_4lxml_5etree_5QName___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_5QName___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":263
 *         self.text = text_or_uri
 *     def __str__(self):
 *         return self.text             # <<<<<<<<<<<<<<
 *     def __hash__(self):
 *         return self.text.__hash__()
 */
  Py_INCREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_self)->text);
  __pyx_r = ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_self)->text;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":264
 *     def __str__(self):
 *         return self.text
 *     def __hash__(self):             # <<<<<<<<<<<<<<
 *         return self.text.__hash__()
 *     def __richcmp__(one, other, int op):
 */

static long __pyx_pf_4lxml_5etree_5QName___hash__(PyObject *__pyx_v_self); /*proto*/
static long __pyx_pf_4lxml_5etree_5QName___hash__(PyObject *__pyx_v_self) {
  long __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  long __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":265
 *         return self.text
 *     def __hash__(self):
 *         return self.text.__hash__()             # <<<<<<<<<<<<<<
 *     def __richcmp__(one, other, int op):
 *         if not _isString(one):
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_self)->text, __pyx_kp___hash__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = __pyx_PyInt_long(__pyx_2); if (unlikely((__pyx_3 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.QName.__hash__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":266
 *     def __hash__(self):
 *         return self.text.__hash__()
 *     def __richcmp__(one, other, int op):             # <<<<<<<<<<<<<<
 *         if not _isString(one):
 *             one = unicode(one)
 */

static PyObject *__pyx_pf_4lxml_5etree_5QName___richcmp__(PyObject *__pyx_v_one, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_5QName___richcmp__(PyObject *__pyx_v_one, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_one);
  Py_INCREF(__pyx_v_other);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":267
 *         return self.text.__hash__()
 *     def __richcmp__(one, other, int op):
 *         if not _isString(one):             # <<<<<<<<<<<<<<
 *             one = unicode(one)
 *         if not _isString(other):
 */
  __pyx_1 = (!_isString(__pyx_v_one));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":268
 *     def __richcmp__(one, other, int op):
 *         if not _isString(one):
 *             one = unicode(one)             # <<<<<<<<<<<<<<
 *         if not _isString(other):
 *             other = unicode(other)
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_one);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_one);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_one);
    __pyx_v_one = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":269
 *         if not _isString(one):
 *             one = unicode(one)
 *         if not _isString(other):             # <<<<<<<<<<<<<<
 *             other = unicode(other)
 *         return python.PyObject_RichCompare(one, other, op)
 */
  __pyx_1 = (!_isString(__pyx_v_other));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":270
 *             one = unicode(one)
 *         if not _isString(other):
 *             other = unicode(other)             # <<<<<<<<<<<<<<
 *         return python.PyObject_RichCompare(one, other, op)
 * 
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_other);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_other);
    __pyx_v_other = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":271
 *         if not _isString(other):
 *             other = unicode(other)
 *         return python.PyObject_RichCompare(one, other, op)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_2 = PyObject_RichCompare(__pyx_v_one, __pyx_v_other, __pyx_v_op); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.QName.__richcmp__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_one);
  Py_DECREF(__pyx_v_other);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":291
 *     cdef _BaseParser _parser
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # if there are no more references to the document, it is safe
 *         # to clean the whole thing up, as all nodes have a reference to
 */

static void __pyx_pf_4lxml_5etree_9_Document___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_9_Document___dealloc__(PyObject *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":299
 *         #print <long>self._c_doc, self._c_doc.dict is __GLOBAL_PARSER_CONTEXT._c_dict
 *         #print <long>self._c_doc, canDeallocateChildNodes(<xmlNode*>self._c_doc)
 *         tree.xmlFreeDoc(self._c_doc)             # <<<<<<<<<<<<<<
 *         #_deallocDocument(self._c_doc)
 * 
 */
  xmlFreeDoc(((struct LxmlDocument *)__pyx_v_self)->_c_doc);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":302
 *         #_deallocDocument(self._c_doc)
 * 
 *     cdef getroot(self):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         c_node = tree.xmlDocGetRootElement(self._c_doc)
 */

static  PyObject *__pyx_f_4lxml_5etree_9_Document_getroot(struct LxmlDocument *__pyx_v_self) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":304
 *     cdef getroot(self):
 *         cdef xmlNode* c_node
 *         c_node = tree.xmlDocGetRootElement(self._c_doc)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             return None
 */
  __pyx_v_c_node = xmlDocGetRootElement(__pyx_v_self->_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":305
 *         cdef xmlNode* c_node
 *         c_node = tree.xmlDocGetRootElement(self._c_doc)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return _elementFactory(self, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":306
 *         c_node = tree.xmlDocGetRootElement(self._c_doc)
 *         if c_node is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return _elementFactory(self, c_node)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":307
 *         if c_node is NULL:
 *             return None
 *         return _elementFactory(self, c_node)             # <<<<<<<<<<<<<<
 * 
 *     cdef bint hasdoctype(self):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_self, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Document.getroot");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":309
 *         return _elementFactory(self, c_node)
 * 
 *     cdef bint hasdoctype(self):             # <<<<<<<<<<<<<<
 *         return self._c_doc.intSubset is not NULL
 * 
 */

static  int __pyx_f_4lxml_5etree_9_Document_hasdoctype(struct LxmlDocument *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":310
 * 
 *     cdef bint hasdoctype(self):
 *         return self._c_doc.intSubset is not NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef getdoctype(self):
 */
  __pyx_r = (__pyx_v_self->_c_doc->intSubset != NULL);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":312
 *         return self._c_doc.intSubset is not NULL
 * 
 *     cdef getdoctype(self):             # <<<<<<<<<<<<<<
 *         cdef tree.xmlDtd* c_dtd
 *         cdef xmlNode* c_root_node
 */

static  PyObject *__pyx_f_4lxml_5etree_9_Document_getdoctype(struct LxmlDocument *__pyx_v_self) {
  xmlDtd *__pyx_v_c_dtd;
  xmlNode *__pyx_v_c_root_node;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_sys_url;
  PyObject *__pyx_v_root_name;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_sys_url = Py_None; Py_INCREF(Py_None);
  __pyx_v_root_name = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":315
 *         cdef tree.xmlDtd* c_dtd
 *         cdef xmlNode* c_root_node
 *         public_id = None             # <<<<<<<<<<<<<<
 *         sys_url   = None
 *         c_dtd = self._c_doc.intSubset
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_public_id);
  __pyx_v_public_id = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":316
 *         cdef xmlNode* c_root_node
 *         public_id = None
 *         sys_url   = None             # <<<<<<<<<<<<<<
 *         c_dtd = self._c_doc.intSubset
 *         if c_dtd is not NULL:
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_sys_url);
  __pyx_v_sys_url = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":317
 *         public_id = None
 *         sys_url   = None
 *         c_dtd = self._c_doc.intSubset             # <<<<<<<<<<<<<<
 *         if c_dtd is not NULL:
 *             if c_dtd.ExternalID is not NULL:
 */
  __pyx_v_c_dtd = __pyx_v_self->_c_doc->intSubset;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":318
 *         sys_url   = None
 *         c_dtd = self._c_doc.intSubset
 *         if c_dtd is not NULL:             # <<<<<<<<<<<<<<
 *             if c_dtd.ExternalID is not NULL:
 *                 public_id = funicode(c_dtd.ExternalID)
 */
  __pyx_1 = (__pyx_v_c_dtd != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":319
 *         c_dtd = self._c_doc.intSubset
 *         if c_dtd is not NULL:
 *             if c_dtd.ExternalID is not NULL:             # <<<<<<<<<<<<<<
 *                 public_id = funicode(c_dtd.ExternalID)
 *             if c_dtd.SystemID is not NULL:
 */
    __pyx_1 = (__pyx_v_c_dtd->ExternalID != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":320
 *         if c_dtd is not NULL:
 *             if c_dtd.ExternalID is not NULL:
 *                 public_id = funicode(c_dtd.ExternalID)             # <<<<<<<<<<<<<<
 *             if c_dtd.SystemID is not NULL:
 *                 sys_url = funicode(c_dtd.SystemID)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_dtd->ExternalID); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_public_id);
      __pyx_v_public_id = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":321
 *             if c_dtd.ExternalID is not NULL:
 *                 public_id = funicode(c_dtd.ExternalID)
 *             if c_dtd.SystemID is not NULL:             # <<<<<<<<<<<<<<
 *                 sys_url = funicode(c_dtd.SystemID)
 *         c_dtd = self._c_doc.extSubset
 */
    __pyx_1 = (__pyx_v_c_dtd->SystemID != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":322
 *                 public_id = funicode(c_dtd.ExternalID)
 *             if c_dtd.SystemID is not NULL:
 *                 sys_url = funicode(c_dtd.SystemID)             # <<<<<<<<<<<<<<
 *         c_dtd = self._c_doc.extSubset
 *         if c_dtd is not NULL:
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_dtd->SystemID); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_sys_url);
      __pyx_v_sys_url = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":323
 *             if c_dtd.SystemID is not NULL:
 *                 sys_url = funicode(c_dtd.SystemID)
 *         c_dtd = self._c_doc.extSubset             # <<<<<<<<<<<<<<
 *         if c_dtd is not NULL:
 *             if not public_id and c_dtd.ExternalID is not NULL:
 */
  __pyx_v_c_dtd = __pyx_v_self->_c_doc->extSubset;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":324
 *                 sys_url = funicode(c_dtd.SystemID)
 *         c_dtd = self._c_doc.extSubset
 *         if c_dtd is not NULL:             # <<<<<<<<<<<<<<
 *             if not public_id and c_dtd.ExternalID is not NULL:
 *                 public_id = funicode(c_dtd.ExternalID)
 */
  __pyx_1 = (__pyx_v_c_dtd != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":325
 *         c_dtd = self._c_doc.extSubset
 *         if c_dtd is not NULL:
 *             if not public_id and c_dtd.ExternalID is not NULL:             # <<<<<<<<<<<<<<
 *                 public_id = funicode(c_dtd.ExternalID)
 *             if not sys_url and c_dtd.SystemID is not NULL:
 */
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_public_id); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = (!__pyx_3);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c_dtd->ExternalID != NULL);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":326
 *         if c_dtd is not NULL:
 *             if not public_id and c_dtd.ExternalID is not NULL:
 *                 public_id = funicode(c_dtd.ExternalID)             # <<<<<<<<<<<<<<
 *             if not sys_url and c_dtd.SystemID is not NULL:
 *                 sys_url = funicode(c_dtd.SystemID)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_dtd->ExternalID); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_public_id);
      __pyx_v_public_id = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":327
 *             if not public_id and c_dtd.ExternalID is not NULL:
 *                 public_id = funicode(c_dtd.ExternalID)
 *             if not sys_url and c_dtd.SystemID is not NULL:             # <<<<<<<<<<<<<<
 *                 sys_url = funicode(c_dtd.SystemID)
 *         c_root_node = tree.xmlDocGetRootElement(self._c_doc)
 */
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_sys_url); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = (!__pyx_1);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_c_dtd->SystemID != NULL);
    }
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":328
 *                 public_id = funicode(c_dtd.ExternalID)
 *             if not sys_url and c_dtd.SystemID is not NULL:
 *                 sys_url = funicode(c_dtd.SystemID)             # <<<<<<<<<<<<<<
 *         c_root_node = tree.xmlDocGetRootElement(self._c_doc)
 *         if c_root_node is NULL:
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_dtd->SystemID); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_sys_url);
      __pyx_v_sys_url = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":329
 *             if not sys_url and c_dtd.SystemID is not NULL:
 *                 sys_url = funicode(c_dtd.SystemID)
 *         c_root_node = tree.xmlDocGetRootElement(self._c_doc)             # <<<<<<<<<<<<<<
 *         if c_root_node is NULL:
 *             root_name = None
 */
  __pyx_v_c_root_node = xmlDocGetRootElement(__pyx_v_self->_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":330
 *                 sys_url = funicode(c_dtd.SystemID)
 *         c_root_node = tree.xmlDocGetRootElement(self._c_doc)
 *         if c_root_node is NULL:             # <<<<<<<<<<<<<<
 *             root_name = None
 *         else:
 */
  __pyx_1 = (__pyx_v_c_root_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":331
 *         c_root_node = tree.xmlDocGetRootElement(self._c_doc)
 *         if c_root_node is NULL:
 *             root_name = None             # <<<<<<<<<<<<<<
 *         else:
 *             root_name = funicode(c_root_node.name)
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = Py_None;
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":333
 *             root_name = None
 *         else:
 *             root_name = funicode(c_root_node.name)             # <<<<<<<<<<<<<<
 *         return (root_name, public_id, sys_url)
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_root_node->name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":334
 *         else:
 *             root_name = funicode(c_root_node.name)
 *         return (root_name, public_id, sys_url)             # <<<<<<<<<<<<<<
 * 
 *     cdef getxmlinfo(self):
 */
  __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_root_name);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_root_name);
  Py_INCREF(__pyx_v_public_id);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_public_id);
  Py_INCREF(__pyx_v_sys_url);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_sys_url);
  __pyx_r = ((PyObject *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Document.getdoctype");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_sys_url);
  Py_DECREF(__pyx_v_root_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":336
 *         return (root_name, public_id, sys_url)
 * 
 *     cdef getxmlinfo(self):             # <<<<<<<<<<<<<<
 *         cdef xmlDoc* c_doc
 *         c_doc = self._c_doc
 */

static  PyObject *__pyx_f_4lxml_5etree_9_Document_getxmlinfo(struct LxmlDocument *__pyx_v_self) {
  xmlDoc *__pyx_v_c_doc;
  PyObject *__pyx_v_version;
  PyObject *__pyx_v_encoding;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_version = Py_None; Py_INCREF(Py_None);
  __pyx_v_encoding = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":338
 *     cdef getxmlinfo(self):
 *         cdef xmlDoc* c_doc
 *         c_doc = self._c_doc             # <<<<<<<<<<<<<<
 *         if c_doc.version is NULL:
 *             version = None
 */
  __pyx_v_c_doc = __pyx_v_self->_c_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":339
 *         cdef xmlDoc* c_doc
 *         c_doc = self._c_doc
 *         if c_doc.version is NULL:             # <<<<<<<<<<<<<<
 *             version = None
 *         else:
 */
  __pyx_1 = (__pyx_v_c_doc->version == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":340
 *         c_doc = self._c_doc
 *         if c_doc.version is NULL:
 *             version = None             # <<<<<<<<<<<<<<
 *         else:
 *             version = funicode(c_doc.version)
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_version);
    __pyx_v_version = Py_None;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":342
 *             version = None
 *         else:
 *             version = funicode(c_doc.version)             # <<<<<<<<<<<<<<
 *         if c_doc.encoding is NULL:
 *             encoding = None
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_doc->version); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_version);
    __pyx_v_version = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":343
 *         else:
 *             version = funicode(c_doc.version)
 *         if c_doc.encoding is NULL:             # <<<<<<<<<<<<<<
 *             encoding = None
 *         else:
 */
  __pyx_1 = (__pyx_v_c_doc->encoding == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":344
 *             version = funicode(c_doc.version)
 *         if c_doc.encoding is NULL:
 *             encoding = None             # <<<<<<<<<<<<<<
 *         else:
 *             encoding = funicode(c_doc.encoding)
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = Py_None;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":346
 *             encoding = None
 *         else:
 *             encoding = funicode(c_doc.encoding)             # <<<<<<<<<<<<<<
 *         return (version, encoding)
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_doc->encoding); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":347
 *         else:
 *             encoding = funicode(c_doc.encoding)
 *         return (version, encoding)             # <<<<<<<<<<<<<<
 * 
 *     cdef buildNewPrefix(self):
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_version);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_version);
  Py_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_encoding);
  __pyx_r = ((PyObject *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Document.getxmlinfo");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_version);
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":349
 *         return (version, encoding)
 * 
 *     cdef buildNewPrefix(self):             # <<<<<<<<<<<<<<
 *         if self._ns_counter < python.PyTuple_GET_SIZE(_PREFIX_CACHE):
 *             ns = python.PyTuple_GET_ITEM(_PREFIX_CACHE, self._ns_counter)
 */

static  PyObject *__pyx_f_4lxml_5etree_9_Document_buildNewPrefix(struct LxmlDocument *__pyx_v_self) {
  PyObject *__pyx_v_ns;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":350
 * 
 *     cdef buildNewPrefix(self):
 *         if self._ns_counter < python.PyTuple_GET_SIZE(_PREFIX_CACHE):             # <<<<<<<<<<<<<<
 *             ns = python.PyTuple_GET_ITEM(_PREFIX_CACHE, self._ns_counter)
 *             python.Py_INCREF(ns)
 */
  __pyx_1 = (__pyx_v_self->_ns_counter < PyTuple_GET_SIZE(__pyx_v_4lxml_5etree__PREFIX_CACHE));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":351
 *     cdef buildNewPrefix(self):
 *         if self._ns_counter < python.PyTuple_GET_SIZE(_PREFIX_CACHE):
 *             ns = python.PyTuple_GET_ITEM(_PREFIX_CACHE, self._ns_counter)             # <<<<<<<<<<<<<<
 *             python.Py_INCREF(ns)
 *         else:
 */
    __pyx_2 = PyTuple_GET_ITEM(__pyx_v_4lxml_5etree__PREFIX_CACHE, __pyx_v_self->_ns_counter); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":352
 *         if self._ns_counter < python.PyTuple_GET_SIZE(_PREFIX_CACHE):
 *             ns = python.PyTuple_GET_ITEM(_PREFIX_CACHE, self._ns_counter)
 *             python.Py_INCREF(ns)             # <<<<<<<<<<<<<<
 *         else:
 *             ns = python.PyString_FromFormat("ns%d", self._ns_counter)
 */
    Py_INCREF(__pyx_v_ns);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":354
 *             python.Py_INCREF(ns)
 *         else:
 *             ns = python.PyString_FromFormat("ns%d", self._ns_counter)             # <<<<<<<<<<<<<<
 *         if self._prefix_tail is not None:
 *             ns += self._prefix_tail
 */
    __pyx_2 = PyString_FromFormat(__pyx_k_220, __pyx_v_self->_ns_counter); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":355
 *         else:
 *             ns = python.PyString_FromFormat("ns%d", self._ns_counter)
 *         if self._prefix_tail is not None:             # <<<<<<<<<<<<<<
 *             ns += self._prefix_tail
 *         self._ns_counter += 1
 */
  __pyx_1 = (__pyx_v_self->_prefix_tail != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":356
 *             ns = python.PyString_FromFormat("ns%d", self._ns_counter)
 *         if self._prefix_tail is not None:
 *             ns += self._prefix_tail             # <<<<<<<<<<<<<<
 *         self._ns_counter += 1
 *         if self._ns_counter < 0:
 */
    __pyx_2 = PyNumber_InPlaceAdd(__pyx_v_ns, __pyx_v_self->_prefix_tail); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":357
 *         if self._prefix_tail is not None:
 *             ns += self._prefix_tail
 *         self._ns_counter += 1             # <<<<<<<<<<<<<<
 *         if self._ns_counter < 0:
 *             # overflow!
 */
  __pyx_v_self->_ns_counter += 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":358
 *             ns += self._prefix_tail
 *         self._ns_counter += 1
 *         if self._ns_counter < 0:             # <<<<<<<<<<<<<<
 *             # overflow!
 *             self._ns_counter = 0
 */
  __pyx_1 = (__pyx_v_self->_ns_counter < 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":360
 *         if self._ns_counter < 0:
 *             # overflow!
 *             self._ns_counter = 0             # <<<<<<<<<<<<<<
 *             if self._prefix_tail is None:
 *                 self._prefix_tail = "A"
 */
    __pyx_v_self->_ns_counter = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":361
 *             # overflow!
 *             self._ns_counter = 0
 *             if self._prefix_tail is None:             # <<<<<<<<<<<<<<
 *                 self._prefix_tail = "A"
 *             else:
 */
    __pyx_1 = (__pyx_v_self->_prefix_tail == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":362
 *             self._ns_counter = 0
 *             if self._prefix_tail is None:
 *                 self._prefix_tail = "A"             # <<<<<<<<<<<<<<
 *             else:
 *                 self._prefix_tail += "A"
 */
      Py_INCREF(__pyx_kp_221);
      Py_DECREF(__pyx_v_self->_prefix_tail);
      __pyx_v_self->_prefix_tail = __pyx_kp_221;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":364
 *                 self._prefix_tail = "A"
 *             else:
 *                 self._prefix_tail += "A"             # <<<<<<<<<<<<<<
 *         return ns
 * 
 */
      __pyx_2 = PyNumber_InPlaceAdd(__pyx_v_self->_prefix_tail, __pyx_kp_222); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_self->_prefix_tail);
      __pyx_v_self->_prefix_tail = __pyx_2;
      __pyx_2 = 0;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":365
 *             else:
 *                 self._prefix_tail += "A"
 *         return ns             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlNs* _findOrBuildNodeNs(self, xmlNode* c_node,
 */
  Py_INCREF(__pyx_v_ns);
  __pyx_r = __pyx_v_ns;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Document.buildNewPrefix");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":367
 *         return ns
 * 
 *     cdef xmlNs* _findOrBuildNodeNs(self, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                                    char* c_href, char* c_prefix) except NULL:
 *         u"""Get or create namespace structure for a node.  Reuses the prefix if
 */

static  xmlNs *__pyx_f_4lxml_5etree_9_Document__findOrBuildNodeNs(struct LxmlDocument *__pyx_v_self, xmlNode *__pyx_v_c_node, char *__pyx_v_c_href, char *__pyx_v_c_prefix) {
  xmlNs *__pyx_v_c_ns;
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_v_prefix;
  xmlNs *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":375
 *         cdef xmlNs* c_doc_ns
 *         cdef python.PyObject* dict_result
 *         if c_node.type != tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *             assert c_node.type == tree.XML_ELEMENT_NODE, \
 *                 u"invalid node type %d, expected %d" % (
 */
  __pyx_1 = (__pyx_v_c_node->type != XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":376
 *         cdef python.PyObject* dict_result
 *         if c_node.type != tree.XML_ELEMENT_NODE:
 *             assert c_node.type == tree.XML_ELEMENT_NODE, \             # <<<<<<<<<<<<<<
 *                 u"invalid node type %d, expected %d" % (
 *                 c_node.type, tree.XML_ELEMENT_NODE)
 */
    #ifndef PYREX_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_c_node->type == XML_ELEMENT_NODE))) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":378
 *             assert c_node.type == tree.XML_ELEMENT_NODE, \
 *                 u"invalid node type %d, expected %d" % (
 *                 c_node.type, tree.XML_ELEMENT_NODE)             # <<<<<<<<<<<<<<
 *         # look for existing ns
 *         c_ns = tree.xmlSearchNsByHref(self._c_doc, c_node, c_href)
 */
      __pyx_2 = PyInt_FromLong(__pyx_v_c_node->type); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyInt_FromLong(XML_ELEMENT_NODE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
      __pyx_2 = 0;
      __pyx_3 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_223), ((PyObject *)__pyx_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":380
 *                 c_node.type, tree.XML_ELEMENT_NODE)
 *         # look for existing ns
 *         c_ns = tree.xmlSearchNsByHref(self._c_doc, c_node, c_href)             # <<<<<<<<<<<<<<
 *         if c_ns is not NULL:
 *             return c_ns
 */
  __pyx_v_c_ns = xmlSearchNsByHref(__pyx_v_self->_c_doc, __pyx_v_c_node, __pyx_v_c_href);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":381
 *         # look for existing ns
 *         c_ns = tree.xmlSearchNsByHref(self._c_doc, c_node, c_href)
 *         if c_ns is not NULL:             # <<<<<<<<<<<<<<
 *             return c_ns
 * 
 */
  __pyx_1 = (__pyx_v_c_ns != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":382
 *         c_ns = tree.xmlSearchNsByHref(self._c_doc, c_node, c_href)
 *         if c_ns is not NULL:
 *             return c_ns             # <<<<<<<<<<<<<<
 * 
 *         if c_prefix is NULL:
 */
    __pyx_r = __pyx_v_c_ns;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":384
 *             return c_ns
 * 
 *         if c_prefix is NULL:             # <<<<<<<<<<<<<<
 *             dict_result = python.PyDict_GetItem(
 *                 _DEFAULT_NAMESPACE_PREFIXES, c_href)
 */
  __pyx_1 = (__pyx_v_c_prefix == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":386
 *         if c_prefix is NULL:
 *             dict_result = python.PyDict_GetItem(
 *                 _DEFAULT_NAMESPACE_PREFIXES, c_href)             # <<<<<<<<<<<<<<
 *             if dict_result is not NULL:
 *                 prefix = <object>dict_result
 */
    __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_c_href); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_dict_result = PyDict_GetItem(__pyx_v_4lxml_5etree__DEFAULT_NAMESPACE_PREFIXES, __pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":387
 *             dict_result = python.PyDict_GetItem(
 *                 _DEFAULT_NAMESPACE_PREFIXES, c_href)
 *             if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *                 prefix = <object>dict_result
 *             else:
 */
    __pyx_1 = (__pyx_v_dict_result != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":388
 *                 _DEFAULT_NAMESPACE_PREFIXES, c_href)
 *             if dict_result is not NULL:
 *                 prefix = <object>dict_result             # <<<<<<<<<<<<<<
 *             else:
 *                 prefix = self.buildNewPrefix()
 */
      Py_INCREF(((PyObject *)__pyx_v_dict_result));
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = ((PyObject *)__pyx_v_dict_result);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":390
 *                 prefix = <object>dict_result
 *             else:
 *                 prefix = self.buildNewPrefix()             # <<<<<<<<<<<<<<
 *             c_prefix = _cstr(prefix)
 * 
 */
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_self->__pyx_vtab)->buildNewPrefix(__pyx_v_self); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_3;
      __pyx_3 = 0;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":391
 *             else:
 *                 prefix = self.buildNewPrefix()
 *             c_prefix = _cstr(prefix)             # <<<<<<<<<<<<<<
 * 
 *         # make sure the prefix is not in use already
 */
    __pyx_v_c_prefix = PyString_AS_STRING(__pyx_v_prefix);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":394
 * 
 *         # make sure the prefix is not in use already
 *         while tree.xmlSearchNs(self._c_doc, c_node, c_prefix) is not NULL:             # <<<<<<<<<<<<<<
 *             prefix = self.buildNewPrefix()
 *             c_prefix = _cstr(prefix)
 */
  while (1) {
    __pyx_1 = (xmlSearchNs(__pyx_v_self->_c_doc, __pyx_v_c_node, __pyx_v_c_prefix) != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":395
 *         # make sure the prefix is not in use already
 *         while tree.xmlSearchNs(self._c_doc, c_node, c_prefix) is not NULL:
 *             prefix = self.buildNewPrefix()             # <<<<<<<<<<<<<<
 *             c_prefix = _cstr(prefix)
 * 
 */
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_self->__pyx_vtab)->buildNewPrefix(__pyx_v_self); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_prefix);
    __pyx_v_prefix = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":396
 *         while tree.xmlSearchNs(self._c_doc, c_node, c_prefix) is not NULL:
 *             prefix = self.buildNewPrefix()
 *             c_prefix = _cstr(prefix)             # <<<<<<<<<<<<<<
 * 
 *         c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 */
    __pyx_v_c_prefix = PyString_AS_STRING(__pyx_v_prefix);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":398
 *             c_prefix = _cstr(prefix)
 * 
 *         c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)             # <<<<<<<<<<<<<<
 *         if c_ns is NULL:
 *             python.PyErr_NoMemory()
 */
  __pyx_v_c_ns = xmlNewNs(__pyx_v_c_node, __pyx_v_c_href, __pyx_v_c_prefix);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":399
 * 
 *         c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 *         if c_ns is NULL:             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 *         return c_ns
 */
  __pyx_1 = (__pyx_v_c_ns == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":400
 *         c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 *         if c_ns is NULL:
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         return c_ns
 * 
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":401
 *         if c_ns is NULL:
 *             python.PyErr_NoMemory()
 *         return c_ns             # <<<<<<<<<<<<<<
 * 
 *     cdef int _setNodeNs(self, xmlNode* c_node, char* href) except -1:
 */
  __pyx_r = __pyx_v_c_ns;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._Document._findOrBuildNodeNs");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":403
 *         return c_ns
 * 
 *     cdef int _setNodeNs(self, xmlNode* c_node, char* href) except -1:             # <<<<<<<<<<<<<<
 *         u"Lookup namespace structure and set it for the node."
 *         cdef xmlNs* c_ns
 */

static  int __pyx_f_4lxml_5etree_9_Document__setNodeNs(struct LxmlDocument *__pyx_v_self, xmlNode *__pyx_v_c_node, char *__pyx_v_href) {
  xmlNs *__pyx_v_c_ns;
  int __pyx_r;
  xmlNs *__pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":406
 *         u"Lookup namespace structure and set it for the node."
 *         cdef xmlNs* c_ns
 *         c_ns = self._findOrBuildNodeNs(c_node, href, NULL)             # <<<<<<<<<<<<<<
 *         tree.xmlSetNs(c_node, c_ns)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_self->__pyx_vtab)->_findOrBuildNodeNs(__pyx_v_self, __pyx_v_c_node, __pyx_v_href, NULL); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_ns = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":407
 *         cdef xmlNs* c_ns
 *         c_ns = self._findOrBuildNodeNs(c_node, href, NULL)
 *         tree.xmlSetNs(c_node, c_ns)             # <<<<<<<<<<<<<<
 * 
 * cdef __initPrefixCache():
 */
  xmlSetNs(__pyx_v_c_node, __pyx_v_c_ns);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Document._setNodeNs");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":409
 *         tree.xmlSetNs(c_node, c_ns)
 * 
 * cdef __initPrefixCache():             # <<<<<<<<<<<<<<
 *     cdef int i
 *     return tuple([ python.PyString_FromFormat("ns%d", i)
 */

static  PyObject *__pyx_f_4lxml_5etree___initPrefixCache(void) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":411
 * cdef __initPrefixCache():
 *     cdef int i
 *     return tuple([ python.PyString_FromFormat("ns%d", i)             # <<<<<<<<<<<<<<
 *                    for i from 0 <= i < 30 ])
 * 
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":412
 *     cdef int i
 *     return tuple([ python.PyString_FromFormat("ns%d", i)
 *                    for i from 0 <= i < 30 ])             # <<<<<<<<<<<<<<
 * 
 * cdef object _PREFIX_CACHE
 */
  for (__pyx_v_i = 0; __pyx_v_i < 30; __pyx_v_i++) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":411
 * cdef __initPrefixCache():
 *     cdef int i
 *     return tuple([ python.PyString_FromFormat("ns%d", i)             # <<<<<<<<<<<<<<
 *                    for i from 0 <= i < 30 ])
 * 
 */
    __pyx_2 = PyString_FromFormat(__pyx_k_224, __pyx_v_i); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyList_Append(__pyx_1, (PyObject*)__pyx_2); if (unlikely(__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_1));
  __pyx_1 = 0;
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)&PyTuple_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.__initPrefixCache");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":421
 *     cdef _Document NEW_DOCUMENT "PY_NEW" (object t)
 * 
 * cdef _Document _documentFactory(xmlDoc* c_doc, _BaseParser parser):             # <<<<<<<<<<<<<<
 *     cdef _Document result
 *     result = NEW_DOCUMENT(_Document)
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__documentFactory(xmlDoc *__pyx_v_c_doc, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  struct LxmlDocument *__pyx_v_result;
  struct LxmlDocument *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF(__pyx_v_parser);
  __pyx_v_result = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":423
 * cdef _Document _documentFactory(xmlDoc* c_doc, _BaseParser parser):
 *     cdef _Document result
 *     result = NEW_DOCUMENT(_Document)             # <<<<<<<<<<<<<<
 *     result._c_doc = c_doc
 *     result._ns_counter = 0
 */
  __pyx_1 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Document)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_result));
  __pyx_v_result = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":424
 *     cdef _Document result
 *     result = NEW_DOCUMENT(_Document)
 *     result._c_doc = c_doc             # <<<<<<<<<<<<<<
 *     result._ns_counter = 0
 *     result._prefix_tail = None
 */
  __pyx_v_result->_c_doc = __pyx_v_c_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":425
 *     result = NEW_DOCUMENT(_Document)
 *     result._c_doc = c_doc
 *     result._ns_counter = 0             # <<<<<<<<<<<<<<
 *     result._prefix_tail = None
 *     if parser is None:
 */
  __pyx_v_result->_ns_counter = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":426
 *     result._c_doc = c_doc
 *     result._ns_counter = 0
 *     result._prefix_tail = None             # <<<<<<<<<<<<<<
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_result->_prefix_tail);
  __pyx_v_result->_prefix_tail = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":427
 *     result._ns_counter = 0
 *     result._prefix_tail = None
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     result._parser = parser
 */
  __pyx_2 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":428
 *     result._prefix_tail = None
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *     result._parser = parser
 *     return result
 */
    __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":429
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     result._parser = parser             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_parser));
  Py_DECREF(((PyObject *)__pyx_v_result->_parser));
  __pyx_v_result->_parser = __pyx_v_parser;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":430
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     result._parser = parser
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._documentFactory");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":436
 *     u"Document information provided by parser and DTD."
 *     cdef _Document _doc
 *     def __init__(self, tree):             # <<<<<<<<<<<<<<
 *         u"Create a DocInfo object for an ElementTree object or root Element."
 *         self._doc = _documentOrRaise(tree)
 */

static int __pyx_pf_4lxml_5etree_7DocInfo___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_7DocInfo___init__[] = "Create a DocInfo object for an ElementTree object or root Element.";
static int __pyx_pf_4lxml_5etree_7DocInfo___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tree = 0;
  PyObject *__pyx_v_root_name;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_system_url;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tree,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_tree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_tree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_tree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.DocInfo.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_root_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_system_url = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":438
 *     def __init__(self, tree):
 *         u"Create a DocInfo object for an ElementTree object or root Element."
 *         self._doc = _documentOrRaise(tree)             # <<<<<<<<<<<<<<
 *         root_name, public_id, system_url = self._doc.getdoctype()
 *         if not root_name and (public_id or system_url):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_tree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc));
  ((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":439
 *         u"Create a DocInfo object for an ElementTree object or root Element."
 *         self._doc = _documentOrRaise(tree)
 *         root_name, public_id, system_url = self._doc.getdoctype()             # <<<<<<<<<<<<<<
 *         if not root_name and (public_id or system_url):
 *             raise ValueError, u"Could not find root node"
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getdoctype(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 3) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 2);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":440
 *         self._doc = _documentOrRaise(tree)
 *         root_name, public_id, system_url = self._doc.getdoctype()
 *         if not root_name and (public_id or system_url):             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Could not find root node"
 * 
 */
  __pyx_5 = __Pyx_PyObject_IsTrue(__pyx_v_root_name); if (unlikely(__pyx_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = (!__pyx_5);
  if (__pyx_4) {
    __pyx_5 = __Pyx_PyObject_IsTrue(__pyx_v_public_id); if (unlikely(__pyx_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __pyx_5;
    if (!__pyx_4) {
      __pyx_5 = __Pyx_PyObject_IsTrue(__pyx_v_system_url); if (unlikely(__pyx_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = __pyx_5;
    }
  }
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":441
 *         root_name, public_id, system_url = self._doc.getdoctype()
 *         if not root_name and (public_id or system_url):
 *             raise ValueError, u"Could not find root node"             # <<<<<<<<<<<<<<
 * 
 *     property root_name:
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_225), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root_name);
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_system_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":445
 *     property root_name:
 *         u"Returns the name of the root node as defined by the DOCTYPE."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             return root_name
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_9root_name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_9root_name___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_root_name;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_system_url;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_root_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_system_url = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":446
 *         u"Returns the name of the root node as defined by the DOCTYPE."
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()             # <<<<<<<<<<<<<<
 *             return root_name
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getdoctype(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 3) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 2);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":447
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             return root_name             # <<<<<<<<<<<<<<
 * 
 *     property public_id:
 */
  Py_INCREF(__pyx_v_root_name);
  __pyx_r = __pyx_v_root_name;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.root_name.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root_name);
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_system_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":451
 *     property public_id:
 *         u"Returns the public ID of the DOCTYPE."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             return public_id
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_9public_id___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_9public_id___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_root_name;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_system_url;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_root_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_system_url = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":452
 *         u"Returns the public ID of the DOCTYPE."
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()             # <<<<<<<<<<<<<<
 *             return public_id
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getdoctype(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 3) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 2);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":453
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             return public_id             # <<<<<<<<<<<<<<
 * 
 *     property system_url:
 */
  Py_INCREF(__pyx_v_public_id);
  __pyx_r = __pyx_v_public_id;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.public_id.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root_name);
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_system_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":457
 *     property system_url:
 *         u"Returns the system ID of the DOCTYPE."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             return system_url
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_10system_url___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_10system_url___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_root_name;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_system_url;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_root_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_system_url = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":458
 *         u"Returns the system ID of the DOCTYPE."
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()             # <<<<<<<<<<<<<<
 *             return system_url
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getdoctype(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 3) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 2);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":459
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             return system_url             # <<<<<<<<<<<<<<
 * 
 *     property xml_version:
 */
  Py_INCREF(__pyx_v_system_url);
  __pyx_r = __pyx_v_system_url;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.system_url.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root_name);
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_system_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":463
 *     property xml_version:
 *         u"Returns the XML version as declared by the document."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             xml_version, encoding = self._doc.getxmlinfo()
 *             return xml_version
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_11xml_version___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_11xml_version___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_xml_version;
  PyObject *__pyx_v_encoding;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_xml_version = Py_None; Py_INCREF(Py_None);
  __pyx_v_encoding = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":464
 *         u"Returns the XML version as declared by the document."
 *         def __get__(self):
 *             xml_version, encoding = self._doc.getxmlinfo()             # <<<<<<<<<<<<<<
 *             return xml_version
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getxmlinfo(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_xml_version);
    __pyx_v_xml_version = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_xml_version);
    __pyx_v_xml_version = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":465
 *         def __get__(self):
 *             xml_version, encoding = self._doc.getxmlinfo()
 *             return xml_version             # <<<<<<<<<<<<<<
 * 
 *     property encoding:
 */
  Py_INCREF(__pyx_v_xml_version);
  __pyx_r = __pyx_v_xml_version;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.xml_version.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_xml_version);
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":469
 *     property encoding:
 *         u"Returns the encoding name as declared by the document."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             xml_version, encoding = self._doc.getxmlinfo()
 *             return encoding
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_8encoding___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_8encoding___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_xml_version;
  PyObject *__pyx_v_encoding;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_xml_version = Py_None; Py_INCREF(Py_None);
  __pyx_v_encoding = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":470
 *         u"Returns the encoding name as declared by the document."
 *         def __get__(self):
 *             xml_version, encoding = self._doc.getxmlinfo()             # <<<<<<<<<<<<<<
 *             return encoding
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getxmlinfo(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_xml_version);
    __pyx_v_xml_version = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_xml_version);
    __pyx_v_xml_version = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":471
 *         def __get__(self):
 *             xml_version, encoding = self._doc.getxmlinfo()
 *             return encoding             # <<<<<<<<<<<<<<
 * 
 *     property URL:
 */
  Py_INCREF(__pyx_v_encoding);
  __pyx_r = __pyx_v_encoding;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.encoding.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_xml_version);
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":475
 *     property URL:
 *         u"The source URL of the document (or None if unknown)."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._doc._c_doc.URL is NULL:
 *                 return None
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_3URL___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_3URL___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":476
 *         u"The source URL of the document (or None if unknown)."
 *         def __get__(self):
 *             if self._doc._c_doc.URL is NULL:             # <<<<<<<<<<<<<<
 *                 return None
 *             return _decodeFilename(self._doc._c_doc.URL)
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->URL == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":477
 *         def __get__(self):
 *             if self._doc._c_doc.URL is NULL:
 *                 return None             # <<<<<<<<<<<<<<
 *             return _decodeFilename(self._doc._c_doc.URL)
 *         def __set__(self, url):
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":478
 *             if self._doc._c_doc.URL is NULL:
 *                 return None
 *             return _decodeFilename(self._doc._c_doc.URL)             # <<<<<<<<<<<<<<
 *         def __set__(self, url):
 *             cdef char* c_oldurl
 */
  __pyx_2 = __pyx_f_4lxml_5etree__decodeFilename(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->URL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.DocInfo.URL.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":479
 *                 return None
 *             return _decodeFilename(self._doc._c_doc.URL)
 *         def __set__(self, url):             # <<<<<<<<<<<<<<
 *             cdef char* c_oldurl
 *             url = _encodeFilename(url)
 */

static int __pyx_pf_4lxml_5etree_7DocInfo_3URL___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_url); /*proto*/
static int __pyx_pf_4lxml_5etree_7DocInfo_3URL___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_url) {
  char *__pyx_v_c_oldurl;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF(__pyx_v_url);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":481
 *         def __set__(self, url):
 *             cdef char* c_oldurl
 *             url = _encodeFilename(url)             # <<<<<<<<<<<<<<
 *             c_oldurl = self._doc._c_doc.URL
 *             if url is None:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_url); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_url);
  __pyx_v_url = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":482
 *             cdef char* c_oldurl
 *             url = _encodeFilename(url)
 *             c_oldurl = self._doc._c_doc.URL             # <<<<<<<<<<<<<<
 *             if url is None:
 *                 self._doc._c_doc.URL = NULL
 */
  __pyx_v_c_oldurl = ((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->URL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":483
 *             url = _encodeFilename(url)
 *             c_oldurl = self._doc._c_doc.URL
 *             if url is None:             # <<<<<<<<<<<<<<
 *                 self._doc._c_doc.URL = NULL
 *             else:
 */
  __pyx_2 = (__pyx_v_url == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":484
 *             c_oldurl = self._doc._c_doc.URL
 *             if url is None:
 *                 self._doc._c_doc.URL = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 self._doc._c_doc.URL = tree.xmlStrdup(_cstr(url))
 */
    ((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->URL = NULL;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":486
 *                 self._doc._c_doc.URL = NULL
 *             else:
 *                 self._doc._c_doc.URL = tree.xmlStrdup(_cstr(url))             # <<<<<<<<<<<<<<
 *             if c_oldurl is not NULL:
 *                 tree.xmlFree(c_oldurl)
 */
    ((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->URL = xmlStrdup(PyString_AS_STRING(__pyx_v_url));
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":487
 *             else:
 *                 self._doc._c_doc.URL = tree.xmlStrdup(_cstr(url))
 *             if c_oldurl is not NULL:             # <<<<<<<<<<<<<<
 *                 tree.xmlFree(c_oldurl)
 * 
 */
  __pyx_2 = (__pyx_v_c_oldurl != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":488
 *                 self._doc._c_doc.URL = tree.xmlStrdup(_cstr(url))
 *             if c_oldurl is not NULL:
 *                 tree.xmlFree(c_oldurl)             # <<<<<<<<<<<<<<
 * 
 *     property doctype:
 */
    xmlFree(__pyx_v_c_oldurl);
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.DocInfo.URL.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":492
 *     property doctype:
 *         u"Returns a DOCTYPE declaration string for the document."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             if public_id:
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_7doctype___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_7doctype___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_root_name;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_system_url;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_root_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_system_url = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":493
 *         u"Returns a DOCTYPE declaration string for the document."
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()             # <<<<<<<<<<<<<<
 *             if public_id:
 *                 if system_url:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->getdoctype(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 3) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 2);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_root_name);
    __pyx_v_root_name = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_public_id);
    __pyx_v_public_id = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_system_url);
    __pyx_v_system_url = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":494
 *         def __get__(self):
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             if public_id:             # <<<<<<<<<<<<<<
 *                 if system_url:
 *                     return u'<!DOCTYPE %s PUBLIC "%s" "%s">' % (
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_public_id); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":495
 *             root_name, public_id, system_url = self._doc.getdoctype()
 *             if public_id:
 *                 if system_url:             # <<<<<<<<<<<<<<
 *                     return u'<!DOCTYPE %s PUBLIC "%s" "%s">' % (
 *                         root_name, public_id, system_url)
 */
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_system_url); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":497
 *                 if system_url:
 *                     return u'<!DOCTYPE %s PUBLIC "%s" "%s">' % (
 *                         root_name, public_id, system_url)             # <<<<<<<<<<<<<<
 *                 else:
 *                     return u'<!DOCTYPE %s PUBLIC "%s">' % (
 */
      __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_root_name);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_root_name);
      Py_INCREF(__pyx_v_public_id);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_public_id);
      Py_INCREF(__pyx_v_system_url);
      PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_system_url);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_226), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":500
 *                 else:
 *                     return u'<!DOCTYPE %s PUBLIC "%s">' % (
 *                         root_name, public_id)             # <<<<<<<<<<<<<<
 *             elif system_url:
 *                 return u'<!DOCTYPE %s SYSTEM "%s">' % (
 */
      __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_root_name);
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_root_name);
      Py_INCREF(__pyx_v_public_id);
      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_public_id);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_227), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":501
 *                     return u'<!DOCTYPE %s PUBLIC "%s">' % (
 *                         root_name, public_id)
 *             elif system_url:             # <<<<<<<<<<<<<<
 *                 return u'<!DOCTYPE %s SYSTEM "%s">' % (
 *                     root_name, system_url)
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_system_url); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":503
 *             elif system_url:
 *                 return u'<!DOCTYPE %s SYSTEM "%s">' % (
 *                     root_name, system_url)             # <<<<<<<<<<<<<<
 *             elif self._doc.hasdoctype():
 *                 return u'<!DOCTYPE %s>' % root_name
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_root_name);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_root_name);
    Py_INCREF(__pyx_v_system_url);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_system_url);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_228), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":504
 *                 return u'<!DOCTYPE %s SYSTEM "%s">' % (
 *                     root_name, system_url)
 *             elif self._doc.hasdoctype():             # <<<<<<<<<<<<<<
 *                 return u'<!DOCTYPE %s>' % root_name
 *             else:
 */
  __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->__pyx_vtab)->hasdoctype(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":505
 *                     root_name, system_url)
 *             elif self._doc.hasdoctype():
 *                 return u'<!DOCTYPE %s>' % root_name             # <<<<<<<<<<<<<<
 *             else:
 *                 return u""
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_229), __pyx_v_root_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":507
 *                 return u'<!DOCTYPE %s>' % root_name
 *             else:
 *                 return u""             # <<<<<<<<<<<<<<
 * 
 *     property internalDTD:
 */
    Py_INCREF(((PyObject *)__pyx_kp_230));
    __pyx_r = ((PyObject *)__pyx_kp_230);
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DocInfo.doctype.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root_name);
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_system_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":511
 *     property internalDTD:
 *         u"Returns a DTD validator based on the internal subset of the document."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return _dtdFactory(self._doc._c_doc.intSubset)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_11internalDTD___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_11internalDTD___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":512
 *         u"Returns a DTD validator based on the internal subset of the document."
 *         def __get__(self):
 *             return _dtdFactory(self._doc._c_doc.intSubset)             # <<<<<<<<<<<<<<
 * 
 *     property externalDTD:
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__dtdFactory(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->intSubset)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.DocInfo.internalDTD.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":516
 *     property externalDTD:
 *         u"Returns a DTD validator based on the external subset of the document."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return _dtdFactory(self._doc._c_doc.extSubset)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_11externalDTD___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7DocInfo_11externalDTD___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":517
 *         u"Returns a DTD validator based on the external subset of the document."
 *         def __get__(self):
 *             return _dtdFactory(self._doc._c_doc.extSubset)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__dtdFactory(((struct __pyx_obj_4lxml_5etree_DocInfo *)__pyx_v_self)->_doc->_c_doc->extSubset)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.DocInfo.externalDTD.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":534
 *     cdef object _attrib
 * 
 *     def _init(self):             # <<<<<<<<<<<<<<
 *         u"""_init(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element__init(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element__init[] = "_init(self)\n\n        Called after object initialisation.  Custom subclasses may override\n        this if they recursively call _init() in the superclasses.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element__init(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":541
 *         """
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         #print "trying to free node:", <int>self._c_node
 *         #displayNode(self._c_node, 0)
 */

static void __pyx_pf_4lxml_5etree_8_Element___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_8_Element___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":544
 *         #print "trying to free node:", <int>self._c_node
 *         #displayNode(self._c_node, 0)
 *         if self._c_node is not NULL:             # <<<<<<<<<<<<<<
 *             _unregisterProxy(self)
 *             attemptDeallocation(self._c_node)
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_c_node != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":545
 *         #displayNode(self._c_node, 0)
 *         if self._c_node is not NULL:
 *             _unregisterProxy(self)             # <<<<<<<<<<<<<<
 *             attemptDeallocation(self._c_node)
 *         _releaseProxy(self)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__unregisterProxy(((struct LxmlElement *)__pyx_v_self)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":546
 *         if self._c_node is not NULL:
 *             _unregisterProxy(self)
 *             attemptDeallocation(self._c_node)             # <<<<<<<<<<<<<<
 *         _releaseProxy(self)
 * 
 */
    __pyx_f_4lxml_5etree_attemptDeallocation(((struct LxmlElement *)__pyx_v_self)->_c_node);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":547
 *             _unregisterProxy(self)
 *             attemptDeallocation(self._c_node)
 *         _releaseProxy(self)             # <<<<<<<<<<<<<<
 * 
 *     # MANIPULATORS
 */
  __pyx_f_4lxml_5etree__releaseProxy(((struct LxmlElement *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.__dealloc__");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":551
 *     # MANIPULATORS
 * 
 *     def __setitem__(self, x, value):             # <<<<<<<<<<<<<<
 *         u"""__setitem__(self, x, value)
 * 
 */

static int __pyx_pf_4lxml_5etree_8_Element___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___setitem__[] = "__setitem__(self, x, value)\n\n        Replaces the given subelement index or slice.\n        ";
static int __pyx_pf_4lxml_5etree_8_Element___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_value) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_v_c_next;
  xmlDoc *__pyx_v_c_source_doc;
  struct LxmlElement *__pyx_v_element;
  int __pyx_v_left_to_right;
  Py_ssize_t __pyx_v_slicelength;
  Py_ssize_t __pyx_v_step;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":562
 *         cdef bint left_to_right
 *         cdef Py_ssize_t slicelength, step
 *         if value is None:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"cannot assign None"
 *         if python.PySlice_Check(x):
 */
  __pyx_1 = (__pyx_v_value == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":563
 *         cdef Py_ssize_t slicelength, step
 *         if value is None:
 *             raise ValueError, u"cannot assign None"             # <<<<<<<<<<<<<<
 *         if python.PySlice_Check(x):
 *             # slice assignment
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_231), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":564
 *         if value is None:
 *             raise ValueError, u"cannot assign None"
 *         if python.PySlice_Check(x):             # <<<<<<<<<<<<<<
 *             # slice assignment
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 */
  __pyx_1 = PySlice_Check(__pyx_v_x);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":566
 *         if python.PySlice_Check(x):
 *             # slice assignment
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)             # <<<<<<<<<<<<<<
 *             if step > 0:
 *                 left_to_right = 1
 */
    if (!(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4lxml_6python_slice))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __pyx_f_4lxml_5etree__findChildSlice(((PySliceObject *)__pyx_v_x), ((struct LxmlElement *)__pyx_v_self)->_c_node, (&__pyx_v_c_node), (&__pyx_v_step), (&__pyx_v_slicelength)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":567
 *             # slice assignment
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if step > 0:             # <<<<<<<<<<<<<<
 *                 left_to_right = 1
 *             else:
 */
    __pyx_1 = (__pyx_v_step > 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":568
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if step > 0:
 *                 left_to_right = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 left_to_right = 0
 */
      __pyx_v_left_to_right = 1;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":570
 *                 left_to_right = 1
 *             else:
 *                 left_to_right = 0             # <<<<<<<<<<<<<<
 *                 step = -step
 *             _replaceSlice(self, c_node, slicelength, step, left_to_right, value)
 */
      __pyx_v_left_to_right = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":571
 *             else:
 *                 left_to_right = 0
 *                 step = -step             # <<<<<<<<<<<<<<
 *             _replaceSlice(self, c_node, slicelength, step, left_to_right, value)
 *             return
 */
      __pyx_v_step = (-__pyx_v_step);
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":572
 *                 left_to_right = 0
 *                 step = -step
 *             _replaceSlice(self, c_node, slicelength, step, left_to_right, value)             # <<<<<<<<<<<<<<
 *             return
 *         else:
 */
    __pyx_2 = __pyx_f_4lxml_5etree__replaceSlice(((struct LxmlElement *)__pyx_v_self), __pyx_v_c_node, __pyx_v_slicelength, __pyx_v_step, __pyx_v_left_to_right, __pyx_v_value); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":573
 *                 step = -step
 *             _replaceSlice(self, c_node, slicelength, step, left_to_right, value)
 *             return             # <<<<<<<<<<<<<<
 *         else:
 *             # otherwise: normal item assignment
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":576
 *         else:
 *             # otherwise: normal item assignment
 *             element = value             # <<<<<<<<<<<<<<
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:
 */
    if (!(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_value);
    Py_DECREF(((PyObject *)__pyx_v_element));
    __pyx_v_element = ((struct LxmlElement *)__pyx_v_value);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":577
 *             # otherwise: normal item assignment
 *             element = value
 *             c_node = _findChild(self._c_node, x)             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"
 */
    __pyx_3 = __pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_node = __pyx_f_4lxml_5etree__findChild(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_3);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":578
 *             element = value
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 raise IndexError, u"list index out of range"
 *             c_source_doc = element._c_node.doc
 */
    __pyx_1 = (__pyx_v_c_node == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":579
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"             # <<<<<<<<<<<<<<
 *             c_source_doc = element._c_node.doc
 *             c_next = element._c_node.next
 */
      __Pyx_Raise(__pyx_builtin_IndexError, ((PyObject *)__pyx_kp_232), 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":580
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"
 *             c_source_doc = element._c_node.doc             # <<<<<<<<<<<<<<
 *             c_next = element._c_node.next
 *             _removeText(c_node.next)
 */
    __pyx_v_c_source_doc = __pyx_v_element->_c_node->doc;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":581
 *                 raise IndexError, u"list index out of range"
 *             c_source_doc = element._c_node.doc
 *             c_next = element._c_node.next             # <<<<<<<<<<<<<<
 *             _removeText(c_node.next)
 *             tree.xmlReplaceNode(c_node, element._c_node)
 */
    __pyx_v_c_next = __pyx_v_element->_c_node->next;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":582
 *             c_source_doc = element._c_node.doc
 *             c_next = element._c_node.next
 *             _removeText(c_node.next)             # <<<<<<<<<<<<<<
 *             tree.xmlReplaceNode(c_node, element._c_node)
 *             _moveTail(c_next, element._c_node)
 */
    __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->next);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":583
 *             c_next = element._c_node.next
 *             _removeText(c_node.next)
 *             tree.xmlReplaceNode(c_node, element._c_node)             # <<<<<<<<<<<<<<
 *             _moveTail(c_next, element._c_node)
 *             moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 */
    xmlReplaceNode(__pyx_v_c_node, __pyx_v_element->_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":584
 *             _removeText(c_node.next)
 *             tree.xmlReplaceNode(c_node, element._c_node)
 *             _moveTail(c_next, element._c_node)             # <<<<<<<<<<<<<<
 *             moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 *             if not attemptDeallocation(c_node):
 */
    __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_element->_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":585
 *             tree.xmlReplaceNode(c_node, element._c_node)
 *             _moveTail(c_next, element._c_node)
 *             moveNodeToDocument(self._doc, c_source_doc, element._c_node)             # <<<<<<<<<<<<<<
 *             if not attemptDeallocation(c_node):
 *                 moveNodeToDocument(self._doc, c_node.doc, c_node)
 */
    __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_source_doc, __pyx_v_element->_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":586
 *             _moveTail(c_next, element._c_node)
 *             moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 *             if not attemptDeallocation(c_node):             # <<<<<<<<<<<<<<
 *                 moveNodeToDocument(self._doc, c_node.doc, c_node)
 * 
 */
    __pyx_1 = (!__pyx_f_4lxml_5etree_attemptDeallocation(__pyx_v_c_node));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":587
 *             moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 *             if not attemptDeallocation(c_node):
 *                 moveNodeToDocument(self._doc, c_node.doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, x):
 */
      __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node->doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":589
 *                 moveNodeToDocument(self._doc, c_node.doc, c_node)
 * 
 *     def __delitem__(self, x):             # <<<<<<<<<<<<<<
 *         u"""__delitem__(self, x)
 * 
 */

static int __pyx_pf_4lxml_5etree_8_Element___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___delitem__[] = "__delitem__(self, x)\n\n        Deletes the given subelement or a slice.\n        ";
static int __pyx_pf_4lxml_5etree_8_Element___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_v_c_next;
  Py_ssize_t __pyx_v_step;
  Py_ssize_t __pyx_v_slicelength;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":597
 *         cdef xmlNode* c_next
 *         cdef Py_ssize_t step, slicelength
 *         if python.PySlice_Check(x):             # <<<<<<<<<<<<<<
 *             # slice deletion
 *             if _isFullSlice(<python.slice>x):
 */
  __pyx_1 = PySlice_Check(__pyx_v_x);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":599
 *         if python.PySlice_Check(x):
 *             # slice deletion
 *             if _isFullSlice(<python.slice>x):             # <<<<<<<<<<<<<<
 *                 c_node = self._c_node.children
 *                 if c_node is not NULL:
 */
    __pyx_1 = __pyx_f_4lxml_5etree__isFullSlice(((PySliceObject *)__pyx_v_x));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":600
 *             # slice deletion
 *             if _isFullSlice(<python.slice>x):
 *                 c_node = self._c_node.children             # <<<<<<<<<<<<<<
 *                 if c_node is not NULL:
 *                     if not _isElement(c_node):
 */
      __pyx_v_c_node = ((struct LxmlElement *)__pyx_v_self)->_c_node->children;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":601
 *             if _isFullSlice(<python.slice>x):
 *                 c_node = self._c_node.children
 *                 if c_node is not NULL:             # <<<<<<<<<<<<<<
 *                     if not _isElement(c_node):
 *                         c_node = _nextElement(c_node)
 */
      __pyx_1 = (__pyx_v_c_node != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":602
 *                 c_node = self._c_node.children
 *                 if c_node is not NULL:
 *                     if not _isElement(c_node):             # <<<<<<<<<<<<<<
 *                         c_node = _nextElement(c_node)
 *                     while c_node is not NULL:
 */
        __pyx_1 = (!_isElement(__pyx_v_c_node));
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":603
 *                 if c_node is not NULL:
 *                     if not _isElement(c_node):
 *                         c_node = _nextElement(c_node)             # <<<<<<<<<<<<<<
 *                     while c_node is not NULL:
 *                         c_next = _nextElement(c_node)
 */
          __pyx_v_c_node = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":604
 *                     if not _isElement(c_node):
 *                         c_node = _nextElement(c_node)
 *                     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *                         c_next = _nextElement(c_node)
 *                         _removeNode(self._doc, c_node)
 */
        while (1) {
          __pyx_1 = (__pyx_v_c_node != NULL);
          if (!__pyx_1) break;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":605
 *                         c_node = _nextElement(c_node)
 *                     while c_node is not NULL:
 *                         c_next = _nextElement(c_node)             # <<<<<<<<<<<<<<
 *                         _removeNode(self._doc, c_node)
 *                         c_node = c_next
 */
          __pyx_v_c_next = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":606
 *                     while c_node is not NULL:
 *                         c_next = _nextElement(c_node)
 *                         _removeNode(self._doc, c_node)             # <<<<<<<<<<<<<<
 *                         c_node = c_next
 *             else:
 */
          __pyx_2 = __pyx_f_4lxml_5etree__removeNode(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":607
 *                         c_next = _nextElement(c_node)
 *                         _removeNode(self._doc, c_node)
 *                         c_node = c_next             # <<<<<<<<<<<<<<
 *             else:
 *                 _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 */
          __pyx_v_c_node = __pyx_v_c_next;
        }
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":609
 *                         c_node = c_next
 *             else:
 *                 _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)             # <<<<<<<<<<<<<<
 *                 _deleteSlice(self._doc, c_node, slicelength, step)
 *         else:
 */
      if (!(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4lxml_6python_slice))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = __pyx_f_4lxml_5etree__findChildSlice(((PySliceObject *)__pyx_v_x), ((struct LxmlElement *)__pyx_v_self)->_c_node, (&__pyx_v_c_node), (&__pyx_v_step), (&__pyx_v_slicelength)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":610
 *             else:
 *                 _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *                 _deleteSlice(self._doc, c_node, slicelength, step)             # <<<<<<<<<<<<<<
 *         else:
 *             # item deletion
 */
      __pyx_2 = __pyx_f_4lxml_5etree__deleteSlice(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node, __pyx_v_slicelength, __pyx_v_step); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":613
 *         else:
 *             # item deletion
 *             c_node = _findChild(self._c_node, x)             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 raise IndexError, u"index out of range: %d" % x
 */
    __pyx_3 = __pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_node = __pyx_f_4lxml_5etree__findChild(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_3);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":614
 *             # item deletion
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 raise IndexError, u"index out of range: %d" % x
 *             _removeText(c_node.next)
 */
    __pyx_1 = (__pyx_v_c_node == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":615
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:
 *                 raise IndexError, u"index out of range: %d" % x             # <<<<<<<<<<<<<<
 *             _removeText(c_node.next)
 *             _removeNode(self._doc, c_node)
 */
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_233), __pyx_v_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_builtin_IndexError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":616
 *             if c_node is NULL:
 *                 raise IndexError, u"index out of range: %d" % x
 *             _removeText(c_node.next)             # <<<<<<<<<<<<<<
 *             _removeNode(self._doc, c_node)
 * 
 */
    __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->next);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":617
 *                 raise IndexError, u"index out of range: %d" % x
 *             _removeText(c_node.next)
 *             _removeNode(self._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self, memo):
 */
    __pyx_2 = __pyx_f_4lxml_5etree__removeNode(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.__delitem__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":619
 *             _removeNode(self._doc, c_node)
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         u"__deepcopy__(self, memo)"
 *         return self.__copy__()
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___deepcopy__[] = "__deepcopy__(self, memo)";
static PyObject *__pyx_pf_4lxml_5etree_8_Element___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":621
 *     def __deepcopy__(self, memo):
 *         u"__deepcopy__(self, memo)"
 *         return self.__copy__()             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___copy__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.__deepcopy__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":623
 *         return self.__copy__()
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         "__copy__(self)"
 *         cdef xmlDoc* c_doc
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element___copy__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___copy__[] = "__copy__(self)";
static PyObject *__pyx_pf_4lxml_5etree_8_Element___copy__(PyObject *__pyx_v_self, PyObject *unused) {
  xmlDoc *__pyx_v_c_doc;
  xmlNode *__pyx_v_c_node;
  struct LxmlDocument *__pyx_v_new_doc;
  PyObject *__pyx_v_root;
  PyObject *__pyx_r;
  xmlDoc *__pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_new_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":628
 *         cdef xmlNode* c_node
 *         cdef _Document new_doc
 *         c_doc = _copyDocRoot(self._doc._c_doc, self._c_node) # recursive             # <<<<<<<<<<<<<<
 *         new_doc = _documentFactory(c_doc, self._doc._parser)
 *         root = new_doc.getroot()
 */
  __pyx_1 = __pyx_f_4lxml_5etree__copyDocRoot(((struct LxmlElement *)__pyx_v_self)->_doc->_c_doc, ((struct LxmlElement *)__pyx_v_self)->_c_node); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":629
 *         cdef _Document new_doc
 *         c_doc = _copyDocRoot(self._doc._c_doc, self._c_node) # recursive
 *         new_doc = _documentFactory(c_doc, self._doc._parser)             # <<<<<<<<<<<<<<
 *         root = new_doc.getroot()
 *         if root is not None:
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, ((struct LxmlElement *)__pyx_v_self)->_doc->_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_new_doc));
  __pyx_v_new_doc = ((struct LxmlDocument *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":630
 *         c_doc = _copyDocRoot(self._doc._c_doc, self._c_node) # recursive
 *         new_doc = _documentFactory(c_doc, self._doc._parser)
 *         root = new_doc.getroot()             # <<<<<<<<<<<<<<
 *         if root is not None:
 *             return root
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_new_doc->__pyx_vtab)->getroot(__pyx_v_new_doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":631
 *         new_doc = _documentFactory(c_doc, self._doc._parser)
 *         root = new_doc.getroot()
 *         if root is not None:             # <<<<<<<<<<<<<<
 *             return root
 *         # Comment/PI
 */
  __pyx_3 = (__pyx_v_root != Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":632
 *         root = new_doc.getroot()
 *         if root is not None:
 *             return root             # <<<<<<<<<<<<<<
 *         # Comment/PI
 *         c_node = c_doc.children
 */
    Py_INCREF(__pyx_v_root);
    __pyx_r = __pyx_v_root;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":634
 *             return root
 *         # Comment/PI
 *         c_node = c_doc.children             # <<<<<<<<<<<<<<
 *         while c_node is not NULL and c_node.type != self._c_node.type:
 *             c_node = c_node.next
 */
  __pyx_v_c_node = __pyx_v_c_doc->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":635
 *         # Comment/PI
 *         c_node = c_doc.children
 *         while c_node is not NULL and c_node.type != self._c_node.type:             # <<<<<<<<<<<<<<
 *             c_node = c_node.next
 *         if c_node is NULL:
 */
  while (1) {
    __pyx_3 = (__pyx_v_c_node != NULL);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_c_node->type != ((struct LxmlElement *)__pyx_v_self)->_c_node->type);
    }
    if (!__pyx_3) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":636
 *         c_node = c_doc.children
 *         while c_node is not NULL and c_node.type != self._c_node.type:
 *             c_node = c_node.next             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             return None
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":637
 *         while c_node is not NULL and c_node.type != self._c_node.type:
 *             c_node = c_node.next
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return _elementFactory(new_doc, c_node)
 */
  __pyx_3 = (__pyx_v_c_node == NULL);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":638
 *             c_node = c_node.next
 *         if c_node is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return _elementFactory(new_doc, c_node)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":639
 *         if c_node is NULL:
 *             return None
 *         return _elementFactory(new_doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def set(self, key, value):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_new_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.__copy__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_new_doc);
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":641
 *         return _elementFactory(new_doc, c_node)
 * 
 *     def set(self, key, value):             # <<<<<<<<<<<<<<
 *         u"""set(self, key, value)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_set[] = "set(self, key, value)\n\n        Sets an element attribute.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_value,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    __pyx_v_value = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.set");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":646
 *         Sets an element attribute.
 *         """
 *         _setAttributeValue(self, key, value)             # <<<<<<<<<<<<<<
 * 
 *     def append(self, _Element element not None):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__setAttributeValue(((struct LxmlElement *)__pyx_v_self), __pyx_v_key, __pyx_v_value); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.set");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":648
 *         _setAttributeValue(self, key, value)
 * 
 *     def append(self, _Element element not None):             # <<<<<<<<<<<<<<
 *         u"""append(self, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_append(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_append[] = "append(self, element)\n\n        Adds a subelement to the end of this element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_append(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  PyObject *__pyx_r;
  int __pyx_1;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":653
 *         Adds a subelement to the end of this element.
 *         """
 *         _appendChild(self, element)             # <<<<<<<<<<<<<<
 * 
 *     def addnext(self, _Element element):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__appendChild(((struct LxmlElement *)__pyx_v_self), ((struct LxmlElement *)__pyx_v_element)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.append");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":655
 *         _appendChild(self, element)
 * 
 *     def addnext(self, _Element element):             # <<<<<<<<<<<<<<
 *         u"""addnext(self, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_addnext(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_addnext[] = "addnext(self, element)\n\n        Adds the element as a following sibling directly after this\n        element.\n\n        This is normally used to set a processing instruction or comment after\n        the root node of a document.  Note that tail text is automatically\n        discarded when adding at the root level.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_addnext(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 1, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":665
 *         discarded when adding at the root level.
 *         """
 *         if self._c_node.parent != NULL and not _isElement(self._c_node.parent):             # <<<<<<<<<<<<<<
 *             if element._c_node.type != tree.XML_PI_NODE:
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_c_node->parent != NULL);
  if (__pyx_1) {
    __pyx_1 = (!_isElement(((struct LxmlElement *)__pyx_v_self)->_c_node->parent));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":666
 *         """
 *         if self._c_node.parent != NULL and not _isElement(self._c_node.parent):
 *             if element._c_node.type != tree.XML_PI_NODE:             # <<<<<<<<<<<<<<
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 */
    __pyx_1 = (((struct LxmlElement *)__pyx_v_element)->_c_node->type != XML_PI_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":667
 *         if self._c_node.parent != NULL and not _isElement(self._c_node.parent):
 *             if element._c_node.type != tree.XML_PI_NODE:
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:             # <<<<<<<<<<<<<<
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 *             element.tail = None
 */
      __pyx_1 = (((struct LxmlElement *)__pyx_v_element)->_c_node->type != XML_COMMENT_NODE);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":668
 *             if element._c_node.type != tree.XML_PI_NODE:
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"             # <<<<<<<<<<<<<<
 *             element.tail = None
 *         _appendSibling(self, element)
 */
        __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_234), 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":669
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 *             element.tail = None             # <<<<<<<<<<<<<<
 *         _appendSibling(self, element)
 * 
 */
    if (PyObject_SetAttr(__pyx_v_element, __pyx_kp_tail, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":670
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 *             element.tail = None
 *         _appendSibling(self, element)             # <<<<<<<<<<<<<<
 * 
 *     def addprevious(self, _Element element):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__appendSibling(((struct LxmlElement *)__pyx_v_self), ((struct LxmlElement *)__pyx_v_element)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.addnext");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":672
 *         _appendSibling(self, element)
 * 
 *     def addprevious(self, _Element element):             # <<<<<<<<<<<<<<
 *         u"""addprevious(self, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_addprevious(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_addprevious[] = "addprevious(self, element)\n\n        Adds the element as a preceding sibling directly before this\n        element.\n\n        This is normally used to set a processing instruction or comment\n        before the root node of a document.  Note that tail text is\n        automatically discarded when adding at the root level.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_addprevious(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 1, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":682
 *         automatically discarded when adding at the root level.
 *         """
 *         if self._c_node.parent != NULL and not _isElement(self._c_node.parent):             # <<<<<<<<<<<<<<
 *             if element._c_node.type != tree.XML_PI_NODE:
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_c_node->parent != NULL);
  if (__pyx_1) {
    __pyx_1 = (!_isElement(((struct LxmlElement *)__pyx_v_self)->_c_node->parent));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":683
 *         """
 *         if self._c_node.parent != NULL and not _isElement(self._c_node.parent):
 *             if element._c_node.type != tree.XML_PI_NODE:             # <<<<<<<<<<<<<<
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 */
    __pyx_1 = (((struct LxmlElement *)__pyx_v_element)->_c_node->type != XML_PI_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":684
 *         if self._c_node.parent != NULL and not _isElement(self._c_node.parent):
 *             if element._c_node.type != tree.XML_PI_NODE:
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:             # <<<<<<<<<<<<<<
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 *             element.tail = None
 */
      __pyx_1 = (((struct LxmlElement *)__pyx_v_element)->_c_node->type != XML_COMMENT_NODE);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":685
 *             if element._c_node.type != tree.XML_PI_NODE:
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"             # <<<<<<<<<<<<<<
 *             element.tail = None
 *         _prependSibling(self, element)
 */
        __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_235), 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":686
 *                 if element._c_node.type != tree.XML_COMMENT_NODE:
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 *             element.tail = None             # <<<<<<<<<<<<<<
 *         _prependSibling(self, element)
 * 
 */
    if (PyObject_SetAttr(__pyx_v_element, __pyx_kp_tail, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":687
 *                     raise TypeError, u"Only processing instructions and comments can be siblings of the root element"
 *             element.tail = None
 *         _prependSibling(self, element)             # <<<<<<<<<<<<<<
 * 
 *     def extend(self, elements):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__prependSibling(((struct LxmlElement *)__pyx_v_self), ((struct LxmlElement *)__pyx_v_element)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.addprevious");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":689
 *         _prependSibling(self, element)
 * 
 *     def extend(self, elements):             # <<<<<<<<<<<<<<
 *         u"""extend(self, elements)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_extend(PyObject *__pyx_v_self, PyObject *__pyx_v_elements); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_extend[] = "extend(self, elements)\n\n        Extends the current children by the elements in the iterable.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_extend(PyObject *__pyx_v_self, PyObject *__pyx_v_elements) {
  PyObject *__pyx_v_element;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":694
 *         Extends the current children by the elements in the iterable.
 *         """
 *         for element in elements:             # <<<<<<<<<<<<<<
 *             _appendChild(self, element)
 * 
 */
  if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
    __pyx_1 = 0; __pyx_2 = __pyx_v_elements; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_element);
    __pyx_v_element = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":695
 *         """
 *         for element in elements:
 *             _appendChild(self, element)             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
    if (!(__Pyx_TypeTest(__pyx_v_element, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __pyx_f_4lxml_5etree__appendChild(((struct LxmlElement *)__pyx_v_self), ((struct LxmlElement *)__pyx_v_element)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.extend");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":697
 *             _appendChild(self, element)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         u"""clear(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_clear(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_clear[] = "clear(self)\n\n        Resets an element.  This function removes all subelements, clears\n        all attributes and sets the text and tail properties to None.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_clear(PyObject *__pyx_v_self, PyObject *unused) {
  xmlAttr *__pyx_v_c_attr;
  xmlAttr *__pyx_v_c_attr_next;
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_v_c_node_next;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":707
 *         cdef xmlNode* c_node
 *         cdef xmlNode* c_node_next
 *         c_node = self._c_node             # <<<<<<<<<<<<<<
 *         # remove self.text and self.tail
 *         _removeText(c_node.children)
 */
  __pyx_v_c_node = ((struct LxmlElement *)__pyx_v_self)->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":709
 *         c_node = self._c_node
 *         # remove self.text and self.tail
 *         _removeText(c_node.children)             # <<<<<<<<<<<<<<
 *         _removeText(c_node.next)
 *         # remove all attributes
 */
  __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->children);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":710
 *         # remove self.text and self.tail
 *         _removeText(c_node.children)
 *         _removeText(c_node.next)             # <<<<<<<<<<<<<<
 *         # remove all attributes
 *         c_attr = c_node.properties
 */
  __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->next);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":712
 *         _removeText(c_node.next)
 *         # remove all attributes
 *         c_attr = c_node.properties             # <<<<<<<<<<<<<<
 *         while c_attr is not NULL:
 *             c_attr_next = c_attr.next
 */
  __pyx_v_c_attr = __pyx_v_c_node->properties;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":713
 *         # remove all attributes
 *         c_attr = c_node.properties
 *         while c_attr is not NULL:             # <<<<<<<<<<<<<<
 *             c_attr_next = c_attr.next
 *             tree.xmlRemoveProp(c_attr)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":714
 *         c_attr = c_node.properties
 *         while c_attr is not NULL:
 *             c_attr_next = c_attr.next             # <<<<<<<<<<<<<<
 *             tree.xmlRemoveProp(c_attr)
 *             c_attr = c_attr_next
 */
    __pyx_v_c_attr_next = __pyx_v_c_attr->next;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":715
 *         while c_attr is not NULL:
 *             c_attr_next = c_attr.next
 *             tree.xmlRemoveProp(c_attr)             # <<<<<<<<<<<<<<
 *             c_attr = c_attr_next
 *         # remove all subelements
 */
    xmlRemoveProp(__pyx_v_c_attr);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":716
 *             c_attr_next = c_attr.next
 *             tree.xmlRemoveProp(c_attr)
 *             c_attr = c_attr_next             # <<<<<<<<<<<<<<
 *         # remove all subelements
 *         c_node = c_node.children
 */
    __pyx_v_c_attr = __pyx_v_c_attr_next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":718
 *             c_attr = c_attr_next
 *         # remove all subelements
 *         c_node = c_node.children             # <<<<<<<<<<<<<<
 *         if c_node is not NULL:
 *             if not _isElement(c_node):
 */
  __pyx_v_c_node = __pyx_v_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":719
 *         # remove all subelements
 *         c_node = c_node.children
 *         if c_node is not NULL:             # <<<<<<<<<<<<<<
 *             if not _isElement(c_node):
 *                 c_node = _nextElement(c_node)
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":720
 *         c_node = c_node.children
 *         if c_node is not NULL:
 *             if not _isElement(c_node):             # <<<<<<<<<<<<<<
 *                 c_node = _nextElement(c_node)
 *             while c_node is not NULL:
 */
    __pyx_1 = (!_isElement(__pyx_v_c_node));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":721
 *         if c_node is not NULL:
 *             if not _isElement(c_node):
 *                 c_node = _nextElement(c_node)             # <<<<<<<<<<<<<<
 *             while c_node is not NULL:
 *                 c_node_next = _nextElement(c_node)
 */
      __pyx_v_c_node = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":722
 *             if not _isElement(c_node):
 *                 c_node = _nextElement(c_node)
 *             while c_node is not NULL:             # <<<<<<<<<<<<<<
 *                 c_node_next = _nextElement(c_node)
 *                 _removeNode(self._doc, c_node)
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_node != NULL);
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":723
 *                 c_node = _nextElement(c_node)
 *             while c_node is not NULL:
 *                 c_node_next = _nextElement(c_node)             # <<<<<<<<<<<<<<
 *                 _removeNode(self._doc, c_node)
 *                 c_node = c_node_next
 */
      __pyx_v_c_node_next = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":724
 *             while c_node is not NULL:
 *                 c_node_next = _nextElement(c_node)
 *                 _removeNode(self._doc, c_node)             # <<<<<<<<<<<<<<
 *                 c_node = c_node_next
 * 
 */
      __pyx_2 = __pyx_f_4lxml_5etree__removeNode(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":725
 *                 c_node_next = _nextElement(c_node)
 *                 _removeNode(self._doc, c_node)
 *                 c_node = c_node_next             # <<<<<<<<<<<<<<
 * 
 *     def insert(self, index, _Element element not None):
 */
      __pyx_v_c_node = __pyx_v_c_node_next;
    }
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.clear");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":727
 *                 c_node = c_node_next
 * 
 *     def insert(self, index, _Element element not None):             # <<<<<<<<<<<<<<
 *         u"""insert(self, index, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_insert[] = "insert(self, index, element)\n\n        Inserts a subelement at the given position in this element\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_index = 0;
  struct LxmlElement *__pyx_v_element = 0;
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_v_c_next;
  xmlDoc *__pyx_v_c_source_doc;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_index,&__pyx_kp_element,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_index);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("insert", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "insert") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_index = values[0];
    __pyx_v_element = ((struct LxmlElement *)values[1]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_index = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 1));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("insert", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.insert");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":735
 *         cdef xmlNode* c_next
 *         cdef xmlDoc* c_source_doc
 *         c_node = _findChild(self._c_node, index)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             _appendChild(self, element)
 */
  __pyx_1 = __pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_node = __pyx_f_4lxml_5etree__findChild(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":736
 *         cdef xmlDoc* c_source_doc
 *         c_node = _findChild(self._c_node, index)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             _appendChild(self, element)
 *             return
 */
  __pyx_2 = (__pyx_v_c_node == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":737
 *         c_node = _findChild(self._c_node, index)
 *         if c_node is NULL:
 *             _appendChild(self, element)             # <<<<<<<<<<<<<<
 *             return
 *         c_source_doc = c_node.doc
 */
    __pyx_3 = __pyx_f_4lxml_5etree__appendChild(((struct LxmlElement *)__pyx_v_self), __pyx_v_element); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":738
 *         if c_node is NULL:
 *             _appendChild(self, element)
 *             return             # <<<<<<<<<<<<<<
 *         c_source_doc = c_node.doc
 *         c_next = element._c_node.next
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":739
 *             _appendChild(self, element)
 *             return
 *         c_source_doc = c_node.doc             # <<<<<<<<<<<<<<
 *         c_next = element._c_node.next
 *         tree.xmlAddPrevSibling(c_node, element._c_node)
 */
  __pyx_v_c_source_doc = __pyx_v_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":740
 *             return
 *         c_source_doc = c_node.doc
 *         c_next = element._c_node.next             # <<<<<<<<<<<<<<
 *         tree.xmlAddPrevSibling(c_node, element._c_node)
 *         _moveTail(c_next, element._c_node)
 */
  __pyx_v_c_next = __pyx_v_element->_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":741
 *         c_source_doc = c_node.doc
 *         c_next = element._c_node.next
 *         tree.xmlAddPrevSibling(c_node, element._c_node)             # <<<<<<<<<<<<<<
 *         _moveTail(c_next, element._c_node)
 *         moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 */
  xmlAddPrevSibling(__pyx_v_c_node, __pyx_v_element->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":742
 *         c_next = element._c_node.next
 *         tree.xmlAddPrevSibling(c_node, element._c_node)
 *         _moveTail(c_next, element._c_node)             # <<<<<<<<<<<<<<
 *         moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 * 
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_element->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":743
 *         tree.xmlAddPrevSibling(c_node, element._c_node)
 *         _moveTail(c_next, element._c_node)
 *         moveNodeToDocument(self._doc, c_source_doc, element._c_node)             # <<<<<<<<<<<<<<
 * 
 *     def remove(self, _Element element not None):
 */
  __pyx_3 = __pyx_f_4lxml_5etree_moveNodeToDocument(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_source_doc, __pyx_v_element->_c_node); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.insert");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":745
 *         moveNodeToDocument(self._doc, c_source_doc, element._c_node)
 * 
 *     def remove(self, _Element element not None):             # <<<<<<<<<<<<<<
 *         u"""remove(self, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_remove(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_remove[] = "remove(self, element)\n\n        Removes a matching subelement. Unlike the find methods, this\n        method compares elements based on identity, not on tag value\n        or contents.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_remove(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_v_c_next;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":754
 *         cdef xmlNode* c_node
 *         cdef xmlNode* c_next
 *         c_node = element._c_node             # <<<<<<<<<<<<<<
 *         if c_node.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."
 */
  __pyx_v_c_node = ((struct LxmlElement *)__pyx_v_element)->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":755
 *         cdef xmlNode* c_next
 *         c_node = element._c_node
 *         if c_node.parent is not self._c_node:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Element is not a child of this node."
 *         c_next = element._c_node.next
 */
  __pyx_1 = (__pyx_v_c_node->parent != ((struct LxmlElement *)__pyx_v_self)->_c_node);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":756
 *         c_node = element._c_node
 *         if c_node.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."             # <<<<<<<<<<<<<<
 *         c_next = element._c_node.next
 *         tree.xmlUnlinkNode(c_node)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_236), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":757
 *         if c_node.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."
 *         c_next = element._c_node.next             # <<<<<<<<<<<<<<
 *         tree.xmlUnlinkNode(c_node)
 *         _moveTail(c_next, c_node)
 */
  __pyx_v_c_next = ((struct LxmlElement *)__pyx_v_element)->_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":758
 *             raise ValueError, u"Element is not a child of this node."
 *         c_next = element._c_node.next
 *         tree.xmlUnlinkNode(c_node)             # <<<<<<<<<<<<<<
 *         _moveTail(c_next, c_node)
 *         # fix namespace declarations
 */
  xmlUnlinkNode(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":759
 *         c_next = element._c_node.next
 *         tree.xmlUnlinkNode(c_node)
 *         _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 *         # fix namespace declarations
 *         moveNodeToDocument(self._doc, c_node.doc, c_node)
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":761
 *         _moveTail(c_next, c_node)
 *         # fix namespace declarations
 *         moveNodeToDocument(self._doc, c_node.doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def replace(self, _Element old_element not None,
 */
  __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node->doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.remove");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":763
 *         moveNodeToDocument(self._doc, c_node.doc, c_node)
 * 
 *     def replace(self, _Element old_element not None,             # <<<<<<<<<<<<<<
 *                 _Element new_element not None):
 *         u"""replace(self, old_element, new_element)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_replace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_replace[] = "replace(self, old_element, new_element)\n\n        Replaces a subelement with the element passed as second argument.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_replace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_old_element = 0;
  struct LxmlElement *__pyx_v_new_element = 0;
  xmlNode *__pyx_v_c_old_node;
  xmlNode *__pyx_v_c_old_next;
  xmlNode *__pyx_v_c_new_node;
  xmlNode *__pyx_v_c_new_next;
  xmlDoc *__pyx_v_c_source_doc;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_old_element,&__pyx_kp_new_element,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_old_element);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_new_element);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("replace", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "replace") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_old_element = ((struct LxmlElement *)values[0]);
    __pyx_v_new_element = ((struct LxmlElement *)values[1]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_old_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_new_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 1));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("replace", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.replace");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_old_element), __pyx_ptype_4lxml_5etree__Element, 0, "old_element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_new_element), __pyx_ptype_4lxml_5etree__Element, 0, "new_element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":774
 *         cdef xmlNode* c_new_next
 *         cdef xmlDoc* c_source_doc
 *         c_old_node = old_element._c_node             # <<<<<<<<<<<<<<
 *         if c_old_node.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."
 */
  __pyx_v_c_old_node = __pyx_v_old_element->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":775
 *         cdef xmlDoc* c_source_doc
 *         c_old_node = old_element._c_node
 *         if c_old_node.parent is not self._c_node:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Element is not a child of this node."
 *         c_old_next = c_old_node.next
 */
  __pyx_1 = (__pyx_v_c_old_node->parent != ((struct LxmlElement *)__pyx_v_self)->_c_node);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":776
 *         c_old_node = old_element._c_node
 *         if c_old_node.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."             # <<<<<<<<<<<<<<
 *         c_old_next = c_old_node.next
 *         c_new_node = new_element._c_node
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_237), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":777
 *         if c_old_node.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."
 *         c_old_next = c_old_node.next             # <<<<<<<<<<<<<<
 *         c_new_node = new_element._c_node
 *         c_new_next = c_new_node.next
 */
  __pyx_v_c_old_next = __pyx_v_c_old_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":778
 *             raise ValueError, u"Element is not a child of this node."
 *         c_old_next = c_old_node.next
 *         c_new_node = new_element._c_node             # <<<<<<<<<<<<<<
 *         c_new_next = c_new_node.next
 *         c_source_doc = c_new_node.doc
 */
  __pyx_v_c_new_node = __pyx_v_new_element->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":779
 *         c_old_next = c_old_node.next
 *         c_new_node = new_element._c_node
 *         c_new_next = c_new_node.next             # <<<<<<<<<<<<<<
 *         c_source_doc = c_new_node.doc
 *         tree.xmlReplaceNode(c_old_node, c_new_node)
 */
  __pyx_v_c_new_next = __pyx_v_c_new_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":780
 *         c_new_node = new_element._c_node
 *         c_new_next = c_new_node.next
 *         c_source_doc = c_new_node.doc             # <<<<<<<<<<<<<<
 *         tree.xmlReplaceNode(c_old_node, c_new_node)
 *         _moveTail(c_new_next, c_new_node)
 */
  __pyx_v_c_source_doc = __pyx_v_c_new_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":781
 *         c_new_next = c_new_node.next
 *         c_source_doc = c_new_node.doc
 *         tree.xmlReplaceNode(c_old_node, c_new_node)             # <<<<<<<<<<<<<<
 *         _moveTail(c_new_next, c_new_node)
 *         _moveTail(c_old_next, c_old_node)
 */
  xmlReplaceNode(__pyx_v_c_old_node, __pyx_v_c_new_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":782
 *         c_source_doc = c_new_node.doc
 *         tree.xmlReplaceNode(c_old_node, c_new_node)
 *         _moveTail(c_new_next, c_new_node)             # <<<<<<<<<<<<<<
 *         _moveTail(c_old_next, c_old_node)
 *         moveNodeToDocument(self._doc, c_source_doc, c_new_node)
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_new_next, __pyx_v_c_new_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":783
 *         tree.xmlReplaceNode(c_old_node, c_new_node)
 *         _moveTail(c_new_next, c_new_node)
 *         _moveTail(c_old_next, c_old_node)             # <<<<<<<<<<<<<<
 *         moveNodeToDocument(self._doc, c_source_doc, c_new_node)
 *         # fix namespace declarations
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_old_next, __pyx_v_c_old_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":784
 *         _moveTail(c_new_next, c_new_node)
 *         _moveTail(c_old_next, c_old_node)
 *         moveNodeToDocument(self._doc, c_source_doc, c_new_node)             # <<<<<<<<<<<<<<
 *         # fix namespace declarations
 *         moveNodeToDocument(self._doc, c_old_node.doc, c_old_node)
 */
  __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_source_doc, __pyx_v_c_new_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":786
 *         moveNodeToDocument(self._doc, c_source_doc, c_new_node)
 *         # fix namespace declarations
 *         moveNodeToDocument(self._doc, c_old_node.doc, c_old_node)             # <<<<<<<<<<<<<<
 * 
 *     # PROPERTIES
 */
  __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_old_node->doc, __pyx_v_c_old_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.replace");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":792
 *         u"""Element tag
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._tag is not None:
 *                 return self._tag
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_3tag___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_3tag___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":793
 *         """
 *         def __get__(self):
 *             if self._tag is not None:             # <<<<<<<<<<<<<<
 *                 return self._tag
 *             self._tag = _namespacedName(self._c_node)
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_tag != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":794
 *         def __get__(self):
 *             if self._tag is not None:
 *                 return self._tag             # <<<<<<<<<<<<<<
 *             self._tag = _namespacedName(self._c_node)
 *             return self._tag
 */
    Py_INCREF(((struct LxmlElement *)__pyx_v_self)->_tag);
    __pyx_r = ((struct LxmlElement *)__pyx_v_self)->_tag;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":795
 *             if self._tag is not None:
 *                 return self._tag
 *             self._tag = _namespacedName(self._c_node)             # <<<<<<<<<<<<<<
 *             return self._tag
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__namespacedName(((struct LxmlElement *)__pyx_v_self)->_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct LxmlElement *)__pyx_v_self)->_tag);
  ((struct LxmlElement *)__pyx_v_self)->_tag = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":796
 *                 return self._tag
 *             self._tag = _namespacedName(self._c_node)
 *             return self._tag             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  Py_INCREF(((struct LxmlElement *)__pyx_v_self)->_tag);
  __pyx_r = ((struct LxmlElement *)__pyx_v_self)->_tag;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.tag.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":798
 *             return self._tag
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             cdef _BaseParser parser
 *             ns, name = _getNsTag(value)
 */

static int __pyx_pf_4lxml_5etree_8_Element_3tag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_8_Element_3tag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_name;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":800
 *         def __set__(self, value):
 *             cdef _BaseParser parser
 *             ns, name = _getNsTag(value)             # <<<<<<<<<<<<<<
 *             parser = self._doc._parser
 *             if parser is not None and parser._for_html:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_value); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":801
 *             cdef _BaseParser parser
 *             ns, name = _getNsTag(value)
 *             parser = self._doc._parser             # <<<<<<<<<<<<<<
 *             if parser is not None and parser._for_html:
 *                 _htmlTagValidOrRaise(name)
 */
  Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_self)->_doc->_parser));
  Py_DECREF(((PyObject *)__pyx_v_parser));
  __pyx_v_parser = ((struct LxmlElement *)__pyx_v_self)->_doc->_parser;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":802
 *             ns, name = _getNsTag(value)
 *             parser = self._doc._parser
 *             if parser is not None and parser._for_html:             # <<<<<<<<<<<<<<
 *                 _htmlTagValidOrRaise(name)
 *             else:
 */
  __pyx_4 = (((PyObject *)__pyx_v_parser) != Py_None);
  if (__pyx_4) {
    __pyx_4 = __pyx_v_parser->_for_html;
  }
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":803
 *             parser = self._doc._parser
 *             if parser is not None and parser._for_html:
 *                 _htmlTagValidOrRaise(name)             # <<<<<<<<<<<<<<
 *             else:
 *                 _tagValidOrRaise(name)
 */
    __pyx_5 = __pyx_f_4lxml_5etree__htmlTagValidOrRaise(__pyx_v_name); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":805
 *                 _htmlTagValidOrRaise(name)
 *             else:
 *                 _tagValidOrRaise(name)             # <<<<<<<<<<<<<<
 *             self._tag = value
 *             tree.xmlNodeSetName(self._c_node, _cstr(name))
 */
    __pyx_5 = __pyx_f_4lxml_5etree__tagValidOrRaise(__pyx_v_name); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":806
 *             else:
 *                 _tagValidOrRaise(name)
 *             self._tag = value             # <<<<<<<<<<<<<<
 *             tree.xmlNodeSetName(self._c_node, _cstr(name))
 *             if ns is None:
 */
  Py_INCREF(__pyx_v_value);
  Py_DECREF(((struct LxmlElement *)__pyx_v_self)->_tag);
  ((struct LxmlElement *)__pyx_v_self)->_tag = __pyx_v_value;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":807
 *                 _tagValidOrRaise(name)
 *             self._tag = value
 *             tree.xmlNodeSetName(self._c_node, _cstr(name))             # <<<<<<<<<<<<<<
 *             if ns is None:
 *                 self._c_node.ns = NULL
 */
  xmlNodeSetName(((struct LxmlElement *)__pyx_v_self)->_c_node, PyString_AS_STRING(__pyx_v_name));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":808
 *             self._tag = value
 *             tree.xmlNodeSetName(self._c_node, _cstr(name))
 *             if ns is None:             # <<<<<<<<<<<<<<
 *                 self._c_node.ns = NULL
 *             else:
 */
  __pyx_4 = (__pyx_v_ns == Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":809
 *             tree.xmlNodeSetName(self._c_node, _cstr(name))
 *             if ns is None:
 *                 self._c_node.ns = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 self._doc._setNodeNs(self._c_node, _cstr(ns))
 */
    ((struct LxmlElement *)__pyx_v_self)->_c_node->ns = NULL;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":811
 *                 self._c_node.ns = NULL
 *             else:
 *                 self._doc._setNodeNs(self._c_node, _cstr(ns))             # <<<<<<<<<<<<<<
 * 
 *     property attrib:
 */
    __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct LxmlElement *)__pyx_v_self)->_doc->__pyx_vtab)->_setNodeNs(((struct LxmlElement *)__pyx_v_self)->_doc, ((struct LxmlElement *)__pyx_v_self)->_c_node, PyString_AS_STRING(__pyx_v_ns)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.tag.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parser);
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":817
 *         keys(), values() and items() to access element attributes.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._attrib is None:
 *                 self._attrib = _Attrib(self)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_6attrib___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_6attrib___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":818
 *         """
 *         def __get__(self):
 *             if self._attrib is None:             # <<<<<<<<<<<<<<
 *                 self._attrib = _Attrib(self)
 *             return self._attrib
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_attrib == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":819
 *         def __get__(self):
 *             if self._attrib is None:
 *                 self._attrib = _Attrib(self)             # <<<<<<<<<<<<<<
 *             return self._attrib
 * 
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Attrib)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(((struct LxmlElement *)__pyx_v_self)->_attrib);
    ((struct LxmlElement *)__pyx_v_self)->_attrib = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":820
 *             if self._attrib is None:
 *                 self._attrib = _Attrib(self)
 *             return self._attrib             # <<<<<<<<<<<<<<
 * 
 *     property text:
 */
  Py_INCREF(((struct LxmlElement *)__pyx_v_self)->_attrib);
  __pyx_r = ((struct LxmlElement *)__pyx_v_self)->_attrib;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.attrib.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":826
 *         the value None, if there was no text.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return _collectText(self._c_node.children)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_4text___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_4text___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":827
 *         """
 *         def __get__(self):
 *             return _collectText(self._c_node.children)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectText(((struct LxmlElement *)__pyx_v_self)->_c_node->children); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.text.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":829
 *             return _collectText(self._c_node.children)
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             if isinstance(value, QName):
 *                 value = python.PyUnicode_FromEncodedObject(
 */

static int __pyx_pf_4lxml_5etree_8_Element_4text___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_8_Element_4text___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF(__pyx_v_value);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":830
 * 
 *         def __set__(self, value):
 *             if isinstance(value, QName):             # <<<<<<<<<<<<<<
 *                 value = python.PyUnicode_FromEncodedObject(
 *                     _resolveQNameText(self, value), 'UTF-8', 'strict')
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_value, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":832
 *             if isinstance(value, QName):
 *                 value = python.PyUnicode_FromEncodedObject(
 *                     _resolveQNameText(self, value), 'UTF-8', 'strict')             # <<<<<<<<<<<<<<
 *             _setNodeText(self._c_node, value)
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree__resolveQNameText(((struct LxmlElement *)__pyx_v_self), __pyx_v_value); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyUnicode_FromEncodedObject(__pyx_2, __pyx_k_238, __pyx_k_239); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":833
 *                 value = python.PyUnicode_FromEncodedObject(
 *                     _resolveQNameText(self, value), 'UTF-8', 'strict')
 *             _setNodeText(self._c_node, value)             # <<<<<<<<<<<<<<
 * 
 *         # using 'del el.text' is the wrong thing to do
 */
  __pyx_4 = __pyx_f_4lxml_5etree__setNodeText(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_v_value); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.text.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":844
 *         there was no text.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return _collectText(self._c_node.next)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_4tail___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_4tail___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":845
 *         """
 *         def __get__(self):
 *             return _collectText(self._c_node.next)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectText(((struct LxmlElement *)__pyx_v_self)->_c_node->next); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.tail.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":847
 *             return _collectText(self._c_node.next)
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             _setTailText(self._c_node, value)
 * 
 */

static int __pyx_pf_4lxml_5etree_8_Element_4tail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_8_Element_4tail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":848
 * 
 *         def __set__(self, value):
 *             _setTailText(self._c_node, value)             # <<<<<<<<<<<<<<
 * 
 *         # using 'del el.tail' is the wrong thing to do
 */
  __pyx_1 = __pyx_f_4lxml_5etree__setTailText(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_v_value); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Element.tail.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":858
 *         u"""Namespace prefix or None.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._c_node.ns is not NULL:
 *                 if self._c_node.ns.prefix is not NULL:
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_6prefix___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_6prefix___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":859
 *         """
 *         def __get__(self):
 *             if self._c_node.ns is not NULL:             # <<<<<<<<<<<<<<
 *                 if self._c_node.ns.prefix is not NULL:
 *                     return funicode(self._c_node.ns.prefix)
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_c_node->ns != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":860
 *         def __get__(self):
 *             if self._c_node.ns is not NULL:
 *                 if self._c_node.ns.prefix is not NULL:             # <<<<<<<<<<<<<<
 *                     return funicode(self._c_node.ns.prefix)
 *             return None
 */
    __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_c_node->ns->prefix != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":861
 *             if self._c_node.ns is not NULL:
 *                 if self._c_node.ns.prefix is not NULL:
 *                     return funicode(self._c_node.ns.prefix)             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(((struct LxmlElement *)__pyx_v_self)->_c_node->ns->prefix); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":862
 *                 if self._c_node.ns.prefix is not NULL:
 *                     return funicode(self._c_node.ns.prefix)
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     # not in ElementTree, read-only
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.prefix.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":868
 *         u"""Original line number as found by the parser or None if unknown.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef long line
 *             line = tree.xmlGetLineNo(self._c_node)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_10sourceline___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_10sourceline___get__(PyObject *__pyx_v_self) {
  long __pyx_v_line;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":870
 *         def __get__(self):
 *             cdef long line
 *             line = tree.xmlGetLineNo(self._c_node)             # <<<<<<<<<<<<<<
 *             if line > 0:
 *                 return line
 */
  __pyx_v_line = xmlGetLineNo(((struct LxmlElement *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":871
 *             cdef long line
 *             line = tree.xmlGetLineNo(self._c_node)
 *             if line > 0:             # <<<<<<<<<<<<<<
 *                 return line
 *             else:
 */
  __pyx_1 = (__pyx_v_line > 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":872
 *             line = tree.xmlGetLineNo(self._c_node)
 *             if line > 0:
 *                 return line             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __pyx_2 = PyInt_FromLong(__pyx_v_line); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":874
 *                 return line
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, line):
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.sourceline.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":876
 *                 return None
 * 
 *         def __set__(self, line):             # <<<<<<<<<<<<<<
 *             if line < 0:
 *                 self._c_node.line = 0
 */

static int __pyx_pf_4lxml_5etree_8_Element_10sourceline___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_line); /*proto*/
static int __pyx_pf_4lxml_5etree_8_Element_10sourceline___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_line) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  unsigned short __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":877
 * 
 *         def __set__(self, line):
 *             if line < 0:             # <<<<<<<<<<<<<<
 *                 self._c_node.line = 0
 *             else:
 */
  __pyx_1 = PyObject_RichCompare(__pyx_v_line, __pyx_int_0, Py_LT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":878
 *         def __set__(self, line):
 *             if line < 0:
 *                 self._c_node.line = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 self._c_node.line = line
 */
    ((struct LxmlElement *)__pyx_v_self)->_c_node->line = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":880
 *                 self._c_node.line = 0
 *             else:
 *                 self._c_node.line = line             # <<<<<<<<<<<<<<
 * 
 *     # not in ElementTree, read-only
 */
    __pyx_3 = __pyx_PyInt_unsigned_short(__pyx_v_line); if (unlikely((__pyx_3 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct LxmlElement *)__pyx_v_self)->_c_node->line = __pyx_3;
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.sourceline.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":886
 *         u"""Namespace prefix->URI mapping known in the context of this Element.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef xmlNode* c_node
 *             cdef xmlNs* c_ns
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_5nsmap___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_5nsmap___get__(PyObject *__pyx_v_self) {
  xmlNode *__pyx_v_c_node;
  xmlNs *__pyx_v_c_ns;
  PyObject *__pyx_v_nsmap;
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  __pyx_v_nsmap = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":889
 *             cdef xmlNode* c_node
 *             cdef xmlNs* c_ns
 *             nsmap = {}             # <<<<<<<<<<<<<<
 *             c_node = self._c_node
 *             while c_node is not NULL and c_node.type == tree.XML_ELEMENT_NODE:
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_nsmap);
  __pyx_v_nsmap = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":890
 *             cdef xmlNs* c_ns
 *             nsmap = {}
 *             c_node = self._c_node             # <<<<<<<<<<<<<<
 *             while c_node is not NULL and c_node.type == tree.XML_ELEMENT_NODE:
 *                 c_ns = c_node.nsDef
 */
  __pyx_v_c_node = ((struct LxmlElement *)__pyx_v_self)->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":891
 *             nsmap = {}
 *             c_node = self._c_node
 *             while c_node is not NULL and c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *                 c_ns = c_node.nsDef
 *                 while c_ns is not NULL:
 */
  while (1) {
    __pyx_2 = (__pyx_v_c_node != NULL);
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
    }
    if (!__pyx_2) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":892
 *             c_node = self._c_node
 *             while c_node is not NULL and c_node.type == tree.XML_ELEMENT_NODE:
 *                 c_ns = c_node.nsDef             # <<<<<<<<<<<<<<
 *                 while c_ns is not NULL:
 *                     if c_ns.prefix is NULL:
 */
    __pyx_v_c_ns = __pyx_v_c_node->nsDef;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":893
 *             while c_node is not NULL and c_node.type == tree.XML_ELEMENT_NODE:
 *                 c_ns = c_node.nsDef
 *                 while c_ns is not NULL:             # <<<<<<<<<<<<<<
 *                     if c_ns.prefix is NULL:
 *                         prefix = None
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_ns != NULL);
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":894
 *                 c_ns = c_node.nsDef
 *                 while c_ns is not NULL:
 *                     if c_ns.prefix is NULL:             # <<<<<<<<<<<<<<
 *                         prefix = None
 *                     else:
 */
      __pyx_2 = (__pyx_v_c_ns->prefix == NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":895
 *                 while c_ns is not NULL:
 *                     if c_ns.prefix is NULL:
 *                         prefix = None             # <<<<<<<<<<<<<<
 *                     else:
 *                         prefix = funicode(c_ns.prefix)
 */
        Py_INCREF(Py_None);
        Py_DECREF(__pyx_v_prefix);
        __pyx_v_prefix = Py_None;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":897
 *                         prefix = None
 *                     else:
 *                         prefix = funicode(c_ns.prefix)             # <<<<<<<<<<<<<<
 *                     if not python.PyDict_GetItem(nsmap, prefix):
 *                         python.PyDict_SetItem(
 */
        __pyx_1 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_ns->prefix); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_prefix);
        __pyx_v_prefix = __pyx_1;
        __pyx_1 = 0;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":898
 *                     else:
 *                         prefix = funicode(c_ns.prefix)
 *                     if not python.PyDict_GetItem(nsmap, prefix):             # <<<<<<<<<<<<<<
 *                         python.PyDict_SetItem(
 *                             nsmap, prefix, funicode(c_ns.href))
 */
      __pyx_2 = (!(PyDict_GetItem(__pyx_v_nsmap, __pyx_v_prefix) != 0));
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":900
 *                     if not python.PyDict_GetItem(nsmap, prefix):
 *                         python.PyDict_SetItem(
 *                             nsmap, prefix, funicode(c_ns.href))             # <<<<<<<<<<<<<<
 *                     c_ns = c_ns.next
 *                 c_node = c_node.parent
 */
        __pyx_1 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_ns->href); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_3 = PyDict_SetItem(__pyx_v_nsmap, __pyx_v_prefix, __pyx_1); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":901
 *                         python.PyDict_SetItem(
 *                             nsmap, prefix, funicode(c_ns.href))
 *                     c_ns = c_ns.next             # <<<<<<<<<<<<<<
 *                 c_node = c_node.parent
 *             return nsmap
 */
      __pyx_v_c_ns = __pyx_v_c_ns->next;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":902
 *                             nsmap, prefix, funicode(c_ns.href))
 *                     c_ns = c_ns.next
 *                 c_node = c_node.parent             # <<<<<<<<<<<<<<
 *             return nsmap
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->parent;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":903
 *                     c_ns = c_ns.next
 *                 c_node = c_node.parent
 *             return nsmap             # <<<<<<<<<<<<<<
 * 
 *     # not in ElementTree, read-only
 */
  Py_INCREF(__pyx_v_nsmap);
  __pyx_r = __pyx_v_nsmap;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.nsmap.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_nsmap);
  Py_DECREF(__pyx_v_prefix);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":917
 *         Element, regardless of the document type (XML or HTML).
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef char* c_base
 *             c_base = tree.xmlNodeGetBase(self._doc._c_doc, self._c_node)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_4base___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Element_4base___get__(PyObject *__pyx_v_self) {
  char *__pyx_v_c_base;
  PyObject *__pyx_v_base;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_base = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":919
 *         def __get__(self):
 *             cdef char* c_base
 *             c_base = tree.xmlNodeGetBase(self._doc._c_doc, self._c_node)             # <<<<<<<<<<<<<<
 *             if c_base is NULL:
 *                 if self._doc._c_doc.URL is NULL:
 */
  __pyx_v_c_base = xmlNodeGetBase(((struct LxmlElement *)__pyx_v_self)->_doc->_c_doc, ((struct LxmlElement *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":920
 *             cdef char* c_base
 *             c_base = tree.xmlNodeGetBase(self._doc._c_doc, self._c_node)
 *             if c_base is NULL:             # <<<<<<<<<<<<<<
 *                 if self._doc._c_doc.URL is NULL:
 *                     return None
 */
  __pyx_1 = (__pyx_v_c_base == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":921
 *             c_base = tree.xmlNodeGetBase(self._doc._c_doc, self._c_node)
 *             if c_base is NULL:
 *                 if self._doc._c_doc.URL is NULL:             # <<<<<<<<<<<<<<
 *                     return None
 *                 return _decodeFilename(self._doc._c_doc.URL)
 */
    __pyx_1 = (((struct LxmlElement *)__pyx_v_self)->_doc->_c_doc->URL == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":922
 *             if c_base is NULL:
 *                 if self._doc._c_doc.URL is NULL:
 *                     return None             # <<<<<<<<<<<<<<
 *                 return _decodeFilename(self._doc._c_doc.URL)
 *             base = _decodeFilename(c_base)
 */
      Py_INCREF(Py_None);
      __pyx_r = Py_None;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":923
 *                 if self._doc._c_doc.URL is NULL:
 *                     return None
 *                 return _decodeFilename(self._doc._c_doc.URL)             # <<<<<<<<<<<<<<
 *             base = _decodeFilename(c_base)
 *             tree.xmlFree(c_base)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__decodeFilename(((struct LxmlElement *)__pyx_v_self)->_doc->_c_doc->URL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":924
 *                     return None
 *                 return _decodeFilename(self._doc._c_doc.URL)
 *             base = _decodeFilename(c_base)             # <<<<<<<<<<<<<<
 *             tree.xmlFree(c_base)
 *             return base
 */
  __pyx_2 = __pyx_f_4lxml_5etree__decodeFilename(__pyx_v_c_base); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_base);
  __pyx_v_base = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":925
 *                 return _decodeFilename(self._doc._c_doc.URL)
 *             base = _decodeFilename(c_base)
 *             tree.xmlFree(c_base)             # <<<<<<<<<<<<<<
 *             return base
 *         def __set__(self, url):
 */
  xmlFree(__pyx_v_c_base);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":926
 *             base = _decodeFilename(c_base)
 *             tree.xmlFree(c_base)
 *             return base             # <<<<<<<<<<<<<<
 *         def __set__(self, url):
 *             cdef char* c_base
 */
  Py_INCREF(__pyx_v_base);
  __pyx_r = __pyx_v_base;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.base.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_base);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":927
 *             tree.xmlFree(c_base)
 *             return base
 *         def __set__(self, url):             # <<<<<<<<<<<<<<
 *             cdef char* c_base
 *             if url is None:
 */

static int __pyx_pf_4lxml_5etree_8_Element_4base___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_url); /*proto*/
static int __pyx_pf_4lxml_5etree_8_Element_4base___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_url) {
  char *__pyx_v_c_base;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_url);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":929
 *         def __set__(self, url):
 *             cdef char* c_base
 *             if url is None:             # <<<<<<<<<<<<<<
 *                 c_base = NULL
 *             else:
 */
  __pyx_1 = (__pyx_v_url == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":930
 *             cdef char* c_base
 *             if url is None:
 *                 c_base = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 url = _encodeFilename(url)
 */
    __pyx_v_c_base = NULL;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":932
 *                 c_base = NULL
 *             else:
 *                 url = _encodeFilename(url)             # <<<<<<<<<<<<<<
 *                 c_base = _cstr(url)
 *             tree.xmlNodeSetBase(self._c_node, c_base)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_url); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_url);
    __pyx_v_url = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":933
 *             else:
 *                 url = _encodeFilename(url)
 *                 c_base = _cstr(url)             # <<<<<<<<<<<<<<
 *             tree.xmlNodeSetBase(self._c_node, c_base)
 * 
 */
    __pyx_v_c_base = PyString_AS_STRING(__pyx_v_url);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":934
 *                 url = _encodeFilename(url)
 *                 c_base = _cstr(url)
 *             tree.xmlNodeSetBase(self._c_node, c_base)             # <<<<<<<<<<<<<<
 * 
 *     # ACCESSORS
 */
  xmlNodeSetBase(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_v_c_base);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.base.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":937
 * 
 *     # ACCESSORS
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         u"__repr__(self)"
 *         return u"<Element %s at %x>" % (self.tag, id(self))
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element___repr__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___repr__[] = "__repr__(self)";
static PyObject *__pyx_pf_4lxml_5etree_8_Element___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":939
 *     def __repr__(self):
 *         u"__repr__(self)"
 *         return u"<Element %s at %x>" % (self.tag, id(self))             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, x):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  __pyx_1 = 0;
  __pyx_3 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_240), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":941
 *         return u"<Element %s at %x>" % (self.tag, id(self))
 * 
 *     def __getitem__(self, x):             # <<<<<<<<<<<<<<
 *         u"""Returns the subelement at the given position or the requested
 *         slice.
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___getitem__[] = "Returns the subelement at the given position or the requested\n        slice.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  xmlNode *__pyx_v_c_node;
  Py_ssize_t __pyx_v_step;
  Py_ssize_t __pyx_v_slicelength;
  Py_ssize_t __pyx_v_c;
  Py_ssize_t __pyx_v_i;
  _node_to_node_function __pyx_v_next_element;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_ssize_t __pyx_4 = 0;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":949
 *         cdef Py_ssize_t c, i
 *         cdef _node_to_node_function next_element
 *         if python.PySlice_Check(x):             # <<<<<<<<<<<<<<
 *             # slicing
 *             if _isFullSlice(<python.slice>x):
 */
  __pyx_1 = PySlice_Check(__pyx_v_x);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":951
 *         if python.PySlice_Check(x):
 *             # slicing
 *             if _isFullSlice(<python.slice>x):             # <<<<<<<<<<<<<<
 *                 return _collectChildren(self)
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 */
    __pyx_1 = __pyx_f_4lxml_5etree__isFullSlice(((PySliceObject *)__pyx_v_x));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":952
 *             # slicing
 *             if _isFullSlice(<python.slice>x):
 *                 return _collectChildren(self)             # <<<<<<<<<<<<<<
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if c_node is NULL:
 */
      __pyx_2 = __pyx_f_4lxml_5etree__collectChildren(((struct LxmlElement *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":953
 *             if _isFullSlice(<python.slice>x):
 *                 return _collectChildren(self)
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 return []
 */
    if (!(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4lxml_6python_slice))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__findChildSlice(((PySliceObject *)__pyx_v_x), ((struct LxmlElement *)__pyx_v_self)->_c_node, (&__pyx_v_c_node), (&__pyx_v_step), (&__pyx_v_slicelength)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":954
 *                 return _collectChildren(self)
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 return []
 *             if step > 0:
 */
    __pyx_1 = (__pyx_v_c_node == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":955
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if c_node is NULL:
 *                 return []             # <<<<<<<<<<<<<<
 *             if step > 0:
 *                 next_element = _nextElement
 */
      __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject *)__pyx_2);
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":956
 *             if c_node is NULL:
 *                 return []
 *             if step > 0:             # <<<<<<<<<<<<<<
 *                 next_element = _nextElement
 *             else:
 */
    __pyx_1 = (__pyx_v_step > 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":957
 *                 return []
 *             if step > 0:
 *                 next_element = _nextElement             # <<<<<<<<<<<<<<
 *             else:
 *                 step = -step
 */
      __pyx_v_next_element = __pyx_f_4lxml_5etree__nextElement;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":959
 *                 next_element = _nextElement
 *             else:
 *                 step = -step             # <<<<<<<<<<<<<<
 *                 next_element = _previousElement
 *             result = []
 */
      __pyx_v_step = (-__pyx_v_step);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":960
 *             else:
 *                 step = -step
 *                 next_element = _previousElement             # <<<<<<<<<<<<<<
 *             result = []
 *             c = 0
 */
      __pyx_v_next_element = __pyx_f_4lxml_5etree__previousElement;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":961
 *                 step = -step
 *                 next_element = _previousElement
 *             result = []             # <<<<<<<<<<<<<<
 *             c = 0
 *             while c_node is not NULL and c < slicelength:
 */
    __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = ((PyObject *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":962
 *                 next_element = _previousElement
 *             result = []
 *             c = 0             # <<<<<<<<<<<<<<
 *             while c_node is not NULL and c < slicelength:
 *                 python.PyList_Append(
 */
    __pyx_v_c = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":963
 *             result = []
 *             c = 0
 *             while c_node is not NULL and c < slicelength:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(
 *                     result, _elementFactory(self._doc, c_node))
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_node != NULL);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c < __pyx_v_slicelength);
      }
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":965
 *             while c_node is not NULL and c < slicelength:
 *                 python.PyList_Append(
 *                     result, _elementFactory(self._doc, c_node))             # <<<<<<<<<<<<<<
 *                 c = c + 1
 *                 for i from 0 <= i < step:
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyList_Append(__pyx_v_result, __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":966
 *                 python.PyList_Append(
 *                     result, _elementFactory(self._doc, c_node))
 *                 c = c + 1             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)
 */
      __pyx_v_c = (__pyx_v_c + 1);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":967
 *                     result, _elementFactory(self._doc, c_node))
 *                 c = c + 1
 *                 for i from 0 <= i < step:             # <<<<<<<<<<<<<<
 *                     c_node = next_element(c_node)
 *             return result
 */
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_step; __pyx_v_i++) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":968
 *                 c = c + 1
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)             # <<<<<<<<<<<<<<
 *             return result
 *         else:
 */
        __pyx_v_c_node = __pyx_v_next_element(__pyx_v_c_node);
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":969
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)
 *             return result             # <<<<<<<<<<<<<<
 *         else:
 *             # indexing
 */
    Py_INCREF(__pyx_v_result);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":972
 *         else:
 *             # indexing
 *             c_node = _findChild(self._c_node, x)             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"
 */
    __pyx_4 = __pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_node = __pyx_f_4lxml_5etree__findChild(((struct LxmlElement *)__pyx_v_self)->_c_node, __pyx_4);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":973
 *             # indexing
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 raise IndexError, u"list index out of range"
 *             return _elementFactory(self._doc, c_node)
 */
    __pyx_1 = (__pyx_v_c_node == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":974
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"             # <<<<<<<<<<<<<<
 *             return _elementFactory(self._doc, c_node)
 * 
 */
      __Pyx_Raise(__pyx_builtin_IndexError, ((PyObject *)__pyx_kp_241), 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":975
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"
 *             return _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":977
 *             return _elementFactory(self._doc, c_node)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         u"""__len__(self)
 * 
 */

static Py_ssize_t __pyx_pf_4lxml_5etree_8_Element___len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___len__[] = "__len__(self)\n\n        Returns the number of subelements.\n        ";
static Py_ssize_t __pyx_pf_4lxml_5etree_8_Element___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":982
 *         Returns the number of subelements.
 *         """
 *         return _countElements(self._c_node.children)             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __pyx_r = __pyx_f_4lxml_5etree__countElements(((struct LxmlElement *)__pyx_v_self)->_c_node->children);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":984
 *         return _countElements(self._c_node.children)
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         u"__nonzero__(self)"
 *         import warnings
 */

static int __pyx_pf_4lxml_5etree_8_Element___nonzero__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___nonzero__[] = "__nonzero__(self)";
static int __pyx_pf_4lxml_5etree_8_Element___nonzero__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_warnings;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_warnings = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":986
 *     def __nonzero__(self):
 *         u"__nonzero__(self)"
 *         import warnings             # <<<<<<<<<<<<<<
 *         warnings.warn(
 *             u"The behavior of this method will change in future versions. "
 */
  __pyx_1 = __Pyx_Import(__pyx_kp_warnings, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_warnings);
  __pyx_v_warnings = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":987
 *         u"__nonzero__(self)"
 *         import warnings
 *         warnings.warn(             # <<<<<<<<<<<<<<
 *             u"The behavior of this method will change in future versions. "
 *             u"Use specific 'len(elem)' or 'elem is not None' test instead.",
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_warnings, __pyx_kp_warn); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":991
 *             u"Use specific 'len(elem)' or 'elem is not None' test instead.",
 *             FutureWarning
 *             )             # <<<<<<<<<<<<<<
 *         # emulate old behaviour
 *         return _hasChild(self._c_node)
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_242));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_242));
  Py_INCREF(__pyx_builtin_FutureWarning);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_builtin_FutureWarning);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":993
 *             )
 *         # emulate old behaviour
 *         return _hasChild(self._c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, element):
 */
  __pyx_r = __pyx_f_4lxml_5etree__hasChild(((struct LxmlElement *)__pyx_v_self)->_c_node);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.__nonzero__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_warnings);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":995
 *         return _hasChild(self._c_node)
 * 
 *     def __contains__(self, element):             # <<<<<<<<<<<<<<
 *         u"__contains__(self, element)"
 *         cdef xmlNode* c_node
 */

static int __pyx_pf_4lxml_5etree_8_Element___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___contains__[] = "__contains__(self, element)";
static int __pyx_pf_4lxml_5etree_8_Element___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  xmlNode *__pyx_v_c_node;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":998
 *         u"__contains__(self, element)"
 *         cdef xmlNode* c_node
 *         if not isinstance(element, _Element):             # <<<<<<<<<<<<<<
 *             return 0
 *         c_node = (<_Element>element)._c_node
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":999
 *         cdef xmlNode* c_node
 *         if not isinstance(element, _Element):
 *             return 0             # <<<<<<<<<<<<<<
 *         c_node = (<_Element>element)._c_node
 *         return c_node is not NULL and c_node.parent is self._c_node
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1000
 *         if not isinstance(element, _Element):
 *             return 0
 *         c_node = (<_Element>element)._c_node             # <<<<<<<<<<<<<<
 *         return c_node is not NULL and c_node.parent is self._c_node
 * 
 */
  __pyx_v_c_node = ((struct LxmlElement *)__pyx_v_element)->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1001
 *             return 0
 *         c_node = (<_Element>element)._c_node
 *         return c_node is not NULL and c_node.parent is self._c_node             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_node->parent == ((struct LxmlElement *)__pyx_v_self)->_c_node);
  }
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1003
 *         return c_node is not NULL and c_node.parent is self._c_node
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         u"__iter__(self)"
 *         return ElementChildIterator(self)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element___iter__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___iter__[] = "__iter__(self)";
static PyObject *__pyx_pf_4lxml_5etree_8_Element___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1005
 *     def __iter__(self):
 *         u"__iter__(self)"
 *         return ElementChildIterator(self)             # <<<<<<<<<<<<<<
 * 
 *     def __reversed__(self):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementChildIterator)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1007
 *         return ElementChildIterator(self)
 * 
 *     def __reversed__(self):             # <<<<<<<<<<<<<<
 *         u"__reversed__(self)"
 *         return ElementChildIterator(self, reversed=True)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element___reversed__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element___reversed__[] = "__reversed__(self)";
static PyObject *__pyx_pf_4lxml_5etree_8_Element___reversed__(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1009
 *     def __reversed__(self):
 *         u"__reversed__(self)"
 *         return ElementChildIterator(self, reversed=True)             # <<<<<<<<<<<<<<
 * 
 *     def index(self, _Element child not None, start=None, stop=None):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_reversed, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementChildIterator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.__reversed__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1011
 *         return ElementChildIterator(self, reversed=True)
 * 
 *     def index(self, _Element child not None, start=None, stop=None):             # <<<<<<<<<<<<<<
 *         u"""index(self, child, start=None, stop=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_index[] = "index(self, child, start=None, stop=None)\n\n        Find the position of the child within the parent.\n\n        This method is not part of the original ElementTree API.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_child = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  Py_ssize_t __pyx_v_k;
  Py_ssize_t __pyx_v_l;
  Py_ssize_t __pyx_v_c_start;
  Py_ssize_t __pyx_v_c_stop;
  xmlNode *__pyx_v_c_child;
  xmlNode *__pyx_v_c_start_node;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_child,&__pyx_kp_start,&__pyx_kp_stop,0};
  __pyx_v_start = Py_None;
  __pyx_v_stop = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_child);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_child = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_start = values[1];
    }
    if (values[2]) {
      __pyx_v_stop = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_stop = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_child = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("index", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.index");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child), __pyx_ptype_4lxml_5etree__Element, 0, "child", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1022
 *         cdef xmlNode* c_child
 *         cdef xmlNode* c_start_node
 *         c_child = child._c_node             # <<<<<<<<<<<<<<
 *         if c_child.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."
 */
  __pyx_v_c_child = __pyx_v_child->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1023
 *         cdef xmlNode* c_start_node
 *         c_child = child._c_node
 *         if c_child.parent is not self._c_node:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Element is not a child of this node."
 * 
 */
  __pyx_1 = (__pyx_v_c_child->parent != ((struct LxmlElement *)__pyx_v_self)->_c_node);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1024
 *         c_child = child._c_node
 *         if c_child.parent is not self._c_node:
 *             raise ValueError, u"Element is not a child of this node."             # <<<<<<<<<<<<<<
 * 
 *         # handle the unbounded search straight away (normal case)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_243), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1027
 * 
 *         # handle the unbounded search straight away (normal case)
 *         if stop is None and (start is None or start == 0):             # <<<<<<<<<<<<<<
 *             k = 0
 *             c_child = c_child.prev
 */
  __pyx_1 = (__pyx_v_stop == Py_None);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_start == Py_None);
    if (!__pyx_1) {
      __pyx_3 = PyObject_RichCompare(__pyx_v_start, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1028
 *         # handle the unbounded search straight away (normal case)
 *         if stop is None and (start is None or start == 0):
 *             k = 0             # <<<<<<<<<<<<<<
 *             c_child = c_child.prev
 *             while c_child is not NULL:
 */
    __pyx_v_k = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1029
 *         if stop is None and (start is None or start == 0):
 *             k = 0
 *             c_child = c_child.prev             # <<<<<<<<<<<<<<
 *             while c_child is not NULL:
 *                 if _isElement(c_child):
 */
    __pyx_v_c_child = __pyx_v_c_child->prev;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1030
 *             k = 0
 *             c_child = c_child.prev
 *             while c_child is not NULL:             # <<<<<<<<<<<<<<
 *                 if _isElement(c_child):
 *                     k = k + 1
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_child != NULL);
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1031
 *             c_child = c_child.prev
 *             while c_child is not NULL:
 *                 if _isElement(c_child):             # <<<<<<<<<<<<<<
 *                     k = k + 1
 *                 c_child = c_child.prev
 */
      __pyx_1 = _isElement(__pyx_v_c_child);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1032
 *             while c_child is not NULL:
 *                 if _isElement(c_child):
 *                     k = k + 1             # <<<<<<<<<<<<<<
 *                 c_child = c_child.prev
 *             return k
 */
        __pyx_v_k = (__pyx_v_k + 1);
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1033
 *                 if _isElement(c_child):
 *                     k = k + 1
 *                 c_child = c_child.prev             # <<<<<<<<<<<<<<
 *             return k
 * 
 */
      __pyx_v_c_child = __pyx_v_c_child->prev;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1034
 *                     k = k + 1
 *                 c_child = c_child.prev
 *             return k             # <<<<<<<<<<<<<<
 * 
 *         # check indices
 */
    __pyx_3 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1037
 * 
 *         # check indices
 *         if start is None:             # <<<<<<<<<<<<<<
 *             c_start = 0
 *         else:
 */
  __pyx_2 = (__pyx_v_start == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1038
 *         # check indices
 *         if start is None:
 *             c_start = 0             # <<<<<<<<<<<<<<
 *         else:
 *             c_start = start
 */
    __pyx_v_c_start = 0;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1040
 *             c_start = 0
 *         else:
 *             c_start = start             # <<<<<<<<<<<<<<
 *         if stop is None:
 *             c_stop = 0
 */
    __pyx_4 = __pyx_PyIndex_AsSsize_t(__pyx_v_start); if (unlikely((__pyx_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_start = __pyx_4;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1041
 *         else:
 *             c_start = start
 *         if stop is None:             # <<<<<<<<<<<<<<
 *             c_stop = 0
 *         else:
 */
  __pyx_1 = (__pyx_v_stop == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1042
 *             c_start = start
 *         if stop is None:
 *             c_stop = 0             # <<<<<<<<<<<<<<
 *         else:
 *             c_stop = stop
 */
    __pyx_v_c_stop = 0;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1044
 *             c_stop = 0
 *         else:
 *             c_stop = stop             # <<<<<<<<<<<<<<
 *             if c_stop == 0 or \
 *                    c_start >= c_stop and (c_stop > 0 or c_start < 0):
 */
    __pyx_4 = __pyx_PyIndex_AsSsize_t(__pyx_v_stop); if (unlikely((__pyx_4 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_stop = __pyx_4;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1045
 *         else:
 *             c_stop = stop
 *             if c_stop == 0 or \             # <<<<<<<<<<<<<<
 *                    c_start >= c_stop and (c_stop > 0 or c_start < 0):
 *                 raise ValueError, u"list.index(x): x not in slice"
 */
    __pyx_2 = (__pyx_v_c_stop == 0);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1046
 *             c_stop = stop
 *             if c_stop == 0 or \
 *                    c_start >= c_stop and (c_stop > 0 or c_start < 0):             # <<<<<<<<<<<<<<
 *                 raise ValueError, u"list.index(x): x not in slice"
 * 
 */
      __pyx_2 = (__pyx_v_c_start >= __pyx_v_c_stop);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_c_stop > 0);
        if (!__pyx_2) {
          __pyx_2 = (__pyx_v_c_start < 0);
        }
      }
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1047
 *             if c_stop == 0 or \
 *                    c_start >= c_stop and (c_stop > 0 or c_start < 0):
 *                 raise ValueError, u"list.index(x): x not in slice"             # <<<<<<<<<<<<<<
 * 
 *         # for negative slice indices, check slice before searching index
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_244), 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L13;
    }
    __pyx_L13:;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1050
 * 
 *         # for negative slice indices, check slice before searching index
 *         if c_start < 0 or c_stop < 0:             # <<<<<<<<<<<<<<
 *             # start from right, at most up to leftmost(c_start, c_stop)
 *             if c_start < c_stop:
 */
  __pyx_1 = (__pyx_v_c_start < 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c_stop < 0);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1052
 *         if c_start < 0 or c_stop < 0:
 *             # start from right, at most up to leftmost(c_start, c_stop)
 *             if c_start < c_stop:             # <<<<<<<<<<<<<<
 *                 k = -c_start
 *             else:
 */
    __pyx_2 = (__pyx_v_c_start < __pyx_v_c_stop);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1053
 *             # start from right, at most up to leftmost(c_start, c_stop)
 *             if c_start < c_stop:
 *                 k = -c_start             # <<<<<<<<<<<<<<
 *             else:
 *                 k = -c_stop
 */
      __pyx_v_k = (-__pyx_v_c_start);
      goto __pyx_L15;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1055
 *                 k = -c_start
 *             else:
 *                 k = -c_stop             # <<<<<<<<<<<<<<
 *             c_start_node = self._c_node.last
 *             l = 1
 */
      __pyx_v_k = (-__pyx_v_c_stop);
    }
    __pyx_L15:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1056
 *             else:
 *                 k = -c_stop
 *             c_start_node = self._c_node.last             # <<<<<<<<<<<<<<
 *             l = 1
 *             while c_start_node != c_child and l < k:
 */
    __pyx_v_c_start_node = ((struct LxmlElement *)__pyx_v_self)->_c_node->last;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1057
 *                 k = -c_stop
 *             c_start_node = self._c_node.last
 *             l = 1             # <<<<<<<<<<<<<<
 *             while c_start_node != c_child and l < k:
 *                 if _isElement(c_start_node):
 */
    __pyx_v_l = 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1058
 *             c_start_node = self._c_node.last
 *             l = 1
 *             while c_start_node != c_child and l < k:             # <<<<<<<<<<<<<<
 *                 if _isElement(c_start_node):
 *                     l = l + 1
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_start_node != __pyx_v_c_child);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_l < __pyx_v_k);
      }
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1059
 *             l = 1
 *             while c_start_node != c_child and l < k:
 *                 if _isElement(c_start_node):             # <<<<<<<<<<<<<<
 *                     l = l + 1
 *                 c_start_node = c_start_node.prev
 */
      __pyx_2 = _isElement(__pyx_v_c_start_node);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1060
 *             while c_start_node != c_child and l < k:
 *                 if _isElement(c_start_node):
 *                     l = l + 1             # <<<<<<<<<<<<<<
 *                 c_start_node = c_start_node.prev
 *             if c_start_node == c_child:
 */
        __pyx_v_l = (__pyx_v_l + 1);
        goto __pyx_L18;
      }
      __pyx_L18:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1061
 *                 if _isElement(c_start_node):
 *                     l = l + 1
 *                 c_start_node = c_start_node.prev             # <<<<<<<<<<<<<<
 *             if c_start_node == c_child:
 *                 # found! before slice end?
 */
      __pyx_v_c_start_node = __pyx_v_c_start_node->prev;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1062
 *                     l = l + 1
 *                 c_start_node = c_start_node.prev
 *             if c_start_node == c_child:             # <<<<<<<<<<<<<<
 *                 # found! before slice end?
 *                 if c_stop < 0 and l <= -c_stop:
 */
    __pyx_1 = (__pyx_v_c_start_node == __pyx_v_c_child);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1064
 *             if c_start_node == c_child:
 *                 # found! before slice end?
 *                 if c_stop < 0 and l <= -c_stop:             # <<<<<<<<<<<<<<
 *                     raise ValueError, u"list.index(x): x not in slice"
 *             elif c_start < 0:
 */
      __pyx_2 = (__pyx_v_c_stop < 0);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_l <= (-__pyx_v_c_stop));
      }
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1065
 *                 # found! before slice end?
 *                 if c_stop < 0 and l <= -c_stop:
 *                     raise ValueError, u"list.index(x): x not in slice"             # <<<<<<<<<<<<<<
 *             elif c_start < 0:
 *                 raise ValueError, u"list.index(x): x not in slice"
 */
        __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_245), 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L20;
      }
      __pyx_L20:;
      goto __pyx_L19;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1066
 *                 if c_stop < 0 and l <= -c_stop:
 *                     raise ValueError, u"list.index(x): x not in slice"
 *             elif c_start < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError, u"list.index(x): x not in slice"
 * 
 */
    __pyx_1 = (__pyx_v_c_start < 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1067
 *                     raise ValueError, u"list.index(x): x not in slice"
 *             elif c_start < 0:
 *                 raise ValueError, u"list.index(x): x not in slice"             # <<<<<<<<<<<<<<
 * 
 *         # now determine the index backwards from child
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_246), 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L19;
    }
    __pyx_L19:;
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1070
 * 
 *         # now determine the index backwards from child
 *         c_child = c_child.prev             # <<<<<<<<<<<<<<
 *         k = 0
 *         if c_stop > 0:
 */
  __pyx_v_c_child = __pyx_v_c_child->prev;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1071
 *         # now determine the index backwards from child
 *         c_child = c_child.prev
 *         k = 0             # <<<<<<<<<<<<<<
 *         if c_stop > 0:
 *             # we can optimize: stop after c_stop elements if not found
 */
  __pyx_v_k = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1072
 *         c_child = c_child.prev
 *         k = 0
 *         if c_stop > 0:             # <<<<<<<<<<<<<<
 *             # we can optimize: stop after c_stop elements if not found
 *             while c_child != NULL and k < c_stop:
 */
  __pyx_2 = (__pyx_v_c_stop > 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1074
 *         if c_stop > 0:
 *             # we can optimize: stop after c_stop elements if not found
 *             while c_child != NULL and k < c_stop:             # <<<<<<<<<<<<<<
 *                 if _isElement(c_child):
 *                     k = k + 1
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_child != NULL);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_k < __pyx_v_c_stop);
      }
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1075
 *             # we can optimize: stop after c_stop elements if not found
 *             while c_child != NULL and k < c_stop:
 *                 if _isElement(c_child):             # <<<<<<<<<<<<<<
 *                     k = k + 1
 *                 c_child = c_child.prev
 */
      __pyx_2 = _isElement(__pyx_v_c_child);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1076
 *             while c_child != NULL and k < c_stop:
 *                 if _isElement(c_child):
 *                     k = k + 1             # <<<<<<<<<<<<<<
 *                 c_child = c_child.prev
 *             if k < c_stop:
 */
        __pyx_v_k = (__pyx_v_k + 1);
        goto __pyx_L24;
      }
      __pyx_L24:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1077
 *                 if _isElement(c_child):
 *                     k = k + 1
 *                 c_child = c_child.prev             # <<<<<<<<<<<<<<
 *             if k < c_stop:
 *                 return k
 */
      __pyx_v_c_child = __pyx_v_c_child->prev;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1078
 *                     k = k + 1
 *                 c_child = c_child.prev
 *             if k < c_stop:             # <<<<<<<<<<<<<<
 *                 return k
 *         else:
 */
    __pyx_1 = (__pyx_v_k < __pyx_v_c_stop);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1079
 *                 c_child = c_child.prev
 *             if k < c_stop:
 *                 return k             # <<<<<<<<<<<<<<
 *         else:
 *             # traverse all
 */
      __pyx_3 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
      goto __pyx_L25;
    }
    __pyx_L25:;
    goto __pyx_L21;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1082
 *         else:
 *             # traverse all
 *             while c_child != NULL:             # <<<<<<<<<<<<<<
 *                 if _isElement(c_child):
 *                     k = k + 1
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_child != NULL);
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1083
 *             # traverse all
 *             while c_child != NULL:
 *                 if _isElement(c_child):             # <<<<<<<<<<<<<<
 *                     k = k + 1
 *                 c_child = c_child.prev
 */
      __pyx_1 = _isElement(__pyx_v_c_child);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1084
 *             while c_child != NULL:
 *                 if _isElement(c_child):
 *                     k = k + 1             # <<<<<<<<<<<<<<
 *                 c_child = c_child.prev
 *             if c_start > 0:
 */
        __pyx_v_k = (__pyx_v_k + 1);
        goto __pyx_L28;
      }
      __pyx_L28:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1085
 *                 if _isElement(c_child):
 *                     k = k + 1
 *                 c_child = c_child.prev             # <<<<<<<<<<<<<<
 *             if c_start > 0:
 *                 if k >= c_start:
 */
      __pyx_v_c_child = __pyx_v_c_child->prev;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1086
 *                     k = k + 1
 *                 c_child = c_child.prev
 *             if c_start > 0:             # <<<<<<<<<<<<<<
 *                 if k >= c_start:
 *                     return k
 */
    __pyx_2 = (__pyx_v_c_start > 0);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1087
 *                 c_child = c_child.prev
 *             if c_start > 0:
 *                 if k >= c_start:             # <<<<<<<<<<<<<<
 *                     return k
 *             else:
 */
      __pyx_1 = (__pyx_v_k >= __pyx_v_c_start);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1088
 *             if c_start > 0:
 *                 if k >= c_start:
 *                     return k             # <<<<<<<<<<<<<<
 *             else:
 *                 return k
 */
        __pyx_3 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_r = __pyx_3;
        __pyx_3 = 0;
        goto __pyx_L0;
        goto __pyx_L30;
      }
      __pyx_L30:;
      goto __pyx_L29;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1090
 *                     return k
 *             else:
 *                 return k             # <<<<<<<<<<<<<<
 *         if c_start != 0 or c_stop != 0:
 *             raise ValueError, u"list.index(x): x not in slice"
 */
      __pyx_3 = PyInt_FromSsize_t(__pyx_v_k); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
    }
    __pyx_L29:;
  }
  __pyx_L21:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1091
 *             else:
 *                 return k
 *         if c_start != 0 or c_stop != 0:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"list.index(x): x not in slice"
 *         else:
 */
  __pyx_2 = (__pyx_v_c_start != 0);
  if (!__pyx_2) {
    __pyx_2 = (__pyx_v_c_stop != 0);
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1092
 *                 return k
 *         if c_start != 0 or c_stop != 0:
 *             raise ValueError, u"list.index(x): x not in slice"             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError, u"list.index(x): x not in list"
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_247), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L31;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1094
 *             raise ValueError, u"list.index(x): x not in slice"
 *         else:
 *             raise ValueError, u"list.index(x): x not in list"             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_248), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L31:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.index");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1096
 *             raise ValueError, u"list.index(x): x not in list"
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         u"""get(self, key, default=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_get[] = "get(self, key, default=None)\n\n        Gets an element attribute.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.get");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1101
 *         Gets an element attribute.
 *         """
 *         return _getAttributeValue(self, key, default)             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getAttributeValue(((struct LxmlElement *)__pyx_v_self), __pyx_v_key, __pyx_v_default); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.get");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1103
 *         return _getAttributeValue(self, key, default)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         u"""keys(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_keys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_keys[] = "keys(self)\n\n        Gets a list of attribute names.  The names are returned in an\n        arbitrary order (just like for an ordinary Python dictionary).\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_keys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1109
 *         arbitrary order (just like for an ordinary Python dictionary).
 *         """
 *         return _collectAttributes(self._c_node, 1)             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct LxmlElement *)__pyx_v_self)->_c_node, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.keys");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1111
 *         return _collectAttributes(self._c_node, 1)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         u"""values(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_values(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_values[] = "values(self)\n\n        Gets element attribute values as a sequence of strings.  The\n        attributes are returned in an arbitrary order.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_values(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1117
 *         attributes are returned in an arbitrary order.
 *         """
 *         return _collectAttributes(self._c_node, 2)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct LxmlElement *)__pyx_v_self)->_c_node, 2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.values");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1119
 *         return _collectAttributes(self._c_node, 2)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         u"""items(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_items(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_items[] = "items(self)\n\n        Gets element attributes, as a sequence. The attributes are returned in\n        an arbitrary order.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_items(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1125
 *         an arbitrary order.
 *         """
 *         return _collectAttributes(self._c_node, 3)             # <<<<<<<<<<<<<<
 * 
 *     def getchildren(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct LxmlElement *)__pyx_v_self)->_c_node, 3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.items");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1127
 *         return _collectAttributes(self._c_node, 3)
 * 
 *     def getchildren(self):             # <<<<<<<<<<<<<<
 *         u"""getchildren(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_getchildren(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_getchildren[] = "getchildren(self)\n\n        Returns all direct children.  The elements are returned in document\n        order.\n\n        :deprecated: Note that this method has been deprecated as of\n          ElementTree 1.3 and lxml 2.0.  New code should use\n          ``list(element)`` or simply iterate over elements.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_getchildren(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1137
 *           ``list(element)`` or simply iterate over elements.
 *         """
 *         return _collectChildren(self)             # <<<<<<<<<<<<<<
 * 
 *     def getparent(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectChildren(((struct LxmlElement *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.getchildren");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1139
 *         return _collectChildren(self)
 * 
 *     def getparent(self):             # <<<<<<<<<<<<<<
 *         u"""getparent(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_getparent(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_getparent[] = "getparent(self)\n\n        Returns the parent of this element or None for the root element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_getparent(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1145
 *         """
 *         cdef xmlNode* c_node
 *         c_node = _parentElement(self._c_node)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             return None
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__parentElement(((struct LxmlElement *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1146
 *         cdef xmlNode* c_node
 *         c_node = _parentElement(self._c_node)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return _elementFactory(self._doc, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1147
 *         c_node = _parentElement(self._c_node)
 *         if c_node is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return _elementFactory(self._doc, c_node)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1148
 *         if c_node is NULL:
 *             return None
 *         return _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def getnext(self):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.getparent");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1150
 *         return _elementFactory(self._doc, c_node)
 * 
 *     def getnext(self):             # <<<<<<<<<<<<<<
 *         u"""getnext(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_getnext(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_getnext[] = "getnext(self)\n\n        Returns the following sibling of this element or None.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_getnext(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1156
 *         """
 *         cdef xmlNode* c_node
 *         c_node = _nextElement(self._c_node)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             return None
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__nextElement(((struct LxmlElement *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1157
 *         cdef xmlNode* c_node
 *         c_node = _nextElement(self._c_node)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return _elementFactory(self._doc, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1158
 *         c_node = _nextElement(self._c_node)
 *         if c_node is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return _elementFactory(self._doc, c_node)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1159
 *         if c_node is NULL:
 *             return None
 *         return _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def getprevious(self):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.getnext");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1161
 *         return _elementFactory(self._doc, c_node)
 * 
 *     def getprevious(self):             # <<<<<<<<<<<<<<
 *         u"""getprevious(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_getprevious(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_getprevious[] = "getprevious(self)\n\n        Returns the preceding sibling of this element or None.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_getprevious(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1167
 *         """
 *         cdef xmlNode* c_node
 *         c_node = _previousElement(self._c_node)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             return None
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__previousElement(((struct LxmlElement *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1168
 *         cdef xmlNode* c_node
 *         c_node = _previousElement(self._c_node)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return _elementFactory(self._doc, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1169
 *         c_node = _previousElement(self._c_node)
 *         if c_node is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return _elementFactory(self._doc, c_node)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1170
 *         if c_node is NULL:
 *             return None
 *         return _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def itersiblings(self, tag=None, *, preceding=False):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlElement *)__pyx_v_self)->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.getprevious");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1172
 *         return _elementFactory(self._doc, c_node)
 * 
 *     def itersiblings(self, tag=None, *, preceding=False):             # <<<<<<<<<<<<<<
 *         u"""itersiblings(self, tag=None, preceding=False)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_itersiblings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_itersiblings[] = "itersiblings(self, tag=None, preceding=False)\n\n        Iterate over the following or preceding siblings of this element.\n\n        The direction is determined by the 'preceding' keyword which defaults\n        to False, i.e. forward iteration over the following siblings.  The\n        generated elements can be restricted to a specific tag name with the\n        'tag' keyword.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_itersiblings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_preceding = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,&__pyx_kp_preceding,0};
  __pyx_v_tag = Py_None;
  __pyx_v_preceding = __pyx_k_67;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "itersiblings") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
    if (values[1]) {
      __pyx_v_preceding = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("itersiblings", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.itersiblings");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1182
 *         'tag' keyword.
 *         """
 *         return SiblingsIterator(self, tag, preceding=preceding)             # <<<<<<<<<<<<<<
 * 
 *     def iterancestors(self, tag=None):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_preceding, __pyx_v_preceding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_SiblingsIterator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.itersiblings");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1184
 *         return SiblingsIterator(self, tag, preceding=preceding)
 * 
 *     def iterancestors(self, tag=None):             # <<<<<<<<<<<<<<
 *         u"""iterancestors(self, tag=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterancestors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_iterancestors[] = "iterancestors(self, tag=None)\n\n        Iterate over the ancestors of this element (from parent to parent).\n\n        The generated elements can be restricted to a specific tag name with\n        the 'tag' keyword.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterancestors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "iterancestors") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterancestors", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.iterancestors");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1192
 *         the 'tag' keyword.
 *         """
 *         return AncestorsIterator(self, tag)             # <<<<<<<<<<<<<<
 * 
 *     def iterdescendants(self, tag=None):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_AncestorsIterator)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.iterancestors");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1194
 *         return AncestorsIterator(self, tag)
 * 
 *     def iterdescendants(self, tag=None):             # <<<<<<<<<<<<<<
 *         u"""iterdescendants(self, tag=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterdescendants(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_iterdescendants[] = "iterdescendants(self, tag=None)\n\n        Iterate over the descendants of this element in document order.\n\n        As opposed to ``el.iter()``, this iterator does not yield the element\n        itself.  The generated elements can be restricted to a specific tag\n        name with the 'tag' keyword.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterdescendants(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "iterdescendants") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterdescendants", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.iterdescendants");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1203
 *         name with the 'tag' keyword.
 *         """
 *         return ElementDepthFirstIterator(self, tag, inclusive=False)             # <<<<<<<<<<<<<<
 * 
 *     def iterchildren(self, tag=None, *, reversed=False):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_inclusive, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementDepthFirstIterator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.iterdescendants");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1205
 *         return ElementDepthFirstIterator(self, tag, inclusive=False)
 * 
 *     def iterchildren(self, tag=None, *, reversed=False):             # <<<<<<<<<<<<<<
 *         u"""iterchildren(self, tag=None, reversed=False)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterchildren(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_iterchildren[] = "iterchildren(self, tag=None, reversed=False)\n\n        Iterate over the children of this element.\n\n        As opposed to using normal iteration on this element, the generated\n        elements can be restricted to a specific tag name with the 'tag'\n        keyword and reversed with the 'reversed' keyword.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterchildren(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_reversed = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,&__pyx_kp_reversed,0};
  __pyx_v_tag = Py_None;
  __pyx_v_reversed = __pyx_k_68;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "iterchildren") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
    if (values[1]) {
      __pyx_v_reversed = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterchildren", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.iterchildren");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1214
 *         keyword and reversed with the 'reversed' keyword.
 *         """
 *         return ElementChildIterator(self, tag, reversed=reversed)             # <<<<<<<<<<<<<<
 * 
 *     def getroottree(self):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_reversed, __pyx_v_reversed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementChildIterator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.iterchildren");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1216
 *         return ElementChildIterator(self, tag, reversed=reversed)
 * 
 *     def getroottree(self):             # <<<<<<<<<<<<<<
 *         u"""getroottree(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_getroottree(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_getroottree[] = "getroottree(self)\n\n        Return an ElementTree for the root node of the document that\n        contains this element.\n\n        This is the same as following element.getparent() up the tree until it\n        returns None (for the root element) and then build an ElementTree for\n        the last parent that was returned.";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_getroottree(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1225
 *         returns None (for the root element) and then build an ElementTree for
 *         the last parent that was returned."""
 *         return _elementTreeFactory(self._doc, None)             # <<<<<<<<<<<<<<
 * 
 *     def getiterator(self, tag=None):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(((struct LxmlElement *)__pyx_v_self)->_doc, ((struct LxmlElement *)Py_None))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.getroottree");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1227
 *         return _elementTreeFactory(self._doc, None)
 * 
 *     def getiterator(self, tag=None):             # <<<<<<<<<<<<<<
 *         u"""getiterator(self, tag=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_getiterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_getiterator[] = "getiterator(self, tag=None)\n\n        Returns a sequence or iterator of all elements in the subtree in\n        document order (depth first pre-order), starting with this\n        element.\n\n        Can be restricted to find only elements with a specific tag\n        (pass ``tag=\"xyz\"``) or from a namespace (pass ``tag=\"{ns}*\"``).\n\n        You can also pass the Element, Comment, ProcessingInstruction and\n        Entity factory functions to look only for the specific element type.\n\n        :deprecated: Note that this method is deprecated as of\n          ElementTree 1.3 and lxml 2.0.  It returns an iterator in\n          lxml, which diverges from the original ElementTree\n          behaviour.  If you want an efficient iterator, use the\n          ``element.iter()`` method instead.  You should only use this\n          method in new code if you require backwards compatibility\n          with older versions of lxml or ElementTree.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_getiterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "getiterator") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getiterator", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.getiterator");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1248
 *           with older versions of lxml or ElementTree.
 *         """
 *         return ElementDepthFirstIterator(self, tag)             # <<<<<<<<<<<<<<
 * 
 *     def iter(self, tag=None):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementDepthFirstIterator)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.getiterator");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1250
 *         return ElementDepthFirstIterator(self, tag)
 * 
 *     def iter(self, tag=None):             # <<<<<<<<<<<<<<
 *         u"""iter(self, tag=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_iter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_iter[] = "iter(self, tag=None)\n\n        Iterate over all elements in the subtree in document order (depth\n        first pre-order), starting with this element.\n\n        Can be restricted to find only elements with a specific tag\n        (pass ``tag=\"xyz\"``) or from a namespace (pass ``tag=\"{ns}*\"``).\n\n        You can also pass the Element, Comment, ProcessingInstruction and\n        Entity factory functions to look only for the specific element type.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_iter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "iter") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.iter");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1262
 *         Entity factory functions to look only for the specific element type.
 *         """
 *         return ElementDepthFirstIterator(self, tag)             # <<<<<<<<<<<<<<
 * 
 *     def itertext(self, tag=None, *, with_tail=True):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementDepthFirstIterator)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Element.iter");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1264
 *         return ElementDepthFirstIterator(self, tag)
 * 
 *     def itertext(self, tag=None, *, with_tail=True):             # <<<<<<<<<<<<<<
 *         u"""itertext(self, tag=None, with_tail=True)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_itertext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_itertext[] = "itertext(self, tag=None, with_tail=True)\n\n        Iterates over the text content of a subtree.\n\n        You can pass the ``tag`` keyword argument to restrict text content to\n        a specific tag name.\n\n        You can set the ``with_tail`` keyword argument to ``False`` to skip\n        over tail text.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_itertext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_with_tail = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,&__pyx_kp_with_tail,0};
  __pyx_v_tag = Py_None;
  __pyx_v_with_tail = __pyx_k_69;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "itertext") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
    if (values[1]) {
      __pyx_v_with_tail = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("itertext", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.itertext");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1275
 *         over tail text.
 *         """
 *         return ElementTextIterator(self, tag, with_tail=with_tail)             # <<<<<<<<<<<<<<
 * 
 *     def makeelement(self, _tag, attrib=None, nsmap=None, **_extra):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_tag);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_with_tail, __pyx_v_with_tail) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementTextIterator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.itertext");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1277
 *         return ElementTextIterator(self, tag, with_tail=with_tail)
 * 
 *     def makeelement(self, _tag, attrib=None, nsmap=None, **_extra):             # <<<<<<<<<<<<<<
 *         u"""makeelement(self, _tag, attrib=None, nsmap=None, **_extra)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_makeelement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_makeelement[] = "makeelement(self, _tag, attrib=None, nsmap=None, **_extra)\n\n        Creates a new element associated with the same document.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_makeelement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__tag = 0;
  PyObject *__pyx_v_attrib = 0;
  PyObject *__pyx_v_nsmap = 0;
  PyObject *__pyx_v__extra = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__tag,&__pyx_kp_attrib,&__pyx_kp_nsmap,0};
  __pyx_v_attrib = Py_None;
  __pyx_v_nsmap = Py_None;
  __pyx_v__extra = PyDict_New(); if (unlikely(!__pyx_v__extra)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__tag);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__extra, values, PyTuple_GET_SIZE(__pyx_args), "makeelement") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__tag = values[0];
    if (values[1]) {
      __pyx_v_attrib = values[1];
    }
    if (values[2]) {
      __pyx_v_nsmap = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_nsmap = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_attrib = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v__tag = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("makeelement", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__extra);
  __Pyx_AddTraceback("lxml.etree._Element.makeelement");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1283
 *         """
 *         return _makeElement(_tag, NULL, self._doc, None, None, None,
 *                             attrib, nsmap, _extra)             # <<<<<<<<<<<<<<
 * 
 *     def find(self, path):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__makeElement(__pyx_v__tag, NULL, ((struct LxmlElement *)__pyx_v_self)->_doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None), Py_None, Py_None, __pyx_v_attrib, __pyx_v_nsmap, __pyx_v__extra)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Element.makeelement");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__extra);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1285
 *                             attrib, nsmap, _extra)
 * 
 *     def find(self, path):             # <<<<<<<<<<<<<<
 *         u"""find(self, path)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_find(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_find[] = "find(self, path)\n\n        Finds the first matching subelement, by tag name or path.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_find(PyObject *__pyx_v_self, PyObject *__pyx_v_path) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1290
 *         Finds the first matching subelement, by tag name or path.
 *         """
 *         if isinstance(path, QName):             # <<<<<<<<<<<<<<
 *             path = (<QName>path).text
 *         return _elementpath.find(self, path)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_path, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1291
 *         """
 *         if isinstance(path, QName):
 *             path = (<QName>path).text             # <<<<<<<<<<<<<<
 *         return _elementpath.find(self, path)
 * 
 */
    Py_INCREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text);
    Py_DECREF(__pyx_v_path);
    __pyx_v_path = ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1292
 *         if isinstance(path, QName):
 *             path = (<QName>path).text
 *         return _elementpath.find(self, path)             # <<<<<<<<<<<<<<
 * 
 *     def findtext(self, path, default=None):
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_4lxml_5etree__elementpath, __pyx_kp_find); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_path);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._Element.find");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1294
 *         return _elementpath.find(self, path)
 * 
 *     def findtext(self, path, default=None):             # <<<<<<<<<<<<<<
 *         u"""findtext(self, path, default=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_findtext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_findtext[] = "findtext(self, path, default=None)\n\n        Finds text for the first matching subelement, by tag name or path.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_findtext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_path,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "findtext") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_path = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_path = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("findtext", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Element.findtext");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1299
 *         Finds text for the first matching subelement, by tag name or path.
 *         """
 *         if isinstance(path, QName):             # <<<<<<<<<<<<<<
 *             path = (<QName>path).text
 *         return _elementpath.findtext(self, path, default)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_path, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1300
 *         """
 *         if isinstance(path, QName):
 *             path = (<QName>path).text             # <<<<<<<<<<<<<<
 *         return _elementpath.findtext(self, path, default)
 * 
 */
    Py_INCREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text);
    Py_DECREF(__pyx_v_path);
    __pyx_v_path = ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1301
 *         if isinstance(path, QName):
 *             path = (<QName>path).text
 *         return _elementpath.findtext(self, path, default)             # <<<<<<<<<<<<<<
 * 
 *     def findall(self, path):
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_4lxml_5etree__elementpath, __pyx_kp_findtext); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_path);
  Py_INCREF(__pyx_v_default);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_default);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._Element.findtext");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1303
 *         return _elementpath.findtext(self, path, default)
 * 
 *     def findall(self, path):             # <<<<<<<<<<<<<<
 *         u"""findall(self, path)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_findall(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_findall[] = "findall(self, path)\n\n        Finds all matching subelements, by tag name or path.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_findall(PyObject *__pyx_v_self, PyObject *__pyx_v_path) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1308
 *         Finds all matching subelements, by tag name or path.
 *         """
 *         if isinstance(path, QName):             # <<<<<<<<<<<<<<
 *             path = (<QName>path).text
 *         return _elementpath.findall(self, path)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_path, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1309
 *         """
 *         if isinstance(path, QName):
 *             path = (<QName>path).text             # <<<<<<<<<<<<<<
 *         return _elementpath.findall(self, path)
 * 
 */
    Py_INCREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text);
    Py_DECREF(__pyx_v_path);
    __pyx_v_path = ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1310
 *         if isinstance(path, QName):
 *             path = (<QName>path).text
 *         return _elementpath.findall(self, path)             # <<<<<<<<<<<<<<
 * 
 *     def iterfind(self, path):
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_4lxml_5etree__elementpath, __pyx_kp_findall); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_path);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._Element.findall");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1312
 *         return _elementpath.findall(self, path)
 * 
 *     def iterfind(self, path):             # <<<<<<<<<<<<<<
 *         u"""iterfind(self, path)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterfind(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_iterfind[] = "iterfind(self, path)\n\n        Iterates over all matching subelements, by tag name or path.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_iterfind(PyObject *__pyx_v_self, PyObject *__pyx_v_path) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1317
 *         Iterates over all matching subelements, by tag name or path.
 *         """
 *         if isinstance(path, QName):             # <<<<<<<<<<<<<<
 *             path = (<QName>path).text
 *         return _elementpath.iterfind(self, path)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_path, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1318
 *         """
 *         if isinstance(path, QName):
 *             path = (<QName>path).text             # <<<<<<<<<<<<<<
 *         return _elementpath.iterfind(self, path)
 * 
 */
    Py_INCREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text);
    Py_DECREF(__pyx_v_path);
    __pyx_v_path = ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_path)->text;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1319
 *         if isinstance(path, QName):
 *             path = (<QName>path).text
 *         return _elementpath.iterfind(self, path)             # <<<<<<<<<<<<<<
 * 
 *     def xpath(self, _path, *, namespaces=None, extensions=None,
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_4lxml_5etree__elementpath, __pyx_kp_iterfind); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_path);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._Element.iterfind");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1321
 *         return _elementpath.iterfind(self, path)
 * 
 *     def xpath(self, _path, *, namespaces=None, extensions=None,             # <<<<<<<<<<<<<<
 *               smart_strings=True, **_variables):
 *         u"""xpath(self, _path, namespaces=None, extensions=None, smart_strings=True, **_variables)
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Element_xpath(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8_Element_xpath[] = "xpath(self, _path, namespaces=None, extensions=None, smart_strings=True, **_variables)\n\n        Evaluate an xpath expression using the element as context node.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8_Element_xpath(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__path = 0;
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_smart_strings = 0;
  PyObject *__pyx_v__variables = 0;
  PyObject *__pyx_v_evaluator;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__path,&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_smart_strings,0};
  __pyx_v_namespaces = Py_None;
  __pyx_v_extensions = Py_None;
  __pyx_v_smart_strings = __pyx_k_70;
  __pyx_v__variables = PyDict_New(); if (unlikely(!__pyx_v__variables)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__variables, values, PyTuple_GET_SIZE(__pyx_args), "xpath") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__path = values[0];
    if (values[1]) {
      __pyx_v_namespaces = values[1];
    }
    if (values[2]) {
      __pyx_v_extensions = values[2];
    }
    if (values[3]) {
      __pyx_v_smart_strings = values[3];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__path = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("xpath", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1321; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__variables);
  __Pyx_AddTraceback("lxml.etree._Element.xpath");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_evaluator = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1327
 *         Evaluate an xpath expression using the element as context node.
 *         """
 *         evaluator = XPathElementEvaluator(self, namespaces=namespaces,             # <<<<<<<<<<<<<<
 *                                           extensions=extensions,
 *                                           smart_strings=smart_strings)
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_namespaces, __pyx_v_namespaces) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1328
 *         """
 *         evaluator = XPathElementEvaluator(self, namespaces=namespaces,
 *                                           extensions=extensions,             # <<<<<<<<<<<<<<
 *                                           smart_strings=smart_strings)
 *         return evaluator(_path, **_variables)
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1329
 *         evaluator = XPathElementEvaluator(self, namespaces=namespaces,
 *                                           extensions=extensions,
 *                                           smart_strings=smart_strings)             # <<<<<<<<<<<<<<
 *         return evaluator(_path, **_variables)
 * 
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_smart_strings, __pyx_v_smart_strings) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPathElementEvaluator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_v_evaluator);
  __pyx_v_evaluator = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1330
 *                                           extensions=extensions,
 *                                           smart_strings=smart_strings)
 *         return evaluator(_path, **_variables)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v__path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v__path);
  __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_v_evaluator, ((PyObject *)__pyx_1), __pyx_v__variables); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Element.xpath");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__variables);
  Py_DECREF(__pyx_v_evaluator);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1337
 *     cdef _Element NEW_ELEMENT "PY_NEW" (object t)
 * 
 * cdef _Element _elementFactory(_Document doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     cdef _Element result
 *     result = getProxy(c_node)
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree__elementFactory(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  struct LxmlElement *__pyx_v_result;
  PyObject *__pyx_v_element_class;
  struct LxmlElement *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  __pyx_v_result = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element_class = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1339
 * cdef _Element _elementFactory(_Document doc, xmlNode* c_node):
 *     cdef _Element result
 *     result = getProxy(c_node)             # <<<<<<<<<<<<<<
 *     if result is not None:
 *         return result
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree_getProxy(__pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_result));
  __pyx_v_result = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1340
 *     cdef _Element result
 *     result = getProxy(c_node)
 *     if result is not None:             # <<<<<<<<<<<<<<
 *         return result
 *     if c_node is NULL:
 */
  __pyx_2 = (((PyObject *)__pyx_v_result) != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1341
 *     result = getProxy(c_node)
 *     if result is not None:
 *         return result             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         return None
 */
    Py_INCREF(((PyObject *)__pyx_v_result));
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1342
 *     if result is not None:
 *         return result
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_2 = (__pyx_v_c_node == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1343
 *         return result
 *     if c_node is NULL:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     element_class = LOOKUP_ELEMENT_CLASS(
 */
    Py_INCREF(Py_None);
    __pyx_r = ((struct LxmlElement *)Py_None);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1346
 * 
 *     element_class = LOOKUP_ELEMENT_CLASS(
 *         ELEMENT_CLASS_LOOKUP_STATE, doc, c_node)             # <<<<<<<<<<<<<<
 *     if hasProxy(c_node):
 *         # prevent re-entry race condition - we just called into Python
 */
  __pyx_1 = __pyx_v_4lxml_5etree_LOOKUP_ELEMENT_CLASS(__pyx_v_4lxml_5etree_ELEMENT_CLASS_LOOKUP_STATE, __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_element_class);
  __pyx_v_element_class = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1347
 *     element_class = LOOKUP_ELEMENT_CLASS(
 *         ELEMENT_CLASS_LOOKUP_STATE, doc, c_node)
 *     if hasProxy(c_node):             # <<<<<<<<<<<<<<
 *         # prevent re-entry race condition - we just called into Python
 *         return getProxy(c_node)
 */
  __pyx_3 = __pyx_f_4lxml_5etree_hasProxy(__pyx_v_c_node);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1349
 *     if hasProxy(c_node):
 *         # prevent re-entry race condition - we just called into Python
 *         return getProxy(c_node)             # <<<<<<<<<<<<<<
 *     if element_class is _Element:
 *         # fast path for standard _Element class
 */
    __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree_getProxy(__pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct LxmlElement *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1350
 *         # prevent re-entry race condition - we just called into Python
 *         return getProxy(c_node)
 *     if element_class is _Element:             # <<<<<<<<<<<<<<
 *         # fast path for standard _Element class
 *         result = NEW_ELEMENT(_Element)
 */
  __pyx_2 = (__pyx_v_element_class == ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element)));
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1352
 *     if element_class is _Element:
 *         # fast path for standard _Element class
 *         result = NEW_ELEMENT(_Element)             # <<<<<<<<<<<<<<
 *     else:
 *         result = element_class()
 */
    __pyx_1 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_result));
    __pyx_v_result = ((struct LxmlElement *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1354
 *         result = NEW_ELEMENT(_Element)
 *     else:
 *         result = element_class()             # <<<<<<<<<<<<<<
 *     if hasProxy(c_node):
 *         # prevent re-entry race condition - we just called into Python
 */
    __pyx_1 = PyObject_Call(__pyx_v_element_class, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_result));
    __pyx_v_result = ((struct LxmlElement *)__pyx_1);
    __pyx_1 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1355
 *     else:
 *         result = element_class()
 *     if hasProxy(c_node):             # <<<<<<<<<<<<<<
 *         # prevent re-entry race condition - we just called into Python
 *         result._c_node = NULL
 */
  __pyx_3 = __pyx_f_4lxml_5etree_hasProxy(__pyx_v_c_node);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1357
 *     if hasProxy(c_node):
 *         # prevent re-entry race condition - we just called into Python
 *         result._c_node = NULL             # <<<<<<<<<<<<<<
 *         return getProxy(c_node)
 *     result._doc = doc
 */
    __pyx_v_result->_c_node = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1358
 *         # prevent re-entry race condition - we just called into Python
 *         result._c_node = NULL
 *         return getProxy(c_node)             # <<<<<<<<<<<<<<
 *     result._doc = doc
 *     result._c_node = c_node
 */
    __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree_getProxy(__pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct LxmlElement *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1359
 *         result._c_node = NULL
 *         return getProxy(c_node)
 *     result._doc = doc             # <<<<<<<<<<<<<<
 *     result._c_node = c_node
 *     _registerProxy(result)
 */
  Py_INCREF(((PyObject *)__pyx_v_doc));
  Py_DECREF(((PyObject *)__pyx_v_result->_doc));
  __pyx_v_result->_doc = __pyx_v_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1360
 *         return getProxy(c_node)
 *     result._doc = doc
 *     result._c_node = c_node             # <<<<<<<<<<<<<<
 *     _registerProxy(result)
 * 
 */
  __pyx_v_result->_c_node = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1361
 *     result._doc = doc
 *     result._c_node = c_node
 *     _registerProxy(result)             # <<<<<<<<<<<<<<
 * 
 *     if element_class is not _Element:
 */
  __pyx_3 = __pyx_f_4lxml_5etree__registerProxy(__pyx_v_result); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1363
 *     _registerProxy(result)
 * 
 *     if element_class is not _Element:             # <<<<<<<<<<<<<<
 *         result._init()
 *     return result
 */
  __pyx_2 = (__pyx_v_element_class != ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element)));
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1364
 * 
 *     if element_class is not _Element:
 *         result._init()             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_kp__init); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1365
 *     if element_class is not _Element:
 *         result._init()
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._elementFactory");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_element_class);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1369
 * 
 * cdef class __ContentOnlyElement(_Element):
 *     cdef int _raiseImmutable(self) except -1:             # <<<<<<<<<<<<<<
 *         raise TypeError, u"this element does not have children or attributes"
 * 
 */

static  int __pyx_f_4lxml_5etree_20__ContentOnlyElement__raiseImmutable(struct __pyx_obj_4lxml_5etree___ContentOnlyElement *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1370
 * cdef class __ContentOnlyElement(_Element):
 *     cdef int _raiseImmutable(self) except -1:
 *         raise TypeError, u"this element does not have children or attributes"             # <<<<<<<<<<<<<<
 * 
 *     def set(self, key, value):
 */
  __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_249), 0);
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement._raiseImmutable");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1372
 *         raise TypeError, u"this element does not have children or attributes"
 * 
 *     def set(self, key, value):             # <<<<<<<<<<<<<<
 *         u"set(self, key, value)"
 *         self._raiseImmutable()
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_set[] = "set(self, key, value)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_value,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    __pyx_v_value = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.set");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1374
 *     def set(self, key, value):
 *         u"set(self, key, value)"
 *         self._raiseImmutable()             # <<<<<<<<<<<<<<
 * 
 *     def append(self, value):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement *)((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_vtab)->_raiseImmutable(((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.set");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1376
 *         self._raiseImmutable()
 * 
 *     def append(self, value):             # <<<<<<<<<<<<<<
 *         u"append(self, value)"
 *         self._raiseImmutable()
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_append(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_append[] = "append(self, value)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_append(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1378
 *     def append(self, value):
 *         u"append(self, value)"
 *         self._raiseImmutable()             # <<<<<<<<<<<<<<
 * 
 *     def insert(self, index, value):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement *)((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_vtab)->_raiseImmutable(((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.append");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1380
 *         self._raiseImmutable()
 * 
 *     def insert(self, index, value):             # <<<<<<<<<<<<<<
 *         u"insert(self, index, value)"
 *         self._raiseImmutable()
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_insert[] = "insert(self, index, value)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_index = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_index,&__pyx_kp_value,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_index);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("insert", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "insert") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_index = values[0];
    __pyx_v_value = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_index = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("insert", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.insert");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1382
 *     def insert(self, index, value):
 *         u"insert(self, index, value)"
 *         self._raiseImmutable()             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, index, value):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement *)((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_vtab)->_raiseImmutable(((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.insert");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1384
 *         self._raiseImmutable()
 * 
 *     def __setitem__(self, index, value):             # <<<<<<<<<<<<<<
 *         u"__setitem__(self, index, value)"
 *         self._raiseImmutable()
 */

static int __pyx_pf_4lxml_5etree_20__ContentOnlyElement___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement___setitem__[] = "__setitem__(self, index, value)";
static int __pyx_pf_4lxml_5etree_20__ContentOnlyElement___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1386
 *     def __setitem__(self, index, value):
 *         u"__setitem__(self, index, value)"
 *         self._raiseImmutable()             # <<<<<<<<<<<<<<
 * 
 *     property attrib:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement *)((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_vtab)->_raiseImmutable(((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1389
 * 
 *     property attrib:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return {}
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_6attrib___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_6attrib___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1390
 *     property attrib:
 *         def __get__(self):
 *             return {}             # <<<<<<<<<<<<<<
 * 
 *     property text:
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.attrib.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1393
 * 
 *     property text:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._c_node.content is NULL:
 *                 return ''
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_4text___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_4text___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1394
 *     property text:
 *         def __get__(self):
 *             if self._c_node.content is NULL:             # <<<<<<<<<<<<<<
 *                 return ''
 *             else:
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_base._c_node->content == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1395
 *         def __get__(self):
 *             if self._c_node.content is NULL:
 *                 return ''             # <<<<<<<<<<<<<<
 *             else:
 *                 return funicode(self._c_node.content)
 */
    Py_INCREF(__pyx_kp_250);
    __pyx_r = __pyx_kp_250;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1397
 *                 return ''
 *             else:
 *                 return funicode(self._c_node.content)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_base._c_node->content); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.text.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1399
 *                 return funicode(self._c_node.content)
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             cdef tree.xmlDict* c_dict
 *             cdef char* c_text
 */

static int __pyx_pf_4lxml_5etree_20__ContentOnlyElement_4text___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_20__ContentOnlyElement_4text___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  char *__pyx_v_c_text;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_value);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1402
 *             cdef tree.xmlDict* c_dict
 *             cdef char* c_text
 *             if value is None:             # <<<<<<<<<<<<<<
 *                 c_text = NULL
 *             else:
 */
  __pyx_1 = (__pyx_v_value == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1403
 *             cdef char* c_text
 *             if value is None:
 *                 c_text = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 value = _utf8(value)
 */
    __pyx_v_c_text = NULL;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1405
 *                 c_text = NULL
 *             else:
 *                 value = _utf8(value)             # <<<<<<<<<<<<<<
 *                 c_text = _cstr(value)
 *             tree.xmlNodeSetContent(self._c_node, c_text)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1406
 *             else:
 *                 value = _utf8(value)
 *                 c_text = _cstr(value)             # <<<<<<<<<<<<<<
 *             tree.xmlNodeSetContent(self._c_node, c_text)
 * 
 */
    __pyx_v_c_text = PyString_AS_STRING(__pyx_v_value);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1407
 *                 value = _utf8(value)
 *                 c_text = _cstr(value)
 *             tree.xmlNodeSetContent(self._c_node, c_text)             # <<<<<<<<<<<<<<
 * 
 *     # ACCESSORS
 */
  xmlNodeSetContent(((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)__pyx_v_self)->__pyx_base._c_node, __pyx_v_c_text);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.text.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1410
 * 
 *     # ACCESSORS
 *     def __getitem__(self, x):             # <<<<<<<<<<<<<<
 *         u"__getitem__(self, x)"
 *         if python.PySlice_Check(x):
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement___getitem__[] = "__getitem__(self, x)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1412
 *     def __getitem__(self, x):
 *         u"__getitem__(self, x)"
 *         if python.PySlice_Check(x):             # <<<<<<<<<<<<<<
 *             return []
 *         else:
 */
  __pyx_1 = PySlice_Check(__pyx_v_x);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1413
 *         u"__getitem__(self, x)"
 *         if python.PySlice_Check(x):
 *             return []             # <<<<<<<<<<<<<<
 *         else:
 *             raise IndexError, u"list index out of range"
 */
    __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1415
 *             return []
 *         else:
 *             raise IndexError, u"list index out of range"             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
    __Pyx_Raise(__pyx_builtin_IndexError, ((PyObject *)__pyx_kp_251), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1417
 *             raise IndexError, u"list index out of range"
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         u"__len__(self)"
 *         return 0
 */

static Py_ssize_t __pyx_pf_4lxml_5etree_20__ContentOnlyElement___len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement___len__[] = "__len__(self)";
static Py_ssize_t __pyx_pf_4lxml_5etree_20__ContentOnlyElement___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1419
 *     def __len__(self):
 *         u"__len__(self)"
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1421
 *         return 0
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         u"get(self, key, default=None)"
 *         return None
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_get[] = "get(self, key, default=None)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.get");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1423
 *     def get(self, key, default=None):
 *         u"get(self, key, default=None)"
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1425
 *         return None
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         u"keys(self)"
 *         return []
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_keys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_keys[] = "keys(self)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_keys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1427
 *     def keys(self):
 *         u"keys(self)"
 *         return []             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.keys");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1429
 *         return []
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         u"items(self)"
 *         return []
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_items(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_items[] = "items(self)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_items(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1431
 *     def items(self):
 *         u"items(self)"
 *         return []             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.items");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1433
 *         return []
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         u"values(self)"
 *         return []
 */

static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_values(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_20__ContentOnlyElement_values[] = "values(self)";
static PyObject *__pyx_pf_4lxml_5etree_20__ContentOnlyElement_values(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1435
 *     def values(self):
 *         u"values(self)"
 *         return []             # <<<<<<<<<<<<<<
 * 
 * cdef class _Comment(__ContentOnlyElement):
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.__ContentOnlyElement.values");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1439
 * cdef class _Comment(__ContentOnlyElement):
 *     property tag:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return Comment
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Comment_3tag___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Comment_3tag___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1440
 *     property tag:
 *         def __get__(self):
 *             return Comment             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_Comment); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Comment.tag.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1442
 *             return Comment
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"<!--%s-->" % self.text
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8_Comment___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8_Comment___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1443
 * 
 *     def __repr__(self):
 *         return u"<!--%s-->" % self.text             # <<<<<<<<<<<<<<
 * 
 * cdef class _ProcessingInstruction(__ContentOnlyElement):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_text); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_252), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Comment.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1447
 * cdef class _ProcessingInstruction(__ContentOnlyElement):
 *     property tag:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return ProcessingInstruction
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_22_ProcessingInstruction_3tag___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_22_ProcessingInstruction_3tag___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1448
 *     property tag:
 *         def __get__(self):
 *             return ProcessingInstruction             # <<<<<<<<<<<<<<
 * 
 *     property target:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_79); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ProcessingInstruction.tag.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1452
 *     property target:
 *         # not in ElementTree
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(self._c_node.name)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_22_ProcessingInstruction_6target___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_22_ProcessingInstruction_6target___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1453
 *         # not in ElementTree
 *         def __get__(self):
 *             return funicode(self._c_node.name)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  __pyx_1 = __pyx_f_4lxml_5etree_funicode(((struct __pyx_obj_4lxml_5etree__ProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base._c_node->name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ProcessingInstruction.target.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1455
 *             return funicode(self._c_node.name)
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             value = _utf8(value)
 *             c_text = _cstr(value)
 */

static int __pyx_pf_4lxml_5etree_22_ProcessingInstruction_6target___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_22_ProcessingInstruction_6target___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_c_text;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  char *__pyx_2;
  Py_INCREF(__pyx_v_value);
  __pyx_v_c_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1456
 * 
 *         def __set__(self, value):
 *             value = _utf8(value)             # <<<<<<<<<<<<<<
 *             c_text = _cstr(value)
 *             tree.xmlNodeSetName(self._c_node, c_text)
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_value);
  __pyx_v_value = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1457
 *         def __set__(self, value):
 *             value = _utf8(value)
 *             c_text = _cstr(value)             # <<<<<<<<<<<<<<
 *             tree.xmlNodeSetName(self._c_node, c_text)
 * 
 */
  __pyx_1 = __Pyx_PyBytes_FromString(PyString_AS_STRING(__pyx_v_value)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_c_text);
  __pyx_v_c_text = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1458
 *             value = _utf8(value)
 *             c_text = _cstr(value)
 *             tree.xmlNodeSetName(self._c_node, c_text)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_2 = __Pyx_PyBytes_AsString(__pyx_v_c_text); if (unlikely((!__pyx_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  xmlNodeSetName(((struct __pyx_obj_4lxml_5etree__ProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base._c_node, __pyx_2);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ProcessingInstruction.target.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_c_text);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1460
 *             tree.xmlNodeSetName(self._c_node, c_text)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         text = self.text
 *         if text:
 */

static PyObject *__pyx_pf_4lxml_5etree_22_ProcessingInstruction___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_22_ProcessingInstruction___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_text;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1461
 * 
 *     def __repr__(self):
 *         text = self.text             # <<<<<<<<<<<<<<
 *         if text:
 *             return u"<?%s %s?>" % (self.target, text)
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_text); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_text);
  __pyx_v_text = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1462
 *     def __repr__(self):
 *         text = self.text
 *         if text:             # <<<<<<<<<<<<<<
 *             return u"<?%s %s?>" % (self.target, text)
 *         else:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_text); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1463
 *         text = self.text
 *         if text:
 *             return u"<?%s %s?>" % (self.target, text)             # <<<<<<<<<<<<<<
 *         else:
 *             return u"<?%s?>" % self.target
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_target); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    Py_INCREF(__pyx_v_text);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_text);
    __pyx_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_253), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1465
 *             return u"<?%s %s?>" % (self.target, text)
 *         else:
 *             return u"<?%s?>" % self.target             # <<<<<<<<<<<<<<
 * 
 * cdef class _Entity(__ContentOnlyElement):
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_target); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_254), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ProcessingInstruction.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1469
 * cdef class _Entity(__ContentOnlyElement):
 *     property tag:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return Entity
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Entity_3tag___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Entity_3tag___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1470
 *     property tag:
 *         def __get__(self):
 *             return Entity             # <<<<<<<<<<<<<<
 * 
 *     property name:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_Entity); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Entity.tag.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1474
 *     property name:
 *         # not in ElementTree
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return funicode(self._c_node.name)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Entity_4name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Entity_4name___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1475
 *         # not in ElementTree
 *         def __get__(self):
 *             return funicode(self._c_node.name)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  __pyx_1 = __pyx_f_4lxml_5etree_funicode(((struct __pyx_obj_4lxml_5etree__Entity *)__pyx_v_self)->__pyx_base.__pyx_base._c_node->name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Entity.name.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1477
 *             return funicode(self._c_node.name)
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             value = _utf8(value)
 *             assert u'&' not in value and u';' not in value, \
 */

static int __pyx_pf_4lxml_5etree_7_Entity_4name___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_7_Entity_4name___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_c_text;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  char *__pyx_3;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_value);
  __pyx_v_c_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1478
 * 
 *         def __set__(self, value):
 *             value = _utf8(value)             # <<<<<<<<<<<<<<
 *             assert u'&' not in value and u';' not in value, \
 *                 u"Invalid entity name '%s'" % value
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_value);
  __pyx_v_value = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1479
 *         def __set__(self, value):
 *             value = _utf8(value)
 *             assert u'&' not in value and u';' not in value, \             # <<<<<<<<<<<<<<
 *                 u"Invalid entity name '%s'" % value
 *             c_text = _cstr(value)
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_2 = (!PySequence_Contains(__pyx_v_value, ((PyObject *)__pyx_kp_255))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {
    __pyx_2 = (!PySequence_Contains(__pyx_v_value, ((PyObject *)__pyx_kp_256))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(!__pyx_2)) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1480
 *             value = _utf8(value)
 *             assert u'&' not in value and u';' not in value, \
 *                 u"Invalid entity name '%s'" % value             # <<<<<<<<<<<<<<
 *             c_text = _cstr(value)
 *             tree.xmlNodeSetName(self._c_node, c_text)
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_257), __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1481
 *             assert u'&' not in value and u';' not in value, \
 *                 u"Invalid entity name '%s'" % value
 *             c_text = _cstr(value)             # <<<<<<<<<<<<<<
 *             tree.xmlNodeSetName(self._c_node, c_text)
 * 
 */
  __pyx_1 = __Pyx_PyBytes_FromString(PyString_AS_STRING(__pyx_v_value)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_c_text);
  __pyx_v_c_text = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1482
 *                 u"Invalid entity name '%s'" % value
 *             c_text = _cstr(value)
 *             tree.xmlNodeSetName(self._c_node, c_text)             # <<<<<<<<<<<<<<
 * 
 *     property text:
 */
  __pyx_3 = __Pyx_PyBytes_AsString(__pyx_v_c_text); if (unlikely((!__pyx_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  xmlNodeSetName(((struct __pyx_obj_4lxml_5etree__Entity *)__pyx_v_self)->__pyx_base.__pyx_base._c_node, __pyx_3);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Entity.name.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_c_text);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1487
 *         # FIXME: should this be None or '&[VALUE];' or the resolved
 *         # entity value ?
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return u'&%s;' % funicode(self._c_node.name)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Entity_4text___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Entity_4text___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1488
 *         # entity value ?
 *         def __get__(self):
 *             return u'&%s;' % funicode(self._c_node.name)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree_funicode(((struct __pyx_obj_4lxml_5etree__Entity *)__pyx_v_self)->__pyx_base.__pyx_base._c_node->name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_258), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Entity.text.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1490
 *             return u'&%s;' % funicode(self._c_node.name)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"&%s;" % self.name
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Entity___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Entity___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1491
 * 
 *     def __repr__(self):
 *         return u"&%s;" % self.name             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_259), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Entity.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1503
 *     # to honour tree restructuring.  _doc can happily be None!
 * 
 *     cdef _assertHasRoot(self):             # <<<<<<<<<<<<<<
 *         u"""We have to take care here: the document may not have a root node!
 *         This can happen if ElementTree() is called without any argument and
 */

static  PyObject *__pyx_f_4lxml_5etree_12_ElementTree__assertHasRoot(struct LxmlElementTree *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1509
 *         the caller program.
 *         """
 *         assert self._context_node is not None, \             # <<<<<<<<<<<<<<
 *                u"ElementTree not initialized, missing root"
 * 
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (((PyObject *)__pyx_v_self->_context_node) != Py_None);
  if (unlikely(!__pyx_1)) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1510
 *         """
 *         assert self._context_node is not None, \
 *                u"ElementTree not initialized, missing root"             # <<<<<<<<<<<<<<
 * 
 *     def parse(self, source, _BaseParser parser=None, *, base_url=None):
 */
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_260));
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree._assertHasRoot");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1512
 *                u"ElementTree not initialized, missing root"
 * 
 *     def parse(self, source, _BaseParser parser=None, *, base_url=None):             # <<<<<<<<<<<<<<
 *         u"""parse(self, source, parser=None, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_parse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_parse[] = "parse(self, source, parser=None, base_url=None)\n\n        Updates self with the content of source and returns its root\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_parse(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_source = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_v_base_url = 0;
  struct LxmlDocument *__pyx_v_doc = 0;
  PyObject *__pyx_v_result_container;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_source,&__pyx_kp_parser,&__pyx_kp_base_url,0};
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_source);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_source = values[0];
    if (values[1]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[1]);
    }
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 1));
      case  1: __pyx_v_source = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("parse", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree.parse");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_result_container = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1517
 *         Updates self with the content of source and returns its root
 *         """
 *         cdef _Document doc = None             # <<<<<<<<<<<<<<
 *         try:
 *             doc = _parseDocument(source, parser, base_url)
 */
  Py_INCREF(Py_None);
  __pyx_v_doc = ((struct LxmlDocument *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1518
 *         """
 *         cdef _Document doc = None
 *         try:             # <<<<<<<<<<<<<<
 *             doc = _parseDocument(source, parser, base_url)
 *             self._context_node = doc.getroot()
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1519
 *         cdef _Document doc = None
 *         try:
 *             doc = _parseDocument(source, parser, base_url)             # <<<<<<<<<<<<<<
 *             self._context_node = doc.getroot()
 *             if self._context_node is None:
 */
      __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocument(__pyx_v_source, __pyx_v_parser, __pyx_v_base_url)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1520
 *         try:
 *             doc = _parseDocument(source, parser, base_url)
 *             self._context_node = doc.getroot()             # <<<<<<<<<<<<<<
 *             if self._context_node is None:
 *                 self._doc = doc
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->getroot(__pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1520; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1520; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
      ((struct LxmlElementTree *)__pyx_v_self)->_context_node = ((struct LxmlElement *)__pyx_1);
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1521
 *             doc = _parseDocument(source, parser, base_url)
 *             self._context_node = doc.getroot()
 *             if self._context_node is None:             # <<<<<<<<<<<<<<
 *                 self._doc = doc
 *         except _TargetParserResult, result_container:
 */
      __pyx_2 = (((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node) == Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1522
 *             self._context_node = doc.getroot()
 *             if self._context_node is None:
 *                 self._doc = doc             # <<<<<<<<<<<<<<
 *         except _TargetParserResult, result_container:
 *             # raises a TypeError if we don't get an _Element
 */
        Py_INCREF(((PyObject *)__pyx_v_doc));
        Py_DECREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_doc));
        ((struct LxmlElementTree *)__pyx_v_self)->_doc = __pyx_v_doc;
        goto __pyx_L11;
      }
      __pyx_L11:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1523
 *             if self._context_node is None:
 *                 self._doc = doc
 *         except _TargetParserResult, result_container:             # <<<<<<<<<<<<<<
 *             # raises a TypeError if we don't get an _Element
 *             self._context_node = result_container.result
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
    __pyx_3 = PyErr_ExceptionMatches(__pyx_1);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.parse");
      if (__Pyx_GetException(&__pyx_1, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1523; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_INCREF(__pyx_4);
      Py_DECREF(__pyx_v_result_container);
      __pyx_v_result_container = __pyx_4;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1525
 *         except _TargetParserResult, result_container:
 *             # raises a TypeError if we don't get an _Element
 *             self._context_node = result_container.result             # <<<<<<<<<<<<<<
 *         return self._context_node
 * 
 */
      __pyx_6 = PyObject_GetAttr(__pyx_v_result_container, __pyx_kp_result); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1525; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      if (!(__Pyx_TypeTest(__pyx_6, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1525; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
      ((struct LxmlElementTree *)__pyx_v_self)->_context_node = ((struct LxmlElement *)__pyx_6);
      __pyx_6 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1526
 *             # raises a TypeError if we don't get an _Element
 *             self._context_node = result_container.result
 *         return self._context_node             # <<<<<<<<<<<<<<
 * 
 *     def _setroot(self, _Element root not None):
 */
  Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
  __pyx_r = ((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._ElementTree.parse");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_result_container);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1528
 *         return self._context_node
 * 
 *     def _setroot(self, _Element root not None):             # <<<<<<<<<<<<<<
 *         u"""_setroot(self, root)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree__setroot(PyObject *__pyx_v_self, PyObject *__pyx_v_root); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree__setroot[] = "_setroot(self, root)\n\n        Relocate the ElementTree to a new root node.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree__setroot(PyObject *__pyx_v_self, PyObject *__pyx_v_root) {
  PyObject *__pyx_r;
  int __pyx_1;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root), __pyx_ptype_4lxml_5etree__Element, 0, "root", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1533
 *         Relocate the ElementTree to a new root node.
 *         """
 *         if root._c_node.type != tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *             raise TypeError, u"Only elements can be the root of an ElementTree"
 *         self._context_node = root
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_root)->_c_node->type != XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1534
 *         """
 *         if root._c_node.type != tree.XML_ELEMENT_NODE:
 *             raise TypeError, u"Only elements can be the root of an ElementTree"             # <<<<<<<<<<<<<<
 *         self._context_node = root
 *         self._doc = None
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_261), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1535
 *         if root._c_node.type != tree.XML_ELEMENT_NODE:
 *             raise TypeError, u"Only elements can be the root of an ElementTree"
 *         self._context_node = root             # <<<<<<<<<<<<<<
 *         self._doc = None
 * 
 */
  Py_INCREF(__pyx_v_root);
  Py_DECREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
  ((struct LxmlElementTree *)__pyx_v_self)->_context_node = ((struct LxmlElement *)__pyx_v_root);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1536
 *             raise TypeError, u"Only elements can be the root of an ElementTree"
 *         self._context_node = root
 *         self._doc = None             # <<<<<<<<<<<<<<
 * 
 *     def getroot(self):
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_doc));
  ((struct LxmlElementTree *)__pyx_v_self)->_doc = ((struct LxmlDocument *)Py_None);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree._setroot");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1538
 *         self._doc = None
 * 
 *     def getroot(self):             # <<<<<<<<<<<<<<
 *         u"""getroot(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_getroot(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_getroot[] = "getroot(self)\n\n        Gets the root element for this tree.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_getroot(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1543
 *         Gets the root element for this tree.
 *         """
 *         return self._context_node             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
  __pyx_r = ((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1545
 *         return self._context_node
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return _elementTreeFactory(self._doc, self._context_node)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree___copy__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree___copy__(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1546
 * 
 *     def __copy__(self):
 *         return _elementTreeFactory(self._doc, self._context_node)             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self, memo):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(((struct LxmlElementTree *)__pyx_v_self)->_doc, ((struct LxmlElementTree *)__pyx_v_self)->_context_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ElementTree.__copy__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1548
 *         return _elementTreeFactory(self._doc, self._context_node)
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         cdef _Element root
 *         if self._context_node is not None:
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  struct LxmlElement *__pyx_v_root;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_root = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1550
 *     def __deepcopy__(self, memo):
 *         cdef _Element root
 *         if self._context_node is not None:             # <<<<<<<<<<<<<<
 *             root = self._context_node.__copy__()
 *         return _elementTreeFactory(None, root)
 */
  __pyx_1 = (((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1551
 *         cdef _Element root
 *         if self._context_node is not None:
 *             root = self._context_node.__copy__()             # <<<<<<<<<<<<<<
 *         return _elementTreeFactory(None, root)
 * 
 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node), __pyx_kp___copy__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_root));
    __pyx_v_root = ((struct LxmlElement *)__pyx_3);
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1552
 *         if self._context_node is not None:
 *             root = self._context_node.__copy__()
 *         return _elementTreeFactory(None, root)             # <<<<<<<<<<<<<<
 * 
 *     # not in ElementTree, read-only
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(((struct LxmlDocument *)Py_None), __pyx_v_root)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.__deepcopy__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1560
 *         of a parsed document (e.g.  those returned by the parse functions).
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertHasRoot()
 *             return DocInfo(self._context_node._doc)
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_7docinfo___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_7docinfo___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1561
 *         """
 *         def __get__(self):
 *             self._assertHasRoot()             # <<<<<<<<<<<<<<
 *             return DocInfo(self._context_node._doc)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1562
 *         def __get__(self):
 *             self._assertHasRoot()
 *             return DocInfo(self._context_node._doc)             # <<<<<<<<<<<<<<
 * 
 *     # not in ElementTree, read-only
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc));
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_DocInfo)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ElementTree.docinfo.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1568
 *         u"""The parser that was used to parse the document in this ElementTree.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._context_node is not None and \
 *                    self._context_node._doc is not None:
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_6parser___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_6parser___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1569
 *         """
 *         def __get__(self):
 *             if self._context_node is not None and \             # <<<<<<<<<<<<<<
 *                    self._context_node._doc is not None:
 *                 return self._context_node._doc._parser
 */
  __pyx_1 = (((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1570
 *         def __get__(self):
 *             if self._context_node is not None and \
 *                    self._context_node._doc is not None:             # <<<<<<<<<<<<<<
 *                 return self._context_node._doc._parser
 *             if self._doc is not None:
 */
    __pyx_1 = (((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc) != Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1571
 *             if self._context_node is not None and \
 *                    self._context_node._doc is not None:
 *                 return self._context_node._doc._parser             # <<<<<<<<<<<<<<
 *             if self._doc is not None:
 *                 return self._doc._parser
 */
    Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc->_parser));
    __pyx_r = ((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc->_parser);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1572
 *                    self._context_node._doc is not None:
 *                 return self._context_node._doc._parser
 *             if self._doc is not None:             # <<<<<<<<<<<<<<
 *                 return self._doc._parser
 *             return None
 */
  __pyx_1 = (((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_doc) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1573
 *                 return self._context_node._doc._parser
 *             if self._doc is not None:
 *                 return self._doc._parser             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
    Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_doc->_parser));
    __pyx_r = ((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_doc->_parser);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1574
 *             if self._doc is not None:
 *                 return self._doc._parser
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     def write(self, file, *, encoding=None, method=u"xml",
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1576
 *             return None
 * 
 *     def write(self, file, *, encoding=None, method=u"xml",             # <<<<<<<<<<<<<<
 *               pretty_print=False, xml_declaration=None, with_tail=True):
 *         u"""write(self, file, encoding=None, method="xml",
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_write[] = "write(self, file, encoding=None, method=\"xml\",\n                  pretty_print=False, xml_declaration=None, with_tail=True)\n\n        Write the tree to a file or file-like object.\n\n        Defaults to ASCII encoding and writing a declaration as needed.\n\n        The keyword argument 'method' selects the output method: 'xml' or\n        'html'.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_file = 0;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_v_pretty_print = 0;
  PyObject *__pyx_v_xml_declaration = 0;
  PyObject *__pyx_v_with_tail = 0;
  int __pyx_v_write_declaration;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_file,&__pyx_kp_encoding,&__pyx_kp_method,&__pyx_kp_pretty_print,&__pyx_kp_xml_declaration,&__pyx_kp_with_tail,0};
  __pyx_v_encoding = Py_None;
  __pyx_v_method = ((PyObject *)__pyx_kp_71);
  __pyx_v_pretty_print = __pyx_k_72;
  __pyx_v_xml_declaration = Py_None;
  __pyx_v_with_tail = __pyx_k_73;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[6] = {0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_file);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_file = values[0];
    if (values[1]) {
      __pyx_v_encoding = values[1];
    }
    if (values[2]) {
      __pyx_v_method = values[2];
    }
    if (values[3]) {
      __pyx_v_pretty_print = values[3];
    }
    if (values[4]) {
      __pyx_v_xml_declaration = values[4];
    }
    if (values[5]) {
      __pyx_v_with_tail = values[5];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_file = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree.write");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_encoding);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1589
 *         """
 *         cdef bint write_declaration
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         # suppress decl. in default case (purely for ElementTree compatibility)
 *         if xml_declaration is not None:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1591
 *         self._assertHasRoot()
 *         # suppress decl. in default case (purely for ElementTree compatibility)
 *         if xml_declaration is not None:             # <<<<<<<<<<<<<<
 *             write_declaration = xml_declaration
 *             if encoding is None:
 */
  __pyx_2 = (__pyx_v_xml_declaration != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1592
 *         # suppress decl. in default case (purely for ElementTree compatibility)
 *         if xml_declaration is not None:
 *             write_declaration = xml_declaration             # <<<<<<<<<<<<<<
 *             if encoding is None:
 *                 encoding = u'ASCII'
 */
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_xml_declaration); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_write_declaration = __pyx_2;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1593
 *         if xml_declaration is not None:
 *             write_declaration = xml_declaration
 *             if encoding is None:             # <<<<<<<<<<<<<<
 *                 encoding = u'ASCII'
 *         elif encoding is None:
 */
    __pyx_2 = (__pyx_v_encoding == Py_None);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1594
 *             write_declaration = xml_declaration
 *             if encoding is None:
 *                 encoding = u'ASCII'             # <<<<<<<<<<<<<<
 *         elif encoding is None:
 *             encoding = u'ASCII'
 */
      Py_INCREF(((PyObject *)__pyx_kp_262));
      Py_DECREF(__pyx_v_encoding);
      __pyx_v_encoding = ((PyObject *)__pyx_kp_262);
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1595
 *             if encoding is None:
 *                 encoding = u'ASCII'
 *         elif encoding is None:             # <<<<<<<<<<<<<<
 *             encoding = u'ASCII'
 *             write_declaration = 0
 */
  __pyx_2 = (__pyx_v_encoding == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1596
 *                 encoding = u'ASCII'
 *         elif encoding is None:
 *             encoding = u'ASCII'             # <<<<<<<<<<<<<<
 *             write_declaration = 0
 *         else:
 */
    Py_INCREF(((PyObject *)__pyx_kp_263));
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = ((PyObject *)__pyx_kp_263);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1597
 *         elif encoding is None:
 *             encoding = u'ASCII'
 *             write_declaration = 0             # <<<<<<<<<<<<<<
 *         else:
 *             encoding = encoding.upper()
 */
    __pyx_v_write_declaration = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1599
 *             write_declaration = 0
 *         else:
 *             encoding = encoding.upper()             # <<<<<<<<<<<<<<
 *             write_declaration = encoding not in \
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_encoding, __pyx_kp_upper); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1600
 *         else:
 *             encoding = encoding.upper()
 *             write_declaration = encoding not in \             # <<<<<<<<<<<<<<
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')
 *         _tofilelike(file, self._context_node, encoding, method,
 */
    __pyx_1 = __pyx_v_encoding;
    Py_INCREF(__pyx_1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1601
 *             encoding = encoding.upper()
 *             write_declaration = encoding not in \
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')             # <<<<<<<<<<<<<<
 *         _tofilelike(file, self._context_node, encoding, method,
 *                     write_declaration, 1, pretty_print, with_tail)
 */
    __pyx_3 = PyObject_RichCompare(__pyx_1, ((PyObject *)__pyx_kp_264), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = ((int)__pyx_4);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1600
 *         else:
 *             encoding = encoding.upper()
 *             write_declaration = encoding not in \             # <<<<<<<<<<<<<<
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')
 *         _tofilelike(file, self._context_node, encoding, method,
 */
      __pyx_3 = PyObject_RichCompare(__pyx_1, ((PyObject *)__pyx_kp_265), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_2 = ((int)__pyx_4);
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1601
 *             encoding = encoding.upper()
 *             write_declaration = encoding not in \
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')             # <<<<<<<<<<<<<<
 *         _tofilelike(file, self._context_node, encoding, method,
 *                     write_declaration, 1, pretty_print, with_tail)
 */
      __pyx_3 = PyObject_RichCompare(__pyx_1, ((PyObject *)__pyx_kp_266), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_2 = ((int)__pyx_4);
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1600
 *         else:
 *             encoding = encoding.upper()
 *             write_declaration = encoding not in \             # <<<<<<<<<<<<<<
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')
 *         _tofilelike(file, self._context_node, encoding, method,
 */
      __pyx_3 = PyObject_RichCompare(__pyx_1, ((PyObject *)__pyx_kp_267), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_2 = ((int)__pyx_4);
    }
    __pyx_v_write_declaration = __pyx_2;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1603
 *                                   (u'US-ASCII', u'ASCII', u'UTF8', u'UTF-8')
 *         _tofilelike(file, self._context_node, encoding, method,
 *                     write_declaration, 1, pretty_print, with_tail)             # <<<<<<<<<<<<<<
 * 
 *     def getpath(self, _Element element not None):
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_pretty_print); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __pyx_f_4lxml_5etree__tofilelike(__pyx_v_file, ((struct LxmlElementTree *)__pyx_v_self)->_context_node, __pyx_v_encoding, __pyx_v_method, __pyx_v_write_declaration, 1, __pyx_4, __pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.write");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1605
 *                     write_declaration, 1, pretty_print, with_tail)
 * 
 *     def getpath(self, _Element element not None):             # <<<<<<<<<<<<<<
 *         u"""getpath(self, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_getpath(PyObject *__pyx_v_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_getpath[] = "getpath(self, element)\n\n        Returns a structural, absolute XPath expression to find that element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_getpath(PyObject *__pyx_v_self, PyObject *__pyx_v_element) {
  struct LxmlDocument *__pyx_v_doc;
  xmlDoc *__pyx_v_c_doc;
  char *__pyx_v_c_path;
  PyObject *__pyx_v_path;
  PyObject *__pyx_r;
  int __pyx_1;
  xmlDoc *__pyx_2;
  PyObject *__pyx_3 = 0;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_path = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1613
 *         cdef xmlDoc* c_doc
 *         cdef char* c_path
 *         doc = self._context_node._doc             # <<<<<<<<<<<<<<
 *         if element._doc is not doc:
 *             raise ValueError, u"Element is not in this tree."
 */
  Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc));
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlElementTree *)__pyx_v_self)->_context_node->_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1614
 *         cdef char* c_path
 *         doc = self._context_node._doc
 *         if element._doc is not doc:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Element is not in this tree."
 *         c_doc = _fakeRootDoc(doc._c_doc, self._context_node._c_node)
 */
  __pyx_1 = (((struct LxmlElement *)__pyx_v_element)->_doc != __pyx_v_doc);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1615
 *         doc = self._context_node._doc
 *         if element._doc is not doc:
 *             raise ValueError, u"Element is not in this tree."             # <<<<<<<<<<<<<<
 *         c_doc = _fakeRootDoc(doc._c_doc, self._context_node._c_node)
 *         c_path = tree.xmlGetNodePath(element._c_node)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_268), 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1616
 *         if element._doc is not doc:
 *             raise ValueError, u"Element is not in this tree."
 *         c_doc = _fakeRootDoc(doc._c_doc, self._context_node._c_node)             # <<<<<<<<<<<<<<
 *         c_path = tree.xmlGetNodePath(element._c_node)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, ((struct LxmlElementTree *)__pyx_v_self)->_context_node->_c_node); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1617
 *             raise ValueError, u"Element is not in this tree."
 *         c_doc = _fakeRootDoc(doc._c_doc, self._context_node._c_node)
 *         c_path = tree.xmlGetNodePath(element._c_node)             # <<<<<<<<<<<<<<
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 *         if c_path is NULL:
 */
  __pyx_v_c_path = xmlGetNodePath(((struct LxmlElement *)__pyx_v_element)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1618
 *         c_doc = _fakeRootDoc(doc._c_doc, self._context_node._c_node)
 *         c_path = tree.xmlGetNodePath(element._c_node)
 *         _destroyFakeDoc(doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 *         if c_path is NULL:
 *             python.PyErr_NoMemory()
 */
  __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1619
 *         c_path = tree.xmlGetNodePath(element._c_node)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 *         if c_path is NULL:             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 *         path = funicode(c_path)
 */
  __pyx_1 = (__pyx_v_c_path == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1620
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 *         if c_path is NULL:
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         path = funicode(c_path)
 *         tree.xmlFree(c_path)
 */
    __pyx_3 = PyErr_NoMemory(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1621
 *         if c_path is NULL:
 *             python.PyErr_NoMemory()
 *         path = funicode(c_path)             # <<<<<<<<<<<<<<
 *         tree.xmlFree(c_path)
 *         return path
 */
  __pyx_3 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_path); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_path);
  __pyx_v_path = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1622
 *             python.PyErr_NoMemory()
 *         path = funicode(c_path)
 *         tree.xmlFree(c_path)             # <<<<<<<<<<<<<<
 *         return path
 * 
 */
  xmlFree(__pyx_v_c_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1623
 *         path = funicode(c_path)
 *         tree.xmlFree(c_path)
 *         return path             # <<<<<<<<<<<<<<
 * 
 *     def getiterator(self, tag=None):
 */
  Py_INCREF(__pyx_v_path);
  __pyx_r = __pyx_v_path;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.getpath");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1625
 *         return path
 * 
 *     def getiterator(self, tag=None):             # <<<<<<<<<<<<<<
 *         u"""getiterator(self, tag=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_getiterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_getiterator[] = "getiterator(self, tag=None)\n\n        Returns a sequence or iterator of all elements in document order\n        (depth first pre-order), starting with the root element.\n\n        Can be restricted to find only elements with a specific tag\n        (pass ``tag=\"xyz\"`` or ``tag=\"{ns}xyz\"``) or from a namespace\n        (pass ``tag=\"{ns}*\"``).\n\n        You can also pass the Element, Comment, ProcessingInstruction and\n        Entity factory functions to look only for the specific element type.\n\n        :deprecated: Note that this method is deprecated as of\n          ElementTree 1.3 and lxml 2.0.  It returns an iterator in\n          lxml, which diverges from the original ElementTree\n          behaviour.  If you want an efficient iterator, use the\n          ``tree.iter()`` method instead.  You should only use this\n          method in new code if you require backwards compatibility\n          with older versions of lxml or ElementTree.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_getiterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_root;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "getiterator") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getiterator", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree.getiterator");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_root = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1646
 *           with older versions of lxml or ElementTree.
 *         """
 *         root = self.getroot()             # <<<<<<<<<<<<<<
 *         if root is None:
 *             return ()
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_getroot); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1647
 *         """
 *         root = self.getroot()
 *         if root is None:             # <<<<<<<<<<<<<<
 *             return ()
 *         return root.getiterator(tag)
 */
  __pyx_3 = (__pyx_v_root == Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1648
 *         root = self.getroot()
 *         if root is None:
 *             return ()             # <<<<<<<<<<<<<<
 *         return root.getiterator(tag)
 * 
 */
    Py_INCREF(((PyObject *)__pyx_empty_tuple));
    __pyx_r = ((PyObject *)__pyx_empty_tuple);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1649
 *         if root is None:
 *             return ()
 *         return root.getiterator(tag)             # <<<<<<<<<<<<<<
 * 
 *     def iter(self, tag=None):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_root, __pyx_kp_getiterator); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_tag);
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ElementTree.getiterator");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1651
 *         return root.getiterator(tag)
 * 
 *     def iter(self, tag=None):             # <<<<<<<<<<<<<<
 *         u"""iter(self, tag=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_iter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_iter[] = "iter(self, tag=None)\n\n        Creates an iterator for the root element.  The iterator loops over\n        all elements in this tree, in document order.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_iter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_root;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "iter") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree.iter");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_root = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1657
 *         all elements in this tree, in document order.
 *         """
 *         root = self.getroot()             # <<<<<<<<<<<<<<
 *         if root is None:
 *             return ()
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_getroot); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1658
 *         """
 *         root = self.getroot()
 *         if root is None:             # <<<<<<<<<<<<<<
 *             return ()
 *         return root.iter(tag)
 */
  __pyx_3 = (__pyx_v_root == Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1659
 *         root = self.getroot()
 *         if root is None:
 *             return ()             # <<<<<<<<<<<<<<
 *         return root.iter(tag)
 * 
 */
    Py_INCREF(((PyObject *)__pyx_empty_tuple));
    __pyx_r = ((PyObject *)__pyx_empty_tuple);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1660
 *         if root is None:
 *             return ()
 *         return root.iter(tag)             # <<<<<<<<<<<<<<
 * 
 *     def find(self, path):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_root, __pyx_kp_iter); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_tag);
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ElementTree.iter");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1662
 *         return root.iter(tag)
 * 
 *     def find(self, path):             # <<<<<<<<<<<<<<
 *         u"""find(self, path)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_find(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_find[] = "find(self, path)\n\n        Finds the first toplevel element with given tag.  Same as\n        ``tree.getroot().find(path)``.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_find(PyObject *__pyx_v_self, PyObject *__pyx_v_path) {
  PyObject *__pyx_v_root;
  PyObject *__pyx_v_start;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_path);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);
  __pyx_v_start = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1668
 *         ``tree.getroot().find(path)``.
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         root = self.getroot()
 *         if _isString(path):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1669
 *         """
 *         self._assertHasRoot()
 *         root = self.getroot()             # <<<<<<<<<<<<<<
 *         if _isString(path):
 *             start = path[:1]
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_getroot); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1670
 *         self._assertHasRoot()
 *         root = self.getroot()
 *         if _isString(path):             # <<<<<<<<<<<<<<
 *             start = path[:1]
 *             if start == u"/":
 */
  __pyx_3 = _isString(__pyx_v_path);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1671
 *         root = self.getroot()
 *         if _isString(path):
 *             start = path[:1]             # <<<<<<<<<<<<<<
 *             if start == u"/":
 *                 path = u"." + path
 */
    __pyx_1 = PySequence_GetSlice(__pyx_v_path, 0, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_start);
    __pyx_v_start = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1672
 *         if _isString(path):
 *             start = path[:1]
 *             if start == u"/":             # <<<<<<<<<<<<<<
 *                 path = u"." + path
 *             elif start == "/":
 */
    __pyx_2 = PyObject_RichCompare(__pyx_v_start, ((PyObject *)__pyx_kp_269), Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1673
 *             start = path[:1]
 *             if start == u"/":
 *                 path = u"." + path             # <<<<<<<<<<<<<<
 *             elif start == "/":
 *                 path = "." + path
 */
      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_270), __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1674
 *             if start == u"/":
 *                 path = u"." + path
 *             elif start == "/":             # <<<<<<<<<<<<<<
 *                 path = "." + path
 *         return root.find(path)
 */
    __pyx_1 = PyObject_RichCompare(__pyx_v_start, __pyx_kp_271, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1675
 *                 path = u"." + path
 *             elif start == "/":
 *                 path = "." + path             # <<<<<<<<<<<<<<
 *         return root.find(path)
 * 
 */
      __pyx_t_1 = PyNumber_Add(__pyx_kp_272, __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1676
 *             elif start == "/":
 *                 path = "." + path
 *         return root.find(path)             # <<<<<<<<<<<<<<
 * 
 *     def findtext(self, path, default=None):
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_root, __pyx_kp_find); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_path);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ElementTree.find");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_start);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1678
 *         return root.find(path)
 * 
 *     def findtext(self, path, default=None):             # <<<<<<<<<<<<<<
 *         u"""findtext(self, path, default=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_findtext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_findtext[] = "findtext(self, path, default=None)\n\n        Finds the text for the first element matching the ElementPath\n        expression.  Same as getroot().findtext(path)\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_findtext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_v_root;
  PyObject *__pyx_v_start;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_path,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "findtext") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_path = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_path = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("findtext", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ElementTree.findtext");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_path);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);
  __pyx_v_start = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1684
 *         expression.  Same as getroot().findtext(path)
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         root = self.getroot()
 *         if _isString(path):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1685
 *         """
 *         self._assertHasRoot()
 *         root = self.getroot()             # <<<<<<<<<<<<<<
 *         if _isString(path):
 *             start = path[:1]
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_getroot); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1686
 *         self._assertHasRoot()
 *         root = self.getroot()
 *         if _isString(path):             # <<<<<<<<<<<<<<
 *             start = path[:1]
 *             if start == u"/":
 */
  __pyx_3 = _isString(__pyx_v_path);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1687
 *         root = self.getroot()
 *         if _isString(path):
 *             start = path[:1]             # <<<<<<<<<<<<<<
 *             if start == u"/":
 *                 path = u"." + path
 */
    __pyx_1 = PySequence_GetSlice(__pyx_v_path, 0, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_start);
    __pyx_v_start = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1688
 *         if _isString(path):
 *             start = path[:1]
 *             if start == u"/":             # <<<<<<<<<<<<<<
 *                 path = u"." + path
 *             elif start == "/":
 */
    __pyx_2 = PyObject_RichCompare(__pyx_v_start, ((PyObject *)__pyx_kp_273), Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1689
 *             start = path[:1]
 *             if start == u"/":
 *                 path = u"." + path             # <<<<<<<<<<<<<<
 *             elif start == "/":
 *                 path = "." + path
 */
      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_274), __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L7;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1690
 *             if start == u"/":
 *                 path = u"." + path
 *             elif start == "/":             # <<<<<<<<<<<<<<
 *                 path = "." + path
 *         return root.findtext(path, default)
 */
    __pyx_1 = PyObject_RichCompare(__pyx_v_start, __pyx_kp_275, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1691
 *                 path = u"." + path
 *             elif start == "/":
 *                 path = "." + path             # <<<<<<<<<<<<<<
 *         return root.findtext(path, default)
 * 
 */
      __pyx_t_1 = PyNumber_Add(__pyx_kp_276, __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1692
 *             elif start == "/":
 *                 path = "." + path
 *         return root.findtext(path, default)             # <<<<<<<<<<<<<<
 * 
 *     def findall(self, path):
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_root, __pyx_kp_findtext); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_path);
  Py_INCREF(__pyx_v_default);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_default);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ElementTree.findtext");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_start);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1694
 *         return root.findtext(path, default)
 * 
 *     def findall(self, path):             # <<<<<<<<<<<<<<
 *         u"""findall(self, path)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_findall(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_findall[] = "findall(self, path)\n\n        Finds all elements matching the ElementPath expression.  Same as\n        getroot().findall(path).\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_findall(PyObject *__pyx_v_self, PyObject *__pyx_v_path) {
  PyObject *__pyx_v_root;
  PyObject *__pyx_v_start;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_path);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);
  __pyx_v_start = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1700
 *         getroot().findall(path).
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         root = self.getroot()
 *         if _isString(path):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1701
 *         """
 *         self._assertHasRoot()
 *         root = self.getroot()             # <<<<<<<<<<<<<<
 *         if _isString(path):
 *             start = path[:1]
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_getroot); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1702
 *         self._assertHasRoot()
 *         root = self.getroot()
 *         if _isString(path):             # <<<<<<<<<<<<<<
 *             start = path[:1]
 *             if start == u"/":
 */
  __pyx_3 = _isString(__pyx_v_path);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1703
 *         root = self.getroot()
 *         if _isString(path):
 *             start = path[:1]             # <<<<<<<<<<<<<<
 *             if start == u"/":
 *                 path = u"." + path
 */
    __pyx_1 = PySequence_GetSlice(__pyx_v_path, 0, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_start);
    __pyx_v_start = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1704
 *         if _isString(path):
 *             start = path[:1]
 *             if start == u"/":             # <<<<<<<<<<<<<<
 *                 path = u"." + path
 *             elif start == "/":
 */
    __pyx_2 = PyObject_RichCompare(__pyx_v_start, ((PyObject *)__pyx_kp_277), Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1705
 *             start = path[:1]
 *             if start == u"/":
 *                 path = u"." + path             # <<<<<<<<<<<<<<
 *             elif start == "/":
 *                 path = "." + path
 */
      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_278), __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1706
 *             if start == u"/":
 *                 path = u"." + path
 *             elif start == "/":             # <<<<<<<<<<<<<<
 *                 path = "." + path
 *         return root.findall(path)
 */
    __pyx_1 = PyObject_RichCompare(__pyx_v_start, __pyx_kp_279, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1707
 *                 path = u"." + path
 *             elif start == "/":
 *                 path = "." + path             # <<<<<<<<<<<<<<
 *         return root.findall(path)
 * 
 */
      __pyx_t_1 = PyNumber_Add(__pyx_kp_280, __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1708
 *             elif start == "/":
 *                 path = "." + path
 *         return root.findall(path)             # <<<<<<<<<<<<<<
 * 
 *     def iterfind(self, path):
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_root, __pyx_kp_findall); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_path);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ElementTree.findall");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_start);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1710
 *         return root.findall(path)
 * 
 *     def iterfind(self, path):             # <<<<<<<<<<<<<<
 *         u"""iterfind(self, path)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_iterfind(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_iterfind[] = "iterfind(self, path)\n\n        Iterates over all elements matching the ElementPath expression.\n        Same as getroot().finditer(path).\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_iterfind(PyObject *__pyx_v_self, PyObject *__pyx_v_path) {
  PyObject *__pyx_v_root;
  PyObject *__pyx_v_start;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_path);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);
  __pyx_v_start = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1716
 *         Same as getroot().finditer(path).
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         root = self.getroot()
 *         if _isString(path):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1717
 *         """
 *         self._assertHasRoot()
 *         root = self.getroot()             # <<<<<<<<<<<<<<
 *         if _isString(path):
 *             start = path[:1]
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_getroot); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1718
 *         self._assertHasRoot()
 *         root = self.getroot()
 *         if _isString(path):             # <<<<<<<<<<<<<<
 *             start = path[:1]
 *             if start == u"/":
 */
  __pyx_3 = _isString(__pyx_v_path);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1719
 *         root = self.getroot()
 *         if _isString(path):
 *             start = path[:1]             # <<<<<<<<<<<<<<
 *             if start == u"/":
 *                 path = u"." + path
 */
    __pyx_1 = PySequence_GetSlice(__pyx_v_path, 0, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_start);
    __pyx_v_start = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1720
 *         if _isString(path):
 *             start = path[:1]
 *             if start == u"/":             # <<<<<<<<<<<<<<
 *                 path = u"." + path
 *             elif start == "/":
 */
    __pyx_2 = PyObject_RichCompare(__pyx_v_start, ((PyObject *)__pyx_kp_281), Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1721
 *             start = path[:1]
 *             if start == u"/":
 *                 path = u"." + path             # <<<<<<<<<<<<<<
 *             elif start == "/":
 *                 path = "." + path
 */
      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_282), __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1722
 *             if start == u"/":
 *                 path = u"." + path
 *             elif start == "/":             # <<<<<<<<<<<<<<
 *                 path = "." + path
 *         return root.iterfind(path)
 */
    __pyx_1 = PyObject_RichCompare(__pyx_v_start, __pyx_kp_283, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1723
 *                 path = u"." + path
 *             elif start == "/":
 *                 path = "." + path             # <<<<<<<<<<<<<<
 *         return root.iterfind(path)
 * 
 */
      __pyx_t_1 = PyNumber_Add(__pyx_kp_284, __pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1724
 *             elif start == "/":
 *                 path = "." + path
 *         return root.iterfind(path)             # <<<<<<<<<<<<<<
 * 
 *     def xpath(self, _path, *, namespaces=None, extensions=None,
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_root, __pyx_kp_iterfind); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_path);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ElementTree.iterfind");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_start);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1726
 *         return root.iterfind(path)
 * 
 *     def xpath(self, _path, *, namespaces=None, extensions=None,             # <<<<<<<<<<<<<<
 *               smart_strings=True, **_variables):
 *         u"""xpath(self, _path, namespaces=None, extensions=None, smart_strings=True, **_variables)
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xpath(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_xpath[] = "xpath(self, _path, namespaces=None, extensions=None, smart_strings=True, **_variables)\n\n        XPath evaluate in context of document.\n\n        ``namespaces`` is an optional dictionary with prefix to namespace URI\n        mappings, used by XPath.  ``extensions`` defines additional extension\n        functions.\n        \n        Returns a list (nodeset), or bool, float or string.\n\n        In case of a list result, return Element for element nodes,\n        string for text and attribute values.\n\n        Note: if you are going to apply multiple XPath expressions\n        against the same document, it is more efficient to use\n        XPathEvaluator directly.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xpath(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__path = 0;
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_smart_strings = 0;
  PyObject *__pyx_v__variables = 0;
  PyObject *__pyx_v_evaluator;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__path,&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_smart_strings,0};
  __pyx_v_namespaces = Py_None;
  __pyx_v_extensions = Py_None;
  __pyx_v_smart_strings = __pyx_k_74;
  __pyx_v__variables = PyDict_New(); if (unlikely(!__pyx_v__variables)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__variables, values, PyTuple_GET_SIZE(__pyx_args), "xpath") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__path = values[0];
    if (values[1]) {
      __pyx_v_namespaces = values[1];
    }
    if (values[2]) {
      __pyx_v_extensions = values[2];
    }
    if (values[3]) {
      __pyx_v_smart_strings = values[3];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__path = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("xpath", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__variables);
  __Pyx_AddTraceback("lxml.etree._ElementTree.xpath");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_evaluator = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1745
 *         XPathEvaluator directly.
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         evaluator = XPathDocumentEvaluator(self, namespaces=namespaces,
 *                                            extensions=extensions,
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1746
 *         """
 *         self._assertHasRoot()
 *         evaluator = XPathDocumentEvaluator(self, namespaces=namespaces,             # <<<<<<<<<<<<<<
 *                                            extensions=extensions,
 *                                            smart_strings=smart_strings)
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_namespaces, __pyx_v_namespaces) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1747
 *         self._assertHasRoot()
 *         evaluator = XPathDocumentEvaluator(self, namespaces=namespaces,
 *                                            extensions=extensions,             # <<<<<<<<<<<<<<
 *                                            smart_strings=smart_strings)
 *         return evaluator(_path, **_variables)
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1748
 *         evaluator = XPathDocumentEvaluator(self, namespaces=namespaces,
 *                                            extensions=extensions,
 *                                            smart_strings=smart_strings)             # <<<<<<<<<<<<<<
 *         return evaluator(_path, **_variables)
 * 
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_smart_strings, __pyx_v_smart_strings) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPathDocumentEvaluator)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_v_evaluator);
  __pyx_v_evaluator = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1749
 *                                            extensions=extensions,
 *                                            smart_strings=smart_strings)
 *         return evaluator(_path, **_variables)             # <<<<<<<<<<<<<<
 * 
 *     def xslt(self, _xslt, extensions=None, access_control=None, **_kw):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v__path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v__path);
  __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_v_evaluator, ((PyObject *)__pyx_1), __pyx_v__variables); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.xpath");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__variables);
  Py_DECREF(__pyx_v_evaluator);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1751
 *         return evaluator(_path, **_variables)
 * 
 *     def xslt(self, _xslt, extensions=None, access_control=None, **_kw):             # <<<<<<<<<<<<<<
 *         u"""xslt(self, _xslt, extensions=None, access_control=None, **_kw)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xslt(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_xslt[] = "xslt(self, _xslt, extensions=None, access_control=None, **_kw)\n\n        Transform this document using other document.\n\n        xslt is a tree that should be XSLT\n        keyword parameters are XSLT transformation parameters.\n\n        Returns the transformed tree.\n\n        Note: if you are going to apply the same XSLT stylesheet against\n        multiple documents, it is more efficient to use the XSLT\n        class directly.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xslt(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__xslt = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_access_control = 0;
  PyObject *__pyx_v__kw = 0;
  PyObject *__pyx_v_style;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__xslt,&__pyx_kp_extensions,&__pyx_kp_access_control,0};
  __pyx_v_extensions = Py_None;
  __pyx_v_access_control = Py_None;
  __pyx_v__kw = PyDict_New(); if (unlikely(!__pyx_v__kw)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__xslt);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__kw, values, PyTuple_GET_SIZE(__pyx_args), "xslt") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__xslt = values[0];
    if (values[1]) {
      __pyx_v_extensions = values[1];
    }
    if (values[2]) {
      __pyx_v_access_control = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_access_control = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_extensions = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v__xslt = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("xslt", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__kw);
  __Pyx_AddTraceback("lxml.etree._ElementTree.xslt");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_style = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1765
 *         class directly.
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         style = XSLT(_xslt, extensions=extensions,
 *                      access_control=access_control)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1766
 *         """
 *         self._assertHasRoot()
 *         style = XSLT(_xslt, extensions=extensions,             # <<<<<<<<<<<<<<
 *                      access_control=access_control)
 *         return style(self, **_kw)
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v__xslt);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v__xslt);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1767
 *         self._assertHasRoot()
 *         style = XSLT(_xslt, extensions=extensions,
 *                      access_control=access_control)             # <<<<<<<<<<<<<<
 *         return style(self, **_kw)
 * 
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_access_control, __pyx_v_access_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XSLT)), ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_v_style);
  __pyx_v_style = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1768
 *         style = XSLT(_xslt, extensions=extensions,
 *                      access_control=access_control)
 *         return style(self, **_kw)             # <<<<<<<<<<<<<<
 * 
 *     def relaxng(self, relaxng):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_v_style, ((PyObject *)__pyx_1), __pyx_v__kw); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.xslt");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__kw);
  Py_DECREF(__pyx_v_style);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1770
 *         return style(self, **_kw)
 * 
 *     def relaxng(self, relaxng):             # <<<<<<<<<<<<<<
 *         u"""relaxng(self, relaxng)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_relaxng(PyObject *__pyx_v_self, PyObject *__pyx_v_relaxng); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_relaxng[] = "relaxng(self, relaxng)\n\n        Validate this document using other document.\n\n        The relaxng argument is a tree that should contain a Relax NG schema.\n\n        Returns True or False, depending on whether validation\n        succeeded.\n\n        Note: if you are going to apply the same Relax NG schema against\n        multiple documents, it is more efficient to use the RelaxNG\n        class directly.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_relaxng(PyObject *__pyx_v_self, PyObject *__pyx_v_relaxng) {
  PyObject *__pyx_v_schema;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_schema = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1784
 *         class directly.
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         schema = RelaxNG(relaxng)
 *         return schema.validate(self)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1785
 *         """
 *         self._assertHasRoot()
 *         schema = RelaxNG(relaxng)             # <<<<<<<<<<<<<<
 *         return schema.validate(self)
 * 
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_relaxng);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_relaxng);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_RelaxNG)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_v_schema);
  __pyx_v_schema = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1786
 *         self._assertHasRoot()
 *         schema = RelaxNG(relaxng)
 *         return schema.validate(self)             # <<<<<<<<<<<<<<
 * 
 *     def xmlschema(self, xmlschema):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_schema, __pyx_kp_validate); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.relaxng");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_schema);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1788
 *         return schema.validate(self)
 * 
 *     def xmlschema(self, xmlschema):             # <<<<<<<<<<<<<<
 *         u"""xmlschema(self, xmlschema)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xmlschema(PyObject *__pyx_v_self, PyObject *__pyx_v_xmlschema); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_xmlschema[] = "xmlschema(self, xmlschema)\n\n        Validate this document using other document.\n\n        The xmlschema argument is a tree that should contain an XML Schema.\n\n        Returns True or False, depending on whether validation\n        succeeded.\n\n        Note: If you are going to apply the same XML Schema against\n        multiple documents, it is more efficient to use the XMLSchema\n        class directly.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xmlschema(PyObject *__pyx_v_self, PyObject *__pyx_v_xmlschema) {
  PyObject *__pyx_v_schema;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_schema = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1802
 *         class directly.
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         schema = XMLSchema(xmlschema)
 *         return schema.validate(self)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1803
 *         """
 *         self._assertHasRoot()
 *         schema = XMLSchema(xmlschema)             # <<<<<<<<<<<<<<
 *         return schema.validate(self)
 * 
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_xmlschema);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_xmlschema);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XMLSchema)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_v_schema);
  __pyx_v_schema = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1804
 *         self._assertHasRoot()
 *         schema = XMLSchema(xmlschema)
 *         return schema.validate(self)             # <<<<<<<<<<<<<<
 * 
 *     def xinclude(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_schema, __pyx_kp_validate); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.xmlschema");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_schema);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1806
 *         return schema.validate(self)
 * 
 *     def xinclude(self):             # <<<<<<<<<<<<<<
 *         u"""xinclude(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xinclude(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_xinclude[] = "xinclude(self)\n\n        Process the XInclude nodes in this document and include the\n        referenced XML fragments.\n\n        There is support for loading files through the file system, HTTP and\n        FTP.\n\n        Note that XInclude does not support custom resolvers in Python space\n        due to restrictions of libxml2 <= 2.6.29.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_xinclude(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1819
 *         """
 *         cdef int result
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         XInclude()(self._context_node)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1820
 *         cdef int result
 *         self._assertHasRoot()
 *         XInclude()(self._context_node)             # <<<<<<<<<<<<<<
 * 
 *     def write_c14n(self, file):
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XInclude)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct LxmlElementTree *)__pyx_v_self)->_context_node));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ElementTree.xinclude");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1822
 *         XInclude()(self._context_node)
 * 
 *     def write_c14n(self, file):             # <<<<<<<<<<<<<<
 *         u"""write_c14n(self, file)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_write_c14n(PyObject *__pyx_v_self, PyObject *__pyx_v_file); /*proto*/
static char __pyx_doc_4lxml_5etree_12_ElementTree_write_c14n[] = "write_c14n(self, file)\n\n        C14N write of document. Always writes UTF-8.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_12_ElementTree_write_c14n(PyObject *__pyx_v_self, PyObject *__pyx_v_file) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1827
 *         C14N write of document. Always writes UTF-8.
 *         """
 *         self._assertHasRoot()             # <<<<<<<<<<<<<<
 *         _tofilelikeC14N(file, self._context_node)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTree *)((struct LxmlElementTree *)__pyx_v_self)->__pyx_vtab)->_assertHasRoot(((struct LxmlElementTree *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1828
 *         """
 *         self._assertHasRoot()
 *         _tofilelikeC14N(file, self._context_node)             # <<<<<<<<<<<<<<
 * 
 * cdef _ElementTree _elementTreeFactory(_Document doc, _Element context_node):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__tofilelikeC14N(__pyx_v_file, ((struct LxmlElementTree *)__pyx_v_self)->_context_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ElementTree.write_c14n");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1830
 *         _tofilelikeC14N(file, self._context_node)
 * 
 * cdef _ElementTree _elementTreeFactory(_Document doc, _Element context_node):             # <<<<<<<<<<<<<<
 *     return _newElementTree(doc, context_node, _ElementTree)
 * 
 */

static  struct LxmlElementTree *__pyx_f_4lxml_5etree__elementTreeFactory(struct LxmlDocument *__pyx_v_doc, struct LxmlElement *__pyx_v_context_node) {
  struct LxmlElementTree *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1831
 * 
 * cdef _ElementTree _elementTreeFactory(_Document doc, _Element context_node):
 *     return _newElementTree(doc, context_node, _ElementTree)             # <<<<<<<<<<<<<<
 * 
 * cdef _ElementTree _newElementTree(_Document doc, _Element context_node,
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__newElementTree(__pyx_v_doc, __pyx_v_context_node, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElementTree *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElementTree *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._elementTreeFactory");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1833
 *     return _newElementTree(doc, context_node, _ElementTree)
 * 
 * cdef _ElementTree _newElementTree(_Document doc, _Element context_node,             # <<<<<<<<<<<<<<
 *                                   object baseclass):
 *     cdef _ElementTree result
 */

static  struct LxmlElementTree *__pyx_f_4lxml_5etree__newElementTree(struct LxmlDocument *__pyx_v_doc, struct LxmlElement *__pyx_v_context_node, PyObject *__pyx_v_baseclass) {
  struct LxmlElementTree *__pyx_v_result;
  struct LxmlElementTree *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF(__pyx_v_context_node);
  __pyx_v_result = ((struct LxmlElementTree *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1836
 *                                   object baseclass):
 *     cdef _ElementTree result
 *     result = baseclass()             # <<<<<<<<<<<<<<
 *     if context_node is None and doc is not None:
 *         context_node = doc.getroot()
 */
  __pyx_1 = PyObject_Call(__pyx_v_baseclass, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ElementTree))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_result));
  __pyx_v_result = ((struct LxmlElementTree *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1837
 *     cdef _ElementTree result
 *     result = baseclass()
 *     if context_node is None and doc is not None:             # <<<<<<<<<<<<<<
 *         context_node = doc.getroot()
 *     if context_node is None:
 */
  __pyx_2 = (((PyObject *)__pyx_v_context_node) == Py_None);
  if (__pyx_2) {
    __pyx_2 = (((PyObject *)__pyx_v_doc) != Py_None);
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1838
 *     result = baseclass()
 *     if context_node is None and doc is not None:
 *         context_node = doc.getroot()             # <<<<<<<<<<<<<<
 *     if context_node is None:
 *         result._doc = doc
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->getroot(__pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_context_node));
    __pyx_v_context_node = ((struct LxmlElement *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1839
 *     if context_node is None and doc is not None:
 *         context_node = doc.getroot()
 *     if context_node is None:             # <<<<<<<<<<<<<<
 *         result._doc = doc
 *     result._context_node = context_node
 */
  __pyx_2 = (((PyObject *)__pyx_v_context_node) == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1840
 *         context_node = doc.getroot()
 *     if context_node is None:
 *         result._doc = doc             # <<<<<<<<<<<<<<
 *     result._context_node = context_node
 *     return result
 */
    Py_INCREF(((PyObject *)__pyx_v_doc));
    Py_DECREF(((PyObject *)__pyx_v_result->_doc));
    __pyx_v_result->_doc = __pyx_v_doc;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1841
 *     if context_node is None:
 *         result._doc = doc
 *     result._context_node = context_node             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_context_node));
  Py_DECREF(((PyObject *)__pyx_v_result->_context_node));
  __pyx_v_result->_context_node = __pyx_v_context_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1842
 *         result._doc = doc
 *     result._context_node = context_node
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElementTree *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._newElementTree");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_context_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1849
 *     """
 *     cdef _Element _element
 *     def __init__(self, _Element element not None):             # <<<<<<<<<<<<<<
 *         self._element = element
 * 
 */

static int __pyx_pf_4lxml_5etree_7_Attrib___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_7_Attrib___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_element = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element = ((struct LxmlElement *)values[0]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Attrib.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1850
 *     cdef _Element _element
 *     def __init__(self, _Element element not None):
 *         self._element = element             # <<<<<<<<<<<<<<
 * 
 *     # MANIPULATORS
 */
  Py_INCREF(((PyObject *)__pyx_v_element));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element));
  ((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element = __pyx_v_element;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Attrib.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1853
 * 
 *     # MANIPULATORS
 *     def __setitem__(self, key, value):             # <<<<<<<<<<<<<<
 *         _setAttributeValue(self._element, key, value)
 * 
 */

static int __pyx_pf_4lxml_5etree_7_Attrib___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_7_Attrib___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1854
 *     # MANIPULATORS
 *     def __setitem__(self, key, value):
 *         _setAttributeValue(self._element, key, value)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, key):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__setAttributeValue(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key, __pyx_v_value); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Attrib.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1856
 *         _setAttributeValue(self._element, key, value)
 * 
 *     def __delitem__(self, key):             # <<<<<<<<<<<<<<
 *         _delAttribute(self._element, key)
 * 
 */

static int __pyx_pf_4lxml_5etree_7_Attrib___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pf_4lxml_5etree_7_Attrib___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1857
 * 
 *     def __delitem__(self, key):
 *         _delAttribute(self._element, key)             # <<<<<<<<<<<<<<
 * 
 *     def update(self, sequence_or_dict):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__delAttribute(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._Attrib.__delitem__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1859
 *         _delAttribute(self._element, key)
 * 
 *     def update(self, sequence_or_dict):             # <<<<<<<<<<<<<<
 *         if isinstance(sequence_or_dict, dict):
 *             sequence_or_dict = sequence_or_dict.items()
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_update(PyObject *__pyx_v_self, PyObject *__pyx_v_sequence_or_dict); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_update(PyObject *__pyx_v_self, PyObject *__pyx_v_sequence_or_dict) {
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  Py_INCREF(__pyx_v_sequence_or_dict);
  __pyx_v_key = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1860
 * 
 *     def update(self, sequence_or_dict):
 *         if isinstance(sequence_or_dict, dict):             # <<<<<<<<<<<<<<
 *             sequence_or_dict = sequence_or_dict.items()
 *         for key, value in sequence_or_dict:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_sequence_or_dict, ((PyTypeObject *)((PyObject*)&PyDict_Type))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1861
 *     def update(self, sequence_or_dict):
 *         if isinstance(sequence_or_dict, dict):
 *             sequence_or_dict = sequence_or_dict.items()             # <<<<<<<<<<<<<<
 *         for key, value in sequence_or_dict:
 *             _setAttributeValue(self._element, key, value)
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_sequence_or_dict, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_sequence_or_dict);
    __pyx_v_sequence_or_dict = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1862
 *         if isinstance(sequence_or_dict, dict):
 *             sequence_or_dict = sequence_or_dict.items()
 *         for key, value in sequence_or_dict:             # <<<<<<<<<<<<<<
 *             _setAttributeValue(self._element, key, value)
 * 
 */
  if (PyList_CheckExact(__pyx_v_sequence_or_dict) || PyTuple_CheckExact(__pyx_v_sequence_or_dict)) {
    __pyx_4 = 0; __pyx_2 = __pyx_v_sequence_or_dict; Py_INCREF(__pyx_2);
  } else {
    __pyx_4 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_sequence_or_dict); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_4 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_6);
      Py_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_6);
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_6;
      __pyx_6 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_5 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_key);
      __pyx_v_key = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_6;
      __pyx_6 = 0;
      if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1863
 *             sequence_or_dict = sequence_or_dict.items()
 *         for key, value in sequence_or_dict:
 *             _setAttributeValue(self._element, key, value)             # <<<<<<<<<<<<<<
 * 
 *     def pop(self, key, *default):
 */
    __pyx_7 = __pyx_f_4lxml_5etree__setAttributeValue(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key, __pyx_v_value); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._Attrib.update");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_sequence_or_dict);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1865
 *             _setAttributeValue(self._element, key, value)
 * 
 *     def pop(self, key, *default):             # <<<<<<<<<<<<<<
 *         if python.PyTuple_GET_SIZE(default) > 1:
 *             raise TypeError, u"pop expected at most 2 arguments, got %d" % (
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_pop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,0};
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_default = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_default)) return NULL;
  } else {
    __pyx_v_default = __pyx_empty_tuple; Py_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "pop") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1865; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pop", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1865; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v_default);
  __Pyx_AddTraceback("lxml.etree._Attrib.pop");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1866
 * 
 *     def pop(self, key, *default):
 *         if python.PyTuple_GET_SIZE(default) > 1:             # <<<<<<<<<<<<<<
 *             raise TypeError, u"pop expected at most 2 arguments, got %d" % (
 *                 python.PyTuple_GET_SIZE(default)+1)
 */
  __pyx_1 = (PyTuple_GET_SIZE(__pyx_v_default) > 1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1868
 *         if python.PyTuple_GET_SIZE(default) > 1:
 *             raise TypeError, u"pop expected at most 2 arguments, got %d" % (
 *                 python.PyTuple_GET_SIZE(default)+1)             # <<<<<<<<<<<<<<
 *         result = _getAttributeValue(self._element, key, None)
 *         if result is None:
 */
    __pyx_2 = PyInt_FromSsize_t((PyTuple_GET_SIZE(__pyx_v_default) + 1)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_285), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1869
 *             raise TypeError, u"pop expected at most 2 arguments, got %d" % (
 *                 python.PyTuple_GET_SIZE(default)+1)
 *         result = _getAttributeValue(self._element, key, None)             # <<<<<<<<<<<<<<
 *         if result is None:
 *             if python.PyTuple_GET_SIZE(default) == 0:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__getAttributeValue(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key, Py_None); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1870
 *                 python.PyTuple_GET_SIZE(default)+1)
 *         result = _getAttributeValue(self._element, key, None)
 *         if result is None:             # <<<<<<<<<<<<<<
 *             if python.PyTuple_GET_SIZE(default) == 0:
 *                 raise KeyError, key
 */
  __pyx_1 = (__pyx_v_result == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1871
 *         result = _getAttributeValue(self._element, key, None)
 *         if result is None:
 *             if python.PyTuple_GET_SIZE(default) == 0:             # <<<<<<<<<<<<<<
 *                 raise KeyError, key
 *             else:
 */
    __pyx_1 = (PyTuple_GET_SIZE(__pyx_v_default) == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1872
 *         if result is None:
 *             if python.PyTuple_GET_SIZE(default) == 0:
 *                 raise KeyError, key             # <<<<<<<<<<<<<<
 *             else:
 *                 result = python.PyTuple_GET_ITEM(default, 0)
 */
      __Pyx_Raise(__pyx_builtin_KeyError, __pyx_v_key, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1874
 *                 raise KeyError, key
 *             else:
 *                 result = python.PyTuple_GET_ITEM(default, 0)             # <<<<<<<<<<<<<<
 *                 python.Py_INCREF(result)
 *         else:
 */
      __pyx_2 = PyTuple_GET_ITEM(__pyx_v_default, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1875
 *             else:
 *                 result = python.PyTuple_GET_ITEM(default, 0)
 *                 python.Py_INCREF(result)             # <<<<<<<<<<<<<<
 *         else:
 *             _delAttribute(self._element, key)
 */
      Py_INCREF(__pyx_v_result);
    }
    __pyx_L8:;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1877
 *                 python.Py_INCREF(result)
 *         else:
 *             _delAttribute(self._element, key)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_3 = __pyx_f_4lxml_5etree__delAttribute(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1878
 *         else:
 *             _delAttribute(self._element, key)
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.pop");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_default);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1880
 *         return result
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         c_node = self._element._c_node
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_clear(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_clear(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1882
 *     def clear(self):
 *         cdef xmlNode* c_node
 *         c_node = self._element._c_node             # <<<<<<<<<<<<<<
 *         while c_node.properties is not NULL:
 *             tree.xmlRemoveProp(c_node.properties)
 */
  __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1883
 *         cdef xmlNode* c_node
 *         c_node = self._element._c_node
 *         while c_node.properties is not NULL:             # <<<<<<<<<<<<<<
 *             tree.xmlRemoveProp(c_node.properties)
 * 
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node->properties != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1884
 *         c_node = self._element._c_node
 *         while c_node.properties is not NULL:
 *             tree.xmlRemoveProp(c_node.properties)             # <<<<<<<<<<<<<<
 * 
 *     # ACCESSORS
 */
    xmlRemoveProp(__pyx_v_c_node->properties);
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1887
 * 
 *     # ACCESSORS
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(dict( _attributeIteratorFactory(self._element, 3) ))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1888
 *     # ACCESSORS
 *     def __repr__(self):
 *         return repr(dict( _attributeIteratorFactory(self._element, 3) ))             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, key):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__attributeIteratorFactory(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, 3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_2 = PyObject_Repr(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1890
 *         return repr(dict( _attributeIteratorFactory(self._element, 3) ))
 * 
 *     def __getitem__(self, key):             # <<<<<<<<<<<<<<
 *         result = _getAttributeValue(self._element, key, None)
 *         if result is None:
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1891
 * 
 *     def __getitem__(self, key):
 *         result = _getAttributeValue(self._element, key, None)             # <<<<<<<<<<<<<<
 *         if result is None:
 *             raise KeyError, key
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getAttributeValue(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key, Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1892
 *     def __getitem__(self, key):
 *         result = _getAttributeValue(self._element, key, None)
 *         if result is None:             # <<<<<<<<<<<<<<
 *             raise KeyError, key
 *         else:
 */
  __pyx_2 = (__pyx_v_result == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1893
 *         result = _getAttributeValue(self._element, key, None)
 *         if result is None:
 *             raise KeyError, key             # <<<<<<<<<<<<<<
 *         else:
 *             return result
 */
    __Pyx_Raise(__pyx_builtin_KeyError, __pyx_v_key, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1895
 *             raise KeyError, key
 *         else:
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
    Py_INCREF(__pyx_v_result);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Attrib.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1897
 *             return result
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlAttr* c_attr
 *         c_attr = self._element._c_node.properties
 */

static int __pyx_pf_4lxml_5etree_7_Attrib___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lxml_5etree_7_Attrib___nonzero__(PyObject *__pyx_v_self) {
  xmlAttr *__pyx_v_c_attr;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1899
 *     def __nonzero__(self):
 *         cdef xmlAttr* c_attr
 *         c_attr = self._element._c_node.properties             # <<<<<<<<<<<<<<
 *         while c_attr is not NULL:
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 */
  __pyx_v_c_attr = ((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node->properties;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1900
 *         cdef xmlAttr* c_attr
 *         c_attr = self._element._c_node.properties
 *         while c_attr is not NULL:             # <<<<<<<<<<<<<<
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *                 return 1
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1901
 *         c_attr = self._element._c_node.properties
 *         while c_attr is not NULL:
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *                 return 1
 *             c_attr = c_attr.next
 */
    __pyx_1 = (__pyx_v_c_attr->type == XML_ATTRIBUTE_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1902
 *         while c_attr is not NULL:
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *                 return 1             # <<<<<<<<<<<<<<
 *             c_attr = c_attr.next
 *         return 0
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1903
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *                 return 1
 *             c_attr = c_attr.next             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    __pyx_v_c_attr = __pyx_v_c_attr->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1904
 *                 return 1
 *             c_attr = c_attr.next
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1906
 *         return 0
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlAttr* c_attr
 *         cdef Py_ssize_t c
 */

static Py_ssize_t __pyx_pf_4lxml_5etree_7_Attrib___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_4lxml_5etree_7_Attrib___len__(PyObject *__pyx_v_self) {
  xmlAttr *__pyx_v_c_attr;
  Py_ssize_t __pyx_v_c;
  Py_ssize_t __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1909
 *         cdef xmlAttr* c_attr
 *         cdef Py_ssize_t c
 *         c = 0             # <<<<<<<<<<<<<<
 *         c_attr = self._element._c_node.properties
 *         while c_attr is not NULL:
 */
  __pyx_v_c = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1910
 *         cdef Py_ssize_t c
 *         c = 0
 *         c_attr = self._element._c_node.properties             # <<<<<<<<<<<<<<
 *         while c_attr is not NULL:
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 */
  __pyx_v_c_attr = ((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node->properties;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1911
 *         c = 0
 *         c_attr = self._element._c_node.properties
 *         while c_attr is not NULL:             # <<<<<<<<<<<<<<
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *                 c = c + 1
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1912
 *         c_attr = self._element._c_node.properties
 *         while c_attr is not NULL:
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *                 c = c + 1
 *             c_attr = c_attr.next
 */
    __pyx_1 = (__pyx_v_c_attr->type == XML_ATTRIBUTE_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1913
 *         while c_attr is not NULL:
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *                 c = c + 1             # <<<<<<<<<<<<<<
 *             c_attr = c_attr.next
 *         return c
 */
      __pyx_v_c = (__pyx_v_c + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1914
 *             if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *                 c = c + 1
 *             c_attr = c_attr.next             # <<<<<<<<<<<<<<
 *         return c
 * 
 */
    __pyx_v_c_attr = __pyx_v_c_attr->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1915
 *                 c = c + 1
 *             c_attr = c_attr.next
 *         return c             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
  __pyx_r = __pyx_v_c;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1917
 *         return c
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         return _getAttributeValue(self._element, key, default)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._Attrib.get");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1918
 * 
 *     def get(self, key, default=None):
 *         return _getAttributeValue(self._element, key, default)             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getAttributeValue(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element, __pyx_v_key, __pyx_v_default); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Attrib.get");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1920
 *         return _getAttributeValue(self._element, key, default)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         return _collectAttributes(self._element._c_node, 1)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_keys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_keys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1921
 * 
 *     def keys(self):
 *         return _collectAttributes(self._element._c_node, 1)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Attrib.keys");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1923
 *         return _collectAttributes(self._element._c_node, 1)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(_collectAttributes(self._element._c_node, 1))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1924
 * 
 *     def __iter__(self):
 *         return iter(_collectAttributes(self._element._c_node, 1))             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1926
 *         return iter(_collectAttributes(self._element._c_node, 1))
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         return iter(_collectAttributes(self._element._c_node, 1))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_iterkeys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_iterkeys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1927
 * 
 *     def iterkeys(self):
 *         return iter(_collectAttributes(self._element._c_node, 1))             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.iterkeys");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1929
 *         return iter(_collectAttributes(self._element._c_node, 1))
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         return _collectAttributes(self._element._c_node, 2)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_values(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_values(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1930
 * 
 *     def values(self):
 *         return _collectAttributes(self._element._c_node, 2)             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Attrib.values");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1932
 *         return _collectAttributes(self._element._c_node, 2)
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         return iter(_collectAttributes(self._element._c_node, 2))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_itervalues(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_itervalues(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1933
 * 
 *     def itervalues(self):
 *         return iter(_collectAttributes(self._element._c_node, 2))             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.itervalues");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1935
 *         return iter(_collectAttributes(self._element._c_node, 2))
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         return _collectAttributes(self._element._c_node, 3)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_items(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_items(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1936
 * 
 *     def items(self):
 *         return _collectAttributes(self._element._c_node, 3)             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Attrib.items");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1938
 *         return _collectAttributes(self._element._c_node, 3)
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         return iter(_collectAttributes(self._element._c_node, 3))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_iteritems(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_iteritems(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1939
 * 
 *     def iteritems(self):
 *         return iter(_collectAttributes(self._element._c_node, 3))             # <<<<<<<<<<<<<<
 * 
 *     def has_key(self, key):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node, 3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.iteritems");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1941
 *         return iter(_collectAttributes(self._element._c_node, 3))
 * 
 *     def has_key(self, key):             # <<<<<<<<<<<<<<
 *         if key in self:
 *             return True
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_has_key(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib_has_key(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1942
 * 
 *     def has_key(self, key):
 *         if key in self:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_1 = (PySequence_Contains(__pyx_v_self, __pyx_v_key)); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1943
 *     def has_key(self, key):
 *         if key in self:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1945
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, key):
 */
    __pyx_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Attrib.has_key");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1947
 *             return False
 * 
 *     def __contains__(self, key):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         cdef char* c_result
 */

static int __pyx_pf_4lxml_5etree_7_Attrib___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static int __pyx_pf_4lxml_5etree_7_Attrib___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  xmlNode *__pyx_v_c_node;
  char *__pyx_v_c_result;
  char *__pyx_v_c_tag;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_tag;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1951
 *         cdef char* c_result
 *         cdef char* c_tag
 *         ns, tag = _getNsTag(key)             # <<<<<<<<<<<<<<
 *         c_tag = _cstr(tag)
 *         c_node = self._element._c_node
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_key); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1952
 *         cdef char* c_tag
 *         ns, tag = _getNsTag(key)
 *         c_tag = _cstr(tag)             # <<<<<<<<<<<<<<
 *         c_node = self._element._c_node
 *         if ns is None:
 */
  __pyx_v_c_tag = PyString_AS_STRING(__pyx_v_tag);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1953
 *         ns, tag = _getNsTag(key)
 *         c_tag = _cstr(tag)
 *         c_node = self._element._c_node             # <<<<<<<<<<<<<<
 *         if ns is None:
 *             c_result = tree.xmlGetNoNsProp(c_node, c_tag)
 */
  __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree__Attrib *)__pyx_v_self)->_element->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1954
 *         c_tag = _cstr(tag)
 *         c_node = self._element._c_node
 *         if ns is None:             # <<<<<<<<<<<<<<
 *             c_result = tree.xmlGetNoNsProp(c_node, c_tag)
 *         else:
 */
  __pyx_4 = (__pyx_v_ns == Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1955
 *         c_node = self._element._c_node
 *         if ns is None:
 *             c_result = tree.xmlGetNoNsProp(c_node, c_tag)             # <<<<<<<<<<<<<<
 *         else:
 *             c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))
 */
    __pyx_v_c_result = xmlGetNoNsProp(__pyx_v_c_node, __pyx_v_c_tag);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1957
 *             c_result = tree.xmlGetNoNsProp(c_node, c_tag)
 *         else:
 *             c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))             # <<<<<<<<<<<<<<
 *         if c_result is NULL:
 *             return 0
 */
    __pyx_v_c_result = xmlGetNsProp(__pyx_v_c_node, __pyx_v_c_tag, PyString_AS_STRING(__pyx_v_ns));
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1958
 *         else:
 *             c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))
 *         if c_result is NULL:             # <<<<<<<<<<<<<<
 *             return 0
 *         else:
 */
  __pyx_4 = (__pyx_v_c_result == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1959
 *             c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))
 *         if c_result is NULL:
 *             return 0             # <<<<<<<<<<<<<<
 *         else:
 *             tree.xmlFree(c_result)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1961
 *             return 0
 *         else:
 *             tree.xmlFree(c_result)             # <<<<<<<<<<<<<<
 *             return 1
 * 
 */
    xmlFree(__pyx_v_c_result);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1962
 *         else:
 *             tree.xmlFree(c_result)
 *             return 1             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(one, other, int op):
 */
    __pyx_r = 1;
    goto __pyx_L0;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Attrib.__contains__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_tag);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1964
 *             return 1
 * 
 *     def __richcmp__(one, other, int op):             # <<<<<<<<<<<<<<
 *         if not python.PyDict_Check(one):
 *             one = dict(one)
 */

static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___richcmp__(PyObject *__pyx_v_one, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_Attrib___richcmp__(PyObject *__pyx_v_one, PyObject *__pyx_v_other, int __pyx_v_op) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_one);
  Py_INCREF(__pyx_v_other);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1965
 * 
 *     def __richcmp__(one, other, int op):
 *         if not python.PyDict_Check(one):             # <<<<<<<<<<<<<<
 *             one = dict(one)
 *         if not python.PyDict_Check(other):
 */
  __pyx_1 = (!PyDict_Check(__pyx_v_one));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1966
 *     def __richcmp__(one, other, int op):
 *         if not python.PyDict_Check(one):
 *             one = dict(one)             # <<<<<<<<<<<<<<
 *         if not python.PyDict_Check(other):
 *             other = dict(other)
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_one);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_one);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_one);
    __pyx_v_one = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1967
 *         if not python.PyDict_Check(one):
 *             one = dict(one)
 *         if not python.PyDict_Check(other):             # <<<<<<<<<<<<<<
 *             other = dict(other)
 *         return python.PyObject_RichCompare(one, other, op)
 */
  __pyx_1 = (!PyDict_Check(__pyx_v_other));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1968
 *             one = dict(one)
 *         if not python.PyDict_Check(other):
 *             other = dict(other)             # <<<<<<<<<<<<<<
 *         return python.PyObject_RichCompare(one, other, op)
 * 
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_other);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_other);
    __pyx_v_other = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1969
 *         if not python.PyDict_Check(other):
 *             other = dict(other)
 *         return python.PyObject_RichCompare(one, other, op)             # <<<<<<<<<<<<<<
 * 
 * cdef class _AttribIterator:
 */
  __pyx_2 = PyObject_RichCompare(__pyx_v_one, __pyx_v_other, __pyx_v_op); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._Attrib.__richcmp__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_one);
  Py_DECREF(__pyx_v_other);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1978
 *     cdef xmlAttr* _c_attr
 *     cdef int _keysvalues # 1 - keys, 2 - values, 3 - items (key, value)
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_15_AttribIterator___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_15_AttribIterator___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1979
 *     cdef int _keysvalues # 1 - keys, 2 - values, 3 - items (key, value)
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1981
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlAttr* c_attr
 *         if self._node is None:
 */

static PyObject *__pyx_pf_4lxml_5etree_15_AttribIterator___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_15_AttribIterator___next__(PyObject *__pyx_v_self) {
  xmlAttr *__pyx_v_c_attr;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1983
 *     def __next__(self):
 *         cdef xmlAttr* c_attr
 *         if self._node is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         c_attr = self._c_attr
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_node) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1984
 *         cdef xmlAttr* c_attr
 *         if self._node is None:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         c_attr = self._c_attr
 *         while c_attr is not NULL and c_attr.type != tree.XML_ATTRIBUTE_NODE:
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1985
 *         if self._node is None:
 *             raise StopIteration
 *         c_attr = self._c_attr             # <<<<<<<<<<<<<<
 *         while c_attr is not NULL and c_attr.type != tree.XML_ATTRIBUTE_NODE:
 *             c_attr = c_attr.next
 */
  __pyx_v_c_attr = ((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_c_attr;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1986
 *             raise StopIteration
 *         c_attr = self._c_attr
 *         while c_attr is not NULL and c_attr.type != tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *             c_attr = c_attr.next
 *         if c_attr is NULL:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c_attr->type != XML_ATTRIBUTE_NODE);
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1987
 *         c_attr = self._c_attr
 *         while c_attr is not NULL and c_attr.type != tree.XML_ATTRIBUTE_NODE:
 *             c_attr = c_attr.next             # <<<<<<<<<<<<<<
 *         if c_attr is NULL:
 *             self._node = None
 */
    __pyx_v_c_attr = __pyx_v_c_attr->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1988
 *         while c_attr is not NULL and c_attr.type != tree.XML_ATTRIBUTE_NODE:
 *             c_attr = c_attr.next
 *         if c_attr is NULL:             # <<<<<<<<<<<<<<
 *             self._node = None
 *             raise StopIteration
 */
  __pyx_1 = (__pyx_v_c_attr == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1989
 *             c_attr = c_attr.next
 *         if c_attr is NULL:
 *             self._node = None             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
    Py_INCREF(Py_None);
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_node));
    ((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_node = ((struct LxmlElement *)Py_None);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1990
 *         if c_attr is NULL:
 *             self._node = None
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         self._c_attr = c_attr.next
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1992
 *             raise StopIteration
 * 
 *         self._c_attr = c_attr.next             # <<<<<<<<<<<<<<
 *         if self._keysvalues == 1:
 *             return _namespacedName(<xmlNode*>c_attr)
 */
  ((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_c_attr = __pyx_v_c_attr->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1993
 * 
 *         self._c_attr = c_attr.next
 *         if self._keysvalues == 1:             # <<<<<<<<<<<<<<
 *             return _namespacedName(<xmlNode*>c_attr)
 *         elif self._keysvalues == 2:
 */
  switch (((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_keysvalues) {
    case 1:

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1994
 *         self._c_attr = c_attr.next
 *         if self._keysvalues == 1:
 *             return _namespacedName(<xmlNode*>c_attr)             # <<<<<<<<<<<<<<
 *         elif self._keysvalues == 2:
 *             return _attributeValue(self._node._c_node, c_attr)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__namespacedName(((xmlNode *)__pyx_v_c_attr)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    break;
    case 2:

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1996
 *             return _namespacedName(<xmlNode*>c_attr)
 *         elif self._keysvalues == 2:
 *             return _attributeValue(self._node._c_node, c_attr)             # <<<<<<<<<<<<<<
 *         else:
 *             return (_namespacedName(<xmlNode*>c_attr),
 */
    __pyx_2 = __pyx_f_4lxml_5etree__attributeValue(((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_node->_c_node, __pyx_v_c_attr); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    break;
    default:

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1998
 *             return _attributeValue(self._node._c_node, c_attr)
 *         else:
 *             return (_namespacedName(<xmlNode*>c_attr),             # <<<<<<<<<<<<<<
 *                     _attributeValue(self._node._c_node, c_attr))
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree__namespacedName(((xmlNode *)__pyx_v_c_attr)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1999
 *         else:
 *             return (_namespacedName(<xmlNode*>c_attr),
 *                     _attributeValue(self._node._c_node, c_attr))             # <<<<<<<<<<<<<<
 * 
 * cdef object _attributeIteratorFactory(_Element element, int keysvalues):
 */
    __pyx_3 = __pyx_f_4lxml_5etree__attributeValue(((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_v_self)->_node->_c_node, __pyx_v_c_attr); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_r = ((PyObject *)__pyx_4);
    __pyx_4 = 0;
    goto __pyx_L0;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._AttribIterator.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2001
 *                     _attributeValue(self._node._c_node, c_attr))
 * 
 * cdef object _attributeIteratorFactory(_Element element, int keysvalues):             # <<<<<<<<<<<<<<
 *     cdef _AttribIterator attribs
 *     if element._c_node.properties is NULL:
 */

static  PyObject *__pyx_f_4lxml_5etree__attributeIteratorFactory(struct LxmlElement *__pyx_v_element, int __pyx_v_keysvalues) {
  struct __pyx_obj_4lxml_5etree__AttribIterator *__pyx_v_attribs;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_attribs = ((struct __pyx_obj_4lxml_5etree__AttribIterator *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2003
 * cdef object _attributeIteratorFactory(_Element element, int keysvalues):
 *     cdef _AttribIterator attribs
 *     if element._c_node.properties is NULL:             # <<<<<<<<<<<<<<
 *         return ITER_EMPTY
 *     attribs = _AttribIterator()
 */
  __pyx_1 = (__pyx_v_element->_c_node->properties == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2004
 *     cdef _AttribIterator attribs
 *     if element._c_node.properties is NULL:
 *         return ITER_EMPTY             # <<<<<<<<<<<<<<
 *     attribs = _AttribIterator()
 *     attribs._node = element
 */
    Py_INCREF(__pyx_v_4lxml_5etree_ITER_EMPTY);
    __pyx_r = __pyx_v_4lxml_5etree_ITER_EMPTY;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2005
 *     if element._c_node.properties is NULL:
 *         return ITER_EMPTY
 *     attribs = _AttribIterator()             # <<<<<<<<<<<<<<
 *     attribs._node = element
 *     attribs._c_attr = element._c_node.properties
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__AttribIterator)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__AttribIterator))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_attribs));
  __pyx_v_attribs = ((struct __pyx_obj_4lxml_5etree__AttribIterator *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2006
 *         return ITER_EMPTY
 *     attribs = _AttribIterator()
 *     attribs._node = element             # <<<<<<<<<<<<<<
 *     attribs._c_attr = element._c_node.properties
 *     attribs._keysvalues = keysvalues
 */
  Py_INCREF(((PyObject *)__pyx_v_element));
  Py_DECREF(((PyObject *)__pyx_v_attribs->_node));
  __pyx_v_attribs->_node = __pyx_v_element;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2007
 *     attribs = _AttribIterator()
 *     attribs._node = element
 *     attribs._c_attr = element._c_node.properties             # <<<<<<<<<<<<<<
 *     attribs._keysvalues = keysvalues
 *     return attribs
 */
  __pyx_v_attribs->_c_attr = __pyx_v_element->_c_node->properties;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2008
 *     attribs._node = element
 *     attribs._c_attr = element._c_node.properties
 *     attribs._keysvalues = keysvalues             # <<<<<<<<<<<<<<
 *     return attribs
 * 
 */
  __pyx_v_attribs->_keysvalues = __pyx_v_keysvalues;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2009
 *     attribs._c_attr = element._c_node.properties
 *     attribs._keysvalues = keysvalues
 *     return attribs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_attribs));
  __pyx_r = ((PyObject *)__pyx_v_attribs);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._attributeIteratorFactory");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_attribs);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2018
 *     cdef char* _href
 *     cdef char* _name
 *     cdef _initTagMatch(self, tag):             # <<<<<<<<<<<<<<
 *         self._href = NULL
 *         self._name = NULL
 */

static  PyObject *__pyx_f_4lxml_5etree_18_ElementTagMatcher__initTagMatch(struct LxmlElementTagMatcher *__pyx_v_self, PyObject *__pyx_v_tag) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2019
 *     cdef char* _name
 *     cdef _initTagMatch(self, tag):
 *         self._href = NULL             # <<<<<<<<<<<<<<
 *         self._name = NULL
 *         if tag is None:
 */
  __pyx_v_self->_href = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2020
 *     cdef _initTagMatch(self, tag):
 *         self._href = NULL
 *         self._name = NULL             # <<<<<<<<<<<<<<
 *         if tag is None:
 *             self._node_type = 0
 */
  __pyx_v_self->_name = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2021
 *         self._href = NULL
 *         self._name = NULL
 *         if tag is None:             # <<<<<<<<<<<<<<
 *             self._node_type = 0
 *         elif tag is Comment:
 */
  __pyx_1 = (__pyx_v_tag == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2022
 *         self._name = NULL
 *         if tag is None:
 *             self._node_type = 0             # <<<<<<<<<<<<<<
 *         elif tag is Comment:
 *             self._node_type = tree.XML_COMMENT_NODE
 */
    __pyx_v_self->_node_type = 0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2023
 *         if tag is None:
 *             self._node_type = 0
 *         elif tag is Comment:             # <<<<<<<<<<<<<<
 *             self._node_type = tree.XML_COMMENT_NODE
 *         elif tag is ProcessingInstruction:
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_Comment); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (__pyx_v_tag == __pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2024
 *             self._node_type = 0
 *         elif tag is Comment:
 *             self._node_type = tree.XML_COMMENT_NODE             # <<<<<<<<<<<<<<
 *         elif tag is ProcessingInstruction:
 *             self._node_type = tree.XML_PI_NODE
 */
    __pyx_v_self->_node_type = XML_COMMENT_NODE;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2025
 *         elif tag is Comment:
 *             self._node_type = tree.XML_COMMENT_NODE
 *         elif tag is ProcessingInstruction:             # <<<<<<<<<<<<<<
 *             self._node_type = tree.XML_PI_NODE
 *         elif tag is Entity:
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_79); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (__pyx_v_tag == __pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2026
 *             self._node_type = tree.XML_COMMENT_NODE
 *         elif tag is ProcessingInstruction:
 *             self._node_type = tree.XML_PI_NODE             # <<<<<<<<<<<<<<
 *         elif tag is Entity:
 *             self._node_type = tree.XML_ENTITY_REF_NODE
 */
    __pyx_v_self->_node_type = XML_PI_NODE;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2027
 *         elif tag is ProcessingInstruction:
 *             self._node_type = tree.XML_PI_NODE
 *         elif tag is Entity:             # <<<<<<<<<<<<<<
 *             self._node_type = tree.XML_ENTITY_REF_NODE
 *         elif tag is Element:
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_Entity); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (__pyx_v_tag == __pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2028
 *             self._node_type = tree.XML_PI_NODE
 *         elif tag is Entity:
 *             self._node_type = tree.XML_ENTITY_REF_NODE             # <<<<<<<<<<<<<<
 *         elif tag is Element:
 *             self._node_type = tree.XML_ELEMENT_NODE
 */
    __pyx_v_self->_node_type = XML_ENTITY_REF_NODE;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2029
 *         elif tag is Entity:
 *             self._node_type = tree.XML_ENTITY_REF_NODE
 *         elif tag is Element:             # <<<<<<<<<<<<<<
 *             self._node_type = tree.XML_ELEMENT_NODE
 *         else:
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_Element); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (__pyx_v_tag == __pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2030
 *             self._node_type = tree.XML_ENTITY_REF_NODE
 *         elif tag is Element:
 *             self._node_type = tree.XML_ELEMENT_NODE             # <<<<<<<<<<<<<<
 *         else:
 *             self._node_type = tree.XML_ELEMENT_NODE
 */
    __pyx_v_self->_node_type = XML_ELEMENT_NODE;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2032
 *             self._node_type = tree.XML_ELEMENT_NODE
 *         else:
 *             self._node_type = tree.XML_ELEMENT_NODE             # <<<<<<<<<<<<<<
 *             self._pystrings = _getNsTag(tag)
 *             if self._pystrings[0] is not None:
 */
    __pyx_v_self->_node_type = XML_ELEMENT_NODE;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2033
 *         else:
 *             self._node_type = tree.XML_ELEMENT_NODE
 *             self._pystrings = _getNsTag(tag)             # <<<<<<<<<<<<<<
 *             if self._pystrings[0] is not None:
 *                 self._href = _cstr(self._pystrings[0])
 */
    __pyx_2 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_tag); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_self->_pystrings);
    __pyx_v_self->_pystrings = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2034
 *             self._node_type = tree.XML_ELEMENT_NODE
 *             self._pystrings = _getNsTag(tag)
 *             if self._pystrings[0] is not None:             # <<<<<<<<<<<<<<
 *                 self._href = _cstr(self._pystrings[0])
 *             self._name = _cstr(self._pystrings[1])
 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_self->_pystrings, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = (__pyx_2 != Py_None);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2035
 *             self._pystrings = _getNsTag(tag)
 *             if self._pystrings[0] is not None:
 *                 self._href = _cstr(self._pystrings[0])             # <<<<<<<<<<<<<<
 *             self._name = _cstr(self._pystrings[1])
 *             if self._name[0] == c'*' and self._name[1] == c'\0':
 */
      __pyx_2 = __Pyx_GetItemInt(__pyx_v_self->_pystrings, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_self->_href = PyString_AS_STRING(__pyx_2);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2036
 *             if self._pystrings[0] is not None:
 *                 self._href = _cstr(self._pystrings[0])
 *             self._name = _cstr(self._pystrings[1])             # <<<<<<<<<<<<<<
 *             if self._name[0] == c'*' and self._name[1] == c'\0':
 *                 self._name = NULL
 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_self->_pystrings, 1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->_name = PyString_AS_STRING(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2037
 *                 self._href = _cstr(self._pystrings[0])
 *             self._name = _cstr(self._pystrings[1])
 *             if self._name[0] == c'*' and self._name[1] == c'\0':             # <<<<<<<<<<<<<<
 *                 self._name = NULL
 * 
 */
    __pyx_1 = ((__pyx_v_self->_name[0]) == '*');
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->_name[1]) == '\x00');
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2038
 *             self._name = _cstr(self._pystrings[1])
 *             if self._name[0] == c'*' and self._name[1] == c'\0':
 *                 self._name = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef public class _ElementIterator(_ElementTagMatcher) [
 */
      __pyx_v_self->_name = NULL;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ElementTagMatcher._initTagMatch");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2045
 *     cdef _Element _node
 *     cdef _node_to_node_function _next_element
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_16_ElementIterator___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_16_ElementIterator___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2046
 *     cdef _node_to_node_function _next_element
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cdef void _storeNext(self, _Element node):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2048
 *         return self
 * 
 *     cdef void _storeNext(self, _Element node):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         c_node = self._next_element(node._c_node)
 */

static  void __pyx_f_4lxml_5etree_16_ElementIterator__storeNext(struct LxmlElementIterator *__pyx_v_self, struct LxmlElement *__pyx_v_node) {
  xmlNode *__pyx_v_c_node;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2050
 *     cdef void _storeNext(self, _Element node):
 *         cdef xmlNode* c_node
 *         c_node = self._next_element(node._c_node)             # <<<<<<<<<<<<<<
 *         while c_node is not NULL and \
 *                   self._node_type != 0 and \
 */
  __pyx_v_c_node = __pyx_v_self->_next_element(__pyx_v_node->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2051
 *         cdef xmlNode* c_node
 *         c_node = self._next_element(node._c_node)
 *         while c_node is not NULL and \             # <<<<<<<<<<<<<<
 *                   self._node_type != 0 and \
 *                   (self._node_type != c_node.type or
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2052
 *         c_node = self._next_element(node._c_node)
 *         while c_node is not NULL and \
 *                   self._node_type != 0 and \             # <<<<<<<<<<<<<<
 *                   (self._node_type != c_node.type or
 *                    not _tagMatches(c_node, self._href, self._name)):
 */
      __pyx_1 = (__pyx_v_self->__pyx_base._node_type != 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2053
 *         while c_node is not NULL and \
 *                   self._node_type != 0 and \
 *                   (self._node_type != c_node.type or             # <<<<<<<<<<<<<<
 *                    not _tagMatches(c_node, self._href, self._name)):
 *             c_node = self._next_element(c_node)
 */
        __pyx_1 = (__pyx_v_self->__pyx_base._node_type != __pyx_v_c_node->type);
        if (!__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2054
 *                   self._node_type != 0 and \
 *                   (self._node_type != c_node.type or
 *                    not _tagMatches(c_node, self._href, self._name)):             # <<<<<<<<<<<<<<
 *             c_node = self._next_element(c_node)
 *         if c_node is NULL:
 */
          __pyx_1 = (!__pyx_f_4lxml_5etree__tagMatches(__pyx_v_c_node, __pyx_v_self->__pyx_base._href, __pyx_v_self->__pyx_base._name));
        }
      }
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2055
 *                   (self._node_type != c_node.type or
 *                    not _tagMatches(c_node, self._href, self._name)):
 *             c_node = self._next_element(c_node)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             self._node = None
 */
    __pyx_v_c_node = __pyx_v_self->_next_element(__pyx_v_c_node);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2056
 *                    not _tagMatches(c_node, self._href, self._name)):
 *             c_node = self._next_element(c_node)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             self._node = None
 *         else:
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2057
 *             c_node = self._next_element(c_node)
 *         if c_node is NULL:
 *             self._node = None             # <<<<<<<<<<<<<<
 *         else:
 *             # Python ref:
 */
    Py_INCREF(Py_None);
    Py_DECREF(((PyObject *)__pyx_v_self->_node));
    __pyx_v_self->_node = ((struct LxmlElement *)Py_None);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2060
 *         else:
 *             # Python ref:
 *             self._node = _elementFactory(node._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_node->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_self->_node));
    __pyx_v_self->_node = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._ElementIterator._storeNext");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2062
 *             self._node = _elementFactory(node._doc, c_node)
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         cdef _Element current_node
 */

static PyObject *__pyx_pf_4lxml_5etree_16_ElementIterator___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_16_ElementIterator___next__(PyObject *__pyx_v_self) {
  struct LxmlElement *__pyx_v_current_node;
  PyObject *__pyx_r;
  int __pyx_1;
  __pyx_v_current_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2065
 *         cdef xmlNode* c_node
 *         cdef _Element current_node
 *         if self._node is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         # Python ref:
 */
  __pyx_1 = (((PyObject *)((struct LxmlElementIterator *)__pyx_v_self)->_node) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2066
 *         cdef _Element current_node
 *         if self._node is None:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         # Python ref:
 *         current_node = self._node
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2068
 *             raise StopIteration
 *         # Python ref:
 *         current_node = self._node             # <<<<<<<<<<<<<<
 *         self._storeNext(current_node)
 *         return current_node
 */
  Py_INCREF(((PyObject *)((struct LxmlElementIterator *)__pyx_v_self)->_node));
  Py_DECREF(((PyObject *)__pyx_v_current_node));
  __pyx_v_current_node = ((struct LxmlElementIterator *)__pyx_v_self)->_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2069
 *         # Python ref:
 *         current_node = self._node
 *         self._storeNext(current_node)             # <<<<<<<<<<<<<<
 *         return current_node
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ElementIterator *)((struct LxmlElementIterator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_storeNext(((struct LxmlElementIterator *)__pyx_v_self), __pyx_v_current_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2070
 *         current_node = self._node
 *         self._storeNext(current_node)
 *         return current_node             # <<<<<<<<<<<<<<
 * 
 * cdef class ElementChildIterator(_ElementIterator):
 */
  Py_INCREF(((PyObject *)__pyx_v_current_node));
  __pyx_r = ((PyObject *)__pyx_v_current_node);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ElementIterator.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_current_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2076
 *     Iterates over the children of an element.
 *     """
 *     def __init__(self, _Element node not None, tag=None, *, reversed=False):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         self._initTagMatch(tag)
 */

static int __pyx_pf_4lxml_5etree_20ElementChildIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_20ElementChildIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_node = 0;
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_reversed = 0;
  xmlNode *__pyx_v_c_node;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_node,&__pyx_kp_tag,&__pyx_kp_reversed,0};
  __pyx_v_tag = Py_None;
  __pyx_v_reversed = __pyx_k_75;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_node);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_node = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_tag = values[1];
    }
    if (values[2]) {
      __pyx_v_reversed = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_node = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ElementChildIterator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_node), __pyx_ptype_4lxml_5etree__Element, 0, "node", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2078
 *     def __init__(self, _Element node not None, tag=None, *, reversed=False):
 *         cdef xmlNode* c_node
 *         self._initTagMatch(tag)             # <<<<<<<<<<<<<<
 *         if reversed:
 *             c_node = _findChildBackwards(node._c_node, 0)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_ElementChildIterator *)((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._initTagMatch(((struct LxmlElementTagMatcher *)__pyx_v_self), __pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2079
 *         cdef xmlNode* c_node
 *         self._initTagMatch(tag)
 *         if reversed:             # <<<<<<<<<<<<<<
 *             c_node = _findChildBackwards(node._c_node, 0)
 *             self._next_element = _previousElement
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_reversed); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2080
 *         self._initTagMatch(tag)
 *         if reversed:
 *             c_node = _findChildBackwards(node._c_node, 0)             # <<<<<<<<<<<<<<
 *             self._next_element = _previousElement
 *         else:
 */
    __pyx_v_c_node = __pyx_f_4lxml_5etree__findChildBackwards(__pyx_v_node->_c_node, 0);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2081
 *         if reversed:
 *             c_node = _findChildBackwards(node._c_node, 0)
 *             self._next_element = _previousElement             # <<<<<<<<<<<<<<
 *         else:
 *             c_node = _findChildForwards(node._c_node, 0)
 */
    ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base._next_element = __pyx_f_4lxml_5etree__previousElement;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2083
 *             self._next_element = _previousElement
 *         else:
 *             c_node = _findChildForwards(node._c_node, 0)             # <<<<<<<<<<<<<<
 *             self._next_element = _nextElement
 *         if tag is not None:
 */
    __pyx_v_c_node = __pyx_f_4lxml_5etree__findChildForwards(__pyx_v_node->_c_node, 0);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2084
 *         else:
 *             c_node = _findChildForwards(node._c_node, 0)
 *             self._next_element = _nextElement             # <<<<<<<<<<<<<<
 *         if tag is not None:
 *             while c_node is not NULL and \
 */
    ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base._next_element = __pyx_f_4lxml_5etree__nextElement;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2085
 *             c_node = _findChildForwards(node._c_node, 0)
 *             self._next_element = _nextElement
 *         if tag is not None:             # <<<<<<<<<<<<<<
 *             while c_node is not NULL and \
 *                       self._node_type != 0 and \
 */
  __pyx_2 = (__pyx_v_tag != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2086
 *             self._next_element = _nextElement
 *         if tag is not None:
 *             while c_node is not NULL and \             # <<<<<<<<<<<<<<
 *                       self._node_type != 0 and \
 *                       (self._node_type != c_node.type or
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_node != NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2087
 *         if tag is not None:
 *             while c_node is not NULL and \
 *                       self._node_type != 0 and \             # <<<<<<<<<<<<<<
 *                       (self._node_type != c_node.type or
 *                        not _tagMatches(c_node, self._href, self._name)):
 */
        __pyx_2 = (((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base.__pyx_base._node_type != 0);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2088
 *             while c_node is not NULL and \
 *                       self._node_type != 0 and \
 *                       (self._node_type != c_node.type or             # <<<<<<<<<<<<<<
 *                        not _tagMatches(c_node, self._href, self._name)):
 *                 c_node = self._next_element(c_node)
 */
          __pyx_2 = (((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base.__pyx_base._node_type != __pyx_v_c_node->type);
          if (!__pyx_2) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2089
 *                       self._node_type != 0 and \
 *                       (self._node_type != c_node.type or
 *                        not _tagMatches(c_node, self._href, self._name)):             # <<<<<<<<<<<<<<
 *                 c_node = self._next_element(c_node)
 *         if c_node is not NULL:
 */
            __pyx_2 = (!__pyx_f_4lxml_5etree__tagMatches(__pyx_v_c_node, ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base.__pyx_base._href, ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base.__pyx_base._name));
          }
        }
      }
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2090
 *                       (self._node_type != c_node.type or
 *                        not _tagMatches(c_node, self._href, self._name)):
 *                 c_node = self._next_element(c_node)             # <<<<<<<<<<<<<<
 *         if c_node is not NULL:
 *             # store Python ref:
 */
      __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base._next_element(__pyx_v_c_node);
    }
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2091
 *                        not _tagMatches(c_node, self._href, self._name)):
 *                 c_node = self._next_element(c_node)
 *         if c_node is not NULL:             # <<<<<<<<<<<<<<
 *             # store Python ref:
 *             self._node = _elementFactory(node._doc, c_node)
 */
  __pyx_2 = (__pyx_v_c_node != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2093
 *         if c_node is not NULL:
 *             # store Python ref:
 *             self._node = _elementFactory(node._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef class SiblingsIterator(_ElementIterator):
 */
    __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_node->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base._node));
    ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)__pyx_v_self)->__pyx_base._node = ((struct LxmlElement *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.ElementChildIterator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2101
 *     You can pass the boolean keyword ``preceding`` to specify the direction.
 *     """
 *     def __init__(self, _Element node not None, tag=None, *, preceding=False):             # <<<<<<<<<<<<<<
 *         self._initTagMatch(tag)
 *         if preceding:
 */

static int __pyx_pf_4lxml_5etree_16SiblingsIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_16SiblingsIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_node = 0;
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_preceding = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_node,&__pyx_kp_tag,&__pyx_kp_preceding,0};
  __pyx_v_tag = Py_None;
  __pyx_v_preceding = __pyx_k_76;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_node);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_node = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_tag = values[1];
    }
    if (values[2]) {
      __pyx_v_preceding = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_node = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.SiblingsIterator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_node), __pyx_ptype_4lxml_5etree__Element, 0, "node", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2102
 *     """
 *     def __init__(self, _Element node not None, tag=None, *, preceding=False):
 *         self._initTagMatch(tag)             # <<<<<<<<<<<<<<
 *         if preceding:
 *             self._next_element = _previousElement
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_SiblingsIterator *)((struct __pyx_obj_4lxml_5etree_SiblingsIterator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._initTagMatch(((struct LxmlElementTagMatcher *)__pyx_v_self), __pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2103
 *     def __init__(self, _Element node not None, tag=None, *, preceding=False):
 *         self._initTagMatch(tag)
 *         if preceding:             # <<<<<<<<<<<<<<
 *             self._next_element = _previousElement
 *         else:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_preceding); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2104
 *         self._initTagMatch(tag)
 *         if preceding:
 *             self._next_element = _previousElement             # <<<<<<<<<<<<<<
 *         else:
 *             self._next_element = _nextElement
 */
    ((struct __pyx_obj_4lxml_5etree_SiblingsIterator *)__pyx_v_self)->__pyx_base._next_element = __pyx_f_4lxml_5etree__previousElement;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2106
 *             self._next_element = _previousElement
 *         else:
 *             self._next_element = _nextElement             # <<<<<<<<<<<<<<
 *         self._storeNext(node)
 * 
 */
    ((struct __pyx_obj_4lxml_5etree_SiblingsIterator *)__pyx_v_self)->__pyx_base._next_element = __pyx_f_4lxml_5etree__nextElement;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2107
 *         else:
 *             self._next_element = _nextElement
 *         self._storeNext(node)             # <<<<<<<<<<<<<<
 * 
 * cdef class AncestorsIterator(_ElementIterator):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree_SiblingsIterator *)((struct __pyx_obj_4lxml_5etree_SiblingsIterator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._storeNext(((struct LxmlElementIterator *)__pyx_v_self), __pyx_v_node);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.SiblingsIterator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2113
 *     Iterates over the ancestors of an element (from parent to parent).
 *     """
 *     def __init__(self, _Element node not None, tag=None):             # <<<<<<<<<<<<<<
 *         self._initTagMatch(tag)
 *         self._next_element = _parentElement
 */

static int __pyx_pf_4lxml_5etree_17AncestorsIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_17AncestorsIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_node = 0;
  PyObject *__pyx_v_tag = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_node,&__pyx_kp_tag,0};
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_node);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_node = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_tag = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_node = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.AncestorsIterator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_node), __pyx_ptype_4lxml_5etree__Element, 0, "node", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2114
 *     """
 *     def __init__(self, _Element node not None, tag=None):
 *         self._initTagMatch(tag)             # <<<<<<<<<<<<<<
 *         self._next_element = _parentElement
 *         self._storeNext(node)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_AncestorsIterator *)((struct __pyx_obj_4lxml_5etree_AncestorsIterator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._initTagMatch(((struct LxmlElementTagMatcher *)__pyx_v_self), __pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2115
 *     def __init__(self, _Element node not None, tag=None):
 *         self._initTagMatch(tag)
 *         self._next_element = _parentElement             # <<<<<<<<<<<<<<
 *         self._storeNext(node)
 * 
 */
  ((struct __pyx_obj_4lxml_5etree_AncestorsIterator *)__pyx_v_self)->__pyx_base._next_element = __pyx_f_4lxml_5etree__parentElement;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2116
 *         self._initTagMatch(tag)
 *         self._next_element = _parentElement
 *         self._storeNext(node)             # <<<<<<<<<<<<<<
 * 
 * cdef class ElementDepthFirstIterator(_ElementTagMatcher):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree_AncestorsIterator *)((struct __pyx_obj_4lxml_5etree_AncestorsIterator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._storeNext(((struct LxmlElementIterator *)__pyx_v_self), __pyx_v_node);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.AncestorsIterator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2142
 *     cdef _Element _next_node
 *     cdef _Element _top_node
 *     def __init__(self, _Element node not None, tag=None, *, inclusive=True):             # <<<<<<<<<<<<<<
 *         self._top_node  = node
 *         self._next_node = node
 */

static int __pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_node = 0;
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_inclusive = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_node,&__pyx_kp_tag,&__pyx_kp_inclusive,0};
  __pyx_v_tag = Py_None;
  __pyx_v_inclusive = __pyx_k_77;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_node);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_node = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_tag = values[1];
    }
    if (values[2]) {
      __pyx_v_inclusive = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_node = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ElementDepthFirstIterator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_node), __pyx_ptype_4lxml_5etree__Element, 0, "node", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2143
 *     cdef _Element _top_node
 *     def __init__(self, _Element node not None, tag=None, *, inclusive=True):
 *         self._top_node  = node             # <<<<<<<<<<<<<<
 *         self._next_node = node
 *         self._initTagMatch(tag)
 */
  Py_INCREF(((PyObject *)__pyx_v_node));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_top_node));
  ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_top_node = __pyx_v_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2144
 *     def __init__(self, _Element node not None, tag=None, *, inclusive=True):
 *         self._top_node  = node
 *         self._next_node = node             # <<<<<<<<<<<<<<
 *         self._initTagMatch(tag)
 *         if not inclusive or \
 */
  Py_INCREF(((PyObject *)__pyx_v_node));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node));
  ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node = __pyx_v_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2145
 *         self._top_node  = node
 *         self._next_node = node
 *         self._initTagMatch(tag)             # <<<<<<<<<<<<<<
 *         if not inclusive or \
 *                tag is not None and \
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._initTagMatch(((struct LxmlElementTagMatcher *)__pyx_v_self), __pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2146
 *         self._next_node = node
 *         self._initTagMatch(tag)
 *         if not inclusive or \             # <<<<<<<<<<<<<<
 *                tag is not None and \
 *                self._node_type != 0 and \
 */
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_inclusive); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_3);
  if (!__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2147
 *         self._initTagMatch(tag)
 *         if not inclusive or \
 *                tag is not None and \             # <<<<<<<<<<<<<<
 *                self._node_type != 0 and \
 *                (self._node_type != node._c_node.type or
 */
    __pyx_2 = (__pyx_v_tag != Py_None);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2148
 *         if not inclusive or \
 *                tag is not None and \
 *                self._node_type != 0 and \             # <<<<<<<<<<<<<<
 *                (self._node_type != node._c_node.type or
 *                 not _tagMatches(node._c_node, self._href, self._name)):
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base._node_type != 0);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2149
 *                tag is not None and \
 *                self._node_type != 0 and \
 *                (self._node_type != node._c_node.type or             # <<<<<<<<<<<<<<
 *                 not _tagMatches(node._c_node, self._href, self._name)):
 *             # this cannot raise StopIteration, self._next_node != None
 */
        __pyx_2 = (((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base._node_type != __pyx_v_node->_c_node->type);
        if (!__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2150
 *                self._node_type != 0 and \
 *                (self._node_type != node._c_node.type or
 *                 not _tagMatches(node._c_node, self._href, self._name)):             # <<<<<<<<<<<<<<
 *             # this cannot raise StopIteration, self._next_node != None
 *             self.__next__()
 */
          __pyx_2 = (!__pyx_f_4lxml_5etree__tagMatches(__pyx_v_node->_c_node, ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base._href, ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base._name));
        }
      }
    }
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2152
 *                 not _tagMatches(node._c_node, self._href, self._name)):
 *             # this cannot raise StopIteration, self._next_node != None
 *             self.__next__()             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___next__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.ElementDepthFirstIterator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2154
 *             self.__next__()
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2155
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2157
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         cdef _Element current_node
 */

static PyObject *__pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___next__(PyObject *__pyx_v_self) {
  xmlNode *__pyx_v_c_node;
  struct LxmlElement *__pyx_v_current_node;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_current_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2160
 *         cdef xmlNode* c_node
 *         cdef _Element current_node
 *         if self._next_node is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         current_node = self._next_node
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2161
 *         cdef _Element current_node
 *         if self._next_node is None:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         current_node = self._next_node
 *         c_node = self._next_node._c_node
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2162
 *         if self._next_node is None:
 *             raise StopIteration
 *         current_node = self._next_node             # <<<<<<<<<<<<<<
 *         c_node = self._next_node._c_node
 *         if self._name is NULL and self._href is NULL:
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node));
  Py_DECREF(((PyObject *)__pyx_v_current_node));
  __pyx_v_current_node = ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2163
 *             raise StopIteration
 *         current_node = self._next_node
 *         c_node = self._next_node._c_node             # <<<<<<<<<<<<<<
 *         if self._name is NULL and self._href is NULL:
 *             c_node = self._nextNodeAnyTag(c_node)
 */
  __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2164
 *         current_node = self._next_node
 *         c_node = self._next_node._c_node
 *         if self._name is NULL and self._href is NULL:             # <<<<<<<<<<<<<<
 *             c_node = self._nextNodeAnyTag(c_node)
 *         else:
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base._name == NULL);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base._href == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2165
 *         c_node = self._next_node._c_node
 *         if self._name is NULL and self._href is NULL:
 *             c_node = self._nextNodeAnyTag(c_node)             # <<<<<<<<<<<<<<
 *         else:
 *             c_node = self._nextNodeMatchTag(c_node)
 */
    __pyx_v_c_node = ((struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_nextNodeAnyTag(((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self), __pyx_v_c_node);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2167
 *             c_node = self._nextNodeAnyTag(c_node)
 *         else:
 *             c_node = self._nextNodeMatchTag(c_node)             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             self._next_node = None
 */
    __pyx_v_c_node = ((struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_nextNodeMatchTag(((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self), __pyx_v_c_node);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2168
 *         else:
 *             c_node = self._nextNodeMatchTag(c_node)
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             self._next_node = None
 *         else:
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2169
 *             c_node = self._nextNodeMatchTag(c_node)
 *         if c_node is NULL:
 *             self._next_node = None             # <<<<<<<<<<<<<<
 *         else:
 *             self._next_node = _elementFactory(current_node._doc, c_node)
 */
    Py_INCREF(Py_None);
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node));
    ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node = ((struct LxmlElement *)Py_None);
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2171
 *             self._next_node = None
 *         else:
 *             self._next_node = _elementFactory(current_node._doc, c_node)             # <<<<<<<<<<<<<<
 *         return current_node
 * 
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_current_node->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node));
    ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)__pyx_v_self)->_next_node = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2172
 *         else:
 *             self._next_node = _elementFactory(current_node._doc, c_node)
 *         return current_node             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlNode* _nextNodeAnyTag(self, xmlNode* c_node):
 */
  Py_INCREF(((PyObject *)__pyx_v_current_node));
  __pyx_r = ((PyObject *)__pyx_v_current_node);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.ElementDepthFirstIterator.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_current_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2174
 *         return current_node
 * 
 *     cdef xmlNode* _nextNodeAnyTag(self, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)
 *         if self._node_type == 0 or self._node_type == c_node.type:
 */

static  xmlNode *__pyx_f_4lxml_5etree_25ElementDepthFirstIterator__nextNodeAnyTag(struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *__pyx_v_self, xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2175
 * 
 *     cdef xmlNode* _nextNodeAnyTag(self, xmlNode* c_node):
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)             # <<<<<<<<<<<<<<
 *         if self._node_type == 0 or self._node_type == c_node.type:
 *             return c_node
 */
  BEGIN_FOR_EACH_ELEMENT_FROM(__pyx_v_self->_top_node->_c_node, __pyx_v_c_node, 0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2176
 *     cdef xmlNode* _nextNodeAnyTag(self, xmlNode* c_node):
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)
 *         if self._node_type == 0 or self._node_type == c_node.type:             # <<<<<<<<<<<<<<
 *             return c_node
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 */
  __pyx_1 = (__pyx_v_self->__pyx_base._node_type == 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->__pyx_base._node_type == __pyx_v_c_node->type);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2177
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)
 *         if self._node_type == 0 or self._node_type == c_node.type:
 *             return c_node             # <<<<<<<<<<<<<<
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *         return NULL
 */
    __pyx_r = __pyx_v_c_node;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2178
 *         if self._node_type == 0 or self._node_type == c_node.type:
 *             return c_node
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)             # <<<<<<<<<<<<<<
 *         return NULL
 * 
 */
  END_FOR_EACH_ELEMENT_FROM(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2179
 *             return c_node
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlNode* _nextNodeMatchTag(self, xmlNode* c_node):
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2181
 *         return NULL
 * 
 *     cdef xmlNode* _nextNodeMatchTag(self, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *         cdef char* c_name = NULL
 *         if self._name is not NULL:
 */

static  xmlNode *__pyx_f_4lxml_5etree_25ElementDepthFirstIterator__nextNodeMatchTag(struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *__pyx_v_self, xmlNode *__pyx_v_c_node) {
  char *__pyx_v_c_name;
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2182
 * 
 *     cdef xmlNode* _nextNodeMatchTag(self, xmlNode* c_node):
 *         cdef char* c_name = NULL             # <<<<<<<<<<<<<<
 *         if self._name is not NULL:
 *             c_name = tree.xmlDictExists(c_node.doc.dict, self._name, -1)
 */
  __pyx_v_c_name = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2183
 *     cdef xmlNode* _nextNodeMatchTag(self, xmlNode* c_node):
 *         cdef char* c_name = NULL
 *         if self._name is not NULL:             # <<<<<<<<<<<<<<
 *             c_name = tree.xmlDictExists(c_node.doc.dict, self._name, -1)
 *             if c_name is NULL:
 */
  __pyx_1 = (__pyx_v_self->__pyx_base._name != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2184
 *         cdef char* c_name = NULL
 *         if self._name is not NULL:
 *             c_name = tree.xmlDictExists(c_node.doc.dict, self._name, -1)             # <<<<<<<<<<<<<<
 *             if c_name is NULL:
 *                 # not found in dict => not in document at all
 */
    __pyx_v_c_name = xmlDictExists(__pyx_v_c_node->doc->dict, __pyx_v_self->__pyx_base._name, -1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2185
 *         if self._name is not NULL:
 *             c_name = tree.xmlDictExists(c_node.doc.dict, self._name, -1)
 *             if c_name is NULL:             # <<<<<<<<<<<<<<
 *                 # not found in dict => not in document at all
 *                 return NULL
 */
    __pyx_1 = (__pyx_v_c_name == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2187
 *             if c_name is NULL:
 *                 # not found in dict => not in document at all
 *                 return NULL             # <<<<<<<<<<<<<<
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)
 *         if c_node.type == tree.XML_ELEMENT_NODE:
 */
      __pyx_r = NULL;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2188
 *                 # not found in dict => not in document at all
 *                 return NULL
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)             # <<<<<<<<<<<<<<
 *         if c_node.type == tree.XML_ELEMENT_NODE:
 *             if (c_name is NULL or c_name is c_node.name) and \
 */
  BEGIN_FOR_EACH_ELEMENT_FROM(__pyx_v_self->_top_node->_c_node, __pyx_v_c_node, 0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2189
 *                 return NULL
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)
 *         if c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *             if (c_name is NULL or c_name is c_node.name) and \
 *                     _tagMatches(c_node, self._href, self._name):
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2190
 *         tree.BEGIN_FOR_EACH_ELEMENT_FROM(self._top_node._c_node, c_node, 0)
 *         if c_node.type == tree.XML_ELEMENT_NODE:
 *             if (c_name is NULL or c_name is c_node.name) and \             # <<<<<<<<<<<<<<
 *                     _tagMatches(c_node, self._href, self._name):
 *                 return c_node
 */
    __pyx_1 = (__pyx_v_c_name == NULL);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_c_name == __pyx_v_c_node->name);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2191
 *         if c_node.type == tree.XML_ELEMENT_NODE:
 *             if (c_name is NULL or c_name is c_node.name) and \
 *                     _tagMatches(c_node, self._href, self._name):             # <<<<<<<<<<<<<<
 *                 return c_node
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 */
      __pyx_1 = __pyx_f_4lxml_5etree__tagMatches(__pyx_v_c_node, __pyx_v_self->__pyx_base._href, __pyx_v_self->__pyx_base._name);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2192
 *             if (c_name is NULL or c_name is c_node.name) and \
 *                     _tagMatches(c_node, self._href, self._name):
 *                 return c_node             # <<<<<<<<<<<<<<
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *         return NULL
 */
      __pyx_r = __pyx_v_c_node;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2193
 *                     _tagMatches(c_node, self._href, self._name):
 *                 return c_node
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)             # <<<<<<<<<<<<<<
 *         return NULL
 * 
 */
  END_FOR_EACH_ELEMENT_FROM(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2194
 *                 return c_node
 *         tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef class ElementTextIterator:
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2208
 *     cdef object _nextEvent
 *     cdef _Element _start_element
 *     def __init__(self, _Element element not None, tag=None, *, with_tail=True):             # <<<<<<<<<<<<<<
 *         if with_tail:
 *             events = (u"start", u"end")
 */

static int __pyx_pf_4lxml_5etree_19ElementTextIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_19ElementTextIterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_element = 0;
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_with_tail = 0;
  PyObject *__pyx_v_events;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element,&__pyx_kp_tag,&__pyx_kp_with_tail,0};
  __pyx_v_tag = Py_None;
  __pyx_v_with_tail = __pyx_k_78;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_tag = values[1];
    }
    if (values[2]) {
      __pyx_v_with_tail = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ElementTextIterator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_events = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2209
 *     cdef _Element _start_element
 *     def __init__(self, _Element element not None, tag=None, *, with_tail=True):
 *         if with_tail:             # <<<<<<<<<<<<<<
 *             events = (u"start", u"end")
 *         else:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2210
 *     def __init__(self, _Element element not None, tag=None, *, with_tail=True):
 *         if with_tail:
 *             events = (u"start", u"end")             # <<<<<<<<<<<<<<
 *         else:
 *             events = (u"start",)
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_286));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_286));
    Py_INCREF(((PyObject *)__pyx_kp_287));
    PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_kp_287));
    Py_DECREF(__pyx_v_events);
    __pyx_v_events = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2212
 *             events = (u"start", u"end")
 *         else:
 *             events = (u"start",)             # <<<<<<<<<<<<<<
 *         self._start_element = element
 *         self._nextEvent = iterwalk(element, events=events, tag=tag).__next__
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_288));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_288));
    Py_DECREF(__pyx_v_events);
    __pyx_v_events = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2213
 *         else:
 *             events = (u"start",)
 *         self._start_element = element             # <<<<<<<<<<<<<<
 *         self._nextEvent = iterwalk(element, events=events, tag=tag).__next__
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_element));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)__pyx_v_self)->_start_element));
  ((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)__pyx_v_self)->_start_element = __pyx_v_element;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2214
 *             events = (u"start",)
 *         self._start_element = element
 *         self._nextEvent = iterwalk(element, events=events, tag=tag).__next__             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_element));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_element));
  __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_3, __pyx_kp_events, __pyx_v_events) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_3, __pyx_kp_tag, __pyx_v_tag) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_iterwalk)), ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_kp___next__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)__pyx_v_self)->_nextEvent);
  ((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)__pyx_v_self)->_nextEvent = __pyx_2;
  __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.ElementTextIterator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_events);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2216
 *         self._nextEvent = iterwalk(element, events=events, tag=tag).__next__
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_19ElementTextIterator___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_19ElementTextIterator___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2217
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2219
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef _Element element
 *         while result is None:
 */

static PyObject *__pyx_pf_4lxml_5etree_19ElementTextIterator___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_19ElementTextIterator___next__(PyObject *__pyx_v_self) {
  struct LxmlElement *__pyx_v_element;
  PyObject *__pyx_v_event;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_event = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2221
 *     def __next__(self):
 *         cdef _Element element
 *         while result is None:             # <<<<<<<<<<<<<<
 *             event, element = self._nextEvent() # raises StopIteration
 *             if event == u"start":
 */
  while (1) {
    __pyx_1 = (__pyx_v_result == Py_None);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2222
 *         cdef _Element element
 *         while result is None:
 *             event, element = self._nextEvent() # raises StopIteration             # <<<<<<<<<<<<<<
 *             if event == u"start":
 *                 result = element.text
 */
    __pyx_2 = PyObject_Call(((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)__pyx_v_self)->_nextEvent, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
      PyObject* tuple = __pyx_2;
      __pyx_4 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_4);
      Py_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_4;
      __pyx_4 = 0;
      __pyx_4 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_4);
      if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_4);
      __pyx_4 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    else {
      __pyx_3 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_4;
      __pyx_4 = 0;
      __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_4);
      __pyx_4 = 0;
      if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2223
 *         while result is None:
 *             event, element = self._nextEvent() # raises StopIteration
 *             if event == u"start":             # <<<<<<<<<<<<<<
 *                 result = element.text
 *             elif element is not self._start_element:
 */
    __pyx_4 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_289), Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2224
 *             event, element = self._nextEvent() # raises StopIteration
 *             if event == u"start":
 *                 result = element.text             # <<<<<<<<<<<<<<
 *             elif element is not self._start_element:
 *                 result = element.tail
 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_element), __pyx_kp_text); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L7;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2225
 *             if event == u"start":
 *                 result = element.text
 *             elif element is not self._start_element:             # <<<<<<<<<<<<<<
 *                 result = element.tail
 *         return result
 */
    __pyx_1 = (__pyx_v_element != ((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)__pyx_v_self)->_start_element);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2226
 *                 result = element.text
 *             elif element is not self._start_element:
 *                 result = element.tail             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_element), __pyx_kp_tail); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2227
 *             elif element is not self._start_element:
 *                 result = element.tail
 *         return result             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* _createElement(xmlDoc* c_doc, object name_utf) except NULL:
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.ElementTextIterator.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  Py_DECREF(__pyx_v_event);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2229
 *         return result
 * 
 * cdef xmlNode* _createElement(xmlDoc* c_doc, object name_utf) except NULL:             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocNode(c_doc, NULL, _cstr(name_utf), NULL)
 */

static  xmlNode *__pyx_f_4lxml_5etree__createElement(xmlDoc *__pyx_v_c_doc, PyObject *__pyx_v_name_utf) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2231
 * cdef xmlNode* _createElement(xmlDoc* c_doc, object name_utf) except NULL:
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocNode(c_doc, NULL, _cstr(name_utf), NULL)             # <<<<<<<<<<<<<<
 *     return c_node
 * 
 */
  __pyx_v_c_node = xmlNewDocNode(__pyx_v_c_doc, NULL, PyString_AS_STRING(__pyx_v_name_utf), NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2232
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocNode(c_doc, NULL, _cstr(name_utf), NULL)
 *     return c_node             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* _createComment(xmlDoc* c_doc, char* text):
 */
  __pyx_r = __pyx_v_c_node;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2234
 *     return c_node
 * 
 * cdef xmlNode* _createComment(xmlDoc* c_doc, char* text):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocComment(c_doc, text)
 */

static  xmlNode *__pyx_f_4lxml_5etree__createComment(xmlDoc *__pyx_v_c_doc, char *__pyx_v_text) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2236
 * cdef xmlNode* _createComment(xmlDoc* c_doc, char* text):
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocComment(c_doc, text)             # <<<<<<<<<<<<<<
 *     return c_node
 * 
 */
  __pyx_v_c_node = xmlNewDocComment(__pyx_v_c_doc, __pyx_v_text);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2237
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocComment(c_doc, text)
 *     return c_node             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* _createPI(xmlDoc* c_doc, char* target, char* text):
 */
  __pyx_r = __pyx_v_c_node;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2239
 *     return c_node
 * 
 * cdef xmlNode* _createPI(xmlDoc* c_doc, char* target, char* text):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocPI(c_doc, target, text)
 */

static  xmlNode *__pyx_f_4lxml_5etree__createPI(xmlDoc *__pyx_v_c_doc, char *__pyx_v_target, char *__pyx_v_text) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2241
 * cdef xmlNode* _createPI(xmlDoc* c_doc, char* target, char* text):
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocPI(c_doc, target, text)             # <<<<<<<<<<<<<<
 *     return c_node
 * 
 */
  __pyx_v_c_node = xmlNewDocPI(__pyx_v_c_doc, __pyx_v_target, __pyx_v_text);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2242
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewDocPI(c_doc, target, text)
 *     return c_node             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* _createEntity(xmlDoc* c_doc, char* name):
 */
  __pyx_r = __pyx_v_c_node;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2244
 *     return c_node
 * 
 * cdef xmlNode* _createEntity(xmlDoc* c_doc, char* name):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewReference(c_doc, name)
 */

static  xmlNode *__pyx_f_4lxml_5etree__createEntity(xmlDoc *__pyx_v_c_doc, char *__pyx_v_name) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2246
 * cdef xmlNode* _createEntity(xmlDoc* c_doc, char* name):
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewReference(c_doc, name)             # <<<<<<<<<<<<<<
 *     return c_node
 * 
 */
  __pyx_v_c_node = xmlNewReference(__pyx_v_c_doc, __pyx_v_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2247
 *     cdef xmlNode* c_node
 *     c_node = tree.xmlNewReference(c_doc, name)
 *     return c_node             # <<<<<<<<<<<<<<
 * 
 * # module-level API for ElementTree
 */
  __pyx_r = __pyx_v_c_node;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2251
 * # module-level API for ElementTree
 * 
 * def Element(_tag, attrib=None, nsmap=None, **_extra):             # <<<<<<<<<<<<<<
 *     u"""Element(_tag, attrib=None, nsmap=None, **_extra)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_Element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_Element[] = "Element(_tag, attrib=None, nsmap=None, **_extra)\n\n    Element factory.  This function returns an object implementing the\n    Element interface.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_Element(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__tag = 0;
  PyObject *__pyx_v_attrib = 0;
  PyObject *__pyx_v_nsmap = 0;
  PyObject *__pyx_v__extra = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__tag,&__pyx_kp_attrib,&__pyx_kp_nsmap,0};
  __pyx_self = __pyx_self;
  __pyx_v_attrib = Py_None;
  __pyx_v_nsmap = Py_None;
  __pyx_v__extra = PyDict_New(); if (unlikely(!__pyx_v__extra)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__tag);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__extra, values, PyTuple_GET_SIZE(__pyx_args), "Element") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__tag = values[0];
    if (values[1]) {
      __pyx_v_attrib = values[1];
    }
    if (values[2]) {
      __pyx_v_nsmap = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_nsmap = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_attrib = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v__tag = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Element", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2251; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__extra);
  __Pyx_AddTraceback("lxml.etree.Element");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2259
 *     ### also look at _Element.makeelement() and _BaseParser.makeelement() ###
 *     return _makeElement(_tag, NULL, None, None, None, None,
 *                         attrib, nsmap, _extra)             # <<<<<<<<<<<<<<
 * 
 * def Comment(text=None):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__makeElement(__pyx_v__tag, NULL, ((struct LxmlDocument *)Py_None), ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None), Py_None, Py_None, __pyx_v_attrib, __pyx_v_nsmap, __pyx_v__extra)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.Element");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__extra);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2261
 *                         attrib, nsmap, _extra)
 * 
 * def Comment(text=None):             # <<<<<<<<<<<<<<
 *     u"""Comment(text=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_Comment(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_Comment[] = "Comment(text=None)\n\n    Comment element factory. This factory function creates a special element that will\n    be serialized as an XML comment.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_Comment(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  struct LxmlDocument *__pyx_v_doc;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_doc;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  xmlDoc *__pyx_3;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_text,0};
  __pyx_self = __pyx_self;
  __pyx_v_text = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "Comment") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_text = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Comment", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Comment");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_text);
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2270
 *     cdef xmlNode*  c_node
 *     cdef xmlDoc*   c_doc
 *     if text is None:             # <<<<<<<<<<<<<<
 *         text = ''
 *     else:
 */
  __pyx_1 = (__pyx_v_text == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2271
 *     cdef xmlDoc*   c_doc
 *     if text is None:
 *         text = ''             # <<<<<<<<<<<<<<
 *     else:
 *         text = _utf8(text)
 */
    Py_INCREF(__pyx_kp_290);
    Py_DECREF(__pyx_v_text);
    __pyx_v_text = __pyx_kp_290;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2273
 *         text = ''
 *     else:
 *         text = _utf8(text)             # <<<<<<<<<<<<<<
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_text); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_text);
    __pyx_v_text = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2274
 *     else:
 *         text = _utf8(text)
 *     c_doc = _newXMLDoc()             # <<<<<<<<<<<<<<
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createComment(c_doc, _cstr(text))
 */
  __pyx_3 = __pyx_f_4lxml_5etree__newXMLDoc(); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2275
 *         text = _utf8(text)
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)             # <<<<<<<<<<<<<<
 *     c_node = _createComment(c_doc, _cstr(text))
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2276
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createComment(c_doc, _cstr(text))             # <<<<<<<<<<<<<<
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 *     return _elementFactory(doc, c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__createComment(__pyx_v_c_doc, PyString_AS_STRING(__pyx_v_text));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2277
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createComment(c_doc, _cstr(text))
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)             # <<<<<<<<<<<<<<
 *     return _elementFactory(doc, c_node)
 * 
 */
  xmlAddChild(((xmlNode *)__pyx_v_c_doc), __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2278
 *     c_node = _createComment(c_doc, _cstr(text))
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 *     return _elementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * def ProcessingInstruction(target, text=None):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.Comment");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2280
 *     return _elementFactory(doc, c_node)
 * 
 * def ProcessingInstruction(target, text=None):             # <<<<<<<<<<<<<<
 *     u"""ProcessingInstruction(target, text=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_ProcessingInstruction(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_ProcessingInstruction[] = "ProcessingInstruction(target, text=None)\n\n    ProcessingInstruction element factory. This factory function creates a\n    special element that will be serialized as an XML processing instruction.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_ProcessingInstruction(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_text = 0;
  struct LxmlDocument *__pyx_v_doc;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_doc;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  xmlDoc *__pyx_3;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_target,&__pyx_kp_text,0};
  __pyx_self = __pyx_self;
  __pyx_v_text = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_target);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "ProcessingInstruction") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_target = values[0];
    if (values[1]) {
      __pyx_v_text = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_target = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ProcessingInstruction", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ProcessingInstruction");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_target);
  Py_INCREF(__pyx_v_text);
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2289
 *     cdef xmlNode*  c_node
 *     cdef xmlDoc*   c_doc
 *     target = _utf8(target)             # <<<<<<<<<<<<<<
 *     if text is None:
 *         text = ''
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_target); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_target);
  __pyx_v_target = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2290
 *     cdef xmlDoc*   c_doc
 *     target = _utf8(target)
 *     if text is None:             # <<<<<<<<<<<<<<
 *         text = ''
 *     else:
 */
  __pyx_2 = (__pyx_v_text == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2291
 *     target = _utf8(target)
 *     if text is None:
 *         text = ''             # <<<<<<<<<<<<<<
 *     else:
 *         text = _utf8(text)
 */
    Py_INCREF(__pyx_kp_291);
    Py_DECREF(__pyx_v_text);
    __pyx_v_text = __pyx_kp_291;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2293
 *         text = ''
 *     else:
 *         text = _utf8(text)             # <<<<<<<<<<<<<<
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)
 */
    __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_text); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_text);
    __pyx_v_text = __pyx_1;
    __pyx_1 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2294
 *     else:
 *         text = _utf8(text)
 *     c_doc = _newXMLDoc()             # <<<<<<<<<<<<<<
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createPI(c_doc, _cstr(target), _cstr(text))
 */
  __pyx_3 = __pyx_f_4lxml_5etree__newXMLDoc(); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2295
 *         text = _utf8(text)
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)             # <<<<<<<<<<<<<<
 *     c_node = _createPI(c_doc, _cstr(target), _cstr(text))
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2296
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createPI(c_doc, _cstr(target), _cstr(text))             # <<<<<<<<<<<<<<
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 *     return _elementFactory(doc, c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__createPI(__pyx_v_c_doc, PyString_AS_STRING(__pyx_v_target), PyString_AS_STRING(__pyx_v_text));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2297
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createPI(c_doc, _cstr(target), _cstr(text))
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)             # <<<<<<<<<<<<<<
 *     return _elementFactory(doc, c_node)
 * 
 */
  xmlAddChild(((xmlNode *)__pyx_v_c_doc), __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2298
 *     c_node = _createPI(c_doc, _cstr(target), _cstr(text))
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 *     return _elementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * PI = ProcessingInstruction
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.ProcessingInstruction");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_target);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2313
 *     """
 *     cdef object _utf8_data
 *     def __init__(self, data):             # <<<<<<<<<<<<<<
 *         self._utf8_data = _utf8(data)
 * 
 */

static int __pyx_pf_4lxml_5etree_5CDATA___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_5CDATA___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_data = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_data,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_data);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_data = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.CDATA.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2314
 *     cdef object _utf8_data
 *     def __init__(self, data):
 *         self._utf8_data = _utf8(data)             # <<<<<<<<<<<<<<
 * 
 * def Entity(name):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_data); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_CDATA *)__pyx_v_self)->_utf8_data);
  ((struct __pyx_obj_4lxml_5etree_CDATA *)__pyx_v_self)->_utf8_data = __pyx_1;
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.CDATA.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2316
 *         self._utf8_data = _utf8(data)
 * 
 * def Entity(name):             # <<<<<<<<<<<<<<
 *     u"""Entity(name)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_Entity(PyObject *__pyx_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_4lxml_5etree_Entity[] = "Entity(name)\n\n    Entity factory.  This factory function creates a special element\n    that will be serialized as an XML entity reference or character\n    reference.  Note, however, that entities will not be automatically\n    declared in the document.  A document that uses entity references\n    requires a DTD to define the entities.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_Entity(PyObject *__pyx_self, PyObject *__pyx_v_name) {
  struct LxmlDocument *__pyx_v_doc;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_doc;
  char *__pyx_v_c_name;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  xmlDoc *__pyx_3;
  PyObject *__pyx_t_1 = NULL;
  __pyx_self = __pyx_self;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2329
 *     cdef xmlDoc*   c_doc
 *     cdef char* c_name
 *     name_utf = _utf8(name)             # <<<<<<<<<<<<<<
 *     c_name = _cstr(name_utf)
 *     if c_name[0] == c'#':
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_name_utf);
  __pyx_v_name_utf = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2330
 *     cdef char* c_name
 *     name_utf = _utf8(name)
 *     c_name = _cstr(name_utf)             # <<<<<<<<<<<<<<
 *     if c_name[0] == c'#':
 *         if not _characterReferenceIsValid(c_name + 1):
 */
  __pyx_v_c_name = PyString_AS_STRING(__pyx_v_name_utf);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2331
 *     name_utf = _utf8(name)
 *     c_name = _cstr(name_utf)
 *     if c_name[0] == c'#':             # <<<<<<<<<<<<<<
 *         if not _characterReferenceIsValid(c_name + 1):
 *             raise ValueError, u"Invalid character reference: '%s'" % name
 */
  __pyx_2 = ((__pyx_v_c_name[0]) == '#');
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2332
 *     c_name = _cstr(name_utf)
 *     if c_name[0] == c'#':
 *         if not _characterReferenceIsValid(c_name + 1):             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Invalid character reference: '%s'" % name
 *     elif not _xmlNameIsValid(c_name):
 */
    __pyx_2 = (!__pyx_f_4lxml_5etree__characterReferenceIsValid((__pyx_v_c_name + 1)));
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2333
 *     if c_name[0] == c'#':
 *         if not _characterReferenceIsValid(c_name + 1):
 *             raise ValueError, u"Invalid character reference: '%s'" % name             # <<<<<<<<<<<<<<
 *     elif not _xmlNameIsValid(c_name):
 *         raise ValueError, u"Invalid entity reference: '%s'" % name
 */
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_292), __pyx_v_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2334
 *         if not _characterReferenceIsValid(c_name + 1):
 *             raise ValueError, u"Invalid character reference: '%s'" % name
 *     elif not _xmlNameIsValid(c_name):             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Invalid entity reference: '%s'" % name
 *     c_doc = _newXMLDoc()
 */
  __pyx_2 = (!__pyx_f_4lxml_5etree__xmlNameIsValid(__pyx_v_c_name));
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2335
 *             raise ValueError, u"Invalid character reference: '%s'" % name
 *     elif not _xmlNameIsValid(c_name):
 *         raise ValueError, u"Invalid entity reference: '%s'" % name             # <<<<<<<<<<<<<<
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_293), __pyx_v_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2336
 *     elif not _xmlNameIsValid(c_name):
 *         raise ValueError, u"Invalid entity reference: '%s'" % name
 *     c_doc = _newXMLDoc()             # <<<<<<<<<<<<<<
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createEntity(c_doc, c_name)
 */
  __pyx_3 = __pyx_f_4lxml_5etree__newXMLDoc(); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2337
 *         raise ValueError, u"Invalid entity reference: '%s'" % name
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)             # <<<<<<<<<<<<<<
 *     c_node = _createEntity(c_doc, c_name)
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2338
 *     c_doc = _newXMLDoc()
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createEntity(c_doc, c_name)             # <<<<<<<<<<<<<<
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 *     return _elementFactory(doc, c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__createEntity(__pyx_v_c_doc, __pyx_v_c_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2339
 *     doc = _documentFactory(c_doc, None)
 *     c_node = _createEntity(c_doc, c_name)
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)             # <<<<<<<<<<<<<<
 *     return _elementFactory(doc, c_node)
 * 
 */
  xmlAddChild(((xmlNode *)__pyx_v_c_doc), __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2340
 *     c_node = _createEntity(c_doc, c_name)
 *     tree.xmlAddChild(<xmlNode*>c_doc, c_node)
 *     return _elementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * def SubElement(_Element _parent not None, _tag,
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.Entity");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2342
 *     return _elementFactory(doc, c_node)
 * 
 * def SubElement(_Element _parent not None, _tag,             # <<<<<<<<<<<<<<
 *                attrib=None, nsmap=None, **_extra):
 *     u"""SubElement(_parent, _tag, attrib=None, nsmap=None, **_extra)
 */

static PyObject *__pyx_pf_4lxml_5etree_SubElement(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_SubElement[] = "SubElement(_parent, _tag, attrib=None, nsmap=None, **_extra)\n\n    Subelement factory.  This function creates an element instance, and\n    appends it to an existing element.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_SubElement(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v__parent = 0;
  PyObject *__pyx_v__tag = 0;
  PyObject *__pyx_v_attrib = 0;
  PyObject *__pyx_v_nsmap = 0;
  PyObject *__pyx_v__extra = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__parent,&__pyx_kp__tag,&__pyx_kp_attrib,&__pyx_kp_nsmap,0};
  __pyx_self = __pyx_self;
  __pyx_v_attrib = Py_None;
  __pyx_v_nsmap = Py_None;
  __pyx_v__extra = PyDict_New(); if (unlikely(!__pyx_v__extra)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__parent);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp__tag);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("SubElement", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__extra, values, PyTuple_GET_SIZE(__pyx_args), "SubElement") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__parent = ((struct LxmlElement *)values[0]);
    __pyx_v__tag = values[1];
    if (values[2]) {
      __pyx_v_attrib = values[2];
    }
    if (values[3]) {
      __pyx_v_nsmap = values[3];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4:
      __pyx_v_nsmap = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_attrib = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v__tag = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v__parent = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("SubElement", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__extra);
  __Pyx_AddTraceback("lxml.etree.SubElement");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__parent), __pyx_ptype_4lxml_5etree__Element, 0, "_parent", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2349
 *     appends it to an existing element.
 *     """
 *     return _makeSubElement(_parent, _tag, None, None, attrib, nsmap, _extra)             # <<<<<<<<<<<<<<
 * 
 * def ElementTree(_Element element=None, *, file=None, _BaseParser parser=None):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__makeSubElement(__pyx_v__parent, __pyx_v__tag, Py_None, Py_None, __pyx_v_attrib, __pyx_v_nsmap, __pyx_v__extra)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.SubElement");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__extra);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2351
 *     return _makeSubElement(_parent, _tag, None, None, attrib, nsmap, _extra)
 * 
 * def ElementTree(_Element element=None, *, file=None, _BaseParser parser=None):             # <<<<<<<<<<<<<<
 *     u"""ElementTree(element=None, file=None, parser=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_ElementTree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_ElementTree[] = "ElementTree(element=None, file=None, parser=None)\n\n    ElementTree wrapper class.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_ElementTree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_element = 0;
  PyObject *__pyx_v_file = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  xmlDoc *__pyx_v_c_doc;
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_v_result_container;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  xmlDoc *__pyx_7;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element,&__pyx_kp_file,&__pyx_kp_parser,0};
  __pyx_self = __pyx_self;
  __pyx_v_element = ((struct LxmlElement *)Py_None);
  __pyx_v_file = Py_None;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "ElementTree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_element = ((struct LxmlElement *)values[0]);
    }
    if (values[1]) {
      __pyx_v_file = values[1];
    }
    if (values[2]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[2]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ElementTree", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ElementTree");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_container = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 1, "element", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2363
 *     cdef _Document doc
 * 
 *     if element is not None:             # <<<<<<<<<<<<<<
 *         doc  = element._doc
 *     elif file is not None:
 */
  __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2364
 * 
 *     if element is not None:
 *         doc  = element._doc             # <<<<<<<<<<<<<<
 *     elif file is not None:
 *         try:
 */
    Py_INCREF(((PyObject *)__pyx_v_element->_doc));
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = __pyx_v_element->_doc;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2365
 *     if element is not None:
 *         doc  = element._doc
 *     elif file is not None:             # <<<<<<<<<<<<<<
 *         try:
 *             doc = _parseDocument(file, parser, None)
 */
  __pyx_1 = (__pyx_v_file != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2366
 *         doc  = element._doc
 *     elif file is not None:
 *         try:             # <<<<<<<<<<<<<<
 *             doc = _parseDocument(file, parser, None)
 *         except _TargetParserResult, result_container:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2367
 *     elif file is not None:
 *         try:
 *             doc = _parseDocument(file, parser, None)             # <<<<<<<<<<<<<<
 *         except _TargetParserResult, result_container:
 *             return result_container.result
 */
        __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocument(__pyx_v_file, __pyx_v_parser, Py_None)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        Py_DECREF(((PyObject *)__pyx_v_doc));
        __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
        __pyx_2 = 0;
      }
      Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L11_try;
      __pyx_L7_error:;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2368
 *         try:
 *             doc = _parseDocument(file, parser, None)
 *         except _TargetParserResult, result_container:             # <<<<<<<<<<<<<<
 *             return result_container.result
 *     else:
 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
      __pyx_3 = PyErr_ExceptionMatches(__pyx_2);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      if (__pyx_3) {
        __Pyx_AddTraceback("lxml.etree.ElementTree");
        if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        Py_INCREF(__pyx_4);
        Py_DECREF(__pyx_v_result_container);
        __pyx_v_result_container = __pyx_4;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2369
 *             doc = _parseDocument(file, parser, None)
 *         except _TargetParserResult, result_container:
 *             return result_container.result             # <<<<<<<<<<<<<<
 *     else:
 *         c_doc = _newXMLDoc()
 */
        __pyx_6 = PyObject_GetAttr(__pyx_v_result_container, __pyx_kp_result); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        __pyx_r = __pyx_6;
        __pyx_6 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L10_except_return;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L8_exception_handled;
      }
      __pyx_L9_except_error:;
      Py_XDECREF(__pyx_save_exc_type);
      Py_XDECREF(__pyx_save_exc_value);
      Py_XDECREF(__pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L10_except_return:;
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L0;
      __pyx_L8_exception_handled:;
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L11_try:;
    }
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2371
 *             return result_container.result
 *     else:
 *         c_doc = _newXMLDoc()             # <<<<<<<<<<<<<<
 *         doc = _documentFactory(c_doc, parser)
 * 
 */
    __pyx_7 = __pyx_f_4lxml_5etree__newXMLDoc(); if (unlikely(__pyx_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_doc = __pyx_7;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2372
 *     else:
 *         c_doc = _newXMLDoc()
 *         doc = _documentFactory(c_doc, parser)             # <<<<<<<<<<<<<<
 * 
 *     return _elementTreeFactory(doc, element)
 */
    __pyx_6 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, __pyx_v_parser)); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlDocument *)__pyx_6);
    __pyx_6 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2374
 *         doc = _documentFactory(c_doc, parser)
 * 
 *     return _elementTreeFactory(doc, element)             # <<<<<<<<<<<<<<
 * 
 * def HTML(text, _BaseParser parser=None, *, base_url=None):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(__pyx_v_doc, __pyx_v_element)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree.ElementTree");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_result_container);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2376
 *     return _elementTreeFactory(doc, element)
 * 
 * def HTML(text, _BaseParser parser=None, *, base_url=None):             # <<<<<<<<<<<<<<
 *     u"""HTML(text, parser=None, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_HTML(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_HTML[] = "HTML(text, parser=None, base_url=None)\n\n    Parses an HTML document from a string constant. This function can be used\n    to embed \"HTML literals\" in Python code.\n\n    To override the parser with a different ``HTMLParser`` you can pass it to\n    the ``parser`` keyword argument.\n\n    The ``base_url`` keyword argument allows to set the original base URL of\n    the document to support relative Paths when looking up external entities\n    (DTD, XInclude, ...).\n    ";
static PyObject *__pyx_pf_4lxml_5etree_HTML(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_v_base_url = 0;
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_v_result_container;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_text,&__pyx_kp_parser,&__pyx_kp_base_url,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_text);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "HTML") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_text = values[0];
    if (values[1]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[1]);
    }
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 1));
      case  1: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("HTML", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.HTML");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_parser);
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_container = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2390
 *     """
 *     cdef _Document doc
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *         if not isinstance(parser, HTMLParser):
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2391
 *     cdef _Document doc
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *         if not isinstance(parser, HTMLParser):
 *             parser = __DEFAULT_HTML_PARSER
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2392
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *         if not isinstance(parser, HTMLParser):             # <<<<<<<<<<<<<<
 *             parser = __DEFAULT_HTML_PARSER
 *     try:
 */
    __pyx_1 = PyObject_TypeCheck(((PyObject *)__pyx_v_parser), ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_HTMLParser))); 
    __pyx_3 = (!__pyx_1);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2393
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *         if not isinstance(parser, HTMLParser):
 *             parser = __DEFAULT_HTML_PARSER             # <<<<<<<<<<<<<<
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)
 */
      Py_INCREF(((PyObject *)__pyx_v_4lxml_5etree___DEFAULT_HTML_PARSER));
      Py_DECREF(((PyObject *)__pyx_v_parser));
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_4lxml_5etree___DEFAULT_HTML_PARSER);
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2394
 *         if not isinstance(parser, HTMLParser):
 *             parser = __DEFAULT_HTML_PARSER
 *     try:             # <<<<<<<<<<<<<<
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2395
 *             parser = __DEFAULT_HTML_PARSER
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)             # <<<<<<<<<<<<<<
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__parseMemoryDocument(__pyx_v_text, __pyx_v_base_url, __pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2395; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2396
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()             # <<<<<<<<<<<<<<
 *     except _TargetParserResult, result_container:
 *         return result_container.result
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->getroot(__pyx_v_doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try;
    __pyx_L8_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2397
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:             # <<<<<<<<<<<<<<
 *         return result_container.result
 * 
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
    __pyx_4 = PyErr_ExceptionMatches(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_4) {
      __Pyx_AddTraceback("lxml.etree.HTML");
      if (__Pyx_GetException(&__pyx_2, &__pyx_5, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_result_container);
      __pyx_v_result_container = __pyx_5;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2398
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:
 *         return result_container.result             # <<<<<<<<<<<<<<
 * 
 * def XML(text, _BaseParser parser=None, *, base_url=None):
 */
      __pyx_7 = PyObject_GetAttr(__pyx_v_result_container, __pyx_kp_result); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __pyx_r = __pyx_7;
      __pyx_7 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      goto __pyx_L11_except_return;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      goto __pyx_L9_exception_handled;
    }
    __pyx_L10_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L11_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L9_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree.HTML");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_result_container);
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2400
 *         return result_container.result
 * 
 * def XML(text, _BaseParser parser=None, *, base_url=None):             # <<<<<<<<<<<<<<
 *     u"""XML(text, parser=None, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_XML(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_XML[] = "XML(text, parser=None, base_url=None)\n\n    Parses an XML document from a string constant. This function can be used\n    to embed \"XML literals\" in Python code, like in\n\n       >>> root = etree.XML(\"<root><test/></root>\")\n\n    To override the parser with a different ``XMLParser`` you can pass it to\n    the ``parser`` keyword argument.\n\n    The ``base_url`` keyword argument allows to set the original base URL of\n    the document to support relative Paths when looking up external entities\n    (DTD, XInclude, ...).\n    ";
static PyObject *__pyx_pf_4lxml_5etree_XML(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_v_base_url = 0;
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_v_result_container;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_text,&__pyx_kp_parser,&__pyx_kp_base_url,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_text);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "XML") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_text = values[0];
    if (values[1]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[1]);
    }
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 1));
      case  1: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("XML", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2400; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XML");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_parser);
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_container = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2416
 *     """
 *     cdef _Document doc
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *         if not isinstance(parser, XMLParser):
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2417
 *     cdef _Document doc
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *         if not isinstance(parser, XMLParser):
 *             parser = __DEFAULT_XML_PARSER
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2418
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *         if not isinstance(parser, XMLParser):             # <<<<<<<<<<<<<<
 *             parser = __DEFAULT_XML_PARSER
 *     try:
 */
    __pyx_1 = PyObject_TypeCheck(((PyObject *)__pyx_v_parser), ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XMLParser))); 
    __pyx_3 = (!__pyx_1);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2419
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *         if not isinstance(parser, XMLParser):
 *             parser = __DEFAULT_XML_PARSER             # <<<<<<<<<<<<<<
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)
 */
      Py_INCREF(((PyObject *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER));
      Py_DECREF(((PyObject *)__pyx_v_parser));
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER);
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2420
 *         if not isinstance(parser, XMLParser):
 *             parser = __DEFAULT_XML_PARSER
 *     try:             # <<<<<<<<<<<<<<
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2421
 *             parser = __DEFAULT_XML_PARSER
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)             # <<<<<<<<<<<<<<
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__parseMemoryDocument(__pyx_v_text, __pyx_v_base_url, __pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2421; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2422
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()             # <<<<<<<<<<<<<<
 *     except _TargetParserResult, result_container:
 *         return result_container.result
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->getroot(__pyx_v_doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2422; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L12_try;
    __pyx_L8_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2423
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:             # <<<<<<<<<<<<<<
 *         return result_container.result
 * 
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2423; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
    __pyx_4 = PyErr_ExceptionMatches(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_4) {
      __Pyx_AddTraceback("lxml.etree.XML");
      if (__Pyx_GetException(&__pyx_2, &__pyx_5, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2423; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_result_container);
      __pyx_v_result_container = __pyx_5;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2424
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:
 *         return result_container.result             # <<<<<<<<<<<<<<
 * 
 * def fromstring(text, _BaseParser parser=None, *, base_url=None):
 */
      __pyx_7 = PyObject_GetAttr(__pyx_v_result_container, __pyx_kp_result); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2424; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __pyx_r = __pyx_7;
      __pyx_7 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      goto __pyx_L11_except_return;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      goto __pyx_L9_exception_handled;
    }
    __pyx_L10_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L11_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L9_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L12_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree.XML");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_result_container);
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2426
 *         return result_container.result
 * 
 * def fromstring(text, _BaseParser parser=None, *, base_url=None):             # <<<<<<<<<<<<<<
 *     u"""fromstring(text, parser=None, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_fromstring(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_fromstring[] = "fromstring(text, parser=None, base_url=None)\n\n    Parses an XML document from a string.\n\n    To override the default parser with a different parser you can pass it to\n    the ``parser`` keyword argument.\n\n    The ``base_url`` keyword argument allows to set the original base URL of\n    the document to support relative Paths when looking up external entities\n    (DTD, XInclude, ...).\n    ";
static PyObject *__pyx_pf_4lxml_5etree_fromstring(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_v_base_url = 0;
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_v_result_container;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_text,&__pyx_kp_parser,&__pyx_kp_base_url,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_text);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fromstring") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2426; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_text = values[0];
    if (values[1]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[1]);
    }
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 1));
      case  1: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fromstring", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2426; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.fromstring");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_container = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2439
 *     """
 *     cdef _Document doc
 *     try:             # <<<<<<<<<<<<<<
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2440
 *     cdef _Document doc
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)             # <<<<<<<<<<<<<<
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:
 */
      __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__parseMemoryDocument(__pyx_v_text, __pyx_v_base_url, __pyx_v_parser)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2441
 *     try:
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()             # <<<<<<<<<<<<<<
 *     except _TargetParserResult, result_container:
 *         return result_container.result
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->getroot(__pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __pyx_r = __pyx_1;
      __pyx_1 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2442
 *         doc = _parseMemoryDocument(text, base_url, parser)
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:             # <<<<<<<<<<<<<<
 *         return result_container.result
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
    __pyx_2 = PyErr_ExceptionMatches(__pyx_1);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree.fromstring");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_INCREF(__pyx_3);
      Py_DECREF(__pyx_v_result_container);
      __pyx_v_result_container = __pyx_3;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2443
 *         return doc.getroot()
 *     except _TargetParserResult, result_container:
 *         return result_container.result             # <<<<<<<<<<<<<<
 * 
 * def fromstringlist(strings, _BaseParser parser=None):
 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_result_container, __pyx_kp_result); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2443; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __pyx_r = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L9_except_return;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.fromstring");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_result_container);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2445
 *         return result_container.result
 * 
 * def fromstringlist(strings, _BaseParser parser=None):             # <<<<<<<<<<<<<<
 *     u"""fromstringlist(strings, parser=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_fromstringlist(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_fromstringlist[] = "fromstringlist(strings, parser=None)\n\n    Parses an XML document from a sequence of strings.\n\n    To override the default parser with a different parser you can pass it to\n    the ``parser`` keyword argument.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_fromstringlist(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_strings = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_v_feed;
  PyObject *__pyx_v_data;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_strings,&__pyx_kp_parser,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_strings);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fromstringlist") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_strings = values[0];
    if (values[1]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[1]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 1));
      case  1: __pyx_v_strings = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fromstringlist", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.fromstringlist");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_parser);
  __pyx_v_feed = Py_None; Py_INCREF(Py_None);
  __pyx_v_data = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2454
 *     """
 *     cdef _Document doc
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     feed = parser.feed
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2455
 *     cdef _Document doc
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *     feed = parser.feed
 *     for data in strings:
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2456
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     feed = parser.feed             # <<<<<<<<<<<<<<
 *     for data in strings:
 *         feed(data)
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_parser), __pyx_kp_feed); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_feed);
  __pyx_v_feed = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2457
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     feed = parser.feed
 *     for data in strings:             # <<<<<<<<<<<<<<
 *         feed(data)
 *     return parser.close()
 */
  if (PyList_CheckExact(__pyx_v_strings) || PyTuple_CheckExact(__pyx_v_strings)) {
    __pyx_3 = 0; __pyx_2 = __pyx_v_strings; Py_INCREF(__pyx_2);
  } else {
    __pyx_3 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_strings); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_2);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_data);
    __pyx_v_data = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2458
 *     feed = parser.feed
 *     for data in strings:
 *         feed(data)             # <<<<<<<<<<<<<<
 *     return parser.close()
 * 
 */
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_data);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_data);
    __pyx_5 = PyObject_Call(__pyx_v_feed, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2459
 *     for data in strings:
 *         feed(data)
 *     return parser.close()             # <<<<<<<<<<<<<<
 * 
 * def iselement(element):
 */
  __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_parser), __pyx_kp_close); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.fromstringlist");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_feed);
  Py_DECREF(__pyx_v_data);
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2461
 *     return parser.close()
 * 
 * def iselement(element):             # <<<<<<<<<<<<<<
 *     u"""iselement(element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_iselement(PyObject *__pyx_self, PyObject *__pyx_v_element); /*proto*/
static char __pyx_doc_4lxml_5etree_iselement[] = "iselement(element)\n\n    Checks if an object appears to be a valid element object.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_iselement(PyObject *__pyx_self, PyObject *__pyx_v_element) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_self = __pyx_self;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2466
 *     Checks if an object appears to be a valid element object.
 *     """
 *     return isinstance(element, _Element)             # <<<<<<<<<<<<<<
 * 
 * def dump(_Element elem not None, *, pretty_print=True, with_tail=True):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  __pyx_2 = __Pyx_PyBool_FromLong(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.iselement");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2468
 *     return isinstance(element, _Element)
 * 
 * def dump(_Element elem not None, *, pretty_print=True, with_tail=True):             # <<<<<<<<<<<<<<
 *     u"""dump(elem, pretty_print=True, with_tail=True)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_dump(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_dump[] = "dump(elem, pretty_print=True, with_tail=True)\n\n    Writes an element tree or element structure to sys.stdout. This function\n    should be used for debugging only.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_dump(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_elem = 0;
  PyObject *__pyx_v_pretty_print = 0;
  PyObject *__pyx_v_with_tail = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_elem,&__pyx_kp_pretty_print,&__pyx_kp_with_tail,0};
  __pyx_self = __pyx_self;
  __pyx_v_pretty_print = __pyx_k_80;
  __pyx_v_with_tail = __pyx_k_81;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_elem);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "dump") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_elem = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_pretty_print = values[1];
    }
    if (values[2]) {
      __pyx_v_with_tail = values[2];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_elem = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("dump", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.dump");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_elem), __pyx_ptype_4lxml_5etree__Element, 0, "elem", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2474
 *     should be used for debugging only.
 *     """
 *     _dumpToFile(sys.stdout, elem._c_node, pretty_print, with_tail)             # <<<<<<<<<<<<<<
 * 
 * def tostring(element_or_tree, *, encoding=None, method=u"xml",
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree_sys, __pyx_kp_stdout); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_pretty_print); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely((__pyx_3 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = __pyx_f_4lxml_5etree__dumpToFile(__pyx_1, __pyx_v_elem->_c_node, __pyx_2, __pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.dump");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2476
 *     _dumpToFile(sys.stdout, elem._c_node, pretty_print, with_tail)
 * 
 * def tostring(element_or_tree, *, encoding=None, method=u"xml",             # <<<<<<<<<<<<<<
 *              xml_declaration=None, pretty_print=False, with_tail=True):
 *     u"""tostring(element_or_tree, encoding=None, method="xml",
 */

static PyObject *__pyx_pf_4lxml_5etree_tostring(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_tostring[] = "tostring(element_or_tree, encoding=None, method=\"xml\",\n                xml_declaration=None, pretty_print=False, with_tail=True)\n\n    Serialize an element to an encoded string representation of its XML\n    tree.\n\n    Defaults to ASCII encoding without XML declaration.  This behaviour can be\n    configured with the keyword arguments 'encoding' (string) and\n    'xml_declaration' (bool).  Note that changing the encoding to a non UTF-8\n    compatible encoding will enable a declaration by default.\n\n    You can also serialise to a Unicode string without declaration by\n    passing the ``unicode`` function as encoding.\n\n    The keyword argument 'pretty_print' (bool) enables formatted XML.\n\n    The keyword argument 'method' selects the output method: 'xml',\n    'html' or plain 'text'.\n\n    You can prevent the tail text of the element from being serialised\n    by passing the boolean ``with_tail`` option.  This has no impact\n    on the tail text of children, which will always be serialised.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_tostring(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_element_or_tree = 0;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_v_xml_declaration = 0;
  PyObject *__pyx_v_pretty_print = 0;
  PyObject *__pyx_v_with_tail = 0;
  int __pyx_v_write_declaration;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element_or_tree,&__pyx_kp_encoding,&__pyx_kp_method,&__pyx_kp_xml_declaration,&__pyx_kp_pretty_print,&__pyx_kp_with_tail,0};
  __pyx_self = __pyx_self;
  __pyx_v_encoding = Py_None;
  __pyx_v_method = ((PyObject *)__pyx_kp_82);
  __pyx_v_xml_declaration = Py_None;
  __pyx_v_pretty_print = __pyx_k_83;
  __pyx_v_with_tail = __pyx_k_84;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[6] = {0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element_or_tree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tostring") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element_or_tree = values[0];
    if (values[1]) {
      __pyx_v_encoding = values[1];
    }
    if (values[2]) {
      __pyx_v_method = values[2];
    }
    if (values[3]) {
      __pyx_v_xml_declaration = values[3];
    }
    if (values[4]) {
      __pyx_v_pretty_print = values[4];
    }
    if (values[5]) {
      __pyx_v_with_tail = values[5];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_element_or_tree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tostring", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.tostring");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_encoding);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2502
 *     """
 *     cdef bint write_declaration
 *     if encoding is _unicode:             # <<<<<<<<<<<<<<
 *         if xml_declaration:
 *             raise ValueError, \
 */
  __pyx_1 = (__pyx_v_encoding == __pyx_v_4lxml_5etree__unicode);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2503
 *     cdef bint write_declaration
 *     if encoding is _unicode:
 *         if xml_declaration:             # <<<<<<<<<<<<<<
 *             raise ValueError, \
 *                 u"Serialisation to unicode must not request an XML declaration"
 */
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_xml_declaration); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2505
 *         if xml_declaration:
 *             raise ValueError, \
 *                 u"Serialisation to unicode must not request an XML declaration"             # <<<<<<<<<<<<<<
 *         write_declaration = 0
 *     elif xml_declaration is None:
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_294), 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2506
 *             raise ValueError, \
 *                 u"Serialisation to unicode must not request an XML declaration"
 *         write_declaration = 0             # <<<<<<<<<<<<<<
 *     elif xml_declaration is None:
 *         # by default, write an XML declaration only for non-standard encodings
 */
    __pyx_v_write_declaration = 0;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2507
 *                 u"Serialisation to unicode must not request an XML declaration"
 *         write_declaration = 0
 *     elif xml_declaration is None:             # <<<<<<<<<<<<<<
 *         # by default, write an XML declaration only for non-standard encodings
 *         write_declaration = encoding is not None and encoding.upper() not in \
 */
  __pyx_1 = (__pyx_v_xml_declaration == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2509
 *     elif xml_declaration is None:
 *         # by default, write an XML declaration only for non-standard encodings
 *         write_declaration = encoding is not None and encoding.upper() not in \             # <<<<<<<<<<<<<<
 *                             (u'ASCII', u'UTF-8', u'UTF8', u'US-ASCII')
 *     else:
 */
    __pyx_1 = (__pyx_v_encoding != Py_None);
    if (__pyx_1) {
      __pyx_2 = PyObject_GetAttr(__pyx_v_encoding, __pyx_kp_upper); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_2 = __pyx_3;
      Py_INCREF(__pyx_2);
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2510
 *         # by default, write an XML declaration only for non-standard encodings
 *         write_declaration = encoding is not None and encoding.upper() not in \
 *                             (u'ASCII', u'UTF-8', u'UTF8', u'US-ASCII')             # <<<<<<<<<<<<<<
 *     else:
 *         write_declaration = xml_declaration
 */
      __pyx_3 = PyObject_RichCompare(__pyx_2, ((PyObject *)__pyx_kp_295), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = ((int)__pyx_4);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2509
 *     elif xml_declaration is None:
 *         # by default, write an XML declaration only for non-standard encodings
 *         write_declaration = encoding is not None and encoding.upper() not in \             # <<<<<<<<<<<<<<
 *                             (u'ASCII', u'UTF-8', u'UTF8', u'US-ASCII')
 *     else:
 */
        __pyx_3 = PyObject_RichCompare(__pyx_2, ((PyObject *)__pyx_kp_296), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_1 = ((int)__pyx_4);
      }
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2510
 *         # by default, write an XML declaration only for non-standard encodings
 *         write_declaration = encoding is not None and encoding.upper() not in \
 *                             (u'ASCII', u'UTF-8', u'UTF8', u'US-ASCII')             # <<<<<<<<<<<<<<
 *     else:
 *         write_declaration = xml_declaration
 */
        __pyx_3 = PyObject_RichCompare(__pyx_2, ((PyObject *)__pyx_kp_297), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_1 = ((int)__pyx_4);
      }
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2509
 *     elif xml_declaration is None:
 *         # by default, write an XML declaration only for non-standard encodings
 *         write_declaration = encoding is not None and encoding.upper() not in \             # <<<<<<<<<<<<<<
 *                             (u'ASCII', u'UTF-8', u'UTF8', u'US-ASCII')
 *     else:
 */
        __pyx_3 = PyObject_RichCompare(__pyx_2, ((PyObject *)__pyx_kp_298), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_1 = ((int)__pyx_4);
      }
    }
    __pyx_v_write_declaration = __pyx_1;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2512
 *                             (u'ASCII', u'UTF-8', u'UTF8', u'US-ASCII')
 *     else:
 *         write_declaration = xml_declaration             # <<<<<<<<<<<<<<
 *     if encoding is None:
 *         encoding = u'ASCII'
 */
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_xml_declaration); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_write_declaration = __pyx_4;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2513
 *     else:
 *         write_declaration = xml_declaration
 *     if encoding is None:             # <<<<<<<<<<<<<<
 *         encoding = u'ASCII'
 * 
 */
  __pyx_1 = (__pyx_v_encoding == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2514
 *         write_declaration = xml_declaration
 *     if encoding is None:
 *         encoding = u'ASCII'             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(element_or_tree, _Element):
 */
    Py_INCREF(((PyObject *)__pyx_kp_299));
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = ((PyObject *)__pyx_kp_299);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2516
 *         encoding = u'ASCII'
 * 
 *     if isinstance(element_or_tree, _Element):             # <<<<<<<<<<<<<<
 *         return _tostring(<_Element>element_or_tree, encoding, method,
 *                          write_declaration, 0, pretty_print, with_tail)
 */
  __pyx_4 = PyObject_TypeCheck(__pyx_v_element_or_tree, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2518
 *     if isinstance(element_or_tree, _Element):
 *         return _tostring(<_Element>element_or_tree, encoding, method,
 *                          write_declaration, 0, pretty_print, with_tail)             # <<<<<<<<<<<<<<
 *     elif isinstance(element_or_tree, _ElementTree):
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 */
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_pretty_print); if (unlikely((__pyx_1 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __pyx_f_4lxml_5etree__tostring(((struct LxmlElement *)__pyx_v_element_or_tree), __pyx_v_encoding, __pyx_v_method, __pyx_v_write_declaration, 0, __pyx_1, __pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2519
 *         return _tostring(<_Element>element_or_tree, encoding, method,
 *                          write_declaration, 0, pretty_print, with_tail)
 *     elif isinstance(element_or_tree, _ElementTree):             # <<<<<<<<<<<<<<
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 *                          encoding, method, write_declaration, 1, pretty_print,
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element_or_tree, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2521
 *     elif isinstance(element_or_tree, _ElementTree):
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 *                          encoding, method, write_declaration, 1, pretty_print,             # <<<<<<<<<<<<<<
 *                          with_tail)
 *     else:
 */
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_pretty_print); if (unlikely((__pyx_4 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2522
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 *                          encoding, method, write_declaration, 1, pretty_print,
 *                          with_tail)             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Type '%s' cannot be serialized." % \
 */
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely((__pyx_1 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__tostring(((struct LxmlElementTree *)__pyx_v_element_or_tree)->_context_node, __pyx_v_encoding, __pyx_v_method, __pyx_v_write_declaration, 1, __pyx_4, __pyx_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2525
 *     else:
 *         raise TypeError, u"Type '%s' cannot be serialized." % \
 *             python._fqtypename(element_or_tree)             # <<<<<<<<<<<<<<
 * 
 * def tostringlist(element_or_tree, *args, **kwargs):
 */
    __pyx_2 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_element_or_tree)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_300), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L9:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.tostring");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2527
 *             python._fqtypename(element_or_tree)
 * 
 * def tostringlist(element_or_tree, *args, **kwargs):             # <<<<<<<<<<<<<<
 *     u"""tostringlist(element_or_tree, *args, **kwargs)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_tostringlist(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_tostringlist[] = "tostringlist(element_or_tree, *args, **kwargs)\n\n    Serialize an element to an encoded string representation of its XML\n    tree, stored in a list of partial strings.\n\n    This is purely for ElementTree 1.3 compatibility.  The result is a\n    single string wrapped in a list.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_tostringlist(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_element_or_tree = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element_or_tree,0};
  __pyx_self = __pyx_self;
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); 
    if (unlikely(!__pyx_v_args)) {
      Py_DECREF(__pyx_v_kwargs);
      return NULL;
    }
  } else {
    __pyx_v_args = __pyx_empty_tuple; Py_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element_or_tree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "tostringlist") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element_or_tree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_element_or_tree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tostringlist", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2527; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v_args);
  Py_DECREF(__pyx_v_kwargs);
  __Pyx_AddTraceback("lxml.etree.tostringlist");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2536
 *     single string wrapped in a list.
 *     """
 *     return [tostring(element_or_tree, *args, **kwargs)]             # <<<<<<<<<<<<<<
 * 
 * def tounicode(element_or_tree, *, method=u"xml", pretty_print=False,
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_tostring); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_element_or_tree);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_element_or_tree);
  __pyx_3 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_2), __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_t_1, __pyx_v_kwargs); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyList_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_r = ((PyObject *)__pyx_3);
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.tostringlist");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_args);
  Py_DECREF(__pyx_v_kwargs);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2538
 *     return [tostring(element_or_tree, *args, **kwargs)]
 * 
 * def tounicode(element_or_tree, *, method=u"xml", pretty_print=False,             # <<<<<<<<<<<<<<
 *               with_tail=True):
 *     u"""tounicode(element_or_tree, method="xml", pretty_print=False,
 */

static PyObject *__pyx_pf_4lxml_5etree_tounicode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_tounicode[] = "tounicode(element_or_tree, method=\"xml\", pretty_print=False,\n                 with_tail=True)\n\n    Serialize an element to the Python unicode representation of its XML\n    tree.\n\n    Note that the result does not carry an XML encoding declaration and is\n    therefore not necessarily suited for serialization to byte streams without\n    further treatment.\n\n    The boolean keyword argument 'pretty_print' enables formatted XML.\n\n    The keyword argument 'method' selects the output method: 'xml',\n    'html' or plain 'text'.\n\n    You can prevent the tail text of the element from being serialised\n    by passing the boolean ``with_tail`` option.  This has no impact\n    on the tail text of children, which will always be serialised.\n\n    :deprecated: use ``tostring(el, encoding=unicode)`` instead.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_tounicode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_element_or_tree = 0;
  PyObject *__pyx_v_method = 0;
  PyObject *__pyx_v_pretty_print = 0;
  PyObject *__pyx_v_with_tail = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element_or_tree,&__pyx_kp_method,&__pyx_kp_pretty_print,&__pyx_kp_with_tail,0};
  __pyx_self = __pyx_self;
  __pyx_v_method = ((PyObject *)__pyx_kp_85);
  __pyx_v_pretty_print = __pyx_k_86;
  __pyx_v_with_tail = __pyx_k_87;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element_or_tree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tounicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element_or_tree = values[0];
    if (values[1]) {
      __pyx_v_method = values[1];
    }
    if (values[2]) {
      __pyx_v_pretty_print = values[2];
    }
    if (values[3]) {
      __pyx_v_with_tail = values[3];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_element_or_tree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tounicode", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.tounicode");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2561
 *     :deprecated: use ``tostring(el, encoding=unicode)`` instead.
 *     """
 *     if isinstance(element_or_tree, _Element):             # <<<<<<<<<<<<<<
 *         return _tostring(<_Element>element_or_tree, _unicode, method,
 *                           0, 0, pretty_print, with_tail)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element_or_tree, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2563
 *     if isinstance(element_or_tree, _Element):
 *         return _tostring(<_Element>element_or_tree, _unicode, method,
 *                           0, 0, pretty_print, with_tail)             # <<<<<<<<<<<<<<
 *     elif isinstance(element_or_tree, _ElementTree):
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 */
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_pretty_print); if (unlikely((__pyx_1 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__tostring(((struct LxmlElement *)__pyx_v_element_or_tree), __pyx_v_4lxml_5etree__unicode, __pyx_v_method, 0, 0, __pyx_1, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2564
 *         return _tostring(<_Element>element_or_tree, _unicode, method,
 *                           0, 0, pretty_print, with_tail)
 *     elif isinstance(element_or_tree, _ElementTree):             # <<<<<<<<<<<<<<
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 *                          _unicode, method, 0, 1, pretty_print, with_tail)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element_or_tree, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2566
 *     elif isinstance(element_or_tree, _ElementTree):
 *         return _tostring((<_ElementTree>element_or_tree)._context_node,
 *                          _unicode, method, 0, 1, pretty_print, with_tail)             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Type '%s' cannot be serialized." % \
 */
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_pretty_print); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_with_tail); if (unlikely((__pyx_1 == (int)-1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__tostring(((struct LxmlElementTree *)__pyx_v_element_or_tree)->_context_node, __pyx_v_4lxml_5etree__unicode, __pyx_v_method, 0, 1, __pyx_2, __pyx_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2569
 *     else:
 *         raise TypeError, u"Type '%s' cannot be serialized." % \
 *             type(element_or_tree)             # <<<<<<<<<<<<<<
 * 
 * def parse(source, _BaseParser parser=None, *, base_url=None):
 */
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_element_or_tree);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_element_or_tree);
    __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)&PyType_Type)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_301), __pyx_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.tounicode");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2571
 *             type(element_or_tree)
 * 
 * def parse(source, _BaseParser parser=None, *, base_url=None):             # <<<<<<<<<<<<<<
 *     u"""parse(source, parser=None, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_parse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_parse[] = "parse(source, parser=None, base_url=None)\n\n    Return an ElementTree object loaded with source elements.  If no parser\n    is provided as second argument, the default parser is used.\n\n    The ``base_url`` keyword allows setting a URL for the document\n    when parsing from a file-like object.  This is needed when looking\n    up external entities (DTD, XInclude, ...) with relative paths.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_parse(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_source = 0;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_v_base_url = 0;
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_v_result_container;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_source,&__pyx_kp_parser,&__pyx_kp_base_url,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_source);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parse") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_source = values[0];
    if (values[1]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[1]);
    }
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 1));
      case  1: __pyx_v_source = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("parse", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.parse");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_container = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2582
 *     """
 *     cdef _Document doc
 *     try:             # <<<<<<<<<<<<<<
 *         doc = _parseDocument(source, parser, base_url)
 *         return _elementTreeFactory(doc, None)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2583
 *     cdef _Document doc
 *     try:
 *         doc = _parseDocument(source, parser, base_url)             # <<<<<<<<<<<<<<
 *         return _elementTreeFactory(doc, None)
 *     except _TargetParserResult, result_container:
 */
      __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocument(__pyx_v_source, __pyx_v_parser, __pyx_v_base_url)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2583; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2584
 *     try:
 *         doc = _parseDocument(source, parser, base_url)
 *         return _elementTreeFactory(doc, None)             # <<<<<<<<<<<<<<
 *     except _TargetParserResult, result_container:
 *         return result_container.result
 */
      __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(__pyx_v_doc, ((struct LxmlElement *)Py_None))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2584; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __pyx_r = __pyx_1;
      __pyx_1 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2585
 *         doc = _parseDocument(source, parser, base_url)
 *         return _elementTreeFactory(doc, None)
 *     except _TargetParserResult, result_container:             # <<<<<<<<<<<<<<
 *         return result_container.result
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
    __pyx_2 = PyErr_ExceptionMatches(__pyx_1);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree.parse");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_INCREF(__pyx_3);
      Py_DECREF(__pyx_v_result_container);
      __pyx_v_result_container = __pyx_3;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2586
 *         return _elementTreeFactory(doc, None)
 *     except _TargetParserResult, result_container:
 *         return result_container.result             # <<<<<<<<<<<<<<
 * 
 * def cleanup_namespaces(tree_or_element):
 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_result_container, __pyx_kp_result); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2586; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __pyx_r = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L9_except_return;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.parse");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_result_container);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2588
 *         return result_container.result
 * 
 * def cleanup_namespaces(tree_or_element):             # <<<<<<<<<<<<<<
 *     u"""cleanup_namespaces(tree_or_element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_cleanup_namespaces(PyObject *__pyx_self, PyObject *__pyx_v_tree_or_element); /*proto*/
static char __pyx_doc_4lxml_5etree_cleanup_namespaces[] = "cleanup_namespaces(tree_or_element)\n\n    Remove all namespace declarations from a subtree that are not used\n    by any of the elements in that tree.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_cleanup_namespaces(PyObject *__pyx_self, PyObject *__pyx_v_tree_or_element) {
  struct LxmlElement *__pyx_v_element;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_self = __pyx_self;
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2595
 *     """
 *     cdef _Element element
 *     element = _rootNodeOrRaise(tree_or_element)             # <<<<<<<<<<<<<<
 *     _removeUnusedNamespaceDeclarations(element._c_node)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_tree_or_element)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_element));
  __pyx_v_element = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2596
 *     cdef _Element element
 *     element = _rootNodeOrRaise(tree_or_element)
 *     _removeUnusedNamespaceDeclarations(element._c_node)             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  __pyx_2 = __pyx_f_4lxml_5etree__removeUnusedNamespaceDeclarations(__pyx_v_element->_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.cleanup_namespaces");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":7
 * # the Python class
 * 
 * cdef inline _Element getProxy(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"""Get a proxy for a given node.
 *     """
 */

static INLINE struct LxmlElement *__pyx_f_4lxml_5etree_getProxy(xmlNode *__pyx_v_c_node) {
  struct LxmlElement *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":11
 *     """
 *     #print "getProxy for:", <int>c_node
 *     if c_node is not NULL and c_node._private is not NULL:             # <<<<<<<<<<<<<<
 *         return <_Element>c_node._private
 *     else:
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_node->_private != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":12
 *     #print "getProxy for:", <int>c_node
 *     if c_node is not NULL and c_node._private is not NULL:
 *         return <_Element>c_node._private             # <<<<<<<<<<<<<<
 *     else:
 *         return None
 */
    Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_c_node->_private)));
    __pyx_r = ((struct LxmlElement *)__pyx_v_c_node->_private);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":14
 *         return <_Element>c_node._private
 *     else:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * cdef inline int hasProxy(xmlNode* c_node):
 */
    Py_INCREF(Py_None);
    __pyx_r = ((struct LxmlElement *)Py_None);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":16
 *         return None
 * 
 * cdef inline int hasProxy(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return c_node._private is not NULL
 * 
 */

static INLINE int __pyx_f_4lxml_5etree_hasProxy(xmlNode *__pyx_v_c_node) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":17
 * 
 * cdef inline int hasProxy(xmlNode* c_node):
 *     return c_node._private is not NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _registerProxy(_Element proxy) except -1:
 */
  __pyx_r = (__pyx_v_c_node->_private != NULL);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":19
 *     return c_node._private is not NULL
 * 
 * cdef inline int _registerProxy(_Element proxy) except -1:             # <<<<<<<<<<<<<<
 *     u"""Register a proxy and type for the node it's proxying for.
 *     """
 */

static INLINE int __pyx_f_4lxml_5etree__registerProxy(struct LxmlElement *__pyx_v_proxy) {
  xmlNode *__pyx_v_c_node;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":24
 *     cdef xmlNode* c_node
 *     # cannot register for NULL
 *     c_node = proxy._c_node             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         return 0
 */
  __pyx_v_c_node = __pyx_v_proxy->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":25
 *     # cannot register for NULL
 *     c_node = proxy._c_node
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return 0
 *     #print "registering for:", <int>proxy._c_node
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":26
 *     c_node = proxy._c_node
 *     if c_node is NULL:
 *         return 0             # <<<<<<<<<<<<<<
 *     #print "registering for:", <int>proxy._c_node
 *     assert c_node._private is NULL, u"double registering proxy!"
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":28
 *         return 0
 *     #print "registering for:", <int>proxy._c_node
 *     assert c_node._private is NULL, u"double registering proxy!"             # <<<<<<<<<<<<<<
 *     c_node._private = <void*>proxy
 *     # additional INCREF to make sure _Document is GC-ed LAST!
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_c_node->_private == NULL))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_302));
    {__pyx_filename = __pyx_f[6]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":29
 *     #print "registering for:", <int>proxy._c_node
 *     assert c_node._private is NULL, u"double registering proxy!"
 *     c_node._private = <void*>proxy             # <<<<<<<<<<<<<<
 *     # additional INCREF to make sure _Document is GC-ed LAST!
 *     proxy._gc_doc = <python.PyObject*>proxy._doc
 */
  __pyx_v_c_node->_private = ((void *)__pyx_v_proxy);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":31
 *     c_node._private = <void*>proxy
 *     # additional INCREF to make sure _Document is GC-ed LAST!
 *     proxy._gc_doc = <python.PyObject*>proxy._doc             # <<<<<<<<<<<<<<
 *     python.Py_INCREF(proxy._doc)
 * 
 */
  __pyx_v_proxy->_gc_doc = ((PyObject *)__pyx_v_proxy->_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":32
 *     # additional INCREF to make sure _Document is GC-ed LAST!
 *     proxy._gc_doc = <python.PyObject*>proxy._doc
 *     python.Py_INCREF(proxy._doc)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _unregisterProxy(_Element proxy) except -1:
 */
  Py_INCREF(((PyObject *)__pyx_v_proxy->_doc));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._registerProxy");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":34
 *     python.Py_INCREF(proxy._doc)
 * 
 * cdef inline int _unregisterProxy(_Element proxy) except -1:             # <<<<<<<<<<<<<<
 *     u"""Unregister a proxy for the node it's proxying for.
 *     """
 */

static INLINE int __pyx_f_4lxml_5etree__unregisterProxy(struct LxmlElement *__pyx_v_proxy) {
  xmlNode *__pyx_v_c_node;
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":38
 *     """
 *     cdef xmlNode* c_node
 *     c_node = proxy._c_node             # <<<<<<<<<<<<<<
 *     assert c_node._private is <void*>proxy, u"Tried to unregister unknown proxy"
 *     c_node._private = NULL
 */
  __pyx_v_c_node = __pyx_v_proxy->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":39
 *     cdef xmlNode* c_node
 *     c_node = proxy._c_node
 *     assert c_node._private is <void*>proxy, u"Tried to unregister unknown proxy"             # <<<<<<<<<<<<<<
 *     c_node._private = NULL
 *     return 0
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_c_node->_private == ((void *)__pyx_v_proxy)))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_303));
    {__pyx_filename = __pyx_f[6]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":40
 *     c_node = proxy._c_node
 *     assert c_node._private is <void*>proxy, u"Tried to unregister unknown proxy"
 *     c_node._private = NULL             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  __pyx_v_c_node->_private = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":41
 *     assert c_node._private is <void*>proxy, u"Tried to unregister unknown proxy"
 *     c_node._private = NULL
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline void _releaseProxy(_Element proxy):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._unregisterProxy");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":43
 *     return 0
 * 
 * cdef inline void _releaseProxy(_Element proxy):             # <<<<<<<<<<<<<<
 *     u"""An additional DECREF for the document.
 *     """
 */

static INLINE void __pyx_f_4lxml_5etree__releaseProxy(struct LxmlElement *__pyx_v_proxy) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":46
 *     u"""An additional DECREF for the document.
 *     """
 *     python.Py_XDECREF(proxy._gc_doc)             # <<<<<<<<<<<<<<
 *     proxy._gc_doc = NULL
 * 
 */
  Py_XDECREF(__pyx_v_proxy->_gc_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":47
 *     """
 *     python.Py_XDECREF(proxy._gc_doc)
 *     proxy._gc_doc = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline _Document _updateProxyDocument(xmlNode* c_node, _Document doc):
 */
  __pyx_v_proxy->_gc_doc = NULL;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":49
 *     proxy._gc_doc = NULL
 * 
 * cdef inline _Document _updateProxyDocument(xmlNode* c_node, _Document doc):             # <<<<<<<<<<<<<<
 *     u"""Replace the document reference of a proxy.
 * 
 */

static INLINE struct LxmlDocument *__pyx_f_4lxml_5etree__updateProxyDocument(xmlNode *__pyx_v_c_node, struct LxmlDocument *__pyx_v_doc) {
  struct LxmlDocument *__pyx_v_old_doc = 0;
  struct LxmlElement *__pyx_v_element = 0;
  struct LxmlDocument *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":54
 *     This may deallocate the original document of the proxy!
 *     """
 *     cdef _Document old_doc = None             # <<<<<<<<<<<<<<
 *     cdef _Element element = <_Element>c_node._private
 *     if element._doc is not doc:
 */
  Py_INCREF(Py_None);
  __pyx_v_old_doc = ((struct LxmlDocument *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":55
 *     """
 *     cdef _Document old_doc = None
 *     cdef _Element element = <_Element>c_node._private             # <<<<<<<<<<<<<<
 *     if element._doc is not doc:
 *         old_doc = element._doc
 */
  Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_c_node->_private)));
  __pyx_v_element = ((struct LxmlElement *)__pyx_v_c_node->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":56
 *     cdef _Document old_doc = None
 *     cdef _Element element = <_Element>c_node._private
 *     if element._doc is not doc:             # <<<<<<<<<<<<<<
 *         old_doc = element._doc
 *         element._doc = doc
 */
  __pyx_1 = (__pyx_v_element->_doc != __pyx_v_doc);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":57
 *     cdef _Element element = <_Element>c_node._private
 *     if element._doc is not doc:
 *         old_doc = element._doc             # <<<<<<<<<<<<<<
 *         element._doc = doc
 *         python.Py_INCREF(doc)
 */
    Py_INCREF(((PyObject *)__pyx_v_element->_doc));
    Py_DECREF(((PyObject *)__pyx_v_old_doc));
    __pyx_v_old_doc = __pyx_v_element->_doc;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":58
 *     if element._doc is not doc:
 *         old_doc = element._doc
 *         element._doc = doc             # <<<<<<<<<<<<<<
 *         python.Py_INCREF(doc)
 *         element._gc_doc = <python.PyObject*>doc
 */
    Py_INCREF(((PyObject *)__pyx_v_doc));
    Py_DECREF(((PyObject *)__pyx_v_element->_doc));
    __pyx_v_element->_doc = __pyx_v_doc;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":59
 *         old_doc = element._doc
 *         element._doc = doc
 *         python.Py_INCREF(doc)             # <<<<<<<<<<<<<<
 *         element._gc_doc = <python.PyObject*>doc
 *         python.Py_DECREF(old_doc)
 */
    Py_INCREF(((PyObject *)__pyx_v_doc));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":60
 *         element._doc = doc
 *         python.Py_INCREF(doc)
 *         element._gc_doc = <python.PyObject*>doc             # <<<<<<<<<<<<<<
 *         python.Py_DECREF(old_doc)
 *     return old_doc
 */
    __pyx_v_element->_gc_doc = ((PyObject *)__pyx_v_doc);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":61
 *         python.Py_INCREF(doc)
 *         element._gc_doc = <python.PyObject*>doc
 *         python.Py_DECREF(old_doc)             # <<<<<<<<<<<<<<
 *     return old_doc
 * 
 */
    Py_DECREF(((PyObject *)__pyx_v_old_doc));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":62
 *         element._gc_doc = <python.PyObject*>doc
 *         python.Py_DECREF(old_doc)
 *     return old_doc             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  Py_INCREF(((PyObject *)__pyx_v_old_doc));
  __pyx_r = __pyx_v_old_doc;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_L0:;
  Py_XDECREF(__pyx_v_old_doc);
  Py_XDECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":67
 * # temporarily make a node the root node of its document
 * 
 * cdef xmlDoc* _fakeRootDoc(xmlDoc* c_base_doc, xmlNode* c_node) except NULL:             # <<<<<<<<<<<<<<
 *     # build a temporary document that has the given node as root node
 *     # note that copy and original must not be modified during its lifetime!!
 */

static  xmlDoc *__pyx_f_4lxml_5etree__fakeRootDoc(xmlDoc *__pyx_v_c_base_doc, xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_v_c_child;
  xmlNode *__pyx_v_c_root;
  xmlNode *__pyx_v_c_new_root;
  xmlDoc *__pyx_v_c_doc;
  xmlDoc *__pyx_r;
  int __pyx_1;
  xmlDoc *__pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":75
 *     cdef xmlNode* c_new_root
 *     cdef xmlDoc*  c_doc
 *     c_root = tree.xmlDocGetRootElement(c_base_doc)             # <<<<<<<<<<<<<<
 *     if c_root is c_node:
 *         # already the root node
 */
  __pyx_v_c_root = xmlDocGetRootElement(__pyx_v_c_base_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":76
 *     cdef xmlDoc*  c_doc
 *     c_root = tree.xmlDocGetRootElement(c_base_doc)
 *     if c_root is c_node:             # <<<<<<<<<<<<<<
 *         # already the root node
 *         return c_base_doc
 */
  __pyx_1 = (__pyx_v_c_root == __pyx_v_c_node);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":78
 *     if c_root is c_node:
 *         # already the root node
 *         return c_base_doc             # <<<<<<<<<<<<<<
 * 
 *     c_doc  = _copyDoc(c_base_doc, 0)                   # non recursive!
 */
    __pyx_r = __pyx_v_c_base_doc;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":80
 *         return c_base_doc
 * 
 *     c_doc  = _copyDoc(c_base_doc, 0)                   # non recursive!             # <<<<<<<<<<<<<<
 *     c_new_root = tree.xmlDocCopyNode(c_node, c_doc, 2) # non recursive!
 *     tree.xmlDocSetRootElement(c_doc, c_new_root)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__copyDoc(__pyx_v_c_base_doc, 0); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":81
 * 
 *     c_doc  = _copyDoc(c_base_doc, 0)                   # non recursive!
 *     c_new_root = tree.xmlDocCopyNode(c_node, c_doc, 2) # non recursive!             # <<<<<<<<<<<<<<
 *     tree.xmlDocSetRootElement(c_doc, c_new_root)
 *     _copyParentNamespaces(c_node, c_new_root)
 */
  __pyx_v_c_new_root = xmlDocCopyNode(__pyx_v_c_node, __pyx_v_c_doc, 2);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":82
 *     c_doc  = _copyDoc(c_base_doc, 0)                   # non recursive!
 *     c_new_root = tree.xmlDocCopyNode(c_node, c_doc, 2) # non recursive!
 *     tree.xmlDocSetRootElement(c_doc, c_new_root)             # <<<<<<<<<<<<<<
 *     _copyParentNamespaces(c_node, c_new_root)
 * 
 */
  xmlDocSetRootElement(__pyx_v_c_doc, __pyx_v_c_new_root);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":83
 *     c_new_root = tree.xmlDocCopyNode(c_node, c_doc, 2) # non recursive!
 *     tree.xmlDocSetRootElement(c_doc, c_new_root)
 *     _copyParentNamespaces(c_node, c_new_root)             # <<<<<<<<<<<<<<
 * 
 *     c_new_root.children = c_node.children
 */
  __pyx_f_4lxml_5etree__copyParentNamespaces(__pyx_v_c_node, __pyx_v_c_new_root);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":85
 *     _copyParentNamespaces(c_node, c_new_root)
 * 
 *     c_new_root.children = c_node.children             # <<<<<<<<<<<<<<
 *     c_new_root.last = c_node.last
 *     c_new_root.next = c_new_root.prev = NULL
 */
  __pyx_v_c_new_root->children = __pyx_v_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":86
 * 
 *     c_new_root.children = c_node.children
 *     c_new_root.last = c_node.last             # <<<<<<<<<<<<<<
 *     c_new_root.next = c_new_root.prev = NULL
 * 
 */
  __pyx_v_c_new_root->last = __pyx_v_c_node->last;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":87
 *     c_new_root.children = c_node.children
 *     c_new_root.last = c_node.last
 *     c_new_root.next = c_new_root.prev = NULL             # <<<<<<<<<<<<<<
 * 
 *     # store original node
 */
  __pyx_v_c_new_root->next = NULL;
  __pyx_v_c_new_root->prev = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":90
 * 
 *     # store original node
 *     c_doc._private = c_node             # <<<<<<<<<<<<<<
 * 
 *     # divert parent pointers of children
 */
  __pyx_v_c_doc->_private = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":93
 * 
 *     # divert parent pointers of children
 *     c_child = c_new_root.children             # <<<<<<<<<<<<<<
 *     while c_child is not NULL:
 *         c_child.parent = c_new_root
 */
  __pyx_v_c_child = __pyx_v_c_new_root->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":94
 *     # divert parent pointers of children
 *     c_child = c_new_root.children
 *     while c_child is not NULL:             # <<<<<<<<<<<<<<
 *         c_child.parent = c_new_root
 *         c_child = c_child.next
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_child != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":95
 *     c_child = c_new_root.children
 *     while c_child is not NULL:
 *         c_child.parent = c_new_root             # <<<<<<<<<<<<<<
 *         c_child = c_child.next
 * 
 */
    __pyx_v_c_child->parent = __pyx_v_c_new_root;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":96
 *     while c_child is not NULL:
 *         c_child.parent = c_new_root
 *         c_child = c_child.next             # <<<<<<<<<<<<<<
 * 
 *     c_doc.children = c_new_root
 */
    __pyx_v_c_child = __pyx_v_c_child->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":98
 *         c_child = c_child.next
 * 
 *     c_doc.children = c_new_root             # <<<<<<<<<<<<<<
 *     return c_doc
 * 
 */
  __pyx_v_c_doc->children = __pyx_v_c_new_root;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":99
 * 
 *     c_doc.children = c_new_root
 *     return c_doc             # <<<<<<<<<<<<<<
 * 
 * cdef void _destroyFakeDoc(xmlDoc* c_base_doc, xmlDoc* c_doc):
 */
  __pyx_r = __pyx_v_c_doc;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._fakeRootDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":101
 *     return c_doc
 * 
 * cdef void _destroyFakeDoc(xmlDoc* c_base_doc, xmlDoc* c_doc):             # <<<<<<<<<<<<<<
 *     # delete a temporary document
 *     cdef xmlNode* c_child
 */

static  void __pyx_f_4lxml_5etree__destroyFakeDoc(xmlDoc *__pyx_v_c_base_doc, xmlDoc *__pyx_v_c_doc) {
  xmlNode *__pyx_v_c_child;
  xmlNode *__pyx_v_c_parent;
  xmlNode *__pyx_v_c_root;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":106
 *     cdef xmlNode* c_parent
 *     cdef xmlNode* c_root
 *     if c_doc is c_base_doc:             # <<<<<<<<<<<<<<
 *         return
 *     c_root = tree.xmlDocGetRootElement(c_doc)
 */
  __pyx_1 = (__pyx_v_c_doc == __pyx_v_c_base_doc);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":107
 *     cdef xmlNode* c_root
 *     if c_doc is c_base_doc:
 *         return             # <<<<<<<<<<<<<<
 *     c_root = tree.xmlDocGetRootElement(c_doc)
 * 
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":108
 *     if c_doc is c_base_doc:
 *         return
 *     c_root = tree.xmlDocGetRootElement(c_doc)             # <<<<<<<<<<<<<<
 * 
 *     # restore parent pointers of children
 */
  __pyx_v_c_root = xmlDocGetRootElement(__pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":111
 * 
 *     # restore parent pointers of children
 *     c_parent = <xmlNode*>c_doc._private             # <<<<<<<<<<<<<<
 *     c_child = c_root.children
 *     while c_child is not NULL:
 */
  __pyx_v_c_parent = ((xmlNode *)__pyx_v_c_doc->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":112
 *     # restore parent pointers of children
 *     c_parent = <xmlNode*>c_doc._private
 *     c_child = c_root.children             # <<<<<<<<<<<<<<
 *     while c_child is not NULL:
 *         c_child.parent = c_parent
 */
  __pyx_v_c_child = __pyx_v_c_root->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":113
 *     c_parent = <xmlNode*>c_doc._private
 *     c_child = c_root.children
 *     while c_child is not NULL:             # <<<<<<<<<<<<<<
 *         c_child.parent = c_parent
 *         c_child = c_child.next
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_child != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":114
 *     c_child = c_root.children
 *     while c_child is not NULL:
 *         c_child.parent = c_parent             # <<<<<<<<<<<<<<
 *         c_child = c_child.next
 * 
 */
    __pyx_v_c_child->parent = __pyx_v_c_parent;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":115
 *     while c_child is not NULL:
 *         c_child.parent = c_parent
 *         c_child = c_child.next             # <<<<<<<<<<<<<<
 * 
 *     # prevent recursive removal of children
 */
    __pyx_v_c_child = __pyx_v_c_child->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":118
 * 
 *     # prevent recursive removal of children
 *     c_root.children = c_root.last = NULL             # <<<<<<<<<<<<<<
 *     tree.xmlFreeDoc(c_doc)
 * 
 */
  __pyx_v_c_root->children = NULL;
  __pyx_v_c_root->last = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":119
 *     # prevent recursive removal of children
 *     c_root.children = c_root.last = NULL
 *     tree.xmlFreeDoc(c_doc)             # <<<<<<<<<<<<<<
 * 
 * cdef _Element _fakeDocElementFactory(_Document doc, xmlNode* c_element):
 */
  xmlFreeDoc(__pyx_v_c_doc);

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":121
 *     tree.xmlFreeDoc(c_doc)
 * 
 * cdef _Element _fakeDocElementFactory(_Document doc, xmlNode* c_element):             # <<<<<<<<<<<<<<
 *     u"""Special element factory for cases where we need to create a fake
 *     root document, but still need to instantiate arbitrary nodes from
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree__fakeDocElementFactory(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_element) {
  struct LxmlElement *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":130
 *     instantiate the original node instead.
 *     """
 *     if c_element.doc is not doc._c_doc:             # <<<<<<<<<<<<<<
 *         if c_element.doc._private is not NULL:
 *             if c_element is c_element.doc.children:
 */
  __pyx_1 = (__pyx_v_c_element->doc != __pyx_v_doc->_c_doc);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":131
 *     """
 *     if c_element.doc is not doc._c_doc:
 *         if c_element.doc._private is not NULL:             # <<<<<<<<<<<<<<
 *             if c_element is c_element.doc.children:
 *                 c_element = <xmlNode*>c_element.doc._private
 */
    __pyx_1 = (__pyx_v_c_element->doc->_private != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":132
 *     if c_element.doc is not doc._c_doc:
 *         if c_element.doc._private is not NULL:
 *             if c_element is c_element.doc.children:             # <<<<<<<<<<<<<<
 *                 c_element = <xmlNode*>c_element.doc._private
 *                 #assert c_element.type == tree.XML_ELEMENT_NODE
 */
      __pyx_1 = (__pyx_v_c_element == __pyx_v_c_element->doc->children);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":133
 *         if c_element.doc._private is not NULL:
 *             if c_element is c_element.doc.children:
 *                 c_element = <xmlNode*>c_element.doc._private             # <<<<<<<<<<<<<<
 *                 #assert c_element.type == tree.XML_ELEMENT_NODE
 *     return _elementFactory(doc, c_element)
 */
        __pyx_v_c_element = ((xmlNode *)__pyx_v_c_element->doc->_private);
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":135
 *                 c_element = <xmlNode*>c_element.doc._private
 *                 #assert c_element.type == tree.XML_ELEMENT_NODE
 *     return _elementFactory(doc, c_element)             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_element)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._fakeDocElementFactory");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":140
 * # support for freeing tree elements when proxy objects are destroyed
 * 
 * cdef int attemptDeallocation(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     """Attempt deallocation of c_node (or higher up in tree).
 *     """
 */

static  int __pyx_f_4lxml_5etree_attemptDeallocation(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_v_c_top;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":145
 *     cdef xmlNode* c_top
 *     # could be we actually aren't referring to the tree at all
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         #print "not freeing, node is NULL"
 *         return 0
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":147
 *     if c_node is NULL:
 *         #print "not freeing, node is NULL"
 *         return 0             # <<<<<<<<<<<<<<
 *     c_top = getDeallocationTop(c_node)
 *     if c_top is not NULL:
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":148
 *         #print "not freeing, node is NULL"
 *         return 0
 *     c_top = getDeallocationTop(c_node)             # <<<<<<<<<<<<<<
 *     if c_top is not NULL:
 *         #print "freeing:", c_top.name
 */
  __pyx_v_c_top = __pyx_f_4lxml_5etree_getDeallocationTop(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":149
 *         return 0
 *     c_top = getDeallocationTop(c_node)
 *     if c_top is not NULL:             # <<<<<<<<<<<<<<
 *         #print "freeing:", c_top.name
 *         _removeText(c_top.next) # tail
 */
  __pyx_1 = (__pyx_v_c_top != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":151
 *     if c_top is not NULL:
 *         #print "freeing:", c_top.name
 *         _removeText(c_top.next) # tail             # <<<<<<<<<<<<<<
 *         tree.xmlFreeNode(c_top)
 *         return 1
 */
    __pyx_f_4lxml_5etree__removeText(__pyx_v_c_top->next);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":152
 *         #print "freeing:", c_top.name
 *         _removeText(c_top.next) # tail
 *         tree.xmlFreeNode(c_top)             # <<<<<<<<<<<<<<
 *         return 1
 *     return 0
 */
    xmlFreeNode(__pyx_v_c_top);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":153
 *         _removeText(c_top.next) # tail
 *         tree.xmlFreeNode(c_top)
 *         return 1             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":154
 *         tree.xmlFreeNode(c_top)
 *         return 1
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* getDeallocationTop(xmlNode* c_node):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":156
 *     return 0
 * 
 * cdef xmlNode* getDeallocationTop(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     """Return the top of the tree that can be deallocated, or NULL.
 *     """
 */

static  xmlNode *__pyx_f_4lxml_5etree_getDeallocationTop(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_v_c_current;
  xmlNode *__pyx_v_c_top;
  xmlNode *__pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":162
 *     cdef xmlNode* c_top
 *     #print "trying to do deallocating:", c_node.type
 *     if c_node._private is not NULL:             # <<<<<<<<<<<<<<
 *         #print "Not freeing: proxies still exist"
 *         return NULL
 */
  __pyx_1 = (__pyx_v_c_node->_private != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":164
 *     if c_node._private is not NULL:
 *         #print "Not freeing: proxies still exist"
 *         return NULL             # <<<<<<<<<<<<<<
 *     c_current = c_node.parent
 *     c_top = c_node
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":165
 *         #print "Not freeing: proxies still exist"
 *         return NULL
 *     c_current = c_node.parent             # <<<<<<<<<<<<<<
 *     c_top = c_node
 *     while c_current is not NULL:
 */
  __pyx_v_c_current = __pyx_v_c_node->parent;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":166
 *         return NULL
 *     c_current = c_node.parent
 *     c_top = c_node             # <<<<<<<<<<<<<<
 *     while c_current is not NULL:
 *         #print "checking:", c_current.type
 */
  __pyx_v_c_top = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":167
 *     c_current = c_node.parent
 *     c_top = c_node
 *     while c_current is not NULL:             # <<<<<<<<<<<<<<
 *         #print "checking:", c_current.type
 *         if c_current.type == tree.XML_DOCUMENT_NODE or \
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_current != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":169
 *     while c_current is not NULL:
 *         #print "checking:", c_current.type
 *         if c_current.type == tree.XML_DOCUMENT_NODE or \             # <<<<<<<<<<<<<<
 *                c_current.type == tree.XML_HTML_DOCUMENT_NODE:
 *             #print "not freeing: still in doc"
 */
    __pyx_1 = (__pyx_v_c_current->type == XML_DOCUMENT_NODE);
    if (!__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":170
 *         #print "checking:", c_current.type
 *         if c_current.type == tree.XML_DOCUMENT_NODE or \
 *                c_current.type == tree.XML_HTML_DOCUMENT_NODE:             # <<<<<<<<<<<<<<
 *             #print "not freeing: still in doc"
 *             return NULL
 */
      __pyx_1 = (__pyx_v_c_current->type == XML_HTML_DOCUMENT_NODE);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":172
 *                c_current.type == tree.XML_HTML_DOCUMENT_NODE:
 *             #print "not freeing: still in doc"
 *             return NULL             # <<<<<<<<<<<<<<
 *         # if we're still attached to the document, don't deallocate
 *         if c_current._private is not NULL:
 */
      __pyx_r = NULL;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":174
 *             return NULL
 *         # if we're still attached to the document, don't deallocate
 *         if c_current._private is not NULL:             # <<<<<<<<<<<<<<
 *             #print "Not freeing: proxies still exist"
 *             return NULL
 */
    __pyx_1 = (__pyx_v_c_current->_private != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":176
 *         if c_current._private is not NULL:
 *             #print "Not freeing: proxies still exist"
 *             return NULL             # <<<<<<<<<<<<<<
 *         c_top = c_current
 *         c_current = c_current.parent
 */
      __pyx_r = NULL;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":177
 *             #print "Not freeing: proxies still exist"
 *             return NULL
 *         c_top = c_current             # <<<<<<<<<<<<<<
 *         c_current = c_current.parent
 *     # see whether we have children to deallocate
 */
    __pyx_v_c_top = __pyx_v_c_current;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":178
 *             return NULL
 *         c_top = c_current
 *         c_current = c_current.parent             # <<<<<<<<<<<<<<
 *     # see whether we have children to deallocate
 *     if canDeallocateChildNodes(c_top):
 */
    __pyx_v_c_current = __pyx_v_c_current->parent;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":180
 *         c_current = c_current.parent
 *     # see whether we have children to deallocate
 *     if canDeallocateChildNodes(c_top):             # <<<<<<<<<<<<<<
 *         return c_top
 *     else:
 */
  __pyx_2 = __pyx_f_4lxml_5etree_canDeallocateChildNodes(__pyx_v_c_top);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":181
 *     # see whether we have children to deallocate
 *     if canDeallocateChildNodes(c_top):
 *         return c_top             # <<<<<<<<<<<<<<
 *     else:
 *         return NULL
 */
    __pyx_r = __pyx_v_c_top;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":183
 *         return c_top
 *     else:
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef int canDeallocateChildNodes(xmlNode* c_parent):
 */
    __pyx_r = NULL;
    goto __pyx_L0;
  }
  __pyx_L8:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":185
 *         return NULL
 * 
 * cdef int canDeallocateChildNodes(xmlNode* c_parent):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     c_node = c_parent.children
 */

static  int __pyx_f_4lxml_5etree_canDeallocateChildNodes(xmlNode *__pyx_v_c_parent) {
  xmlNode *__pyx_v_c_node;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":187
 * cdef int canDeallocateChildNodes(xmlNode* c_parent):
 *     cdef xmlNode* c_node
 *     c_node = c_parent.children             # <<<<<<<<<<<<<<
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_parent, c_node, 1)
 *     if c_node._private is not NULL:
 */
  __pyx_v_c_node = __pyx_v_c_parent->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":188
 *     cdef xmlNode* c_node
 *     c_node = c_parent.children
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_parent, c_node, 1)             # <<<<<<<<<<<<<<
 *     if c_node._private is not NULL:
 *         return 0
 */
  BEGIN_FOR_EACH_ELEMENT_FROM(__pyx_v_c_parent, __pyx_v_c_node, 1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":189
 *     c_node = c_parent.children
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_parent, c_node, 1)
 *     if c_node._private is not NULL:             # <<<<<<<<<<<<<<
 *         return 0
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 */
  __pyx_1 = (__pyx_v_c_node->_private != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":190
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_parent, c_node, 1)
 *     if c_node._private is not NULL:
 *         return 0             # <<<<<<<<<<<<<<
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *     return 1
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":191
 *     if c_node._private is not NULL:
 *         return 0
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
  END_FOR_EACH_ELEMENT_FROM(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":192
 *         return 0
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":197
 * # fix _Document references and namespaces when a node changes documents
 * 
 * cdef void _copyParentNamespaces(xmlNode* c_from_node, xmlNode* c_to_node) nogil:             # <<<<<<<<<<<<<<
 *     u"""Copy the namespaces of all ancestors of c_from_node to c_to_node.
 *     """
 */

static  void __pyx_f_4lxml_5etree__copyParentNamespaces(xmlNode *__pyx_v_c_from_node, xmlNode *__pyx_v_c_to_node) {
  xmlNode *__pyx_v_c_parent;
  xmlNs *__pyx_v_c_new_ns;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":204
 *     cdef xmlNs* c_new_ns
 *     cdef int prefix_known
 *     c_parent = c_from_node.parent             # <<<<<<<<<<<<<<
 *     while c_parent is not NULL and (tree._isElementOrXInclude(c_parent) or
 *                                     c_parent.type == tree.XML_DOCUMENT_NODE):
 */
  __pyx_v_c_parent = __pyx_v_c_from_node->parent;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":205
 *     cdef int prefix_known
 *     c_parent = c_from_node.parent
 *     while c_parent is not NULL and (tree._isElementOrXInclude(c_parent) or             # <<<<<<<<<<<<<<
 *                                     c_parent.type == tree.XML_DOCUMENT_NODE):
 *         c_new_ns = c_parent.nsDef
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_parent != NULL);
    if (__pyx_1) {
      __pyx_1 = _isElementOrXInclude(__pyx_v_c_parent);
      if (!__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":206
 *     c_parent = c_from_node.parent
 *     while c_parent is not NULL and (tree._isElementOrXInclude(c_parent) or
 *                                     c_parent.type == tree.XML_DOCUMENT_NODE):             # <<<<<<<<<<<<<<
 *         c_new_ns = c_parent.nsDef
 *         while c_new_ns is not NULL:
 */
        __pyx_1 = (__pyx_v_c_parent->type == XML_DOCUMENT_NODE);
      }
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":207
 *     while c_parent is not NULL and (tree._isElementOrXInclude(c_parent) or
 *                                     c_parent.type == tree.XML_DOCUMENT_NODE):
 *         c_new_ns = c_parent.nsDef             # <<<<<<<<<<<<<<
 *         while c_new_ns is not NULL:
 *             # libxml2 will check if the prefix is already defined
 */
    __pyx_v_c_new_ns = __pyx_v_c_parent->nsDef;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":208
 *                                     c_parent.type == tree.XML_DOCUMENT_NODE):
 *         c_new_ns = c_parent.nsDef
 *         while c_new_ns is not NULL:             # <<<<<<<<<<<<<<
 *             # libxml2 will check if the prefix is already defined
 *             tree.xmlNewNs(c_to_node, c_new_ns.href, c_new_ns.prefix)
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_new_ns != NULL);
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":210
 *         while c_new_ns is not NULL:
 *             # libxml2 will check if the prefix is already defined
 *             tree.xmlNewNs(c_to_node, c_new_ns.href, c_new_ns.prefix)             # <<<<<<<<<<<<<<
 *             c_new_ns = c_new_ns.next
 *         c_parent = c_parent.parent
 */
      xmlNewNs(__pyx_v_c_to_node, __pyx_v_c_new_ns->href, __pyx_v_c_new_ns->prefix);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":211
 *             # libxml2 will check if the prefix is already defined
 *             tree.xmlNewNs(c_to_node, c_new_ns.href, c_new_ns.prefix)
 *             c_new_ns = c_new_ns.next             # <<<<<<<<<<<<<<
 *         c_parent = c_parent.parent
 * 
 */
      __pyx_v_c_new_ns = __pyx_v_c_new_ns->next;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":212
 *             tree.xmlNewNs(c_to_node, c_new_ns.href, c_new_ns.prefix)
 *             c_new_ns = c_new_ns.next
 *         c_parent = c_parent.parent             # <<<<<<<<<<<<<<
 * 
 * ctypedef struct _nscache:
 */
    __pyx_v_c_parent = __pyx_v_c_parent->parent;
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":220
 *     cstd.size_t last
 * 
 * cdef int _growNsCache(_nscache* c_ns_cache) except -1:             # <<<<<<<<<<<<<<
 *     cdef xmlNs** c_ns_ptr
 *     if c_ns_cache.size == 0:
 */

static  int __pyx_f_4lxml_5etree__growNsCache(__pyx_t_4lxml_5etree__nscache *__pyx_v_c_ns_cache) {
  xmlNs **__pyx_v_c_ns_ptr;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":222
 * cdef int _growNsCache(_nscache* c_ns_cache) except -1:
 *     cdef xmlNs** c_ns_ptr
 *     if c_ns_cache.size == 0:             # <<<<<<<<<<<<<<
 *         c_ns_cache.size = 20
 *     else:
 */
  __pyx_1 = (__pyx_v_c_ns_cache->size == 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":223
 *     cdef xmlNs** c_ns_ptr
 *     if c_ns_cache.size == 0:
 *         c_ns_cache.size = 20             # <<<<<<<<<<<<<<
 *     else:
 *         c_ns_cache.size *= 2
 */
    __pyx_v_c_ns_cache->size = 20;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":225
 *         c_ns_cache.size = 20
 *     else:
 *         c_ns_cache.size *= 2             # <<<<<<<<<<<<<<
 *     c_ns_ptr = <xmlNs**> cstd.realloc(
 *         c_ns_cache.new, c_ns_cache.size * sizeof(xmlNs*))
 */
    __pyx_v_c_ns_cache->size *= 2;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":227
 *         c_ns_cache.size *= 2
 *     c_ns_ptr = <xmlNs**> cstd.realloc(
 *         c_ns_cache.new, c_ns_cache.size * sizeof(xmlNs*))             # <<<<<<<<<<<<<<
 *     if c_ns_ptr is not NULL:
 *         c_ns_cache.new = c_ns_ptr
 */
  __pyx_v_c_ns_ptr = ((xmlNs **)realloc(__pyx_v_c_ns_cache->new, (__pyx_v_c_ns_cache->size * (sizeof(xmlNs *)))));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":228
 *     c_ns_ptr = <xmlNs**> cstd.realloc(
 *         c_ns_cache.new, c_ns_cache.size * sizeof(xmlNs*))
 *     if c_ns_ptr is not NULL:             # <<<<<<<<<<<<<<
 *         c_ns_cache.new = c_ns_ptr
 *         c_ns_ptr = <xmlNs**> cstd.realloc(
 */
  __pyx_1 = (__pyx_v_c_ns_ptr != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":229
 *         c_ns_cache.new, c_ns_cache.size * sizeof(xmlNs*))
 *     if c_ns_ptr is not NULL:
 *         c_ns_cache.new = c_ns_ptr             # <<<<<<<<<<<<<<
 *         c_ns_ptr = <xmlNs**> cstd.realloc(
 *             c_ns_cache.old, c_ns_cache.size * sizeof(xmlNs*))
 */
    __pyx_v_c_ns_cache->new = __pyx_v_c_ns_ptr;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":231
 *         c_ns_cache.new = c_ns_ptr
 *         c_ns_ptr = <xmlNs**> cstd.realloc(
 *             c_ns_cache.old, c_ns_cache.size * sizeof(xmlNs*))             # <<<<<<<<<<<<<<
 *     if c_ns_ptr is not NULL:
 *         c_ns_cache.old = c_ns_ptr
 */
    __pyx_v_c_ns_ptr = ((xmlNs **)realloc(__pyx_v_c_ns_cache->old, (__pyx_v_c_ns_cache->size * (sizeof(xmlNs *)))));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":232
 *         c_ns_ptr = <xmlNs**> cstd.realloc(
 *             c_ns_cache.old, c_ns_cache.size * sizeof(xmlNs*))
 *     if c_ns_ptr is not NULL:             # <<<<<<<<<<<<<<
 *         c_ns_cache.old = c_ns_ptr
 *     else:
 */
  __pyx_1 = (__pyx_v_c_ns_ptr != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":233
 *             c_ns_cache.old, c_ns_cache.size * sizeof(xmlNs*))
 *     if c_ns_ptr is not NULL:
 *         c_ns_cache.old = c_ns_ptr             # <<<<<<<<<<<<<<
 *     else:
 *         cstd.free(c_ns_cache.new)
 */
    __pyx_v_c_ns_cache->old = __pyx_v_c_ns_ptr;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":235
 *         c_ns_cache.old = c_ns_ptr
 *     else:
 *         cstd.free(c_ns_cache.new)             # <<<<<<<<<<<<<<
 *         cstd.free(c_ns_cache.old)
 *         python.PyErr_NoMemory()
 */
    free(__pyx_v_c_ns_cache->new);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":236
 *     else:
 *         cstd.free(c_ns_cache.new)
 *         cstd.free(c_ns_cache.old)             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *         return -1
 */
    free(__pyx_v_c_ns_cache->old);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":237
 *         cstd.free(c_ns_cache.new)
 *         cstd.free(c_ns_cache.old)
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         return -1
 *     return 0
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":238
 *         cstd.free(c_ns_cache.old)
 *         python.PyErr_NoMemory()
 *         return -1             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":239
 *         python.PyErr_NoMemory()
 *         return -1
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _appendToNsCache(_nscache* c_ns_cache,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._growNsCache");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":241
 *     return 0
 * 
 * cdef inline int _appendToNsCache(_nscache* c_ns_cache,             # <<<<<<<<<<<<<<
 *                                  xmlNs* c_old_ns, xmlNs* c_new_ns) except -1:
 *     if c_ns_cache.last >= c_ns_cache.size:
 */

static INLINE int __pyx_f_4lxml_5etree__appendToNsCache(__pyx_t_4lxml_5etree__nscache *__pyx_v_c_ns_cache, xmlNs *__pyx_v_c_old_ns, xmlNs *__pyx_v_c_new_ns) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":243
 * cdef inline int _appendToNsCache(_nscache* c_ns_cache,
 *                                  xmlNs* c_old_ns, xmlNs* c_new_ns) except -1:
 *     if c_ns_cache.last >= c_ns_cache.size:             # <<<<<<<<<<<<<<
 *         _growNsCache(c_ns_cache)
 *     c_ns_cache.old[c_ns_cache.last] = c_old_ns
 */
  __pyx_1 = (__pyx_v_c_ns_cache->last >= __pyx_v_c_ns_cache->size);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":244
 *                                  xmlNs* c_old_ns, xmlNs* c_new_ns) except -1:
 *     if c_ns_cache.last >= c_ns_cache.size:
 *         _growNsCache(c_ns_cache)             # <<<<<<<<<<<<<<
 *     c_ns_cache.old[c_ns_cache.last] = c_old_ns
 *     c_ns_cache.new[c_ns_cache.last] = c_new_ns
 */
    __pyx_2 = __pyx_f_4lxml_5etree__growNsCache(__pyx_v_c_ns_cache); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":245
 *     if c_ns_cache.last >= c_ns_cache.size:
 *         _growNsCache(c_ns_cache)
 *     c_ns_cache.old[c_ns_cache.last] = c_old_ns             # <<<<<<<<<<<<<<
 *     c_ns_cache.new[c_ns_cache.last] = c_new_ns
 *     c_ns_cache.last += 1
 */
  (__pyx_v_c_ns_cache->old[__pyx_v_c_ns_cache->last]) = __pyx_v_c_old_ns;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":246
 *         _growNsCache(c_ns_cache)
 *     c_ns_cache.old[c_ns_cache.last] = c_old_ns
 *     c_ns_cache.new[c_ns_cache.last] = c_new_ns             # <<<<<<<<<<<<<<
 *     c_ns_cache.last += 1
 * 
 */
  (__pyx_v_c_ns_cache->new[__pyx_v_c_ns_cache->last]) = __pyx_v_c_new_ns;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":247
 *     c_ns_cache.old[c_ns_cache.last] = c_old_ns
 *     c_ns_cache.new[c_ns_cache.last] = c_new_ns
 *     c_ns_cache.last += 1             # <<<<<<<<<<<<<<
 * 
 * cdef int _stripRedundantNamespaceDeclarations(
 */
  __pyx_v_c_ns_cache->last += 1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._appendToNsCache");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":249
 *     c_ns_cache.last += 1
 * 
 * cdef int _stripRedundantNamespaceDeclarations(             # <<<<<<<<<<<<<<
 *     xmlNode* c_element, _nscache* c_ns_cache, xmlNs** c_del_ns_list) except -1:
 *     u"""Removes namespace declarations from an element that are already
 */

static  int __pyx_f_4lxml_5etree__stripRedundantNamespaceDeclarations(xmlNode *__pyx_v_c_element, __pyx_t_4lxml_5etree__nscache *__pyx_v_c_ns_cache, xmlNs **__pyx_v_c_del_ns_list) {
  xmlNs *__pyx_v_c_ns;
  xmlNs *__pyx_v_c_ns_next;
  xmlNs **__pyx_v_c_nsdef;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":259
 *     cdef xmlNs** c_nsdef
 *     # use a xmlNs** to handle assignments to "c_element.nsDef" correctly
 *     c_nsdef = &c_element.nsDef             # <<<<<<<<<<<<<<
 *     while c_nsdef[0] is not NULL:
 *         c_ns = tree.xmlSearchNsByHref(
 */
  __pyx_v_c_nsdef = (&__pyx_v_c_element->nsDef);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":260
 *     # use a xmlNs** to handle assignments to "c_element.nsDef" correctly
 *     c_nsdef = &c_element.nsDef
 *     while c_nsdef[0] is not NULL:             # <<<<<<<<<<<<<<
 *         c_ns = tree.xmlSearchNsByHref(
 *             c_element.doc, c_element.parent, c_nsdef[0].href)
 */
  while (1) {
    __pyx_1 = ((__pyx_v_c_nsdef[0]) != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":262
 *     while c_nsdef[0] is not NULL:
 *         c_ns = tree.xmlSearchNsByHref(
 *             c_element.doc, c_element.parent, c_nsdef[0].href)             # <<<<<<<<<<<<<<
 *         if c_ns is NULL:
 *             # new namespace href => keep and cache the ns declaration
 */
    __pyx_v_c_ns = xmlSearchNsByHref(__pyx_v_c_element->doc, __pyx_v_c_element->parent, (__pyx_v_c_nsdef[0])->href);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":263
 *         c_ns = tree.xmlSearchNsByHref(
 *             c_element.doc, c_element.parent, c_nsdef[0].href)
 *         if c_ns is NULL:             # <<<<<<<<<<<<<<
 *             # new namespace href => keep and cache the ns declaration
 *             _appendToNsCache(c_ns_cache, c_nsdef[0], c_nsdef[0])
 */
    __pyx_1 = (__pyx_v_c_ns == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":265
 *         if c_ns is NULL:
 *             # new namespace href => keep and cache the ns declaration
 *             _appendToNsCache(c_ns_cache, c_nsdef[0], c_nsdef[0])             # <<<<<<<<<<<<<<
 *             c_nsdef = &c_nsdef[0].next
 *         else:
 */
      __pyx_2 = __pyx_f_4lxml_5etree__appendToNsCache(__pyx_v_c_ns_cache, (__pyx_v_c_nsdef[0]), (__pyx_v_c_nsdef[0])); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":266
 *             # new namespace href => keep and cache the ns declaration
 *             _appendToNsCache(c_ns_cache, c_nsdef[0], c_nsdef[0])
 *             c_nsdef = &c_nsdef[0].next             # <<<<<<<<<<<<<<
 *         else:
 *             # known namespace href => strip the ns
 */
      __pyx_v_c_nsdef = (&(__pyx_v_c_nsdef[0])->next);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":270
 *             # known namespace href => strip the ns
 *             if c_ns is tree.xmlSearchNs(c_element.doc, c_element.parent,
 *                                         c_ns.prefix):             # <<<<<<<<<<<<<<
 *                 # prefix is not shadowed by parents => ns is reusable
 *                 _appendToNsCache(c_ns_cache, c_nsdef[0], c_ns)
 */
      __pyx_1 = (__pyx_v_c_ns == xmlSearchNs(__pyx_v_c_element->doc, __pyx_v_c_element->parent, __pyx_v_c_ns->prefix));
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":272
 *                                         c_ns.prefix):
 *                 # prefix is not shadowed by parents => ns is reusable
 *                 _appendToNsCache(c_ns_cache, c_nsdef[0], c_ns)             # <<<<<<<<<<<<<<
 *             # cut out c_nsdef.next and prepend it to garbage chain
 *             c_ns_next = c_nsdef[0].next
 */
        __pyx_2 = __pyx_f_4lxml_5etree__appendToNsCache(__pyx_v_c_ns_cache, (__pyx_v_c_nsdef[0]), __pyx_v_c_ns); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":274
 *                 _appendToNsCache(c_ns_cache, c_nsdef[0], c_ns)
 *             # cut out c_nsdef.next and prepend it to garbage chain
 *             c_ns_next = c_nsdef[0].next             # <<<<<<<<<<<<<<
 *             c_nsdef[0].next = c_del_ns_list[0]
 *             c_del_ns_list[0] = c_nsdef[0]
 */
      __pyx_v_c_ns_next = (__pyx_v_c_nsdef[0])->next;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":275
 *             # cut out c_nsdef.next and prepend it to garbage chain
 *             c_ns_next = c_nsdef[0].next
 *             c_nsdef[0].next = c_del_ns_list[0]             # <<<<<<<<<<<<<<
 *             c_del_ns_list[0] = c_nsdef[0]
 *             c_nsdef[0] = c_ns_next
 */
      (__pyx_v_c_nsdef[0])->next = (__pyx_v_c_del_ns_list[0]);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":276
 *             c_ns_next = c_nsdef[0].next
 *             c_nsdef[0].next = c_del_ns_list[0]
 *             c_del_ns_list[0] = c_nsdef[0]             # <<<<<<<<<<<<<<
 *             c_nsdef[0] = c_ns_next
 *     return 0
 */
      (__pyx_v_c_del_ns_list[0]) = (__pyx_v_c_nsdef[0]);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":277
 *             c_nsdef[0].next = c_del_ns_list[0]
 *             c_del_ns_list[0] = c_nsdef[0]
 *             c_nsdef[0] = c_ns_next             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
      (__pyx_v_c_nsdef[0]) = __pyx_v_c_ns_next;
    }
    __pyx_L5:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":278
 *             c_del_ns_list[0] = c_nsdef[0]
 *             c_nsdef[0] = c_ns_next
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int moveNodeToDocument(_Document doc, xmlDoc* c_source_doc,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._stripRedundantNamespaceDeclarations");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":280
 *     return 0
 * 
 * cdef int moveNodeToDocument(_Document doc, xmlDoc* c_source_doc,             # <<<<<<<<<<<<<<
 *                             xmlNode* c_element) except -1:
 *     u"""Fix the xmlNs pointers of a node and its subtree that were moved.
 */

static  int __pyx_f_4lxml_5etree_moveNodeToDocument(struct LxmlDocument *__pyx_v_doc, xmlDoc *__pyx_v_c_source_doc, xmlNode *__pyx_v_c_element) {
  xmlNode *__pyx_v_c_start_node;
  xmlNode *__pyx_v_c_node;
  __pyx_t_4lxml_5etree__nscache __pyx_v_c_ns_cache;
  xmlNs *__pyx_v_c_ns;
  xmlNs *__pyx_v_c_del_ns_list;
  size_t __pyx_v_i;
  PyObject *__pyx_v_old_docs = 0;
  PyObject *__pyx_v_old_doc;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  size_t __pyx_4;
  xmlNs *__pyx_5;
  __pyx_v_old_doc = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":319
 *     cdef xmlNs* c_del_ns_list
 *     cdef cstd.size_t i
 *     cdef list old_docs = []             # <<<<<<<<<<<<<<
 * 
 *     if not tree._isElementOrXInclude(c_element):
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_old_docs = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":321
 *     cdef list old_docs = []
 * 
 *     if not tree._isElementOrXInclude(c_element):             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_2 = (!_isElementOrXInclude(__pyx_v_c_element));
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":322
 * 
 *     if not tree._isElementOrXInclude(c_element):
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     c_start_node = c_element
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":324
 *         return 0
 * 
 *     c_start_node = c_element             # <<<<<<<<<<<<<<
 *     c_del_ns_list = NULL
 * 
 */
  __pyx_v_c_start_node = __pyx_v_c_element;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":325
 * 
 *     c_start_node = c_element
 *     c_del_ns_list = NULL             # <<<<<<<<<<<<<<
 * 
 *     c_ns_cache.new = NULL
 */
  __pyx_v_c_del_ns_list = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":327
 *     c_del_ns_list = NULL
 * 
 *     c_ns_cache.new = NULL             # <<<<<<<<<<<<<<
 *     c_ns_cache.old = NULL
 *     c_ns_cache.size = 0
 */
  __pyx_v_c_ns_cache.new = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":328
 * 
 *     c_ns_cache.new = NULL
 *     c_ns_cache.old = NULL             # <<<<<<<<<<<<<<
 *     c_ns_cache.size = 0
 *     c_ns_cache.last = 0
 */
  __pyx_v_c_ns_cache.old = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":329
 *     c_ns_cache.new = NULL
 *     c_ns_cache.old = NULL
 *     c_ns_cache.size = 0             # <<<<<<<<<<<<<<
 *     c_ns_cache.last = 0
 * 
 */
  __pyx_v_c_ns_cache.size = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":330
 *     c_ns_cache.old = NULL
 *     c_ns_cache.size = 0
 *     c_ns_cache.last = 0             # <<<<<<<<<<<<<<
 * 
 *     while c_element is not NULL:
 */
  __pyx_v_c_ns_cache.last = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":332
 *     c_ns_cache.last = 0
 * 
 *     while c_element is not NULL:             # <<<<<<<<<<<<<<
 *         # 1) cut out namespaces defined here that are already known by
 *         #    the ancestors
 */
  while (1) {
    __pyx_2 = (__pyx_v_c_element != NULL);
    if (!__pyx_2) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":335
 *         # 1) cut out namespaces defined here that are already known by
 *         #    the ancestors
 *         if c_element.nsDef is not NULL:             # <<<<<<<<<<<<<<
 *             _stripRedundantNamespaceDeclarations(
 *                 c_element, &c_ns_cache, &c_del_ns_list)
 */
    __pyx_2 = (__pyx_v_c_element->nsDef != NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":337
 *         if c_element.nsDef is not NULL:
 *             _stripRedundantNamespaceDeclarations(
 *                 c_element, &c_ns_cache, &c_del_ns_list)             # <<<<<<<<<<<<<<
 * 
 *         # 2) make sure the namespaces of an element and its attributes
 */
      __pyx_3 = __pyx_f_4lxml_5etree__stripRedundantNamespaceDeclarations(__pyx_v_c_element, (&__pyx_v_c_ns_cache), (&__pyx_v_c_del_ns_list)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":341
 *         # 2) make sure the namespaces of an element and its attributes
 *         #    are declared in this document (i.e. on the node or its parents)
 *         c_node = c_element             # <<<<<<<<<<<<<<
 *         while c_node is not NULL:
 *             if c_node.ns is not NULL:
 */
    __pyx_v_c_node = __pyx_v_c_element;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":342
 *         #    are declared in this document (i.e. on the node or its parents)
 *         c_node = c_element
 *         while c_node is not NULL:             # <<<<<<<<<<<<<<
 *             if c_node.ns is not NULL:
 *                 for i from 0 <= i < c_ns_cache.last:
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_node != NULL);
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":343
 *         c_node = c_element
 *         while c_node is not NULL:
 *             if c_node.ns is not NULL:             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < c_ns_cache.last:
 *                     if c_node.ns is c_ns_cache.old[i]:
 */
      __pyx_2 = (__pyx_v_c_node->ns != NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":344
 *         while c_node is not NULL:
 *             if c_node.ns is not NULL:
 *                 for i from 0 <= i < c_ns_cache.last:             # <<<<<<<<<<<<<<
 *                     if c_node.ns is c_ns_cache.old[i]:
 *                         c_node.ns = c_ns_cache.new[i]
 */
        __pyx_4 = __pyx_v_c_ns_cache.last;
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_4; __pyx_v_i++) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":345
 *             if c_node.ns is not NULL:
 *                 for i from 0 <= i < c_ns_cache.last:
 *                     if c_node.ns is c_ns_cache.old[i]:             # <<<<<<<<<<<<<<
 *                         c_node.ns = c_ns_cache.new[i]
 *                         break
 */
          __pyx_2 = (__pyx_v_c_node->ns == (__pyx_v_c_ns_cache.old[__pyx_v_i]));
          if (__pyx_2) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":346
 *                 for i from 0 <= i < c_ns_cache.last:
 *                     if c_node.ns is c_ns_cache.old[i]:
 *                         c_node.ns = c_ns_cache.new[i]             # <<<<<<<<<<<<<<
 *                         break
 *                 else:
 */
            __pyx_v_c_node->ns = (__pyx_v_c_ns_cache.new[__pyx_v_i]);

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":347
 *                     if c_node.ns is c_ns_cache.old[i]:
 *                         c_node.ns = c_ns_cache.new[i]
 *                         break             # <<<<<<<<<<<<<<
 *                 else:
 *                     # not in cache => find a replacement from this document
 */
            goto __pyx_L11;
            goto __pyx_L12;
          }
          __pyx_L12:;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":351
 *                     # not in cache => find a replacement from this document
 *                     c_ns = doc._findOrBuildNodeNs(
 *                         c_element, c_node.ns.href, c_node.ns.prefix)             # <<<<<<<<<<<<<<
 *                     _appendToNsCache(&c_ns_cache, c_node.ns, c_ns)
 *                     c_node.ns = c_ns
 */
          __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->_findOrBuildNodeNs(__pyx_v_doc, __pyx_v_c_element, __pyx_v_c_node->ns->href, __pyx_v_c_node->ns->prefix); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_v_c_ns = __pyx_5;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":352
 *                     c_ns = doc._findOrBuildNodeNs(
 *                         c_element, c_node.ns.href, c_node.ns.prefix)
 *                     _appendToNsCache(&c_ns_cache, c_node.ns, c_ns)             # <<<<<<<<<<<<<<
 *                     c_node.ns = c_ns
 * 
 */
          __pyx_3 = __pyx_f_4lxml_5etree__appendToNsCache((&__pyx_v_c_ns_cache), __pyx_v_c_node->ns, __pyx_v_c_ns); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":353
 *                         c_element, c_node.ns.href, c_node.ns.prefix)
 *                     _appendToNsCache(&c_ns_cache, c_node.ns, c_ns)
 *                     c_node.ns = c_ns             # <<<<<<<<<<<<<<
 * 
 *             if c_node is c_element:
 */
          __pyx_v_c_node->ns = __pyx_v_c_ns;
        }
        __pyx_L11:;
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":355
 *                     c_node.ns = c_ns
 * 
 *             if c_node is c_element:             # <<<<<<<<<<<<<<
 *                 # after the element, continue with its attributes
 *                 c_node = <xmlNode*>c_element.properties
 */
      __pyx_2 = (__pyx_v_c_node == __pyx_v_c_element);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":357
 *             if c_node is c_element:
 *                 # after the element, continue with its attributes
 *                 c_node = <xmlNode*>c_element.properties             # <<<<<<<<<<<<<<
 *             else:
 *                 c_node = c_node.next
 */
        __pyx_v_c_node = ((xmlNode *)__pyx_v_c_element->properties);
        goto __pyx_L13;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":359
 *                 c_node = <xmlNode*>c_element.properties
 *             else:
 *                 c_node = c_node.next             # <<<<<<<<<<<<<<
 * 
 *         # traverse to next element, start with children
 */
        __pyx_v_c_node = __pyx_v_c_node->next;
      }
      __pyx_L13:;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":362
 * 
 *         # traverse to next element, start with children
 *         c_node = c_element.children             # <<<<<<<<<<<<<<
 *         while c_node is not NULL and \
 *               not tree._isElementOrXInclude(c_node):
 */
    __pyx_v_c_node = __pyx_v_c_element->children;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":363
 *         # traverse to next element, start with children
 *         c_node = c_element.children
 *         while c_node is not NULL and \             # <<<<<<<<<<<<<<
 *               not tree._isElementOrXInclude(c_node):
 *             c_node = c_node.next
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_node != NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":364
 *         c_node = c_element.children
 *         while c_node is not NULL and \
 *               not tree._isElementOrXInclude(c_node):             # <<<<<<<<<<<<<<
 *             c_node = c_node.next
 * 
 */
        __pyx_2 = (!_isElementOrXInclude(__pyx_v_c_node));
      }
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":365
 *         while c_node is not NULL and \
 *               not tree._isElementOrXInclude(c_node):
 *             c_node = c_node.next             # <<<<<<<<<<<<<<
 * 
 *         if c_node is NULL:
 */
      __pyx_v_c_node = __pyx_v_c_node->next;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":367
 *             c_node = c_node.next
 * 
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             # no children => back off and continue with siblings and parents
 * 
 */
    __pyx_2 = (__pyx_v_c_node == NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":371
 * 
 *             # 4) fix _Document reference
 *             if c_element._private is not NULL:             # <<<<<<<<<<<<<<
 *                 old_doc = _updateProxyDocument(c_element, doc)
 *                 if old_doc not in old_docs:
 */
      __pyx_2 = (__pyx_v_c_element->_private != NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":372
 *             # 4) fix _Document reference
 *             if c_element._private is not NULL:
 *                 old_doc = _updateProxyDocument(c_element, doc)             # <<<<<<<<<<<<<<
 *                 if old_doc not in old_docs:
 *                     old_docs.append(old_doc)
 */
        __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__updateProxyDocument(__pyx_v_c_element, __pyx_v_doc)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_old_doc);
        __pyx_v_old_doc = __pyx_1;
        __pyx_1 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":373
 *             if c_element._private is not NULL:
 *                 old_doc = _updateProxyDocument(c_element, doc)
 *                 if old_doc not in old_docs:             # <<<<<<<<<<<<<<
 *                     old_docs.append(old_doc)
 * 
 */
        __pyx_2 = (!PySequence_Contains(((PyObject *)__pyx_v_old_docs), __pyx_v_old_doc)); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":374
 *                 old_doc = _updateProxyDocument(c_element, doc)
 *                 if old_doc not in old_docs:
 *                     old_docs.append(old_doc)             # <<<<<<<<<<<<<<
 * 
 *             if c_element is c_start_node:
 */
          __pyx_3 = PyList_Append(((PyObject *)__pyx_v_old_docs), __pyx_v_old_doc); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L18;
        }
        __pyx_L18:;
        goto __pyx_L17;
      }
      __pyx_L17:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":376
 *                     old_docs.append(old_doc)
 * 
 *             if c_element is c_start_node:             # <<<<<<<<<<<<<<
 *                 break # all done
 * 
 */
      __pyx_2 = (__pyx_v_c_element == __pyx_v_c_start_node);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":377
 * 
 *             if c_element is c_start_node:
 *                 break # all done             # <<<<<<<<<<<<<<
 * 
 *             # continue with siblings
 */
        goto __pyx_L5;
        goto __pyx_L19;
      }
      __pyx_L19:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":380
 * 
 *             # continue with siblings
 *             c_node = c_element.next             # <<<<<<<<<<<<<<
 *             while (c_node is not NULL and
 *                    not tree._isElementOrXInclude(c_node)):
 */
      __pyx_v_c_node = __pyx_v_c_element->next;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":381
 *             # continue with siblings
 *             c_node = c_element.next
 *             while (c_node is not NULL and             # <<<<<<<<<<<<<<
 *                    not tree._isElementOrXInclude(c_node)):
 *                 c_node = c_node.next
 */
      while (1) {
        __pyx_2 = (__pyx_v_c_node != NULL);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":382
 *             c_node = c_element.next
 *             while (c_node is not NULL and
 *                    not tree._isElementOrXInclude(c_node)):             # <<<<<<<<<<<<<<
 *                 c_node = c_node.next
 *             # if that didn't help, back off through parents' siblings
 */
          __pyx_2 = (!_isElementOrXInclude(__pyx_v_c_node));
        }
        if (!__pyx_2) break;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":383
 *             while (c_node is not NULL and
 *                    not tree._isElementOrXInclude(c_node)):
 *                 c_node = c_node.next             # <<<<<<<<<<<<<<
 *             # if that didn't help, back off through parents' siblings
 *             while c_node is NULL:
 */
        __pyx_v_c_node = __pyx_v_c_node->next;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":385
 *                 c_node = c_node.next
 *             # if that didn't help, back off through parents' siblings
 *             while c_node is NULL:             # <<<<<<<<<<<<<<
 *                 c_element = c_element.parent
 *                 if c_element is NULL or not tree._isElementOrXInclude(c_element):
 */
      while (1) {
        __pyx_2 = (__pyx_v_c_node == NULL);
        if (!__pyx_2) break;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":386
 *             # if that didn't help, back off through parents' siblings
 *             while c_node is NULL:
 *                 c_element = c_element.parent             # <<<<<<<<<<<<<<
 *                 if c_element is NULL or not tree._isElementOrXInclude(c_element):
 *                     break
 */
        __pyx_v_c_element = __pyx_v_c_element->parent;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":387
 *             while c_node is NULL:
 *                 c_element = c_element.parent
 *                 if c_element is NULL or not tree._isElementOrXInclude(c_element):             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
        __pyx_2 = (__pyx_v_c_element == NULL);
        if (!__pyx_2) {
          __pyx_2 = (!_isElementOrXInclude(__pyx_v_c_element));
        }
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":388
 *                 c_element = c_element.parent
 *                 if c_element is NULL or not tree._isElementOrXInclude(c_element):
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 # 4) fix _Document reference
 */
          goto __pyx_L23;
          goto __pyx_L24;
        }
        __pyx_L24:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":391
 * 
 *                 # 4) fix _Document reference
 *                 if c_element._private is not NULL:             # <<<<<<<<<<<<<<
 *                     old_doc = _updateProxyDocument(c_element, doc)
 *                     if old_doc not in old_docs:
 */
        __pyx_2 = (__pyx_v_c_element->_private != NULL);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":392
 *                 # 4) fix _Document reference
 *                 if c_element._private is not NULL:
 *                     old_doc = _updateProxyDocument(c_element, doc)             # <<<<<<<<<<<<<<
 *                     if old_doc not in old_docs:
 *                         old_docs.append(old_doc)
 */
          __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__updateProxyDocument(__pyx_v_c_element, __pyx_v_doc)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_old_doc);
          __pyx_v_old_doc = __pyx_1;
          __pyx_1 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":393
 *                 if c_element._private is not NULL:
 *                     old_doc = _updateProxyDocument(c_element, doc)
 *                     if old_doc not in old_docs:             # <<<<<<<<<<<<<<
 *                         old_docs.append(old_doc)
 * 
 */
          __pyx_2 = (!PySequence_Contains(((PyObject *)__pyx_v_old_docs), __pyx_v_old_doc)); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          if (__pyx_2) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":394
 *                     old_doc = _updateProxyDocument(c_element, doc)
 *                     if old_doc not in old_docs:
 *                         old_docs.append(old_doc)             # <<<<<<<<<<<<<<
 * 
 *                 if c_element is c_start_node:
 */
            __pyx_3 = PyList_Append(((PyObject *)__pyx_v_old_docs), __pyx_v_old_doc); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            goto __pyx_L26;
          }
          __pyx_L26:;
          goto __pyx_L25;
        }
        __pyx_L25:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":396
 *                         old_docs.append(old_doc)
 * 
 *                 if c_element is c_start_node:             # <<<<<<<<<<<<<<
 *                     break
 *                 # parents already done -> look for their siblings
 */
        __pyx_2 = (__pyx_v_c_element == __pyx_v_c_start_node);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":397
 * 
 *                 if c_element is c_start_node:
 *                     break             # <<<<<<<<<<<<<<
 *                 # parents already done -> look for their siblings
 *                 c_node = c_element.next
 */
          goto __pyx_L23;
          goto __pyx_L27;
        }
        __pyx_L27:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":399
 *                     break
 *                 # parents already done -> look for their siblings
 *                 c_node = c_element.next             # <<<<<<<<<<<<<<
 *                 while (c_node is not NULL and
 *                        not tree._isElementOrXInclude(c_node)):
 */
        __pyx_v_c_node = __pyx_v_c_element->next;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":400
 *                 # parents already done -> look for their siblings
 *                 c_node = c_element.next
 *                 while (c_node is not NULL and             # <<<<<<<<<<<<<<
 *                        not tree._isElementOrXInclude(c_node)):
 *                     c_node = c_node.next
 */
        while (1) {
          __pyx_2 = (__pyx_v_c_node != NULL);
          if (__pyx_2) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":401
 *                 c_node = c_element.next
 *                 while (c_node is not NULL and
 *                        not tree._isElementOrXInclude(c_node)):             # <<<<<<<<<<<<<<
 *                     c_node = c_node.next
 *         if c_node is c_start_node:
 */
            __pyx_2 = (!_isElementOrXInclude(__pyx_v_c_node));
          }
          if (!__pyx_2) break;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":402
 *                 while (c_node is not NULL and
 *                        not tree._isElementOrXInclude(c_node)):
 *                     c_node = c_node.next             # <<<<<<<<<<<<<<
 *         if c_node is c_start_node:
 *             break # all done
 */
          __pyx_v_c_node = __pyx_v_c_node->next;
        }
      }
      __pyx_L23:;
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":403
 *                        not tree._isElementOrXInclude(c_node)):
 *                     c_node = c_node.next
 *         if c_node is c_start_node:             # <<<<<<<<<<<<<<
 *             break # all done
 *         c_element = c_node
 */
    __pyx_2 = (__pyx_v_c_node == __pyx_v_c_start_node);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":404
 *                     c_node = c_node.next
 *         if c_node is c_start_node:
 *             break # all done             # <<<<<<<<<<<<<<
 *         c_element = c_node
 * 
 */
      goto __pyx_L5;
      goto __pyx_L30;
    }
    __pyx_L30:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":405
 *         if c_node is c_start_node:
 *             break # all done
 *         c_element = c_node             # <<<<<<<<<<<<<<
 * 
 *     # 3) fix the names in the tree in case we moved it to a different thread
 */
    __pyx_v_c_element = __pyx_v_c_node;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":408
 * 
 *     # 3) fix the names in the tree in case we moved it to a different thread
 *     if doc._c_doc.dict is not c_source_doc.dict:             # <<<<<<<<<<<<<<
 *         fixThreadDictNames(c_start_node, c_source_doc.dict, doc._c_doc.dict)
 * 
 */
  __pyx_2 = (__pyx_v_doc->_c_doc->dict != __pyx_v_c_source_doc->dict);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":409
 *     # 3) fix the names in the tree in case we moved it to a different thread
 *     if doc._c_doc.dict is not c_source_doc.dict:
 *         fixThreadDictNames(c_start_node, c_source_doc.dict, doc._c_doc.dict)             # <<<<<<<<<<<<<<
 * 
 *     # *now* free all _Documents the original tree referred to
 */
    __pyx_f_4lxml_5etree_fixThreadDictNames(__pyx_v_c_start_node, __pyx_v_c_source_doc->dict, __pyx_v_doc->_c_doc->dict);
    goto __pyx_L31;
  }
  __pyx_L31:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":412
 * 
 *     # *now* free all _Documents the original tree referred to
 *     old_docs = None             # <<<<<<<<<<<<<<
 * 
 *     # free now unused namespace declarations
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)__pyx_v_old_docs));
  __pyx_v_old_docs = ((PyObject *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":415
 * 
 *     # free now unused namespace declarations
 *     if c_del_ns_list is not NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlFreeNsList(c_del_ns_list)
 * 
 */
  __pyx_2 = (__pyx_v_c_del_ns_list != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":416
 *     # free now unused namespace declarations
 *     if c_del_ns_list is not NULL:
 *         tree.xmlFreeNsList(c_del_ns_list)             # <<<<<<<<<<<<<<
 * 
 *     # cleanup
 */
    xmlFreeNsList(__pyx_v_c_del_ns_list);
    goto __pyx_L32;
  }
  __pyx_L32:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":419
 * 
 *     # cleanup
 *     if c_ns_cache.new is not NULL:             # <<<<<<<<<<<<<<
 *         cstd.free(c_ns_cache.new)
 *     if c_ns_cache.old is not NULL:
 */
  __pyx_2 = (__pyx_v_c_ns_cache.new != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":420
 *     # cleanup
 *     if c_ns_cache.new is not NULL:
 *         cstd.free(c_ns_cache.new)             # <<<<<<<<<<<<<<
 *     if c_ns_cache.old is not NULL:
 *         cstd.free(c_ns_cache.old)
 */
    free(__pyx_v_c_ns_cache.new);
    goto __pyx_L33;
  }
  __pyx_L33:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":421
 *     if c_ns_cache.new is not NULL:
 *         cstd.free(c_ns_cache.new)
 *     if c_ns_cache.old is not NULL:             # <<<<<<<<<<<<<<
 *         cstd.free(c_ns_cache.old)
 * 
 */
  __pyx_2 = (__pyx_v_c_ns_cache.old != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":422
 *         cstd.free(c_ns_cache.new)
 *     if c_ns_cache.old is not NULL:
 *         cstd.free(c_ns_cache.old)             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
    free(__pyx_v_c_ns_cache.old);
    goto __pyx_L34;
  }
  __pyx_L34:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":424
 *         cstd.free(c_ns_cache.old)
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.moveNodeToDocument");
  __pyx_r = -1;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_old_docs);
  Py_DECREF(__pyx_v_old_doc);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":427
 * 
 * 
 * cdef void fixThreadDictNames(xmlNode* c_element,             # <<<<<<<<<<<<<<
 *                              tree.xmlDict* c_src_dict,
 *                              tree.xmlDict* c_dict) nogil:
 */

static  void __pyx_f_4lxml_5etree_fixThreadDictNames(xmlNode *__pyx_v_c_element, xmlDict *__pyx_v_c_src_dict, xmlDict *__pyx_v_c_dict) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":434
 *     # this should only be called when the element is based on a
 *     # different libxml2 tag name dictionary
 *     if c_element.type == tree.XML_DOCUMENT_NODE or \             # <<<<<<<<<<<<<<
 *             c_element.type == tree.XML_HTML_DOCUMENT_NODE:
 *         # may define "xml" namespace
 */
  __pyx_1 = (__pyx_v_c_element->type == XML_DOCUMENT_NODE);
  if (!__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":435
 *     # different libxml2 tag name dictionary
 *     if c_element.type == tree.XML_DOCUMENT_NODE or \
 *             c_element.type == tree.XML_HTML_DOCUMENT_NODE:             # <<<<<<<<<<<<<<
 *         # may define "xml" namespace
 *         fixThreadDictNsForNode(c_element, c_src_dict, c_dict)
 */
    __pyx_1 = (__pyx_v_c_element->type == XML_HTML_DOCUMENT_NODE);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":437
 *             c_element.type == tree.XML_HTML_DOCUMENT_NODE:
 *         # may define "xml" namespace
 *         fixThreadDictNsForNode(c_element, c_src_dict, c_dict)             # <<<<<<<<<<<<<<
 *         c_element = c_element.children
 *         while c_element is not NULL:
 */
    __pyx_f_4lxml_5etree_fixThreadDictNsForNode(__pyx_v_c_element, __pyx_v_c_src_dict, __pyx_v_c_dict);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":438
 *         # may define "xml" namespace
 *         fixThreadDictNsForNode(c_element, c_src_dict, c_dict)
 *         c_element = c_element.children             # <<<<<<<<<<<<<<
 *         while c_element is not NULL:
 *             fixThreadDictNames(c_element, c_src_dict, c_dict)
 */
    __pyx_v_c_element = __pyx_v_c_element->children;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":439
 *         fixThreadDictNsForNode(c_element, c_src_dict, c_dict)
 *         c_element = c_element.children
 *         while c_element is not NULL:             # <<<<<<<<<<<<<<
 *             fixThreadDictNames(c_element, c_src_dict, c_dict)
 *             c_element = c_element.next
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_element != NULL);
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":440
 *         c_element = c_element.children
 *         while c_element is not NULL:
 *             fixThreadDictNames(c_element, c_src_dict, c_dict)             # <<<<<<<<<<<<<<
 *             c_element = c_element.next
 *         return
 */
      __pyx_f_4lxml_5etree_fixThreadDictNames(__pyx_v_c_element, __pyx_v_c_src_dict, __pyx_v_c_dict);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":441
 *         while c_element is not NULL:
 *             fixThreadDictNames(c_element, c_src_dict, c_dict)
 *             c_element = c_element.next             # <<<<<<<<<<<<<<
 *         return
 *     elif not tree._isElementOrXInclude(c_element):
 */
      __pyx_v_c_element = __pyx_v_c_element->next;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":442
 *             fixThreadDictNames(c_element, c_src_dict, c_dict)
 *             c_element = c_element.next
 *         return             # <<<<<<<<<<<<<<
 *     elif not tree._isElementOrXInclude(c_element):
 *         return
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":443
 *             c_element = c_element.next
 *         return
 *     elif not tree._isElementOrXInclude(c_element):             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_1 = (!_isElementOrXInclude(__pyx_v_c_element));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":444
 *         return
 *     elif not tree._isElementOrXInclude(c_element):
 *         return             # <<<<<<<<<<<<<<
 * 
 *     tree.BEGIN_FOR_EACH_FROM(c_element, c_element, 1)
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":446
 *         return
 * 
 *     tree.BEGIN_FOR_EACH_FROM(c_element, c_element, 1)             # <<<<<<<<<<<<<<
 *     if c_element.name is not NULL:
 *         fixThreadDictNameForNode(c_element, c_dict)
 */
  BEGIN_FOR_EACH_FROM(__pyx_v_c_element, __pyx_v_c_element, 1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":447
 * 
 *     tree.BEGIN_FOR_EACH_FROM(c_element, c_element, 1)
 *     if c_element.name is not NULL:             # <<<<<<<<<<<<<<
 *         fixThreadDictNameForNode(c_element, c_dict)
 *     if c_element.type == tree.XML_ELEMENT_NODE:
 */
  __pyx_1 = (__pyx_v_c_element->name != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":448
 *     tree.BEGIN_FOR_EACH_FROM(c_element, c_element, 1)
 *     if c_element.name is not NULL:
 *         fixThreadDictNameForNode(c_element, c_dict)             # <<<<<<<<<<<<<<
 *     if c_element.type == tree.XML_ELEMENT_NODE:
 *         fixThreadDictNamesForAttributes(
 */
    __pyx_f_4lxml_5etree_fixThreadDictNameForNode(__pyx_v_c_element, __pyx_v_c_dict);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":449
 *     if c_element.name is not NULL:
 *         fixThreadDictNameForNode(c_element, c_dict)
 *     if c_element.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         fixThreadDictNamesForAttributes(
 *             c_element.properties, c_src_dict, c_dict)
 */
  __pyx_1 = (__pyx_v_c_element->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":451
 *     if c_element.type == tree.XML_ELEMENT_NODE:
 *         fixThreadDictNamesForAttributes(
 *             c_element.properties, c_src_dict, c_dict)             # <<<<<<<<<<<<<<
 *     tree.END_FOR_EACH_FROM(c_element)
 * 
 */
    __pyx_f_4lxml_5etree_fixThreadDictNamesForAttributes(__pyx_v_c_element->properties, __pyx_v_c_src_dict, __pyx_v_c_dict);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":452
 *         fixThreadDictNamesForAttributes(
 *             c_element.properties, c_src_dict, c_dict)
 *     tree.END_FOR_EACH_FROM(c_element)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void fixThreadDictNamesForAttributes(tree.xmlAttr* c_attr,
 */
  END_FOR_EACH_FROM(__pyx_v_c_element);

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":454
 *     tree.END_FOR_EACH_FROM(c_element)
 * 
 * cdef inline void fixThreadDictNamesForAttributes(tree.xmlAttr* c_attr,             # <<<<<<<<<<<<<<
 *                                                  tree.xmlDict* c_src_dict,
 *                                                  tree.xmlDict* c_dict) nogil:
 */

static INLINE void __pyx_f_4lxml_5etree_fixThreadDictNamesForAttributes(xmlAttr *__pyx_v_c_attr, xmlDict *__pyx_v_c_src_dict, xmlDict *__pyx_v_c_dict) {
  xmlNode *__pyx_v_c_child;
  xmlNode *__pyx_v_c_node;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":459
 *     cdef xmlNode* c_child
 *     cdef xmlNode* c_node
 *     c_node = <xmlNode*>c_attr             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         fixThreadDictNameForNode(c_node, c_dict)
 */
  __pyx_v_c_node = ((xmlNode *)__pyx_v_c_attr);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":460
 *     cdef xmlNode* c_node
 *     c_node = <xmlNode*>c_attr
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         fixThreadDictNameForNode(c_node, c_dict)
 *         fixThreadDictContentForNode(c_node, c_src_dict, c_dict)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":461
 *     c_node = <xmlNode*>c_attr
 *     while c_node is not NULL:
 *         fixThreadDictNameForNode(c_node, c_dict)             # <<<<<<<<<<<<<<
 *         fixThreadDictContentForNode(c_node, c_src_dict, c_dict)
 *         # libxml2 keeps some (!) attribute values in the dict
 */
    __pyx_f_4lxml_5etree_fixThreadDictNameForNode(__pyx_v_c_node, __pyx_v_c_dict);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":462
 *     while c_node is not NULL:
 *         fixThreadDictNameForNode(c_node, c_dict)
 *         fixThreadDictContentForNode(c_node, c_src_dict, c_dict)             # <<<<<<<<<<<<<<
 *         # libxml2 keeps some (!) attribute values in the dict
 *         c_child = c_node.children
 */
    __pyx_f_4lxml_5etree_fixThreadDictContentForNode(__pyx_v_c_node, __pyx_v_c_src_dict, __pyx_v_c_dict);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":464
 *         fixThreadDictContentForNode(c_node, c_src_dict, c_dict)
 *         # libxml2 keeps some (!) attribute values in the dict
 *         c_child = c_node.children             # <<<<<<<<<<<<<<
 *         while c_child is not NULL:
 *             fixThreadDictNameForNode(c_child, c_dict)
 */
    __pyx_v_c_child = __pyx_v_c_node->children;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":465
 *         # libxml2 keeps some (!) attribute values in the dict
 *         c_child = c_node.children
 *         while c_child is not NULL:             # <<<<<<<<<<<<<<
 *             fixThreadDictNameForNode(c_child, c_dict)
 *             fixThreadDictContentForNode(c_child, c_src_dict, c_dict)
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_child != NULL);
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":466
 *         c_child = c_node.children
 *         while c_child is not NULL:
 *             fixThreadDictNameForNode(c_child, c_dict)             # <<<<<<<<<<<<<<
 *             fixThreadDictContentForNode(c_child, c_src_dict, c_dict)
 *             c_child = c_child.next
 */
      __pyx_f_4lxml_5etree_fixThreadDictNameForNode(__pyx_v_c_child, __pyx_v_c_dict);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":467
 *         while c_child is not NULL:
 *             fixThreadDictNameForNode(c_child, c_dict)
 *             fixThreadDictContentForNode(c_child, c_src_dict, c_dict)             # <<<<<<<<<<<<<<
 *             c_child = c_child.next
 *         c_node = c_node.next
 */
      __pyx_f_4lxml_5etree_fixThreadDictContentForNode(__pyx_v_c_child, __pyx_v_c_src_dict, __pyx_v_c_dict);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":468
 *             fixThreadDictNameForNode(c_child, c_dict)
 *             fixThreadDictContentForNode(c_child, c_src_dict, c_dict)
 *             c_child = c_child.next             # <<<<<<<<<<<<<<
 *         c_node = c_node.next
 * 
 */
      __pyx_v_c_child = __pyx_v_c_child->next;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":469
 *             fixThreadDictContentForNode(c_child, c_src_dict, c_dict)
 *             c_child = c_child.next
 *         c_node = c_node.next             # <<<<<<<<<<<<<<
 * 
 * cdef inline void fixThreadDictNameForNode(xmlNode* c_node,
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":471
 *         c_node = c_node.next
 * 
 * cdef inline void fixThreadDictNameForNode(xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                                           tree.xmlDict* c_dict) nogil:
 *     cdef char* c_name
 */

static INLINE void __pyx_f_4lxml_5etree_fixThreadDictNameForNode(xmlNode *__pyx_v_c_node, xmlDict *__pyx_v_c_dict) {
  char *__pyx_v_c_name;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":475
 *     cdef char* c_name
 *     # c_name can be NULL on memory error, but we don't handle that here
 *     c_name = tree.xmlDictLookup(c_dict, c_node.name, -1)             # <<<<<<<<<<<<<<
 *     if c_name is not NULL:
 *         c_node.name = c_name
 */
  __pyx_v_c_name = xmlDictLookup(__pyx_v_c_dict, __pyx_v_c_node->name, -1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":476
 *     # c_name can be NULL on memory error, but we don't handle that here
 *     c_name = tree.xmlDictLookup(c_dict, c_node.name, -1)
 *     if c_name is not NULL:             # <<<<<<<<<<<<<<
 *         c_node.name = c_name
 * 
 */
  __pyx_1 = (__pyx_v_c_name != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":477
 *     c_name = tree.xmlDictLookup(c_dict, c_node.name, -1)
 *     if c_name is not NULL:
 *         c_node.name = c_name             # <<<<<<<<<<<<<<
 * 
 * cdef inline void fixThreadDictContentForNode(xmlNode* c_node,
 */
    __pyx_v_c_node->name = __pyx_v_c_name;
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":479
 *         c_node.name = c_name
 * 
 * cdef inline void fixThreadDictContentForNode(xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                                              tree.xmlDict* c_src_dict,
 *                                              tree.xmlDict* c_dict) nogil:
 */

static INLINE void __pyx_f_4lxml_5etree_fixThreadDictContentForNode(xmlNode *__pyx_v_c_node, xmlDict *__pyx_v_c_src_dict, xmlDict *__pyx_v_c_dict) {
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":482
 *                                              tree.xmlDict* c_src_dict,
 *                                              tree.xmlDict* c_dict) nogil:
 *     if c_node.content is not NULL:             # <<<<<<<<<<<<<<
 *         if tree.xmlDictOwns(c_src_dict, c_node.content):
 *             # result can be NULL on memory error, but we don't handle that here
 */
  __pyx_1 = (__pyx_v_c_node->content != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":483
 *                                              tree.xmlDict* c_dict) nogil:
 *     if c_node.content is not NULL:
 *         if tree.xmlDictOwns(c_src_dict, c_node.content):             # <<<<<<<<<<<<<<
 *             # result can be NULL on memory error, but we don't handle that here
 *             c_node.content = tree.xmlDictLookup(c_dict, c_node.content, -1)
 */
    __pyx_2 = xmlDictOwns(__pyx_v_c_src_dict, __pyx_v_c_node->content);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":485
 *         if tree.xmlDictOwns(c_src_dict, c_node.content):
 *             # result can be NULL on memory error, but we don't handle that here
 *             c_node.content = tree.xmlDictLookup(c_dict, c_node.content, -1)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void fixThreadDictNsForNode(xmlNode* c_node,
 */
      __pyx_v_c_node->content = xmlDictLookup(__pyx_v_c_dict, __pyx_v_c_node->content, -1);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":487
 *             c_node.content = tree.xmlDictLookup(c_dict, c_node.content, -1)
 * 
 * cdef inline void fixThreadDictNsForNode(xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                                         tree.xmlDict* c_src_dict,
 *                                         tree.xmlDict* c_dict) nogil:
 */

static INLINE void __pyx_f_4lxml_5etree_fixThreadDictNsForNode(xmlNode *__pyx_v_c_node, xmlDict *__pyx_v_c_src_dict, xmlDict *__pyx_v_c_dict) {
  xmlNs *__pyx_v_c_ns;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":490
 *                                         tree.xmlDict* c_src_dict,
 *                                         tree.xmlDict* c_dict) nogil:
 *     cdef xmlNs* c_ns = c_node.nsDef             # <<<<<<<<<<<<<<
 *     while c_ns is not NULL:
 *         if c_ns.href is not NULL:
 */
  __pyx_v_c_ns = __pyx_v_c_node->nsDef;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":491
 *                                         tree.xmlDict* c_dict) nogil:
 *     cdef xmlNs* c_ns = c_node.nsDef
 *     while c_ns is not NULL:             # <<<<<<<<<<<<<<
 *         if c_ns.href is not NULL:
 *             if tree.xmlDictOwns(c_src_dict, c_ns.href):
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_ns != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":492
 *     cdef xmlNs* c_ns = c_node.nsDef
 *     while c_ns is not NULL:
 *         if c_ns.href is not NULL:             # <<<<<<<<<<<<<<
 *             if tree.xmlDictOwns(c_src_dict, c_ns.href):
 *                 c_ns.href = tree.xmlDictLookup(c_dict, c_ns.href, -1)
 */
    __pyx_1 = (__pyx_v_c_ns->href != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":493
 *     while c_ns is not NULL:
 *         if c_ns.href is not NULL:
 *             if tree.xmlDictOwns(c_src_dict, c_ns.href):             # <<<<<<<<<<<<<<
 *                 c_ns.href = tree.xmlDictLookup(c_dict, c_ns.href, -1)
 *         if c_ns.prefix is not NULL:
 */
      __pyx_2 = xmlDictOwns(__pyx_v_c_src_dict, __pyx_v_c_ns->href);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":494
 *         if c_ns.href is not NULL:
 *             if tree.xmlDictOwns(c_src_dict, c_ns.href):
 *                 c_ns.href = tree.xmlDictLookup(c_dict, c_ns.href, -1)             # <<<<<<<<<<<<<<
 *         if c_ns.prefix is not NULL:
 *             if tree.xmlDictOwns(c_src_dict, c_ns.prefix):
 */
        __pyx_v_c_ns->href = xmlDictLookup(__pyx_v_c_dict, __pyx_v_c_ns->href, -1);
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":495
 *             if tree.xmlDictOwns(c_src_dict, c_ns.href):
 *                 c_ns.href = tree.xmlDictLookup(c_dict, c_ns.href, -1)
 *         if c_ns.prefix is not NULL:             # <<<<<<<<<<<<<<
 *             if tree.xmlDictOwns(c_src_dict, c_ns.prefix):
 *                 c_ns.prefix = tree.xmlDictLookup(c_dict, c_ns.prefix, -1)
 */
    __pyx_1 = (__pyx_v_c_ns->prefix != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":496
 *                 c_ns.href = tree.xmlDictLookup(c_dict, c_ns.href, -1)
 *         if c_ns.prefix is not NULL:
 *             if tree.xmlDictOwns(c_src_dict, c_ns.prefix):             # <<<<<<<<<<<<<<
 *                 c_ns.prefix = tree.xmlDictLookup(c_dict, c_ns.prefix, -1)
 *         c_ns = c_ns.next
 */
      __pyx_2 = xmlDictOwns(__pyx_v_c_src_dict, __pyx_v_c_ns->prefix);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":497
 *         if c_ns.prefix is not NULL:
 *             if tree.xmlDictOwns(c_src_dict, c_ns.prefix):
 *                 c_ns.prefix = tree.xmlDictLookup(c_dict, c_ns.prefix, -1)             # <<<<<<<<<<<<<<
 *         c_ns = c_ns.next
 */
        __pyx_v_c_ns->prefix = xmlDictLookup(__pyx_v_c_dict, __pyx_v_c_ns->prefix, -1);
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/proxy.pxi":498
 *             if tree.xmlDictOwns(c_src_dict, c_ns.prefix):
 *                 c_ns.prefix = tree.xmlDictLookup(c_dict, c_ns.prefix, -1)
 *         c_ns = c_ns.next             # <<<<<<<<<<<<<<
 */
    __pyx_v_c_ns = __pyx_v_c_ns->next;
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":3
 * # Private/public helper functions for API functions
 * 
 * cdef void displayNode(xmlNode* c_node, indent):             # <<<<<<<<<<<<<<
 *     # to help with debugging
 *     cdef xmlNode* c_child
 */

static  void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) {
  xmlNode *__pyx_v_c_child;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":6
 *     # to help with debugging
 *     cdef xmlNode* c_child
 *     print indent * u' ', <long>c_node             # <<<<<<<<<<<<<<
 *     c_child = c_node.children
 *     while c_child is not NULL:
 */
  __pyx_t_1 = PyNumber_Multiply(__pyx_v_indent, ((PyObject *)__pyx_kp_304)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyInt_FromLong(((long)__pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_t_1);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_1);
  __pyx_t_1 = 0;
  __pyx_1 = 0;
  if (__Pyx_Print(((PyObject *)__pyx_2), 1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":7
 *     cdef xmlNode* c_child
 *     print indent * u' ', <long>c_node
 *     c_child = c_node.children             # <<<<<<<<<<<<<<
 *     while c_child is not NULL:
 *         displayNode(c_child, indent + 1)
 */
  __pyx_v_c_child = __pyx_v_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":8
 *     print indent * u' ', <long>c_node
 *     c_child = c_node.children
 *     while c_child is not NULL:             # <<<<<<<<<<<<<<
 *         displayNode(c_child, indent + 1)
 *         c_child = c_child.next
 */
  while (1) {
    __pyx_3 = (__pyx_v_c_child != NULL);
    if (!__pyx_3) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":9
 *     c_child = c_node.children
 *     while c_child is not NULL:
 *         displayNode(c_child, indent + 1)             # <<<<<<<<<<<<<<
 *         c_child = c_child.next
 * 
 */
    __pyx_t_1 = PyNumber_Add(__pyx_v_indent, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_f_4lxml_5etree_displayNode(__pyx_v_c_child, __pyx_t_1);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":10
 *     while c_child is not NULL:
 *         displayNode(c_child, indent + 1)
 *         c_child = c_child.next             # <<<<<<<<<<<<<<
 * 
 * cdef _Document _documentOrRaise(object input):
 */
    __pyx_v_c_child = __pyx_v_c_child->next;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree.displayNode");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":12
 *         c_child = c_child.next
 * 
 * cdef _Document _documentOrRaise(object input):             # <<<<<<<<<<<<<<
 *     u"""Call this to get the document of a _Document, _ElementTree or _Element
 *     object, or to raise an exception if it can't be determined.
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__documentOrRaise(PyObject *__pyx_v_input) {
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_element;
  struct LxmlDocument *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":20
 *     cdef _Document doc
 *     cdef _Element element
 *     if isinstance(input, _ElementTree):             # <<<<<<<<<<<<<<
 *         element = (<_ElementTree>input)._context_node
 *         if element is not None:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":21
 *     cdef _Element element
 *     if isinstance(input, _ElementTree):
 *         element = (<_ElementTree>input)._context_node             # <<<<<<<<<<<<<<
 *         if element is not None:
 *             doc = element._doc
 */
    Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_input)->_context_node));
    Py_DECREF(((PyObject *)__pyx_v_element));
    __pyx_v_element = ((struct LxmlElementTree *)__pyx_v_input)->_context_node;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":22
 *     if isinstance(input, _ElementTree):
 *         element = (<_ElementTree>input)._context_node
 *         if element is not None:             # <<<<<<<<<<<<<<
 *             doc = element._doc
 *     elif isinstance(input, _Element):
 */
    __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":23
 *         element = (<_ElementTree>input)._context_node
 *         if element is not None:
 *             doc = element._doc             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Element):
 *         doc = (<_Element>input)._doc
 */
      Py_INCREF(((PyObject *)__pyx_v_element->_doc));
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = __pyx_v_element->_doc;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":24
 *         if element is not None:
 *             doc = element._doc
 *     elif isinstance(input, _Element):             # <<<<<<<<<<<<<<
 *         doc = (<_Element>input)._doc
 *     elif isinstance(input, _Document):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":25
 *             doc = element._doc
 *     elif isinstance(input, _Element):
 *         doc = (<_Element>input)._doc             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Document):
 *         doc = <_Document>input
 */
    Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_input)->_doc));
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlElement *)__pyx_v_input)->_doc;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":26
 *     elif isinstance(input, _Element):
 *         doc = (<_Element>input)._doc
 *     elif isinstance(input, _Document):             # <<<<<<<<<<<<<<
 *         doc = <_Document>input
 *     else:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Document))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":27
 *         doc = (<_Element>input)._doc
 *     elif isinstance(input, _Document):
 *         doc = <_Document>input             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Invalid input object: %s" % \
 */
    Py_INCREF(((PyObject *)((struct LxmlDocument *)__pyx_v_input)));
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlDocument *)__pyx_v_input);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":30
 *     else:
 *         raise TypeError, u"Invalid input object: %s" % \
 *             python._fqtypename(input)             # <<<<<<<<<<<<<<
 *     if doc is None:
 *         raise ValueError, u"Input object has no document: %s" % \
 */
    __pyx_2 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_input)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_305), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":31
 *         raise TypeError, u"Invalid input object: %s" % \
 *             python._fqtypename(input)
 *     if doc is None:             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Input object has no document: %s" % \
 *             python._fqtypename(input)
 */
  __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":33
 *     if doc is None:
 *         raise ValueError, u"Input object has no document: %s" % \
 *             python._fqtypename(input)             # <<<<<<<<<<<<<<
 *     else:
 *         return doc
 */
    __pyx_2 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_input)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_306), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":35
 *             python._fqtypename(input)
 *     else:
 *         return doc             # <<<<<<<<<<<<<<
 * 
 * cdef _Element _rootNodeOrRaise(object input):
 */
    Py_INCREF(((PyObject *)__pyx_v_doc));
    __pyx_r = __pyx_v_doc;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._documentOrRaise");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":37
 *         return doc
 * 
 * cdef _Element _rootNodeOrRaise(object input):             # <<<<<<<<<<<<<<
 *     u"""Call this to get the root node of a _Document, _ElementTree or
 *      _Element object, or to raise an exception if it can't be determined.
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree__rootNodeOrRaise(PyObject *__pyx_v_input) {
  struct LxmlElement *__pyx_v_node;
  struct LxmlElement *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":44
 *      """
 *     cdef _Element node
 *     if isinstance(input, _ElementTree):             # <<<<<<<<<<<<<<
 *         node = (<_ElementTree>input)._context_node
 *     elif isinstance(input, _Element):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":45
 *     cdef _Element node
 *     if isinstance(input, _ElementTree):
 *         node = (<_ElementTree>input)._context_node             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Element):
 *         node = <_Element>input
 */
    Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_input)->_context_node));
    Py_DECREF(((PyObject *)__pyx_v_node));
    __pyx_v_node = ((struct LxmlElementTree *)__pyx_v_input)->_context_node;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":46
 *     if isinstance(input, _ElementTree):
 *         node = (<_ElementTree>input)._context_node
 *     elif isinstance(input, _Element):             # <<<<<<<<<<<<<<
 *         node = <_Element>input
 *     elif isinstance(input, _Document):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":47
 *         node = (<_ElementTree>input)._context_node
 *     elif isinstance(input, _Element):
 *         node = <_Element>input             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Document):
 *         node = (<_Document>input).getroot()
 */
    Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_input)));
    Py_DECREF(((PyObject *)__pyx_v_node));
    __pyx_v_node = ((struct LxmlElement *)__pyx_v_input);
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":48
 *     elif isinstance(input, _Element):
 *         node = <_Element>input
 *     elif isinstance(input, _Document):             # <<<<<<<<<<<<<<
 *         node = (<_Document>input).getroot()
 *     else:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Document))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":49
 *         node = <_Element>input
 *     elif isinstance(input, _Document):
 *         node = (<_Document>input).getroot()             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Invalid input object: %s" % \
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct LxmlDocument *)__pyx_v_input)->__pyx_vtab)->getroot(((struct LxmlDocument *)__pyx_v_input)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_node));
    __pyx_v_node = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":52
 *     else:
 *         raise TypeError, u"Invalid input object: %s" % \
 *             python._fqtypename(input)             # <<<<<<<<<<<<<<
 *     if node is None:
 *         raise ValueError, u"Input object has no element: %s" % \
 */
    __pyx_2 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_input)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_307), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":53
 *         raise TypeError, u"Invalid input object: %s" % \
 *             python._fqtypename(input)
 *     if node is None:             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Input object has no element: %s" % \
 *             python._fqtypename(input)
 */
  __pyx_1 = (((PyObject *)__pyx_v_node) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":55
 *     if node is None:
 *         raise ValueError, u"Input object has no element: %s" % \
 *             python._fqtypename(input)             # <<<<<<<<<<<<<<
 *     else:
 *         return node
 */
    __pyx_2 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_input)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_308), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":57
 *             python._fqtypename(input)
 *     else:
 *         return node             # <<<<<<<<<<<<<<
 * 
 * cdef _Document _documentOf(object input):
 */
    Py_INCREF(((PyObject *)__pyx_v_node));
    __pyx_r = __pyx_v_node;
    goto __pyx_L0;
  }
  __pyx_L4:;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._rootNodeOrRaise");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":59
 *         return node
 * 
 * cdef _Document _documentOf(object input):             # <<<<<<<<<<<<<<
 *     # call this to get the document of a
 *     # _Document, _ElementTree or _Element object
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__documentOf(PyObject *__pyx_v_input) {
  struct LxmlElement *__pyx_v_element;
  struct LxmlDocument *__pyx_r;
  int __pyx_1;
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":64
 *     # may return None!
 *     cdef _Element element
 *     if isinstance(input, _ElementTree):             # <<<<<<<<<<<<<<
 *         element = (<_ElementTree>input)._context_node
 *         if element is not None:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":65
 *     cdef _Element element
 *     if isinstance(input, _ElementTree):
 *         element = (<_ElementTree>input)._context_node             # <<<<<<<<<<<<<<
 *         if element is not None:
 *             return element._doc
 */
    Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_input)->_context_node));
    Py_DECREF(((PyObject *)__pyx_v_element));
    __pyx_v_element = ((struct LxmlElementTree *)__pyx_v_input)->_context_node;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":66
 *     if isinstance(input, _ElementTree):
 *         element = (<_ElementTree>input)._context_node
 *         if element is not None:             # <<<<<<<<<<<<<<
 *             return element._doc
 *     elif isinstance(input, _Element):
 */
    __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":67
 *         element = (<_ElementTree>input)._context_node
 *         if element is not None:
 *             return element._doc             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Element):
 *         return (<_Element>input)._doc
 */
      Py_INCREF(((PyObject *)__pyx_v_element->_doc));
      __pyx_r = __pyx_v_element->_doc;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":68
 *         if element is not None:
 *             return element._doc
 *     elif isinstance(input, _Element):             # <<<<<<<<<<<<<<
 *         return (<_Element>input)._doc
 *     elif isinstance(input, _Document):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":69
 *             return element._doc
 *     elif isinstance(input, _Element):
 *         return (<_Element>input)._doc             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Document):
 *         return <_Document>input
 */
    Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_input)->_doc));
    __pyx_r = ((struct LxmlElement *)__pyx_v_input)->_doc;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":70
 *     elif isinstance(input, _Element):
 *         return (<_Element>input)._doc
 *     elif isinstance(input, _Document):             # <<<<<<<<<<<<<<
 *         return <_Document>input
 *     return None
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Document))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":71
 *         return (<_Element>input)._doc
 *     elif isinstance(input, _Document):
 *         return <_Document>input             # <<<<<<<<<<<<<<
 *     return None
 * 
 */
    Py_INCREF(((PyObject *)((struct LxmlDocument *)__pyx_v_input)));
    __pyx_r = ((struct LxmlDocument *)__pyx_v_input);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":72
 *     elif isinstance(input, _Document):
 *         return <_Document>input
 *     return None             # <<<<<<<<<<<<<<
 * 
 * cdef _Element _rootNodeOf(object input):
 */
  Py_INCREF(Py_None);
  __pyx_r = ((struct LxmlDocument *)Py_None);
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":74
 *     return None
 * 
 * cdef _Element _rootNodeOf(object input):             # <<<<<<<<<<<<<<
 *     # call this to get the root node of a
 *     # _Document, _ElementTree or _Element object
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree__rootNodeOf(PyObject *__pyx_v_input) {
  struct LxmlElement *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":78
 *     # _Document, _ElementTree or _Element object
 *     # may return None!
 *     if isinstance(input, _ElementTree):             # <<<<<<<<<<<<<<
 *         return (<_ElementTree>input)._context_node
 *     elif isinstance(input, _Element):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":79
 *     # may return None!
 *     if isinstance(input, _ElementTree):
 *         return (<_ElementTree>input)._context_node             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Element):
 *         return <_Element>input
 */
    Py_INCREF(((PyObject *)((struct LxmlElementTree *)__pyx_v_input)->_context_node));
    __pyx_r = ((struct LxmlElementTree *)__pyx_v_input)->_context_node;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":80
 *     if isinstance(input, _ElementTree):
 *         return (<_ElementTree>input)._context_node
 *     elif isinstance(input, _Element):             # <<<<<<<<<<<<<<
 *         return <_Element>input
 *     elif isinstance(input, _Document):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":81
 *         return (<_ElementTree>input)._context_node
 *     elif isinstance(input, _Element):
 *         return <_Element>input             # <<<<<<<<<<<<<<
 *     elif isinstance(input, _Document):
 *         return (<_Document>input).getroot()
 */
    Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_input)));
    __pyx_r = ((struct LxmlElement *)__pyx_v_input);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":82
 *     elif isinstance(input, _Element):
 *         return <_Element>input
 *     elif isinstance(input, _Document):             # <<<<<<<<<<<<<<
 *         return (<_Document>input).getroot()
 *     else:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_input, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Document))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":83
 *         return <_Element>input
 *     elif isinstance(input, _Document):
 *         return (<_Document>input).getroot()             # <<<<<<<<<<<<<<
 *     else:
 *         return None
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct LxmlDocument *)__pyx_v_input)->__pyx_vtab)->getroot(((struct LxmlDocument *)__pyx_v_input)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":85
 *         return (<_Document>input).getroot()
 *     else:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * cdef _Element _makeElement(tag, xmlDoc* c_doc, _Document doc,
 */
    Py_INCREF(Py_None);
    __pyx_r = ((struct LxmlElement *)Py_None);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._rootNodeOf");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":87
 *         return None
 * 
 * cdef _Element _makeElement(tag, xmlDoc* c_doc, _Document doc,             # <<<<<<<<<<<<<<
 *                            _BaseParser parser, text, tail, attrib, nsmap,
 *                            extra_attrs):
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree__makeElement(PyObject *__pyx_v_tag, xmlDoc *__pyx_v_c_doc, struct LxmlDocument *__pyx_v_doc, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser, PyObject *__pyx_v_text, PyObject *__pyx_v_tail, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap, PyObject *__pyx_v_extra_attrs) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_name_utf;
  struct LxmlElement *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  xmlDoc *__pyx_6;
  xmlDoc *__pyx_7;
  xmlNode *__pyx_8;
  Py_INCREF(__pyx_v_doc);
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":105
 *     """
 *     cdef xmlNode* c_node
 *     if doc is not None:             # <<<<<<<<<<<<<<
 *         c_doc = doc._c_doc
 *     ns_utf, name_utf = _getNsTag(tag)
 */
  __pyx_1 = (((PyObject *)__pyx_v_doc) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":106
 *     cdef xmlNode* c_node
 *     if doc is not None:
 *         c_doc = doc._c_doc             # <<<<<<<<<<<<<<
 *     ns_utf, name_utf = _getNsTag(tag)
 *     if parser is not None and parser._for_html:
 */
    __pyx_v_c_doc = __pyx_v_doc->_c_doc;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":107
 *     if doc is not None:
 *         c_doc = doc._c_doc
 *     ns_utf, name_utf = _getNsTag(tag)             # <<<<<<<<<<<<<<
 *     if parser is not None and parser._for_html:
 *         _htmlTagValidOrRaise(name_utf)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_tag); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
    PyObject* tuple = __pyx_2;
    __pyx_4 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_4);
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = __pyx_4;
    __pyx_4 = 0;
    __pyx_4 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_4);
    Py_DECREF(__pyx_v_name_utf);
    __pyx_v_name_utf = __pyx_4;
    __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  else {
    __pyx_3 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = __pyx_4;
    __pyx_4 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name_utf);
    __pyx_v_name_utf = __pyx_4;
    __pyx_4 = 0;
    if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":108
 *         c_doc = doc._c_doc
 *     ns_utf, name_utf = _getNsTag(tag)
 *     if parser is not None and parser._for_html:             # <<<<<<<<<<<<<<
 *         _htmlTagValidOrRaise(name_utf)
 *         if c_doc is NULL:
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) != Py_None);
  if (__pyx_1) {
    __pyx_1 = __pyx_v_parser->_for_html;
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":109
 *     ns_utf, name_utf = _getNsTag(tag)
 *     if parser is not None and parser._for_html:
 *         _htmlTagValidOrRaise(name_utf)             # <<<<<<<<<<<<<<
 *         if c_doc is NULL:
 *             c_doc = _newHTMLDoc()
 */
    __pyx_5 = __pyx_f_4lxml_5etree__htmlTagValidOrRaise(__pyx_v_name_utf); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":110
 *     if parser is not None and parser._for_html:
 *         _htmlTagValidOrRaise(name_utf)
 *         if c_doc is NULL:             # <<<<<<<<<<<<<<
 *             c_doc = _newHTMLDoc()
 *     else:
 */
    __pyx_1 = (__pyx_v_c_doc == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":111
 *         _htmlTagValidOrRaise(name_utf)
 *         if c_doc is NULL:
 *             c_doc = _newHTMLDoc()             # <<<<<<<<<<<<<<
 *     else:
 *         _tagValidOrRaise(name_utf)
 */
      __pyx_6 = __pyx_f_4lxml_5etree__newHTMLDoc(); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_c_doc = __pyx_6;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":113
 *             c_doc = _newHTMLDoc()
 *     else:
 *         _tagValidOrRaise(name_utf)             # <<<<<<<<<<<<<<
 *         if c_doc is NULL:
 *             c_doc = _newXMLDoc()
 */
    __pyx_5 = __pyx_f_4lxml_5etree__tagValidOrRaise(__pyx_v_name_utf); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":114
 *     else:
 *         _tagValidOrRaise(name_utf)
 *         if c_doc is NULL:             # <<<<<<<<<<<<<<
 *             c_doc = _newXMLDoc()
 *     c_node = _createElement(c_doc, name_utf)
 */
    __pyx_1 = (__pyx_v_c_doc == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":115
 *         _tagValidOrRaise(name_utf)
 *         if c_doc is NULL:
 *             c_doc = _newXMLDoc()             # <<<<<<<<<<<<<<
 *     c_node = _createElement(c_doc, name_utf)
 *     if c_node is NULL:
 */
      __pyx_7 = __pyx_f_4lxml_5etree__newXMLDoc(); if (unlikely(__pyx_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_c_doc = __pyx_7;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":116
 *         if c_doc is NULL:
 *             c_doc = _newXMLDoc()
 *     c_node = _createElement(c_doc, name_utf)             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         if doc is None and c_doc is not NULL:
 */
  __pyx_8 = __pyx_f_4lxml_5etree__createElement(__pyx_v_c_doc, __pyx_v_name_utf); if (unlikely(__pyx_8 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_node = __pyx_8;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":117
 *             c_doc = _newXMLDoc()
 *     c_node = _createElement(c_doc, name_utf)
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         if doc is None and c_doc is not NULL:
 *             tree.xmlFreeDoc(c_doc)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":118
 *     c_node = _createElement(c_doc, name_utf)
 *     if c_node is NULL:
 *         if doc is None and c_doc is not NULL:             # <<<<<<<<<<<<<<
 *             tree.xmlFreeDoc(c_doc)
 *         return python.PyErr_NoMemory()
 */
    __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c_doc != NULL);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":119
 *     if c_node is NULL:
 *         if doc is None and c_doc is not NULL:
 *             tree.xmlFreeDoc(c_doc)             # <<<<<<<<<<<<<<
 *         return python.PyErr_NoMemory()
 *     try:
 */
      xmlFreeDoc(__pyx_v_c_doc);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":120
 *         if doc is None and c_doc is not NULL:
 *             tree.xmlFreeDoc(c_doc)
 *         return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     try:
 *         if doc is None:
 */
    __pyx_4 = PyErr_NoMemory(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct LxmlElement *)__pyx_4);
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":121
 *             tree.xmlFreeDoc(c_doc)
 *         return python.PyErr_NoMemory()
 *     try:             # <<<<<<<<<<<<<<
 *         if doc is None:
 *             tree.xmlDocSetRootElement(c_doc, c_node)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":122
 *         return python.PyErr_NoMemory()
 *     try:
 *         if doc is None:             # <<<<<<<<<<<<<<
 *             tree.xmlDocSetRootElement(c_doc, c_node)
 *             doc = _documentFactory(c_doc, parser)
 */
      __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":123
 *     try:
 *         if doc is None:
 *             tree.xmlDocSetRootElement(c_doc, c_node)             # <<<<<<<<<<<<<<
 *             doc = _documentFactory(c_doc, parser)
 *         if text is not None:
 */
        xmlDocSetRootElement(__pyx_v_c_doc, __pyx_v_c_node);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":124
 *         if doc is None:
 *             tree.xmlDocSetRootElement(c_doc, c_node)
 *             doc = _documentFactory(c_doc, parser)             # <<<<<<<<<<<<<<
 *         if text is not None:
 *             _setNodeText(c_node, text)
 */
        __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, __pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        Py_DECREF(((PyObject *)__pyx_v_doc));
        __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
        __pyx_2 = 0;
        goto __pyx_L14;
      }
      __pyx_L14:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":125
 *             tree.xmlDocSetRootElement(c_doc, c_node)
 *             doc = _documentFactory(c_doc, parser)
 *         if text is not None:             # <<<<<<<<<<<<<<
 *             _setNodeText(c_node, text)
 *         if tail is not None:
 */
      __pyx_1 = (__pyx_v_text != Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":126
 *             doc = _documentFactory(c_doc, parser)
 *         if text is not None:
 *             _setNodeText(c_node, text)             # <<<<<<<<<<<<<<
 *         if tail is not None:
 *             _setTailText(c_node, tail)
 */
        __pyx_5 = __pyx_f_4lxml_5etree__setNodeText(__pyx_v_c_node, __pyx_v_text); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        goto __pyx_L15;
      }
      __pyx_L15:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":127
 *         if text is not None:
 *             _setNodeText(c_node, text)
 *         if tail is not None:             # <<<<<<<<<<<<<<
 *             _setTailText(c_node, tail)
 *         # add namespaces to node if necessary
 */
      __pyx_1 = (__pyx_v_tail != Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":128
 *             _setNodeText(c_node, text)
 *         if tail is not None:
 *             _setTailText(c_node, tail)             # <<<<<<<<<<<<<<
 *         # add namespaces to node if necessary
 *         _initNodeNamespaces(c_node, doc, ns_utf, nsmap)
 */
        __pyx_5 = __pyx_f_4lxml_5etree__setTailText(__pyx_v_c_node, __pyx_v_tail); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        goto __pyx_L16;
      }
      __pyx_L16:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":130
 *             _setTailText(c_node, tail)
 *         # add namespaces to node if necessary
 *         _initNodeNamespaces(c_node, doc, ns_utf, nsmap)             # <<<<<<<<<<<<<<
 *         _initNodeAttributes(c_node, doc, attrib, extra_attrs)
 *         return _elementFactory(doc, c_node)
 */
      __pyx_5 = __pyx_f_4lxml_5etree__initNodeNamespaces(__pyx_v_c_node, __pyx_v_doc, __pyx_v_ns_utf, __pyx_v_nsmap); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L9_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":131
 *         # add namespaces to node if necessary
 *         _initNodeNamespaces(c_node, doc, ns_utf, nsmap)
 *         _initNodeAttributes(c_node, doc, attrib, extra_attrs)             # <<<<<<<<<<<<<<
 *         return _elementFactory(doc, c_node)
 *     except:
 */
      __pyx_3 = __pyx_f_4lxml_5etree__initNodeAttributes(__pyx_v_c_node, __pyx_v_doc, __pyx_v_attrib, __pyx_v_extra_attrs); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":132
 *         _initNodeNamespaces(c_node, doc, ns_utf, nsmap)
 *         _initNodeAttributes(c_node, doc, attrib, extra_attrs)
 *         return _elementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 *     except:
 *         # free allocated c_node/c_doc unless Python does it for us
 */
      __pyx_4 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
      __pyx_r = ((struct LxmlElement *)__pyx_4);
      __pyx_4 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L13_try;
    __pyx_L9_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":133
 *         _initNodeAttributes(c_node, doc, attrib, extra_attrs)
 *         return _elementFactory(doc, c_node)
 *     except:             # <<<<<<<<<<<<<<
 *         # free allocated c_node/c_doc unless Python does it for us
 *         if c_node.doc is not c_doc:
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._makeElement");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":135
 *     except:
 *         # free allocated c_node/c_doc unless Python does it for us
 *         if c_node.doc is not c_doc:             # <<<<<<<<<<<<<<
 *             # node not yet in document => will not be freed by document
 *             if tail is not None:
 */
      __pyx_1 = (__pyx_v_c_node->doc != __pyx_v_c_doc);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":137
 *         if c_node.doc is not c_doc:
 *             # node not yet in document => will not be freed by document
 *             if tail is not None:             # <<<<<<<<<<<<<<
 *                 _removeText(c_node.next) # tail
 *             tree.xmlFreeNode(c_node)
 */
        __pyx_1 = (__pyx_v_tail != Py_None);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":138
 *             # node not yet in document => will not be freed by document
 *             if tail is not None:
 *                 _removeText(c_node.next) # tail             # <<<<<<<<<<<<<<
 *             tree.xmlFreeNode(c_node)
 *         if doc is None:
 */
          __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->next);
          goto __pyx_L18;
        }
        __pyx_L18:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":139
 *             if tail is not None:
 *                 _removeText(c_node.next) # tail
 *             tree.xmlFreeNode(c_node)             # <<<<<<<<<<<<<<
 *         if doc is None:
 *             # c_doc will not be freed by doc
 */
        xmlFreeNode(__pyx_v_c_node);
        goto __pyx_L17;
      }
      __pyx_L17:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":140
 *                 _removeText(c_node.next) # tail
 *             tree.xmlFreeNode(c_node)
 *         if doc is None:             # <<<<<<<<<<<<<<
 *             # c_doc will not be freed by doc
 *             tree.xmlFreeDoc(c_doc)
 */
      __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":142
 *         if doc is None:
 *             # c_doc will not be freed by doc
 *             tree.xmlFreeDoc(c_doc)             # <<<<<<<<<<<<<<
 *         raise
 * 
 */
        xmlFreeDoc(__pyx_v_c_doc);
        goto __pyx_L19;
      }
      __pyx_L19:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":143
 *             # c_doc will not be freed by doc
 *             tree.xmlFreeDoc(c_doc)
 *         raise             # <<<<<<<<<<<<<<
 * 
 * cdef _Element _makeSubElement(_Element parent, tag, text, tail,
 */
      __Pyx_Raise(__pyx_2, __pyx_3, __pyx_4);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L10_exception_handled;
    }
    __pyx_L11_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L10_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L13_try:;
  }

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._makeElement");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_name_utf);
  Py_DECREF(__pyx_v_doc);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":145
 *         raise
 * 
 * cdef _Element _makeSubElement(_Element parent, tag, text, tail,             # <<<<<<<<<<<<<<
 *                               attrib, nsmap, extra_attrs):
 *     u"""Create a new child element and initialize text content, namespaces and
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree__makeSubElement(struct LxmlElement *__pyx_v_parent, PyObject *__pyx_v_tag, PyObject *__pyx_v_text, PyObject *__pyx_v_tail, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap, PyObject *__pyx_v_extra_attrs) {
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_doc;
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_name_utf;
  struct LxmlElement *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  xmlNode *__pyx_6;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":152
 *     cdef xmlNode* c_node
 *     cdef xmlDoc* c_doc
 *     if parent is None or parent._doc is None:             # <<<<<<<<<<<<<<
 *         return None
 *     ns_utf, name_utf = _getNsTag(tag)
 */
  __pyx_1 = (((PyObject *)__pyx_v_parent) == Py_None);
  if (!__pyx_1) {
    __pyx_1 = (((PyObject *)__pyx_v_parent->_doc) == Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":153
 *     cdef xmlDoc* c_doc
 *     if parent is None or parent._doc is None:
 *         return None             # <<<<<<<<<<<<<<
 *     ns_utf, name_utf = _getNsTag(tag)
 *     c_doc = parent._doc._c_doc
 */
    Py_INCREF(Py_None);
    __pyx_r = ((struct LxmlElement *)Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":154
 *     if parent is None or parent._doc is None:
 *         return None
 *     ns_utf, name_utf = _getNsTag(tag)             # <<<<<<<<<<<<<<
 *     c_doc = parent._doc._c_doc
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_tag); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
    PyObject* tuple = __pyx_2;
    __pyx_4 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_4);
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = __pyx_4;
    __pyx_4 = 0;
    __pyx_4 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_4);
    Py_DECREF(__pyx_v_name_utf);
    __pyx_v_name_utf = __pyx_4;
    __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  else {
    __pyx_3 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = __pyx_4;
    __pyx_4 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name_utf);
    __pyx_v_name_utf = __pyx_4;
    __pyx_4 = 0;
    if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":155
 *         return None
 *     ns_utf, name_utf = _getNsTag(tag)
 *     c_doc = parent._doc._c_doc             # <<<<<<<<<<<<<<
 * 
 *     if parent._doc._parser is not None and parent._doc._parser._for_html:
 */
  __pyx_v_c_doc = __pyx_v_parent->_doc->_c_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":157
 *     c_doc = parent._doc._c_doc
 * 
 *     if parent._doc._parser is not None and parent._doc._parser._for_html:             # <<<<<<<<<<<<<<
 *         _htmlTagValidOrRaise(name_utf)
 *     else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_parent->_doc->_parser) != Py_None);
  if (__pyx_1) {
    __pyx_1 = __pyx_v_parent->_doc->_parser->_for_html;
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":158
 * 
 *     if parent._doc._parser is not None and parent._doc._parser._for_html:
 *         _htmlTagValidOrRaise(name_utf)             # <<<<<<<<<<<<<<
 *     else:
 *         _tagValidOrRaise(name_utf)
 */
    __pyx_5 = __pyx_f_4lxml_5etree__htmlTagValidOrRaise(__pyx_v_name_utf); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":160
 *         _htmlTagValidOrRaise(name_utf)
 *     else:
 *         _tagValidOrRaise(name_utf)             # <<<<<<<<<<<<<<
 * 
 *     c_node = _createElement(c_doc, name_utf)
 */
    __pyx_5 = __pyx_f_4lxml_5etree__tagValidOrRaise(__pyx_v_name_utf); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":162
 *         _tagValidOrRaise(name_utf)
 * 
 *     c_node = _createElement(c_doc, name_utf)             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         return python.PyErr_NoMemory()
 */
  __pyx_6 = __pyx_f_4lxml_5etree__createElement(__pyx_v_c_doc, __pyx_v_name_utf); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_node = __pyx_6;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":163
 * 
 *     c_node = _createElement(c_doc, name_utf)
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return python.PyErr_NoMemory()
 *     tree.xmlAddChild(parent._c_node, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":164
 *     c_node = _createElement(c_doc, name_utf)
 *     if c_node is NULL:
 *         return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     tree.xmlAddChild(parent._c_node, c_node)
 * 
 */
    __pyx_4 = PyErr_NoMemory(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct LxmlElement *)__pyx_4);
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":165
 *     if c_node is NULL:
 *         return python.PyErr_NoMemory()
 *     tree.xmlAddChild(parent._c_node, c_node)             # <<<<<<<<<<<<<<
 * 
 *     if text is not None:
 */
  xmlAddChild(__pyx_v_parent->_c_node, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":167
 *     tree.xmlAddChild(parent._c_node, c_node)
 * 
 *     if text is not None:             # <<<<<<<<<<<<<<
 *         _setNodeText(c_node, text)
 *     if tail is not None:
 */
  __pyx_1 = (__pyx_v_text != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":168
 * 
 *     if text is not None:
 *         _setNodeText(c_node, text)             # <<<<<<<<<<<<<<
 *     if tail is not None:
 *         _setTailText(c_node, tail)
 */
    __pyx_5 = __pyx_f_4lxml_5etree__setNodeText(__pyx_v_c_node, __pyx_v_text); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":169
 *     if text is not None:
 *         _setNodeText(c_node, text)
 *     if tail is not None:             # <<<<<<<<<<<<<<
 *         _setTailText(c_node, tail)
 * 
 */
  __pyx_1 = (__pyx_v_tail != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":170
 *         _setNodeText(c_node, text)
 *     if tail is not None:
 *         _setTailText(c_node, tail)             # <<<<<<<<<<<<<<
 * 
 *     # add namespaces to node if necessary
 */
    __pyx_5 = __pyx_f_4lxml_5etree__setTailText(__pyx_v_c_node, __pyx_v_tail); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":173
 * 
 *     # add namespaces to node if necessary
 *     _initNodeNamespaces(c_node, parent._doc, ns_utf, nsmap)             # <<<<<<<<<<<<<<
 *     _initNodeAttributes(c_node, parent._doc, attrib, extra_attrs)
 *     return _elementFactory(parent._doc, c_node)
 */
  __pyx_5 = __pyx_f_4lxml_5etree__initNodeNamespaces(__pyx_v_c_node, __pyx_v_parent->_doc, __pyx_v_ns_utf, __pyx_v_nsmap); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":174
 *     # add namespaces to node if necessary
 *     _initNodeNamespaces(c_node, parent._doc, ns_utf, nsmap)
 *     _initNodeAttributes(c_node, parent._doc, attrib, extra_attrs)             # <<<<<<<<<<<<<<
 *     return _elementFactory(parent._doc, c_node)
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__initNodeAttributes(__pyx_v_c_node, __pyx_v_parent->_doc, __pyx_v_attrib, __pyx_v_extra_attrs); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":175
 *     _initNodeNamespaces(c_node, parent._doc, ns_utf, nsmap)
 *     _initNodeAttributes(c_node, parent._doc, attrib, extra_attrs)
 *     return _elementFactory(parent._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef int _initNodeNamespaces(xmlNode* c_node, _Document doc,
 */
  __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_parent->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_3);
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._makeSubElement");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":177
 *     return _elementFactory(parent._doc, c_node)
 * 
 * cdef int _initNodeNamespaces(xmlNode* c_node, _Document doc,             # <<<<<<<<<<<<<<
 *                              object node_ns_utf, object nsmap) except -1:
 *     u"""Lookup current namespace prefixes, then set namespace structure for
 */

static  int __pyx_f_4lxml_5etree__initNodeNamespaces(xmlNode *__pyx_v_c_node, struct LxmlDocument *__pyx_v_doc, PyObject *__pyx_v_node_ns_utf, PyObject *__pyx_v_nsmap) {
  xmlNs *__pyx_v_c_ns;
  char *__pyx_v_c_prefix;
  char *__pyx_v_c_href;
  PyObject *__pyx_v_nsdefs;
  PyObject *__pyx_v_item;
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_v_href;
  PyObject *__pyx_v_href_utf;
  PyObject *__pyx_v_prefix_utf;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_ssize_t __pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  Py_INCREF(__pyx_v_node_ns_utf);
  __pyx_v_nsdefs = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);
  __pyx_v_href = Py_None; Py_INCREF(Py_None);
  __pyx_v_href_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":187
 *     cdef char*  c_prefix
 *     cdef char*  c_href
 *     if not nsmap:             # <<<<<<<<<<<<<<
 *         if node_ns_utf is not None:
 *             doc._setNodeNs(c_node, _cstr(node_ns_utf))
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_nsmap); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":188
 *     cdef char*  c_href
 *     if not nsmap:
 *         if node_ns_utf is not None:             # <<<<<<<<<<<<<<
 *             doc._setNodeNs(c_node, _cstr(node_ns_utf))
 *         return 0
 */
    __pyx_1 = (__pyx_v_node_ns_utf != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":189
 *     if not nsmap:
 *         if node_ns_utf is not None:
 *             doc._setNodeNs(c_node, _cstr(node_ns_utf))             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->_setNodeNs(__pyx_v_doc, __pyx_v_c_node, PyString_AS_STRING(__pyx_v_node_ns_utf)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":190
 *         if node_ns_utf is not None:
 *             doc._setNodeNs(c_node, _cstr(node_ns_utf))
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     nsdefs = list(nsmap.items())
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":192
 *         return 0
 * 
 *     nsdefs = list(nsmap.items())             # <<<<<<<<<<<<<<
 *     if None in nsmap and python.PyList_GET_SIZE(nsdefs) > 1:
 *         # Move the default namespace to the end.  This makes sure libxml2
 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_nsmap, __pyx_kp_items); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
  __pyx_5 = 0;
  __pyx_5 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  Py_DECREF(__pyx_v_nsdefs);
  __pyx_v_nsdefs = __pyx_5;
  __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":193
 * 
 *     nsdefs = list(nsmap.items())
 *     if None in nsmap and python.PyList_GET_SIZE(nsdefs) > 1:             # <<<<<<<<<<<<<<
 *         # Move the default namespace to the end.  This makes sure libxml2
 *         # prefers a prefix if the ns is defined redundantly on the same
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_nsmap, Py_None)); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {
    __pyx_2 = (PyList_GET_SIZE(__pyx_v_nsdefs) > 1);
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":200
 *         # elements serialise without prefix (i.e. into the non-default
 *         # namespace).
 *         item = (None, nsmap[None])             # <<<<<<<<<<<<<<
 *         nsdefs.remove(item)
 *         nsdefs.append(item)
 */
    __pyx_4 = PyObject_GetItem(__pyx_v_nsmap, Py_None); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_5, 0, Py_None);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    __pyx_4 = 0;
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = ((PyObject *)__pyx_5);
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":201
 *         # namespace).
 *         item = (None, nsmap[None])
 *         nsdefs.remove(item)             # <<<<<<<<<<<<<<
 *         nsdefs.append(item)
 * 
 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_nsdefs, __pyx_kp_remove); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_item);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_item);
    __pyx_6 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":202
 *         item = (None, nsmap[None])
 *         nsdefs.remove(item)
 *         nsdefs.append(item)             # <<<<<<<<<<<<<<
 * 
 *     for prefix, href in nsdefs:
 */
    __pyx_4 = __Pyx_PyObject_Append(__pyx_v_nsdefs, __pyx_v_item); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":204
 *         nsdefs.append(item)
 * 
 *     for prefix, href in nsdefs:             # <<<<<<<<<<<<<<
 *         href_utf = _utf8(href)
 *         c_href = _cstr(href_utf)
 */
  if (PyList_CheckExact(__pyx_v_nsdefs) || PyTuple_CheckExact(__pyx_v_nsdefs)) {
    __pyx_7 = 0; __pyx_5 = __pyx_v_nsdefs; Py_INCREF(__pyx_5);
  } else {
    __pyx_7 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_nsdefs); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_5))) {
      if (__pyx_7 >= PyList_GET_SIZE(__pyx_5)) break;
      __pyx_6 = PyList_GET_ITEM(__pyx_5, __pyx_7); Py_INCREF(__pyx_6); __pyx_7++;
    } else if (likely(PyTuple_CheckExact(__pyx_5))) {
      if (__pyx_7 >= PyTuple_GET_SIZE(__pyx_5)) break;
      __pyx_6 = PyTuple_GET_ITEM(__pyx_5, __pyx_7); Py_INCREF(__pyx_6); __pyx_7++;
    } else {
      __pyx_6 = PyIter_Next(__pyx_5);
      if (!__pyx_6) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_6) && PyTuple_GET_SIZE(__pyx_6) == 2) {
      PyObject* tuple = __pyx_6;
      __pyx_8 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_8);
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_8;
      __pyx_8 = 0;
      __pyx_8 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_8);
      Py_DECREF(__pyx_v_href);
      __pyx_v_href = __pyx_8;
      __pyx_8 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_8 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_8;
      __pyx_8 = 0;
      __pyx_8 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_href);
      __pyx_v_href = __pyx_8;
      __pyx_8 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":205
 * 
 *     for prefix, href in nsdefs:
 *         href_utf = _utf8(href)             # <<<<<<<<<<<<<<
 *         c_href = _cstr(href_utf)
 *         if prefix is not None:
 */
    __pyx_8 = __pyx_f_4lxml_5etree__utf8(__pyx_v_href); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_href_utf);
    __pyx_v_href_utf = __pyx_8;
    __pyx_8 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":206
 *     for prefix, href in nsdefs:
 *         href_utf = _utf8(href)
 *         c_href = _cstr(href_utf)             # <<<<<<<<<<<<<<
 *         if prefix is not None:
 *             prefix_utf = _utf8(prefix)
 */
    __pyx_v_c_href = PyString_AS_STRING(__pyx_v_href_utf);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":207
 *         href_utf = _utf8(href)
 *         c_href = _cstr(href_utf)
 *         if prefix is not None:             # <<<<<<<<<<<<<<
 *             prefix_utf = _utf8(prefix)
 *             _prefixValidOrRaise(prefix_utf)
 */
    __pyx_1 = (__pyx_v_prefix != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":208
 *         c_href = _cstr(href_utf)
 *         if prefix is not None:
 *             prefix_utf = _utf8(prefix)             # <<<<<<<<<<<<<<
 *             _prefixValidOrRaise(prefix_utf)
 *             c_prefix = _cstr(prefix_utf)
 */
      __pyx_6 = __pyx_f_4lxml_5etree__utf8(__pyx_v_prefix); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix_utf);
      __pyx_v_prefix_utf = __pyx_6;
      __pyx_6 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":209
 *         if prefix is not None:
 *             prefix_utf = _utf8(prefix)
 *             _prefixValidOrRaise(prefix_utf)             # <<<<<<<<<<<<<<
 *             c_prefix = _cstr(prefix_utf)
 *         else:
 */
      __pyx_3 = __pyx_f_4lxml_5etree__prefixValidOrRaise(__pyx_v_prefix_utf); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":210
 *             prefix_utf = _utf8(prefix)
 *             _prefixValidOrRaise(prefix_utf)
 *             c_prefix = _cstr(prefix_utf)             # <<<<<<<<<<<<<<
 *         else:
 *             c_prefix = NULL
 */
      __pyx_v_c_prefix = PyString_AS_STRING(__pyx_v_prefix_utf);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":212
 *             c_prefix = _cstr(prefix_utf)
 *         else:
 *             c_prefix = NULL             # <<<<<<<<<<<<<<
 *         # add namespace with prefix if it is not already known
 *         c_ns = tree.xmlSearchNs(doc._c_doc, c_node, c_prefix)
 */
      __pyx_v_c_prefix = NULL;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":214
 *             c_prefix = NULL
 *         # add namespace with prefix if it is not already known
 *         c_ns = tree.xmlSearchNs(doc._c_doc, c_node, c_prefix)             # <<<<<<<<<<<<<<
 *         if c_ns is NULL or \
 *                 c_ns.href is NULL or \
 */
    __pyx_v_c_ns = xmlSearchNs(__pyx_v_doc->_c_doc, __pyx_v_c_node, __pyx_v_c_prefix);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":215
 *         # add namespace with prefix if it is not already known
 *         c_ns = tree.xmlSearchNs(doc._c_doc, c_node, c_prefix)
 *         if c_ns is NULL or \             # <<<<<<<<<<<<<<
 *                 c_ns.href is NULL or \
 *                 cstd.strcmp(c_ns.href, c_href) != 0:
 */
    __pyx_2 = (__pyx_v_c_ns == NULL);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":216
 *         c_ns = tree.xmlSearchNs(doc._c_doc, c_node, c_prefix)
 *         if c_ns is NULL or \
 *                 c_ns.href is NULL or \             # <<<<<<<<<<<<<<
 *                 cstd.strcmp(c_ns.href, c_href) != 0:
 *             c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 */
      __pyx_2 = (__pyx_v_c_ns->href == NULL);
      if (!__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":217
 *         if c_ns is NULL or \
 *                 c_ns.href is NULL or \
 *                 cstd.strcmp(c_ns.href, c_href) != 0:             # <<<<<<<<<<<<<<
 *             c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 *         if href_utf == node_ns_utf:
 */
        __pyx_2 = (strcmp(__pyx_v_c_ns->href, __pyx_v_c_href) != 0);
      }
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":218
 *                 c_ns.href is NULL or \
 *                 cstd.strcmp(c_ns.href, c_href) != 0:
 *             c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)             # <<<<<<<<<<<<<<
 *         if href_utf == node_ns_utf:
 *             tree.xmlSetNs(c_node, c_ns)
 */
      __pyx_v_c_ns = xmlNewNs(__pyx_v_c_node, __pyx_v_c_href, __pyx_v_c_prefix);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":219
 *                 cstd.strcmp(c_ns.href, c_href) != 0:
 *             c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 *         if href_utf == node_ns_utf:             # <<<<<<<<<<<<<<
 *             tree.xmlSetNs(c_node, c_ns)
 *             node_ns_utf = None
 */
    __pyx_4 = PyObject_RichCompare(__pyx_v_href_utf, __pyx_v_node_ns_utf, Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":220
 *             c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
 *         if href_utf == node_ns_utf:
 *             tree.xmlSetNs(c_node, c_ns)             # <<<<<<<<<<<<<<
 *             node_ns_utf = None
 * 
 */
      xmlSetNs(__pyx_v_c_node, __pyx_v_c_ns);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":221
 *         if href_utf == node_ns_utf:
 *             tree.xmlSetNs(c_node, c_ns)
 *             node_ns_utf = None             # <<<<<<<<<<<<<<
 * 
 *     if node_ns_utf is not None:
 */
      Py_INCREF(Py_None);
      Py_DECREF(__pyx_v_node_ns_utf);
      __pyx_v_node_ns_utf = Py_None;
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":223
 *             node_ns_utf = None
 * 
 *     if node_ns_utf is not None:             # <<<<<<<<<<<<<<
 *         doc._setNodeNs(c_node, _cstr(node_ns_utf))
 *     return 0
 */
  __pyx_2 = (__pyx_v_node_ns_utf != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":224
 * 
 *     if node_ns_utf is not None:
 *         doc._setNodeNs(c_node, _cstr(node_ns_utf))             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->_setNodeNs(__pyx_v_doc, __pyx_v_c_node, PyString_AS_STRING(__pyx_v_node_ns_utf)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":225
 *     if node_ns_utf is not None:
 *         doc._setNodeNs(c_node, _cstr(node_ns_utf))
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef _initNodeAttributes(xmlNode* c_node, _Document doc, attrib, extra):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("lxml.etree._initNodeNamespaces");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_nsdefs);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_prefix);
  Py_DECREF(__pyx_v_href);
  Py_DECREF(__pyx_v_href_utf);
  Py_DECREF(__pyx_v_prefix_utf);
  Py_DECREF(__pyx_v_node_ns_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":227
 *     return 0
 * 
 * cdef _initNodeAttributes(xmlNode* c_node, _Document doc, attrib, extra):             # <<<<<<<<<<<<<<
 *     u"""Initialise the attributes of an element node.
 *     """
 */

static  PyObject *__pyx_f_4lxml_5etree__initNodeAttributes(xmlNode *__pyx_v_c_node, struct LxmlDocument *__pyx_v_doc, PyObject *__pyx_v_attrib, PyObject *__pyx_v_extra) {
  int __pyx_v_is_html;
  xmlNs *__pyx_v_c_ns;
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_attr_ns_utf;
  PyObject *__pyx_v_attr_name_utf;
  PyObject *__pyx_v_value_utf;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  int __pyx_8;
  xmlNs *__pyx_9;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_attrib);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);
  __pyx_v_attr_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_attr_name_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_value_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":233
 *     cdef xmlNs* c_ns
 *     # 'extra' is not checked here (expected to be a keyword dict)
 *     if attrib is not None and not hasattr(attrib, u'items'):             # <<<<<<<<<<<<<<
 *         raise TypeError, u"Invalid attribute dictionary: %s" % \
 *             python._fqtypename(attrib)
 */
  __pyx_1 = (__pyx_v_attrib != Py_None);
  if (__pyx_1) {
    __pyx_2 = PyObject_HasAttr(__pyx_v_attrib, ((PyObject *)__pyx_kp_309)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = (!__pyx_2);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":235
 *     if attrib is not None and not hasattr(attrib, u'items'):
 *         raise TypeError, u"Invalid attribute dictionary: %s" % \
 *             python._fqtypename(attrib)             # <<<<<<<<<<<<<<
 *     if extra is not None and extra:
 *         if attrib is None:
 */
    __pyx_3 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_attrib)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_310), __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":236
 *         raise TypeError, u"Invalid attribute dictionary: %s" % \
 *             python._fqtypename(attrib)
 *     if extra is not None and extra:             # <<<<<<<<<<<<<<
 *         if attrib is None:
 *             attrib = extra
 */
  __pyx_2 = (__pyx_v_extra != Py_None);
  if (__pyx_2) {
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_extra); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __pyx_1;
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":237
 *             python._fqtypename(attrib)
 *     if extra is not None and extra:
 *         if attrib is None:             # <<<<<<<<<<<<<<
 *             attrib = extra
 *         else:
 */
    __pyx_1 = (__pyx_v_attrib == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":238
 *     if extra is not None and extra:
 *         if attrib is None:
 *             attrib = extra             # <<<<<<<<<<<<<<
 *         else:
 *             attrib.update(extra)
 */
      Py_INCREF(__pyx_v_extra);
      Py_DECREF(__pyx_v_attrib);
      __pyx_v_attrib = __pyx_v_extra;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":240
 *             attrib = extra
 *         else:
 *             attrib.update(extra)             # <<<<<<<<<<<<<<
 *     if attrib:
 *         is_html = doc._parser._for_html
 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_attrib, __pyx_kp_update); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_extra);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_extra);
      __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":241
 *         else:
 *             attrib.update(extra)
 *     if attrib:             # <<<<<<<<<<<<<<
 *         is_html = doc._parser._for_html
 *         for name, value in attrib.items():
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_attrib); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":242
 *             attrib.update(extra)
 *     if attrib:
 *         is_html = doc._parser._for_html             # <<<<<<<<<<<<<<
 *         for name, value in attrib.items():
 *             attr_ns_utf, attr_name_utf = _getNsTag(name)
 */
    __pyx_v_is_html = __pyx_v_doc->_parser->_for_html;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":243
 *     if attrib:
 *         is_html = doc._parser._for_html
 *         for name, value in attrib.items():             # <<<<<<<<<<<<<<
 *             attr_ns_utf, attr_name_utf = _getNsTag(name)
 *             if not is_html:
 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_attrib, __pyx_kp_items); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
      __pyx_6 = 0; __pyx_5 = __pyx_4; Py_INCREF(__pyx_5);
    } else {
      __pyx_6 = -1; __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_5))) {
        if (__pyx_6 >= PyList_GET_SIZE(__pyx_5)) break;
        __pyx_3 = PyList_GET_ITEM(__pyx_5, __pyx_6); Py_INCREF(__pyx_3); __pyx_6++;
      } else if (likely(PyTuple_CheckExact(__pyx_5))) {
        if (__pyx_6 >= PyTuple_GET_SIZE(__pyx_5)) break;
        __pyx_3 = PyTuple_GET_ITEM(__pyx_5, __pyx_6); Py_INCREF(__pyx_3); __pyx_6++;
      } else {
        __pyx_3 = PyIter_Next(__pyx_5);
        if (!__pyx_3) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
        PyObject* tuple = __pyx_3;
        __pyx_7 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_7);
        Py_DECREF(__pyx_v_name);
        __pyx_v_name = __pyx_7;
        __pyx_7 = 0;
        __pyx_7 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_7);
        Py_DECREF(__pyx_v_value);
        __pyx_v_value = __pyx_7;
        __pyx_7 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
      }
      else {
        __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_7 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_name);
        __pyx_v_name = __pyx_7;
        __pyx_7 = 0;
        __pyx_7 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_value);
        __pyx_v_value = __pyx_7;
        __pyx_7 = 0;
        if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":244
 *         is_html = doc._parser._for_html
 *         for name, value in attrib.items():
 *             attr_ns_utf, attr_name_utf = _getNsTag(name)             # <<<<<<<<<<<<<<
 *             if not is_html:
 *                 _attributeValidOrRaise(attr_name_utf)
 */
      __pyx_7 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_name); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (PyTuple_CheckExact(__pyx_7) && PyTuple_GET_SIZE(__pyx_7) == 2) {
        PyObject* tuple = __pyx_7;
        __pyx_4 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_4);
        Py_DECREF(__pyx_v_attr_ns_utf);
        __pyx_v_attr_ns_utf = __pyx_4;
        __pyx_4 = 0;
        __pyx_4 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_4);
        Py_DECREF(__pyx_v_attr_name_utf);
        __pyx_v_attr_name_utf = __pyx_4;
        __pyx_4 = 0;
        Py_DECREF(__pyx_7); __pyx_7 = 0;
      }
      else {
        __pyx_3 = PyObject_GetIter(__pyx_7); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_attr_ns_utf);
        __pyx_v_attr_ns_utf = __pyx_4;
        __pyx_4 = 0;
        __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_attr_name_utf);
        __pyx_v_attr_name_utf = __pyx_4;
        __pyx_4 = 0;
        if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":245
 *         for name, value in attrib.items():
 *             attr_ns_utf, attr_name_utf = _getNsTag(name)
 *             if not is_html:             # <<<<<<<<<<<<<<
 *                 _attributeValidOrRaise(attr_name_utf)
 *             value_utf = _utf8(value)
 */
      __pyx_1 = (!__pyx_v_is_html);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":246
 *             attr_ns_utf, attr_name_utf = _getNsTag(name)
 *             if not is_html:
 *                 _attributeValidOrRaise(attr_name_utf)             # <<<<<<<<<<<<<<
 *             value_utf = _utf8(value)
 *             if attr_ns_utf is None:
 */
        __pyx_8 = __pyx_f_4lxml_5etree__attributeValidOrRaise(__pyx_v_attr_name_utf); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":247
 *             if not is_html:
 *                 _attributeValidOrRaise(attr_name_utf)
 *             value_utf = _utf8(value)             # <<<<<<<<<<<<<<
 *             if attr_ns_utf is None:
 *                 tree.xmlNewProp(c_node, _cstr(attr_name_utf), _cstr(value_utf))
 */
      __pyx_4 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_value_utf);
      __pyx_v_value_utf = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":248
 *                 _attributeValidOrRaise(attr_name_utf)
 *             value_utf = _utf8(value)
 *             if attr_ns_utf is None:             # <<<<<<<<<<<<<<
 *                 tree.xmlNewProp(c_node, _cstr(attr_name_utf), _cstr(value_utf))
 *             else:
 */
      __pyx_2 = (__pyx_v_attr_ns_utf == Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":249
 *             value_utf = _utf8(value)
 *             if attr_ns_utf is None:
 *                 tree.xmlNewProp(c_node, _cstr(attr_name_utf), _cstr(value_utf))             # <<<<<<<<<<<<<<
 *             else:
 *                 c_ns = doc._findOrBuildNodeNs(c_node, _cstr(attr_ns_utf), NULL)
 */
        xmlNewProp(__pyx_v_c_node, PyString_AS_STRING(__pyx_v_attr_name_utf), PyString_AS_STRING(__pyx_v_value_utf));
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":251
 *                 tree.xmlNewProp(c_node, _cstr(attr_name_utf), _cstr(value_utf))
 *             else:
 *                 c_ns = doc._findOrBuildNodeNs(c_node, _cstr(attr_ns_utf), NULL)             # <<<<<<<<<<<<<<
 *                 tree.xmlNewNsProp(c_node, c_ns,
 *                                   _cstr(attr_name_utf), _cstr(value_utf))
 */
        __pyx_9 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->_findOrBuildNodeNs(__pyx_v_doc, __pyx_v_c_node, PyString_AS_STRING(__pyx_v_attr_ns_utf), NULL); if (unlikely(__pyx_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_c_ns = __pyx_9;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":253
 *                 c_ns = doc._findOrBuildNodeNs(c_node, _cstr(attr_ns_utf), NULL)
 *                 tree.xmlNewNsProp(c_node, c_ns,
 *                                   _cstr(attr_name_utf), _cstr(value_utf))             # <<<<<<<<<<<<<<
 * 
 * ctypedef struct _ns_node_ref:
 */
        xmlNewNsProp(__pyx_v_c_node, __pyx_v_c_ns, PyString_AS_STRING(__pyx_v_attr_name_utf), PyString_AS_STRING(__pyx_v_value_utf));
      }
      __pyx_L10:;
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree._initNodeAttributes");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_attr_ns_utf);
  Py_DECREF(__pyx_v_attr_name_utf);
  Py_DECREF(__pyx_v_value_utf);
  Py_DECREF(__pyx_v_attrib);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":259
 *     xmlNode* node
 * 
 * cdef int _removeUnusedNamespaceDeclarations(xmlNode* c_element) except -1:             # <<<<<<<<<<<<<<
 *     u"""Remove any namespace declarations from a subtree that do not used
 *     by any of its elements (or attributes).
 */

static  int __pyx_f_4lxml_5etree__removeUnusedNamespaceDeclarations(xmlNode *__pyx_v_c_element) {
  __pyx_t_4lxml_5etree__ns_node_ref *__pyx_v_c_ns_list;
  __pyx_t_4lxml_5etree__ns_node_ref *__pyx_v_c_nsref_ptr;
  xmlNs *__pyx_v_c_nsdef;
  xmlNode *__pyx_v_c_node;
  size_t __pyx_v_c_ns_list_size;
  size_t __pyx_v_c_ns_list_len;
  size_t __pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":271
 *     cdef cstd.size_t i
 * 
 *     c_ns_list = NULL             # <<<<<<<<<<<<<<
 *     c_ns_list_size = 0
 *     c_ns_list_len  = 0
 */
  __pyx_v_c_ns_list = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":272
 * 
 *     c_ns_list = NULL
 *     c_ns_list_size = 0             # <<<<<<<<<<<<<<
 *     c_ns_list_len  = 0
 * 
 */
  __pyx_v_c_ns_list_size = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":273
 *     c_ns_list = NULL
 *     c_ns_list_size = 0
 *     c_ns_list_len  = 0             # <<<<<<<<<<<<<<
 * 
 *     if c_element.parent is not NULL and \
 */
  __pyx_v_c_ns_list_len = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":275
 *     c_ns_list_len  = 0
 * 
 *     if c_element.parent is not NULL and \             # <<<<<<<<<<<<<<
 *             c_element.parent.type == tree.XML_DOCUMENT_NODE:
 *         # include the document node
 */
  __pyx_1 = (__pyx_v_c_element->parent != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":276
 * 
 *     if c_element.parent is not NULL and \
 *             c_element.parent.type == tree.XML_DOCUMENT_NODE:             # <<<<<<<<<<<<<<
 *         # include the document node
 *         c_nsdef = c_element.parent.nsDef
 */
    __pyx_1 = (__pyx_v_c_element->parent->type == XML_DOCUMENT_NODE);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":278
 *             c_element.parent.type == tree.XML_DOCUMENT_NODE:
 *         # include the document node
 *         c_nsdef = c_element.parent.nsDef             # <<<<<<<<<<<<<<
 *         while c_nsdef is not NULL:
 *             if c_ns_list_len >= c_ns_list_size:
 */
    __pyx_v_c_nsdef = __pyx_v_c_element->parent->nsDef;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":279
 *         # include the document node
 *         c_nsdef = c_element.parent.nsDef
 *         while c_nsdef is not NULL:             # <<<<<<<<<<<<<<
 *             if c_ns_list_len >= c_ns_list_size:
 *                 if c_ns_list is NULL:
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_nsdef != NULL);
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":280
 *         c_nsdef = c_element.parent.nsDef
 *         while c_nsdef is not NULL:
 *             if c_ns_list_len >= c_ns_list_size:             # <<<<<<<<<<<<<<
 *                 if c_ns_list is NULL:
 *                     c_ns_list_size = 20
 */
      __pyx_1 = (__pyx_v_c_ns_list_len >= __pyx_v_c_ns_list_size);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":281
 *         while c_nsdef is not NULL:
 *             if c_ns_list_len >= c_ns_list_size:
 *                 if c_ns_list is NULL:             # <<<<<<<<<<<<<<
 *                     c_ns_list_size = 20
 *                 else:
 */
        __pyx_1 = (__pyx_v_c_ns_list == NULL);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":282
 *             if c_ns_list_len >= c_ns_list_size:
 *                 if c_ns_list is NULL:
 *                     c_ns_list_size = 20             # <<<<<<<<<<<<<<
 *                 else:
 *                     c_ns_list_size *= 2
 */
          __pyx_v_c_ns_list_size = 20;
          goto __pyx_L7;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":284
 *                     c_ns_list_size = 20
 *                 else:
 *                     c_ns_list_size *= 2             # <<<<<<<<<<<<<<
 *                 c_nsref_ptr = <_ns_node_ref*> cstd.realloc(
 *                     c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))
 */
          __pyx_v_c_ns_list_size *= 2;
        }
        __pyx_L7:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":286
 *                     c_ns_list_size *= 2
 *                 c_nsref_ptr = <_ns_node_ref*> cstd.realloc(
 *                     c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))             # <<<<<<<<<<<<<<
 *                 if c_nsref_ptr is NULL:
 *                     if c_ns_list is not NULL:
 */
        __pyx_v_c_nsref_ptr = ((__pyx_t_4lxml_5etree__ns_node_ref *)realloc(__pyx_v_c_ns_list, (__pyx_v_c_ns_list_size * (sizeof(__pyx_t_4lxml_5etree__ns_node_ref)))));

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":287
 *                 c_nsref_ptr = <_ns_node_ref*> cstd.realloc(
 *                     c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))
 *                 if c_nsref_ptr is NULL:             # <<<<<<<<<<<<<<
 *                     if c_ns_list is not NULL:
 *                         cstd.free(c_ns_list)
 */
        __pyx_1 = (__pyx_v_c_nsref_ptr == NULL);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":288
 *                     c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))
 *                 if c_nsref_ptr is NULL:
 *                     if c_ns_list is not NULL:             # <<<<<<<<<<<<<<
 *                         cstd.free(c_ns_list)
 *                     python.PyErr_NoMemory()
 */
          __pyx_1 = (__pyx_v_c_ns_list != NULL);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":289
 *                 if c_nsref_ptr is NULL:
 *                     if c_ns_list is not NULL:
 *                         cstd.free(c_ns_list)             # <<<<<<<<<<<<<<
 *                     python.PyErr_NoMemory()
 *                     return -1
 */
            free(__pyx_v_c_ns_list);
            goto __pyx_L9;
          }
          __pyx_L9:;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":290
 *                     if c_ns_list is not NULL:
 *                         cstd.free(c_ns_list)
 *                     python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *                     return -1
 *                 c_ns_list = c_nsref_ptr
 */
          __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":291
 *                         cstd.free(c_ns_list)
 *                     python.PyErr_NoMemory()
 *                     return -1             # <<<<<<<<<<<<<<
 *                 c_ns_list = c_nsref_ptr
 * 
 */
          __pyx_r = -1;
          goto __pyx_L0;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":292
 *                     python.PyErr_NoMemory()
 *                     return -1
 *                 c_ns_list = c_nsref_ptr             # <<<<<<<<<<<<<<
 * 
 *             c_ns_list[c_ns_list_len].ns   = c_nsdef
 */
        __pyx_v_c_ns_list = __pyx_v_c_nsref_ptr;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":294
 *                 c_ns_list = c_nsref_ptr
 * 
 *             c_ns_list[c_ns_list_len].ns   = c_nsdef             # <<<<<<<<<<<<<<
 *             c_ns_list[c_ns_list_len].node = c_element.parent
 *             c_ns_list_len += 1
 */
      (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).ns = __pyx_v_c_nsdef;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":295
 * 
 *             c_ns_list[c_ns_list_len].ns   = c_nsdef
 *             c_ns_list[c_ns_list_len].node = c_element.parent             # <<<<<<<<<<<<<<
 *             c_ns_list_len += 1
 *             c_nsdef = c_nsdef.next
 */
      (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).node = __pyx_v_c_element->parent;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":296
 *             c_ns_list[c_ns_list_len].ns   = c_nsdef
 *             c_ns_list[c_ns_list_len].node = c_element.parent
 *             c_ns_list_len += 1             # <<<<<<<<<<<<<<
 *             c_nsdef = c_nsdef.next
 * 
 */
      __pyx_v_c_ns_list_len += 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":297
 *             c_ns_list[c_ns_list_len].node = c_element.parent
 *             c_ns_list_len += 1
 *             c_nsdef = c_nsdef.next             # <<<<<<<<<<<<<<
 * 
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_element, c_element, 1)
 */
      __pyx_v_c_nsdef = __pyx_v_c_nsdef->next;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":299
 *             c_nsdef = c_nsdef.next
 * 
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_element, c_element, 1)             # <<<<<<<<<<<<<<
 *     # collect all new namespace declarations into the ns list
 *     c_nsdef = c_element.nsDef
 */
  BEGIN_FOR_EACH_ELEMENT_FROM(__pyx_v_c_element, __pyx_v_c_element, 1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":301
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_element, c_element, 1)
 *     # collect all new namespace declarations into the ns list
 *     c_nsdef = c_element.nsDef             # <<<<<<<<<<<<<<
 *     while c_nsdef is not NULL:
 *         if c_ns_list_len >= c_ns_list_size:
 */
  __pyx_v_c_nsdef = __pyx_v_c_element->nsDef;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":302
 *     # collect all new namespace declarations into the ns list
 *     c_nsdef = c_element.nsDef
 *     while c_nsdef is not NULL:             # <<<<<<<<<<<<<<
 *         if c_ns_list_len >= c_ns_list_size:
 *             if c_ns_list is NULL:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_nsdef != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":303
 *     c_nsdef = c_element.nsDef
 *     while c_nsdef is not NULL:
 *         if c_ns_list_len >= c_ns_list_size:             # <<<<<<<<<<<<<<
 *             if c_ns_list is NULL:
 *                 c_ns_list_size = 20
 */
    __pyx_1 = (__pyx_v_c_ns_list_len >= __pyx_v_c_ns_list_size);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":304
 *     while c_nsdef is not NULL:
 *         if c_ns_list_len >= c_ns_list_size:
 *             if c_ns_list is NULL:             # <<<<<<<<<<<<<<
 *                 c_ns_list_size = 20
 *             else:
 */
      __pyx_1 = (__pyx_v_c_ns_list == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":305
 *         if c_ns_list_len >= c_ns_list_size:
 *             if c_ns_list is NULL:
 *                 c_ns_list_size = 20             # <<<<<<<<<<<<<<
 *             else:
 *                 c_ns_list_size *= 2
 */
        __pyx_v_c_ns_list_size = 20;
        goto __pyx_L13;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":307
 *                 c_ns_list_size = 20
 *             else:
 *                 c_ns_list_size *= 2             # <<<<<<<<<<<<<<
 *             c_nsref_ptr = <_ns_node_ref*> cstd.realloc(
 *                 c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))
 */
        __pyx_v_c_ns_list_size *= 2;
      }
      __pyx_L13:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":309
 *                 c_ns_list_size *= 2
 *             c_nsref_ptr = <_ns_node_ref*> cstd.realloc(
 *                 c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))             # <<<<<<<<<<<<<<
 *             if c_nsref_ptr is NULL:
 *                 if c_ns_list is not NULL:
 */
      __pyx_v_c_nsref_ptr = ((__pyx_t_4lxml_5etree__ns_node_ref *)realloc(__pyx_v_c_ns_list, (__pyx_v_c_ns_list_size * (sizeof(__pyx_t_4lxml_5etree__ns_node_ref)))));

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":310
 *             c_nsref_ptr = <_ns_node_ref*> cstd.realloc(
 *                 c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))
 *             if c_nsref_ptr is NULL:             # <<<<<<<<<<<<<<
 *                 if c_ns_list is not NULL:
 *                     cstd.free(c_ns_list)
 */
      __pyx_1 = (__pyx_v_c_nsref_ptr == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":311
 *                 c_ns_list, c_ns_list_size * sizeof(_ns_node_ref))
 *             if c_nsref_ptr is NULL:
 *                 if c_ns_list is not NULL:             # <<<<<<<<<<<<<<
 *                     cstd.free(c_ns_list)
 *                 python.PyErr_NoMemory()
 */
        __pyx_1 = (__pyx_v_c_ns_list != NULL);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":312
 *             if c_nsref_ptr is NULL:
 *                 if c_ns_list is not NULL:
 *                     cstd.free(c_ns_list)             # <<<<<<<<<<<<<<
 *                 python.PyErr_NoMemory()
 *                 return -1
 */
          free(__pyx_v_c_ns_list);
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":313
 *                 if c_ns_list is not NULL:
 *                     cstd.free(c_ns_list)
 *                 python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *                 return -1
 *             c_ns_list = c_nsref_ptr
 */
        __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":314
 *                     cstd.free(c_ns_list)
 *                 python.PyErr_NoMemory()
 *                 return -1             # <<<<<<<<<<<<<<
 *             c_ns_list = c_nsref_ptr
 * 
 */
        __pyx_r = -1;
        goto __pyx_L0;
        goto __pyx_L14;
      }
      __pyx_L14:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":315
 *                 python.PyErr_NoMemory()
 *                 return -1
 *             c_ns_list = c_nsref_ptr             # <<<<<<<<<<<<<<
 * 
 *         c_ns_list[c_ns_list_len].ns   = c_nsdef
 */
      __pyx_v_c_ns_list = __pyx_v_c_nsref_ptr;
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":317
 *             c_ns_list = c_nsref_ptr
 * 
 *         c_ns_list[c_ns_list_len].ns   = c_nsdef             # <<<<<<<<<<<<<<
 *         c_ns_list[c_ns_list_len].node = c_element
 *         c_ns_list_len += 1
 */
    (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).ns = __pyx_v_c_nsdef;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":318
 * 
 *         c_ns_list[c_ns_list_len].ns   = c_nsdef
 *         c_ns_list[c_ns_list_len].node = c_element             # <<<<<<<<<<<<<<
 *         c_ns_list_len += 1
 *         c_nsdef = c_nsdef.next
 */
    (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).node = __pyx_v_c_element;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":319
 *         c_ns_list[c_ns_list_len].ns   = c_nsdef
 *         c_ns_list[c_ns_list_len].node = c_element
 *         c_ns_list_len += 1             # <<<<<<<<<<<<<<
 *         c_nsdef = c_nsdef.next
 * 
 */
    __pyx_v_c_ns_list_len += 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":320
 *         c_ns_list[c_ns_list_len].node = c_element
 *         c_ns_list_len += 1
 *         c_nsdef = c_nsdef.next             # <<<<<<<<<<<<<<
 * 
 *     # remove all namespace declarations from the list that are referenced
 */
    __pyx_v_c_nsdef = __pyx_v_c_nsdef->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":323
 * 
 *     # remove all namespace declarations from the list that are referenced
 *     if c_element.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         c_node = c_element
 *         while c_node is not NULL:
 */
  __pyx_1 = (__pyx_v_c_element->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":324
 *     # remove all namespace declarations from the list that are referenced
 *     if c_element.type == tree.XML_ELEMENT_NODE:
 *         c_node = c_element             # <<<<<<<<<<<<<<
 *         while c_node is not NULL:
 *             if c_node.ns is not NULL:
 */
    __pyx_v_c_node = __pyx_v_c_element;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":325
 *     if c_element.type == tree.XML_ELEMENT_NODE:
 *         c_node = c_element
 *         while c_node is not NULL:             # <<<<<<<<<<<<<<
 *             if c_node.ns is not NULL:
 *                 for i from 0 <= i < c_ns_list_len:
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_node != NULL);
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":326
 *         c_node = c_element
 *         while c_node is not NULL:
 *             if c_node.ns is not NULL:             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < c_ns_list_len:
 *                     if c_node.ns is c_ns_list[i].ns:
 */
      __pyx_1 = (__pyx_v_c_node->ns != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":327
 *         while c_node is not NULL:
 *             if c_node.ns is not NULL:
 *                 for i from 0 <= i < c_ns_list_len:             # <<<<<<<<<<<<<<
 *                     if c_node.ns is c_ns_list[i].ns:
 *                         c_ns_list_len -= 1
 */
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_c_ns_list_len; __pyx_v_i++) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":328
 *             if c_node.ns is not NULL:
 *                 for i from 0 <= i < c_ns_list_len:
 *                     if c_node.ns is c_ns_list[i].ns:             # <<<<<<<<<<<<<<
 *                         c_ns_list_len -= 1
 *                         c_ns_list[i].ns   = c_ns_list[c_ns_list_len].ns
 */
          __pyx_1 = (__pyx_v_c_node->ns == (__pyx_v_c_ns_list[__pyx_v_i]).ns);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":329
 *                 for i from 0 <= i < c_ns_list_len:
 *                     if c_node.ns is c_ns_list[i].ns:
 *                         c_ns_list_len -= 1             # <<<<<<<<<<<<<<
 *                         c_ns_list[i].ns   = c_ns_list[c_ns_list_len].ns
 *                         c_ns_list[i].node = c_ns_list[c_ns_list_len].node
 */
            __pyx_v_c_ns_list_len -= 1;

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":330
 *                     if c_node.ns is c_ns_list[i].ns:
 *                         c_ns_list_len -= 1
 *                         c_ns_list[i].ns   = c_ns_list[c_ns_list_len].ns             # <<<<<<<<<<<<<<
 *                         c_ns_list[i].node = c_ns_list[c_ns_list_len].node
 *                         c_ns_list[c_ns_list_len].ns   = NULL
 */
            (__pyx_v_c_ns_list[__pyx_v_i]).ns = (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).ns;

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":331
 *                         c_ns_list_len -= 1
 *                         c_ns_list[i].ns   = c_ns_list[c_ns_list_len].ns
 *                         c_ns_list[i].node = c_ns_list[c_ns_list_len].node             # <<<<<<<<<<<<<<
 *                         c_ns_list[c_ns_list_len].ns   = NULL
 *                         c_ns_list[c_ns_list_len].node = NULL
 */
            (__pyx_v_c_ns_list[__pyx_v_i]).node = (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).node;

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":332
 *                         c_ns_list[i].ns   = c_ns_list[c_ns_list_len].ns
 *                         c_ns_list[i].node = c_ns_list[c_ns_list_len].node
 *                         c_ns_list[c_ns_list_len].ns   = NULL             # <<<<<<<<<<<<<<
 *                         c_ns_list[c_ns_list_len].node = NULL
 *                         break
 */
            (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).ns = NULL;

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":333
 *                         c_ns_list[i].node = c_ns_list[c_ns_list_len].node
 *                         c_ns_list[c_ns_list_len].ns   = NULL
 *                         c_ns_list[c_ns_list_len].node = NULL             # <<<<<<<<<<<<<<
 *                         break
 *             if c_node is c_element:
 */
            (__pyx_v_c_ns_list[__pyx_v_c_ns_list_len]).node = NULL;

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":334
 *                         c_ns_list[c_ns_list_len].ns   = NULL
 *                         c_ns_list[c_ns_list_len].node = NULL
 *                         break             # <<<<<<<<<<<<<<
 *             if c_node is c_element:
 *                 # continue with attributes
 */
            goto __pyx_L21;
            goto __pyx_L22;
          }
          __pyx_L22:;
        }
        __pyx_L21:;
        goto __pyx_L19;
      }
      __pyx_L19:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":335
 *                         c_ns_list[c_ns_list_len].node = NULL
 *                         break
 *             if c_node is c_element:             # <<<<<<<<<<<<<<
 *                 # continue with attributes
 *                 c_node = <xmlNode*>c_element.properties
 */
      __pyx_1 = (__pyx_v_c_node == __pyx_v_c_element);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":337
 *             if c_node is c_element:
 *                 # continue with attributes
 *                 c_node = <xmlNode*>c_element.properties             # <<<<<<<<<<<<<<
 *             else:
 *                 c_node = c_node.next
 */
        __pyx_v_c_node = ((xmlNode *)__pyx_v_c_element->properties);
        goto __pyx_L23;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":339
 *                 c_node = <xmlNode*>c_element.properties
 *             else:
 *                 c_node = c_node.next             # <<<<<<<<<<<<<<
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_element)
 * 
 */
        __pyx_v_c_node = __pyx_v_c_node->next;
      }
      __pyx_L23:;
    }
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":340
 *             else:
 *                 c_node = c_node.next
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_element)             # <<<<<<<<<<<<<<
 * 
 *     if c_ns_list is NULL:
 */
  END_FOR_EACH_ELEMENT_FROM(__pyx_v_c_element);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":342
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_element)
 * 
 *     if c_ns_list is NULL:             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_1 = (__pyx_v_c_ns_list == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":343
 * 
 *     if c_ns_list is NULL:
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     # free all namespace declarations that remained in the list
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L24;
  }
  __pyx_L24:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":346
 * 
 *     # free all namespace declarations that remained in the list
 *     for i from 0 <= i < c_ns_list_len:             # <<<<<<<<<<<<<<
 *         c_node = c_ns_list[i].node
 *         c_nsdef = c_node.nsDef
 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_c_ns_list_len; __pyx_v_i++) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":347
 *     # free all namespace declarations that remained in the list
 *     for i from 0 <= i < c_ns_list_len:
 *         c_node = c_ns_list[i].node             # <<<<<<<<<<<<<<
 *         c_nsdef = c_node.nsDef
 *         if c_nsdef is c_ns_list[i].ns:
 */
    __pyx_v_c_node = (__pyx_v_c_ns_list[__pyx_v_i]).node;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":348
 *     for i from 0 <= i < c_ns_list_len:
 *         c_node = c_ns_list[i].node
 *         c_nsdef = c_node.nsDef             # <<<<<<<<<<<<<<
 *         if c_nsdef is c_ns_list[i].ns:
 *             c_node.nsDef = c_node.nsDef.next
 */
    __pyx_v_c_nsdef = __pyx_v_c_node->nsDef;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":349
 *         c_node = c_ns_list[i].node
 *         c_nsdef = c_node.nsDef
 *         if c_nsdef is c_ns_list[i].ns:             # <<<<<<<<<<<<<<
 *             c_node.nsDef = c_node.nsDef.next
 *         else:
 */
    __pyx_1 = (__pyx_v_c_nsdef == (__pyx_v_c_ns_list[__pyx_v_i]).ns);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":350
 *         c_nsdef = c_node.nsDef
 *         if c_nsdef is c_ns_list[i].ns:
 *             c_node.nsDef = c_node.nsDef.next             # <<<<<<<<<<<<<<
 *         else:
 *             while c_nsdef.next is not c_ns_list[i].ns:
 */
      __pyx_v_c_node->nsDef = __pyx_v_c_node->nsDef->next;
      goto __pyx_L27;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":352
 *             c_node.nsDef = c_node.nsDef.next
 *         else:
 *             while c_nsdef.next is not c_ns_list[i].ns:             # <<<<<<<<<<<<<<
 *                 c_nsdef = c_nsdef.next
 *             c_nsdef.next = c_nsdef.next.next
 */
      while (1) {
        __pyx_1 = (__pyx_v_c_nsdef->next != (__pyx_v_c_ns_list[__pyx_v_i]).ns);
        if (!__pyx_1) break;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":353
 *         else:
 *             while c_nsdef.next is not c_ns_list[i].ns:
 *                 c_nsdef = c_nsdef.next             # <<<<<<<<<<<<<<
 *             c_nsdef.next = c_nsdef.next.next
 *         tree.xmlFreeNs(c_ns_list[i].ns)
 */
        __pyx_v_c_nsdef = __pyx_v_c_nsdef->next;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":354
 *             while c_nsdef.next is not c_ns_list[i].ns:
 *                 c_nsdef = c_nsdef.next
 *             c_nsdef.next = c_nsdef.next.next             # <<<<<<<<<<<<<<
 *         tree.xmlFreeNs(c_ns_list[i].ns)
 * 
 */
      __pyx_v_c_nsdef->next = __pyx_v_c_nsdef->next->next;
    }
    __pyx_L27:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":355
 *                 c_nsdef = c_nsdef.next
 *             c_nsdef.next = c_nsdef.next.next
 *         tree.xmlFreeNs(c_ns_list[i].ns)             # <<<<<<<<<<<<<<
 * 
 *     if c_ns_list is not NULL:
 */
    xmlFreeNs((__pyx_v_c_ns_list[__pyx_v_i]).ns);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":357
 *         tree.xmlFreeNs(c_ns_list[i].ns)
 * 
 *     if c_ns_list is not NULL:             # <<<<<<<<<<<<<<
 *         cstd.free(c_ns_list)
 *     return 0
 */
  __pyx_1 = (__pyx_v_c_ns_list != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":358
 * 
 *     if c_ns_list is not NULL:
 *         cstd.free(c_ns_list)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    free(__pyx_v_c_ns_list);
    goto __pyx_L30;
  }
  __pyx_L30:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":359
 *     if c_ns_list is not NULL:
 *         cstd.free(c_ns_list)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef object _attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._removeUnusedNamespaceDeclarations");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":361
 *     return 0
 * 
 * cdef object _attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):             # <<<<<<<<<<<<<<
 *     cdef char* value
 *     cdef char* href
 */

static  PyObject *__pyx_f_4lxml_5etree__attributeValue(xmlNode *__pyx_v_c_element, xmlAttr *__pyx_v_c_attrib_node) {
  char *__pyx_v_value;
  char *__pyx_v_href;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":364
 *     cdef char* value
 *     cdef char* href
 *     href = _getNs(<xmlNode*>c_attrib_node)             # <<<<<<<<<<<<<<
 *     if href is NULL:
 *         value = tree.xmlGetNoNsProp(c_element, c_attrib_node.name)
 */
  __pyx_v_href = _getNs(((xmlNode *)__pyx_v_c_attrib_node));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":365
 *     cdef char* href
 *     href = _getNs(<xmlNode*>c_attrib_node)
 *     if href is NULL:             # <<<<<<<<<<<<<<
 *         value = tree.xmlGetNoNsProp(c_element, c_attrib_node.name)
 *     else:
 */
  __pyx_1 = (__pyx_v_href == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":366
 *     href = _getNs(<xmlNode*>c_attrib_node)
 *     if href is NULL:
 *         value = tree.xmlGetNoNsProp(c_element, c_attrib_node.name)             # <<<<<<<<<<<<<<
 *     else:
 *         value = tree.xmlGetNsProp(c_element, c_attrib_node.name, href)
 */
    __pyx_v_value = xmlGetNoNsProp(__pyx_v_c_element, __pyx_v_c_attrib_node->name);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":368
 *         value = tree.xmlGetNoNsProp(c_element, c_attrib_node.name)
 *     else:
 *         value = tree.xmlGetNsProp(c_element, c_attrib_node.name, href)             # <<<<<<<<<<<<<<
 *     result = funicode(value)
 *     tree.xmlFree(value)
 */
    __pyx_v_value = xmlGetNsProp(__pyx_v_c_element, __pyx_v_c_attrib_node->name, __pyx_v_href);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":369
 *     else:
 *         value = tree.xmlGetNsProp(c_element, c_attrib_node.name, href)
 *     result = funicode(value)             # <<<<<<<<<<<<<<
 *     tree.xmlFree(value)
 *     return result
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_value); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":370
 *         value = tree.xmlGetNsProp(c_element, c_attrib_node.name, href)
 *     result = funicode(value)
 *     tree.xmlFree(value)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  xmlFree(__pyx_v_value);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":371
 *     result = funicode(value)
 *     tree.xmlFree(value)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef object _attributeValueFromNsName(xmlNode* c_element,
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._attributeValue");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":373
 *     return result
 * 
 * cdef object _attributeValueFromNsName(xmlNode* c_element,             # <<<<<<<<<<<<<<
 *                                       char* c_href, char* c_name):
 *     cdef char* c_result
 */

static  PyObject *__pyx_f_4lxml_5etree__attributeValueFromNsName(xmlNode *__pyx_v_c_element, char *__pyx_v_c_href, char *__pyx_v_c_name) {
  char *__pyx_v_c_result;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":376
 *                                       char* c_href, char* c_name):
 *     cdef char* c_result
 *     if c_href is NULL:             # <<<<<<<<<<<<<<
 *         c_result = tree.xmlGetNoNsProp(c_element, c_name)
 *     else:
 */
  __pyx_1 = (__pyx_v_c_href == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":377
 *     cdef char* c_result
 *     if c_href is NULL:
 *         c_result = tree.xmlGetNoNsProp(c_element, c_name)             # <<<<<<<<<<<<<<
 *     else:
 *         c_result = tree.xmlGetNsProp(c_element, c_name, c_href)
 */
    __pyx_v_c_result = xmlGetNoNsProp(__pyx_v_c_element, __pyx_v_c_name);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":379
 *         c_result = tree.xmlGetNoNsProp(c_element, c_name)
 *     else:
 *         c_result = tree.xmlGetNsProp(c_element, c_name, c_href)             # <<<<<<<<<<<<<<
 *     if c_result is NULL:
 *         return None
 */
    __pyx_v_c_result = xmlGetNsProp(__pyx_v_c_element, __pyx_v_c_name, __pyx_v_c_href);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":380
 *     else:
 *         c_result = tree.xmlGetNsProp(c_element, c_name, c_href)
 *     if c_result is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     result = funicode(c_result)
 */
  __pyx_1 = (__pyx_v_c_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":381
 *         c_result = tree.xmlGetNsProp(c_element, c_name, c_href)
 *     if c_result is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     result = funicode(c_result)
 *     tree.xmlFree(c_result)
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":382
 *     if c_result is NULL:
 *         return None
 *     result = funicode(c_result)             # <<<<<<<<<<<<<<
 *     tree.xmlFree(c_result)
 *     return result
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_result); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":383
 *         return None
 *     result = funicode(c_result)
 *     tree.xmlFree(c_result)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  xmlFree(__pyx_v_c_result);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":384
 *     result = funicode(c_result)
 *     tree.xmlFree(c_result)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef object _getNodeAttributeValue(xmlNode* c_node, key, default):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._attributeValueFromNsName");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":386
 *     return result
 * 
 * cdef object _getNodeAttributeValue(xmlNode* c_node, key, default):             # <<<<<<<<<<<<<<
 *     cdef char* c_result
 *     cdef char* c_tag
 */

static  PyObject *__pyx_f_4lxml_5etree__getNodeAttributeValue(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  char *__pyx_v_c_result;
  char *__pyx_v_c_tag;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_tag;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":389
 *     cdef char* c_result
 *     cdef char* c_tag
 *     ns, tag = _getNsTag(key)             # <<<<<<<<<<<<<<
 *     c_tag = _cstr(tag)
 *     if ns is None:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_key); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":390
 *     cdef char* c_tag
 *     ns, tag = _getNsTag(key)
 *     c_tag = _cstr(tag)             # <<<<<<<<<<<<<<
 *     if ns is None:
 *         c_result = tree.xmlGetNoNsProp(c_node, c_tag)
 */
  __pyx_v_c_tag = PyString_AS_STRING(__pyx_v_tag);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":391
 *     ns, tag = _getNsTag(key)
 *     c_tag = _cstr(tag)
 *     if ns is None:             # <<<<<<<<<<<<<<
 *         c_result = tree.xmlGetNoNsProp(c_node, c_tag)
 *     else:
 */
  __pyx_4 = (__pyx_v_ns == Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":392
 *     c_tag = _cstr(tag)
 *     if ns is None:
 *         c_result = tree.xmlGetNoNsProp(c_node, c_tag)             # <<<<<<<<<<<<<<
 *     else:
 *         c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))
 */
    __pyx_v_c_result = xmlGetNoNsProp(__pyx_v_c_node, __pyx_v_c_tag);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":394
 *         c_result = tree.xmlGetNoNsProp(c_node, c_tag)
 *     else:
 *         c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))             # <<<<<<<<<<<<<<
 *     if c_result is NULL:
 *         # XXX free namespace that is not in use..?
 */
    __pyx_v_c_result = xmlGetNsProp(__pyx_v_c_node, __pyx_v_c_tag, PyString_AS_STRING(__pyx_v_ns));
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":395
 *     else:
 *         c_result = tree.xmlGetNsProp(c_node, c_tag, _cstr(ns))
 *     if c_result is NULL:             # <<<<<<<<<<<<<<
 *         # XXX free namespace that is not in use..?
 *         return default
 */
  __pyx_4 = (__pyx_v_c_result == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":397
 *     if c_result is NULL:
 *         # XXX free namespace that is not in use..?
 *         return default             # <<<<<<<<<<<<<<
 *     result = funicode(c_result)
 *     tree.xmlFree(c_result)
 */
    Py_INCREF(__pyx_v_default);
    __pyx_r = __pyx_v_default;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":398
 *         # XXX free namespace that is not in use..?
 *         return default
 *     result = funicode(c_result)             # <<<<<<<<<<<<<<
 *     tree.xmlFree(c_result)
 *     return result
 */
  __pyx_3 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_result); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":399
 *         return default
 *     result = funicode(c_result)
 *     tree.xmlFree(c_result)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  xmlFree(__pyx_v_c_result);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":400
 *     result = funicode(c_result)
 *     tree.xmlFree(c_result)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef inline object _getAttributeValue(_Element element, key, default):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._getNodeAttributeValue");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_tag);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":402
 *     return result
 * 
 * cdef inline object _getAttributeValue(_Element element, key, default):             # <<<<<<<<<<<<<<
 *     return _getNodeAttributeValue(element._c_node, key, default)
 * 
 */

static INLINE PyObject *__pyx_f_4lxml_5etree__getAttributeValue(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":403
 * 
 * cdef inline object _getAttributeValue(_Element element, key, default):
 *     return _getNodeAttributeValue(element._c_node, key, default)             # <<<<<<<<<<<<<<
 * 
 * cdef int _setAttributeValue(_Element element, key, value) except -1:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNodeAttributeValue(__pyx_v_element->_c_node, __pyx_v_key, __pyx_v_default); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._getAttributeValue");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":405
 *     return _getNodeAttributeValue(element._c_node, key, default)
 * 
 * cdef int _setAttributeValue(_Element element, key, value) except -1:             # <<<<<<<<<<<<<<
 *     cdef xmlNs* c_ns
 *     cdef char* c_value
 */

static  int __pyx_f_4lxml_5etree__setAttributeValue(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  xmlNs *__pyx_v_c_ns;
  char *__pyx_v_c_value;
  char *__pyx_v_c_tag;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_tag;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  xmlNs *__pyx_6;
  Py_INCREF(__pyx_v_value);
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":409
 *     cdef char* c_value
 *     cdef char* c_tag
 *     ns, tag = _getNsTag(key)             # <<<<<<<<<<<<<<
 *     if not element._doc._parser._for_html:
 *         _attributeValidOrRaise(tag)
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_key); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":410
 *     cdef char* c_tag
 *     ns, tag = _getNsTag(key)
 *     if not element._doc._parser._for_html:             # <<<<<<<<<<<<<<
 *         _attributeValidOrRaise(tag)
 *     c_tag = _cstr(tag)
 */
  __pyx_4 = (!__pyx_v_element->_doc->_parser->_for_html);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":411
 *     ns, tag = _getNsTag(key)
 *     if not element._doc._parser._for_html:
 *         _attributeValidOrRaise(tag)             # <<<<<<<<<<<<<<
 *     c_tag = _cstr(tag)
 *     if isinstance(value, QName):
 */
    __pyx_5 = __pyx_f_4lxml_5etree__attributeValidOrRaise(__pyx_v_tag); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":412
 *     if not element._doc._parser._for_html:
 *         _attributeValidOrRaise(tag)
 *     c_tag = _cstr(tag)             # <<<<<<<<<<<<<<
 *     if isinstance(value, QName):
 *         value = _resolveQNameText(element, value)
 */
  __pyx_v_c_tag = PyString_AS_STRING(__pyx_v_tag);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":413
 *         _attributeValidOrRaise(tag)
 *     c_tag = _cstr(tag)
 *     if isinstance(value, QName):             # <<<<<<<<<<<<<<
 *         value = _resolveQNameText(element, value)
 *     else:
 */
  __pyx_4 = PyObject_TypeCheck(__pyx_v_value, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":414
 *     c_tag = _cstr(tag)
 *     if isinstance(value, QName):
 *         value = _resolveQNameText(element, value)             # <<<<<<<<<<<<<<
 *     else:
 *         value = _utf8(value)
 */
    __pyx_3 = __pyx_f_4lxml_5etree__resolveQNameText(__pyx_v_element, __pyx_v_value); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":416
 *         value = _resolveQNameText(element, value)
 *     else:
 *         value = _utf8(value)             # <<<<<<<<<<<<<<
 *     c_value = _cstr(value)
 *     if ns is None:
 */
    __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_1;
    __pyx_1 = 0;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":417
 *     else:
 *         value = _utf8(value)
 *     c_value = _cstr(value)             # <<<<<<<<<<<<<<
 *     if ns is None:
 *         tree.xmlSetProp(element._c_node, c_tag, c_value)
 */
  __pyx_v_c_value = PyString_AS_STRING(__pyx_v_value);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":418
 *         value = _utf8(value)
 *     c_value = _cstr(value)
 *     if ns is None:             # <<<<<<<<<<<<<<
 *         tree.xmlSetProp(element._c_node, c_tag, c_value)
 *     else:
 */
  __pyx_4 = (__pyx_v_ns == Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":419
 *     c_value = _cstr(value)
 *     if ns is None:
 *         tree.xmlSetProp(element._c_node, c_tag, c_value)             # <<<<<<<<<<<<<<
 *     else:
 *         c_ns = element._doc._findOrBuildNodeNs(element._c_node,
 */
    xmlSetProp(__pyx_v_element->_c_node, __pyx_v_c_tag, __pyx_v_c_value);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":422
 *     else:
 *         c_ns = element._doc._findOrBuildNodeNs(element._c_node,
 *                                                _cstr(ns), NULL)             # <<<<<<<<<<<<<<
 *         tree.xmlSetNsProp(element._c_node, c_ns, c_tag, c_value)
 *     return 0
 */
    __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_element->_doc->__pyx_vtab)->_findOrBuildNodeNs(__pyx_v_element->_doc, __pyx_v_element->_c_node, PyString_AS_STRING(__pyx_v_ns), NULL); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_ns = __pyx_6;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":423
 *         c_ns = element._doc._findOrBuildNodeNs(element._c_node,
 *                                                _cstr(ns), NULL)
 *         tree.xmlSetNsProp(element._c_node, c_ns, c_tag, c_value)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    xmlSetNsProp(__pyx_v_element->_c_node, __pyx_v_c_ns, __pyx_v_c_tag, __pyx_v_c_value);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":424
 *                                                _cstr(ns), NULL)
 *         tree.xmlSetNsProp(element._c_node, c_ns, c_tag, c_value)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _delAttribute(_Element element, key) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._setAttributeValue");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_tag);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":426
 *     return 0
 * 
 * cdef int _delAttribute(_Element element, key) except -1:             # <<<<<<<<<<<<<<
 *     cdef xmlAttr* c_attr
 *     cdef char* c_href
 */

static  int __pyx_f_4lxml_5etree__delAttribute(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_key) {
  char *__pyx_v_c_href;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_tag;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":429
 *     cdef xmlAttr* c_attr
 *     cdef char* c_href
 *     ns, tag = _getNsTag(key)             # <<<<<<<<<<<<<<
 *     if ns is None:
 *         c_href = NULL
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_key); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":430
 *     cdef char* c_href
 *     ns, tag = _getNsTag(key)
 *     if ns is None:             # <<<<<<<<<<<<<<
 *         c_href = NULL
 *     else:
 */
  __pyx_4 = (__pyx_v_ns == Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":431
 *     ns, tag = _getNsTag(key)
 *     if ns is None:
 *         c_href = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         c_href = _cstr(ns)
 */
    __pyx_v_c_href = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":433
 *         c_href = NULL
 *     else:
 *         c_href = _cstr(ns)             # <<<<<<<<<<<<<<
 *     if _delAttributeFromNsName(element._c_node, c_href, _cstr(tag)):
 *         raise KeyError, key
 */
    __pyx_v_c_href = PyString_AS_STRING(__pyx_v_ns);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":434
 *     else:
 *         c_href = _cstr(ns)
 *     if _delAttributeFromNsName(element._c_node, c_href, _cstr(tag)):             # <<<<<<<<<<<<<<
 *         raise KeyError, key
 *     return 0
 */
  __pyx_5 = __pyx_f_4lxml_5etree__delAttributeFromNsName(__pyx_v_element->_c_node, __pyx_v_c_href, PyString_AS_STRING(__pyx_v_tag));
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":435
 *         c_href = _cstr(ns)
 *     if _delAttributeFromNsName(element._c_node, c_href, _cstr(tag)):
 *         raise KeyError, key             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __Pyx_Raise(__pyx_builtin_KeyError, __pyx_v_key, 0);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":436
 *     if _delAttributeFromNsName(element._c_node, c_href, _cstr(tag)):
 *         raise KeyError, key
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _delAttributeFromNsName(xmlNode* c_node, char* c_href, char* c_name):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._delAttribute");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_tag);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":438
 *     return 0
 * 
 * cdef int _delAttributeFromNsName(xmlNode* c_node, char* c_href, char* c_name):             # <<<<<<<<<<<<<<
 *     cdef xmlAttr* c_attr
 *     if c_href is NULL:
 */

static  int __pyx_f_4lxml_5etree__delAttributeFromNsName(xmlNode *__pyx_v_c_node, char *__pyx_v_c_href, char *__pyx_v_c_name) {
  xmlAttr *__pyx_v_c_attr;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":440
 * cdef int _delAttributeFromNsName(xmlNode* c_node, char* c_href, char* c_name):
 *     cdef xmlAttr* c_attr
 *     if c_href is NULL:             # <<<<<<<<<<<<<<
 *         c_attr = tree.xmlHasProp(c_node, c_name)
 *     else:
 */
  __pyx_1 = (__pyx_v_c_href == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":441
 *     cdef xmlAttr* c_attr
 *     if c_href is NULL:
 *         c_attr = tree.xmlHasProp(c_node, c_name)             # <<<<<<<<<<<<<<
 *     else:
 *         c_attr = tree.xmlHasNsProp(c_node, c_name, c_href)
 */
    __pyx_v_c_attr = xmlHasProp(__pyx_v_c_node, __pyx_v_c_name);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":443
 *         c_attr = tree.xmlHasProp(c_node, c_name)
 *     else:
 *         c_attr = tree.xmlHasNsProp(c_node, c_name, c_href)             # <<<<<<<<<<<<<<
 *     if c_attr is NULL:
 *         # XXX free namespace that is not in use..?
 */
    __pyx_v_c_attr = xmlHasNsProp(__pyx_v_c_node, __pyx_v_c_name, __pyx_v_c_href);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":444
 *     else:
 *         c_attr = tree.xmlHasNsProp(c_node, c_name, c_href)
 *     if c_attr is NULL:             # <<<<<<<<<<<<<<
 *         # XXX free namespace that is not in use..?
 *         return -1
 */
  __pyx_1 = (__pyx_v_c_attr == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":446
 *     if c_attr is NULL:
 *         # XXX free namespace that is not in use..?
 *         return -1             # <<<<<<<<<<<<<<
 *     tree.xmlRemoveProp(c_attr)
 *     return 0
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":447
 *         # XXX free namespace that is not in use..?
 *         return -1
 *     tree.xmlRemoveProp(c_attr)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  xmlRemoveProp(__pyx_v_c_attr);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":448
 *         return -1
 *     tree.xmlRemoveProp(c_attr)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef object _collectAttributes(xmlNode* c_node, int collecttype):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":450
 *     return 0
 * 
 * cdef object _collectAttributes(xmlNode* c_node, int collecttype):             # <<<<<<<<<<<<<<
 *     u"""Collect all attributes of a node in a list.  Depending on collecttype,
 *     it collects either the name (1), the value (2) or the name-value tuples.
 */

static  PyObject *__pyx_f_4lxml_5etree__collectAttributes(xmlNode *__pyx_v_c_node, int __pyx_v_collecttype) {
  Py_ssize_t __pyx_v_count;
  xmlAttr *__pyx_v_c_attr;
  PyObject *__pyx_v_attributes;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_attributes = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":456
 *     cdef Py_ssize_t count
 *     cdef xmlAttr* c_attr
 *     c_attr = c_node.properties             # <<<<<<<<<<<<<<
 *     count = 0
 *     while c_attr is not NULL:
 */
  __pyx_v_c_attr = __pyx_v_c_node->properties;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":457
 *     cdef xmlAttr* c_attr
 *     c_attr = c_node.properties
 *     count = 0             # <<<<<<<<<<<<<<
 *     while c_attr is not NULL:
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 */
  __pyx_v_count = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":458
 *     c_attr = c_node.properties
 *     count = 0
 *     while c_attr is not NULL:             # <<<<<<<<<<<<<<
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *             count = count + 1
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":459
 *     count = 0
 *     while c_attr is not NULL:
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *             count = count + 1
 *         c_attr = c_attr.next
 */
    __pyx_1 = (__pyx_v_c_attr->type == XML_ATTRIBUTE_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":460
 *     while c_attr is not NULL:
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *             count = count + 1             # <<<<<<<<<<<<<<
 *         c_attr = c_attr.next
 * 
 */
      __pyx_v_count = (__pyx_v_count + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":461
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *             count = count + 1
 *         c_attr = c_attr.next             # <<<<<<<<<<<<<<
 * 
 *     if count == 0:
 */
    __pyx_v_c_attr = __pyx_v_c_attr->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":463
 *         c_attr = c_attr.next
 * 
 *     if count == 0:             # <<<<<<<<<<<<<<
 *         return []
 * 
 */
  __pyx_1 = (__pyx_v_count == 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":464
 * 
 *     if count == 0:
 *         return []             # <<<<<<<<<<<<<<
 * 
 *     attributes = python.PyList_New(count)
 */
    __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":466
 *         return []
 * 
 *     attributes = python.PyList_New(count)             # <<<<<<<<<<<<<<
 *     c_attr = c_node.properties
 *     count = 0
 */
  __pyx_2 = PyList_New(__pyx_v_count); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_attributes);
  __pyx_v_attributes = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":467
 * 
 *     attributes = python.PyList_New(count)
 *     c_attr = c_node.properties             # <<<<<<<<<<<<<<
 *     count = 0
 *     while c_attr is not NULL:
 */
  __pyx_v_c_attr = __pyx_v_c_node->properties;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":468
 *     attributes = python.PyList_New(count)
 *     c_attr = c_node.properties
 *     count = 0             # <<<<<<<<<<<<<<
 *     while c_attr is not NULL:
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 */
  __pyx_v_count = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":469
 *     c_attr = c_node.properties
 *     count = 0
 *     while c_attr is not NULL:             # <<<<<<<<<<<<<<
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *             if collecttype == 1:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":470
 *     count = 0
 *     while c_attr is not NULL:
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *             if collecttype == 1:
 *                 item = _namespacedName(<xmlNode*>c_attr)
 */
    __pyx_1 = (__pyx_v_c_attr->type == XML_ATTRIBUTE_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":471
 *     while c_attr is not NULL:
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *             if collecttype == 1:             # <<<<<<<<<<<<<<
 *                 item = _namespacedName(<xmlNode*>c_attr)
 *             elif collecttype == 2:
 */
      switch (__pyx_v_collecttype) {
        case 1:

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":472
 *         if c_attr.type == tree.XML_ATTRIBUTE_NODE:
 *             if collecttype == 1:
 *                 item = _namespacedName(<xmlNode*>c_attr)             # <<<<<<<<<<<<<<
 *             elif collecttype == 2:
 *                 item = _attributeValue(c_node, c_attr)
 */
        __pyx_2 = __pyx_f_4lxml_5etree__namespacedName(((xmlNode *)__pyx_v_c_attr)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_item);
        __pyx_v_item = __pyx_2;
        __pyx_2 = 0;
        break;
        case 2:

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":474
 *                 item = _namespacedName(<xmlNode*>c_attr)
 *             elif collecttype == 2:
 *                 item = _attributeValue(c_node, c_attr)             # <<<<<<<<<<<<<<
 *             else:
 *                 item = (_namespacedName(<xmlNode*>c_attr),
 */
        __pyx_2 = __pyx_f_4lxml_5etree__attributeValue(__pyx_v_c_node, __pyx_v_c_attr); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_item);
        __pyx_v_item = __pyx_2;
        __pyx_2 = 0;
        break;
        default:

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":476
 *                 item = _attributeValue(c_node, c_attr)
 *             else:
 *                 item = (_namespacedName(<xmlNode*>c_attr),             # <<<<<<<<<<<<<<
 *                         _attributeValue(c_node, c_attr))
 * 
 */
        __pyx_2 = __pyx_f_4lxml_5etree__namespacedName(((xmlNode *)__pyx_v_c_attr)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":477
 *             else:
 *                 item = (_namespacedName(<xmlNode*>c_attr),
 *                         _attributeValue(c_node, c_attr))             # <<<<<<<<<<<<<<
 * 
 *             python.Py_INCREF(item)
 */
        __pyx_3 = __pyx_f_4lxml_5etree__attributeValue(__pyx_v_c_node, __pyx_v_c_attr); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
        PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
        __pyx_2 = 0;
        __pyx_3 = 0;
        Py_DECREF(__pyx_v_item);
        __pyx_v_item = ((PyObject *)__pyx_4);
        __pyx_4 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":479
 *                         _attributeValue(c_node, c_attr))
 * 
 *             python.Py_INCREF(item)             # <<<<<<<<<<<<<<
 *             python.PyList_SET_ITEM(attributes, count, item)
 *             count = count + 1
 */
      Py_INCREF(__pyx_v_item);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":480
 * 
 *             python.Py_INCREF(item)
 *             python.PyList_SET_ITEM(attributes, count, item)             # <<<<<<<<<<<<<<
 *             count = count + 1
 *         c_attr = c_attr.next
 */
      PyList_SET_ITEM(__pyx_v_attributes, __pyx_v_count, __pyx_v_item);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":481
 *             python.Py_INCREF(item)
 *             python.PyList_SET_ITEM(attributes, count, item)
 *             count = count + 1             # <<<<<<<<<<<<<<
 *         c_attr = c_attr.next
 *     return attributes
 */
      __pyx_v_count = (__pyx_v_count + 1);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":482
 *             python.PyList_SET_ITEM(attributes, count, item)
 *             count = count + 1
 *         c_attr = c_attr.next             # <<<<<<<<<<<<<<
 *     return attributes
 * 
 */
    __pyx_v_c_attr = __pyx_v_c_attr->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":483
 *             count = count + 1
 *         c_attr = c_attr.next
 *     return attributes             # <<<<<<<<<<<<<<
 * 
 * cdef object __RE_XML_ENCODING
 */
  Py_INCREF(__pyx_v_attributes);
  __pyx_r = __pyx_v_attributes;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._collectAttributes");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_attributes);
  Py_DECREF(__pyx_v_item);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":495
 * __HAS_XML_ENCODING = __RE_XML_ENCODING.match
 * 
 * cdef object _stripEncodingDeclaration(object xml_string):             # <<<<<<<<<<<<<<
 *     # this is a hack to remove the XML encoding declaration from unicode
 *     return __REPLACE_XML_ENCODING(ur'\g<1>', xml_string)
 */

static  PyObject *__pyx_f_4lxml_5etree__stripEncodingDeclaration(PyObject *__pyx_v_xml_string) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":497
 * cdef object _stripEncodingDeclaration(object xml_string):
 *     # this is a hack to remove the XML encoding declaration from unicode
 *     return __REPLACE_XML_ENCODING(ur'\g<1>', xml_string)             # <<<<<<<<<<<<<<
 * 
 * cdef int _hasEncodingDeclaration(object xml_string):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_311));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_kp_311));
  Py_INCREF(__pyx_v_xml_string);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_xml_string);
  __pyx_2 = PyObject_Call(__pyx_v_4lxml_5etree___REPLACE_XML_ENCODING, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._stripEncodingDeclaration");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":499
 *     return __REPLACE_XML_ENCODING(ur'\g<1>', xml_string)
 * 
 * cdef int _hasEncodingDeclaration(object xml_string):             # <<<<<<<<<<<<<<
 *     # check if a (unicode) string has an XML encoding declaration
 *     return __HAS_XML_ENCODING(xml_string) is not None
 */

static  int __pyx_f_4lxml_5etree__hasEncodingDeclaration(PyObject *__pyx_v_xml_string) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":501
 * cdef int _hasEncodingDeclaration(object xml_string):
 *     # check if a (unicode) string has an XML encoding declaration
 *     return __HAS_XML_ENCODING(xml_string) is not None             # <<<<<<<<<<<<<<
 * 
 * cdef object _stripDeclaration(object xml_string):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_xml_string);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_xml_string);
  __pyx_2 = PyObject_Call(__pyx_v_4lxml_5etree___HAS_XML_ENCODING, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_3 = (__pyx_2 != Py_None);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._hasEncodingDeclaration");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":503
 *     return __HAS_XML_ENCODING(xml_string) is not None
 * 
 * cdef object _stripDeclaration(object xml_string):             # <<<<<<<<<<<<<<
 *     # this is a hack to remove the XML declaration when we encode to UTF-8
 *     xml_string = xml_string.strip()
 */

static  PyObject *__pyx_f_4lxml_5etree__stripDeclaration(PyObject *__pyx_v_xml_string) {
  PyObject *__pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5 = 0;
  Py_ssize_t __pyx_6 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_xml_string);
  __pyx_v_i = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":505
 * cdef object _stripDeclaration(object xml_string):
 *     # this is a hack to remove the XML declaration when we encode to UTF-8
 *     xml_string = xml_string.strip()             # <<<<<<<<<<<<<<
 *     if xml_string[:5] == '<?xml':
 *         i = xml_string.find('?>')
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_xml_string, __pyx_kp_strip); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_xml_string);
  __pyx_v_xml_string = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":506
 *     # this is a hack to remove the XML declaration when we encode to UTF-8
 *     xml_string = xml_string.strip()
 *     if xml_string[:5] == '<?xml':             # <<<<<<<<<<<<<<
 *         i = xml_string.find('?>')
 *         if i != -1:
 */
  __pyx_1 = PySequence_GetSlice(__pyx_v_xml_string, 0, 5); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_RichCompare(__pyx_1, __pyx_kp_312, Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":507
 *     xml_string = xml_string.strip()
 *     if xml_string[:5] == '<?xml':
 *         i = xml_string.find('?>')             # <<<<<<<<<<<<<<
 *         if i != -1:
 *             i = i + 2
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_xml_string, __pyx_kp_find); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_kp_313);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_kp_313);
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":508
 *     if xml_string[:5] == '<?xml':
 *         i = xml_string.find('?>')
 *         if i != -1:             # <<<<<<<<<<<<<<
 *             i = i + 2
 *             while xml_string[i:i+1] in '\n\r ':
 */
    __pyx_1 = PyObject_RichCompare(__pyx_v_i, __pyx_int_neg_1, Py_NE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":509
 *         i = xml_string.find('?>')
 *         if i != -1:
 *             i = i + 2             # <<<<<<<<<<<<<<
 *             while xml_string[i:i+1] in '\n\r ':
 *                 i = i+1
 */
      __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_int_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":510
 *         if i != -1:
 *             i = i + 2
 *             while xml_string[i:i+1] in '\n\r ':             # <<<<<<<<<<<<<<
 *                 i = i+1
 *             xml_string = xml_string[i:]
 */
      while (1) {
        __pyx_5 = __pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_6 = __pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_2 = PySequence_GetSlice(__pyx_v_xml_string, __pyx_5, __pyx_6); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_3 = (PySequence_Contains(__pyx_kp_314, __pyx_2)); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        if (!__pyx_3) break;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":511
 *             i = i + 2
 *             while xml_string[i:i+1] in '\n\r ':
 *                 i = i+1             # <<<<<<<<<<<<<<
 *             xml_string = xml_string[i:]
 *     return xml_string
 */
        __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_i);
        __pyx_v_i = __pyx_t_1;
        __pyx_t_1 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":512
 *             while xml_string[i:i+1] in '\n\r ':
 *                 i = i+1
 *             xml_string = xml_string[i:]             # <<<<<<<<<<<<<<
 *     return xml_string
 * 
 */
      __pyx_5 = __pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PySequence_GetSlice(__pyx_v_xml_string, __pyx_5, PY_SSIZE_T_MAX); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_xml_string);
      __pyx_v_xml_string = __pyx_4;
      __pyx_4 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":513
 *                 i = i+1
 *             xml_string = xml_string[i:]
 *     return xml_string             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _hasText(xmlNode* c_node):
 */
  Py_INCREF(__pyx_v_xml_string);
  __pyx_r = __pyx_v_xml_string;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._stripDeclaration");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_xml_string);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":515
 *     return xml_string
 * 
 * cdef inline int _hasText(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return c_node is not NULL and _textNodeOrSkip(c_node.children) is not NULL
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__hasText(xmlNode *__pyx_v_c_node) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":516
 * 
 * cdef inline int _hasText(xmlNode* c_node):
 *     return c_node is not NULL and _textNodeOrSkip(c_node.children) is not NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _hasTail(xmlNode* c_node):
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node->children) != NULL);
  }
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":518
 *     return c_node is not NULL and _textNodeOrSkip(c_node.children) is not NULL
 * 
 * cdef inline int _hasTail(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return c_node is not NULL and _textNodeOrSkip(c_node.next) is not NULL
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__hasTail(xmlNode *__pyx_v_c_node) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":519
 * 
 * cdef inline int _hasTail(xmlNode* c_node):
 *     return c_node is not NULL and _textNodeOrSkip(c_node.next) is not NULL             # <<<<<<<<<<<<<<
 * 
 * cdef _collectText(xmlNode* c_node):
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node->next) != NULL);
  }
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":521
 *     return c_node is not NULL and _textNodeOrSkip(c_node.next) is not NULL
 * 
 * cdef _collectText(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"""Collect all text nodes and return them as a unicode string.
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree__collectText(xmlNode *__pyx_v_c_node) {
  Py_ssize_t __pyx_v_scount;
  char *__pyx_v_c_text;
  xmlNode *__pyx_v_c_node_cur;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  xmlNode *__pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  char *__pyx_4;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":532
 *     cdef xmlNode* c_node_cur
 *     # check for multiple text nodes
 *     scount = 0             # <<<<<<<<<<<<<<
 *     c_text = NULL
 *     c_node_cur = c_node = _textNodeOrSkip(c_node)
 */
  __pyx_v_scount = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":533
 *     # check for multiple text nodes
 *     scount = 0
 *     c_text = NULL             # <<<<<<<<<<<<<<
 *     c_node_cur = c_node = _textNodeOrSkip(c_node)
 *     while c_node_cur is not NULL:
 */
  __pyx_v_c_text = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":534
 *     scount = 0
 *     c_text = NULL
 *     c_node_cur = c_node = _textNodeOrSkip(c_node)             # <<<<<<<<<<<<<<
 *     while c_node_cur is not NULL:
 *         if c_node_cur.content[0] != c'\0':
 */
  __pyx_1 = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node);
  __pyx_v_c_node_cur = __pyx_1;
  __pyx_v_c_node = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":535
 *     c_text = NULL
 *     c_node_cur = c_node = _textNodeOrSkip(c_node)
 *     while c_node_cur is not NULL:             # <<<<<<<<<<<<<<
 *         if c_node_cur.content[0] != c'\0':
 *             c_text = c_node_cur.content
 */
  while (1) {
    __pyx_2 = (__pyx_v_c_node_cur != NULL);
    if (!__pyx_2) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":536
 *     c_node_cur = c_node = _textNodeOrSkip(c_node)
 *     while c_node_cur is not NULL:
 *         if c_node_cur.content[0] != c'\0':             # <<<<<<<<<<<<<<
 *             c_text = c_node_cur.content
 *         scount = scount + 1
 */
    __pyx_2 = ((__pyx_v_c_node_cur->content[0]) != '\x00');
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":537
 *     while c_node_cur is not NULL:
 *         if c_node_cur.content[0] != c'\0':
 *             c_text = c_node_cur.content             # <<<<<<<<<<<<<<
 *         scount = scount + 1
 *         c_node_cur = _textNodeOrSkip(c_node_cur.next)
 */
      __pyx_v_c_text = __pyx_v_c_node_cur->content;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":538
 *         if c_node_cur.content[0] != c'\0':
 *             c_text = c_node_cur.content
 *         scount = scount + 1             # <<<<<<<<<<<<<<
 *         c_node_cur = _textNodeOrSkip(c_node_cur.next)
 * 
 */
    __pyx_v_scount = (__pyx_v_scount + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":539
 *             c_text = c_node_cur.content
 *         scount = scount + 1
 *         c_node_cur = _textNodeOrSkip(c_node_cur.next)             # <<<<<<<<<<<<<<
 * 
 *     # handle two most common cases first
 */
    __pyx_v_c_node_cur = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node_cur->next);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":542
 * 
 *     # handle two most common cases first
 *     if c_text is NULL:             # <<<<<<<<<<<<<<
 *         if scount > 0:
 *             if python.IS_PYTHON3:
 */
  __pyx_2 = (__pyx_v_c_text == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":543
 *     # handle two most common cases first
 *     if c_text is NULL:
 *         if scount > 0:             # <<<<<<<<<<<<<<
 *             if python.IS_PYTHON3:
 *                 return u''
 */
    __pyx_2 = (__pyx_v_scount > 0);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":544
 *     if c_text is NULL:
 *         if scount > 0:
 *             if python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *                 return u''
 *             else:
 */
      __pyx_2 = IS_PYTHON3;
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":545
 *         if scount > 0:
 *             if python.IS_PYTHON3:
 *                 return u''             # <<<<<<<<<<<<<<
 *             else:
 *                 return ''
 */
        Py_INCREF(((PyObject *)__pyx_kp_315));
        __pyx_r = ((PyObject *)__pyx_kp_315);
        goto __pyx_L0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":547
 *                 return u''
 *             else:
 *                 return ''             # <<<<<<<<<<<<<<
 *         else:
 *             return None
 */
        Py_INCREF(__pyx_kp_316);
        __pyx_r = __pyx_kp_316;
        goto __pyx_L0;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":549
 *                 return ''
 *         else:
 *             return None             # <<<<<<<<<<<<<<
 *     if scount == 1:
 *         return funicode(c_text)
 */
      Py_INCREF(Py_None);
      __pyx_r = Py_None;
      goto __pyx_L0;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":550
 *         else:
 *             return None
 *     if scount == 1:             # <<<<<<<<<<<<<<
 *         return funicode(c_text)
 * 
 */
  __pyx_2 = (__pyx_v_scount == 1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":551
 *             return None
 *     if scount == 1:
 *         return funicode(c_text)             # <<<<<<<<<<<<<<
 * 
 *     # the rest is not performance critical anymore
 */
    __pyx_3 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_text); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":554
 * 
 *     # the rest is not performance critical anymore
 *     result = ''             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         result = result + c_node.content
 */
  Py_INCREF(__pyx_kp_317);
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_kp_317;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":555
 *     # the rest is not performance critical anymore
 *     result = ''
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         result = result + c_node.content
 *         c_node = _textNodeOrSkip(c_node.next)
 */
  while (1) {
    __pyx_2 = (__pyx_v_c_node != NULL);
    if (!__pyx_2) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":556
 *     result = ''
 *     while c_node is not NULL:
 *         result = result + c_node.content             # <<<<<<<<<<<<<<
 *         c_node = _textNodeOrSkip(c_node.next)
 *     return funicode(result)
 */
    __pyx_3 = __Pyx_PyBytes_FromString(__pyx_v_c_node->content); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Add(__pyx_v_result, __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":557
 *     while c_node is not NULL:
 *         result = result + c_node.content
 *         c_node = _textNodeOrSkip(c_node.next)             # <<<<<<<<<<<<<<
 *     return funicode(result)
 * 
 */
    __pyx_v_c_node = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node->next);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":558
 *         result = result + c_node.content
 *         c_node = _textNodeOrSkip(c_node.next)
 *     return funicode(result)             # <<<<<<<<<<<<<<
 * 
 * cdef void _removeText(xmlNode* c_node):
 */
  __pyx_4 = __Pyx_PyBytes_AsString(__pyx_v_result); if (unlikely((!__pyx_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __pyx_f_4lxml_5etree_funicode(__pyx_4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._collectText");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":560
 *     return funicode(result)
 * 
 * cdef void _removeText(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"""Remove all text nodes.
 * 
 */

static  void __pyx_f_4lxml_5etree__removeText(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_v_c_next;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":566
 *     """
 *     cdef xmlNode* c_next
 *     c_node = _textNodeOrSkip(c_node)             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         c_next = _textNodeOrSkip(c_node.next)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":567
 *     cdef xmlNode* c_next
 *     c_node = _textNodeOrSkip(c_node)
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         c_next = _textNodeOrSkip(c_node.next)
 *         tree.xmlUnlinkNode(c_node)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":568
 *     c_node = _textNodeOrSkip(c_node)
 *     while c_node is not NULL:
 *         c_next = _textNodeOrSkip(c_node.next)             # <<<<<<<<<<<<<<
 *         tree.xmlUnlinkNode(c_node)
 *         tree.xmlFreeNode(c_node)
 */
    __pyx_v_c_next = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node->next);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":569
 *     while c_node is not NULL:
 *         c_next = _textNodeOrSkip(c_node.next)
 *         tree.xmlUnlinkNode(c_node)             # <<<<<<<<<<<<<<
 *         tree.xmlFreeNode(c_node)
 *         c_node = c_next
 */
    xmlUnlinkNode(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":570
 *         c_next = _textNodeOrSkip(c_node.next)
 *         tree.xmlUnlinkNode(c_node)
 *         tree.xmlFreeNode(c_node)             # <<<<<<<<<<<<<<
 *         c_node = c_next
 * 
 */
    xmlFreeNode(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":571
 *         tree.xmlUnlinkNode(c_node)
 *         tree.xmlFreeNode(c_node)
 *         c_node = c_next             # <<<<<<<<<<<<<<
 * 
 * cdef int _setNodeText(xmlNode* c_node, value) except -1:
 */
    __pyx_v_c_node = __pyx_v_c_next;
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":573
 *         c_node = c_next
 * 
 * cdef int _setNodeText(xmlNode* c_node, value) except -1:             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_text_node
 *     # remove all text nodes at the start first
 */

static  int __pyx_f_4lxml_5etree__setNodeText(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_value) {
  xmlNode *__pyx_v_c_text_node;
  PyObject *__pyx_v_text;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":576
 *     cdef xmlNode* c_text_node
 *     # remove all text nodes at the start first
 *     _removeText(c_node.children)             # <<<<<<<<<<<<<<
 *     if value is None:
 *         return 0
 */
  __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->children);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":577
 *     # remove all text nodes at the start first
 *     _removeText(c_node.children)
 *     if value is None:             # <<<<<<<<<<<<<<
 *         return 0
 *     # now add new text node with value at start
 */
  __pyx_1 = (__pyx_v_value == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":578
 *     _removeText(c_node.children)
 *     if value is None:
 *         return 0             # <<<<<<<<<<<<<<
 *     # now add new text node with value at start
 *     if python._isString(value):
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":580
 *         return 0
 *     # now add new text node with value at start
 *     if python._isString(value):             # <<<<<<<<<<<<<<
 *         text = _utf8(value)
 *         c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))
 */
  __pyx_1 = _isString(__pyx_v_value);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":581
 *     # now add new text node with value at start
 *     if python._isString(value):
 *         text = _utf8(value)             # <<<<<<<<<<<<<<
 *         c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))
 *     elif isinstance(value, CDATA):
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_text);
    __pyx_v_text = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":582
 *     if python._isString(value):
 *         text = _utf8(value)
 *         c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))             # <<<<<<<<<<<<<<
 *     elif isinstance(value, CDATA):
 *         c_text_node = tree.xmlNewCDataBlock(
 */
    __pyx_v_c_text_node = xmlNewDocText(__pyx_v_c_node->doc, PyString_AS_STRING(__pyx_v_text));
    goto __pyx_L4;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":583
 *         text = _utf8(value)
 *         c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))
 *     elif isinstance(value, CDATA):             # <<<<<<<<<<<<<<
 *         c_text_node = tree.xmlNewCDataBlock(
 *             c_node.doc, _cstr((<CDATA>value)._utf8_data),
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_value, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_CDATA))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":586
 *         c_text_node = tree.xmlNewCDataBlock(
 *             c_node.doc, _cstr((<CDATA>value)._utf8_data),
 *             python.PyString_GET_SIZE((<CDATA>value)._utf8_data))             # <<<<<<<<<<<<<<
 *     else:
 *         # this will raise the right error
 */
    __pyx_v_c_text_node = xmlNewCDataBlock(__pyx_v_c_node->doc, PyString_AS_STRING(((struct __pyx_obj_4lxml_5etree_CDATA *)__pyx_v_value)->_utf8_data), PyString_GET_SIZE(((struct __pyx_obj_4lxml_5etree_CDATA *)__pyx_v_value)->_utf8_data));
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":589
 *     else:
 *         # this will raise the right error
 *        _utf8(value)             # <<<<<<<<<<<<<<
 *        return -1
 *     if c_node.children is NULL:
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":590
 *         # this will raise the right error
 *        _utf8(value)
 *        return -1             # <<<<<<<<<<<<<<
 *     if c_node.children is NULL:
 *         tree.xmlAddChild(c_node, c_text_node)
 */
    __pyx_r = -1;
    goto __pyx_L0;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":591
 *        _utf8(value)
 *        return -1
 *     if c_node.children is NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlAddChild(c_node, c_text_node)
 *     else:
 */
  __pyx_1 = (__pyx_v_c_node->children == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":592
 *        return -1
 *     if c_node.children is NULL:
 *         tree.xmlAddChild(c_node, c_text_node)             # <<<<<<<<<<<<<<
 *     else:
 *         tree.xmlAddPrevSibling(c_node.children, c_text_node)
 */
    xmlAddChild(__pyx_v_c_node, __pyx_v_c_text_node);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":594
 *         tree.xmlAddChild(c_node, c_text_node)
 *     else:
 *         tree.xmlAddPrevSibling(c_node.children, c_text_node)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    xmlAddPrevSibling(__pyx_v_c_node->children, __pyx_v_c_text_node);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":595
 *     else:
 *         tree.xmlAddPrevSibling(c_node.children, c_text_node)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _setTailText(xmlNode* c_node, value) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._setNodeText");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":597
 *     return 0
 * 
 * cdef int _setTailText(xmlNode* c_node, value) except -1:             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_text_node
 *     # remove all text nodes at the start first
 */

static  int __pyx_f_4lxml_5etree__setTailText(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_value) {
  xmlNode *__pyx_v_c_text_node;
  PyObject *__pyx_v_text;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":600
 *     cdef xmlNode* c_text_node
 *     # remove all text nodes at the start first
 *     _removeText(c_node.next)             # <<<<<<<<<<<<<<
 *     if value is None:
 *         return 0
 */
  __pyx_f_4lxml_5etree__removeText(__pyx_v_c_node->next);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":601
 *     # remove all text nodes at the start first
 *     _removeText(c_node.next)
 *     if value is None:             # <<<<<<<<<<<<<<
 *         return 0
 *     text = _utf8(value)
 */
  __pyx_1 = (__pyx_v_value == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":602
 *     _removeText(c_node.next)
 *     if value is None:
 *         return 0             # <<<<<<<<<<<<<<
 *     text = _utf8(value)
 *     c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":603
 *     if value is None:
 *         return 0
 *     text = _utf8(value)             # <<<<<<<<<<<<<<
 *     c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))
 *     # XXX what if we're the top element?
 */
  __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_text);
  __pyx_v_text = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":604
 *         return 0
 *     text = _utf8(value)
 *     c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))             # <<<<<<<<<<<<<<
 *     # XXX what if we're the top element?
 *     tree.xmlAddNextSibling(c_node, c_text_node)
 */
  __pyx_v_c_text_node = xmlNewDocText(__pyx_v_c_node->doc, PyString_AS_STRING(__pyx_v_text));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":606
 *     c_text_node = tree.xmlNewDocText(c_node.doc, _cstr(text))
 *     # XXX what if we're the top element?
 *     tree.xmlAddNextSibling(c_node, c_text_node)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  xmlAddNextSibling(__pyx_v_c_node, __pyx_v_c_text_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":607
 *     # XXX what if we're the top element?
 *     tree.xmlAddNextSibling(c_node, c_text_node)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef _resolveQNameText(_Element element, value):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._setTailText");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":609
 *     return 0
 * 
 * cdef _resolveQNameText(_Element element, value):             # <<<<<<<<<<<<<<
 *     cdef xmlNs* c_ns
 *     ns, tag = _getNsTag(value)
 */

static  PyObject *__pyx_f_4lxml_5etree__resolveQNameText(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_value) {
  xmlNs *__pyx_v_c_ns;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_tag;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  xmlNs *__pyx_5;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":611
 * cdef _resolveQNameText(_Element element, value):
 *     cdef xmlNs* c_ns
 *     ns, tag = _getNsTag(value)             # <<<<<<<<<<<<<<
 *     if ns is None:
 *         return tag
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_value); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":612
 *     cdef xmlNs* c_ns
 *     ns, tag = _getNsTag(value)
 *     if ns is None:             # <<<<<<<<<<<<<<
 *         return tag
 *     else:
 */
  __pyx_4 = (__pyx_v_ns == Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":613
 *     ns, tag = _getNsTag(value)
 *     if ns is None:
 *         return tag             # <<<<<<<<<<<<<<
 *     else:
 *         c_ns = element._doc._findOrBuildNodeNs(
 */
    Py_INCREF(__pyx_v_tag);
    __pyx_r = __pyx_v_tag;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":616
 *     else:
 *         c_ns = element._doc._findOrBuildNodeNs(
 *             element._c_node, _cstr(ns), NULL)             # <<<<<<<<<<<<<<
 *         return python.PyString_FromFormat('%s:%s', c_ns.prefix, _cstr(tag))
 * 
 */
    __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_element->_doc->__pyx_vtab)->_findOrBuildNodeNs(__pyx_v_element->_doc, __pyx_v_element->_c_node, PyString_AS_STRING(__pyx_v_ns), NULL); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_ns = __pyx_5;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":617
 *         c_ns = element._doc._findOrBuildNodeNs(
 *             element._c_node, _cstr(ns), NULL)
 *         return python.PyString_FromFormat('%s:%s', c_ns.prefix, _cstr(tag))             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint _hasChild(xmlNode* c_node):
 */
    __pyx_3 = PyString_FromFormat(__pyx_k_318, __pyx_v_c_ns->prefix, PyString_AS_STRING(__pyx_v_tag)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._resolveQNameText");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_tag);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":619
 *         return python.PyString_FromFormat('%s:%s', c_ns.prefix, _cstr(tag))
 * 
 * cdef inline bint _hasChild(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return c_node is not NULL and _findChildForwards(c_node, 0) is not NULL
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__hasChild(xmlNode *__pyx_v_c_node) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":620
 * 
 * cdef inline bint _hasChild(xmlNode* c_node):
 *     return c_node is not NULL and _findChildForwards(c_node, 0) is not NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline Py_ssize_t _countElements(xmlNode* c_node):
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_f_4lxml_5etree__findChildForwards(__pyx_v_c_node, 0) != NULL);
  }
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":622
 *     return c_node is not NULL and _findChildForwards(c_node, 0) is not NULL
 * 
 * cdef inline Py_ssize_t _countElements(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"Counts the elements within the following siblings and the node itself."
 *     cdef Py_ssize_t count
 */

static INLINE Py_ssize_t __pyx_f_4lxml_5etree__countElements(xmlNode *__pyx_v_c_node) {
  Py_ssize_t __pyx_v_count;
  Py_ssize_t __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":625
 *     u"Counts the elements within the following siblings and the node itself."
 *     cdef Py_ssize_t count
 *     count = 0             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         if _isElement(c_node):
 */
  __pyx_v_count = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":626
 *     cdef Py_ssize_t count
 *     count = 0
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         if _isElement(c_node):
 *             count = count + 1
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":627
 *     count = 0
 *     while c_node is not NULL:
 *         if _isElement(c_node):             # <<<<<<<<<<<<<<
 *             count = count + 1
 *         c_node = c_node.next
 */
    __pyx_1 = _isElement(__pyx_v_c_node);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":628
 *     while c_node is not NULL:
 *         if _isElement(c_node):
 *             count = count + 1             # <<<<<<<<<<<<<<
 *         c_node = c_node.next
 *     return count
 */
      __pyx_v_count = (__pyx_v_count + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":629
 *         if _isElement(c_node):
 *             count = count + 1
 *         c_node = c_node.next             # <<<<<<<<<<<<<<
 *     return count
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":630
 *             count = count + 1
 *         c_node = c_node.next
 *     return count             # <<<<<<<<<<<<<<
 * 
 * cdef int _findChildSlice(
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":632
 *     return count
 * 
 * cdef int _findChildSlice(             # <<<<<<<<<<<<<<
 *     python.slice sliceobject, xmlNode* c_parent,
 *     xmlNode** c_start_node, Py_ssize_t* c_step, Py_ssize_t* c_length) except -1:
 */

static  int __pyx_f_4lxml_5etree__findChildSlice(PySliceObject *__pyx_v_sliceobject, xmlNode *__pyx_v_c_parent, xmlNode **__pyx_v_c_start_node, Py_ssize_t *__pyx_v_c_step, Py_ssize_t *__pyx_v_c_length) {
  Py_ssize_t __pyx_v_start;
  Py_ssize_t __pyx_v_stop;
  Py_ssize_t __pyx_v_childcount;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":641
 *     """
 *     cdef Py_ssize_t start, stop, childcount
 *     childcount = _countElements(c_parent.children)             # <<<<<<<<<<<<<<
 *     if childcount == 0:
 *         c_start_node[0] = NULL
 */
  __pyx_v_childcount = __pyx_f_4lxml_5etree__countElements(__pyx_v_c_parent->children);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":642
 *     cdef Py_ssize_t start, stop, childcount
 *     childcount = _countElements(c_parent.children)
 *     if childcount == 0:             # <<<<<<<<<<<<<<
 *         c_start_node[0] = NULL
 *         c_length[0] = 0
 */
  __pyx_1 = (__pyx_v_childcount == 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":643
 *     childcount = _countElements(c_parent.children)
 *     if childcount == 0:
 *         c_start_node[0] = NULL             # <<<<<<<<<<<<<<
 *         c_length[0] = 0
 *         if sliceobject.step is None:
 */
    (__pyx_v_c_start_node[0]) = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":644
 *     if childcount == 0:
 *         c_start_node[0] = NULL
 *         c_length[0] = 0             # <<<<<<<<<<<<<<
 *         if sliceobject.step is None:
 *             c_step[0] = 1
 */
    (__pyx_v_c_length[0]) = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":645
 *         c_start_node[0] = NULL
 *         c_length[0] = 0
 *         if sliceobject.step is None:             # <<<<<<<<<<<<<<
 *             c_step[0] = 1
 *         else:
 */
    __pyx_1 = (__pyx_v_sliceobject->step == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":646
 *         c_length[0] = 0
 *         if sliceobject.step is None:
 *             c_step[0] = 1             # <<<<<<<<<<<<<<
 *         else:
 *             python._PyEval_SliceIndex(sliceobject.step, c_step)
 */
      (__pyx_v_c_step[0]) = 1;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":648
 *             c_step[0] = 1
 *         else:
 *             python._PyEval_SliceIndex(sliceobject.step, c_step)             # <<<<<<<<<<<<<<
 *         return 0
 *     python.PySlice_GetIndicesEx(
 */
      __pyx_2 = _PyEval_SliceIndex(__pyx_v_sliceobject->step, __pyx_v_c_step); if (unlikely(__pyx_2 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":649
 *         else:
 *             python._PyEval_SliceIndex(sliceobject.step, c_step)
 *         return 0             # <<<<<<<<<<<<<<
 *     python.PySlice_GetIndicesEx(
 *         sliceobject, childcount, &start, &stop, c_step, c_length)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":651
 *         return 0
 *     python.PySlice_GetIndicesEx(
 *         sliceobject, childcount, &start, &stop, c_step, c_length)             # <<<<<<<<<<<<<<
 *     if start > childcount / 2:
 *         c_start_node[0] = _findChildBackwards(c_parent, childcount - start - 1)
 */
  __pyx_2 = PySlice_GetIndicesEx(((PyObject *)__pyx_v_sliceobject), __pyx_v_childcount, (&__pyx_v_start), (&__pyx_v_stop), __pyx_v_c_step, __pyx_v_c_length); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":652
 *     python.PySlice_GetIndicesEx(
 *         sliceobject, childcount, &start, &stop, c_step, c_length)
 *     if start > childcount / 2:             # <<<<<<<<<<<<<<
 *         c_start_node[0] = _findChildBackwards(c_parent, childcount - start - 1)
 *     else:
 */
  __pyx_1 = (__pyx_v_start > (__pyx_v_childcount / 2));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":653
 *         sliceobject, childcount, &start, &stop, c_step, c_length)
 *     if start > childcount / 2:
 *         c_start_node[0] = _findChildBackwards(c_parent, childcount - start - 1)             # <<<<<<<<<<<<<<
 *     else:
 *         c_start_node[0] = _findChild(c_parent, start)
 */
    (__pyx_v_c_start_node[0]) = __pyx_f_4lxml_5etree__findChildBackwards(__pyx_v_c_parent, ((__pyx_v_childcount - __pyx_v_start) - 1));
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":655
 *         c_start_node[0] = _findChildBackwards(c_parent, childcount - start - 1)
 *     else:
 *         c_start_node[0] = _findChild(c_parent, start)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    (__pyx_v_c_start_node[0]) = __pyx_f_4lxml_5etree__findChild(__pyx_v_c_parent, __pyx_v_start);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":656
 *     else:
 *         c_start_node[0] = _findChild(c_parent, start)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef bint _isFullSlice(python.slice sliceobject):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._findChildSlice");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":658
 *     return 0
 * 
 * cdef bint _isFullSlice(python.slice sliceobject):             # <<<<<<<<<<<<<<
 *     u"""Conservative guess if this slice is a full slice as in ``s[:]``.
 *     """
 */

static  int __pyx_f_4lxml_5etree__isFullSlice(PySliceObject *__pyx_v_sliceobject) {
  Py_ssize_t __pyx_v_step;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":662
 *     """
 *     cdef Py_ssize_t step
 *     if sliceobject is None:             # <<<<<<<<<<<<<<
 *         return 0
 *     if sliceobject.start is None and \
 */
  __pyx_1 = (((PyObject *)__pyx_v_sliceobject) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":663
 *     cdef Py_ssize_t step
 *     if sliceobject is None:
 *         return 0             # <<<<<<<<<<<<<<
 *     if sliceobject.start is None and \
 *             sliceobject.stop is None:
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":664
 *     if sliceobject is None:
 *         return 0
 *     if sliceobject.start is None and \             # <<<<<<<<<<<<<<
 *             sliceobject.stop is None:
 *         if sliceobject.step is None:
 */
  __pyx_1 = (__pyx_v_sliceobject->start == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":665
 *         return 0
 *     if sliceobject.start is None and \
 *             sliceobject.stop is None:             # <<<<<<<<<<<<<<
 *         if sliceobject.step is None:
 *             return 1
 */
    __pyx_1 = (__pyx_v_sliceobject->stop == Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":666
 *     if sliceobject.start is None and \
 *             sliceobject.stop is None:
 *         if sliceobject.step is None:             # <<<<<<<<<<<<<<
 *             return 1
 *         python._PyEval_SliceIndex(sliceobject.step, &step)
 */
    __pyx_1 = (__pyx_v_sliceobject->step == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":667
 *             sliceobject.stop is None:
 *         if sliceobject.step is None:
 *             return 1             # <<<<<<<<<<<<<<
 *         python._PyEval_SliceIndex(sliceobject.step, &step)
 *         if step == 1:
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":668
 *         if sliceobject.step is None:
 *             return 1
 *         python._PyEval_SliceIndex(sliceobject.step, &step)             # <<<<<<<<<<<<<<
 *         if step == 1:
 *             return 1
 */
    __pyx_2 = _PyEval_SliceIndex(__pyx_v_sliceobject->step, (&__pyx_v_step)); if (unlikely(__pyx_2 == 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":669
 *             return 1
 *         python._PyEval_SliceIndex(sliceobject.step, &step)
 *         if step == 1:             # <<<<<<<<<<<<<<
 *             return 1
 *         return 0
 */
    __pyx_1 = (__pyx_v_step == 1);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":670
 *         python._PyEval_SliceIndex(sliceobject.step, &step)
 *         if step == 1:
 *             return 1             # <<<<<<<<<<<<<<
 *         return 0
 *     return 0
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":671
 *         if step == 1:
 *             return 1
 *         return 0             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":672
 *             return 1
 *         return 0
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef _collectChildren(_Element element):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("lxml.etree._isFullSlice");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":674
 *     return 0
 * 
 * cdef _collectChildren(_Element element):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     result = []
 */

static  PyObject *__pyx_f_4lxml_5etree__collectChildren(struct LxmlElement *__pyx_v_element) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":676
 * cdef _collectChildren(_Element element):
 *     cdef xmlNode* c_node
 *     result = []             # <<<<<<<<<<<<<<
 *     c_node = element._c_node.children
 *     if c_node is not NULL:
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":677
 *     cdef xmlNode* c_node
 *     result = []
 *     c_node = element._c_node.children             # <<<<<<<<<<<<<<
 *     if c_node is not NULL:
 *         if not _isElement(c_node):
 */
  __pyx_v_c_node = __pyx_v_element->_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":678
 *     result = []
 *     c_node = element._c_node.children
 *     if c_node is not NULL:             # <<<<<<<<<<<<<<
 *         if not _isElement(c_node):
 *             c_node = _nextElement(c_node)
 */
  __pyx_2 = (__pyx_v_c_node != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":679
 *     c_node = element._c_node.children
 *     if c_node is not NULL:
 *         if not _isElement(c_node):             # <<<<<<<<<<<<<<
 *             c_node = _nextElement(c_node)
 *         while c_node is not NULL:
 */
    __pyx_2 = (!_isElement(__pyx_v_c_node));
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":680
 *     if c_node is not NULL:
 *         if not _isElement(c_node):
 *             c_node = _nextElement(c_node)             # <<<<<<<<<<<<<<
 *         while c_node is not NULL:
 *             python.PyList_Append(result, _elementFactory(element._doc, c_node))
 */
      __pyx_v_c_node = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":681
 *         if not _isElement(c_node):
 *             c_node = _nextElement(c_node)
 *         while c_node is not NULL:             # <<<<<<<<<<<<<<
 *             python.PyList_Append(result, _elementFactory(element._doc, c_node))
 *             c_node = _nextElement(c_node)
 */
    while (1) {
      __pyx_2 = (__pyx_v_c_node != NULL);
      if (!__pyx_2) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":682
 *             c_node = _nextElement(c_node)
 *         while c_node is not NULL:
 *             python.PyList_Append(result, _elementFactory(element._doc, c_node))             # <<<<<<<<<<<<<<
 *             c_node = _nextElement(c_node)
 *     return result
 */
      __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_element->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyList_Append(__pyx_v_result, __pyx_1); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":683
 *         while c_node is not NULL:
 *             python.PyList_Append(result, _elementFactory(element._doc, c_node))
 *             c_node = _nextElement(c_node)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
      __pyx_v_c_node = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":684
 *             python.PyList_Append(result, _elementFactory(element._doc, c_node))
 *             c_node = _nextElement(c_node)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _findChild(xmlNode* c_node, Py_ssize_t index):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._collectChildren");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":686
 *     return result
 * 
 * cdef inline xmlNode* _findChild(xmlNode* c_node, Py_ssize_t index):             # <<<<<<<<<<<<<<
 *     if index < 0:
 *         return _findChildBackwards(c_node, -index - 1)
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__findChild(xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_index) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":687
 * 
 * cdef inline xmlNode* _findChild(xmlNode* c_node, Py_ssize_t index):
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         return _findChildBackwards(c_node, -index - 1)
 *     else:
 */
  __pyx_1 = (__pyx_v_index < 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":688
 * cdef inline xmlNode* _findChild(xmlNode* c_node, Py_ssize_t index):
 *     if index < 0:
 *         return _findChildBackwards(c_node, -index - 1)             # <<<<<<<<<<<<<<
 *     else:
 *         return _findChildForwards(c_node, index)
 */
    __pyx_r = __pyx_f_4lxml_5etree__findChildBackwards(__pyx_v_c_node, ((-__pyx_v_index) - 1));
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":690
 *         return _findChildBackwards(c_node, -index - 1)
 *     else:
 *         return _findChildForwards(c_node, index)             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _findChildForwards(xmlNode* c_node, Py_ssize_t index):
 */
    __pyx_r = __pyx_f_4lxml_5etree__findChildForwards(__pyx_v_c_node, __pyx_v_index);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":692
 *         return _findChildForwards(c_node, index)
 * 
 * cdef inline xmlNode* _findChildForwards(xmlNode* c_node, Py_ssize_t index):             # <<<<<<<<<<<<<<
 *     u"""Return child element of c_node with index, or return NULL if not found.
 *     """
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__findChildForwards(xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_index) {
  xmlNode *__pyx_v_c_child;
  Py_ssize_t __pyx_v_c;
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":697
 *     cdef xmlNode* c_child
 *     cdef Py_ssize_t c
 *     c_child = c_node.children             # <<<<<<<<<<<<<<
 *     c = 0
 *     while c_child is not NULL:
 */
  __pyx_v_c_child = __pyx_v_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":698
 *     cdef Py_ssize_t c
 *     c_child = c_node.children
 *     c = 0             # <<<<<<<<<<<<<<
 *     while c_child is not NULL:
 *         if _isElement(c_child):
 */
  __pyx_v_c = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":699
 *     c_child = c_node.children
 *     c = 0
 *     while c_child is not NULL:             # <<<<<<<<<<<<<<
 *         if _isElement(c_child):
 *             if c == index:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_child != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":700
 *     c = 0
 *     while c_child is not NULL:
 *         if _isElement(c_child):             # <<<<<<<<<<<<<<
 *             if c == index:
 *                 return c_child
 */
    __pyx_1 = _isElement(__pyx_v_c_child);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":701
 *     while c_child is not NULL:
 *         if _isElement(c_child):
 *             if c == index:             # <<<<<<<<<<<<<<
 *                 return c_child
 *             c = c + 1
 */
      __pyx_1 = (__pyx_v_c == __pyx_v_index);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":702
 *         if _isElement(c_child):
 *             if c == index:
 *                 return c_child             # <<<<<<<<<<<<<<
 *             c = c + 1
 *         c_child = c_child.next
 */
        __pyx_r = __pyx_v_c_child;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":703
 *             if c == index:
 *                 return c_child
 *             c = c + 1             # <<<<<<<<<<<<<<
 *         c_child = c_child.next
 *     return NULL
 */
      __pyx_v_c = (__pyx_v_c + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":704
 *                 return c_child
 *             c = c + 1
 *         c_child = c_child.next             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    __pyx_v_c_child = __pyx_v_c_child->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":705
 *             c = c + 1
 *         c_child = c_child.next
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _findChildBackwards(xmlNode* c_node, Py_ssize_t index):
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":707
 *     return NULL
 * 
 * cdef inline xmlNode* _findChildBackwards(xmlNode* c_node, Py_ssize_t index):             # <<<<<<<<<<<<<<
 *     u"""Return child element of c_node with index, or return NULL if not found.
 *     Search from the end.
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__findChildBackwards(xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_index) {
  xmlNode *__pyx_v_c_child;
  Py_ssize_t __pyx_v_c;
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":713
 *     cdef xmlNode* c_child
 *     cdef Py_ssize_t c
 *     c_child = c_node.last             # <<<<<<<<<<<<<<
 *     c = 0
 *     while c_child is not NULL:
 */
  __pyx_v_c_child = __pyx_v_c_node->last;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":714
 *     cdef Py_ssize_t c
 *     c_child = c_node.last
 *     c = 0             # <<<<<<<<<<<<<<
 *     while c_child is not NULL:
 *         if _isElement(c_child):
 */
  __pyx_v_c = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":715
 *     c_child = c_node.last
 *     c = 0
 *     while c_child is not NULL:             # <<<<<<<<<<<<<<
 *         if _isElement(c_child):
 *             if c == index:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_child != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":716
 *     c = 0
 *     while c_child is not NULL:
 *         if _isElement(c_child):             # <<<<<<<<<<<<<<
 *             if c == index:
 *                 return c_child
 */
    __pyx_1 = _isElement(__pyx_v_c_child);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":717
 *     while c_child is not NULL:
 *         if _isElement(c_child):
 *             if c == index:             # <<<<<<<<<<<<<<
 *                 return c_child
 *             c = c + 1
 */
      __pyx_1 = (__pyx_v_c == __pyx_v_index);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":718
 *         if _isElement(c_child):
 *             if c == index:
 *                 return c_child             # <<<<<<<<<<<<<<
 *             c = c + 1
 *         c_child = c_child.prev
 */
        __pyx_r = __pyx_v_c_child;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":719
 *             if c == index:
 *                 return c_child
 *             c = c + 1             # <<<<<<<<<<<<<<
 *         c_child = c_child.prev
 *     return NULL
 */
      __pyx_v_c = (__pyx_v_c + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":720
 *                 return c_child
 *             c = c + 1
 *         c_child = c_child.prev             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    __pyx_v_c_child = __pyx_v_c_child->prev;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":721
 *             c = c + 1
 *         c_child = c_child.prev
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _textNodeOrSkip(xmlNode* c_node) nogil:
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":723
 *     return NULL
 * 
 * cdef inline xmlNode* _textNodeOrSkip(xmlNode* c_node) nogil:             # <<<<<<<<<<<<<<
 *     u"""Return the node if it's a text node.  Skip over ignorable nodes in a
 *     series of text nodes.  Return NULL if a non-ignorable node is found.
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__textNodeOrSkip(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":730
 *     nodes.
 *     """
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         if c_node.type == tree.XML_TEXT_NODE:
 *             return c_node
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":731
 *     """
 *     while c_node is not NULL:
 *         if c_node.type == tree.XML_TEXT_NODE:             # <<<<<<<<<<<<<<
 *             return c_node
 *         if c_node.type == tree.XML_CDATA_SECTION_NODE:
 */
    __pyx_1 = (__pyx_v_c_node->type == XML_TEXT_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":732
 *     while c_node is not NULL:
 *         if c_node.type == tree.XML_TEXT_NODE:
 *             return c_node             # <<<<<<<<<<<<<<
 *         if c_node.type == tree.XML_CDATA_SECTION_NODE:
 *             return c_node
 */
      __pyx_r = __pyx_v_c_node;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":733
 *         if c_node.type == tree.XML_TEXT_NODE:
 *             return c_node
 *         if c_node.type == tree.XML_CDATA_SECTION_NODE:             # <<<<<<<<<<<<<<
 *             return c_node
 *         elif c_node.type == tree.XML_XINCLUDE_START or \
 */
    __pyx_1 = (__pyx_v_c_node->type == XML_CDATA_SECTION_NODE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":734
 *             return c_node
 *         if c_node.type == tree.XML_CDATA_SECTION_NODE:
 *             return c_node             # <<<<<<<<<<<<<<
 *         elif c_node.type == tree.XML_XINCLUDE_START or \
 *                  c_node.type == tree.XML_XINCLUDE_END:
 */
      __pyx_r = __pyx_v_c_node;
      goto __pyx_L0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":735
 *         if c_node.type == tree.XML_CDATA_SECTION_NODE:
 *             return c_node
 *         elif c_node.type == tree.XML_XINCLUDE_START or \             # <<<<<<<<<<<<<<
 *                  c_node.type == tree.XML_XINCLUDE_END:
 *             c_node = c_node.next
 */
    __pyx_1 = (__pyx_v_c_node->type == XML_XINCLUDE_START);
    if (!__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":736
 *             return c_node
 *         elif c_node.type == tree.XML_XINCLUDE_START or \
 *                  c_node.type == tree.XML_XINCLUDE_END:             # <<<<<<<<<<<<<<
 *             c_node = c_node.next
 *         else:
 */
      __pyx_1 = (__pyx_v_c_node->type == XML_XINCLUDE_END);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":737
 *         elif c_node.type == tree.XML_XINCLUDE_START or \
 *                  c_node.type == tree.XML_XINCLUDE_END:
 *             c_node = c_node.next             # <<<<<<<<<<<<<<
 *         else:
 *             return NULL
 */
      __pyx_v_c_node = __pyx_v_c_node->next;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":739
 *             c_node = c_node.next
 *         else:
 *             return NULL             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
      __pyx_r = NULL;
      goto __pyx_L0;
    }
    __pyx_L6:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":740
 *         else:
 *             return NULL
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _nextElement(xmlNode* c_node):
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":742
 *     return NULL
 * 
 * cdef inline xmlNode* _nextElement(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"""Given a node, find the next sibling that is an element.
 *     """
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__nextElement(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":745
 *     u"""Given a node, find the next sibling that is an element.
 *     """
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return NULL
 *     c_node = c_node.next
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":746
 *     """
 *     if c_node is NULL:
 *         return NULL             # <<<<<<<<<<<<<<
 *     c_node = c_node.next
 *     while c_node is not NULL:
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":747
 *     if c_node is NULL:
 *         return NULL
 *     c_node = c_node.next             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         if _isElement(c_node):
 */
  __pyx_v_c_node = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":748
 *         return NULL
 *     c_node = c_node.next
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         if _isElement(c_node):
 *             return c_node
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":749
 *     c_node = c_node.next
 *     while c_node is not NULL:
 *         if _isElement(c_node):             # <<<<<<<<<<<<<<
 *             return c_node
 *         c_node = c_node.next
 */
    __pyx_1 = _isElement(__pyx_v_c_node);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":750
 *     while c_node is not NULL:
 *         if _isElement(c_node):
 *             return c_node             # <<<<<<<<<<<<<<
 *         c_node = c_node.next
 *     return NULL
 */
      __pyx_r = __pyx_v_c_node;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":751
 *         if _isElement(c_node):
 *             return c_node
 *         c_node = c_node.next             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":752
 *             return c_node
 *         c_node = c_node.next
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _previousElement(xmlNode* c_node):
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":754
 *     return NULL
 * 
 * cdef inline xmlNode* _previousElement(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"""Given a node, find the next sibling that is an element.
 *     """
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__previousElement(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":757
 *     u"""Given a node, find the next sibling that is an element.
 *     """
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return NULL
 *     c_node = c_node.prev
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":758
 *     """
 *     if c_node is NULL:
 *         return NULL             # <<<<<<<<<<<<<<
 *     c_node = c_node.prev
 *     while c_node is not NULL:
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":759
 *     if c_node is NULL:
 *         return NULL
 *     c_node = c_node.prev             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         if _isElement(c_node):
 */
  __pyx_v_c_node = __pyx_v_c_node->prev;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":760
 *         return NULL
 *     c_node = c_node.prev
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         if _isElement(c_node):
 *             return c_node
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":761
 *     c_node = c_node.prev
 *     while c_node is not NULL:
 *         if _isElement(c_node):             # <<<<<<<<<<<<<<
 *             return c_node
 *         c_node = c_node.prev
 */
    __pyx_1 = _isElement(__pyx_v_c_node);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":762
 *     while c_node is not NULL:
 *         if _isElement(c_node):
 *             return c_node             # <<<<<<<<<<<<<<
 *         c_node = c_node.prev
 *     return NULL
 */
      __pyx_r = __pyx_v_c_node;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":763
 *         if _isElement(c_node):
 *             return c_node
 *         c_node = c_node.prev             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->prev;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":764
 *             return c_node
 *         c_node = c_node.prev
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _parentElement(xmlNode* c_node):
 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":766
 *     return NULL
 * 
 * cdef inline xmlNode* _parentElement(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"Given a node, find the parent element."
 *     if c_node is NULL or not _isElement(c_node):
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__parentElement(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":768
 * cdef inline xmlNode* _parentElement(xmlNode* c_node):
 *     u"Given a node, find the parent element."
 *     if c_node is NULL or not _isElement(c_node):             # <<<<<<<<<<<<<<
 *         return NULL
 *     c_node = c_node.parent
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (!__pyx_1) {
    __pyx_1 = (!_isElement(__pyx_v_c_node));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":769
 *     u"Given a node, find the parent element."
 *     if c_node is NULL or not _isElement(c_node):
 *         return NULL             # <<<<<<<<<<<<<<
 *     c_node = c_node.parent
 *     if c_node is NULL or not _isElement(c_node):
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":770
 *     if c_node is NULL or not _isElement(c_node):
 *         return NULL
 *     c_node = c_node.parent             # <<<<<<<<<<<<<<
 *     if c_node is NULL or not _isElement(c_node):
 *         return NULL
 */
  __pyx_v_c_node = __pyx_v_c_node->parent;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":771
 *         return NULL
 *     c_node = c_node.parent
 *     if c_node is NULL or not _isElement(c_node):             # <<<<<<<<<<<<<<
 *         return NULL
 *     return c_node
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (!__pyx_1) {
    __pyx_1 = (!_isElement(__pyx_v_c_node));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":772
 *     c_node = c_node.parent
 *     if c_node is NULL or not _isElement(c_node):
 *         return NULL             # <<<<<<<<<<<<<<
 *     return c_node
 * 
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":773
 *     if c_node is NULL or not _isElement(c_node):
 *         return NULL
 *     return c_node             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint _tagMatches(xmlNode* c_node, char* c_href, char* c_name):
 */
  __pyx_r = __pyx_v_c_node;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":775
 *     return c_node
 * 
 * cdef inline bint _tagMatches(xmlNode* c_node, char* c_href, char* c_name):             # <<<<<<<<<<<<<<
 *     u"""Tests if the node matches namespace URI and tag name.
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__tagMatches(xmlNode *__pyx_v_c_node, char *__pyx_v_c_href, char *__pyx_v_c_name) {
  char *__pyx_v_c_node_href;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":790
 *     """
 *     cdef char* c_node_href
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return 0
 *     if c_node.type != tree.XML_ELEMENT_NODE:
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":791
 *     cdef char* c_node_href
 *     if c_node is NULL:
 *         return 0             # <<<<<<<<<<<<<<
 *     if c_node.type != tree.XML_ELEMENT_NODE:
 *         # not an element, only succeed if we match everything
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":792
 *     if c_node is NULL:
 *         return 0
 *     if c_node.type != tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         # not an element, only succeed if we match everything
 *         return c_name is NULL and c_href is NULL
 */
  __pyx_1 = (__pyx_v_c_node->type != XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":794
 *     if c_node.type != tree.XML_ELEMENT_NODE:
 *         # not an element, only succeed if we match everything
 *         return c_name is NULL and c_href is NULL             # <<<<<<<<<<<<<<
 *     if c_name is NULL:
 *         if c_href is NULL:
 */
    __pyx_1 = (__pyx_v_c_name == NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c_href == NULL);
    }
    __pyx_r = __pyx_1;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":795
 *         # not an element, only succeed if we match everything
 *         return c_name is NULL and c_href is NULL
 *     if c_name is NULL:             # <<<<<<<<<<<<<<
 *         if c_href is NULL:
 *             # always match
 */
  __pyx_1 = (__pyx_v_c_name == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":796
 *         return c_name is NULL and c_href is NULL
 *     if c_name is NULL:
 *         if c_href is NULL:             # <<<<<<<<<<<<<<
 *             # always match
 *             return 1
 */
    __pyx_1 = (__pyx_v_c_href == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":798
 *         if c_href is NULL:
 *             # always match
 *             return 1             # <<<<<<<<<<<<<<
 *         else:
 *             c_node_href = _getNs(c_node)
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":800
 *             return 1
 *         else:
 *             c_node_href = _getNs(c_node)             # <<<<<<<<<<<<<<
 *             if c_node_href is NULL:
 *                 return c_href[0] == c'\0'
 */
      __pyx_v_c_node_href = _getNs(__pyx_v_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":801
 *         else:
 *             c_node_href = _getNs(c_node)
 *             if c_node_href is NULL:             # <<<<<<<<<<<<<<
 *                 return c_href[0] == c'\0'
 *             else:
 */
      __pyx_1 = (__pyx_v_c_node_href == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":802
 *             c_node_href = _getNs(c_node)
 *             if c_node_href is NULL:
 *                 return c_href[0] == c'\0'             # <<<<<<<<<<<<<<
 *             else:
 *                 return cstd.strcmp(c_node_href, c_href) == 0
 */
        __pyx_r = ((__pyx_v_c_href[0]) == '\x00');
        goto __pyx_L0;
        goto __pyx_L7;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":804
 *                 return c_href[0] == c'\0'
 *             else:
 *                 return cstd.strcmp(c_node_href, c_href) == 0             # <<<<<<<<<<<<<<
 *     elif c_href is NULL:
 *         if _getNs(c_node) is not NULL:
 */
        __pyx_r = (strcmp(__pyx_v_c_node_href, __pyx_v_c_href) == 0);
        goto __pyx_L0;
      }
      __pyx_L7:;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":805
 *             else:
 *                 return cstd.strcmp(c_node_href, c_href) == 0
 *     elif c_href is NULL:             # <<<<<<<<<<<<<<
 *         if _getNs(c_node) is not NULL:
 *             return 0
 */
  __pyx_1 = (__pyx_v_c_href == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":806
 *                 return cstd.strcmp(c_node_href, c_href) == 0
 *     elif c_href is NULL:
 *         if _getNs(c_node) is not NULL:             # <<<<<<<<<<<<<<
 *             return 0
 *         return c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0
 */
    __pyx_1 = (_getNs(__pyx_v_c_node) != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":807
 *     elif c_href is NULL:
 *         if _getNs(c_node) is not NULL:
 *             return 0             # <<<<<<<<<<<<<<
 *         return c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0
 *     elif c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0:
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":808
 *         if _getNs(c_node) is not NULL:
 *             return 0
 *         return c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0             # <<<<<<<<<<<<<<
 *     elif c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0:
 *         c_node_href = _getNs(c_node)
 */
    __pyx_1 = (__pyx_v_c_node->name == __pyx_v_c_name);
    if (!__pyx_1) {
      __pyx_1 = (strcmp(__pyx_v_c_node->name, __pyx_v_c_name) == 0);
    }
    __pyx_r = __pyx_1;
    goto __pyx_L0;
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":809
 *             return 0
 *         return c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0
 *     elif c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0:             # <<<<<<<<<<<<<<
 *         c_node_href = _getNs(c_node)
 *         if c_node_href is NULL:
 */
  __pyx_1 = (__pyx_v_c_node->name == __pyx_v_c_name);
  if (!__pyx_1) {
    __pyx_1 = (strcmp(__pyx_v_c_node->name, __pyx_v_c_name) == 0);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":810
 *         return c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0
 *     elif c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0:
 *         c_node_href = _getNs(c_node)             # <<<<<<<<<<<<<<
 *         if c_node_href is NULL:
 *             return c_href[0] == c'\0'
 */
    __pyx_v_c_node_href = _getNs(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":811
 *     elif c_node.name == c_name or cstd.strcmp(c_node.name, c_name) == 0:
 *         c_node_href = _getNs(c_node)
 *         if c_node_href is NULL:             # <<<<<<<<<<<<<<
 *             return c_href[0] == c'\0'
 *         else:
 */
    __pyx_1 = (__pyx_v_c_node_href == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":812
 *         c_node_href = _getNs(c_node)
 *         if c_node_href is NULL:
 *             return c_href[0] == c'\0'             # <<<<<<<<<<<<<<
 *         else:
 *             return cstd.strcmp(c_node_href, c_href) == 0
 */
      __pyx_r = ((__pyx_v_c_href[0]) == '\x00');
      goto __pyx_L0;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":814
 *             return c_href[0] == c'\0'
 *         else:
 *             return cstd.strcmp(c_node_href, c_href) == 0             # <<<<<<<<<<<<<<
 *     else:
 *         return 0
 */
      __pyx_r = (strcmp(__pyx_v_c_node_href, __pyx_v_c_href) == 0);
      goto __pyx_L0;
    }
    __pyx_L9:;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":816
 *             return cstd.strcmp(c_node_href, c_href) == 0
 *     else:
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _removeNode(_Document doc, xmlNode* c_node) except -1:
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":818
 *         return 0
 * 
 * cdef int _removeNode(_Document doc, xmlNode* c_node) except -1:             # <<<<<<<<<<<<<<
 *     u"""Unlink and free a node and subnodes if possible.  Otherwise, make sure
 *     it's self-contained.
 */

static  int __pyx_f_4lxml_5etree__removeNode(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_v_c_next;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":823
 *     """
 *     cdef xmlNode* c_next
 *     c_next = c_node.next             # <<<<<<<<<<<<<<
 *     tree.xmlUnlinkNode(c_node)
 *     _moveTail(c_next, c_node)
 */
  __pyx_v_c_next = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":824
 *     cdef xmlNode* c_next
 *     c_next = c_node.next
 *     tree.xmlUnlinkNode(c_node)             # <<<<<<<<<<<<<<
 *     _moveTail(c_next, c_node)
 *     if not attemptDeallocation(c_node):
 */
  xmlUnlinkNode(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":825
 *     c_next = c_node.next
 *     tree.xmlUnlinkNode(c_node)
 *     _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 *     if not attemptDeallocation(c_node):
 *         # make namespaces absolute
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":826
 *     tree.xmlUnlinkNode(c_node)
 *     _moveTail(c_next, c_node)
 *     if not attemptDeallocation(c_node):             # <<<<<<<<<<<<<<
 *         # make namespaces absolute
 *         moveNodeToDocument(doc, c_node.doc, c_node)
 */
  __pyx_1 = (!__pyx_f_4lxml_5etree_attemptDeallocation(__pyx_v_c_node));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":828
 *     if not attemptDeallocation(c_node):
 *         # make namespaces absolute
 *         moveNodeToDocument(doc, c_node.doc, c_node)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(__pyx_v_doc, __pyx_v_c_node->doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":829
 *         # make namespaces absolute
 *         moveNodeToDocument(doc, c_node.doc, c_node)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef void _moveTail(xmlNode* c_tail, xmlNode* c_target):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._removeNode");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":831
 *     return 0
 * 
 * cdef void _moveTail(xmlNode* c_tail, xmlNode* c_target):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_next
 *     # tail support: look for any text nodes trailing this node and
 */

static  void __pyx_f_4lxml_5etree__moveTail(xmlNode *__pyx_v_c_tail, xmlNode *__pyx_v_c_target) {
  xmlNode *__pyx_v_c_next;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":835
 *     # tail support: look for any text nodes trailing this node and
 *     # move them too
 *     c_tail = _textNodeOrSkip(c_tail)             # <<<<<<<<<<<<<<
 *     while c_tail is not NULL:
 *         c_next = _textNodeOrSkip(c_tail.next)
 */
  __pyx_v_c_tail = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_tail);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":836
 *     # move them too
 *     c_tail = _textNodeOrSkip(c_tail)
 *     while c_tail is not NULL:             # <<<<<<<<<<<<<<
 *         c_next = _textNodeOrSkip(c_tail.next)
 *         tree.xmlUnlinkNode(c_tail)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_tail != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":837
 *     c_tail = _textNodeOrSkip(c_tail)
 *     while c_tail is not NULL:
 *         c_next = _textNodeOrSkip(c_tail.next)             # <<<<<<<<<<<<<<
 *         tree.xmlUnlinkNode(c_tail)
 *         tree.xmlAddNextSibling(c_target, c_tail)
 */
    __pyx_v_c_next = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_tail->next);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":838
 *     while c_tail is not NULL:
 *         c_next = _textNodeOrSkip(c_tail.next)
 *         tree.xmlUnlinkNode(c_tail)             # <<<<<<<<<<<<<<
 *         tree.xmlAddNextSibling(c_target, c_tail)
 *         c_target = c_tail
 */
    xmlUnlinkNode(__pyx_v_c_tail);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":839
 *         c_next = _textNodeOrSkip(c_tail.next)
 *         tree.xmlUnlinkNode(c_tail)
 *         tree.xmlAddNextSibling(c_target, c_tail)             # <<<<<<<<<<<<<<
 *         c_target = c_tail
 *         c_tail = c_next
 */
    xmlAddNextSibling(__pyx_v_c_target, __pyx_v_c_tail);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":840
 *         tree.xmlUnlinkNode(c_tail)
 *         tree.xmlAddNextSibling(c_target, c_tail)
 *         c_target = c_tail             # <<<<<<<<<<<<<<
 *         c_tail = c_next
 * 
 */
    __pyx_v_c_target = __pyx_v_c_tail;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":841
 *         tree.xmlAddNextSibling(c_target, c_tail)
 *         c_target = c_tail
 *         c_tail = c_next             # <<<<<<<<<<<<<<
 * 
 * cdef void _copyTail(xmlNode* c_tail, xmlNode* c_target):
 */
    __pyx_v_c_tail = __pyx_v_c_next;
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":843
 *         c_tail = c_next
 * 
 * cdef void _copyTail(xmlNode* c_tail, xmlNode* c_target):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_new_tail
 *     # tail copying support: look for any text nodes trailing this node and
 */

static  void __pyx_f_4lxml_5etree__copyTail(xmlNode *__pyx_v_c_tail, xmlNode *__pyx_v_c_target) {
  xmlNode *__pyx_v_c_new_tail;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":847
 *     # tail copying support: look for any text nodes trailing this node and
 *     # copy it to the target node
 *     c_tail = _textNodeOrSkip(c_tail)             # <<<<<<<<<<<<<<
 *     while c_tail is not NULL:
 *         if c_target.doc is not c_tail.doc:
 */
  __pyx_v_c_tail = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_tail);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":848
 *     # copy it to the target node
 *     c_tail = _textNodeOrSkip(c_tail)
 *     while c_tail is not NULL:             # <<<<<<<<<<<<<<
 *         if c_target.doc is not c_tail.doc:
 *             c_new_tail = tree.xmlDocCopyNode(c_tail, c_target.doc, 0)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_tail != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":849
 *     c_tail = _textNodeOrSkip(c_tail)
 *     while c_tail is not NULL:
 *         if c_target.doc is not c_tail.doc:             # <<<<<<<<<<<<<<
 *             c_new_tail = tree.xmlDocCopyNode(c_tail, c_target.doc, 0)
 *         else:
 */
    __pyx_1 = (__pyx_v_c_target->doc != __pyx_v_c_tail->doc);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":850
 *     while c_tail is not NULL:
 *         if c_target.doc is not c_tail.doc:
 *             c_new_tail = tree.xmlDocCopyNode(c_tail, c_target.doc, 0)             # <<<<<<<<<<<<<<
 *         else:
 *             c_new_tail = tree.xmlCopyNode(c_tail, 0)
 */
      __pyx_v_c_new_tail = xmlDocCopyNode(__pyx_v_c_tail, __pyx_v_c_target->doc, 0);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":852
 *             c_new_tail = tree.xmlDocCopyNode(c_tail, c_target.doc, 0)
 *         else:
 *             c_new_tail = tree.xmlCopyNode(c_tail, 0)             # <<<<<<<<<<<<<<
 *         tree.xmlAddNextSibling(c_target, c_new_tail)
 *         c_target = c_new_tail
 */
      __pyx_v_c_new_tail = xmlCopyNode(__pyx_v_c_tail, 0);
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":853
 *         else:
 *             c_new_tail = tree.xmlCopyNode(c_tail, 0)
 *         tree.xmlAddNextSibling(c_target, c_new_tail)             # <<<<<<<<<<<<<<
 *         c_target = c_new_tail
 *         c_tail = _textNodeOrSkip(c_tail.next)
 */
    xmlAddNextSibling(__pyx_v_c_target, __pyx_v_c_new_tail);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":854
 *             c_new_tail = tree.xmlCopyNode(c_tail, 0)
 *         tree.xmlAddNextSibling(c_target, c_new_tail)
 *         c_target = c_new_tail             # <<<<<<<<<<<<<<
 *         c_tail = _textNodeOrSkip(c_tail.next)
 * 
 */
    __pyx_v_c_target = __pyx_v_c_new_tail;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":855
 *         tree.xmlAddNextSibling(c_target, c_new_tail)
 *         c_target = c_new_tail
 *         c_tail = _textNodeOrSkip(c_tail.next)             # <<<<<<<<<<<<<<
 * 
 * cdef int _deleteSlice(_Document doc, xmlNode* c_node,
 */
    __pyx_v_c_tail = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_tail->next);
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":857
 *         c_tail = _textNodeOrSkip(c_tail.next)
 * 
 * cdef int _deleteSlice(_Document doc, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                       Py_ssize_t count, Py_ssize_t step) except -1:
 *     u"""Delete slice, ``count`` items starting with ``c_node`` with a step
 */

static  int __pyx_f_4lxml_5etree__deleteSlice(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_count, Py_ssize_t __pyx_v_step) {
  xmlNode *__pyx_v_c_next;
  Py_ssize_t __pyx_v_c;
  Py_ssize_t __pyx_v_i;
  _node_to_node_function __pyx_v_next_element;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":865
 *     cdef Py_ssize_t c, i
 *     cdef _node_to_node_function next_element
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return 0
 *     if step > 0:
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":866
 *     cdef _node_to_node_function next_element
 *     if c_node is NULL:
 *         return 0             # <<<<<<<<<<<<<<
 *     if step > 0:
 *         next_element = _nextElement
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":867
 *     if c_node is NULL:
 *         return 0
 *     if step > 0:             # <<<<<<<<<<<<<<
 *         next_element = _nextElement
 *     else:
 */
  __pyx_1 = (__pyx_v_step > 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":868
 *         return 0
 *     if step > 0:
 *         next_element = _nextElement             # <<<<<<<<<<<<<<
 *     else:
 *         step = -step
 */
    __pyx_v_next_element = __pyx_f_4lxml_5etree__nextElement;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":870
 *         next_element = _nextElement
 *     else:
 *         step = -step             # <<<<<<<<<<<<<<
 *         next_element = _previousElement
 *     # now start deleting nodes
 */
    __pyx_v_step = (-__pyx_v_step);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":871
 *     else:
 *         step = -step
 *         next_element = _previousElement             # <<<<<<<<<<<<<<
 *     # now start deleting nodes
 *     c = 0
 */
    __pyx_v_next_element = __pyx_f_4lxml_5etree__previousElement;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":873
 *         next_element = _previousElement
 *     # now start deleting nodes
 *     c = 0             # <<<<<<<<<<<<<<
 *     c_next = c_node
 *     while c_node is not NULL and c < count:
 */
  __pyx_v_c = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":874
 *     # now start deleting nodes
 *     c = 0
 *     c_next = c_node             # <<<<<<<<<<<<<<
 *     while c_node is not NULL and c < count:
 *         for i from 0 <= i < step:
 */
  __pyx_v_c_next = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":875
 *     c = 0
 *     c_next = c_node
 *     while c_node is not NULL and c < count:             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < step:
 *             c_next = next_element(c_next)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c < __pyx_v_count);
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":876
 *     c_next = c_node
 *     while c_node is not NULL and c < count:
 *         for i from 0 <= i < step:             # <<<<<<<<<<<<<<
 *             c_next = next_element(c_next)
 *         _removeNode(doc, c_node)
 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_step; __pyx_v_i++) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":877
 *     while c_node is not NULL and c < count:
 *         for i from 0 <= i < step:
 *             c_next = next_element(c_next)             # <<<<<<<<<<<<<<
 *         _removeNode(doc, c_node)
 *         c = c + 1
 */
      __pyx_v_c_next = __pyx_v_next_element(__pyx_v_c_next);
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":878
 *         for i from 0 <= i < step:
 *             c_next = next_element(c_next)
 *         _removeNode(doc, c_node)             # <<<<<<<<<<<<<<
 *         c = c + 1
 *         c_node = c_next
 */
    __pyx_2 = __pyx_f_4lxml_5etree__removeNode(__pyx_v_doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":879
 *             c_next = next_element(c_next)
 *         _removeNode(doc, c_node)
 *         c = c + 1             # <<<<<<<<<<<<<<
 *         c_node = c_next
 *     return 0
 */
    __pyx_v_c = (__pyx_v_c + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":880
 *         _removeNode(doc, c_node)
 *         c = c + 1
 *         c_node = c_next             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_v_c_node = __pyx_v_c_next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":881
 *         c = c + 1
 *         c_node = c_next
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _replaceSlice(_Element parent, xmlNode* c_node,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._deleteSlice");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":883
 *     return 0
 * 
 * cdef int _replaceSlice(_Element parent, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                        Py_ssize_t slicelength, Py_ssize_t step,
 *                        bint left_to_right, elements) except -1:
 */

static  int __pyx_f_4lxml_5etree__replaceSlice(struct LxmlElement *__pyx_v_parent, xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_slicelength, Py_ssize_t __pyx_v_step, int __pyx_v_left_to_right, PyObject *__pyx_v_elements) {
  xmlNode *__pyx_v_c_orig_neighbour;
  xmlNode *__pyx_v_c_next;
  xmlDoc *__pyx_v_c_source_doc;
  struct LxmlElement *__pyx_v_element;
  Py_ssize_t __pyx_v_seqlength;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_c;
  _node_to_node_function __pyx_v_next_element;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_elements);
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":898
 *     cdef Py_ssize_t seqlength, i, c
 *     cdef _node_to_node_function next_element
 *     assert step > 0             # <<<<<<<<<<<<<<
 *     if left_to_right:
 *         next_element = _nextElement
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_step > 0))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":899
 *     cdef _node_to_node_function next_element
 *     assert step > 0
 *     if left_to_right:             # <<<<<<<<<<<<<<
 *         next_element = _nextElement
 *     else:
 */
  __pyx_1 = __pyx_v_left_to_right;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":900
 *     assert step > 0
 *     if left_to_right:
 *         next_element = _nextElement             # <<<<<<<<<<<<<<
 *     else:
 *         next_element = _previousElement
 */
    __pyx_v_next_element = __pyx_f_4lxml_5etree__nextElement;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":902
 *         next_element = _nextElement
 *     else:
 *         next_element = _previousElement             # <<<<<<<<<<<<<<
 * 
 *     if not python.PyList_Check(elements) and \
 */
    __pyx_v_next_element = __pyx_f_4lxml_5etree__previousElement;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":904
 *         next_element = _previousElement
 * 
 *     if not python.PyList_Check(elements) and \             # <<<<<<<<<<<<<<
 *             not python.PyTuple_Check(elements):
 *         elements = list(elements)
 */
  __pyx_1 = (!PyList_Check(__pyx_v_elements));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":905
 * 
 *     if not python.PyList_Check(elements) and \
 *             not python.PyTuple_Check(elements):             # <<<<<<<<<<<<<<
 *         elements = list(elements)
 * 
 */
    __pyx_1 = (!PyTuple_Check(__pyx_v_elements));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":906
 *     if not python.PyList_Check(elements) and \
 *             not python.PyTuple_Check(elements):
 *         elements = list(elements)             # <<<<<<<<<<<<<<
 * 
 *     if step > 1:
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_elements);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_elements);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_elements);
    __pyx_v_elements = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":908
 *         elements = list(elements)
 * 
 *     if step > 1:             # <<<<<<<<<<<<<<
 *         # *replacing* children stepwise with list => check size!
 *         seqlength = len(elements)
 */
  __pyx_1 = (__pyx_v_step > 1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":910
 *     if step > 1:
 *         # *replacing* children stepwise with list => check size!
 *         seqlength = len(elements)             # <<<<<<<<<<<<<<
 *         if seqlength != slicelength:
 *             raise ValueError, u"attempt to assign sequence of size %d " \
 */
    __pyx_4 = PyObject_Length(__pyx_v_elements); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seqlength = __pyx_4;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":911
 *         # *replacing* children stepwise with list => check size!
 *         seqlength = len(elements)
 *         if seqlength != slicelength:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"attempt to assign sequence of size %d " \
 *                 u"to extended slice of size %d" % (seqlength, slicelength)
 */
    __pyx_1 = (__pyx_v_seqlength != __pyx_v_slicelength);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":913
 *         if seqlength != slicelength:
 *             raise ValueError, u"attempt to assign sequence of size %d " \
 *                 u"to extended slice of size %d" % (seqlength, slicelength)             # <<<<<<<<<<<<<<
 * 
 *     if c_node is NULL:
 */
      __pyx_2 = PyInt_FromSsize_t(__pyx_v_seqlength); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyInt_FromSsize_t(__pyx_v_slicelength); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
      PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
      __pyx_2 = 0;
      __pyx_3 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_319), ((PyObject *)__pyx_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":915
 *                 u"to extended slice of size %d" % (seqlength, slicelength)
 * 
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         # no children yet => add all elements straight away
 *         if left_to_right:
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":917
 *     if c_node is NULL:
 *         # no children yet => add all elements straight away
 *         if left_to_right:             # <<<<<<<<<<<<<<
 *             for element in elements:
 *                 assert element is not None, u"Node must not be None"
 */
    __pyx_1 = __pyx_v_left_to_right;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":918
 *         # no children yet => add all elements straight away
 *         if left_to_right:
 *             for element in elements:             # <<<<<<<<<<<<<<
 *                 assert element is not None, u"Node must not be None"
 *                 _appendChild(parent, element)
 */
      if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
        __pyx_4 = 0; __pyx_2 = __pyx_v_elements; Py_INCREF(__pyx_2);
      } else {
        __pyx_4 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_2))) {
          if (__pyx_4 >= PyList_GET_SIZE(__pyx_2)) break;
          __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
        } else if (likely(PyTuple_CheckExact(__pyx_2))) {
          if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_2)) break;
          __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
        } else {
          __pyx_3 = PyIter_Next(__pyx_2);
          if (!__pyx_3) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_v_element));
        __pyx_v_element = ((struct LxmlElement *)__pyx_3);
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":919
 *         if left_to_right:
 *             for element in elements:
 *                 assert element is not None, u"Node must not be None"             # <<<<<<<<<<<<<<
 *                 _appendChild(parent, element)
 *         else:
 */
        #ifndef PYREX_WITHOUT_ASSERTIONS
        __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
        if (unlikely(!__pyx_1)) {
          PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_320));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #endif

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":920
 *             for element in elements:
 *                 assert element is not None, u"Node must not be None"
 *                 _appendChild(parent, element)             # <<<<<<<<<<<<<<
 *         else:
 *             for element in elements:
 */
        __pyx_6 = __pyx_f_4lxml_5etree__appendChild(__pyx_v_parent, __pyx_v_element); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":922
 *                 _appendChild(parent, element)
 *         else:
 *             for element in elements:             # <<<<<<<<<<<<<<
 *                 assert element is not None, u"Node must not be None"
 *                 _prependChild(parent, element)
 */
      if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
        __pyx_4 = 0; __pyx_5 = __pyx_v_elements; Py_INCREF(__pyx_5);
      } else {
        __pyx_4 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_5))) {
          if (__pyx_4 >= PyList_GET_SIZE(__pyx_5)) break;
          __pyx_3 = PyList_GET_ITEM(__pyx_5, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
        } else if (likely(PyTuple_CheckExact(__pyx_5))) {
          if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_5)) break;
          __pyx_3 = PyTuple_GET_ITEM(__pyx_5, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
        } else {
          __pyx_3 = PyIter_Next(__pyx_5);
          if (!__pyx_3) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_v_element));
        __pyx_v_element = ((struct LxmlElement *)__pyx_3);
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":923
 *         else:
 *             for element in elements:
 *                 assert element is not None, u"Node must not be None"             # <<<<<<<<<<<<<<
 *                 _prependChild(parent, element)
 *         return 0
 */
        #ifndef PYREX_WITHOUT_ASSERTIONS
        __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
        if (unlikely(!__pyx_1)) {
          PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_321));
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #endif

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":924
 *             for element in elements:
 *                 assert element is not None, u"Node must not be None"
 *                 _prependChild(parent, element)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
        __pyx_6 = __pyx_f_4lxml_5etree__prependChild(__pyx_v_parent, __pyx_v_element); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":925
 *                 assert element is not None, u"Node must not be None"
 *                 _prependChild(parent, element)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     # remove the elements first as some might be re-added
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":928
 * 
 *     # remove the elements first as some might be re-added
 *     if left_to_right:             # <<<<<<<<<<<<<<
 *         # L->R, remember left neighbour
 *         c_orig_neighbour = _previousElement(c_node)
 */
  __pyx_1 = __pyx_v_left_to_right;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":930
 *     if left_to_right:
 *         # L->R, remember left neighbour
 *         c_orig_neighbour = _previousElement(c_node)             # <<<<<<<<<<<<<<
 *     else:
 *         # R->L, remember right neighbour
 */
    __pyx_v_c_orig_neighbour = __pyx_f_4lxml_5etree__previousElement(__pyx_v_c_node);
    goto __pyx_L13;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":933
 *     else:
 *         # R->L, remember right neighbour
 *         c_orig_neighbour = _nextElement(c_node)             # <<<<<<<<<<<<<<
 * 
 *     c = 0
 */
    __pyx_v_c_orig_neighbour = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":935
 *         c_orig_neighbour = _nextElement(c_node)
 * 
 *     c = 0             # <<<<<<<<<<<<<<
 *     c_next = c_node
 *     while c_node is not NULL and c < slicelength:
 */
  __pyx_v_c = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":936
 * 
 *     c = 0
 *     c_next = c_node             # <<<<<<<<<<<<<<
 *     while c_node is not NULL and c < slicelength:
 *         for i from 0 <= i < step:
 */
  __pyx_v_c_next = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":937
 *     c = 0
 *     c_next = c_node
 *     while c_node is not NULL and c < slicelength:             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < step:
 *             c_next = next_element(c_next)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c < __pyx_v_slicelength);
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":938
 *     c_next = c_node
 *     while c_node is not NULL and c < slicelength:
 *         for i from 0 <= i < step:             # <<<<<<<<<<<<<<
 *             c_next = next_element(c_next)
 *         _removeNode(parent._doc, c_node)
 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_step; __pyx_v_i++) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":939
 *     while c_node is not NULL and c < slicelength:
 *         for i from 0 <= i < step:
 *             c_next = next_element(c_next)             # <<<<<<<<<<<<<<
 *         _removeNode(parent._doc, c_node)
 *         c = c + 1
 */
      __pyx_v_c_next = __pyx_v_next_element(__pyx_v_c_next);
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":940
 *         for i from 0 <= i < step:
 *             c_next = next_element(c_next)
 *         _removeNode(parent._doc, c_node)             # <<<<<<<<<<<<<<
 *         c = c + 1
 *         c_node = c_next
 */
    __pyx_6 = __pyx_f_4lxml_5etree__removeNode(__pyx_v_parent->_doc, __pyx_v_c_node); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":941
 *             c_next = next_element(c_next)
 *         _removeNode(parent._doc, c_node)
 *         c = c + 1             # <<<<<<<<<<<<<<
 *         c_node = c_next
 * 
 */
    __pyx_v_c = (__pyx_v_c + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":942
 *         _removeNode(parent._doc, c_node)
 *         c = c + 1
 *         c_node = c_next             # <<<<<<<<<<<<<<
 * 
 *     # make sure each element is inserted only once
 */
    __pyx_v_c_node = __pyx_v_c_next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":945
 * 
 *     # make sure each element is inserted only once
 *     elements = iter(elements)             # <<<<<<<<<<<<<<
 * 
 *     # find the first node right of the new insertion point
 */
  __pyx_2 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_elements);
  __pyx_v_elements = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":948
 * 
 *     # find the first node right of the new insertion point
 *     if left_to_right:             # <<<<<<<<<<<<<<
 *         if c_orig_neighbour is not NULL:
 *             c_node = next_element(c_orig_neighbour)
 */
  __pyx_1 = __pyx_v_left_to_right;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":949
 *     # find the first node right of the new insertion point
 *     if left_to_right:
 *         if c_orig_neighbour is not NULL:             # <<<<<<<<<<<<<<
 *             c_node = next_element(c_orig_neighbour)
 *         else:
 */
    __pyx_1 = (__pyx_v_c_orig_neighbour != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":950
 *     if left_to_right:
 *         if c_orig_neighbour is not NULL:
 *             c_node = next_element(c_orig_neighbour)             # <<<<<<<<<<<<<<
 *         else:
 *             # before the first element
 */
      __pyx_v_c_node = __pyx_v_next_element(__pyx_v_c_orig_neighbour);
      goto __pyx_L19;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":953
 *         else:
 *             # before the first element
 *             c_node = _findChildForwards(parent._c_node, 0)             # <<<<<<<<<<<<<<
 *     elif c_orig_neighbour is NULL:
 *         # at the end, but reversed stepping
 */
      __pyx_v_c_node = __pyx_f_4lxml_5etree__findChildForwards(__pyx_v_parent->_c_node, 0);
    }
    __pyx_L19:;
    goto __pyx_L18;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":954
 *             # before the first element
 *             c_node = _findChildForwards(parent._c_node, 0)
 *     elif c_orig_neighbour is NULL:             # <<<<<<<<<<<<<<
 *         # at the end, but reversed stepping
 *         # append one element and go to the next insertion point
 */
  __pyx_1 = (__pyx_v_c_orig_neighbour == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":957
 *         # at the end, but reversed stepping
 *         # append one element and go to the next insertion point
 *         for element in elements:             # <<<<<<<<<<<<<<
 *             assert element is not None, u"Node must not be None"
 *             _appendChild(parent, element)
 */
    if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
      __pyx_4 = 0; __pyx_3 = __pyx_v_elements; Py_INCREF(__pyx_3);
    } else {
      __pyx_4 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_3))) {
        if (__pyx_4 >= PyList_GET_SIZE(__pyx_3)) break;
        __pyx_5 = PyList_GET_ITEM(__pyx_3, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else if (likely(PyTuple_CheckExact(__pyx_3))) {
        if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_3)) break;
        __pyx_5 = PyTuple_GET_ITEM(__pyx_3, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else {
        __pyx_5 = PyIter_Next(__pyx_3);
        if (!__pyx_5) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_5);
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":958
 *         # append one element and go to the next insertion point
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"             # <<<<<<<<<<<<<<
 *             _appendChild(parent, element)
 *             c_node = element._c_node
 */
      #ifndef PYREX_WITHOUT_ASSERTIONS
      __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
      if (unlikely(!__pyx_1)) {
        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_322));
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":959
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"
 *             _appendChild(parent, element)             # <<<<<<<<<<<<<<
 *             c_node = element._c_node
 *             if slicelength > 0:
 */
      __pyx_6 = __pyx_f_4lxml_5etree__appendChild(__pyx_v_parent, __pyx_v_element); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":960
 *             assert element is not None, u"Node must not be None"
 *             _appendChild(parent, element)
 *             c_node = element._c_node             # <<<<<<<<<<<<<<
 *             if slicelength > 0:
 *                 slicelength = slicelength - 1
 */
      __pyx_v_c_node = __pyx_v_element->_c_node;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":961
 *             _appendChild(parent, element)
 *             c_node = element._c_node
 *             if slicelength > 0:             # <<<<<<<<<<<<<<
 *                 slicelength = slicelength - 1
 *                 for i from 1 <= i < step:
 */
      __pyx_1 = (__pyx_v_slicelength > 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":962
 *             c_node = element._c_node
 *             if slicelength > 0:
 *                 slicelength = slicelength - 1             # <<<<<<<<<<<<<<
 *                 for i from 1 <= i < step:
 *                     c_node = next_element(c_node)
 */
        __pyx_v_slicelength = (__pyx_v_slicelength - 1);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":963
 *             if slicelength > 0:
 *                 slicelength = slicelength - 1
 *                 for i from 1 <= i < step:             # <<<<<<<<<<<<<<
 *                     c_node = next_element(c_node)
 *             break
 */
        for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_step; __pyx_v_i++) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":964
 *                 slicelength = slicelength - 1
 *                 for i from 1 <= i < step:
 *                     c_node = next_element(c_node)             # <<<<<<<<<<<<<<
 *             break
 * 
 */
          __pyx_v_c_node = __pyx_v_next_element(__pyx_v_c_node);
        }
        goto __pyx_L22;
      }
      __pyx_L22:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":965
 *                 for i from 1 <= i < step:
 *                     c_node = next_element(c_node)
 *             break             # <<<<<<<<<<<<<<
 * 
 *     if left_to_right:
 */
      goto __pyx_L21;
    }
    __pyx_L21:;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L18;
  }
  __pyx_L18:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":967
 *             break
 * 
 *     if left_to_right:             # <<<<<<<<<<<<<<
 *         # adjust step size after removing slice as we are not stepping
 *         # over the newly inserted elements
 */
  __pyx_1 = __pyx_v_left_to_right;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":970
 *         # adjust step size after removing slice as we are not stepping
 *         # over the newly inserted elements
 *         step = step - 1             # <<<<<<<<<<<<<<
 * 
 *     # now insert elements where we removed them
 */
    __pyx_v_step = (__pyx_v_step - 1);
    goto __pyx_L25;
  }
  __pyx_L25:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":973
 * 
 *     # now insert elements where we removed them
 *     if c_node is not NULL:             # <<<<<<<<<<<<<<
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":974
 *     # now insert elements where we removed them
 *     if c_node is not NULL:
 *         for element in elements:             # <<<<<<<<<<<<<<
 *             assert element is not None, u"Node must not be None"
 *             # move element and tail over
 */
    if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
      __pyx_4 = 0; __pyx_2 = __pyx_v_elements; Py_INCREF(__pyx_2);
    } else {
      __pyx_4 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_2))) {
        if (__pyx_4 >= PyList_GET_SIZE(__pyx_2)) break;
        __pyx_5 = PyList_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else if (likely(PyTuple_CheckExact(__pyx_2))) {
        if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_2)) break;
        __pyx_5 = PyTuple_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else {
        __pyx_5 = PyIter_Next(__pyx_2);
        if (!__pyx_5) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_5);
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":975
 *     if c_node is not NULL:
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"             # <<<<<<<<<<<<<<
 *             # move element and tail over
 *             c_source_doc = element._c_node.doc
 */
      #ifndef PYREX_WITHOUT_ASSERTIONS
      __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
      if (unlikely(!__pyx_1)) {
        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_323));
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":977
 *             assert element is not None, u"Node must not be None"
 *             # move element and tail over
 *             c_source_doc = element._c_node.doc             # <<<<<<<<<<<<<<
 *             c_next = element._c_node.next
 *             tree.xmlAddPrevSibling(c_node, element._c_node)
 */
      __pyx_v_c_source_doc = __pyx_v_element->_c_node->doc;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":978
 *             # move element and tail over
 *             c_source_doc = element._c_node.doc
 *             c_next = element._c_node.next             # <<<<<<<<<<<<<<
 *             tree.xmlAddPrevSibling(c_node, element._c_node)
 *             _moveTail(c_next, element._c_node)
 */
      __pyx_v_c_next = __pyx_v_element->_c_node->next;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":979
 *             c_source_doc = element._c_node.doc
 *             c_next = element._c_node.next
 *             tree.xmlAddPrevSibling(c_node, element._c_node)             # <<<<<<<<<<<<<<
 *             _moveTail(c_next, element._c_node)
 * 
 */
      xmlAddPrevSibling(__pyx_v_c_node, __pyx_v_element->_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":980
 *             c_next = element._c_node.next
 *             tree.xmlAddPrevSibling(c_node, element._c_node)
 *             _moveTail(c_next, element._c_node)             # <<<<<<<<<<<<<<
 * 
 *             # integrate element into new document
 */
      __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_element->_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":983
 * 
 *             # integrate element into new document
 *             moveNodeToDocument(parent._doc, c_source_doc, element._c_node)             # <<<<<<<<<<<<<<
 * 
 *             # stop at the end of the slice
 */
      __pyx_6 = __pyx_f_4lxml_5etree_moveNodeToDocument(__pyx_v_parent->_doc, __pyx_v_c_source_doc, __pyx_v_element->_c_node); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":986
 * 
 *             # stop at the end of the slice
 *             if slicelength > 0:             # <<<<<<<<<<<<<<
 *                 slicelength = slicelength - 1
 *                 for i from 0 <= i < step:
 */
      __pyx_1 = (__pyx_v_slicelength > 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":987
 *             # stop at the end of the slice
 *             if slicelength > 0:
 *                 slicelength = slicelength - 1             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)
 */
        __pyx_v_slicelength = (__pyx_v_slicelength - 1);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":988
 *             if slicelength > 0:
 *                 slicelength = slicelength - 1
 *                 for i from 0 <= i < step:             # <<<<<<<<<<<<<<
 *                     c_node = next_element(c_node)
 *                 if c_node is NULL:
 */
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_step; __pyx_v_i++) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":989
 *                 slicelength = slicelength - 1
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)             # <<<<<<<<<<<<<<
 *                 if c_node is NULL:
 *                     break
 */
          __pyx_v_c_node = __pyx_v_next_element(__pyx_v_c_node);
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":990
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)
 *                 if c_node is NULL:             # <<<<<<<<<<<<<<
 *                     break
 *         else:
 */
        __pyx_1 = (__pyx_v_c_node == NULL);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":991
 *                     c_node = next_element(c_node)
 *                 if c_node is NULL:
 *                     break             # <<<<<<<<<<<<<<
 *         else:
 *             # everything inserted
 */
          goto __pyx_L28;
          goto __pyx_L32;
        }
        __pyx_L32:;
        goto __pyx_L29;
      }
      __pyx_L29:;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":994
 *         else:
 *             # everything inserted
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *     # append the remaining elements at the respective end
 */
      __pyx_r = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L0;
    }
    __pyx_L28:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L26;
  }
  __pyx_L26:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":997
 * 
 *     # append the remaining elements at the respective end
 *     if left_to_right:             # <<<<<<<<<<<<<<
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"
 */
  __pyx_1 = __pyx_v_left_to_right;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":998
 *     # append the remaining elements at the respective end
 *     if left_to_right:
 *         for element in elements:             # <<<<<<<<<<<<<<
 *             assert element is not None, u"Node must not be None"
 *             _appendChild(parent, element)
 */
    if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
      __pyx_4 = 0; __pyx_3 = __pyx_v_elements; Py_INCREF(__pyx_3);
    } else {
      __pyx_4 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_3))) {
        if (__pyx_4 >= PyList_GET_SIZE(__pyx_3)) break;
        __pyx_5 = PyList_GET_ITEM(__pyx_3, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else if (likely(PyTuple_CheckExact(__pyx_3))) {
        if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_3)) break;
        __pyx_5 = PyTuple_GET_ITEM(__pyx_3, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else {
        __pyx_5 = PyIter_Next(__pyx_3);
        if (!__pyx_5) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_5);
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":999
 *     if left_to_right:
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"             # <<<<<<<<<<<<<<
 *             _appendChild(parent, element)
 *     else:
 */
      #ifndef PYREX_WITHOUT_ASSERTIONS
      __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
      if (unlikely(!__pyx_1)) {
        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_324));
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1000
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"
 *             _appendChild(parent, element)             # <<<<<<<<<<<<<<
 *     else:
 *         for element in elements:
 */
      __pyx_6 = __pyx_f_4lxml_5etree__appendChild(__pyx_v_parent, __pyx_v_element); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L33;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1002
 *             _appendChild(parent, element)
 *     else:
 *         for element in elements:             # <<<<<<<<<<<<<<
 *             assert element is not None, u"Node must not be None"
 *             _prependChild(parent, element)
 */
    if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
      __pyx_4 = 0; __pyx_2 = __pyx_v_elements; Py_INCREF(__pyx_2);
    } else {
      __pyx_4 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_2))) {
        if (__pyx_4 >= PyList_GET_SIZE(__pyx_2)) break;
        __pyx_5 = PyList_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else if (likely(PyTuple_CheckExact(__pyx_2))) {
        if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_2)) break;
        __pyx_5 = PyTuple_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_5); __pyx_4++;
      } else {
        __pyx_5 = PyIter_Next(__pyx_2);
        if (!__pyx_5) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_5);
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1003
 *     else:
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"             # <<<<<<<<<<<<<<
 *             _prependChild(parent, element)
 * 
 */
      #ifndef PYREX_WITHOUT_ASSERTIONS
      __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
      if (unlikely(!__pyx_1)) {
        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_325));
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1004
 *         for element in elements:
 *             assert element is not None, u"Node must not be None"
 *             _prependChild(parent, element)             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
      __pyx_6 = __pyx_f_4lxml_5etree__prependChild(__pyx_v_parent, __pyx_v_element); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L33:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1006
 *             _prependChild(parent, element)
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _appendChild(_Element parent, _Element child) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._replaceSlice");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  Py_DECREF(__pyx_v_elements);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1008
 *     return 0
 * 
 * cdef int _appendChild(_Element parent, _Element child) except -1:             # <<<<<<<<<<<<<<
 *     u"""Append a new child to a parent element.
 *     """
 */

static  int __pyx_f_4lxml_5etree__appendChild(struct LxmlElement *__pyx_v_parent, struct LxmlElement *__pyx_v_child) {
  xmlNode *__pyx_v_c_next;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_source_doc;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1014
 *     cdef xmlNode* c_node
 *     cdef xmlDoc* c_source_doc
 *     c_node = child._c_node             # <<<<<<<<<<<<<<
 *     c_source_doc = c_node.doc
 *     # store possible text node
 */
  __pyx_v_c_node = __pyx_v_child->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1015
 *     cdef xmlDoc* c_source_doc
 *     c_node = child._c_node
 *     c_source_doc = c_node.doc             # <<<<<<<<<<<<<<
 *     # store possible text node
 *     c_next = c_node.next
 */
  __pyx_v_c_source_doc = __pyx_v_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1017
 *     c_source_doc = c_node.doc
 *     # store possible text node
 *     c_next = c_node.next             # <<<<<<<<<<<<<<
 *     # move node itself
 *     tree.xmlUnlinkNode(c_node)
 */
  __pyx_v_c_next = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1019
 *     c_next = c_node.next
 *     # move node itself
 *     tree.xmlUnlinkNode(c_node)             # <<<<<<<<<<<<<<
 *     tree.xmlAddChild(parent._c_node, c_node)
 *     _moveTail(c_next, c_node)
 */
  xmlUnlinkNode(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1020
 *     # move node itself
 *     tree.xmlUnlinkNode(c_node)
 *     tree.xmlAddChild(parent._c_node, c_node)             # <<<<<<<<<<<<<<
 *     _moveTail(c_next, c_node)
 *     # uh oh, elements may be pointing to different doc when
 */
  xmlAddChild(__pyx_v_parent->_c_node, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1021
 *     tree.xmlUnlinkNode(c_node)
 *     tree.xmlAddChild(parent._c_node, c_node)
 *     _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1024
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 *     moveNodeToDocument(parent._doc, c_source_doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef int _prependChild(_Element parent, _Element child) except -1:
 */
  __pyx_1 = __pyx_f_4lxml_5etree_moveNodeToDocument(__pyx_v_parent->_doc, __pyx_v_c_source_doc, __pyx_v_c_node); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._appendChild");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1026
 *     moveNodeToDocument(parent._doc, c_source_doc, c_node)
 * 
 * cdef int _prependChild(_Element parent, _Element child) except -1:             # <<<<<<<<<<<<<<
 *     u"""Prepend a new child to a parent element.
 *     """
 */

static  int __pyx_f_4lxml_5etree__prependChild(struct LxmlElement *__pyx_v_parent, struct LxmlElement *__pyx_v_child) {
  xmlNode *__pyx_v_c_next;
  xmlNode *__pyx_v_c_child;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_source_doc;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1033
 *     cdef xmlNode* c_node
 *     cdef xmlDoc* c_source_doc
 *     c_node = child._c_node             # <<<<<<<<<<<<<<
 *     c_source_doc = c_node.doc
 *     # store possible text node
 */
  __pyx_v_c_node = __pyx_v_child->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1034
 *     cdef xmlDoc* c_source_doc
 *     c_node = child._c_node
 *     c_source_doc = c_node.doc             # <<<<<<<<<<<<<<
 *     # store possible text node
 *     c_next = c_node.next
 */
  __pyx_v_c_source_doc = __pyx_v_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1036
 *     c_source_doc = c_node.doc
 *     # store possible text node
 *     c_next = c_node.next             # <<<<<<<<<<<<<<
 *     # move node itself
 *     c_child = _findChildForwards(parent._c_node, 0)
 */
  __pyx_v_c_next = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1038
 *     c_next = c_node.next
 *     # move node itself
 *     c_child = _findChildForwards(parent._c_node, 0)             # <<<<<<<<<<<<<<
 *     if c_child is NULL:
 *         tree.xmlUnlinkNode(c_node)
 */
  __pyx_v_c_child = __pyx_f_4lxml_5etree__findChildForwards(__pyx_v_parent->_c_node, 0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1039
 *     # move node itself
 *     c_child = _findChildForwards(parent._c_node, 0)
 *     if c_child is NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlUnlinkNode(c_node)
 *         tree.xmlAddChild(parent._c_node, c_node)
 */
  __pyx_1 = (__pyx_v_c_child == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1040
 *     c_child = _findChildForwards(parent._c_node, 0)
 *     if c_child is NULL:
 *         tree.xmlUnlinkNode(c_node)             # <<<<<<<<<<<<<<
 *         tree.xmlAddChild(parent._c_node, c_node)
 *     else:
 */
    xmlUnlinkNode(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1041
 *     if c_child is NULL:
 *         tree.xmlUnlinkNode(c_node)
 *         tree.xmlAddChild(parent._c_node, c_node)             # <<<<<<<<<<<<<<
 *     else:
 *         tree.xmlAddPrevSibling(c_child, c_node)
 */
    xmlAddChild(__pyx_v_parent->_c_node, __pyx_v_c_node);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1043
 *         tree.xmlAddChild(parent._c_node, c_node)
 *     else:
 *         tree.xmlAddPrevSibling(c_child, c_node)             # <<<<<<<<<<<<<<
 *     _moveTail(c_next, c_node)
 *     # uh oh, elements may be pointing to different doc when
 */
    xmlAddPrevSibling(__pyx_v_c_child, __pyx_v_c_node);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1044
 *     else:
 *         tree.xmlAddPrevSibling(c_child, c_node)
 *     _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1047
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 *     moveNodeToDocument(parent._doc, c_source_doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef int _appendSibling(_Element element, _Element sibling) except -1:
 */
  __pyx_2 = __pyx_f_4lxml_5etree_moveNodeToDocument(__pyx_v_parent->_doc, __pyx_v_c_source_doc, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._prependChild");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1049
 *     moveNodeToDocument(parent._doc, c_source_doc, c_node)
 * 
 * cdef int _appendSibling(_Element element, _Element sibling) except -1:             # <<<<<<<<<<<<<<
 *     u"""Append a new child to a parent element.
 *     """
 */

static  int __pyx_f_4lxml_5etree__appendSibling(struct LxmlElement *__pyx_v_element, struct LxmlElement *__pyx_v_sibling) {
  xmlNode *__pyx_v_c_next;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_source_doc;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1055
 *     cdef xmlNode* c_node
 *     cdef xmlDoc* c_source_doc
 *     c_node = sibling._c_node             # <<<<<<<<<<<<<<
 *     c_source_doc = c_node.doc
 *     # store possible text node
 */
  __pyx_v_c_node = __pyx_v_sibling->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1056
 *     cdef xmlDoc* c_source_doc
 *     c_node = sibling._c_node
 *     c_source_doc = c_node.doc             # <<<<<<<<<<<<<<
 *     # store possible text node
 *     c_next = c_node.next
 */
  __pyx_v_c_source_doc = __pyx_v_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1058
 *     c_source_doc = c_node.doc
 *     # store possible text node
 *     c_next = c_node.next             # <<<<<<<<<<<<<<
 *     # move node itself
 *     tree.xmlAddNextSibling(element._c_node, c_node)
 */
  __pyx_v_c_next = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1060
 *     c_next = c_node.next
 *     # move node itself
 *     tree.xmlAddNextSibling(element._c_node, c_node)             # <<<<<<<<<<<<<<
 *     _moveTail(c_next, c_node)
 *     # uh oh, elements may be pointing to different doc when
 */
  xmlAddNextSibling(__pyx_v_element->_c_node, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1061
 *     # move node itself
 *     tree.xmlAddNextSibling(element._c_node, c_node)
 *     _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1064
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 *     moveNodeToDocument(element._doc, c_source_doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef int _prependSibling(_Element element, _Element sibling) except -1:
 */
  __pyx_1 = __pyx_f_4lxml_5etree_moveNodeToDocument(__pyx_v_element->_doc, __pyx_v_c_source_doc, __pyx_v_c_node); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._appendSibling");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1066
 *     moveNodeToDocument(element._doc, c_source_doc, c_node)
 * 
 * cdef int _prependSibling(_Element element, _Element sibling) except -1:             # <<<<<<<<<<<<<<
 *     u"""Append a new child to a parent element.
 *     """
 */

static  int __pyx_f_4lxml_5etree__prependSibling(struct LxmlElement *__pyx_v_element, struct LxmlElement *__pyx_v_sibling) {
  xmlNode *__pyx_v_c_next;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_c_source_doc;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1072
 *     cdef xmlNode* c_node
 *     cdef xmlDoc* c_source_doc
 *     c_node = sibling._c_node             # <<<<<<<<<<<<<<
 *     c_source_doc = c_node.doc
 *     # store possible text node
 */
  __pyx_v_c_node = __pyx_v_sibling->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1073
 *     cdef xmlDoc* c_source_doc
 *     c_node = sibling._c_node
 *     c_source_doc = c_node.doc             # <<<<<<<<<<<<<<
 *     # store possible text node
 *     c_next = c_node.next
 */
  __pyx_v_c_source_doc = __pyx_v_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1075
 *     c_source_doc = c_node.doc
 *     # store possible text node
 *     c_next = c_node.next             # <<<<<<<<<<<<<<
 *     # move node itself
 *     tree.xmlAddPrevSibling(element._c_node, c_node)
 */
  __pyx_v_c_next = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1077
 *     c_next = c_node.next
 *     # move node itself
 *     tree.xmlAddPrevSibling(element._c_node, c_node)             # <<<<<<<<<<<<<<
 *     _moveTail(c_next, c_node)
 *     # uh oh, elements may be pointing to different doc when
 */
  xmlAddPrevSibling(__pyx_v_element->_c_node, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1078
 *     # move node itself
 *     tree.xmlAddPrevSibling(element._c_node, c_node)
 *     _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1081
 *     # uh oh, elements may be pointing to different doc when
 *     # parent element has moved; change them too..
 *     moveNodeToDocument(element._doc, c_source_doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int isutf8(char* s):
 */
  __pyx_1 = __pyx_f_4lxml_5etree_moveNodeToDocument(__pyx_v_element->_doc, __pyx_v_c_source_doc, __pyx_v_c_node); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._prependSibling");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1083
 *     moveNodeToDocument(element._doc, c_source_doc, c_node)
 * 
 * cdef inline int isutf8(char* s):             # <<<<<<<<<<<<<<
 *     cdef char c
 *     c = s[0]
 */

static INLINE int __pyx_f_4lxml_5etree_isutf8(char *__pyx_v_s) {
  char __pyx_v_c;
  int __pyx_r;
  int __pyx_1;
  long __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1085
 * cdef inline int isutf8(char* s):
 *     cdef char c
 *     c = s[0]             # <<<<<<<<<<<<<<
 *     while c != c'\0':
 *         if c & 0x80:
 */
  __pyx_v_c = (__pyx_v_s[0]);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1086
 *     cdef char c
 *     c = s[0]
 *     while c != c'\0':             # <<<<<<<<<<<<<<
 *         if c & 0x80:
 *             return 1
 */
  while (1) {
    __pyx_1 = (__pyx_v_c != '\x00');
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1087
 *     c = s[0]
 *     while c != c'\0':
 *         if c & 0x80:             # <<<<<<<<<<<<<<
 *             return 1
 *         s = s + 1
 */
    __pyx_2 = (__pyx_v_c & 0x80);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1088
 *     while c != c'\0':
 *         if c & 0x80:
 *             return 1             # <<<<<<<<<<<<<<
 *         s = s + 1
 *         c = s[0]
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1089
 *         if c & 0x80:
 *             return 1
 *         s = s + 1             # <<<<<<<<<<<<<<
 *         c = s[0]
 *     return 0
 */
    __pyx_v_s = (__pyx_v_s + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1090
 *             return 1
 *         s = s + 1
 *         c = s[0]             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_v_c = (__pyx_v_s[0]);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1091
 *         s = s + 1
 *         c = s[0]
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int isutf8py(pystring):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1093
 *     return 0
 * 
 * cdef int isutf8py(pystring):             # <<<<<<<<<<<<<<
 *     cdef char* s
 *     cdef char* c_end
 */

static  int __pyx_f_4lxml_5etree_isutf8py(PyObject *__pyx_v_pystring) {
  char *__pyx_v_s;
  char *__pyx_v_c_end;
  char __pyx_v_c;
  int __pyx_v_is_non_ascii;
  int __pyx_r;
  int __pyx_1;
  long __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1098
 *     cdef char c
 *     cdef bint is_non_ascii
 *     s = _cstr(pystring)             # <<<<<<<<<<<<<<
 *     c_end = s + python.PyString_GET_SIZE(pystring)
 *     is_non_ascii = 0
 */
  __pyx_v_s = PyString_AS_STRING(__pyx_v_pystring);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1099
 *     cdef bint is_non_ascii
 *     s = _cstr(pystring)
 *     c_end = s + python.PyString_GET_SIZE(pystring)             # <<<<<<<<<<<<<<
 *     is_non_ascii = 0
 *     while s < c_end:
 */
  __pyx_v_c_end = (__pyx_v_s + PyString_GET_SIZE(__pyx_v_pystring));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1100
 *     s = _cstr(pystring)
 *     c_end = s + python.PyString_GET_SIZE(pystring)
 *     is_non_ascii = 0             # <<<<<<<<<<<<<<
 *     while s < c_end:
 *         c = s[0]
 */
  __pyx_v_is_non_ascii = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1101
 *     c_end = s + python.PyString_GET_SIZE(pystring)
 *     is_non_ascii = 0
 *     while s < c_end:             # <<<<<<<<<<<<<<
 *         c = s[0]
 *         if c & 0x80:
 */
  while (1) {
    __pyx_1 = (__pyx_v_s < __pyx_v_c_end);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1102
 *     is_non_ascii = 0
 *     while s < c_end:
 *         c = s[0]             # <<<<<<<<<<<<<<
 *         if c & 0x80:
 *             is_non_ascii = 1
 */
    __pyx_v_c = (__pyx_v_s[0]);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1103
 *     while s < c_end:
 *         c = s[0]
 *         if c & 0x80:             # <<<<<<<<<<<<<<
 *             is_non_ascii = 1
 *         elif c == c'\0':
 */
    __pyx_2 = (__pyx_v_c & 0x80);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1104
 *         c = s[0]
 *         if c & 0x80:
 *             is_non_ascii = 1             # <<<<<<<<<<<<<<
 *         elif c == c'\0':
 *             return -1 # invalid!
 */
      __pyx_v_is_non_ascii = 1;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1105
 *         if c & 0x80:
 *             is_non_ascii = 1
 *         elif c == c'\0':             # <<<<<<<<<<<<<<
 *             return -1 # invalid!
 *         elif is_non_ascii == 0 and not tree.xmlIsChar_ch(c):
 */
    __pyx_1 = (__pyx_v_c == '\x00');
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1106
 *             is_non_ascii = 1
 *         elif c == c'\0':
 *             return -1 # invalid!             # <<<<<<<<<<<<<<
 *         elif is_non_ascii == 0 and not tree.xmlIsChar_ch(c):
 *             return -1 # invalid!
 */
      __pyx_r = -1;
      goto __pyx_L0;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1107
 *         elif c == c'\0':
 *             return -1 # invalid!
 *         elif is_non_ascii == 0 and not tree.xmlIsChar_ch(c):             # <<<<<<<<<<<<<<
 *             return -1 # invalid!
 *         s += 1
 */
    __pyx_1 = (__pyx_v_is_non_ascii == 0);
    if (__pyx_1) {
      __pyx_1 = (!xmlIsChar_ch(__pyx_v_c));
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1108
 *             return -1 # invalid!
 *         elif is_non_ascii == 0 and not tree.xmlIsChar_ch(c):
 *             return -1 # invalid!             # <<<<<<<<<<<<<<
 *         s += 1
 *     return is_non_ascii
 */
      __pyx_r = -1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1109
 *         elif is_non_ascii == 0 and not tree.xmlIsChar_ch(c):
 *             return -1 # invalid!
 *         s += 1             # <<<<<<<<<<<<<<
 *     return is_non_ascii
 * 
 */
    __pyx_v_s += 1;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1110
 *             return -1 # invalid!
 *         s += 1
 *     return is_non_ascii             # <<<<<<<<<<<<<<
 * 
 * cdef object funicode(char* s):
 */
  __pyx_r = __pyx_v_is_non_ascii;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1112
 *     return is_non_ascii
 * 
 * cdef object funicode(char* s):             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t slen
 *     cdef char* spos
 */

static  PyObject *__pyx_f_4lxml_5etree_funicode(char *__pyx_v_s) {
  Py_ssize_t __pyx_v_slen;
  char *__pyx_v_spos;
  int __pyx_v_is_non_ascii;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  long __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1116
 *     cdef char* spos
 *     cdef bint is_non_ascii
 *     if python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *         slen = cstd.strlen(s)
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 */
  __pyx_1 = IS_PYTHON3;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1117
 *     cdef bint is_non_ascii
 *     if python.IS_PYTHON3:
 *         slen = cstd.strlen(s)             # <<<<<<<<<<<<<<
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 *     spos = s
 */
    __pyx_v_slen = strlen(__pyx_v_s);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1118
 *     if python.IS_PYTHON3:
 *         slen = cstd.strlen(s)
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)             # <<<<<<<<<<<<<<
 *     spos = s
 *     is_non_ascii = 0
 */
    __pyx_2 = PyUnicode_DecodeUTF8(__pyx_v_s, __pyx_v_slen, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1119
 *         slen = cstd.strlen(s)
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 *     spos = s             # <<<<<<<<<<<<<<
 *     is_non_ascii = 0
 *     while spos[0] != c'\0':
 */
  __pyx_v_spos = __pyx_v_s;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1120
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 *     spos = s
 *     is_non_ascii = 0             # <<<<<<<<<<<<<<
 *     while spos[0] != c'\0':
 *         if spos[0] & 0x80:
 */
  __pyx_v_is_non_ascii = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1121
 *     spos = s
 *     is_non_ascii = 0
 *     while spos[0] != c'\0':             # <<<<<<<<<<<<<<
 *         if spos[0] & 0x80:
 *             is_non_ascii = 1
 */
  while (1) {
    __pyx_1 = ((__pyx_v_spos[0]) != '\x00');
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1122
 *     is_non_ascii = 0
 *     while spos[0] != c'\0':
 *         if spos[0] & 0x80:             # <<<<<<<<<<<<<<
 *             is_non_ascii = 1
 *             break
 */
    __pyx_3 = ((__pyx_v_spos[0]) & 0x80);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1123
 *     while spos[0] != c'\0':
 *         if spos[0] & 0x80:
 *             is_non_ascii = 1             # <<<<<<<<<<<<<<
 *             break
 *         spos += 1
 */
      __pyx_v_is_non_ascii = 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1124
 *         if spos[0] & 0x80:
 *             is_non_ascii = 1
 *             break             # <<<<<<<<<<<<<<
 *         spos += 1
 *     while spos[0] != c'\0':
 */
      goto __pyx_L5;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1125
 *             is_non_ascii = 1
 *             break
 *         spos += 1             # <<<<<<<<<<<<<<
 *     while spos[0] != c'\0':
 *         spos += 1
 */
    __pyx_v_spos += 1;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1126
 *             break
 *         spos += 1
 *     while spos[0] != c'\0':             # <<<<<<<<<<<<<<
 *         spos += 1
 *     slen = spos - s
 */
  while (1) {
    __pyx_1 = ((__pyx_v_spos[0]) != '\x00');
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1127
 *         spos += 1
 *     while spos[0] != c'\0':
 *         spos += 1             # <<<<<<<<<<<<<<
 *     slen = spos - s
 *     if is_non_ascii:
 */
    __pyx_v_spos += 1;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1128
 *     while spos[0] != c'\0':
 *         spos += 1
 *     slen = spos - s             # <<<<<<<<<<<<<<
 *     if is_non_ascii:
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 */
  __pyx_v_slen = (__pyx_v_spos - __pyx_v_s);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1129
 *         spos += 1
 *     slen = spos - s
 *     if is_non_ascii:             # <<<<<<<<<<<<<<
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 *     return python.PyString_FromStringAndSize(s, slen)
 */
  __pyx_1 = __pyx_v_is_non_ascii;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1130
 *     slen = spos - s
 *     if is_non_ascii:
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)             # <<<<<<<<<<<<<<
 *     return python.PyString_FromStringAndSize(s, slen)
 * 
 */
    __pyx_2 = PyUnicode_DecodeUTF8(__pyx_v_s, __pyx_v_slen, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1131
 *     if is_non_ascii:
 *         return python.PyUnicode_DecodeUTF8(s, slen, NULL)
 *     return python.PyString_FromStringAndSize(s, slen)             # <<<<<<<<<<<<<<
 * 
 * cdef object _utf8(object s):
 */
  __pyx_2 = PyString_FromStringAndSize(__pyx_v_s, __pyx_v_slen); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.funicode");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1133
 *     return python.PyString_FromStringAndSize(s, slen)
 * 
 * cdef object _utf8(object s):             # <<<<<<<<<<<<<<
 *     if python.PyString_Check(s):
 *         if isutf8py(s):
 */

static  PyObject *__pyx_f_4lxml_5etree__utf8(PyObject *__pyx_v_s) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF(__pyx_v_s);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1134
 * 
 * cdef object _utf8(object s):
 *     if python.PyString_Check(s):             # <<<<<<<<<<<<<<
 *         if isutf8py(s):
 *             raise ValueError, \
 */
  __pyx_1 = PyString_Check(__pyx_v_s);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1135
 * cdef object _utf8(object s):
 *     if python.PyString_Check(s):
 *         if isutf8py(s):             # <<<<<<<<<<<<<<
 *             raise ValueError, \
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"
 */
    __pyx_1 = __pyx_f_4lxml_5etree_isutf8py(__pyx_v_s);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1137
 *         if isutf8py(s):
 *             raise ValueError, \
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"             # <<<<<<<<<<<<<<
 *     elif python.PyUnicode_Check(s):
 *         s = python.PyUnicode_AsUTF8String(s)
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_326), 0);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1138
 *             raise ValueError, \
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"
 *     elif python.PyUnicode_Check(s):             # <<<<<<<<<<<<<<
 *         s = python.PyUnicode_AsUTF8String(s)
 *         if isutf8py(s) == -1:
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_s);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1139
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"
 *     elif python.PyUnicode_Check(s):
 *         s = python.PyUnicode_AsUTF8String(s)             # <<<<<<<<<<<<<<
 *         if isutf8py(s) == -1:
 *             raise ValueError, \
 */
    __pyx_2 = PyUnicode_AsUTF8String(__pyx_v_s); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1140
 *     elif python.PyUnicode_Check(s):
 *         s = python.PyUnicode_AsUTF8String(s)
 *         if isutf8py(s) == -1:             # <<<<<<<<<<<<<<
 *             raise ValueError, \
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"
 */
    __pyx_3 = (__pyx_f_4lxml_5etree_isutf8py(__pyx_v_s) == -1);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1142
 *         if isutf8py(s) == -1:
 *             raise ValueError, \
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_327), 0);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1144
 *                 u"All strings must be XML compatible: Unicode or ASCII, no NULL bytes"
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."             # <<<<<<<<<<<<<<
 *     return s
 * 
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_328), 0);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1145
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."
 *     return s             # <<<<<<<<<<<<<<
 * 
 * cdef bint _isFilePath(char* c_path):
 */
  Py_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._utf8");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1147
 *     return s
 * 
 * cdef bint _isFilePath(char* c_path):             # <<<<<<<<<<<<<<
 *     u"simple heuristic to see if a path is a filename"
 *     # test if it looks like an absolute Unix path or a Windows network path
 */

static  int __pyx_f_4lxml_5etree__isFilePath(char *__pyx_v_c_path) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1150
 *     u"simple heuristic to see if a path is a filename"
 *     # test if it looks like an absolute Unix path or a Windows network path
 *     if c_path[0] == c'/':             # <<<<<<<<<<<<<<
 *         return 1
 *     # test if it looks like an absolute Windows path
 */
  __pyx_1 = ((__pyx_v_c_path[0]) == '/');
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1151
 *     # test if it looks like an absolute Unix path or a Windows network path
 *     if c_path[0] == c'/':
 *         return 1             # <<<<<<<<<<<<<<
 *     # test if it looks like an absolute Windows path
 *     if (c_path[0] >= c'a' and c_path[0] <= c'z') or \
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1153
 *         return 1
 *     # test if it looks like an absolute Windows path
 *     if (c_path[0] >= c'a' and c_path[0] <= c'z') or \             # <<<<<<<<<<<<<<
 *             (c_path[0] >= c'A' and c_path[0] <= c'Z'):
 *         if c_path[1] == c':':
 */
  __pyx_1 = ((__pyx_v_c_path[0]) >= 'a');
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_c_path[0]) <= 'z');
  }
  if (!__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1154
 *     # test if it looks like an absolute Windows path
 *     if (c_path[0] >= c'a' and c_path[0] <= c'z') or \
 *             (c_path[0] >= c'A' and c_path[0] <= c'Z'):             # <<<<<<<<<<<<<<
 *         if c_path[1] == c':':
 *             return 1
 */
    __pyx_1 = ((__pyx_v_c_path[0]) >= 'A');
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_c_path[0]) <= 'Z');
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1155
 *     if (c_path[0] >= c'a' and c_path[0] <= c'z') or \
 *             (c_path[0] >= c'A' and c_path[0] <= c'Z'):
 *         if c_path[1] == c':':             # <<<<<<<<<<<<<<
 *             return 1
 *     # test if it looks like a relative path
 */
    __pyx_1 = ((__pyx_v_c_path[1]) == ':');
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1156
 *             (c_path[0] >= c'A' and c_path[0] <= c'Z'):
 *         if c_path[1] == c':':
 *             return 1             # <<<<<<<<<<<<<<
 *     # test if it looks like a relative path
 *     while c_path[0] != c'\0':
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1158
 *             return 1
 *     # test if it looks like a relative path
 *     while c_path[0] != c'\0':             # <<<<<<<<<<<<<<
 *         if c_path[0] == c':':
 *             return 0
 */
  while (1) {
    __pyx_1 = ((__pyx_v_c_path[0]) != '\x00');
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1159
 *     # test if it looks like a relative path
 *     while c_path[0] != c'\0':
 *         if c_path[0] == c':':             # <<<<<<<<<<<<<<
 *             return 0
 *         if c_path[0] == c'/':
 */
    __pyx_1 = ((__pyx_v_c_path[0]) == ':');
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1160
 *     while c_path[0] != c'\0':
 *         if c_path[0] == c':':
 *             return 0             # <<<<<<<<<<<<<<
 *         if c_path[0] == c'/':
 *             return 1
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1161
 *         if c_path[0] == c':':
 *             return 0
 *         if c_path[0] == c'/':             # <<<<<<<<<<<<<<
 *             return 1
 *         if c_path[0] == c'\\':
 */
    __pyx_1 = ((__pyx_v_c_path[0]) == '/');
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1162
 *             return 0
 *         if c_path[0] == c'/':
 *             return 1             # <<<<<<<<<<<<<<
 *         if c_path[0] == c'\\':
 *             return 1
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1163
 *         if c_path[0] == c'/':
 *             return 1
 *         if c_path[0] == c'\\':             # <<<<<<<<<<<<<<
 *             return 1
 *         c_path += 1
 */
    __pyx_1 = ((__pyx_v_c_path[0]) == '\\');
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1164
 *             return 1
 *         if c_path[0] == c'\\':
 *             return 1             # <<<<<<<<<<<<<<
 *         c_path += 1
 *     return 1
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1165
 *         if c_path[0] == c'\\':
 *             return 1
 *         c_path += 1             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
    __pyx_v_c_path += 1;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1166
 *             return 1
 *         c_path += 1
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef object _encodeFilename(object filename):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1168
 *     return 1
 * 
 * cdef object _encodeFilename(object filename):             # <<<<<<<<<<<<<<
 *     u"""Make sure a filename is 8-bit encoded (or None).
 *     """
 */

static  PyObject *__pyx_f_4lxml_5etree__encodeFilename(PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_filename8;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  char *__pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  __pyx_v_filename8 = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1171
 *     u"""Make sure a filename is 8-bit encoded (or None).
 *     """
 *     if filename is None:             # <<<<<<<<<<<<<<
 *         return None
 *     elif python.PyString_Check(filename):
 */
  __pyx_1 = (__pyx_v_filename == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1172
 *     """
 *     if filename is None:
 *         return None             # <<<<<<<<<<<<<<
 *     elif python.PyString_Check(filename):
 *         return filename
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1173
 *     if filename is None:
 *         return None
 *     elif python.PyString_Check(filename):             # <<<<<<<<<<<<<<
 *         return filename
 *     elif python.PyUnicode_Check(filename):
 */
  __pyx_2 = PyString_Check(__pyx_v_filename);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1174
 *         return None
 *     elif python.PyString_Check(filename):
 *         return filename             # <<<<<<<<<<<<<<
 *     elif python.PyUnicode_Check(filename):
 *         filename8 = python.PyUnicode_AsEncodedString(
 */
    Py_INCREF(__pyx_v_filename);
    __pyx_r = __pyx_v_filename;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1175
 *     elif python.PyString_Check(filename):
 *         return filename
 *     elif python.PyUnicode_Check(filename):             # <<<<<<<<<<<<<<
 *         filename8 = python.PyUnicode_AsEncodedString(
 *             filename, 'UTF-8', NULL)
 */
  __pyx_2 = PyUnicode_Check(__pyx_v_filename);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1177
 *     elif python.PyUnicode_Check(filename):
 *         filename8 = python.PyUnicode_AsEncodedString(
 *             filename, 'UTF-8', NULL)             # <<<<<<<<<<<<<<
 *         if _isFilePath(filename8):
 *             try:
 */
    __pyx_3 = PyUnicode_AsEncodedString(__pyx_v_filename, __pyx_k_329, NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_filename8);
    __pyx_v_filename8 = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1178
 *         filename8 = python.PyUnicode_AsEncodedString(
 *             filename, 'UTF-8', NULL)
 *         if _isFilePath(filename8):             # <<<<<<<<<<<<<<
 *             try:
 *                 return python.PyUnicode_AsEncodedString(
 */
    __pyx_4 = __Pyx_PyBytes_AsString(__pyx_v_filename8); if (unlikely((!__pyx_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __pyx_f_4lxml_5etree__isFilePath(__pyx_4);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1179
 *             filename, 'UTF-8', NULL)
 *         if _isFilePath(filename8):
 *             try:             # <<<<<<<<<<<<<<
 *                 return python.PyUnicode_AsEncodedString(
 *                     filename, _C_FILENAME_ENCODING, NULL)
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        /*try:*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1181
 *             try:
 *                 return python.PyUnicode_AsEncodedString(
 *                     filename, _C_FILENAME_ENCODING, NULL)             # <<<<<<<<<<<<<<
 *             except UnicodeEncodeError:
 *                 pass
 */
          __pyx_3 = PyUnicode_AsEncodedString(__pyx_v_filename, __pyx_v_4lxml_5etree__C_FILENAME_ENCODING, NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_r = __pyx_3;
          __pyx_3 = 0;
          goto __pyx_L0;
        }
        Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L9_try;
        __pyx_L5_error:;
        Py_XDECREF(__pyx_3); __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1182
 *                 return python.PyUnicode_AsEncodedString(
 *                     filename, _C_FILENAME_ENCODING, NULL)
 *             except UnicodeEncodeError:             # <<<<<<<<<<<<<<
 *                 pass
 *         return filename8
 */
        __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeEncodeError);
        if (__pyx_2) {
          __Pyx_AddTraceback("lxml.etree._encodeFilename");
          if (__Pyx_GetException(&__pyx_3, &__pyx_5, &__pyx_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          goto __pyx_L6_exception_handled;
        }
        __pyx_L7_except_error:;
        Py_XDECREF(__pyx_save_exc_type);
        Py_XDECREF(__pyx_save_exc_value);
        Py_XDECREF(__pyx_save_exc_tb);
        goto __pyx_L1_error;
        __pyx_L6_exception_handled:;
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L9_try:;
      }
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1184
 *             except UnicodeEncodeError:
 *                 pass
 *         return filename8             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."
 */
    Py_INCREF(__pyx_v_filename8);
    __pyx_r = __pyx_v_filename8;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1186
 *         return filename8
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."             # <<<<<<<<<<<<<<
 * 
 * cdef object _decodeFilename(char* c_path):
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_330), 0);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._encodeFilename");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_filename8);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1188
 *         raise TypeError, u"Argument must be string or unicode."
 * 
 * cdef object _decodeFilename(char* c_path):             # <<<<<<<<<<<<<<
 *     u"""Make the filename a unicode string if we are in Py3.
 *     """
 */

static  PyObject *__pyx_f_4lxml_5etree__decodeFilename(char *__pyx_v_c_path) {
  Py_ssize_t __pyx_v_c_len;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1191
 *     u"""Make the filename a unicode string if we are in Py3.
 *     """
 *     cdef Py_ssize_t c_len = cstd.strlen(c_path)             # <<<<<<<<<<<<<<
 *     if _isFilePath(c_path):
 *         try:
 */
  __pyx_v_c_len = strlen(__pyx_v_c_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1192
 *     """
 *     cdef Py_ssize_t c_len = cstd.strlen(c_path)
 *     if _isFilePath(c_path):             # <<<<<<<<<<<<<<
 *         try:
 *             return python.PyUnicode_Decode(
 */
  __pyx_1 = __pyx_f_4lxml_5etree__isFilePath(__pyx_v_c_path);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1193
 *     cdef Py_ssize_t c_len = cstd.strlen(c_path)
 *     if _isFilePath(c_path):
 *         try:             # <<<<<<<<<<<<<<
 *             return python.PyUnicode_Decode(
 *                 c_path, c_len, _C_FILENAME_ENCODING, NULL)
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1195
 *         try:
 *             return python.PyUnicode_Decode(
 *                 c_path, c_len, _C_FILENAME_ENCODING, NULL)             # <<<<<<<<<<<<<<
 *         except UnicodeDecodeError:
 *             pass
 */
        __pyx_2 = PyUnicode_Decode(__pyx_v_c_path, __pyx_v_c_len, __pyx_v_4lxml_5etree__C_FILENAME_ENCODING, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_r = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L0;
      }
      Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L8_try;
      __pyx_L4_error:;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1196
 *             return python.PyUnicode_Decode(
 *                 c_path, c_len, _C_FILENAME_ENCODING, NULL)
 *         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *             pass
 *     try:
 */
      __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
      if (__pyx_3) {
        __Pyx_AddTraceback("lxml.etree._decodeFilename");
        if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L5_exception_handled;
      }
      __pyx_L6_except_error:;
      Py_XDECREF(__pyx_save_exc_type);
      Py_XDECREF(__pyx_save_exc_value);
      Py_XDECREF(__pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L8_try:;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1198
 *         except UnicodeDecodeError:
 *             pass
 *     try:             # <<<<<<<<<<<<<<
 *         return python.PyUnicode_DecodeUTF8(c_path, c_len, NULL)
 *     except UnicodeDecodeError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1199
 *             pass
 *     try:
 *         return python.PyUnicode_DecodeUTF8(c_path, c_len, NULL)             # <<<<<<<<<<<<<<
 *     except UnicodeDecodeError:
 *         # this is a stupid fallback, but it might still work...
 */
      __pyx_2 = PyUnicode_DecodeUTF8(__pyx_v_c_path, __pyx_v_c_len, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1199; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L13_try;
    __pyx_L9_error:;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1200
 *     try:
 *         return python.PyUnicode_DecodeUTF8(c_path, c_len, NULL)
 *     except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *         # this is a stupid fallback, but it might still work...
 *         return python.PyUnicode_DecodeLatin1(c_path, c_len, 'replace')
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree._decodeFilename");
      if (__Pyx_GetException(&__pyx_4, &__pyx_5, &__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1200; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1202
 *     except UnicodeDecodeError:
 *         # this is a stupid fallback, but it might still work...
 *         return python.PyUnicode_DecodeLatin1(c_path, c_len, 'replace')             # <<<<<<<<<<<<<<
 * 
 * cdef object _encodeFilenameUTF8(object filename):
 */
      __pyx_6 = PyUnicode_DecodeLatin1(__pyx_v_c_path, __pyx_v_c_len, __pyx_k_331); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
      __pyx_r = __pyx_6;
      __pyx_6 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L12_except_return;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L10_exception_handled;
    }
    __pyx_L11_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L12_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L10_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L13_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._decodeFilename");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1204
 *         return python.PyUnicode_DecodeLatin1(c_path, c_len, 'replace')
 * 
 * cdef object _encodeFilenameUTF8(object filename):             # <<<<<<<<<<<<<<
 *     u"""Recode filename as UTF-8. Tries ASCII, local filesystem encoding and
 *     UTF-8 as source encoding.
 */

static  PyObject *__pyx_f_4lxml_5etree__encodeFilenameUTF8(PyObject *__pyx_v_filename) {
  char *__pyx_v_c_filename;
  PyObject *__pyx_v_decode_exc;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  Py_INCREF(__pyx_v_filename);
  __pyx_v_decode_exc = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1209
 *     """
 *     cdef char* c_filename
 *     if filename is None:             # <<<<<<<<<<<<<<
 *         return None
 *     elif python.PyString_Check(filename):
 */
  __pyx_1 = (__pyx_v_filename == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1210
 *     cdef char* c_filename
 *     if filename is None:
 *         return None             # <<<<<<<<<<<<<<
 *     elif python.PyString_Check(filename):
 *         if not isutf8py(filename):
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1211
 *     if filename is None:
 *         return None
 *     elif python.PyString_Check(filename):             # <<<<<<<<<<<<<<
 *         if not isutf8py(filename):
 *             # plain ASCII!
 */
  __pyx_2 = PyString_Check(__pyx_v_filename);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1212
 *         return None
 *     elif python.PyString_Check(filename):
 *         if not isutf8py(filename):             # <<<<<<<<<<<<<<
 *             # plain ASCII!
 *             return filename
 */
    __pyx_1 = (!__pyx_f_4lxml_5etree_isutf8py(__pyx_v_filename));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1214
 *         if not isutf8py(filename):
 *             # plain ASCII!
 *             return filename             # <<<<<<<<<<<<<<
 *         c_filename = _cstr(filename)
 *         try:
 */
      Py_INCREF(__pyx_v_filename);
      __pyx_r = __pyx_v_filename;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1215
 *             # plain ASCII!
 *             return filename
 *         c_filename = _cstr(filename)             # <<<<<<<<<<<<<<
 *         try:
 *             # try to decode with default encoding
 */
    __pyx_v_c_filename = PyString_AS_STRING(__pyx_v_filename);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1216
 *             return filename
 *         c_filename = _cstr(filename)
 *         try:             # <<<<<<<<<<<<<<
 *             # try to decode with default encoding
 *             filename = python.PyUnicode_Decode(
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1220
 *             filename = python.PyUnicode_Decode(
 *                 c_filename, python.PyString_GET_SIZE(filename),
 *                 _C_FILENAME_ENCODING, NULL)             # <<<<<<<<<<<<<<
 *         except UnicodeDecodeError, decode_exc:
 *             try:
 */
        __pyx_3 = PyUnicode_Decode(__pyx_v_c_filename, PyString_GET_SIZE(__pyx_v_filename), __pyx_v_4lxml_5etree__C_FILENAME_ENCODING, NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_filename);
        __pyx_v_filename = __pyx_3;
        __pyx_3 = 0;
      }
      Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L9_try;
      __pyx_L5_error:;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1221
 *                 c_filename, python.PyString_GET_SIZE(filename),
 *                 _C_FILENAME_ENCODING, NULL)
 *         except UnicodeDecodeError, decode_exc:             # <<<<<<<<<<<<<<
 *             try:
 *                 # try if it's UTF-8
 */
      __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
      if (__pyx_2) {
        __Pyx_AddTraceback("lxml.etree._encodeFilenameUTF8");
        if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_INCREF(__pyx_4);
        Py_DECREF(__pyx_v_decode_exc);
        __pyx_v_decode_exc = __pyx_4;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1222
 *                 _C_FILENAME_ENCODING, NULL)
 *         except UnicodeDecodeError, decode_exc:
 *             try:             # <<<<<<<<<<<<<<
 *                 # try if it's UTF-8
 *                 filename = python.PyUnicode_DecodeUTF8(
 */
        {
          PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
          __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
          /*try:*/ {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1225
 *                 # try if it's UTF-8
 *                 filename = python.PyUnicode_DecodeUTF8(
 *                     c_filename, python.PyString_GET_SIZE(filename), NULL)             # <<<<<<<<<<<<<<
 *             except UnicodeDecodeError:
 *                 raise decode_exc # otherwise re-raise original exception
 */
            __pyx_6 = PyUnicode_DecodeUTF8(__pyx_v_c_filename, PyString_GET_SIZE(__pyx_v_filename), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            Py_DECREF(__pyx_v_filename);
            __pyx_v_filename = __pyx_6;
            __pyx_6 = 0;
          }
          Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
          Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
          Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
          goto __pyx_L14_try;
          __pyx_L10_error:;
          Py_XDECREF(__pyx_6); __pyx_6 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1226
 *                 filename = python.PyUnicode_DecodeUTF8(
 *                     c_filename, python.PyString_GET_SIZE(filename), NULL)
 *             except UnicodeDecodeError:             # <<<<<<<<<<<<<<
 *                 raise decode_exc # otherwise re-raise original exception
 *     if python.PyUnicode_Check(filename):
 */
          __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
          if (__pyx_2) {
            __Pyx_AddTraceback("lxml.etree._encodeFilenameUTF8");
            if (__Pyx_GetException(&__pyx_6, &__pyx_7, &__pyx_8) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1227
 *                     c_filename, python.PyString_GET_SIZE(filename), NULL)
 *             except UnicodeDecodeError:
 *                 raise decode_exc # otherwise re-raise original exception             # <<<<<<<<<<<<<<
 *     if python.PyUnicode_Check(filename):
 *         return python.PyUnicode_AsUTF8String(filename)
 */
            __Pyx_Raise(__pyx_v_decode_exc, 0, 0);
            {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
            Py_DECREF(__pyx_6); __pyx_6 = 0;
            Py_DECREF(__pyx_7); __pyx_7 = 0;
            Py_DECREF(__pyx_8); __pyx_8 = 0;
            goto __pyx_L11_exception_handled;
          }
          __pyx_L12_except_error:;
          Py_XDECREF(__pyx_save_exc_type);
          Py_XDECREF(__pyx_save_exc_value);
          Py_XDECREF(__pyx_save_exc_tb);
          goto __pyx_L7_except_error;
          __pyx_L11_exception_handled:;
          __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
          __pyx_L14_try:;
        }
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L6_exception_handled;
      }
      __pyx_L7_except_error:;
      Py_XDECREF(__pyx_save_exc_type);
      Py_XDECREF(__pyx_save_exc_value);
      Py_XDECREF(__pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L6_exception_handled:;
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L9_try:;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1228
 *             except UnicodeDecodeError:
 *                 raise decode_exc # otherwise re-raise original exception
 *     if python.PyUnicode_Check(filename):             # <<<<<<<<<<<<<<
 *         return python.PyUnicode_AsUTF8String(filename)
 *     else:
 */
  __pyx_2 = PyUnicode_Check(__pyx_v_filename);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1229
 *                 raise decode_exc # otherwise re-raise original exception
 *     if python.PyUnicode_Check(filename):
 *         return python.PyUnicode_AsUTF8String(filename)             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."
 */
    __pyx_6 = PyUnicode_AsUTF8String(__pyx_v_filename); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_6;
    __pyx_6 = 0;
    goto __pyx_L0;
    goto __pyx_L15;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1231
 *         return python.PyUnicode_AsUTF8String(filename)
 *     else:
 *         raise TypeError, u"Argument must be string or unicode."             # <<<<<<<<<<<<<<
 * 
 * cdef _getNsTag(tag):
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_332), 0);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L15:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("lxml.etree._encodeFilenameUTF8");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_decode_exc);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1233
 *         raise TypeError, u"Argument must be string or unicode."
 * 
 * cdef _getNsTag(tag):             # <<<<<<<<<<<<<<
 *     u"""Given a tag, find namespace URI and tag name.
 *     Return None for NS uri if no namespace URI available.
 */

static  PyObject *__pyx_f_4lxml_5etree__getNsTag(PyObject *__pyx_v_tag) {
  char *__pyx_v_c_tag;
  char *__pyx_v_c_ns_end;
  Py_ssize_t __pyx_v_taglen;
  Py_ssize_t __pyx_v_nslen;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_tag);
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1242
 *     cdef Py_ssize_t nslen
 *     # _isString() is much faster than isinstance()
 *     if not _isString(tag) and isinstance(tag, QName):             # <<<<<<<<<<<<<<
 *         tag = (<QName>tag).text
 *     tag = _utf8(tag)
 */
  __pyx_1 = (!_isString(__pyx_v_tag));
  if (__pyx_1) {
    __pyx_1 = PyObject_TypeCheck(__pyx_v_tag, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1243
 *     # _isString() is much faster than isinstance()
 *     if not _isString(tag) and isinstance(tag, QName):
 *         tag = (<QName>tag).text             # <<<<<<<<<<<<<<
 *     tag = _utf8(tag)
 *     c_tag = _cstr(tag)
 */
    Py_INCREF(((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_tag)->text);
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = ((struct __pyx_obj_4lxml_5etree_QName *)__pyx_v_tag)->text;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1244
 *     if not _isString(tag) and isinstance(tag, QName):
 *         tag = (<QName>tag).text
 *     tag = _utf8(tag)             # <<<<<<<<<<<<<<
 *     c_tag = _cstr(tag)
 *     if c_tag[0] == c'{':
 */
  __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_tag); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_tag);
  __pyx_v_tag = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1245
 *         tag = (<QName>tag).text
 *     tag = _utf8(tag)
 *     c_tag = _cstr(tag)             # <<<<<<<<<<<<<<
 *     if c_tag[0] == c'{':
 *         c_tag = c_tag + 1
 */
  __pyx_v_c_tag = PyString_AS_STRING(__pyx_v_tag);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1246
 *     tag = _utf8(tag)
 *     c_tag = _cstr(tag)
 *     if c_tag[0] == c'{':             # <<<<<<<<<<<<<<
 *         c_tag = c_tag + 1
 *         c_ns_end = cstd.strchr(c_tag, c'}')
 */
  __pyx_1 = ((__pyx_v_c_tag[0]) == '{');
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1247
 *     c_tag = _cstr(tag)
 *     if c_tag[0] == c'{':
 *         c_tag = c_tag + 1             # <<<<<<<<<<<<<<
 *         c_ns_end = cstd.strchr(c_tag, c'}')
 *         if c_ns_end is NULL:
 */
      __pyx_v_c_tag = (__pyx_v_c_tag + 1);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1248
 *     if c_tag[0] == c'{':
 *         c_tag = c_tag + 1
 *         c_ns_end = cstd.strchr(c_tag, c'}')             # <<<<<<<<<<<<<<
 *         if c_ns_end is NULL:
 *             raise ValueError, u"Invalid tag name"
 */
    __pyx_v_c_ns_end = strchr(__pyx_v_c_tag, '}');

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1249
 *         c_tag = c_tag + 1
 *         c_ns_end = cstd.strchr(c_tag, c'}')
 *         if c_ns_end is NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Invalid tag name"
 *         nslen  = c_ns_end - c_tag
 */
    __pyx_1 = (__pyx_v_c_ns_end == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1250
 *         c_ns_end = cstd.strchr(c_tag, c'}')
 *         if c_ns_end is NULL:
 *             raise ValueError, u"Invalid tag name"             # <<<<<<<<<<<<<<
 *         nslen  = c_ns_end - c_tag
 *         taglen = python.PyString_GET_SIZE(tag) - nslen - 2
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_333), 0);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1251
 *         if c_ns_end is NULL:
 *             raise ValueError, u"Invalid tag name"
 *         nslen  = c_ns_end - c_tag             # <<<<<<<<<<<<<<
 *         taglen = python.PyString_GET_SIZE(tag) - nslen - 2
 *         if taglen == 0:
 */
    __pyx_v_nslen = (__pyx_v_c_ns_end - __pyx_v_c_tag);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1252
 *             raise ValueError, u"Invalid tag name"
 *         nslen  = c_ns_end - c_tag
 *         taglen = python.PyString_GET_SIZE(tag) - nslen - 2             # <<<<<<<<<<<<<<
 *         if taglen == 0:
 *             raise ValueError, u"Empty tag name"
 */
    __pyx_v_taglen = ((PyString_GET_SIZE(__pyx_v_tag) - __pyx_v_nslen) - 2);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1253
 *         nslen  = c_ns_end - c_tag
 *         taglen = python.PyString_GET_SIZE(tag) - nslen - 2
 *         if taglen == 0:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Empty tag name"
 *         if nslen > 0:
 */
    __pyx_1 = (__pyx_v_taglen == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1254
 *         taglen = python.PyString_GET_SIZE(tag) - nslen - 2
 *         if taglen == 0:
 *             raise ValueError, u"Empty tag name"             # <<<<<<<<<<<<<<
 *         if nslen > 0:
 *             ns = python.PyString_FromStringAndSize(c_tag,   nslen)
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_334), 0);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1255
 *         if taglen == 0:
 *             raise ValueError, u"Empty tag name"
 *         if nslen > 0:             # <<<<<<<<<<<<<<
 *             ns = python.PyString_FromStringAndSize(c_tag,   nslen)
 *         tag = python.PyString_FromStringAndSize(c_ns_end+1, taglen)
 */
    __pyx_1 = (__pyx_v_nslen > 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1256
 *             raise ValueError, u"Empty tag name"
 *         if nslen > 0:
 *             ns = python.PyString_FromStringAndSize(c_tag,   nslen)             # <<<<<<<<<<<<<<
 *         tag = python.PyString_FromStringAndSize(c_ns_end+1, taglen)
 *     elif python.PyString_GET_SIZE(tag) == 0:
 */
      __pyx_2 = PyString_FromStringAndSize(__pyx_v_c_tag, __pyx_v_nslen); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns);
      __pyx_v_ns = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1257
 *         if nslen > 0:
 *             ns = python.PyString_FromStringAndSize(c_tag,   nslen)
 *         tag = python.PyString_FromStringAndSize(c_ns_end+1, taglen)             # <<<<<<<<<<<<<<
 *     elif python.PyString_GET_SIZE(tag) == 0:
 *         raise ValueError, u"Empty tag name"
 */
    __pyx_2 = PyString_FromStringAndSize((__pyx_v_c_ns_end + 1), __pyx_v_taglen); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_tag);
    __pyx_v_tag = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L4;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1258
 *             ns = python.PyString_FromStringAndSize(c_tag,   nslen)
 *         tag = python.PyString_FromStringAndSize(c_ns_end+1, taglen)
 *     elif python.PyString_GET_SIZE(tag) == 0:             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Empty tag name"
 *     return ns, tag
 */
  __pyx_1 = (PyString_GET_SIZE(__pyx_v_tag) == 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1259
 *         tag = python.PyString_FromStringAndSize(c_ns_end+1, taglen)
 *     elif python.PyString_GET_SIZE(tag) == 0:
 *         raise ValueError, u"Empty tag name"             # <<<<<<<<<<<<<<
 *     return ns, tag
 * 
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_335), 0);
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1260
 *     elif python.PyString_GET_SIZE(tag) == 0:
 *         raise ValueError, u"Empty tag name"
 *     return ns, tag             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _pyXmlNameIsValid(name_utf8):
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_ns);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_ns);
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_tag);
  __pyx_r = ((PyObject *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._getNsTag");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_tag);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1262
 *     return ns, tag
 * 
 * cdef inline int _pyXmlNameIsValid(name_utf8):             # <<<<<<<<<<<<<<
 *     return _xmlNameIsValid(_cstr(name_utf8))
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__pyXmlNameIsValid(PyObject *__pyx_v_name_utf8) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1263
 * 
 * cdef inline int _pyXmlNameIsValid(name_utf8):
 *     return _xmlNameIsValid(_cstr(name_utf8))             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _pyHtmlNameIsValid(name_utf8):
 */
  __pyx_r = __pyx_f_4lxml_5etree__xmlNameIsValid(PyString_AS_STRING(__pyx_v_name_utf8));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1265
 *     return _xmlNameIsValid(_cstr(name_utf8))
 * 
 * cdef inline int _pyHtmlNameIsValid(name_utf8):             # <<<<<<<<<<<<<<
 *     return _htmlNameIsValid(_cstr(name_utf8))
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__pyHtmlNameIsValid(PyObject *__pyx_v_name_utf8) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1266
 * 
 * cdef inline int _pyHtmlNameIsValid(name_utf8):
 *     return _htmlNameIsValid(_cstr(name_utf8))             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _xmlNameIsValid(char* c_name):
 */
  __pyx_r = __pyx_f_4lxml_5etree__htmlNameIsValid(PyString_AS_STRING(__pyx_v_name_utf8));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1268
 *     return _htmlNameIsValid(_cstr(name_utf8))
 * 
 * cdef inline int _xmlNameIsValid(char* c_name):             # <<<<<<<<<<<<<<
 *     return tree.xmlValidateNCName(c_name, 0) == 0
 * 
 */

static INLINE int __pyx_f_4lxml_5etree__xmlNameIsValid(char *__pyx_v_c_name) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1269
 * 
 * cdef inline int _xmlNameIsValid(char* c_name):
 *     return tree.xmlValidateNCName(c_name, 0) == 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _htmlNameIsValid(char* c_name):
 */
  __pyx_r = (xmlValidateNCName(__pyx_v_c_name, 0) == 0);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1271
 *     return tree.xmlValidateNCName(c_name, 0) == 0
 * 
 * cdef int _htmlNameIsValid(char* c_name):             # <<<<<<<<<<<<<<
 *     if c_name is NULL or c_name[0] == c'\0':
 *         return 0
 */

static  int __pyx_f_4lxml_5etree__htmlNameIsValid(char *__pyx_v_c_name) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1272
 * 
 * cdef int _htmlNameIsValid(char* c_name):
 *     if c_name is NULL or c_name[0] == c'\0':             # <<<<<<<<<<<<<<
 *         return 0
 *     while c_name[0] != c'\0':
 */
  __pyx_1 = (__pyx_v_c_name == NULL);
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_c_name[0]) == '\x00');
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1273
 * cdef int _htmlNameIsValid(char* c_name):
 *     if c_name is NULL or c_name[0] == c'\0':
 *         return 0             # <<<<<<<<<<<<<<
 *     while c_name[0] != c'\0':
 *         if c_name[0] == c'&' or \
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1274
 *     if c_name is NULL or c_name[0] == c'\0':
 *         return 0
 *     while c_name[0] != c'\0':             # <<<<<<<<<<<<<<
 *         if c_name[0] == c'&' or \
 *                 c_name[0] == c'<' or \
 */
  while (1) {
    __pyx_1 = ((__pyx_v_c_name[0]) != '\x00');
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1275
 *         return 0
 *     while c_name[0] != c'\0':
 *         if c_name[0] == c'&' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'<' or \
 *                 c_name[0] == c'>' or \
 */
    __pyx_1 = ((__pyx_v_c_name[0]) == '&');
    if (!__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1276
 *     while c_name[0] != c'\0':
 *         if c_name[0] == c'&' or \
 *                 c_name[0] == c'<' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'>' or \
 *                 c_name[0] == c'/' or \
 */
      __pyx_1 = ((__pyx_v_c_name[0]) == '<');
      if (!__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1277
 *         if c_name[0] == c'&' or \
 *                 c_name[0] == c'<' or \
 *                 c_name[0] == c'>' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'/' or \
 *                 c_name[0] == c'"' or \
 */
        __pyx_1 = ((__pyx_v_c_name[0]) == '>');
        if (!__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1278
 *                 c_name[0] == c'<' or \
 *                 c_name[0] == c'>' or \
 *                 c_name[0] == c'/' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'"' or \
 *                 c_name[0] == c"'" or \
 */
          __pyx_1 = ((__pyx_v_c_name[0]) == '/');
          if (!__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1279
 *                 c_name[0] == c'>' or \
 *                 c_name[0] == c'/' or \
 *                 c_name[0] == c'"' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c"'" or \
 *                 c_name[0] == c'\x09' or \
 */
            __pyx_1 = ((__pyx_v_c_name[0]) == '"');
            if (!__pyx_1) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1280
 *                 c_name[0] == c'/' or \
 *                 c_name[0] == c'"' or \
 *                 c_name[0] == c"'" or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'\x09' or \
 *                 c_name[0] == c'\x0A' or \
 */
              __pyx_1 = ((__pyx_v_c_name[0]) == '\'');
              if (!__pyx_1) {

                /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1281
 *                 c_name[0] == c'"' or \
 *                 c_name[0] == c"'" or \
 *                 c_name[0] == c'\x09' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'\x0A' or \
 *                 c_name[0] == c'\x0B' or \
 */
                __pyx_1 = ((__pyx_v_c_name[0]) == '\t');
                if (!__pyx_1) {

                  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1282
 *                 c_name[0] == c"'" or \
 *                 c_name[0] == c'\x09' or \
 *                 c_name[0] == c'\x0A' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'\x0B' or \
 *                 c_name[0] == c'\x0C' or \
 */
                  __pyx_1 = ((__pyx_v_c_name[0]) == '\n');
                  if (!__pyx_1) {

                    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1283
 *                 c_name[0] == c'\x09' or \
 *                 c_name[0] == c'\x0A' or \
 *                 c_name[0] == c'\x0B' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'\x0C' or \
 *                 c_name[0] == c'\x20':
 */
                    __pyx_1 = ((__pyx_v_c_name[0]) == '\x0B');
                    if (!__pyx_1) {

                      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1284
 *                 c_name[0] == c'\x0A' or \
 *                 c_name[0] == c'\x0B' or \
 *                 c_name[0] == c'\x0C' or \             # <<<<<<<<<<<<<<
 *                 c_name[0] == c'\x20':
 *             return 0
 */
                      __pyx_1 = ((__pyx_v_c_name[0]) == '\x0C');
                      if (!__pyx_1) {

                        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1285
 *                 c_name[0] == c'\x0B' or \
 *                 c_name[0] == c'\x0C' or \
 *                 c_name[0] == c'\x20':             # <<<<<<<<<<<<<<
 *             return 0
 *         c_name = c_name + 1
 */
                        __pyx_1 = ((__pyx_v_c_name[0]) == ' ');
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1286
 *                 c_name[0] == c'\x0C' or \
 *                 c_name[0] == c'\x20':
 *             return 0             # <<<<<<<<<<<<<<
 *         c_name = c_name + 1
 *     return 1
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1287
 *                 c_name[0] == c'\x20':
 *             return 0
 *         c_name = c_name + 1             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
    __pyx_v_c_name = (__pyx_v_c_name + 1);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1288
 *             return 0
 *         c_name = c_name + 1
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef bint _characterReferenceIsValid(char* c_name):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1290
 *     return 1
 * 
 * cdef bint _characterReferenceIsValid(char* c_name):             # <<<<<<<<<<<<<<
 *     cdef bint is_hex
 *     if c_name[0] == c'x':
 */

static  int __pyx_f_4lxml_5etree__characterReferenceIsValid(char *__pyx_v_c_name) {
  int __pyx_v_is_hex;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1292
 * cdef bint _characterReferenceIsValid(char* c_name):
 *     cdef bint is_hex
 *     if c_name[0] == c'x':             # <<<<<<<<<<<<<<
 *         c_name += 1
 *         is_hex = 1
 */
  __pyx_1 = ((__pyx_v_c_name[0]) == 'x');
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1293
 *     cdef bint is_hex
 *     if c_name[0] == c'x':
 *         c_name += 1             # <<<<<<<<<<<<<<
 *         is_hex = 1
 *     else:
 */
    __pyx_v_c_name += 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1294
 *     if c_name[0] == c'x':
 *         c_name += 1
 *         is_hex = 1             # <<<<<<<<<<<<<<
 *     else:
 *         is_hex = 0
 */
    __pyx_v_is_hex = 1;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1296
 *         is_hex = 1
 *     else:
 *         is_hex = 0             # <<<<<<<<<<<<<<
 *     if c_name[0] == c'\0':
 *         return 0
 */
    __pyx_v_is_hex = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1297
 *     else:
 *         is_hex = 0
 *     if c_name[0] == c'\0':             # <<<<<<<<<<<<<<
 *         return 0
 *     while c_name[0] != c'\0':
 */
  __pyx_1 = ((__pyx_v_c_name[0]) == '\x00');
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1298
 *         is_hex = 0
 *     if c_name[0] == c'\0':
 *         return 0             # <<<<<<<<<<<<<<
 *     while c_name[0] != c'\0':
 *         if c_name[0] < c'0' or c_name[0] > c'9':
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1299
 *     if c_name[0] == c'\0':
 *         return 0
 *     while c_name[0] != c'\0':             # <<<<<<<<<<<<<<
 *         if c_name[0] < c'0' or c_name[0] > c'9':
 *             if not is_hex:
 */
  while (1) {
    __pyx_1 = ((__pyx_v_c_name[0]) != '\x00');
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1300
 *         return 0
 *     while c_name[0] != c'\0':
 *         if c_name[0] < c'0' or c_name[0] > c'9':             # <<<<<<<<<<<<<<
 *             if not is_hex:
 *                 return 0
 */
    __pyx_1 = ((__pyx_v_c_name[0]) < '0');
    if (!__pyx_1) {
      __pyx_1 = ((__pyx_v_c_name[0]) > '9');
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1301
 *     while c_name[0] != c'\0':
 *         if c_name[0] < c'0' or c_name[0] > c'9':
 *             if not is_hex:             # <<<<<<<<<<<<<<
 *                 return 0
 *             if not (c_name[0] >= c'a' and c_name[0] <= c'f'):
 */
      __pyx_1 = (!__pyx_v_is_hex);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1302
 *         if c_name[0] < c'0' or c_name[0] > c'9':
 *             if not is_hex:
 *                 return 0             # <<<<<<<<<<<<<<
 *             if not (c_name[0] >= c'a' and c_name[0] <= c'f'):
 *                 if not (c_name[0] >= c'A' and c_name[0] <= c'F'):
 */
        __pyx_r = 0;
        goto __pyx_L0;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1303
 *             if not is_hex:
 *                 return 0
 *             if not (c_name[0] >= c'a' and c_name[0] <= c'f'):             # <<<<<<<<<<<<<<
 *                 if not (c_name[0] >= c'A' and c_name[0] <= c'F'):
 *                     return 0
 */
      __pyx_1 = ((__pyx_v_c_name[0]) >= 'a');
      if (__pyx_1) {
        __pyx_1 = ((__pyx_v_c_name[0]) <= 'f');
      }
      __pyx_2 = (!__pyx_1);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1304
 *                 return 0
 *             if not (c_name[0] >= c'a' and c_name[0] <= c'f'):
 *                 if not (c_name[0] >= c'A' and c_name[0] <= c'F'):             # <<<<<<<<<<<<<<
 *                     return 0
 *         c_name += 1
 */
        __pyx_1 = ((__pyx_v_c_name[0]) >= 'A');
        if (__pyx_1) {
          __pyx_1 = ((__pyx_v_c_name[0]) <= 'F');
        }
        __pyx_2 = (!__pyx_1);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1305
 *             if not (c_name[0] >= c'a' and c_name[0] <= c'f'):
 *                 if not (c_name[0] >= c'A' and c_name[0] <= c'F'):
 *                     return 0             # <<<<<<<<<<<<<<
 *         c_name += 1
 *     return 1
 */
          __pyx_r = 0;
          goto __pyx_L0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1306
 *                 if not (c_name[0] >= c'A' and c_name[0] <= c'F'):
 *                     return 0
 *         c_name += 1             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
    __pyx_v_c_name += 1;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1307
 *                     return 0
 *         c_name += 1
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef int _tagValidOrRaise(tag_utf) except -1:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1309
 *     return 1
 * 
 * cdef int _tagValidOrRaise(tag_utf) except -1:             # <<<<<<<<<<<<<<
 *     if not _pyXmlNameIsValid(tag_utf):
 *         raise ValueError, u"Invalid tag name %r" % \
 */

static  int __pyx_f_4lxml_5etree__tagValidOrRaise(PyObject *__pyx_v_tag_utf) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1310
 * 
 * cdef int _tagValidOrRaise(tag_utf) except -1:
 *     if not _pyXmlNameIsValid(tag_utf):             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Invalid tag name %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)
 */
  __pyx_1 = (!__pyx_f_4lxml_5etree__pyXmlNameIsValid(__pyx_v_tag_utf));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1312
 *     if not _pyXmlNameIsValid(tag_utf):
 *         raise ValueError, u"Invalid tag name %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_tag_utf, __pyx_k_337, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_336), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1313
 *         raise ValueError, u"Invalid tag name %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _htmlTagValidOrRaise(tag_utf) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._tagValidOrRaise");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1315
 *     return 0
 * 
 * cdef int _htmlTagValidOrRaise(tag_utf) except -1:             # <<<<<<<<<<<<<<
 *     if not _pyHtmlNameIsValid(tag_utf):
 *         raise ValueError, u"Invalid HTML tag name %r" % \
 */

static  int __pyx_f_4lxml_5etree__htmlTagValidOrRaise(PyObject *__pyx_v_tag_utf) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1316
 * 
 * cdef int _htmlTagValidOrRaise(tag_utf) except -1:
 *     if not _pyHtmlNameIsValid(tag_utf):             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Invalid HTML tag name %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)
 */
  __pyx_1 = (!__pyx_f_4lxml_5etree__pyHtmlNameIsValid(__pyx_v_tag_utf));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1318
 *     if not _pyHtmlNameIsValid(tag_utf):
 *         raise ValueError, u"Invalid HTML tag name %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_tag_utf, __pyx_k_339, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_338), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1319
 *         raise ValueError, u"Invalid HTML tag name %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _attributeValidOrRaise(name_utf) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._htmlTagValidOrRaise");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1321
 *     return 0
 * 
 * cdef int _attributeValidOrRaise(name_utf) except -1:             # <<<<<<<<<<<<<<
 *     if not _pyXmlNameIsValid(name_utf):
 *         raise ValueError, u"Invalid attribute name %r" % \
 */

static  int __pyx_f_4lxml_5etree__attributeValidOrRaise(PyObject *__pyx_v_name_utf) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1322
 * 
 * cdef int _attributeValidOrRaise(name_utf) except -1:
 *     if not _pyXmlNameIsValid(name_utf):             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Invalid attribute name %r" % \
 *             python.PyUnicode_FromEncodedObject(name_utf, 'UTF-8', NULL)
 */
  __pyx_1 = (!__pyx_f_4lxml_5etree__pyXmlNameIsValid(__pyx_v_name_utf));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1324
 *     if not _pyXmlNameIsValid(name_utf):
 *         raise ValueError, u"Invalid attribute name %r" % \
 *             python.PyUnicode_FromEncodedObject(name_utf, 'UTF-8', NULL)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_name_utf, __pyx_k_341, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_340), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1325
 *         raise ValueError, u"Invalid attribute name %r" % \
 *             python.PyUnicode_FromEncodedObject(name_utf, 'UTF-8', NULL)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _prefixValidOrRaise(tag_utf) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._attributeValidOrRaise");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1327
 *     return 0
 * 
 * cdef int _prefixValidOrRaise(tag_utf) except -1:             # <<<<<<<<<<<<<<
 *     if not _pyXmlNameIsValid(tag_utf):
 *         raise ValueError, u"Invalid namespace prefix %r" % \
 */

static  int __pyx_f_4lxml_5etree__prefixValidOrRaise(PyObject *__pyx_v_tag_utf) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1328
 * 
 * cdef int _prefixValidOrRaise(tag_utf) except -1:
 *     if not _pyXmlNameIsValid(tag_utf):             # <<<<<<<<<<<<<<
 *         raise ValueError, u"Invalid namespace prefix %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)
 */
  __pyx_1 = (!__pyx_f_4lxml_5etree__pyXmlNameIsValid(__pyx_v_tag_utf));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1330
 *     if not _pyXmlNameIsValid(tag_utf):
 *         raise ValueError, u"Invalid namespace prefix %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_tag_utf, __pyx_k_343, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_342), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1331
 *         raise ValueError, u"Invalid namespace prefix %r" % \
 *             python.PyUnicode_FromEncodedObject(tag_utf, 'UTF-8', NULL)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline object _namespacedName(xmlNode* c_node):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._prefixValidOrRaise");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1333
 *     return 0
 * 
 * cdef inline object _namespacedName(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _namespacedNameFromNsName(_getNs(c_node), c_node.name)
 * 
 */

static INLINE PyObject *__pyx_f_4lxml_5etree__namespacedName(xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1334
 * 
 * cdef inline object _namespacedName(xmlNode* c_node):
 *     return _namespacedNameFromNsName(_getNs(c_node), c_node.name)             # <<<<<<<<<<<<<<
 * 
 * cdef object _namespacedNameFromNsName(char* href, char* name):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__namespacedNameFromNsName(_getNs(__pyx_v_c_node), __pyx_v_c_node->name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._namespacedName");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1336
 *     return _namespacedNameFromNsName(_getNs(c_node), c_node.name)
 * 
 * cdef object _namespacedNameFromNsName(char* href, char* name):             # <<<<<<<<<<<<<<
 *     if href is NULL:
 *         return funicode(name)
 */

static  PyObject *__pyx_f_4lxml_5etree__namespacedNameFromNsName(char *__pyx_v_href, char *__pyx_v_name) {
  PyObject *__pyx_v_s;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_s = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1337
 * 
 * cdef object _namespacedNameFromNsName(char* href, char* name):
 *     if href is NULL:             # <<<<<<<<<<<<<<
 *         return funicode(name)
 *     elif python.IS_PYTHON3:
 */
  __pyx_1 = (__pyx_v_href == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1338
 * cdef object _namespacedNameFromNsName(char* href, char* name):
 *     if href is NULL:
 *         return funicode(name)             # <<<<<<<<<<<<<<
 *     elif python.IS_PYTHON3:
 *         return python.PyUnicode_FromFormat("{%s}%s", href, name)
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1339
 *     if href is NULL:
 *         return funicode(name)
 *     elif python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *         return python.PyUnicode_FromFormat("{%s}%s", href, name)
 *     else:
 */
  __pyx_1 = IS_PYTHON3;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1340
 *         return funicode(name)
 *     elif python.IS_PYTHON3:
 *         return python.PyUnicode_FromFormat("{%s}%s", href, name)             # <<<<<<<<<<<<<<
 *     else:
 *         s = python.PyString_FromFormat("{%s}%s", href, name)
 */
    __pyx_2 = PyUnicode_FromFormat(__pyx_k_344, __pyx_v_href, __pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1342
 *         return python.PyUnicode_FromFormat("{%s}%s", href, name)
 *     else:
 *         s = python.PyString_FromFormat("{%s}%s", href, name)             # <<<<<<<<<<<<<<
 *         if isutf8(href) or isutf8(name):
 *             return python.PyUnicode_FromEncodedObject(s, 'UTF-8', NULL)
 */
    __pyx_2 = PyString_FromFormat(__pyx_k_345, __pyx_v_href, __pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1343
 *     else:
 *         s = python.PyString_FromFormat("{%s}%s", href, name)
 *         if isutf8(href) or isutf8(name):             # <<<<<<<<<<<<<<
 *             return python.PyUnicode_FromEncodedObject(s, 'UTF-8', NULL)
 *         else:
 */
    __pyx_1 = __pyx_f_4lxml_5etree_isutf8(__pyx_v_href);
    if (!__pyx_1) {
      __pyx_1 = __pyx_f_4lxml_5etree_isutf8(__pyx_v_name);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1344
 *         s = python.PyString_FromFormat("{%s}%s", href, name)
 *         if isutf8(href) or isutf8(name):
 *             return python.PyUnicode_FromEncodedObject(s, 'UTF-8', NULL)             # <<<<<<<<<<<<<<
 *         else:
 *             return s
 */
      __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_s, __pyx_k_346, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1346
 *             return python.PyUnicode_FromEncodedObject(s, 'UTF-8', NULL)
 *         else:
 *             return s             # <<<<<<<<<<<<<<
 * 
 * cdef _getFilenameForFile(source):
 */
      Py_INCREF(__pyx_v_s);
      __pyx_r = __pyx_v_s;
      goto __pyx_L0;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._namespacedNameFromNsName");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1348
 *             return s
 * 
 * cdef _getFilenameForFile(source):             # <<<<<<<<<<<<<<
 *     u"""Given a Python File or Gzip object, give filename back.
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree__getFilenameForFile(PyObject *__pyx_v_source) {
  PyObject *__pyx_v_filename;
  PyObject *__pyx_v_geturl;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  __pyx_v_filename = Py_None; Py_INCREF(Py_None);
  __pyx_v_geturl = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1354
 *     """
 *     # file instances have a name attribute
 *     filename = getattr3(source, u'name', None)             # <<<<<<<<<<<<<<
 *     if filename is not None:
 *         return os_path_abspath(filename)
 */
  __pyx_1 = __Pyx_GetAttr3(__pyx_v_source, ((PyObject *)__pyx_kp_347), Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_filename);
  __pyx_v_filename = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1355
 *     # file instances have a name attribute
 *     filename = getattr3(source, u'name', None)
 *     if filename is not None:             # <<<<<<<<<<<<<<
 *         return os_path_abspath(filename)
 *     # urllib2 provides a geturl() method
 */
  __pyx_2 = (__pyx_v_filename != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1356
 *     filename = getattr3(source, u'name', None)
 *     if filename is not None:
 *         return os_path_abspath(filename)             # <<<<<<<<<<<<<<
 *     # urllib2 provides a geturl() method
 *     geturl = getattr3(source, u'geturl', None)
 */
    __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_filename);
    __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree_os_path_abspath, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1358
 *         return os_path_abspath(filename)
 *     # urllib2 provides a geturl() method
 *     geturl = getattr3(source, u'geturl', None)             # <<<<<<<<<<<<<<
 *     if geturl is not None:
 *         return geturl()
 */
  __pyx_1 = __Pyx_GetAttr3(__pyx_v_source, ((PyObject *)__pyx_kp_348), Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_geturl);
  __pyx_v_geturl = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1359
 *     # urllib2 provides a geturl() method
 *     geturl = getattr3(source, u'geturl', None)
 *     if geturl is not None:             # <<<<<<<<<<<<<<
 *         return geturl()
 *     # gzip file instances have a filename attribute (before Py3k)
 */
  __pyx_2 = (__pyx_v_geturl != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1360
 *     geturl = getattr3(source, u'geturl', None)
 *     if geturl is not None:
 *         return geturl()             # <<<<<<<<<<<<<<
 *     # gzip file instances have a filename attribute (before Py3k)
 *     filename = getattr3(source, u'filename', None)
 */
    __pyx_3 = PyObject_Call(__pyx_v_geturl, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1362
 *         return geturl()
 *     # gzip file instances have a filename attribute (before Py3k)
 *     filename = getattr3(source, u'filename', None)             # <<<<<<<<<<<<<<
 *     if filename is not None:
 *         return os_path_abspath(filename)
 */
  __pyx_1 = __Pyx_GetAttr3(__pyx_v_source, ((PyObject *)__pyx_kp_349), Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_filename);
  __pyx_v_filename = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1363
 *     # gzip file instances have a filename attribute (before Py3k)
 *     filename = getattr3(source, u'filename', None)
 *     if filename is not None:             # <<<<<<<<<<<<<<
 *         return os_path_abspath(filename)
 *     # can't determine filename
 */
  __pyx_2 = (__pyx_v_filename != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1364
 *     filename = getattr3(source, u'filename', None)
 *     if filename is not None:
 *         return os_path_abspath(filename)             # <<<<<<<<<<<<<<
 *     # can't determine filename
 *     return None
 */
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_filename);
    __pyx_1 = PyObject_Call(__pyx_v_4lxml_5etree_os_path_abspath, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":1366
 *         return os_path_abspath(filename)
 *     # can't determine filename
 *     return None             # <<<<<<<<<<<<<<
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._getFilenameForFile");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_filename);
  Py_DECREF(__pyx_v_geturl);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":7
 * # module level API functions
 * 
 * def clear_error_log():             # <<<<<<<<<<<<<<
 *     u"""clear_error_log()
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_clear_error_log(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_clear_error_log[] = "clear_error_log()\n\n    Clear the global error log.  Note that this log is already bound to a\n    fixed size.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_clear_error_log(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_self = __pyx_self;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":13
 *     fixed size.
 *     """
 *     __GLOBAL_ERROR_LOG.clear()             # <<<<<<<<<<<<<<
 * 
 * # dummy function: no debug output at all
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG), __pyx_kp_clear); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.clear_error_log");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":16
 * 
 * # dummy function: no debug output at all
 * cdef void _nullGenericErrorFunc(void* ctxt, char* msg, ...) nogil:             # <<<<<<<<<<<<<<
 *     pass
 * 
 */

static  void __pyx_f_4lxml_5etree__nullGenericErrorFunc(void *__pyx_v_ctxt, char *__pyx_v_msg, ...) {

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":21
 * # setup for global log:
 * 
 * cdef void _initThreadLogging():             # <<<<<<<<<<<<<<
 *     # disable generic error lines from libxml2
 *     xmlerror.xmlThrDefSetGenericErrorFunc(NULL, _nullGenericErrorFunc)
 */

static  void __pyx_f_4lxml_5etree__initThreadLogging(void) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":23
 * cdef void _initThreadLogging():
 *     # disable generic error lines from libxml2
 *     xmlerror.xmlThrDefSetGenericErrorFunc(NULL, _nullGenericErrorFunc)             # <<<<<<<<<<<<<<
 *     xmlerror.xmlSetGenericErrorFunc(NULL, _nullGenericErrorFunc)
 * 
 */
  xmlThrDefSetGenericErrorFunc(NULL, __pyx_f_4lxml_5etree__nullGenericErrorFunc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":24
 *     # disable generic error lines from libxml2
 *     xmlerror.xmlThrDefSetGenericErrorFunc(NULL, _nullGenericErrorFunc)
 *     xmlerror.xmlSetGenericErrorFunc(NULL, _nullGenericErrorFunc)             # <<<<<<<<<<<<<<
 * 
 *     # divert error messages to the global error log
 */
  xmlSetGenericErrorFunc(NULL, __pyx_f_4lxml_5etree__nullGenericErrorFunc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":27
 * 
 *     # divert error messages to the global error log
 *     xmlerror.xmlThrDefSetStructuredErrorFunc(NULL, _receiveError)             # <<<<<<<<<<<<<<
 *     connectErrorLog(NULL)
 * 
 */
  xmlThrDefSetStructuredErrorFunc(NULL, __pyx_f_4lxml_5etree__receiveError);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":28
 *     # divert error messages to the global error log
 *     xmlerror.xmlThrDefSetStructuredErrorFunc(NULL, _receiveError)
 *     connectErrorLog(NULL)             # <<<<<<<<<<<<<<
 * 
 * cdef void connectErrorLog(void* log):
 */
  __pyx_f_4lxml_5etree_connectErrorLog(NULL);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":30
 *     connectErrorLog(NULL)
 * 
 * cdef void connectErrorLog(void* log):             # <<<<<<<<<<<<<<
 *     xmlerror.xmlSetStructuredErrorFunc(log, _receiveError)
 *     xslt.xsltSetGenericErrorFunc(log, _receiveXSLTError)
 */

static  void __pyx_f_4lxml_5etree_connectErrorLog(void *__pyx_v_log) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":31
 * 
 * cdef void connectErrorLog(void* log):
 *     xmlerror.xmlSetStructuredErrorFunc(log, _receiveError)             # <<<<<<<<<<<<<<
 *     xslt.xsltSetGenericErrorFunc(log, _receiveXSLTError)
 * 
 */
  xmlSetStructuredErrorFunc(__pyx_v_log, __pyx_f_4lxml_5etree__receiveError);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":32
 * cdef void connectErrorLog(void* log):
 *     xmlerror.xmlSetStructuredErrorFunc(log, _receiveError)
 *     xslt.xsltSetGenericErrorFunc(log, _receiveXSLTError)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  xsltSetGenericErrorFunc(__pyx_v_log, __pyx_f_4lxml_5etree__receiveXSLTError);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":46
 *     cdef readonly object filename
 * 
 *     cdef _setError(self, xmlerror.xmlError* error):             # <<<<<<<<<<<<<<
 *         cdef int size
 *         self.domain   = error.domain
 */

static  PyObject *__pyx_f_4lxml_5etree_9_LogEntry__setError(struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_self, xmlError *__pyx_v_error) {
  int __pyx_v_size;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":48
 *     cdef _setError(self, xmlerror.xmlError* error):
 *         cdef int size
 *         self.domain   = error.domain             # <<<<<<<<<<<<<<
 *         self.type     = error.code
 *         self.level    = <int>error.level
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_error->domain); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->domain);
  __pyx_v_self->domain = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":49
 *         cdef int size
 *         self.domain   = error.domain
 *         self.type     = error.code             # <<<<<<<<<<<<<<
 *         self.level    = <int>error.level
 *         self.line     = error.line
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_error->code); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->type);
  __pyx_v_self->type = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":50
 *         self.domain   = error.domain
 *         self.type     = error.code
 *         self.level    = <int>error.level             # <<<<<<<<<<<<<<
 *         self.line     = error.line
 *         self.column   = error.int2
 */
  __pyx_1 = PyInt_FromLong(((int)__pyx_v_error->level)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->level);
  __pyx_v_self->level = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":51
 *         self.type     = error.code
 *         self.level    = <int>error.level
 *         self.line     = error.line             # <<<<<<<<<<<<<<
 *         self.column   = error.int2
 *         size = cstd.strlen(error.message)
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_error->line); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->line);
  __pyx_v_self->line = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":52
 *         self.level    = <int>error.level
 *         self.line     = error.line
 *         self.column   = error.int2             # <<<<<<<<<<<<<<
 *         size = cstd.strlen(error.message)
 *         if size > 0 and error.message[size-1] == c'\n':
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_error->int2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->column);
  __pyx_v_self->column = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":53
 *         self.line     = error.line
 *         self.column   = error.int2
 *         size = cstd.strlen(error.message)             # <<<<<<<<<<<<<<
 *         if size > 0 and error.message[size-1] == c'\n':
 *             size = size - 1 # strip EOL
 */
  __pyx_v_size = strlen(__pyx_v_error->message);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":54
 *         self.column   = error.int2
 *         size = cstd.strlen(error.message)
 *         if size > 0 and error.message[size-1] == c'\n':             # <<<<<<<<<<<<<<
 *             size = size - 1 # strip EOL
 *         try:
 */
  __pyx_2 = (__pyx_v_size > 0);
  if (__pyx_2) {
    __pyx_2 = ((__pyx_v_error->message[(__pyx_v_size - 1)]) == '\n');
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":55
 *         size = cstd.strlen(error.message)
 *         if size > 0 and error.message[size-1] == c'\n':
 *             size = size - 1 # strip EOL             # <<<<<<<<<<<<<<
 *         try:
 *             self.message = python.PyUnicode_DecodeUTF8(
 */
    __pyx_v_size = (__pyx_v_size - 1);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":56
 *         if size > 0 and error.message[size-1] == c'\n':
 *             size = size - 1 # strip EOL
 *         try:             # <<<<<<<<<<<<<<
 *             self.message = python.PyUnicode_DecodeUTF8(
 *                 error.message, size, NULL)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":58
 *         try:
 *             self.message = python.PyUnicode_DecodeUTF8(
 *                 error.message, size, NULL)             # <<<<<<<<<<<<<<
 *         except:
 *             self.message = repr(error.message)
 */
      __pyx_1 = PyUnicode_DecodeUTF8(__pyx_v_error->message, __pyx_v_size, NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":57
 *             size = size - 1 # strip EOL
 *         try:
 *             self.message = python.PyUnicode_DecodeUTF8(             # <<<<<<<<<<<<<<
 *                 error.message, size, NULL)
 *         except:
 */
      Py_DECREF(__pyx_v_self->message);
      __pyx_v_self->message = __pyx_1;
      __pyx_1 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L8_try;
    __pyx_L4_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":59
 *             self.message = python.PyUnicode_DecodeUTF8(
 *                 error.message, size, NULL)
 *         except:             # <<<<<<<<<<<<<<
 *             self.message = repr(error.message)
 *         if error.file is NULL:
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._setError");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":60
 *                 error.message, size, NULL)
 *         except:
 *             self.message = repr(error.message)             # <<<<<<<<<<<<<<
 *         if error.file is NULL:
 *             self.filename = u'<string>'
 */
      __pyx_5 = __Pyx_PyBytes_FromString(__pyx_v_error->message); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      __pyx_6 = PyObject_Repr(__pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_v_self->message);
      __pyx_v_self->message = __pyx_6;
      __pyx_6 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L5_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L8_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":61
 *         except:
 *             self.message = repr(error.message)
 *         if error.file is NULL:             # <<<<<<<<<<<<<<
 *             self.filename = u'<string>'
 *         else:
 */
  __pyx_2 = (__pyx_v_error->file == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":62
 *             self.message = repr(error.message)
 *         if error.file is NULL:
 *             self.filename = u'<string>'             # <<<<<<<<<<<<<<
 *         else:
 *             self.filename = _decodeFilename(error.file)
 */
    Py_INCREF(((PyObject *)__pyx_kp_350));
    Py_DECREF(__pyx_v_self->filename);
    __pyx_v_self->filename = ((PyObject *)__pyx_kp_350);
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":64
 *             self.filename = u'<string>'
 *         else:
 *             self.filename = _decodeFilename(error.file)             # <<<<<<<<<<<<<<
 * 
 *     cdef _setGeneric(self, int domain, int type, int level, int line,
 */
    __pyx_5 = __pyx_f_4lxml_5etree__decodeFilename(__pyx_v_error->file); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_self->filename);
    __pyx_v_self->filename = __pyx_5;
    __pyx_5 = 0;
  }
  __pyx_L9:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._LogEntry._setError");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":66
 *             self.filename = _decodeFilename(error.file)
 * 
 *     cdef _setGeneric(self, int domain, int type, int level, int line,             # <<<<<<<<<<<<<<
 *                      message, filename):
 *         self.domain  = domain
 */

static  PyObject *__pyx_f_4lxml_5etree_9_LogEntry__setGeneric(struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_self, int __pyx_v_domain, int __pyx_v_type, int __pyx_v_level, int __pyx_v_line, PyObject *__pyx_v_message, PyObject *__pyx_v_filename) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":68
 *     cdef _setGeneric(self, int domain, int type, int level, int line,
 *                      message, filename):
 *         self.domain  = domain             # <<<<<<<<<<<<<<
 *         self.type    = type
 *         self.level   = level
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_domain); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->domain);
  __pyx_v_self->domain = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":69
 *                      message, filename):
 *         self.domain  = domain
 *         self.type    = type             # <<<<<<<<<<<<<<
 *         self.level   = level
 *         self.line    = line
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_type); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->type);
  __pyx_v_self->type = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":70
 *         self.domain  = domain
 *         self.type    = type
 *         self.level   = level             # <<<<<<<<<<<<<<
 *         self.line    = line
 *         self.column  = 0
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_level); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->level);
  __pyx_v_self->level = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":71
 *         self.type    = type
 *         self.level   = level
 *         self.line    = line             # <<<<<<<<<<<<<<
 *         self.column  = 0
 *         self.message = message
 */
  __pyx_1 = PyInt_FromLong(__pyx_v_line); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_self->line);
  __pyx_v_self->line = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":72
 *         self.level   = level
 *         self.line    = line
 *         self.column  = 0             # <<<<<<<<<<<<<<
 *         self.message = message
 *         self.filename = filename
 */
  Py_INCREF(__pyx_int_0);
  Py_DECREF(__pyx_v_self->column);
  __pyx_v_self->column = __pyx_int_0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":73
 *         self.line    = line
 *         self.column  = 0
 *         self.message = message             # <<<<<<<<<<<<<<
 *         self.filename = filename
 * 
 */
  Py_INCREF(__pyx_v_message);
  Py_DECREF(__pyx_v_self->message);
  __pyx_v_self->message = __pyx_v_message;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":74
 *         self.column  = 0
 *         self.message = message
 *         self.filename = filename             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  Py_INCREF(__pyx_v_filename);
  Py_DECREF(__pyx_v_self->filename);
  __pyx_v_self->filename = __pyx_v_filename;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._LogEntry._setGeneric");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":76
 *         self.filename = filename
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"%s:%d:%d:%s:%s:%s: %s" % (
 *             self.filename, self.line, self.column, self.level_name,
 */

static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":78
 *     def __repr__(self):
 *         return u"%s:%d:%d:%s:%s:%s: %s" % (
 *             self.filename, self.line, self.column, self.level_name,             # <<<<<<<<<<<<<<
 *             self.domain_name, self.type_name, self.message)
 * 
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_level_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":79
 *         return u"%s:%d:%d:%s:%s:%s: %s" % (
 *             self.filename, self.line, self.column, self.level_name,
 *             self.domain_name, self.type_name, self.message)             # <<<<<<<<<<<<<<
 * 
 *     property domain_name:
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_domain_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_type_name); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(7); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->filename);
  PyTuple_SET_ITEM(__pyx_4, 0, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->filename);
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->line);
  PyTuple_SET_ITEM(__pyx_4, 1, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->line);
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->column);
  PyTuple_SET_ITEM(__pyx_4, 2, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->column);
  PyTuple_SET_ITEM(__pyx_4, 3, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 4, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 5, __pyx_3);
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->message);
  PyTuple_SET_ITEM(__pyx_4, 6, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->message);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_351), ((PyObject *)__pyx_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._LogEntry.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":82
 * 
 *     property domain_name:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return ErrorDomains._getName(self.domain, u"unknown")
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry_11domain_name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry_11domain_name___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":83
 *     property domain_name:
 *         def __get__(self):
 *             return ErrorDomains._getName(self.domain, u"unknown")             # <<<<<<<<<<<<<<
 * 
 *     property type_name:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorDomains); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp__getName); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->domain);
  PyTuple_SET_ITEM(__pyx_1, 0, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->domain);
  Py_INCREF(((PyObject *)__pyx_kp_352));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_kp_352));
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._LogEntry.domain_name.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":86
 * 
 *     property type_name:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.domain == ErrorDomains.RELAXNGV:
 *                 getName = RelaxNGErrorTypes._getName
 */

static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry_9type_name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry_9type_name___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_getName;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_getName = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":87
 *     property type_name:
 *         def __get__(self):
 *             if self.domain == ErrorDomains.RELAXNGV:             # <<<<<<<<<<<<<<
 *                 getName = RelaxNGErrorTypes._getName
 *             else:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorDomains); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_RELAXNGV); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_RichCompare(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->domain, __pyx_2, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":88
 *         def __get__(self):
 *             if self.domain == ErrorDomains.RELAXNGV:
 *                 getName = RelaxNGErrorTypes._getName             # <<<<<<<<<<<<<<
 *             else:
 *                 getName = ErrorTypes._getName
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGErrorTypes); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp__getName); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_getName);
    __pyx_v_getName = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":90
 *                 getName = RelaxNGErrorTypes._getName
 *             else:
 *                 getName = ErrorTypes._getName             # <<<<<<<<<<<<<<
 *             return getName(self.type, u"unknown")
 * 
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorTypes); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp__getName); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_getName);
    __pyx_v_getName = __pyx_1;
    __pyx_1 = 0;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":91
 *             else:
 *                 getName = ErrorTypes._getName
 *             return getName(self.type, u"unknown")             # <<<<<<<<<<<<<<
 * 
 *     property level_name:
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->type);
  PyTuple_SET_ITEM(__pyx_2, 0, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->type);
  Py_INCREF(((PyObject *)__pyx_kp_353));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_kp_353));
  __pyx_1 = PyObject_Call(__pyx_v_getName, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._LogEntry.type_name.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_getName);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":94
 * 
 *     property level_name:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return ErrorLevels._getName(self.level, u"unknown")
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry_10level_name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_LogEntry_10level_name___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":95
 *     property level_name:
 *         def __get__(self):
 *             return ErrorLevels._getName(self.level, u"unknown")             # <<<<<<<<<<<<<<
 * 
 * cdef class _BaseErrorLog:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp__getName); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->level);
  PyTuple_SET_ITEM(__pyx_1, 0, ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_self)->level);
  Py_INCREF(((PyObject *)__pyx_kp_354));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_kp_354));
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._LogEntry.level_name.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":100
 *     cdef _LogEntry _first_error
 *     cdef readonly object last_error
 *     def __init__(self, first_error, last_error):             # <<<<<<<<<<<<<<
 *         self._first_error = first_error
 *         self.last_error = last_error
 */

static int __pyx_pf_4lxml_5etree_13_BaseErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_13_BaseErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_first_error = 0;
  PyObject *__pyx_v_last_error = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_first_error,&__pyx_kp_last_error,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_first_error);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_last_error);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_first_error = values[0];
    __pyx_v_last_error = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_first_error = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_last_error = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._BaseErrorLog.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":101
 *     cdef readonly object last_error
 *     def __init__(self, first_error, last_error):
 *         self._first_error = first_error             # <<<<<<<<<<<<<<
 *         self.last_error = last_error
 * 
 */
  if (!(__Pyx_TypeTest(__pyx_v_first_error, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_first_error);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->_first_error));
  ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->_first_error = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_first_error);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":102
 *     def __init__(self, first_error, last_error):
 *         self._first_error = first_error
 *         self.last_error = last_error             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  Py_INCREF(__pyx_v_last_error);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->last_error);
  ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->last_error = __pyx_v_last_error;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._BaseErrorLog.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":104
 *         self.last_error = last_error
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         return _BaseErrorLog(self._first_error, self.last_error)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_BaseErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_13_BaseErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":105
 * 
 *     def copy(self):
 *         return _BaseErrorLog(self._first_error, self.last_error)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->_first_error));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->_first_error));
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->last_error);
  PyTuple_SET_ITEM(__pyx_1, 1, ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self)->last_error);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseErrorLog)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseErrorLog.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":107
 *         return _BaseErrorLog(self._first_error, self.last_error)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u''
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_BaseErrorLog___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_13_BaseErrorLog___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":108
 * 
 *     def __repr__(self):
 *         return u''             # <<<<<<<<<<<<<<
 * 
 *     cdef void _receive(self, xmlerror.xmlError* error):
 */
  Py_INCREF(((PyObject *)__pyx_kp_355));
  __pyx_r = ((PyObject *)__pyx_kp_355);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":110
 *         return u''
 * 
 *     cdef void _receive(self, xmlerror.xmlError* error):             # <<<<<<<<<<<<<<
 *         cdef bint is_error
 *         cdef _LogEntry entry
 */

static  void __pyx_f_4lxml_5etree_13_BaseErrorLog__receive(struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_self, xmlError *__pyx_v_error) {
  int __pyx_v_is_error;
  struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_entry;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":113
 *         cdef bint is_error
 *         cdef _LogEntry entry
 *         entry = _LogEntry()             # <<<<<<<<<<<<<<
 *         entry._setError(error)
 *         is_error = error.level == xmlerror.XML_ERR_ERROR or \
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__LogEntry)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_entry));
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":114
 *         cdef _LogEntry entry
 *         entry = _LogEntry()
 *         entry._setError(error)             # <<<<<<<<<<<<<<
 *         is_error = error.level == xmlerror.XML_ERR_ERROR or \
 *                    error.level == xmlerror.XML_ERR_FATAL
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__LogEntry *)__pyx_v_entry->__pyx_vtab)->_setError(__pyx_v_entry, __pyx_v_error); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":115
 *         entry = _LogEntry()
 *         entry._setError(error)
 *         is_error = error.level == xmlerror.XML_ERR_ERROR or \             # <<<<<<<<<<<<<<
 *                    error.level == xmlerror.XML_ERR_FATAL
 *         if __GLOBAL_ERROR_LOG is not self:
 */
  __pyx_2 = (__pyx_v_error->level == XML_ERR_ERROR);
  if (!__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":116
 *         entry._setError(error)
 *         is_error = error.level == xmlerror.XML_ERR_ERROR or \
 *                    error.level == xmlerror.XML_ERR_FATAL             # <<<<<<<<<<<<<<
 *         if __GLOBAL_ERROR_LOG is not self:
 *             __GLOBAL_ERROR_LOG.receive(entry)
 */
    __pyx_2 = (__pyx_v_error->level == XML_ERR_FATAL);
  }
  __pyx_v_is_error = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":117
 *         is_error = error.level == xmlerror.XML_ERR_ERROR or \
 *                    error.level == xmlerror.XML_ERR_FATAL
 *         if __GLOBAL_ERROR_LOG is not self:             # <<<<<<<<<<<<<<
 *             __GLOBAL_ERROR_LOG.receive(entry)
 *             if is_error:
 */
  __pyx_2 = (__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG != __pyx_v_self);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":118
 *                    error.level == xmlerror.XML_ERR_FATAL
 *         if __GLOBAL_ERROR_LOG is not self:
 *             __GLOBAL_ERROR_LOG.receive(entry)             # <<<<<<<<<<<<<<
 *             if is_error:
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG), __pyx_kp_receive); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_entry));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_entry));
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":119
 *         if __GLOBAL_ERROR_LOG is not self:
 *             __GLOBAL_ERROR_LOG.receive(entry)
 *             if is_error:             # <<<<<<<<<<<<<<
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 *         self.receive(entry)
 */
    __pyx_2 = __pyx_v_is_error;
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":120
 *             __GLOBAL_ERROR_LOG.receive(entry)
 *             if is_error:
 *                 __GLOBAL_ERROR_LOG.last_error = entry             # <<<<<<<<<<<<<<
 *         self.receive(entry)
 *         if is_error:
 */
      Py_INCREF(((PyObject *)__pyx_v_entry));
      Py_DECREF(__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG->last_error);
      __pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG->last_error = ((PyObject *)__pyx_v_entry);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":121
 *             if is_error:
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 *         self.receive(entry)             # <<<<<<<<<<<<<<
 *         if is_error:
 *             self.last_error = entry
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_receive); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_entry));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_entry));
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":122
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 *         self.receive(entry)
 *         if is_error:             # <<<<<<<<<<<<<<
 *             self.last_error = entry
 * 
 */
  __pyx_2 = __pyx_v_is_error;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":123
 *         self.receive(entry)
 *         if is_error:
 *             self.last_error = entry             # <<<<<<<<<<<<<<
 * 
 *     cdef void _receiveGeneric(self, int domain, int type, int level, int line,
 */
    Py_INCREF(((PyObject *)__pyx_v_entry));
    Py_DECREF(__pyx_v_self->last_error);
    __pyx_v_self->last_error = ((PyObject *)__pyx_v_entry);
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._BaseErrorLog._receive");
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":125
 *             self.last_error = entry
 * 
 *     cdef void _receiveGeneric(self, int domain, int type, int level, int line,             # <<<<<<<<<<<<<<
 *                               message, filename):
 *         cdef bint is_error
 */

static  void __pyx_f_4lxml_5etree_13_BaseErrorLog__receiveGeneric(struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_self, int __pyx_v_domain, int __pyx_v_type, int __pyx_v_level, int __pyx_v_line, PyObject *__pyx_v_message, PyObject *__pyx_v_filename) {
  int __pyx_v_is_error;
  struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_entry;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":129
 *         cdef bint is_error
 *         cdef _LogEntry entry
 *         entry = _LogEntry()             # <<<<<<<<<<<<<<
 *         entry._setGeneric(domain, type, level, line, message, filename)
 *         is_error = level == xmlerror.XML_ERR_ERROR or \
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__LogEntry)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_entry));
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":130
 *         cdef _LogEntry entry
 *         entry = _LogEntry()
 *         entry._setGeneric(domain, type, level, line, message, filename)             # <<<<<<<<<<<<<<
 *         is_error = level == xmlerror.XML_ERR_ERROR or \
 *                    level == xmlerror.XML_ERR_FATAL
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__LogEntry *)__pyx_v_entry->__pyx_vtab)->_setGeneric(__pyx_v_entry, __pyx_v_domain, __pyx_v_type, __pyx_v_level, __pyx_v_line, __pyx_v_message, __pyx_v_filename); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":131
 *         entry = _LogEntry()
 *         entry._setGeneric(domain, type, level, line, message, filename)
 *         is_error = level == xmlerror.XML_ERR_ERROR or \             # <<<<<<<<<<<<<<
 *                    level == xmlerror.XML_ERR_FATAL
 *         if __GLOBAL_ERROR_LOG is not self:
 */
  __pyx_2 = (__pyx_v_level == XML_ERR_ERROR);
  if (!__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":132
 *         entry._setGeneric(domain, type, level, line, message, filename)
 *         is_error = level == xmlerror.XML_ERR_ERROR or \
 *                    level == xmlerror.XML_ERR_FATAL             # <<<<<<<<<<<<<<
 *         if __GLOBAL_ERROR_LOG is not self:
 *             __GLOBAL_ERROR_LOG.receive(entry)
 */
    __pyx_2 = (__pyx_v_level == XML_ERR_FATAL);
  }
  __pyx_v_is_error = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":133
 *         is_error = level == xmlerror.XML_ERR_ERROR or \
 *                    level == xmlerror.XML_ERR_FATAL
 *         if __GLOBAL_ERROR_LOG is not self:             # <<<<<<<<<<<<<<
 *             __GLOBAL_ERROR_LOG.receive(entry)
 *             if is_error:
 */
  __pyx_2 = (__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG != __pyx_v_self);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":134
 *                    level == xmlerror.XML_ERR_FATAL
 *         if __GLOBAL_ERROR_LOG is not self:
 *             __GLOBAL_ERROR_LOG.receive(entry)             # <<<<<<<<<<<<<<
 *             if is_error:
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG), __pyx_kp_receive); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_entry));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_entry));
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":135
 *         if __GLOBAL_ERROR_LOG is not self:
 *             __GLOBAL_ERROR_LOG.receive(entry)
 *             if is_error:             # <<<<<<<<<<<<<<
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 *         self.receive(entry)
 */
    __pyx_2 = __pyx_v_is_error;
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":136
 *             __GLOBAL_ERROR_LOG.receive(entry)
 *             if is_error:
 *                 __GLOBAL_ERROR_LOG.last_error = entry             # <<<<<<<<<<<<<<
 *         self.receive(entry)
 *         if is_error:
 */
      Py_INCREF(((PyObject *)__pyx_v_entry));
      Py_DECREF(__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG->last_error);
      __pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG->last_error = ((PyObject *)__pyx_v_entry);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":137
 *             if is_error:
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 *         self.receive(entry)             # <<<<<<<<<<<<<<
 *         if is_error:
 *             self.last_error = entry
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_receive); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_entry));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_entry));
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":138
 *                 __GLOBAL_ERROR_LOG.last_error = entry
 *         self.receive(entry)
 *         if is_error:             # <<<<<<<<<<<<<<
 *             self.last_error = entry
 * 
 */
  __pyx_2 = __pyx_v_is_error;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":139
 *         self.receive(entry)
 *         if is_error:
 *             self.last_error = entry             # <<<<<<<<<<<<<<
 * 
 *     cdef _buildParseException(self, exctype, default_message):
 */
    Py_INCREF(((PyObject *)__pyx_v_entry));
    Py_DECREF(__pyx_v_self->last_error);
    __pyx_v_self->last_error = ((PyObject *)__pyx_v_entry);
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._BaseErrorLog._receiveGeneric");
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":141
 *             self.last_error = entry
 * 
 *     cdef _buildParseException(self, exctype, default_message):             # <<<<<<<<<<<<<<
 *         code = xmlerror.XML_ERR_INTERNAL_ERROR
 *         if self._first_error is None:
 */

static  PyObject *__pyx_f_4lxml_5etree_13_BaseErrorLog__buildParseException(struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_self, PyObject *__pyx_v_exctype, PyObject *__pyx_v_default_message) {
  PyObject *__pyx_v_code;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_line;
  PyObject *__pyx_v_column;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_code = Py_None; Py_INCREF(Py_None);
  __pyx_v_message = Py_None; Py_INCREF(Py_None);
  __pyx_v_line = Py_None; Py_INCREF(Py_None);
  __pyx_v_column = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":142
 * 
 *     cdef _buildParseException(self, exctype, default_message):
 *         code = xmlerror.XML_ERR_INTERNAL_ERROR             # <<<<<<<<<<<<<<
 *         if self._first_error is None:
 *             return exctype(default_message, code, 0, 0)
 */
  __pyx_1 = PyInt_FromLong(XML_ERR_INTERNAL_ERROR); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_code);
  __pyx_v_code = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":143
 *     cdef _buildParseException(self, exctype, default_message):
 *         code = xmlerror.XML_ERR_INTERNAL_ERROR
 *         if self._first_error is None:             # <<<<<<<<<<<<<<
 *             return exctype(default_message, code, 0, 0)
 *         if self._first_error is None or \
 */
  __pyx_2 = (((PyObject *)__pyx_v_self->_first_error) == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":144
 *         code = xmlerror.XML_ERR_INTERNAL_ERROR
 *         if self._first_error is None:
 *             return exctype(default_message, code, 0, 0)             # <<<<<<<<<<<<<<
 *         if self._first_error is None or \
 *                 self._first_error.message is None or \
 */
    __pyx_1 = PyTuple_New(4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_default_message);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_default_message);
    Py_INCREF(__pyx_v_code);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_code);
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_1, 2, __pyx_int_0);
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_1, 3, __pyx_int_0);
    __pyx_3 = PyObject_Call(__pyx_v_exctype, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":145
 *         if self._first_error is None:
 *             return exctype(default_message, code, 0, 0)
 *         if self._first_error is None or \             # <<<<<<<<<<<<<<
 *                 self._first_error.message is None or \
 *                 not self._first_error.message:
 */
  __pyx_2 = (((PyObject *)__pyx_v_self->_first_error) == Py_None);
  if (!__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":146
 *             return exctype(default_message, code, 0, 0)
 *         if self._first_error is None or \
 *                 self._first_error.message is None or \             # <<<<<<<<<<<<<<
 *                 not self._first_error.message:
 *             message = default_message
 */
    __pyx_2 = (__pyx_v_self->_first_error->message == Py_None);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":147
 *         if self._first_error is None or \
 *                 self._first_error.message is None or \
 *                 not self._first_error.message:             # <<<<<<<<<<<<<<
 *             message = default_message
 *             line = 0
 */
      __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_first_error->message); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = (!__pyx_4);
    }
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":148
 *                 self._first_error.message is None or \
 *                 not self._first_error.message:
 *             message = default_message             # <<<<<<<<<<<<<<
 *             line = 0
 *             column = 0
 */
    Py_INCREF(__pyx_v_default_message);
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_v_default_message;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":149
 *                 not self._first_error.message:
 *             message = default_message
 *             line = 0             # <<<<<<<<<<<<<<
 *             column = 0
 *         else:
 */
    Py_INCREF(__pyx_int_0);
    Py_DECREF(__pyx_v_line);
    __pyx_v_line = __pyx_int_0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":150
 *             message = default_message
 *             line = 0
 *             column = 0             # <<<<<<<<<<<<<<
 *         else:
 *             message = self._first_error.message
 */
    Py_INCREF(__pyx_int_0);
    Py_DECREF(__pyx_v_column);
    __pyx_v_column = __pyx_int_0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":152
 *             column = 0
 *         else:
 *             message = self._first_error.message             # <<<<<<<<<<<<<<
 *             code = self._first_error.type
 *             line = self._first_error.line
 */
    Py_INCREF(__pyx_v_self->_first_error->message);
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_v_self->_first_error->message;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":153
 *         else:
 *             message = self._first_error.message
 *             code = self._first_error.type             # <<<<<<<<<<<<<<
 *             line = self._first_error.line
 *             column = self._first_error.column
 */
    Py_INCREF(__pyx_v_self->_first_error->type);
    Py_DECREF(__pyx_v_code);
    __pyx_v_code = __pyx_v_self->_first_error->type;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":154
 *             message = self._first_error.message
 *             code = self._first_error.type
 *             line = self._first_error.line             # <<<<<<<<<<<<<<
 *             column = self._first_error.column
 *             if line > 0:
 */
    Py_INCREF(__pyx_v_self->_first_error->line);
    Py_DECREF(__pyx_v_line);
    __pyx_v_line = __pyx_v_self->_first_error->line;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":155
 *             code = self._first_error.type
 *             line = self._first_error.line
 *             column = self._first_error.column             # <<<<<<<<<<<<<<
 *             if line > 0:
 *                 if column > 0:
 */
    Py_INCREF(__pyx_v_self->_first_error->column);
    Py_DECREF(__pyx_v_column);
    __pyx_v_column = __pyx_v_self->_first_error->column;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":156
 *             line = self._first_error.line
 *             column = self._first_error.column
 *             if line > 0:             # <<<<<<<<<<<<<<
 *                 if column > 0:
 *                     message = u"%s, line %d, column %d" % (message, line, column)
 */
    __pyx_1 = PyObject_RichCompare(__pyx_v_line, __pyx_int_0, Py_GT); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":157
 *             column = self._first_error.column
 *             if line > 0:
 *                 if column > 0:             # <<<<<<<<<<<<<<
 *                     message = u"%s, line %d, column %d" % (message, line, column)
 *                 else:
 */
      __pyx_3 = PyObject_RichCompare(__pyx_v_column, __pyx_int_0, Py_GT); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":158
 *             if line > 0:
 *                 if column > 0:
 *                     message = u"%s, line %d, column %d" % (message, line, column)             # <<<<<<<<<<<<<<
 *                 else:
 *                     message = u"%s, line %d" % (message, line)
 */
        __pyx_1 = PyTuple_New(3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_message);
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_message);
        Py_INCREF(__pyx_v_line);
        PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_line);
        Py_INCREF(__pyx_v_column);
        PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_column);
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_356), ((PyObject *)__pyx_1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
        Py_DECREF(__pyx_v_message);
        __pyx_v_message = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":160
 *                     message = u"%s, line %d, column %d" % (message, line, column)
 *                 else:
 *                     message = u"%s, line %d" % (message, line)             # <<<<<<<<<<<<<<
 *         return exctype(message, code, line, column)
 * 
 */
        __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_message);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
        Py_INCREF(__pyx_v_line);
        PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_line);
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_357), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
        Py_DECREF(__pyx_v_message);
        __pyx_v_message = __pyx_t_1;
        __pyx_t_1 = 0;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":161
 *                 else:
 *                     message = u"%s, line %d" % (message, line)
 *         return exctype(message, code, line, column)             # <<<<<<<<<<<<<<
 * 
 *     cdef _buildExceptionMessage(self, default_message):
 */
  __pyx_1 = PyTuple_New(4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_message);
  Py_INCREF(__pyx_v_code);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_code);
  Py_INCREF(__pyx_v_line);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_line);
  Py_INCREF(__pyx_v_column);
  PyTuple_SET_ITEM(__pyx_1, 3, __pyx_v_column);
  __pyx_3 = PyObject_Call(__pyx_v_exctype, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._BaseErrorLog._buildParseException");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_code);
  Py_DECREF(__pyx_v_message);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_column);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":163
 *         return exctype(message, code, line, column)
 * 
 *     cdef _buildExceptionMessage(self, default_message):             # <<<<<<<<<<<<<<
 *         if self._first_error is None:
 *             return default_message
 */

static  PyObject *__pyx_f_4lxml_5etree_13_BaseErrorLog__buildExceptionMessage(struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_self, PyObject *__pyx_v_default_message) {
  PyObject *__pyx_v_message;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_message = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":164
 * 
 *     cdef _buildExceptionMessage(self, default_message):
 *         if self._first_error is None:             # <<<<<<<<<<<<<<
 *             return default_message
 *         if self._first_error.message is not None and self._first_error.message:
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_first_error) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":165
 *     cdef _buildExceptionMessage(self, default_message):
 *         if self._first_error is None:
 *             return default_message             # <<<<<<<<<<<<<<
 *         if self._first_error.message is not None and self._first_error.message:
 *             message = self._first_error.message
 */
    Py_INCREF(__pyx_v_default_message);
    __pyx_r = __pyx_v_default_message;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":166
 *         if self._first_error is None:
 *             return default_message
 *         if self._first_error.message is not None and self._first_error.message:             # <<<<<<<<<<<<<<
 *             message = self._first_error.message
 *         elif default_message is None:
 */
  __pyx_1 = (__pyx_v_self->_first_error->message != Py_None);
  if (__pyx_1) {
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->_first_error->message); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __pyx_2;
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":167
 *             return default_message
 *         if self._first_error.message is not None and self._first_error.message:
 *             message = self._first_error.message             # <<<<<<<<<<<<<<
 *         elif default_message is None:
 *             return None
 */
    Py_INCREF(__pyx_v_self->_first_error->message);
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_v_self->_first_error->message;
    goto __pyx_L4;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":168
 *         if self._first_error.message is not None and self._first_error.message:
 *             message = self._first_error.message
 *         elif default_message is None:             # <<<<<<<<<<<<<<
 *             return None
 *         else:
 */
  __pyx_2 = (__pyx_v_default_message == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":169
 *             message = self._first_error.message
 *         elif default_message is None:
 *             return None             # <<<<<<<<<<<<<<
 *         else:
 *             message = default_message
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":171
 *             return None
 *         else:
 *             message = default_message             # <<<<<<<<<<<<<<
 *         if self._first_error.line > 0:
 *             if self._first_error.column > 0:
 */
    Py_INCREF(__pyx_v_default_message);
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_v_default_message;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":172
 *         else:
 *             message = default_message
 *         if self._first_error.line > 0:             # <<<<<<<<<<<<<<
 *             if self._first_error.column > 0:
 *                 message = u"%s, line %d, column %d" % (
 */
  __pyx_3 = PyObject_RichCompare(__pyx_v_self->_first_error->line, __pyx_int_0, Py_GT); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":173
 *             message = default_message
 *         if self._first_error.line > 0:
 *             if self._first_error.column > 0:             # <<<<<<<<<<<<<<
 *                 message = u"%s, line %d, column %d" % (
 *                     message, self._first_error.line, self._first_error.column)
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_self->_first_error->column, __pyx_int_0, Py_GT); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":175
 *             if self._first_error.column > 0:
 *                 message = u"%s, line %d, column %d" % (
 *                     message, self._first_error.line, self._first_error.column)             # <<<<<<<<<<<<<<
 *             else:
 *                 message = u"%s, line %d" % (message, self._first_error.line)
 */
      __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
      Py_INCREF(__pyx_v_self->_first_error->line);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_self->_first_error->line);
      Py_INCREF(__pyx_v_self->_first_error->column);
      PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_self->_first_error->column);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_358), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":177
 *                     message, self._first_error.line, self._first_error.column)
 *             else:
 *                 message = u"%s, line %d" % (message, self._first_error.line)             # <<<<<<<<<<<<<<
 *         return message
 * 
 */
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
      Py_INCREF(__pyx_v_self->_first_error->line);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_self->_first_error->line);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_359), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":178
 *             else:
 *                 message = u"%s, line %d" % (message, self._first_error.line)
 *         return message             # <<<<<<<<<<<<<<
 * 
 * cdef class _ListErrorLog(_BaseErrorLog):
 */
  Py_INCREF(__pyx_v_message);
  __pyx_r = __pyx_v_message;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._BaseErrorLog._buildExceptionMessage");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_message);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":183
 *     u"Immutable base version of a list based error log."
 *     cdef object _entries
 *     def __init__(self, entries, first_error, last_error):             # <<<<<<<<<<<<<<
 *         if entries:
 *             if first_error is None:
 */

static int __pyx_pf_4lxml_5etree_13_ListErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_13_ListErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_entries = 0;
  PyObject *__pyx_v_first_error = 0;
  PyObject *__pyx_v_last_error = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_entries,&__pyx_kp_first_error,&__pyx_kp_last_error,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_entries);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_first_error);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_last_error);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_entries = values[0];
    __pyx_v_first_error = values[1];
    __pyx_v_last_error = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_entries = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_first_error = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_last_error = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_first_error);
  Py_INCREF(__pyx_v_last_error);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":184
 *     cdef object _entries
 *     def __init__(self, entries, first_error, last_error):
 *         if entries:             # <<<<<<<<<<<<<<
 *             if first_error is None:
 *                 first_error = entries[0]
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_entries); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":185
 *     def __init__(self, entries, first_error, last_error):
 *         if entries:
 *             if first_error is None:             # <<<<<<<<<<<<<<
 *                 first_error = entries[0]
 *             if last_error is None:
 */
    __pyx_1 = (__pyx_v_first_error == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":186
 *         if entries:
 *             if first_error is None:
 *                 first_error = entries[0]             # <<<<<<<<<<<<<<
 *             if last_error is None:
 *                 last_error = entries[-1]
 */
      __pyx_2 = __Pyx_GetItemInt(__pyx_v_entries, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_first_error);
      __pyx_v_first_error = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":187
 *             if first_error is None:
 *                 first_error = entries[0]
 *             if last_error is None:             # <<<<<<<<<<<<<<
 *                 last_error = entries[-1]
 *         _BaseErrorLog.__init__(self, first_error, last_error)
 */
    __pyx_1 = (__pyx_v_last_error == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":188
 *                 first_error = entries[0]
 *             if last_error is None:
 *                 last_error = entries[-1]             # <<<<<<<<<<<<<<
 *         _BaseErrorLog.__init__(self, first_error, last_error)
 *         self._entries = entries
 */
      __pyx_2 = __Pyx_GetItemInt(__pyx_v_entries, -1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_last_error);
      __pyx_v_last_error = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":189
 *             if last_error is None:
 *                 last_error = entries[-1]
 *         _BaseErrorLog.__init__(self, first_error, last_error)             # <<<<<<<<<<<<<<
 *         self._entries = entries
 * 
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseErrorLog)), __pyx_kp___init__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_first_error);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_first_error);
  Py_INCREF(__pyx_v_last_error);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_last_error);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":190
 *                 last_error = entries[-1]
 *         _BaseErrorLog.__init__(self, first_error, last_error)
 *         self._entries = entries             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  Py_INCREF(__pyx_v_entries);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries);
  ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries = __pyx_v_entries;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_first_error);
  Py_DECREF(__pyx_v_last_error);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":192
 *         self._entries = entries
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         u"""Creates a shallow copy of this error log.  Reuses the list of
 *         entries.
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_copy[] = "Creates a shallow copy of this error log.  Reuses the list of\n        entries.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":196
 *         entries.
 *         """
 *         return _ListErrorLog(self._entries, self._first_error, self.last_error)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_1 = PyTuple_New(3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries);
  PyTuple_SET_ITEM(__pyx_1, 0, ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries);
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->__pyx_base._first_error));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->__pyx_base._first_error));
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->__pyx_base.last_error);
  PyTuple_SET_ITEM(__pyx_1, 2, ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->__pyx_base.last_error);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":198
 *         return _ListErrorLog(self._entries, self._first_error, self.last_error)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self._entries)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":199
 * 
 *     def __iter__(self):
 *         return iter(self._entries)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":201
 *         return iter(self._entries)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         l = []
 *         for entry in self._entries:
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_l;
  PyObject *__pyx_v_entry;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  __pyx_v_l = Py_None; Py_INCREF(Py_None);
  __pyx_v_entry = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":202
 * 
 *     def __repr__(self):
 *         l = []             # <<<<<<<<<<<<<<
 *         for entry in self._entries:
 *             python.PyList_Append(l, repr(entry))
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_l);
  __pyx_v_l = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":203
 *     def __repr__(self):
 *         l = []
 *         for entry in self._entries:             # <<<<<<<<<<<<<<
 *             python.PyList_Append(l, repr(entry))
 *         return u'\n'.join(l)
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries)) {
    __pyx_2 = 0; __pyx_1 = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries; Py_INCREF(__pyx_1);
  } else {
    __pyx_2 = -1; __pyx_1 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_1, __pyx_2); Py_INCREF(__pyx_3); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_1, __pyx_2); Py_INCREF(__pyx_3); __pyx_2++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_entry);
    __pyx_v_entry = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":204
 *         l = []
 *         for entry in self._entries:
 *             python.PyList_Append(l, repr(entry))             # <<<<<<<<<<<<<<
 *         return u'\n'.join(l)
 * 
 */
    __pyx_3 = PyObject_Repr(__pyx_v_entry); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyList_Append(__pyx_v_l, __pyx_3); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":205
 *         for entry in self._entries:
 *             python.PyList_Append(l, repr(entry))
 *         return u'\n'.join(l)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, index):
 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_360), __pyx_kp_join); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_l);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_l);
  __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_l);
  Py_DECREF(__pyx_v_entry);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":207
 *         return u'\n'.join(l)
 * 
 *     def __getitem__(self, index):             # <<<<<<<<<<<<<<
 *         return self._entries[index]
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":208
 * 
 *     def __getitem__(self, index):
 *         return self._entries[index]             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_1 = PyObject_GetItem(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries, __pyx_v_index); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":210
 *         return self._entries[index]
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self._entries)
 * 
 */

static Py_ssize_t __pyx_pf_4lxml_5etree_13_ListErrorLog___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_4lxml_5etree_13_ListErrorLog___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  Py_ssize_t __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":211
 * 
 *     def __len__(self):
 *         return len(self._entries)             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, error_type):
 */
  __pyx_1 = PyObject_Length(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":213
 *         return len(self._entries)
 * 
 *     def __contains__(self, error_type):             # <<<<<<<<<<<<<<
 *         for entry in self._entries:
 *             if entry.type == error_type:
 */

static int __pyx_pf_4lxml_5etree_13_ListErrorLog___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_error_type); /*proto*/
static int __pyx_pf_4lxml_5etree_13_ListErrorLog___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_error_type) {
  PyObject *__pyx_v_entry;
  int __pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  __pyx_v_entry = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":214
 * 
 *     def __contains__(self, error_type):
 *         for entry in self._entries:             # <<<<<<<<<<<<<<
 *             if entry.type == error_type:
 *                 return True
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries)) {
    __pyx_1 = 0; __pyx_2 = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_entry);
    __pyx_v_entry = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":215
 *     def __contains__(self, error_type):
 *         for entry in self._entries:
 *             if entry.type == error_type:             # <<<<<<<<<<<<<<
 *                 return True
 *         return False
 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_entry, __pyx_kp_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_RichCompare(__pyx_3, __pyx_v_error_type, Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_5 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":216
 *         for entry in self._entries:
 *             if entry.type == error_type:
 *                 return True             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_r = 1;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":217
 *             if entry.type == error_type:
 *                 return True
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__contains__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":219
 *         return False
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         cdef bint result
 *         result = self._entries
 */

static int __pyx_pf_4lxml_5etree_13_ListErrorLog___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lxml_5etree_13_ListErrorLog___nonzero__(PyObject *__pyx_v_self) {
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":221
 *     def __nonzero__(self):
 *         cdef bint result
 *         result = self._entries             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely((__pyx_1 == (int)-1))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_result = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":222
 *         cdef bint result
 *         result = self._entries
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def filter_domains(self, domains):
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.__nonzero__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":224
 *         return result
 * 
 *     def filter_domains(self, domains):             # <<<<<<<<<<<<<<
 *         u"""Filter the errors by the given domains and return a new error log
 *         containing the matches.
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_domains(PyObject *__pyx_v_self, PyObject *__pyx_v_domains); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_domains[] = "Filter the errors by the given domains and return a new error log\n        containing the matches.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_domains(PyObject *__pyx_v_self, PyObject *__pyx_v_domains) {
  struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_entry;
  PyObject *__pyx_v_filtered;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF(__pyx_v_domains);
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filtered = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":229
 *         """
 *         cdef _LogEntry entry
 *         filtered = []             # <<<<<<<<<<<<<<
 *         if not python.PySequence_Check(domains):
 *             domains = (domains,)
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_filtered);
  __pyx_v_filtered = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":230
 *         cdef _LogEntry entry
 *         filtered = []
 *         if not python.PySequence_Check(domains):             # <<<<<<<<<<<<<<
 *             domains = (domains,)
 *         for entry in self._entries:
 */
  __pyx_2 = (!PySequence_Check(__pyx_v_domains));
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":231
 *         filtered = []
 *         if not python.PySequence_Check(domains):
 *             domains = (domains,)             # <<<<<<<<<<<<<<
 *         for entry in self._entries:
 *             if entry.domain in domains:
 */
    __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_domains);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_domains);
    Py_DECREF(__pyx_v_domains);
    __pyx_v_domains = ((PyObject *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":232
 *         if not python.PySequence_Check(domains):
 *             domains = (domains,)
 *         for entry in self._entries:             # <<<<<<<<<<<<<<
 *             if entry.domain in domains:
 *                 python.PyList_Append(filtered, entry)
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries)) {
    __pyx_3 = 0; __pyx_1 = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries; Py_INCREF(__pyx_1);
  } else {
    __pyx_3 = -1; __pyx_1 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_1);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_entry));
    __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":233
 *             domains = (domains,)
 *         for entry in self._entries:
 *             if entry.domain in domains:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)
 */
    __pyx_2 = (PySequence_Contains(__pyx_v_domains, __pyx_v_entry->domain)); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":234
 *         for entry in self._entries:
 *             if entry.domain in domains:
 *                 python.PyList_Append(filtered, entry)             # <<<<<<<<<<<<<<
 *         return _ListErrorLog(filtered, None, None)
 * 
 */
      __pyx_5 = PyList_Append(__pyx_v_filtered, ((PyObject *)__pyx_v_entry)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":235
 *             if entry.domain in domains:
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)             # <<<<<<<<<<<<<<
 * 
 *     def filter_types(self, types):
 */
  __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_filtered);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_filtered);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 2, Py_None);
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_domains");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
  Py_DECREF(__pyx_v_filtered);
  Py_DECREF(__pyx_v_domains);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":237
 *         return _ListErrorLog(filtered, None, None)
 * 
 *     def filter_types(self, types):             # <<<<<<<<<<<<<<
 *         u"""filter_types(self, types)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_types[] = "filter_types(self, types)\n\n        Filter the errors by the given types and return a new error\n        log containing the matches.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_types(PyObject *__pyx_v_self, PyObject *__pyx_v_types) {
  struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_entry;
  PyObject *__pyx_v_filtered;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF(__pyx_v_types);
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filtered = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":244
 *         """
 *         cdef _LogEntry entry
 *         if not python.PySequence_Check(types):             # <<<<<<<<<<<<<<
 *             types = (types,)
 *         filtered = []
 */
  __pyx_1 = (!PySequence_Check(__pyx_v_types));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":245
 *         cdef _LogEntry entry
 *         if not python.PySequence_Check(types):
 *             types = (types,)             # <<<<<<<<<<<<<<
 *         filtered = []
 *         for entry in self._entries:
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_types);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_types);
    Py_DECREF(__pyx_v_types);
    __pyx_v_types = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":246
 *         if not python.PySequence_Check(types):
 *             types = (types,)
 *         filtered = []             # <<<<<<<<<<<<<<
 *         for entry in self._entries:
 *             if entry.type in types:
 */
  __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_filtered);
  __pyx_v_filtered = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":247
 *             types = (types,)
 *         filtered = []
 *         for entry in self._entries:             # <<<<<<<<<<<<<<
 *             if entry.type in types:
 *                 python.PyList_Append(filtered, entry)
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries)) {
    __pyx_3 = 0; __pyx_2 = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries; Py_INCREF(__pyx_2);
  } else {
    __pyx_3 = -1; __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_2);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_entry));
    __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":248
 *         filtered = []
 *         for entry in self._entries:
 *             if entry.type in types:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)
 */
    __pyx_1 = (PySequence_Contains(__pyx_v_types, __pyx_v_entry->type)); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":249
 *         for entry in self._entries:
 *             if entry.type in types:
 *                 python.PyList_Append(filtered, entry)             # <<<<<<<<<<<<<<
 *         return _ListErrorLog(filtered, None, None)
 * 
 */
      __pyx_5 = PyList_Append(__pyx_v_filtered, ((PyObject *)__pyx_v_entry)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":250
 *             if entry.type in types:
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)             # <<<<<<<<<<<<<<
 * 
 *     def filter_levels(self, levels):
 */
  __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_filtered);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_filtered);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 2, Py_None);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_types");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
  Py_DECREF(__pyx_v_filtered);
  Py_DECREF(__pyx_v_types);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":252
 *         return _ListErrorLog(filtered, None, None)
 * 
 *     def filter_levels(self, levels):             # <<<<<<<<<<<<<<
 *         u"""filter_levels(self, levels)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_levels(PyObject *__pyx_v_self, PyObject *__pyx_v_levels); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_levels[] = "filter_levels(self, levels)\n\n        Filter the errors by the given error levels and return a new\n        error log containing the matches.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_levels(PyObject *__pyx_v_self, PyObject *__pyx_v_levels) {
  struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_entry;
  PyObject *__pyx_v_filtered;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF(__pyx_v_levels);
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filtered = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":259
 *         """
 *         cdef _LogEntry entry
 *         if not python.PySequence_Check(levels):             # <<<<<<<<<<<<<<
 *             levels = (levels,)
 *         filtered = []
 */
  __pyx_1 = (!PySequence_Check(__pyx_v_levels));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":260
 *         cdef _LogEntry entry
 *         if not python.PySequence_Check(levels):
 *             levels = (levels,)             # <<<<<<<<<<<<<<
 *         filtered = []
 *         for entry in self._entries:
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_levels);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_levels);
    Py_DECREF(__pyx_v_levels);
    __pyx_v_levels = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":261
 *         if not python.PySequence_Check(levels):
 *             levels = (levels,)
 *         filtered = []             # <<<<<<<<<<<<<<
 *         for entry in self._entries:
 *             if entry.level in levels:
 */
  __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_filtered);
  __pyx_v_filtered = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":262
 *             levels = (levels,)
 *         filtered = []
 *         for entry in self._entries:             # <<<<<<<<<<<<<<
 *             if entry.level in levels:
 *                 python.PyList_Append(filtered, entry)
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries)) {
    __pyx_3 = 0; __pyx_2 = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries; Py_INCREF(__pyx_2);
  } else {
    __pyx_3 = -1; __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_2);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_entry));
    __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":263
 *         filtered = []
 *         for entry in self._entries:
 *             if entry.level in levels:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)
 */
    __pyx_1 = (PySequence_Contains(__pyx_v_levels, __pyx_v_entry->level)); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":264
 *         for entry in self._entries:
 *             if entry.level in levels:
 *                 python.PyList_Append(filtered, entry)             # <<<<<<<<<<<<<<
 *         return _ListErrorLog(filtered, None, None)
 * 
 */
      __pyx_5 = PyList_Append(__pyx_v_filtered, ((PyObject *)__pyx_v_entry)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":265
 *             if entry.level in levels:
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)             # <<<<<<<<<<<<<<
 * 
 *     def filter_from_level(self, level):
 */
  __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_filtered);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_filtered);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 2, Py_None);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_levels");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
  Py_DECREF(__pyx_v_filtered);
  Py_DECREF(__pyx_v_levels);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":267
 *         return _ListErrorLog(filtered, None, None)
 * 
 *     def filter_from_level(self, level):             # <<<<<<<<<<<<<<
 *         u"""filter_from_level(self, level)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_level(PyObject *__pyx_v_self, PyObject *__pyx_v_level); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_level[] = "filter_from_level(self, level)\n\n        Return a log with all messages of the requested level of worse.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_level(PyObject *__pyx_v_self, PyObject *__pyx_v_level) {
  struct __pyx_obj_4lxml_5etree__LogEntry *__pyx_v_entry;
  PyObject *__pyx_v_filtered;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filtered = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":273
 *         """
 *         cdef _LogEntry entry
 *         filtered = []             # <<<<<<<<<<<<<<
 *         for entry in self._entries:
 *             if entry.level >= level:
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_filtered);
  __pyx_v_filtered = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":274
 *         cdef _LogEntry entry
 *         filtered = []
 *         for entry in self._entries:             # <<<<<<<<<<<<<<
 *             if entry.level >= level:
 *                 python.PyList_Append(filtered, entry)
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries)) {
    __pyx_2 = 0; __pyx_1 = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries; Py_INCREF(__pyx_1);
  } else {
    __pyx_2 = -1; __pyx_1 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ListErrorLog *)__pyx_v_self)->_entries); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_1, __pyx_2); Py_INCREF(__pyx_3); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_1, __pyx_2); Py_INCREF(__pyx_3); __pyx_2++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_entry));
    __pyx_v_entry = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_3);
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":275
 *         filtered = []
 *         for entry in self._entries:
 *             if entry.level >= level:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_entry->level, __pyx_v_level, Py_GE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":276
 *         for entry in self._entries:
 *             if entry.level >= level:
 *                 python.PyList_Append(filtered, entry)             # <<<<<<<<<<<<<<
 *         return _ListErrorLog(filtered, None, None)
 * 
 */
      __pyx_5 = PyList_Append(__pyx_v_filtered, ((PyObject *)__pyx_v_entry)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":277
 *             if entry.level >= level:
 *                 python.PyList_Append(filtered, entry)
 *         return _ListErrorLog(filtered, None, None)             # <<<<<<<<<<<<<<
 * 
 *     def filter_from_fatals(self):
 */
  __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_filtered);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_filtered);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_3, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_3, 2, Py_None);
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_from_level");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry);
  Py_DECREF(__pyx_v_filtered);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":279
 *         return _ListErrorLog(filtered, None, None)
 * 
 *     def filter_from_fatals(self):             # <<<<<<<<<<<<<<
 *         u"""filter_from_fatals(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_fatals(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_fatals[] = "filter_from_fatals(self)\n\n        Convenience method to get all fatal error messages.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_fatals(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":284
 *         Convenience method to get all fatal error messages.
 *         """
 *         return self.filter_from_level(ErrorLevels.FATAL)             # <<<<<<<<<<<<<<
 * 
 *     def filter_from_errors(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_filter_from_level); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_FATAL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_from_fatals");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":286
 *         return self.filter_from_level(ErrorLevels.FATAL)
 * 
 *     def filter_from_errors(self):             # <<<<<<<<<<<<<<
 *         u"""filter_from_errors(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_errors(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_errors[] = "filter_from_errors(self)\n\n        Convenience method to get all error messages or worse.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_errors(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":291
 *         Convenience method to get all error messages or worse.
 *         """
 *         return self.filter_from_level(ErrorLevels.ERROR)             # <<<<<<<<<<<<<<
 * 
 *     def filter_from_warnings(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_filter_from_level); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_ERROR); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_from_errors");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":293
 *         return self.filter_from_level(ErrorLevels.ERROR)
 * 
 *     def filter_from_warnings(self):             # <<<<<<<<<<<<<<
 *         u"""filter_from_warnings(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_warnings(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_warnings[] = "filter_from_warnings(self)\n\n        Convenience method to get all warnings or worse.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_warnings(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":298
 *         Convenience method to get all warnings or worse.
 *         """
 *         return self.filter_from_level(ErrorLevels.WARNING)             # <<<<<<<<<<<<<<
 * 
 * cdef class _ErrorLog(_ListErrorLog):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_filter_from_level); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_WARNING); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ListErrorLog.filter_from_warnings");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":301
 * 
 * cdef class _ErrorLog(_ListErrorLog):
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         _ListErrorLog.__init__(self, [], None, None)
 * 
 */

static int __pyx_pf_4lxml_5etree_9_ErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_9_ErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":302
 * cdef class _ErrorLog(_ListErrorLog):
 *     def __init__(self):
 *         _ListErrorLog.__init__(self, [], None, None)             # <<<<<<<<<<<<<<
 * 
 *     cdef void connect(self):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_2));
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_3, 2, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_3, 3, Py_None);
  __pyx_2 = 0;
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ErrorLog.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":304
 *         _ListErrorLog.__init__(self, [], None, None)
 * 
 *     cdef void connect(self):             # <<<<<<<<<<<<<<
 *         self._first_error = None
 *         del self._entries[:]
 */

static  void __pyx_f_4lxml_5etree_9_ErrorLog_connect(struct __pyx_obj_4lxml_5etree__ErrorLog *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":305
 * 
 *     cdef void connect(self):
 *         self._first_error = None             # <<<<<<<<<<<<<<
 *         del self._entries[:]
 *         connectErrorLog(<void*>self)
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._first_error));
  __pyx_v_self->__pyx_base.__pyx_base._first_error = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":306
 *     cdef void connect(self):
 *         self._first_error = None
 *         del self._entries[:]             # <<<<<<<<<<<<<<
 *         connectErrorLog(<void*>self)
 * 
 */
  if (PySequence_DelSlice(__pyx_v_self->__pyx_base._entries, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":307
 *         self._first_error = None
 *         del self._entries[:]
 *         connectErrorLog(<void*>self)             # <<<<<<<<<<<<<<
 * 
 *     cdef void disconnect(self):
 */
  __pyx_f_4lxml_5etree_connectErrorLog(((void *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("lxml.etree._ErrorLog.connect");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":309
 *         connectErrorLog(<void*>self)
 * 
 *     cdef void disconnect(self):             # <<<<<<<<<<<<<<
 *         connectErrorLog(NULL)
 * 
 */

static  void __pyx_f_4lxml_5etree_9_ErrorLog_disconnect(struct __pyx_obj_4lxml_5etree__ErrorLog *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":310
 * 
 *     cdef void disconnect(self):
 *         connectErrorLog(NULL)             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __pyx_f_4lxml_5etree_connectErrorLog(NULL);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":312
 *         connectErrorLog(NULL)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self._first_error = None
 *         del self._entries[:]
 */

static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog_clear(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog_clear(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":313
 * 
 *     def clear(self):
 *         self._first_error = None             # <<<<<<<<<<<<<<
 *         del self._entries[:]
 * 
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error));
  ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":314
 *     def clear(self):
 *         self._first_error = None
 *         del self._entries[:]             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  if (PySequence_DelSlice(((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base._entries, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ErrorLog.clear");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":316
 *         del self._entries[:]
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         u"""Creates a shallow copy of this error log and the list of entries.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_9_ErrorLog_copy[] = "Creates a shallow copy of this error log and the list of entries.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":319
 *         u"""Creates a shallow copy of this error log and the list of entries.
 *         """
 *         return _ListErrorLog(self._entries[:], self._first_error,             # <<<<<<<<<<<<<<
 *                              self.last_error)
 * 
 */
  __pyx_1 = PySequence_GetSlice(((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base._entries, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":320
 *         """
 *         return _ListErrorLog(self._entries[:], self._first_error,
 *                              self.last_error)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error));
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base.last_error);
  PyTuple_SET_ITEM(__pyx_2, 2, ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base.last_error);
  __pyx_1 = 0;
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ErrorLog.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":322
 *                              self.last_error)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self._entries[:])
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":323
 * 
 *     def __iter__(self):
 *         return iter(self._entries[:])             # <<<<<<<<<<<<<<
 * 
 *     def receive(self, entry):
 */
  __pyx_1 = PySequence_GetSlice(((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base._entries, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ErrorLog.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":325
 *         return iter(self._entries[:])
 * 
 *     def receive(self, entry):             # <<<<<<<<<<<<<<
 *         if self._first_error is None:
 *             self._first_error = entry
 */

static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9_ErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":326
 * 
 *     def receive(self, entry):
 *         if self._first_error is None:             # <<<<<<<<<<<<<<
 *             self._first_error = entry
 *         python.PyList_Append(self._entries, entry)
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":327
 *     def receive(self, entry):
 *         if self._first_error is None:
 *             self._first_error = entry             # <<<<<<<<<<<<<<
 *         python.PyList_Append(self._entries, entry)
 * 
 */
    if (!(__Pyx_TypeTest(__pyx_v_entry, __pyx_ptype_4lxml_5etree__LogEntry))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_entry);
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error));
    ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._first_error = ((struct __pyx_obj_4lxml_5etree__LogEntry *)__pyx_v_entry);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":328
 *         if self._first_error is None:
 *             self._first_error = entry
 *         python.PyList_Append(self._entries, entry)             # <<<<<<<<<<<<<<
 * 
 * cdef class _DomainErrorLog(_ErrorLog):
 */
  __pyx_2 = PyList_Append(((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_v_self)->__pyx_base._entries, __pyx_v_entry); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ErrorLog.receive");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":331
 * 
 * cdef class _DomainErrorLog(_ErrorLog):
 *     def __init__(self, domains):             # <<<<<<<<<<<<<<
 *         _ErrorLog.__init__(self)
 *         self._accepted_domains = tuple(domains)
 */

static int __pyx_pf_4lxml_5etree_15_DomainErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_15_DomainErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_domains = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_domains,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_domains);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_domains = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_domains = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._DomainErrorLog.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":332
 * cdef class _DomainErrorLog(_ErrorLog):
 *     def __init__(self, domains):
 *         _ErrorLog.__init__(self)             # <<<<<<<<<<<<<<
 *         self._accepted_domains = tuple(domains)
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":333
 *     def __init__(self, domains):
 *         _ErrorLog.__init__(self)
 *         self._accepted_domains = tuple(domains)             # <<<<<<<<<<<<<<
 * 
 *     def receive(self, entry):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_domains);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_domains);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)&PyTuple_Type)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_v_self, __pyx_kp__accepted_domains, __pyx_2) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._DomainErrorLog.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":335
 *         self._accepted_domains = tuple(domains)
 * 
 *     def receive(self, entry):             # <<<<<<<<<<<<<<
 *         if entry.domain in self._accepted_domains:
 *             _ErrorLog.receive(self, entry)
 */

static PyObject *__pyx_pf_4lxml_5etree_15_DomainErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_15_DomainErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":336
 * 
 *     def receive(self, entry):
 *         if entry.domain in self._accepted_domains:             # <<<<<<<<<<<<<<
 *             _ErrorLog.receive(self, entry)
 * 
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_entry, __pyx_kp_domain); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__accepted_domains); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = (PySequence_Contains(__pyx_2, __pyx_1)); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":337
 *     def receive(self, entry):
 *         if entry.domain in self._accepted_domains:
 *             _ErrorLog.receive(self, entry)             # <<<<<<<<<<<<<<
 * 
 * cdef class _RotatingErrorLog(_ErrorLog):
 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), __pyx_kp_receive); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    Py_INCREF(__pyx_v_entry);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_entry);
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._DomainErrorLog.receive");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":341
 * cdef class _RotatingErrorLog(_ErrorLog):
 *     cdef int _max_len
 *     def __init__(self, max_len):             # <<<<<<<<<<<<<<
 *         _ErrorLog.__init__(self)
 *         self._max_len = max_len
 */

static int __pyx_pf_4lxml_5etree_17_RotatingErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_17_RotatingErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_max_len = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_max_len,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_max_len);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_max_len = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_max_len = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._RotatingErrorLog.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":342
 *     cdef int _max_len
 *     def __init__(self, max_len):
 *         _ErrorLog.__init__(self)             # <<<<<<<<<<<<<<
 *         self._max_len = max_len
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":343
 *     def __init__(self, max_len):
 *         _ErrorLog.__init__(self)
 *         self._max_len = max_len             # <<<<<<<<<<<<<<
 * 
 *     def receive(self, entry):
 */
  __pyx_4 = __pyx_PyInt_int(__pyx_v_max_len); if (unlikely((__pyx_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree__RotatingErrorLog *)__pyx_v_self)->_max_len = __pyx_4;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._RotatingErrorLog.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":345
 *         self._max_len = max_len
 * 
 *     def receive(self, entry):             # <<<<<<<<<<<<<<
 *         entries = self._entries
 *         if python.PyList_GET_SIZE(entries) > self._max_len:
 */

static PyObject *__pyx_pf_4lxml_5etree_17_RotatingErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_17_RotatingErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry) {
  PyObject *__pyx_v_entries;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  __pyx_v_entries = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":346
 * 
 *     def receive(self, entry):
 *         entries = self._entries             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(entries) > self._max_len:
 *             del entries[0]
 */
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__RotatingErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._entries);
  Py_DECREF(__pyx_v_entries);
  __pyx_v_entries = ((struct __pyx_obj_4lxml_5etree__RotatingErrorLog *)__pyx_v_self)->__pyx_base.__pyx_base._entries;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":347
 *     def receive(self, entry):
 *         entries = self._entries
 *         if python.PyList_GET_SIZE(entries) > self._max_len:             # <<<<<<<<<<<<<<
 *             del entries[0]
 *         python.PyList_Append(entries, entry)
 */
  __pyx_1 = (PyList_GET_SIZE(__pyx_v_entries) > ((struct __pyx_obj_4lxml_5etree__RotatingErrorLog *)__pyx_v_self)->_max_len);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":348
 *         entries = self._entries
 *         if python.PyList_GET_SIZE(entries) > self._max_len:
 *             del entries[0]             # <<<<<<<<<<<<<<
 *         python.PyList_Append(entries, entry)
 * 
 */
    if (__Pyx_DelItemInt(__pyx_v_entries, 0, 0) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":349
 *         if python.PyList_GET_SIZE(entries) > self._max_len:
 *             del entries[0]
 *         python.PyList_Append(entries, entry)             # <<<<<<<<<<<<<<
 * 
 * cdef class PyErrorLog(_BaseErrorLog):
 */
  __pyx_2 = PyList_Append(__pyx_v_entries, __pyx_v_entry); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._RotatingErrorLog.receive");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entries);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":373
 *     cdef object _map_level
 *     cdef object _log
 *     def __init__(self, logger_name=None):             # <<<<<<<<<<<<<<
 *         _BaseErrorLog.__init__(self, None, None)
 *         import logging
 */

static int __pyx_pf_4lxml_5etree_10PyErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_10PyErrorLog___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_logger_name = 0;
  PyObject *__pyx_v_logging;
  PyObject *__pyx_v_logger;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_logger_name,0};
  __pyx_v_logger_name = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_logger_name = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_logger_name = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.PyErrorLog.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_logging = Py_None; Py_INCREF(Py_None);
  __pyx_v_logger = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":374
 *     cdef object _log
 *     def __init__(self, logger_name=None):
 *         _BaseErrorLog.__init__(self, None, None)             # <<<<<<<<<<<<<<
 *         import logging
 *         self.level_map = {
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseErrorLog)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_2, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_2, 2, Py_None);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":375
 *     def __init__(self, logger_name=None):
 *         _BaseErrorLog.__init__(self, None, None)
 *         import logging             # <<<<<<<<<<<<<<
 *         self.level_map = {
 *             ErrorLevels.WARNING : logging.WARNING,
 */
  __pyx_1 = __Pyx_Import(__pyx_kp_logging, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_logging);
  __pyx_v_logging = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":376
 *         _BaseErrorLog.__init__(self, None, None)
 *         import logging
 *         self.level_map = {             # <<<<<<<<<<<<<<
 *             ErrorLevels.WARNING : logging.WARNING,
 *             ErrorLevels.ERROR   : logging.ERROR,
 */
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":377
 *         import logging
 *         self.level_map = {
 *             ErrorLevels.WARNING : logging.WARNING,             # <<<<<<<<<<<<<<
 *             ErrorLevels.ERROR   : logging.ERROR,
 *             ErrorLevels.FATAL   : logging.CRITICAL
 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_kp_WARNING); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyObject_GetAttr(__pyx_v_logging, __pyx_kp_WARNING); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_1, __pyx_3) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":378
 *         self.level_map = {
 *             ErrorLevels.WARNING : logging.WARNING,
 *             ErrorLevels.ERROR   : logging.ERROR,             # <<<<<<<<<<<<<<
 *             ErrorLevels.FATAL   : logging.CRITICAL
 *             }
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_kp_ERROR); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_logging, __pyx_kp_ERROR); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_3, __pyx_1) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":379
 *             ErrorLevels.WARNING : logging.WARNING,
 *             ErrorLevels.ERROR   : logging.ERROR,
 *             ErrorLevels.FATAL   : logging.CRITICAL             # <<<<<<<<<<<<<<
 *             }
 *         self._map_level = self.level_map.get
 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_kp_FATAL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyObject_GetAttr(__pyx_v_logging, __pyx_kp_CRITICAL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_1, __pyx_3) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":376
 *         _BaseErrorLog.__init__(self, None, None)
 *         import logging
 *         self.level_map = {             # <<<<<<<<<<<<<<
 *             ErrorLevels.WARNING : logging.WARNING,
 *             ErrorLevels.ERROR   : logging.ERROR,
 */
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->level_map);
  ((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->level_map = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":381
 *             ErrorLevels.FATAL   : logging.CRITICAL
 *             }
 *         self._map_level = self.level_map.get             # <<<<<<<<<<<<<<
 *         if logger_name:
 *             logger = logging.getLogger(logger_name)
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->level_map, __pyx_kp_get); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->_map_level);
  ((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->_map_level = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":382
 *             }
 *         self._map_level = self.level_map.get
 *         if logger_name:             # <<<<<<<<<<<<<<
 *             logger = logging.getLogger(logger_name)
 *         else:
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_v_logger_name); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":383
 *         self._map_level = self.level_map.get
 *         if logger_name:
 *             logger = logging.getLogger(logger_name)             # <<<<<<<<<<<<<<
 *         else:
 *             logger = logging.getLogger()
 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_logging, __pyx_kp_getLogger); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_logger_name);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_logger_name);
    __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_logger);
    __pyx_v_logger = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":385
 *             logger = logging.getLogger(logger_name)
 *         else:
 *             logger = logging.getLogger()             # <<<<<<<<<<<<<<
 *         self._log = logger.log
 * 
 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_logging, __pyx_kp_getLogger); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_logger);
    __pyx_v_logger = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":386
 *         else:
 *             logger = logging.getLogger()
 *         self._log = logger.log             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_logger, __pyx_kp_log); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->_log);
  ((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->_log = __pyx_1;
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.PyErrorLog.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_logging);
  Py_DECREF(__pyx_v_logger);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":388
 *         self._log = logger.log
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         u"""Dummy method that returns an empty error log.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_10PyErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_10PyErrorLog_copy[] = "Dummy method that returns an empty error log.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_10PyErrorLog_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":391
 *         u"""Dummy method that returns an empty error log.
 *         """
 *         return _ListErrorLog([], None, None)             # <<<<<<<<<<<<<<
 * 
 *     def log(self, entry, message_format_string, *args):
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_1));
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_2, 1, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_2, 2, Py_None);
  __pyx_1 = 0;
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ListErrorLog)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.PyErrorLog.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":393
 *         return _ListErrorLog([], None, None)
 * 
 *     def log(self, entry, message_format_string, *args):             # <<<<<<<<<<<<<<
 *         self._log(
 *             self._map_level(entry.level, 0),
 */

static PyObject *__pyx_pf_4lxml_5etree_10PyErrorLog_log(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_10PyErrorLog_log(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_entry = 0;
  PyObject *__pyx_v_message_format_string = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_entry,&__pyx_kp_35,0};
  if (PyTuple_GET_SIZE(__pyx_args) > 2) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args)); if (unlikely(!__pyx_v_args)) return NULL;
  } else {
    __pyx_v_args = __pyx_empty_tuple; Py_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_entry);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_35);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("log", 0, 2, 2, 1); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 2) ? PyTuple_GET_SIZE(__pyx_args) : 2;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "log") < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_entry = values[0];
    __pyx_v_message_format_string = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_entry = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_message_format_string = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("log", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("lxml.etree.PyErrorLog.log");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":395
 *     def log(self, entry, message_format_string, *args):
 *         self._log(
 *             self._map_level(entry.level, 0),             # <<<<<<<<<<<<<<
 *             message_format_string, *args
 *             )
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_entry, __pyx_kp_level); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_int_0);
  __pyx_1 = 0;
  __pyx_1 = PyObject_Call(((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->_map_level, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":396
 *         self._log(
 *             self._map_level(entry.level, 0),
 *             message_format_string, *args             # <<<<<<<<<<<<<<
 *             )
 * 
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_v_message_format_string);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_message_format_string);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":397
 *             self._map_level(entry.level, 0),
 *             message_format_string, *args
 *             )             # <<<<<<<<<<<<<<
 * 
 *     def receive(self, entry):
 */
  __pyx_1 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_2), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyObject_Call(((struct __pyx_obj_4lxml_5etree_PyErrorLog *)__pyx_v_self)->_log, __pyx_t_1, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.PyErrorLog.log");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_args);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":399
 *             )
 * 
 *     def receive(self, entry):             # <<<<<<<<<<<<<<
 *         self.log(entry, entry)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_10PyErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_10PyErrorLog_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_entry) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":400
 * 
 *     def receive(self, entry):
 *         self.log(entry, entry)             # <<<<<<<<<<<<<<
 * 
 * # global list log to collect error output messages from libxml2/libxslt
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_log); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_entry);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_entry);
  Py_INCREF(__pyx_v_entry);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_entry);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.PyErrorLog.receive");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":406
 * __GLOBAL_ERROR_LOG = _RotatingErrorLog(__MAX_LOG_SIZE)
 * 
 * cdef __copyGlobalErrorLog():             # <<<<<<<<<<<<<<
 *     u"Helper function for properties in exceptions."
 *     return __GLOBAL_ERROR_LOG.copy()
 */

static  PyObject *__pyx_f_4lxml_5etree___copyGlobalErrorLog(void) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":408
 * cdef __copyGlobalErrorLog():
 *     u"Helper function for properties in exceptions."
 *     return __GLOBAL_ERROR_LOG.copy()             # <<<<<<<<<<<<<<
 * 
 * def use_global_python_log(PyErrorLog log not None):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.__copyGlobalErrorLog");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":410
 *     return __GLOBAL_ERROR_LOG.copy()
 * 
 * def use_global_python_log(PyErrorLog log not None):             # <<<<<<<<<<<<<<
 *     u"""use_global_python_log(log)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_use_global_python_log(PyObject *__pyx_self, PyObject *__pyx_v_log); /*proto*/
static char __pyx_doc_4lxml_5etree_use_global_python_log[] = "use_global_python_log(log)\n\n    Replace the global error log by an etree.PyErrorLog that uses the\n    standard Python logging package.\n\n    Note that this disables access to the global error log from exceptions.\n    Parsers, XSLT etc. will continue to provide their normal local error log.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_use_global_python_log(PyObject *__pyx_self, PyObject *__pyx_v_log) {
  PyObject *__pyx_r;
  __pyx_self = __pyx_self;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_log), __pyx_ptype_4lxml_5etree_PyErrorLog, 0, "log", 0))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":420
 *     """
 *     global __GLOBAL_ERROR_LOG
 *     __GLOBAL_ERROR_LOG = log             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_log);
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG));
  __pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_log);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.use_global_python_log");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":424
 * 
 * # local log functions: forward error to logger object
 * cdef void _forwardError(void* c_log_handler, xmlerror.xmlError* error) with gil:             # <<<<<<<<<<<<<<
 *     cdef _BaseErrorLog log_handler
 *     if c_log_handler is not NULL:
 */

static  void __pyx_f_4lxml_5etree__forwardError(void *__pyx_v_c_log_handler, xmlError *__pyx_v_error) {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_log_handler;
  int __pyx_1;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_log_handler = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":426
 * cdef void _forwardError(void* c_log_handler, xmlerror.xmlError* error) with gil:
 *     cdef _BaseErrorLog log_handler
 *     if c_log_handler is not NULL:             # <<<<<<<<<<<<<<
 *         log_handler = <_BaseErrorLog>c_log_handler
 *     else:
 */
  __pyx_1 = (__pyx_v_c_log_handler != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":427
 *     cdef _BaseErrorLog log_handler
 *     if c_log_handler is not NULL:
 *         log_handler = <_BaseErrorLog>c_log_handler             # <<<<<<<<<<<<<<
 *     else:
 *         log_handler = __GLOBAL_ERROR_LOG
 */
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_c_log_handler)));
    Py_DECREF(((PyObject *)__pyx_v_log_handler));
    __pyx_v_log_handler = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_c_log_handler);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":429
 *         log_handler = <_BaseErrorLog>c_log_handler
 *     else:
 *         log_handler = __GLOBAL_ERROR_LOG             # <<<<<<<<<<<<<<
 *     log_handler._receive(error)
 * 
 */
    Py_INCREF(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG));
    Py_DECREF(((PyObject *)__pyx_v_log_handler));
    __pyx_v_log_handler = __pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":430
 *     else:
 *         log_handler = __GLOBAL_ERROR_LOG
 *     log_handler._receive(error)             # <<<<<<<<<<<<<<
 * 
 * cdef void _receiveError(void* c_log_handler, xmlerror.xmlError* error) nogil:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog *)__pyx_v_log_handler->__pyx_vtab)->_receive(__pyx_v_log_handler, __pyx_v_error);

  Py_DECREF(__pyx_v_log_handler);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":432
 *     log_handler._receive(error)
 * 
 * cdef void _receiveError(void* c_log_handler, xmlerror.xmlError* error) nogil:             # <<<<<<<<<<<<<<
 *     # no Python objects here, may be called without thread context !
 *     # when we declare a Python object, Pyrex will INCREF(None) !
 */

static  void __pyx_f_4lxml_5etree__receiveError(void *__pyx_v_c_log_handler, xmlError *__pyx_v_error) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":435
 *     # no Python objects here, may be called without thread context !
 *     # when we declare a Python object, Pyrex will INCREF(None) !
 *     if __DEBUG != 0:             # <<<<<<<<<<<<<<
 *         _forwardError(c_log_handler, error)
 * 
 */
  __pyx_1 = (1 != 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":436
 *     # when we declare a Python object, Pyrex will INCREF(None) !
 *     if __DEBUG != 0:
 *         _forwardError(c_log_handler, error)             # <<<<<<<<<<<<<<
 * 
 * cdef void _receiveXSLTError(void* c_log_handler, char* msg, ...) nogil:
 */
    __pyx_f_4lxml_5etree__forwardError(__pyx_v_c_log_handler, __pyx_v_error);
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":438
 *         _forwardError(c_log_handler, error)
 * 
 * cdef void _receiveXSLTError(void* c_log_handler, char* msg, ...) nogil:             # <<<<<<<<<<<<<<
 *     # no Python objects here, may be called without thread context !
 *     # when we declare a Python object, Pyrex will INCREF(None) !
 */

static  void __pyx_f_4lxml_5etree__receiveXSLTError(void *__pyx_v_c_log_handler, char *__pyx_v_msg, ...) {
  xmlError __pyx_v_c_error;
  va_list __pyx_v_args;
  char *__pyx_v_c_text;
  char *__pyx_v_c_message;
  char *__pyx_v_c_element;
  int __pyx_v_text_size;
  int __pyx_v_element_size;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":447
 *     cdef char* c_element
 *     cdef int i, text_size, element_size
 *     if __DEBUG == 0 or msg is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     if msg[0] == c'\n' or msg[0] == c'\0':
 */
  __pyx_1 = (1 == 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_msg == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":448
 *     cdef int i, text_size, element_size
 *     if __DEBUG == 0 or msg is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     if msg[0] == c'\n' or msg[0] == c'\0':
 *         return
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":449
 *     if __DEBUG == 0 or msg is NULL:
 *         return
 *     if msg[0] == c'\n' or msg[0] == c'\0':             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_1 = ((__pyx_v_msg[0]) == '\n');
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_msg[0]) == '\x00');
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":450
 *         return
 *     if msg[0] == c'\n' or msg[0] == c'\0':
 *         return             # <<<<<<<<<<<<<<
 * 
 *     cstd.va_start(args, msg)
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":452
 *         return
 * 
 *     cstd.va_start(args, msg)             # <<<<<<<<<<<<<<
 *     if msg[0] == c'%' and msg[1] == c's':
 *         c_text = cstd.va_charptr(args)
 */
  va_start(__pyx_v_args, __pyx_v_msg);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":453
 * 
 *     cstd.va_start(args, msg)
 *     if msg[0] == c'%' and msg[1] == c's':             # <<<<<<<<<<<<<<
 *         c_text = cstd.va_charptr(args)
 *     else:
 */
  __pyx_1 = ((__pyx_v_msg[0]) == '%');
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_msg[1]) == 's');
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":454
 *     cstd.va_start(args, msg)
 *     if msg[0] == c'%' and msg[1] == c's':
 *         c_text = cstd.va_charptr(args)             # <<<<<<<<<<<<<<
 *     else:
 *         c_text = NULL
 */
    __pyx_v_c_text = va_charptr(__pyx_v_args);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":456
 *         c_text = cstd.va_charptr(args)
 *     else:
 *         c_text = NULL             # <<<<<<<<<<<<<<
 *     if cstd.strstr(msg, 'file %s'):
 *         c_error.file = cstd.va_charptr(args)
 */
    __pyx_v_c_text = NULL;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":457
 *     else:
 *         c_text = NULL
 *     if cstd.strstr(msg, 'file %s'):             # <<<<<<<<<<<<<<
 *         c_error.file = cstd.va_charptr(args)
 *         if c_error.file and \
 */
  __pyx_1 = (strstr(__pyx_v_msg, __pyx_k_361) != 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":458
 *         c_text = NULL
 *     if cstd.strstr(msg, 'file %s'):
 *         c_error.file = cstd.va_charptr(args)             # <<<<<<<<<<<<<<
 *         if c_error.file and \
 *                 cstd.strncmp(c_error.file,
 */
    __pyx_v_c_error.file = va_charptr(__pyx_v_args);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":459
 *     if cstd.strstr(msg, 'file %s'):
 *         c_error.file = cstd.va_charptr(args)
 *         if c_error.file and \             # <<<<<<<<<<<<<<
 *                 cstd.strncmp(c_error.file,
 *                             'string://__STRING__XSLT', 23) == 0:
 */
    __pyx_1 = (__pyx_v_c_error.file != 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":461
 *         if c_error.file and \
 *                 cstd.strncmp(c_error.file,
 *                             'string://__STRING__XSLT', 23) == 0:             # <<<<<<<<<<<<<<
 *             c_error.file = '<xslt>'
 *     else:
 */
      __pyx_1 = (strncmp(__pyx_v_c_error.file, __pyx_k_362, 23) == 0);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":462
 *                 cstd.strncmp(c_error.file,
 *                             'string://__STRING__XSLT', 23) == 0:
 *             c_error.file = '<xslt>'             # <<<<<<<<<<<<<<
 *     else:
 *         c_error.file = NULL
 */
      __pyx_v_c_error.file = __pyx_k_363;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":464
 *             c_error.file = '<xslt>'
 *     else:
 *         c_error.file = NULL             # <<<<<<<<<<<<<<
 *     if cstd.strstr(msg, 'line %d'):
 *         c_error.line = cstd.va_int(args)
 */
    __pyx_v_c_error.file = NULL;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":465
 *     else:
 *         c_error.file = NULL
 *     if cstd.strstr(msg, 'line %d'):             # <<<<<<<<<<<<<<
 *         c_error.line = cstd.va_int(args)
 *     else:
 */
  __pyx_1 = (strstr(__pyx_v_msg, __pyx_k_364) != 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":466
 *         c_error.file = NULL
 *     if cstd.strstr(msg, 'line %d'):
 *         c_error.line = cstd.va_int(args)             # <<<<<<<<<<<<<<
 *     else:
 *         c_error.line = 0
 */
    __pyx_v_c_error.line = va_int(__pyx_v_args);
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":468
 *         c_error.line = cstd.va_int(args)
 *     else:
 *         c_error.line = 0             # <<<<<<<<<<<<<<
 *     if cstd.strstr(msg, 'element %s'):
 *         c_element = cstd.va_charptr(args)
 */
    __pyx_v_c_error.line = 0;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":469
 *     else:
 *         c_error.line = 0
 *     if cstd.strstr(msg, 'element %s'):             # <<<<<<<<<<<<<<
 *         c_element = cstd.va_charptr(args)
 *     else:
 */
  __pyx_1 = (strstr(__pyx_v_msg, __pyx_k_365) != 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":470
 *         c_error.line = 0
 *     if cstd.strstr(msg, 'element %s'):
 *         c_element = cstd.va_charptr(args)             # <<<<<<<<<<<<<<
 *     else:
 *         c_element = NULL
 */
    __pyx_v_c_element = va_charptr(__pyx_v_args);
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":472
 *         c_element = cstd.va_charptr(args)
 *     else:
 *         c_element = NULL             # <<<<<<<<<<<<<<
 *     cstd.va_end(args)
 * 
 */
    __pyx_v_c_element = NULL;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":473
 *     else:
 *         c_element = NULL
 *     cstd.va_end(args)             # <<<<<<<<<<<<<<
 * 
 *     c_message = NULL
 */
  va_end(__pyx_v_args);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":475
 *     cstd.va_end(args)
 * 
 *     c_message = NULL             # <<<<<<<<<<<<<<
 *     if c_text is NULL:
 *         if c_element is not NULL and \
 */
  __pyx_v_c_message = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":476
 * 
 *     c_message = NULL
 *     if c_text is NULL:             # <<<<<<<<<<<<<<
 *         if c_element is not NULL and \
 *                 cstd.strchr(msg, c'%') == cstd.strrchr(msg, c'%'):
 */
  __pyx_1 = (__pyx_v_c_text == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":477
 *     c_message = NULL
 *     if c_text is NULL:
 *         if c_element is not NULL and \             # <<<<<<<<<<<<<<
 *                 cstd.strchr(msg, c'%') == cstd.strrchr(msg, c'%'):
 *             # special case: a single occurrence of 'element %s'
 */
    __pyx_1 = (__pyx_v_c_element != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":478
 *     if c_text is NULL:
 *         if c_element is not NULL and \
 *                 cstd.strchr(msg, c'%') == cstd.strrchr(msg, c'%'):             # <<<<<<<<<<<<<<
 *             # special case: a single occurrence of 'element %s'
 *             text_size    = cstd.strlen(msg)
 */
      __pyx_1 = (strchr(__pyx_v_msg, '%') == strrchr(__pyx_v_msg, '%'));
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":480
 *                 cstd.strchr(msg, c'%') == cstd.strrchr(msg, c'%'):
 *             # special case: a single occurrence of 'element %s'
 *             text_size    = cstd.strlen(msg)             # <<<<<<<<<<<<<<
 *             element_size = cstd.strlen(c_element)
 *             c_message = <char*>cstd.malloc(
 */
      __pyx_v_text_size = strlen(__pyx_v_msg);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":481
 *             # special case: a single occurrence of 'element %s'
 *             text_size    = cstd.strlen(msg)
 *             element_size = cstd.strlen(c_element)             # <<<<<<<<<<<<<<
 *             c_message = <char*>cstd.malloc(
 *                 (text_size + element_size + 1) * sizeof(char))
 */
      __pyx_v_element_size = strlen(__pyx_v_c_element);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":483
 *             element_size = cstd.strlen(c_element)
 *             c_message = <char*>cstd.malloc(
 *                 (text_size + element_size + 1) * sizeof(char))             # <<<<<<<<<<<<<<
 *             cstd.sprintf(c_message, msg, c_element)
 *             c_error.message = c_message
 */
      __pyx_v_c_message = ((char *)malloc((((__pyx_v_text_size + __pyx_v_element_size) + 1) * (sizeof(char)))));

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":484
 *             c_message = <char*>cstd.malloc(
 *                 (text_size + element_size + 1) * sizeof(char))
 *             cstd.sprintf(c_message, msg, c_element)             # <<<<<<<<<<<<<<
 *             c_error.message = c_message
 *         else:
 */
      sprintf(__pyx_v_c_message, __pyx_v_msg, __pyx_v_c_element);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":485
 *                 (text_size + element_size + 1) * sizeof(char))
 *             cstd.sprintf(c_message, msg, c_element)
 *             c_error.message = c_message             # <<<<<<<<<<<<<<
 *         else:
 *             c_error.message = ''
 */
      __pyx_v_c_error.message = __pyx_v_c_message;
      goto __pyx_L11;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":487
 *             c_error.message = c_message
 *         else:
 *             c_error.message = ''             # <<<<<<<<<<<<<<
 *     elif c_element is NULL:
 *         c_error.message = c_text
 */
      __pyx_v_c_error.message = __pyx_k_366;
    }
    __pyx_L11:;
    goto __pyx_L10;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":488
 *         else:
 *             c_error.message = ''
 *     elif c_element is NULL:             # <<<<<<<<<<<<<<
 *         c_error.message = c_text
 *     else:
 */
  __pyx_1 = (__pyx_v_c_element == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":489
 *             c_error.message = ''
 *     elif c_element is NULL:
 *         c_error.message = c_text             # <<<<<<<<<<<<<<
 *     else:
 *         text_size    = cstd.strlen(c_text)
 */
    __pyx_v_c_error.message = __pyx_v_c_text;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":491
 *         c_error.message = c_text
 *     else:
 *         text_size    = cstd.strlen(c_text)             # <<<<<<<<<<<<<<
 *         element_size = cstd.strlen(c_element)
 *         c_message = <char*>cstd.malloc(
 */
    __pyx_v_text_size = strlen(__pyx_v_c_text);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":492
 *     else:
 *         text_size    = cstd.strlen(c_text)
 *         element_size = cstd.strlen(c_element)             # <<<<<<<<<<<<<<
 *         c_message = <char*>cstd.malloc(
 *             (text_size + 12 + element_size + 1) * sizeof(char))
 */
    __pyx_v_element_size = strlen(__pyx_v_c_element);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":494
 *         element_size = cstd.strlen(c_element)
 *         c_message = <char*>cstd.malloc(
 *             (text_size + 12 + element_size + 1) * sizeof(char))             # <<<<<<<<<<<<<<
 *         cstd.sprintf(c_message, "%s, element '%s'", c_text, c_element)
 *         c_error.message = c_message
 */
    __pyx_v_c_message = ((char *)malloc(((((__pyx_v_text_size + 12) + __pyx_v_element_size) + 1) * (sizeof(char)))));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":495
 *         c_message = <char*>cstd.malloc(
 *             (text_size + 12 + element_size + 1) * sizeof(char))
 *         cstd.sprintf(c_message, "%s, element '%s'", c_text, c_element)             # <<<<<<<<<<<<<<
 *         c_error.message = c_message
 * 
 */
    sprintf(__pyx_v_c_message, __pyx_k_367, __pyx_v_c_text, __pyx_v_c_element);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":496
 *             (text_size + 12 + element_size + 1) * sizeof(char))
 *         cstd.sprintf(c_message, "%s, element '%s'", c_text, c_element)
 *         c_error.message = c_message             # <<<<<<<<<<<<<<
 * 
 *     c_error.domain = xmlerror.XML_FROM_XSLT
 */
    __pyx_v_c_error.message = __pyx_v_c_message;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":498
 *         c_error.message = c_message
 * 
 *     c_error.domain = xmlerror.XML_FROM_XSLT             # <<<<<<<<<<<<<<
 *     c_error.code   = xmlerror.XML_ERR_OK    # what else?
 *     c_error.level  = xmlerror.XML_ERR_ERROR # what else?
 */
  __pyx_v_c_error.domain = XML_FROM_XSLT;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":499
 * 
 *     c_error.domain = xmlerror.XML_FROM_XSLT
 *     c_error.code   = xmlerror.XML_ERR_OK    # what else?             # <<<<<<<<<<<<<<
 *     c_error.level  = xmlerror.XML_ERR_ERROR # what else?
 *     c_error.int2   = 0
 */
  __pyx_v_c_error.code = XML_ERR_OK;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":500
 *     c_error.domain = xmlerror.XML_FROM_XSLT
 *     c_error.code   = xmlerror.XML_ERR_OK    # what else?
 *     c_error.level  = xmlerror.XML_ERR_ERROR # what else?             # <<<<<<<<<<<<<<
 *     c_error.int2   = 0
 * 
 */
  __pyx_v_c_error.level = XML_ERR_ERROR;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":501
 *     c_error.code   = xmlerror.XML_ERR_OK    # what else?
 *     c_error.level  = xmlerror.XML_ERR_ERROR # what else?
 *     c_error.int2   = 0             # <<<<<<<<<<<<<<
 * 
 *     _forwardError(c_log_handler, &c_error)
 */
  __pyx_v_c_error.int2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":503
 *     c_error.int2   = 0
 * 
 *     _forwardError(c_log_handler, &c_error)             # <<<<<<<<<<<<<<
 * 
 *     if c_message is not NULL:
 */
  __pyx_f_4lxml_5etree__forwardError(__pyx_v_c_log_handler, (&__pyx_v_c_error));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":505
 *     _forwardError(c_log_handler, &c_error)
 * 
 *     if c_message is not NULL:             # <<<<<<<<<<<<<<
 *         cstd.free(c_message)
 * 
 */
  __pyx_1 = (__pyx_v_c_message != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":506
 * 
 *     if c_message is not NULL:
 *         cstd.free(c_message)             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
    free(__pyx_v_c_message);
    goto __pyx_L12;
  }
  __pyx_L12:;

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":512
 * ################################################################################
 * 
 * cdef void __initErrorConstants():             # <<<<<<<<<<<<<<
 *     u"Called at setup time to parse the constants and build the classes below."
 *     find_constants = re.compile(ur"\s*([a-zA-Z0-9_]+)\s*=\s*([0-9]+)").findall
 */

static  void __pyx_f_4lxml_5etree___initErrorConstants(void) {
  PyObject *__pyx_v_find_constants;
  PyObject *__pyx_v_const_defs;
  PyObject *__pyx_v_cls;
  PyObject *__pyx_v_constant_tuple;
  PyObject *__pyx_v_reverse_dict;
  PyObject *__pyx_v_constants;
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_value;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6 = 0;
  Py_ssize_t __pyx_7 = 0;
  Py_ssize_t __pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  int __pyx_10;
  __pyx_v_find_constants = Py_None; Py_INCREF(Py_None);
  __pyx_v_const_defs = Py_None; Py_INCREF(Py_None);
  __pyx_v_cls = Py_None; Py_INCREF(Py_None);
  __pyx_v_constant_tuple = Py_None; Py_INCREF(Py_None);
  __pyx_v_reverse_dict = Py_None; Py_INCREF(Py_None);
  __pyx_v_constants = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":514
 * cdef void __initErrorConstants():
 *     u"Called at setup time to parse the constants and build the classes below."
 *     find_constants = re.compile(ur"\s*([a-zA-Z0-9_]+)\s*=\s*([0-9]+)").findall             # <<<<<<<<<<<<<<
 *     const_defs = ((ErrorLevels,          __ERROR_LEVELS),
 *                   (ErrorDomains,         __ERROR_DOMAINS),
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_368));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_368));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_kp_findall); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_find_constants);
  __pyx_v_find_constants = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":515
 *     u"Called at setup time to parse the constants and build the classes below."
 *     find_constants = re.compile(ur"\s*([a-zA-Z0-9_]+)\s*=\s*([0-9]+)").findall
 *     const_defs = ((ErrorLevels,          __ERROR_LEVELS),             # <<<<<<<<<<<<<<
 *                   (ErrorDomains,         __ERROR_DOMAINS),
 *                   (ErrorTypes,           __PARSER_ERROR_TYPES),
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorLevels); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  Py_INCREF(__pyx_v_4lxml_5etree___ERROR_LEVELS);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_4lxml_5etree___ERROR_LEVELS);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":516
 *     find_constants = re.compile(ur"\s*([a-zA-Z0-9_]+)\s*=\s*([0-9]+)").findall
 *     const_defs = ((ErrorLevels,          __ERROR_LEVELS),
 *                   (ErrorDomains,         __ERROR_DOMAINS),             # <<<<<<<<<<<<<<
 *                   (ErrorTypes,           __PARSER_ERROR_TYPES),
 *                   (RelaxNGErrorTypes,    __RELAXNG_ERROR_TYPES))
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorDomains); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_v_4lxml_5etree___ERROR_DOMAINS);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_4lxml_5etree___ERROR_DOMAINS);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":517
 *     const_defs = ((ErrorLevels,          __ERROR_LEVELS),
 *                   (ErrorDomains,         __ERROR_DOMAINS),
 *                   (ErrorTypes,           __PARSER_ERROR_TYPES),             # <<<<<<<<<<<<<<
 *                   (RelaxNGErrorTypes,    __RELAXNG_ERROR_TYPES))
 *     for cls, constant_tuple in const_defs:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorTypes); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  Py_INCREF(__pyx_v_4lxml_5etree___PARSER_ERROR_TYPES);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_4lxml_5etree___PARSER_ERROR_TYPES);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":518
 *                   (ErrorDomains,         __ERROR_DOMAINS),
 *                   (ErrorTypes,           __PARSER_ERROR_TYPES),
 *                   (RelaxNGErrorTypes,    __RELAXNG_ERROR_TYPES))             # <<<<<<<<<<<<<<
 *     for cls, constant_tuple in const_defs:
 *         reverse_dict = {}
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGErrorTypes); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  Py_INCREF(__pyx_v_4lxml_5etree___RELAXNG_ERROR_TYPES);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_4lxml_5etree___RELAXNG_ERROR_TYPES);
  __pyx_1 = 0;
  __pyx_1 = PyTuple_New(4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_3));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_2));
  PyTuple_SET_ITEM(__pyx_1, 2, ((PyObject *)__pyx_4));
  PyTuple_SET_ITEM(__pyx_1, 3, ((PyObject *)__pyx_5));
  __pyx_3 = 0;
  __pyx_2 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  Py_DECREF(__pyx_v_const_defs);
  __pyx_v_const_defs = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":519
 *                   (ErrorTypes,           __PARSER_ERROR_TYPES),
 *                   (RelaxNGErrorTypes,    __RELAXNG_ERROR_TYPES))
 *     for cls, constant_tuple in const_defs:             # <<<<<<<<<<<<<<
 *         reverse_dict = {}
 *         cls._names   = reverse_dict
 */
  if (PyList_CheckExact(__pyx_v_const_defs) || PyTuple_CheckExact(__pyx_v_const_defs)) {
    __pyx_6 = 0; __pyx_3 = __pyx_v_const_defs; Py_INCREF(__pyx_3);
  } else {
    __pyx_6 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_const_defs); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_3))) {
      if (__pyx_6 >= PyList_GET_SIZE(__pyx_3)) break;
      __pyx_2 = PyList_GET_ITEM(__pyx_3, __pyx_6); Py_INCREF(__pyx_2); __pyx_6++;
    } else if (likely(PyTuple_CheckExact(__pyx_3))) {
      if (__pyx_6 >= PyTuple_GET_SIZE(__pyx_3)) break;
      __pyx_2 = PyTuple_GET_ITEM(__pyx_3, __pyx_6); Py_INCREF(__pyx_2); __pyx_6++;
    } else {
      __pyx_2 = PyIter_Next(__pyx_3);
      if (!__pyx_2) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
      PyObject* tuple = __pyx_2;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_5;
      __pyx_5 = 0;
      __pyx_1 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_1);
      Py_DECREF(__pyx_v_constant_tuple);
      __pyx_v_constant_tuple = __pyx_1;
      __pyx_1 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_5;
      __pyx_5 = 0;
      __pyx_1 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_constant_tuple);
      __pyx_v_constant_tuple = __pyx_1;
      __pyx_1 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":520
 *                   (RelaxNGErrorTypes,    __RELAXNG_ERROR_TYPES))
 *     for cls, constant_tuple in const_defs:
 *         reverse_dict = {}             # <<<<<<<<<<<<<<
 *         cls._names   = reverse_dict
 *         cls._getName = reverse_dict.get
 */
    __pyx_5 = PyDict_New(); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_reverse_dict);
    __pyx_v_reverse_dict = ((PyObject *)__pyx_5);
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":521
 *     for cls, constant_tuple in const_defs:
 *         reverse_dict = {}
 *         cls._names   = reverse_dict             # <<<<<<<<<<<<<<
 *         cls._getName = reverse_dict.get
 *         for constants in constant_tuple:
 */
    if (PyObject_SetAttr(__pyx_v_cls, __pyx_kp__names, __pyx_v_reverse_dict) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":522
 *         reverse_dict = {}
 *         cls._names   = reverse_dict
 *         cls._getName = reverse_dict.get             # <<<<<<<<<<<<<<
 *         for constants in constant_tuple:
 *             #print len(constants) + 1
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_reverse_dict, __pyx_kp_get); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyObject_SetAttr(__pyx_v_cls, __pyx_kp__getName, __pyx_1) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":523
 *         cls._names   = reverse_dict
 *         cls._getName = reverse_dict.get
 *         for constants in constant_tuple:             # <<<<<<<<<<<<<<
 *             #print len(constants) + 1
 *             for name, value in find_constants(constants):
 */
    if (PyList_CheckExact(__pyx_v_constant_tuple) || PyTuple_CheckExact(__pyx_v_constant_tuple)) {
      __pyx_7 = 0; __pyx_2 = __pyx_v_constant_tuple; Py_INCREF(__pyx_2);
    } else {
      __pyx_7 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_constant_tuple); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_2))) {
        if (__pyx_7 >= PyList_GET_SIZE(__pyx_2)) break;
        __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_7); Py_INCREF(__pyx_4); __pyx_7++;
      } else if (likely(PyTuple_CheckExact(__pyx_2))) {
        if (__pyx_7 >= PyTuple_GET_SIZE(__pyx_2)) break;
        __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_7); Py_INCREF(__pyx_4); __pyx_7++;
      } else {
        __pyx_4 = PyIter_Next(__pyx_2);
        if (!__pyx_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_constants);
      __pyx_v_constants = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":525
 *         for constants in constant_tuple:
 *             #print len(constants) + 1
 *             for name, value in find_constants(constants):             # <<<<<<<<<<<<<<
 *                 value = int(value)
 *                 python.PyObject_SetAttr(cls, name, value)
 */
      __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_constants);
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_constants);
      __pyx_1 = PyObject_Call(__pyx_v_find_constants, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      if (PyList_CheckExact(__pyx_1) || PyTuple_CheckExact(__pyx_1)) {
        __pyx_8 = 0; __pyx_4 = __pyx_1; Py_INCREF(__pyx_4);
      } else {
        __pyx_8 = -1; __pyx_4 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_4))) {
          if (__pyx_8 >= PyList_GET_SIZE(__pyx_4)) break;
          __pyx_5 = PyList_GET_ITEM(__pyx_4, __pyx_8); Py_INCREF(__pyx_5); __pyx_8++;
        } else if (likely(PyTuple_CheckExact(__pyx_4))) {
          if (__pyx_8 >= PyTuple_GET_SIZE(__pyx_4)) break;
          __pyx_5 = PyTuple_GET_ITEM(__pyx_4, __pyx_8); Py_INCREF(__pyx_5); __pyx_8++;
        } else {
          __pyx_5 = PyIter_Next(__pyx_4);
          if (!__pyx_5) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        if (PyTuple_CheckExact(__pyx_5) && PyTuple_GET_SIZE(__pyx_5) == 2) {
          PyObject* tuple = __pyx_5;
          __pyx_9 = PyTuple_GET_ITEM(tuple, 0);
          Py_INCREF(__pyx_9);
          Py_DECREF(__pyx_v_name);
          __pyx_v_name = __pyx_9;
          __pyx_9 = 0;
          __pyx_9 = PyTuple_GET_ITEM(tuple, 1);
          Py_INCREF(__pyx_9);
          Py_DECREF(__pyx_v_value);
          __pyx_v_value = __pyx_9;
          __pyx_9 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
        }
        else {
          __pyx_1 = PyObject_GetIter(__pyx_5); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_9 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_name);
          __pyx_v_name = __pyx_9;
          __pyx_9 = 0;
          __pyx_9 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_value);
          __pyx_v_value = __pyx_9;
          __pyx_9 = 0;
          if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":526
 *             #print len(constants) + 1
 *             for name, value in find_constants(constants):
 *                 value = int(value)             # <<<<<<<<<<<<<<
 *                 python.PyObject_SetAttr(cls, name, value)
 *                 python.PyDict_SetItem(reverse_dict, value, name)
 */
        __pyx_9 = PyTuple_New(1); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_value);
        PyTuple_SET_ITEM(__pyx_9, 0, __pyx_v_value);
        __pyx_5 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), ((PyObject *)__pyx_9), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_9)); __pyx_9 = 0;
        Py_DECREF(__pyx_v_value);
        __pyx_v_value = __pyx_5;
        __pyx_5 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":527
 *             for name, value in find_constants(constants):
 *                 value = int(value)
 *                 python.PyObject_SetAttr(cls, name, value)             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(reverse_dict, value, name)
 * 
 */
        PyObject_SetAttr(__pyx_v_cls, __pyx_v_name, __pyx_v_value);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":528
 *                 value = int(value)
 *                 python.PyObject_SetAttr(cls, name, value)
 *                 python.PyDict_SetItem(reverse_dict, value, name)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_10 = PyDict_SetItem(__pyx_v_reverse_dict, __pyx_v_value, __pyx_v_name); if (unlikely(__pyx_10 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_9);
  __Pyx_WriteUnraisable("lxml.etree.__initErrorConstants");
  __pyx_L0:;
  Py_DECREF(__pyx_v_find_constants);
  Py_DECREF(__pyx_v_const_defs);
  Py_DECREF(__pyx_v_cls);
  Py_DECREF(__pyx_v_constant_tuple);
  Py_DECREF(__pyx_v_reverse_dict);
  Py_DECREF(__pyx_v_constants);
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_value);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":10
 *     cdef object _dependent_proxies
 * 
 *     cdef int _assertNode(self) except -1:             # <<<<<<<<<<<<<<
 *         u"""This is our way of saying: this proxy is invalid!
 *         """
 */

static  int __pyx_f_4lxml_5etree_21_ReadOnlyElementProxy__assertNode(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":13
 *         u"""This is our way of saying: this proxy is invalid!
 *         """
 *         assert self._c_node is not NULL, u"Proxy invalidated!"             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_self->_c_node != NULL))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_369));
    {__pyx_filename = __pyx_f[8]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":14
 *         """
 *         assert self._c_node is not NULL, u"Proxy invalidated!"
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void free_after_use(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy._assertNode");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":16
 *         return 0
 * 
 *     cdef void free_after_use(self):             # <<<<<<<<<<<<<<
 *         u"""Should the xmlNode* be freed when releasing the proxy?
 *         """
 */

static  void __pyx_f_4lxml_5etree_21_ReadOnlyElementProxy_free_after_use(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":19
 *         u"""Should the xmlNode* be freed when releasing the proxy?
 *         """
 *         self._free_after_use = 1             # <<<<<<<<<<<<<<
 * 
 *     property tag:
 */
  __pyx_v_self->_free_after_use = 1;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":24
 *         u"""Element tag
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             return _namespacedName(self._c_node)
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_3tag___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_3tag___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":25
 *         """
 *         def __get__(self):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             return _namespacedName(self._c_node)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":26
 *         def __get__(self):
 *             self._assertNode()
 *             return _namespacedName(self._c_node)             # <<<<<<<<<<<<<<
 * 
 *     property text:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__namespacedName(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.tag.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":32
 *         the value None, if there was no text.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             return _collectText(self._c_node.children)
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_4text___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_4text___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":33
 *         """
 *         def __get__(self):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             return _collectText(self._c_node.children)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":34
 *         def __get__(self):
 *             self._assertNode()
 *             return _collectText(self._c_node.children)             # <<<<<<<<<<<<<<
 * 
 *     property tail:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectText(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->children); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.text.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":41
 *         there was no text.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             return _collectText(self._c_node.next)
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_4tail___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_4tail___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":42
 *         """
 *         def __get__(self):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             return _collectText(self._c_node.next)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":43
 *         def __get__(self):
 *             self._assertNode()
 *             return _collectText(self._c_node.next)             # <<<<<<<<<<<<<<
 * 
 *     property attrib:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectText(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->next); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.tail.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":46
 * 
 *     property attrib:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             return dict(_collectAttributes(self._c_node, 3))
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_6attrib___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_6attrib___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":47
 *     property attrib:
 *         def __get__(self):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             return dict(_collectAttributes(self._c_node, 3))
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":48
 *         def __get__(self):
 *             self._assertNode()
 *             return dict(_collectAttributes(self._c_node, 3))             # <<<<<<<<<<<<<<
 * 
 *     property prefix:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, 3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.attrib.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":53
 *         u"""Namespace prefix or None.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             if self._c_node.ns is not NULL:
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_6prefix___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_6prefix___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":54
 *         """
 *         def __get__(self):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             if self._c_node.ns is not NULL:
 *                 if self._c_node.ns.prefix is not NULL:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":55
 *         def __get__(self):
 *             self._assertNode()
 *             if self._c_node.ns is not NULL:             # <<<<<<<<<<<<<<
 *                 if self._c_node.ns.prefix is not NULL:
 *                     return funicode(self._c_node.ns.prefix)
 */
  __pyx_2 = (((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->ns != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":56
 *             self._assertNode()
 *             if self._c_node.ns is not NULL:
 *                 if self._c_node.ns.prefix is not NULL:             # <<<<<<<<<<<<<<
 *                     return funicode(self._c_node.ns.prefix)
 *             return None
 */
    __pyx_2 = (((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->ns->prefix != NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":57
 *             if self._c_node.ns is not NULL:
 *                 if self._c_node.ns.prefix is not NULL:
 *                     return funicode(self._c_node.ns.prefix)             # <<<<<<<<<<<<<<
 *             return None
 * 
 */
      __pyx_3 = __pyx_f_4lxml_5etree_funicode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->ns->prefix); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":58
 *                 if self._c_node.ns.prefix is not NULL:
 *                     return funicode(self._c_node.ns.prefix)
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     property sourceline:
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.prefix.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":63
 *         u"""Original line number as found by the parser or None if unknown.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef long line
 *             self._assertNode()
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_10sourceline___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_10sourceline___get__(PyObject *__pyx_v_self) {
  long __pyx_v_line;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":65
 *         def __get__(self):
 *             cdef long line
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             line = tree.xmlGetLineNo(self._c_node)
 *             if line > 0:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":66
 *             cdef long line
 *             self._assertNode()
 *             line = tree.xmlGetLineNo(self._c_node)             # <<<<<<<<<<<<<<
 *             if line > 0:
 *                 return line
 */
  __pyx_v_line = xmlGetLineNo(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":67
 *             self._assertNode()
 *             line = tree.xmlGetLineNo(self._c_node)
 *             if line > 0:             # <<<<<<<<<<<<<<
 *                 return line
 *             else:
 */
  __pyx_2 = (__pyx_v_line > 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":68
 *             line = tree.xmlGetLineNo(self._c_node)
 *             if line > 0:
 *                 return line             # <<<<<<<<<<<<<<
 *             else:
 *                 return None
 */
    __pyx_3 = PyInt_FromLong(__pyx_v_line); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":70
 *                 return line
 *             else:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.sourceline.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":72
 *                 return None
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"<Element %s at %x>" % (self.tag, id(self))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":73
 * 
 *     def __repr__(self):
 *         return u"<Element %s at %x>" % (self.tag, id(self))             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, x):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  __pyx_1 = 0;
  __pyx_3 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_370), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":75
 *         return u"<Element %s at %x>" % (self.tag, id(self))
 * 
 *     def __getitem__(self, x):             # <<<<<<<<<<<<<<
 *         u"""Returns the subelement at the given position or the requested
 *         slice.
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___getitem__[] = "Returns the subelement at the given position or the requested\n        slice.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  xmlNode *__pyx_v_c_node;
  Py_ssize_t __pyx_v_step;
  Py_ssize_t __pyx_v_slicelength;
  Py_ssize_t __pyx_v_c;
  Py_ssize_t __pyx_v_i;
  _node_to_node_function __pyx_v_next_element;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5 = 0;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":83
 *         cdef Py_ssize_t c, i
 *         cdef _node_to_node_function next_element
 *         if python.PySlice_Check(x):             # <<<<<<<<<<<<<<
 *             # slicing
 *             if _isFullSlice(<python.slice>x):
 */
  __pyx_1 = PySlice_Check(__pyx_v_x);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":85
 *         if python.PySlice_Check(x):
 *             # slicing
 *             if _isFullSlice(<python.slice>x):             # <<<<<<<<<<<<<<
 *                 return _collectChildren(self)
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 */
    __pyx_1 = __pyx_f_4lxml_5etree__isFullSlice(((PySliceObject *)__pyx_v_x));
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":86
 *             # slicing
 *             if _isFullSlice(<python.slice>x):
 *                 return _collectChildren(self)             # <<<<<<<<<<<<<<
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if c_node is NULL:
 */
      if (!(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = __pyx_f_4lxml_5etree__collectChildren(((struct LxmlElement *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":87
 *             if _isFullSlice(<python.slice>x):
 *                 return _collectChildren(self)
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 return []
 */
    if (!(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_4lxml_6python_slice))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__findChildSlice(((PySliceObject *)__pyx_v_x), ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, (&__pyx_v_c_node), (&__pyx_v_step), (&__pyx_v_slicelength)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":88
 *                 return _collectChildren(self)
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 return []
 *             if step > 0:
 */
    __pyx_1 = (__pyx_v_c_node == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":89
 *             _findChildSlice(x, self._c_node, &c_node, &step, &slicelength)
 *             if c_node is NULL:
 *                 return []             # <<<<<<<<<<<<<<
 *             if step > 0:
 *                 next_element = _nextElement
 */
      __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject *)__pyx_2);
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":90
 *             if c_node is NULL:
 *                 return []
 *             if step > 0:             # <<<<<<<<<<<<<<
 *                 next_element = _nextElement
 *             else:
 */
    __pyx_1 = (__pyx_v_step > 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":91
 *                 return []
 *             if step > 0:
 *                 next_element = _nextElement             # <<<<<<<<<<<<<<
 *             else:
 *                 step = -step
 */
      __pyx_v_next_element = __pyx_f_4lxml_5etree__nextElement;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":93
 *                 next_element = _nextElement
 *             else:
 *                 step = -step             # <<<<<<<<<<<<<<
 *                 next_element = _previousElement
 *             result = []
 */
      __pyx_v_step = (-__pyx_v_step);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":94
 *             else:
 *                 step = -step
 *                 next_element = _previousElement             # <<<<<<<<<<<<<<
 *             result = []
 *             c = 0
 */
      __pyx_v_next_element = __pyx_f_4lxml_5etree__previousElement;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":95
 *                 step = -step
 *                 next_element = _previousElement
 *             result = []             # <<<<<<<<<<<<<<
 *             c = 0
 *             while c_node is not NULL and c < slicelength:
 */
    __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = ((PyObject *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":96
 *                 next_element = _previousElement
 *             result = []
 *             c = 0             # <<<<<<<<<<<<<<
 *             while c_node is not NULL and c < slicelength:
 *                 python.PyList_Append(
 */
    __pyx_v_c = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":97
 *             result = []
 *             c = 0
 *             while c_node is not NULL and c < slicelength:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_node != NULL);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c < __pyx_v_slicelength);
      }
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":99
 *             while c_node is not NULL and c < slicelength:
 *                 python.PyList_Append(
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(
 *                     result, _elementFactory(self._doc, c_node))
 */
      if (!(__Pyx_TypeTest(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy), __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyList_Append(__pyx_v_result, __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":101
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))
 *                 python.PyList_Append(
 *                     result, _elementFactory(self._doc, c_node))             # <<<<<<<<<<<<<<
 *                 c = c + 1
 *                 for i from 0 <= i < step:
 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Document))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlDocument *)__pyx_2), __pyx_v_c_node)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_3 = PyList_Append(__pyx_v_result, __pyx_4); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":102
 *                 python.PyList_Append(
 *                     result, _elementFactory(self._doc, c_node))
 *                 c = c + 1             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)
 */
      __pyx_v_c = (__pyx_v_c + 1);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":103
 *                     result, _elementFactory(self._doc, c_node))
 *                 c = c + 1
 *                 for i from 0 <= i < step:             # <<<<<<<<<<<<<<
 *                     c_node = next_element(c_node)
 *             return result
 */
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_step; __pyx_v_i++) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":104
 *                 c = c + 1
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)             # <<<<<<<<<<<<<<
 *             return result
 *         else:
 */
        __pyx_v_c_node = __pyx_v_next_element(__pyx_v_c_node);
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":105
 *                 for i from 0 <= i < step:
 *                     c_node = next_element(c_node)
 *             return result             # <<<<<<<<<<<<<<
 *         else:
 *             # indexing
 */
    Py_INCREF(__pyx_v_result);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":108
 *         else:
 *             # indexing
 *             c_node = _findChild(self._c_node, x)             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"
 */
    __pyx_5 = __pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_node = __pyx_f_4lxml_5etree__findChild(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, __pyx_5);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":109
 *             # indexing
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 raise IndexError, u"list index out of range"
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 */
    __pyx_1 = (__pyx_v_c_node == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":110
 *             c_node = _findChild(self._c_node, x)
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"             # <<<<<<<<<<<<<<
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 * 
 */
      __Pyx_Raise(__pyx_builtin_IndexError, ((PyObject *)__pyx_kp_371), 0);
      {__pyx_filename = __pyx_f[8]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":111
 *             if c_node is NULL:
 *                 raise IndexError, u"list index out of range"
 *             return _newReadOnlyProxy(self._source_proxy, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
    if (!(__Pyx_TypeTest(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy), __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":113
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         u"""Returns the number of subelements.
 *         """
 */

static Py_ssize_t __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___len__[] = "Returns the number of subelements.\n        ";
static Py_ssize_t __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_v_c;
  xmlNode *__pyx_v_c_node;
  Py_ssize_t __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":118
 *         cdef Py_ssize_t c
 *         cdef xmlNode* c_node
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         c = 0
 *         c_node = self._c_node.children
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":119
 *         cdef xmlNode* c_node
 *         self._assertNode()
 *         c = 0             # <<<<<<<<<<<<<<
 *         c_node = self._c_node.children
 *         while c_node is not NULL:
 */
  __pyx_v_c = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":120
 *         self._assertNode()
 *         c = 0
 *         c_node = self._c_node.children             # <<<<<<<<<<<<<<
 *         while c_node is not NULL:
 *             if tree._isElement(c_node):
 */
  __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":121
 *         c = 0
 *         c_node = self._c_node.children
 *         while c_node is not NULL:             # <<<<<<<<<<<<<<
 *             if tree._isElement(c_node):
 *                 c = c + 1
 */
  while (1) {
    __pyx_2 = (__pyx_v_c_node != NULL);
    if (!__pyx_2) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":122
 *         c_node = self._c_node.children
 *         while c_node is not NULL:
 *             if tree._isElement(c_node):             # <<<<<<<<<<<<<<
 *                 c = c + 1
 *             c_node = c_node.next
 */
    __pyx_2 = _isElement(__pyx_v_c_node);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":123
 *         while c_node is not NULL:
 *             if tree._isElement(c_node):
 *                 c = c + 1             # <<<<<<<<<<<<<<
 *             c_node = c_node.next
 *         return c
 */
      __pyx_v_c = (__pyx_v_c + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":124
 *             if tree._isElement(c_node):
 *                 c = c + 1
 *             c_node = c_node.next             # <<<<<<<<<<<<<<
 *         return c
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":125
 *                 c = c + 1
 *             c_node = c_node.next
 *         return c             # <<<<<<<<<<<<<<
 * 
 *     def __nonzero__(self):
 */
  __pyx_r = __pyx_v_c;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":127
 *         return c
 * 
 *     def __nonzero__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         self._assertNode()
 */

static int __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___nonzero__(PyObject *__pyx_v_self) {
  xmlNode *__pyx_v_c_node;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":129
 *     def __nonzero__(self):
 *         cdef xmlNode* c_node
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         c_node = _findChildBackwards(self._c_node, 0)
 *         return c_node != NULL
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":130
 *         cdef xmlNode* c_node
 *         self._assertNode()
 *         c_node = _findChildBackwards(self._c_node, 0)             # <<<<<<<<<<<<<<
 *         return c_node != NULL
 * 
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__findChildBackwards(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, 0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":131
 *         self._assertNode()
 *         c_node = _findChildBackwards(self._c_node, 0)
 *         return c_node != NULL             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self, memo):
 */
  __pyx_r = (__pyx_v_c_node != NULL);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__nonzero__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":133
 *         return c_node != NULL
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         u"__deepcopy__(self, memo)"
 *         return self.__copy__()
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___deepcopy__[] = "__deepcopy__(self, memo)";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":135
 *     def __deepcopy__(self, memo):
 *         u"__deepcopy__(self, memo)"
 *         return self.__copy__()             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___copy__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__deepcopy__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":137
 *         return self.__copy__()
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         u"__copy__(self)"
 *         cdef xmlDoc* c_doc
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___copy__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___copy__[] = "__copy__(self)";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___copy__(PyObject *__pyx_v_self, PyObject *unused) {
  xmlDoc *__pyx_v_c_doc;
  xmlNode *__pyx_v_c_node;
  struct LxmlDocument *__pyx_v_new_doc;
  PyObject *__pyx_v_root;
  PyObject *__pyx_r;
  xmlDoc *__pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_new_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":142
 *         cdef xmlNode* c_node
 *         cdef _Document new_doc
 *         c_doc = _copyDocRoot(self._c_node.doc, self._c_node) # recursive             # <<<<<<<<<<<<<<
 *         new_doc = _documentFactory(c_doc, None)
 *         root = new_doc.getroot()
 */
  __pyx_1 = __pyx_f_4lxml_5etree__copyDocRoot(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->doc, ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":143
 *         cdef _Document new_doc
 *         c_doc = _copyDocRoot(self._c_node.doc, self._c_node) # recursive
 *         new_doc = _documentFactory(c_doc, None)             # <<<<<<<<<<<<<<
 *         root = new_doc.getroot()
 *         if root is not None:
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_new_doc));
  __pyx_v_new_doc = ((struct LxmlDocument *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":144
 *         c_doc = _copyDocRoot(self._c_node.doc, self._c_node) # recursive
 *         new_doc = _documentFactory(c_doc, None)
 *         root = new_doc.getroot()             # <<<<<<<<<<<<<<
 *         if root is not None:
 *             return root
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_new_doc->__pyx_vtab)->getroot(__pyx_v_new_doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":145
 *         new_doc = _documentFactory(c_doc, None)
 *         root = new_doc.getroot()
 *         if root is not None:             # <<<<<<<<<<<<<<
 *             return root
 *         # Comment/PI
 */
  __pyx_3 = (__pyx_v_root != Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":146
 *         root = new_doc.getroot()
 *         if root is not None:
 *             return root             # <<<<<<<<<<<<<<
 *         # Comment/PI
 *         c_node = c_doc.children
 */
    Py_INCREF(__pyx_v_root);
    __pyx_r = __pyx_v_root;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":148
 *             return root
 *         # Comment/PI
 *         c_node = c_doc.children             # <<<<<<<<<<<<<<
 *         while c_node is not NULL and c_node.type != self._c_node.type:
 *             c_node = c_node.next
 */
  __pyx_v_c_node = __pyx_v_c_doc->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":149
 *         # Comment/PI
 *         c_node = c_doc.children
 *         while c_node is not NULL and c_node.type != self._c_node.type:             # <<<<<<<<<<<<<<
 *             c_node = c_node.next
 *         if c_node is NULL:
 */
  while (1) {
    __pyx_3 = (__pyx_v_c_node != NULL);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_c_node->type != ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->type);
    }
    if (!__pyx_3) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":150
 *         c_node = c_doc.children
 *         while c_node is not NULL and c_node.type != self._c_node.type:
 *             c_node = c_node.next             # <<<<<<<<<<<<<<
 *         if c_node is NULL:
 *             return None
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":151
 *         while c_node is not NULL and c_node.type != self._c_node.type:
 *             c_node = c_node.next
 *         if c_node is NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         return _elementFactory(new_doc, c_node)
 */
  __pyx_3 = (__pyx_v_c_node == NULL);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":152
 *             c_node = c_node.next
 *         if c_node is NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         return _elementFactory(new_doc, c_node)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":153
 *         if c_node is NULL:
 *             return None
 *         return _elementFactory(new_doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_new_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__copy__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_new_doc);
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":155
 *         return _elementFactory(new_doc, c_node)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self.getchildren())
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":156
 * 
 *     def __iter__(self):
 *         return iter(self.getchildren())             # <<<<<<<<<<<<<<
 * 
 *     def iterchildren(self, tag=None, *, reversed=False):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->getchildren(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self), 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":158
 *         return iter(self.getchildren())
 * 
 *     def iterchildren(self, tag=None, *, reversed=False):             # <<<<<<<<<<<<<<
 *         u"""iterchildren(self, tag=None, reversed=False)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_iterchildren(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_iterchildren[] = "iterchildren(self, tag=None, reversed=False)\n\n        Iterate over the children of this element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_iterchildren(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_reversed = 0;
  PyObject *__pyx_v_children;
  PyObject *__pyx_v_el;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  Py_ssize_t __pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  int __pyx_8;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,&__pyx_kp_reversed,0};
  __pyx_v_tag = Py_None;
  __pyx_v_reversed = __pyx_k_106;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "iterchildren") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_tag = values[0];
    }
    if (values[1]) {
      __pyx_v_reversed = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterchildren", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.iterchildren");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_children = Py_None; Py_INCREF(Py_None);
  __pyx_v_el = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":163
 *         Iterate over the children of this element.
 *         """
 *         children = self.getchildren()             # <<<<<<<<<<<<<<
 *         if tag is not None and tag != '*':
 *             children = [ el for el in children if el.tag == tag ]
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->getchildren(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self), 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_children);
  __pyx_v_children = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":164
 *         """
 *         children = self.getchildren()
 *         if tag is not None and tag != '*':             # <<<<<<<<<<<<<<
 *             children = [ el for el in children if el.tag == tag ]
 *         if reversed:
 */
  __pyx_2 = (__pyx_v_tag != Py_None);
  if (__pyx_2) {
    __pyx_1 = PyObject_RichCompare(__pyx_v_tag, __pyx_kp_372, Py_NE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":165
 *         children = self.getchildren()
 *         if tag is not None and tag != '*':
 *             children = [ el for el in children if el.tag == tag ]             # <<<<<<<<<<<<<<
 *         if reversed:
 *             children = children[::-1]
 */
    __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyList_CheckExact(__pyx_v_children) || PyTuple_CheckExact(__pyx_v_children)) {
      __pyx_4 = 0; __pyx_5 = __pyx_v_children; Py_INCREF(__pyx_5);
    } else {
      __pyx_4 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_children); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_5))) {
        if (__pyx_4 >= PyList_GET_SIZE(__pyx_5)) break;
        __pyx_6 = PyList_GET_ITEM(__pyx_5, __pyx_4); Py_INCREF(__pyx_6); __pyx_4++;
      } else if (likely(PyTuple_CheckExact(__pyx_5))) {
        if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_5)) break;
        __pyx_6 = PyTuple_GET_ITEM(__pyx_5, __pyx_4); Py_INCREF(__pyx_6); __pyx_4++;
      } else {
        __pyx_6 = PyIter_Next(__pyx_5);
        if (!__pyx_6) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_el);
      __pyx_v_el = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = PyObject_GetAttr(__pyx_v_el, __pyx_kp_tag); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_7 = PyObject_RichCompare(__pyx_6, __pyx_v_tag, Py_EQ); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_7); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      if (__pyx_3) {
        __pyx_8 = PyList_Append(__pyx_1, (PyObject*)__pyx_v_el); if (unlikely(__pyx_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_v_children);
    __pyx_v_children = ((PyObject *)__pyx_1);
    __pyx_1 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":166
 *         if tag is not None and tag != '*':
 *             children = [ el for el in children if el.tag == tag ]
 *         if reversed:             # <<<<<<<<<<<<<<
 *             children = children[::-1]
 *         return iter(children)
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_reversed); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":167
 *             children = [ el for el in children if el.tag == tag ]
 *         if reversed:
 *             children = children[::-1]             # <<<<<<<<<<<<<<
 *         return iter(children)
 * 
 */
    __pyx_6 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_7 = PyObject_GetItem(__pyx_v_children, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_v_children);
    __pyx_v_children = __pyx_7;
    __pyx_7 = 0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":168
 *         if reversed:
 *             children = children[::-1]
 *         return iter(children)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
  __pyx_5 = PyObject_GetIter(__pyx_v_children); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.iterchildren");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_children);
  Py_DECREF(__pyx_v_el);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":170
 *         return iter(children)
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         u"""Gets an element attribute.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_get[] = "Gets an element attribute.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.get");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":173
 *         u"""Gets an element attribute.
 *         """
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         return _getNodeAttributeValue(self._c_node, key, default)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":174
 *         """
 *         self._assertNode()
 *         return _getNodeAttributeValue(self._c_node, key, default)             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__getNodeAttributeValue(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, __pyx_v_key, __pyx_v_default); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.get");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":176
 *         return _getNodeAttributeValue(self._c_node, key, default)
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         u"""Gets a list of attribute names. The names are returned in an
 *         arbitrary order (just like for an ordinary Python dictionary).
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_keys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_keys[] = "Gets a list of attribute names. The names are returned in an\n        arbitrary order (just like for an ordinary Python dictionary).\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_keys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":180
 *         arbitrary order (just like for an ordinary Python dictionary).
 *         """
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         return _collectAttributes(self._c_node, 1)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":181
 *         """
 *         self._assertNode()
 *         return _collectAttributes(self._c_node, 1)             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, 1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.keys");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":183
 *         return _collectAttributes(self._c_node, 1)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         u"""Gets element attributes, as a sequence. The attributes are returned
 *         in an arbitrary order.
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_values(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_values[] = "Gets element attributes, as a sequence. The attributes are returned\n        in an arbitrary order.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_values(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":187
 *         in an arbitrary order.
 *         """
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         return _collectAttributes(self._c_node, 2)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":188
 *         """
 *         self._assertNode()
 *         return _collectAttributes(self._c_node, 2)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, 2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.values");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":190
 *         return _collectAttributes(self._c_node, 2)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         u"""Gets element attributes, as a sequence. The attributes are returned
 *         in an arbitrary order.
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_items(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_items[] = "Gets element attributes, as a sequence. The attributes are returned\n        in an arbitrary order.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_items(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":194
 *         in an arbitrary order.
 *         """
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         return _collectAttributes(self._c_node, 3)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":195
 *         """
 *         self._assertNode()
 *         return _collectAttributes(self._c_node, 3)             # <<<<<<<<<<<<<<
 * 
 *     cpdef getchildren(self):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectAttributes(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node, 3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.items");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":197
 *         return _collectAttributes(self._c_node, 3)
 * 
 *     cpdef getchildren(self):             # <<<<<<<<<<<<<<
 *         u"""Returns all subelements. The elements are returned in document
 *         order.
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getchildren(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static  PyObject *__pyx_f_4lxml_5etree_21_ReadOnlyElementProxy_getchildren(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_self, int __pyx_skip_dispatch) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_getchildren); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(strcmp(Py_TYPE(__pyx_1)->tp_name, "builtin_function_or_method") == 0) || (PyCFunction_GET_FUNCTION(__pyx_1) != (void *)&__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getchildren)) {
      __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
    }
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":202
 *         """
 *         cdef xmlNode* c_node
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         result = []
 *         c_node = self._c_node.children
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self->__pyx_vtab)->_assertNode(__pyx_v_self); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":203
 *         cdef xmlNode* c_node
 *         self._assertNode()
 *         result = []             # <<<<<<<<<<<<<<
 *         c_node = self._c_node.children
 *         while c_node is not NULL:
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":204
 *         self._assertNode()
 *         result = []
 *         c_node = self._c_node.children             # <<<<<<<<<<<<<<
 *         while c_node is not NULL:
 *             if tree._isElement(c_node):
 */
  __pyx_v_c_node = __pyx_v_self->_c_node->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":205
 *         result = []
 *         c_node = self._c_node.children
 *         while c_node is not NULL:             # <<<<<<<<<<<<<<
 *             if tree._isElement(c_node):
 *                 python.PyList_Append(
 */
  while (1) {
    __pyx_4 = (__pyx_v_c_node != NULL);
    if (!__pyx_4) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":206
 *         c_node = self._c_node.children
 *         while c_node is not NULL:
 *             if tree._isElement(c_node):             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))
 */
    __pyx_4 = _isElement(__pyx_v_c_node);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":208
 *             if tree._isElement(c_node):
 *                 python.PyList_Append(
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))             # <<<<<<<<<<<<<<
 *             c_node = c_node.next
 *         return result
 */
      if (!(__Pyx_TypeTest(__pyx_v_self->_source_proxy, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self->_source_proxy), __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyList_Append(__pyx_v_result, __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":209
 *                 python.PyList_Append(
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))
 *             c_node = c_node.next             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":210
 *                     result, _newReadOnlyProxy(self._source_proxy, c_node))
 *             c_node = c_node.next
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def getparent(self):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.getchildren");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":197
 *         return _collectAttributes(self._c_node, 3)
 * 
 *     cpdef getchildren(self):             # <<<<<<<<<<<<<<
 *         u"""Returns all subelements. The elements are returned in document
 *         order.
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getchildren(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getchildren[] = "Returns all subelements. The elements are returned in document\n        order.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getchildren(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->getchildren(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self), 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.getchildren");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":212
 *         return result
 * 
 *     def getparent(self):             # <<<<<<<<<<<<<<
 *         u"""Returns the parent of this element or None for the root element.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getparent(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getparent[] = "Returns the parent of this element or None for the root element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getparent(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_parent;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":216
 *         """
 *         cdef xmlNode* c_parent
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         c_parent = self._c_node.parent
 *         if c_parent is NULL or not tree._isElement(c_parent):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":217
 *         cdef xmlNode* c_parent
 *         self._assertNode()
 *         c_parent = self._c_node.parent             # <<<<<<<<<<<<<<
 *         if c_parent is NULL or not tree._isElement(c_parent):
 *             return None
 */
  __pyx_v_c_parent = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node->parent;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":218
 *         self._assertNode()
 *         c_parent = self._c_node.parent
 *         if c_parent is NULL or not tree._isElement(c_parent):             # <<<<<<<<<<<<<<
 *             return None
 *         else:
 */
  __pyx_2 = (__pyx_v_c_parent == NULL);
  if (!__pyx_2) {
    __pyx_2 = (!_isElement(__pyx_v_c_parent));
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":219
 *         c_parent = self._c_node.parent
 *         if c_parent is NULL or not tree._isElement(c_parent):
 *             return None             # <<<<<<<<<<<<<<
 *         else:
 *             return _newReadOnlyProxy(self._source_proxy, c_parent)
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":221
 *             return None
 *         else:
 *             return _newReadOnlyProxy(self._source_proxy, c_parent)             # <<<<<<<<<<<<<<
 * 
 *     def getnext(self):
 */
    if (!(__Pyx_TypeTest(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy), __pyx_v_c_parent)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.getparent");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":223
 *             return _newReadOnlyProxy(self._source_proxy, c_parent)
 * 
 *     def getnext(self):             # <<<<<<<<<<<<<<
 *         u"""Returns the following sibling of this element or None.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getnext(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getnext[] = "Returns the following sibling of this element or None.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getnext(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":227
 *         """
 *         cdef xmlNode* c_node
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         c_node = _nextElement(self._c_node)
 *         if c_node is not NULL:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":228
 *         cdef xmlNode* c_node
 *         self._assertNode()
 *         c_node = _nextElement(self._c_node)             # <<<<<<<<<<<<<<
 *         if c_node is not NULL:
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__nextElement(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":229
 *         self._assertNode()
 *         c_node = _nextElement(self._c_node)
 *         if c_node is not NULL:             # <<<<<<<<<<<<<<
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 *         return None
 */
  __pyx_2 = (__pyx_v_c_node != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":230
 *         c_node = _nextElement(self._c_node)
 *         if c_node is not NULL:
 *             return _newReadOnlyProxy(self._source_proxy, c_node)             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
    if (!(__Pyx_TypeTest(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy), __pyx_v_c_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":231
 *         if c_node is not NULL:
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def getprevious(self):
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.getnext");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":233
 *         return None
 * 
 *     def getprevious(self):             # <<<<<<<<<<<<<<
 *         u"""Returns the preceding sibling of this element or None.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getprevious(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getprevious[] = "Returns the preceding sibling of this element or None.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getprevious(PyObject *__pyx_v_self, PyObject *unused) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":237
 *         """
 *         cdef xmlNode* c_node
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         c_node = _previousElement(self._c_node)
 *         if c_node is not NULL:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->__pyx_vtab)->_assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":238
 *         cdef xmlNode* c_node
 *         self._assertNode()
 *         c_node = _previousElement(self._c_node)             # <<<<<<<<<<<<<<
 *         if c_node is not NULL:
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__previousElement(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":239
 *         self._assertNode()
 *         c_node = _previousElement(self._c_node)
 *         if c_node is not NULL:             # <<<<<<<<<<<<<<
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 *         return None
 */
  __pyx_2 = (__pyx_v_c_node != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":240
 *         c_node = _previousElement(self._c_node)
 *         if c_node is not NULL:
 *             return _newReadOnlyProxy(self._source_proxy, c_node)             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
    if (!(__Pyx_TypeTest(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)->_source_proxy), __pyx_v_c_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":241
 *         if c_node is not NULL:
 *             return _newReadOnlyProxy(self._source_proxy, c_node)
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ReadOnlyElementProxy.getprevious");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":248
 *     cdef _ReadOnlyElementProxy NEW_RO_PROXY "PY_NEW" (object t)
 * 
 * cdef _ReadOnlyElementProxy _newReadOnlyProxy(             # <<<<<<<<<<<<<<
 *     _ReadOnlyElementProxy source_proxy, xmlNode* c_node):
 *     cdef _ReadOnlyElementProxy el
 */

static  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_f_4lxml_5etree__newReadOnlyProxy(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_source_proxy, xmlNode *__pyx_v_c_node) {
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_el;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_el = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":251
 *     _ReadOnlyElementProxy source_proxy, xmlNode* c_node):
 *     cdef _ReadOnlyElementProxy el
 *     el = NEW_RO_PROXY(_ReadOnlyElementProxy)             # <<<<<<<<<<<<<<
 *     el._c_node = c_node
 *     _initReadOnlyProxy(el, source_proxy)
 */
  __pyx_1 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ReadOnlyElementProxy)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_el));
  __pyx_v_el = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":252
 *     cdef _ReadOnlyElementProxy el
 *     el = NEW_RO_PROXY(_ReadOnlyElementProxy)
 *     el._c_node = c_node             # <<<<<<<<<<<<<<
 *     _initReadOnlyProxy(el, source_proxy)
 *     return el
 */
  __pyx_v_el->_c_node = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":253
 *     el = NEW_RO_PROXY(_ReadOnlyElementProxy)
 *     el._c_node = c_node
 *     _initReadOnlyProxy(el, source_proxy)             # <<<<<<<<<<<<<<
 *     return el
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__initReadOnlyProxy(__pyx_v_el, __pyx_v_source_proxy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":254
 *     el._c_node = c_node
 *     _initReadOnlyProxy(el, source_proxy)
 *     return el             # <<<<<<<<<<<<<<
 * 
 * cdef inline _initReadOnlyProxy(_ReadOnlyElementProxy el,
 */
  Py_INCREF(((PyObject *)__pyx_v_el));
  __pyx_r = __pyx_v_el;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._newReadOnlyProxy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_el);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":256
 *     return el
 * 
 * cdef inline _initReadOnlyProxy(_ReadOnlyElementProxy el,             # <<<<<<<<<<<<<<
 *                                _ReadOnlyElementProxy source_proxy):
 *     el._free_after_use = 0
 */

static INLINE PyObject *__pyx_f_4lxml_5etree__initReadOnlyProxy(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_el, struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_source_proxy) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":258
 * cdef inline _initReadOnlyProxy(_ReadOnlyElementProxy el,
 *                                _ReadOnlyElementProxy source_proxy):
 *     el._free_after_use = 0             # <<<<<<<<<<<<<<
 *     if source_proxy is None:
 *         el._source_proxy = el
 */
  __pyx_v_el->_free_after_use = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":259
 *                                _ReadOnlyElementProxy source_proxy):
 *     el._free_after_use = 0
 *     if source_proxy is None:             # <<<<<<<<<<<<<<
 *         el._source_proxy = el
 *         el._dependent_proxies = [el]
 */
  __pyx_1 = (((PyObject *)__pyx_v_source_proxy) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":260
 *     el._free_after_use = 0
 *     if source_proxy is None:
 *         el._source_proxy = el             # <<<<<<<<<<<<<<
 *         el._dependent_proxies = [el]
 *     else:
 */
    Py_INCREF(((PyObject *)__pyx_v_el));
    Py_DECREF(__pyx_v_el->_source_proxy);
    __pyx_v_el->_source_proxy = ((PyObject *)__pyx_v_el);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":261
 *     if source_proxy is None:
 *         el._source_proxy = el
 *         el._dependent_proxies = [el]             # <<<<<<<<<<<<<<
 *     else:
 *         el._source_proxy = source_proxy
 */
    __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_el));
    PyList_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_el));
    Py_DECREF(__pyx_v_el->_dependent_proxies);
    __pyx_v_el->_dependent_proxies = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":263
 *         el._dependent_proxies = [el]
 *     else:
 *         el._source_proxy = source_proxy             # <<<<<<<<<<<<<<
 *         python.PyList_Append(source_proxy._dependent_proxies, el)
 * 
 */
    Py_INCREF(((PyObject *)__pyx_v_source_proxy));
    Py_DECREF(__pyx_v_el->_source_proxy);
    __pyx_v_el->_source_proxy = ((PyObject *)__pyx_v_source_proxy);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":264
 *     else:
 *         el._source_proxy = source_proxy
 *         python.PyList_Append(source_proxy._dependent_proxies, el)             # <<<<<<<<<<<<<<
 * 
 * cdef _freeReadOnlyProxies(_ReadOnlyElementProxy sourceProxy):
 */
    __pyx_3 = PyList_Append(__pyx_v_source_proxy->_dependent_proxies, ((PyObject *)__pyx_v_el)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._initReadOnlyProxy");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":266
 *         python.PyList_Append(source_proxy._dependent_proxies, el)
 * 
 * cdef _freeReadOnlyProxies(_ReadOnlyElementProxy sourceProxy):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     cdef _ReadOnlyElementProxy el
 */

static  PyObject *__pyx_f_4lxml_5etree__freeReadOnlyProxies(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_sourceProxy) {
  xmlNode *__pyx_v_c_node;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_el;
  PyObject *__pyx_r;
  int __pyx_1;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_el = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":269
 *     cdef xmlNode* c_node
 *     cdef _ReadOnlyElementProxy el
 *     if sourceProxy is None:             # <<<<<<<<<<<<<<
 *         return
 *     if sourceProxy._dependent_proxies is None:
 */
  __pyx_1 = (((PyObject *)__pyx_v_sourceProxy) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":270
 *     cdef _ReadOnlyElementProxy el
 *     if sourceProxy is None:
 *         return             # <<<<<<<<<<<<<<
 *     if sourceProxy._dependent_proxies is None:
 *         return
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":271
 *     if sourceProxy is None:
 *         return
 *     if sourceProxy._dependent_proxies is None:             # <<<<<<<<<<<<<<
 *         return
 *     for el in sourceProxy._dependent_proxies:
 */
  __pyx_1 = (__pyx_v_sourceProxy->_dependent_proxies == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":272
 *         return
 *     if sourceProxy._dependent_proxies is None:
 *         return             # <<<<<<<<<<<<<<
 *     for el in sourceProxy._dependent_proxies:
 *         c_node = el._c_node
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":273
 *     if sourceProxy._dependent_proxies is None:
 *         return
 *     for el in sourceProxy._dependent_proxies:             # <<<<<<<<<<<<<<
 *         c_node = el._c_node
 *         el._c_node = NULL
 */
  if (PyList_CheckExact(__pyx_v_sourceProxy->_dependent_proxies) || PyTuple_CheckExact(__pyx_v_sourceProxy->_dependent_proxies)) {
    __pyx_2 = 0; __pyx_3 = __pyx_v_sourceProxy->_dependent_proxies; Py_INCREF(__pyx_3);
  } else {
    __pyx_2 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_sourceProxy->_dependent_proxies); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_3);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_el));
    __pyx_v_el = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":274
 *         return
 *     for el in sourceProxy._dependent_proxies:
 *         c_node = el._c_node             # <<<<<<<<<<<<<<
 *         el._c_node = NULL
 *         if el._free_after_use:
 */
    __pyx_v_c_node = __pyx_v_el->_c_node;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":275
 *     for el in sourceProxy._dependent_proxies:
 *         c_node = el._c_node
 *         el._c_node = NULL             # <<<<<<<<<<<<<<
 *         if el._free_after_use:
 *             tree.xmlFreeNode(c_node)
 */
    __pyx_v_el->_c_node = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":276
 *         c_node = el._c_node
 *         el._c_node = NULL
 *         if el._free_after_use:             # <<<<<<<<<<<<<<
 *             tree.xmlFreeNode(c_node)
 *     del sourceProxy._dependent_proxies[:]
 */
    __pyx_1 = __pyx_v_el->_free_after_use;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":277
 *         el._c_node = NULL
 *         if el._free_after_use:
 *             tree.xmlFreeNode(c_node)             # <<<<<<<<<<<<<<
 *     del sourceProxy._dependent_proxies[:]
 * 
 */
      xmlFreeNode(__pyx_v_c_node);
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":278
 *         if el._free_after_use:
 *             tree.xmlFreeNode(c_node)
 *     del sourceProxy._dependent_proxies[:]             # <<<<<<<<<<<<<<
 * 
 * cdef class _AppendOnlyElementProxy(_ReadOnlyElementProxy):
 */
  if (PySequence_DelSlice(__pyx_v_sourceProxy->_dependent_proxies, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._freeReadOnlyProxies");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_el);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":284
 *     text content (i.e. everything that adds to the subtree).
 *     """
 *     cpdef append(self, other_element):             # <<<<<<<<<<<<<<
 *         u"""Append a copy of an Element to the list of children.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_append(PyObject *__pyx_v_self, PyObject *__pyx_v_other_element); /*proto*/
static  PyObject *__pyx_f_4lxml_5etree_23_AppendOnlyElementProxy_append(struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *__pyx_v_self, PyObject *__pyx_v_other_element, int __pyx_skip_dispatch) {
  xmlNode *__pyx_v_c_next;
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  xmlNode *__pyx_5;
  xmlNode *__pyx_6;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_append); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(strcmp(Py_TYPE(__pyx_1)->tp_name, "builtin_function_or_method") == 0) || (PyCFunction_GET_FUNCTION(__pyx_1) != (void *)&__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_append)) {
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_other_element);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_other_element);
      __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
    }
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":289
 *         cdef xmlNode* c_next
 *         cdef xmlNode* c_node
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         c_node = _roNodeOf(other_element)
 *         c_node = _copyNodeToDoc(c_node, self._c_node.doc)
 */
  __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":290
 *         cdef xmlNode* c_node
 *         self._assertNode()
 *         c_node = _roNodeOf(other_element)             # <<<<<<<<<<<<<<
 *         c_node = _copyNodeToDoc(c_node, self._c_node.doc)
 *         c_next = c_node.next
 */
  __pyx_5 = __pyx_f_4lxml_5etree__roNodeOf(__pyx_v_other_element); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_node = __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":291
 *         self._assertNode()
 *         c_node = _roNodeOf(other_element)
 *         c_node = _copyNodeToDoc(c_node, self._c_node.doc)             # <<<<<<<<<<<<<<
 *         c_next = c_node.next
 *         tree.xmlAddChild(self._c_node, c_node)
 */
  __pyx_6 = __pyx_f_4lxml_5etree__copyNodeToDoc(__pyx_v_c_node, __pyx_v_self->__pyx_base._c_node->doc); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_node = __pyx_6;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":292
 *         c_node = _roNodeOf(other_element)
 *         c_node = _copyNodeToDoc(c_node, self._c_node.doc)
 *         c_next = c_node.next             # <<<<<<<<<<<<<<
 *         tree.xmlAddChild(self._c_node, c_node)
 *         _moveTail(c_next, c_node)
 */
  __pyx_v_c_next = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":293
 *         c_node = _copyNodeToDoc(c_node, self._c_node.doc)
 *         c_next = c_node.next
 *         tree.xmlAddChild(self._c_node, c_node)             # <<<<<<<<<<<<<<
 *         _moveTail(c_next, c_node)
 * 
 */
  xmlAddChild(__pyx_v_self->__pyx_base._c_node, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":294
 *         c_next = c_node.next
 *         tree.xmlAddChild(self._c_node, c_node)
 *         _moveTail(c_next, c_node)             # <<<<<<<<<<<<<<
 * 
 *     def extend(self, elements):
 */
  __pyx_f_4lxml_5etree__moveTail(__pyx_v_c_next, __pyx_v_c_node);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._AppendOnlyElementProxy.append");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":284
 *     text content (i.e. everything that adds to the subtree).
 *     """
 *     cpdef append(self, other_element):             # <<<<<<<<<<<<<<
 *         u"""Append a copy of an Element to the list of children.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_append(PyObject *__pyx_v_self, PyObject *__pyx_v_other_element); /*proto*/
static char __pyx_doc_4lxml_5etree_23_AppendOnlyElementProxy_append[] = "Append a copy of an Element to the list of children.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_append(PyObject *__pyx_v_self, PyObject *__pyx_v_other_element) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base.__pyx_vtab)->append(((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self), __pyx_v_other_element, 1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._AppendOnlyElementProxy.append");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":296
 *         _moveTail(c_next, c_node)
 * 
 *     def extend(self, elements):             # <<<<<<<<<<<<<<
 *         u"""Append a copy of all Elements from a sequence to the list of
 *         children.
 */

static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_extend(PyObject *__pyx_v_self, PyObject *__pyx_v_elements); /*proto*/
static char __pyx_doc_4lxml_5etree_23_AppendOnlyElementProxy_extend[] = "Append a copy of all Elements from a sequence to the list of\n        children.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_extend(PyObject *__pyx_v_self, PyObject *__pyx_v_elements) {
  PyObject *__pyx_v_element;
  PyObject *__pyx_r;
  int __pyx_1;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":300
 *         children.
 *         """
 *         self._assertNode()             # <<<<<<<<<<<<<<
 *         for element in elements:
 *             self.append(element)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":301
 *         """
 *         self._assertNode()
 *         for element in elements:             # <<<<<<<<<<<<<<
 *             self.append(element)
 * 
 */
  if (PyList_CheckExact(__pyx_v_elements) || PyTuple_CheckExact(__pyx_v_elements)) {
    __pyx_2 = 0; __pyx_3 = __pyx_v_elements; Py_INCREF(__pyx_3);
  } else {
    __pyx_2 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_elements); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_3);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_element);
    __pyx_v_element = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":302
 *         self._assertNode()
 *         for element in elements:
 *             self.append(element)             # <<<<<<<<<<<<<<
 * 
 *     property text:
 */
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base.__pyx_vtab)->append(((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self), __pyx_v_element, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._AppendOnlyElementProxy.extend");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":308
 *         value None, if there was no text.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             return _collectText(self._c_node.children)
 */

static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_4text___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_4text___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":309
 *         """
 *         def __get__(self):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             return _collectText(self._c_node.children)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":310
 *         def __get__(self):
 *             self._assertNode()
 *             return _collectText(self._c_node.children)             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, value):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectText(((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base._c_node->children); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._AppendOnlyElementProxy.text.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":312
 *             return _collectText(self._c_node.children)
 * 
 *         def __set__(self, value):             # <<<<<<<<<<<<<<
 *             self._assertNode()
 *             if isinstance(value, QName):
 */

static int __pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_4text___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_4text___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_value);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":313
 * 
 *         def __set__(self, value):
 *             self._assertNode()             # <<<<<<<<<<<<<<
 *             if isinstance(value, QName):
 *                 value = python.PyUnicode_FromEncodedObject(
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy *)((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._assertNode(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_self)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":314
 *         def __set__(self, value):
 *             self._assertNode()
 *             if isinstance(value, QName):             # <<<<<<<<<<<<<<
 *                 value = python.PyUnicode_FromEncodedObject(
 *                     _resolveQNameText(self, value), 'UTF-8', 'strict')
 */
  __pyx_2 = PyObject_TypeCheck(__pyx_v_value, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_QName))); 
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":316
 *             if isinstance(value, QName):
 *                 value = python.PyUnicode_FromEncodedObject(
 *                     _resolveQNameText(self, value), 'UTF-8', 'strict')             # <<<<<<<<<<<<<<
 *             _setNodeText(self._c_node, value)
 * 
 */
    if (!(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __pyx_f_4lxml_5etree__resolveQNameText(((struct LxmlElement *)__pyx_v_self), __pyx_v_value); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyUnicode_FromEncodedObject(__pyx_3, __pyx_k_373, __pyx_k_374); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":317
 *                 value = python.PyUnicode_FromEncodedObject(
 *                     _resolveQNameText(self, value), 'UTF-8', 'strict')
 *             _setNodeText(self._c_node, value)             # <<<<<<<<<<<<<<
 * 
 * cdef _AppendOnlyElementProxy _newAppendOnlyProxy(
 */
  __pyx_1 = __pyx_f_4lxml_5etree__setNodeText(((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_v_self)->__pyx_base._c_node, __pyx_v_value); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._AppendOnlyElementProxy.text.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":319
 *             _setNodeText(self._c_node, value)
 * 
 * cdef _AppendOnlyElementProxy _newAppendOnlyProxy(             # <<<<<<<<<<<<<<
 *     _ReadOnlyElementProxy source_proxy, xmlNode* c_node):
 *     cdef _AppendOnlyElementProxy el
 */

static  struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *__pyx_f_4lxml_5etree__newAppendOnlyProxy(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_source_proxy, xmlNode *__pyx_v_c_node) {
  struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *__pyx_v_el;
  struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_el = ((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":322
 *     _ReadOnlyElementProxy source_proxy, xmlNode* c_node):
 *     cdef _AppendOnlyElementProxy el
 *     el = <_AppendOnlyElementProxy>NEW_RO_PROXY(_AppendOnlyElementProxy)             # <<<<<<<<<<<<<<
 *     el._c_node = c_node
 *     _initReadOnlyProxy(el, source_proxy)
 */
  __pyx_1 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__AppendOnlyElementProxy)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_1)));
  Py_DECREF(((PyObject *)__pyx_v_el));
  __pyx_v_el = ((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)__pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":323
 *     cdef _AppendOnlyElementProxy el
 *     el = <_AppendOnlyElementProxy>NEW_RO_PROXY(_AppendOnlyElementProxy)
 *     el._c_node = c_node             # <<<<<<<<<<<<<<
 *     _initReadOnlyProxy(el, source_proxy)
 *     return el
 */
  __pyx_v_el->__pyx_base._c_node = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":324
 *     el = <_AppendOnlyElementProxy>NEW_RO_PROXY(_AppendOnlyElementProxy)
 *     el._c_node = c_node
 *     _initReadOnlyProxy(el, source_proxy)             # <<<<<<<<<<<<<<
 *     return el
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__initReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_el), __pyx_v_source_proxy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":325
 *     el._c_node = c_node
 *     _initReadOnlyProxy(el, source_proxy)
 *     return el             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* _roNodeOf(element) except NULL:
 */
  Py_INCREF(((PyObject *)__pyx_v_el));
  __pyx_r = __pyx_v_el;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._newAppendOnlyProxy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_el);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":327
 *     return el
 * 
 * cdef xmlNode* _roNodeOf(element) except NULL:             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     if isinstance(element, _Element):
 */

static  xmlNode *__pyx_f_4lxml_5etree__roNodeOf(PyObject *__pyx_v_element) {
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":329
 * cdef xmlNode* _roNodeOf(element) except NULL:
 *     cdef xmlNode* c_node
 *     if isinstance(element, _Element):             # <<<<<<<<<<<<<<
 *         c_node = (<_Element>element)._c_node
 *     elif isinstance(element, _ReadOnlyElementProxy):
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":330
 *     cdef xmlNode* c_node
 *     if isinstance(element, _Element):
 *         c_node = (<_Element>element)._c_node             # <<<<<<<<<<<<<<
 *     elif isinstance(element, _ReadOnlyElementProxy):
 *         c_node = (<_ReadOnlyElementProxy>element)._c_node
 */
    __pyx_v_c_node = ((struct LxmlElement *)__pyx_v_element)->_c_node;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":331
 *     if isinstance(element, _Element):
 *         c_node = (<_Element>element)._c_node
 *     elif isinstance(element, _ReadOnlyElementProxy):             # <<<<<<<<<<<<<<
 *         c_node = (<_ReadOnlyElementProxy>element)._c_node
 *     else:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_element, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ReadOnlyElementProxy))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":332
 *         c_node = (<_Element>element)._c_node
 *     elif isinstance(element, _ReadOnlyElementProxy):
 *         c_node = (<_ReadOnlyElementProxy>element)._c_node             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError, u"invalid value to append()"
 */
    __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_element)->_c_node;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":334
 *         c_node = (<_ReadOnlyElementProxy>element)._c_node
 *     else:
 *         raise TypeError, u"invalid value to append()"             # <<<<<<<<<<<<<<
 * 
 *     if c_node is NULL:
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_375), 0);
    {__pyx_filename = __pyx_f[8]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":336
 *         raise TypeError, u"invalid value to append()"
 * 
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         raise TypeError, u"invalid element"
 *     return c_node
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":337
 * 
 *     if c_node is NULL:
 *         raise TypeError, u"invalid element"             # <<<<<<<<<<<<<<
 *     return c_node
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_376), 0);
    {__pyx_filename = __pyx_f[8]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":338
 *     if c_node is NULL:
 *         raise TypeError, u"invalid element"
 *     return c_node             # <<<<<<<<<<<<<<
 */
  __pyx_r = __pyx_v_c_node;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._roNodeOf");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":76
 *     """
 *     cdef _element_class_lookup_function _lookup_function
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._lookup_function = NULL # use default lookup
 * 
 */

static int __pyx_pf_4lxml_5etree_18ElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_18ElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":77
 *     cdef _element_class_lookup_function _lookup_function
 *     def __cinit__(self):
 *         self._lookup_function = NULL # use default lookup             # <<<<<<<<<<<<<<
 * 
 * cdef public class FallbackElementClassLookup(ElementClassLookup) \
 */
  ((struct LxmlElementClassLookup *)__pyx_v_self)->_lookup_function = NULL;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":88
 *     cdef readonly ElementClassLookup fallback
 *     cdef _element_class_lookup_function _fallback_function
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         # fall back to default lookup
 *         self._fallback_function = _lookupDefaultElementClass
 */

static int __pyx_pf_4lxml_5etree_26FallbackElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_26FallbackElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":90
 *     def __cinit__(self):
 *         # fall back to default lookup
 *         self._fallback_function = _lookupDefaultElementClass             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, ElementClassLookup fallback=None):
 */
  ((struct LxmlFallbackElementClassLookup *)__pyx_v_self)->_fallback_function = __pyx_f_4lxml_5etree__lookupDefaultElementClass;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":92
 *         self._fallback_function = _lookupDefaultElementClass
 * 
 *     def __init__(self, ElementClassLookup fallback=None):             # <<<<<<<<<<<<<<
 *         if fallback is not None:
 *             self._setFallback(fallback)
 */

static int __pyx_pf_4lxml_5etree_26FallbackElementClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_26FallbackElementClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElementClassLookup *__pyx_v_fallback = 0;
  int __pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_fallback,0};
  __pyx_v_fallback = ((struct LxmlElementClassLookup *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_fallback = ((struct LxmlElementClassLookup *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_fallback = ((struct LxmlElementClassLookup *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.FallbackElementClassLookup.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fallback), __pyx_ptype_4lxml_5etree_ElementClassLookup, 1, "fallback", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":93
 * 
 *     def __init__(self, ElementClassLookup fallback=None):
 *         if fallback is not None:             # <<<<<<<<<<<<<<
 *             self._setFallback(fallback)
 *         else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_fallback) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":94
 *     def __init__(self, ElementClassLookup fallback=None):
 *         if fallback is not None:
 *             self._setFallback(fallback)             # <<<<<<<<<<<<<<
 *         else:
 *             self._fallback_function = _lookupDefaultElementClass
 */
    ((struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup *)((struct LxmlFallbackElementClassLookup *)__pyx_v_self)->__pyx_vtab)->_setFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_self), __pyx_v_fallback);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":96
 *             self._setFallback(fallback)
 *         else:
 *             self._fallback_function = _lookupDefaultElementClass             # <<<<<<<<<<<<<<
 * 
 *     cdef void _setFallback(self, ElementClassLookup lookup):
 */
    ((struct LxmlFallbackElementClassLookup *)__pyx_v_self)->_fallback_function = __pyx_f_4lxml_5etree__lookupDefaultElementClass;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.FallbackElementClassLookup.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":98
 *             self._fallback_function = _lookupDefaultElementClass
 * 
 *     cdef void _setFallback(self, ElementClassLookup lookup):             # <<<<<<<<<<<<<<
 *         u"""Sets the fallback scheme for this lookup method.
 *         """
 */

static  void __pyx_f_4lxml_5etree_26FallbackElementClassLookup__setFallback(struct LxmlFallbackElementClassLookup *__pyx_v_self, struct LxmlElementClassLookup *__pyx_v_lookup) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":101
 *         u"""Sets the fallback scheme for this lookup method.
 *         """
 *         self.fallback = lookup             # <<<<<<<<<<<<<<
 *         self._fallback_function = lookup._lookup_function
 *         if self._fallback_function is NULL:
 */
  Py_INCREF(((PyObject *)__pyx_v_lookup));
  Py_DECREF(((PyObject *)__pyx_v_self->fallback));
  __pyx_v_self->fallback = __pyx_v_lookup;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":102
 *         """
 *         self.fallback = lookup
 *         self._fallback_function = lookup._lookup_function             # <<<<<<<<<<<<<<
 *         if self._fallback_function is NULL:
 *             self._fallback_function = _lookupDefaultElementClass
 */
  __pyx_v_self->_fallback_function = __pyx_v_lookup->_lookup_function;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":103
 *         self.fallback = lookup
 *         self._fallback_function = lookup._lookup_function
 *         if self._fallback_function is NULL:             # <<<<<<<<<<<<<<
 *             self._fallback_function = _lookupDefaultElementClass
 * 
 */
  __pyx_1 = (__pyx_v_self->_fallback_function == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":104
 *         self._fallback_function = lookup._lookup_function
 *         if self._fallback_function is NULL:
 *             self._fallback_function = _lookupDefaultElementClass             # <<<<<<<<<<<<<<
 * 
 *     def set_fallback(self, ElementClassLookup lookup not None):
 */
    __pyx_v_self->_fallback_function = __pyx_f_4lxml_5etree__lookupDefaultElementClass;
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":106
 *             self._fallback_function = _lookupDefaultElementClass
 * 
 *     def set_fallback(self, ElementClassLookup lookup not None):             # <<<<<<<<<<<<<<
 *         u"""set_fallback(self, lookup)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_26FallbackElementClassLookup_set_fallback(PyObject *__pyx_v_self, PyObject *__pyx_v_lookup); /*proto*/
static char __pyx_doc_4lxml_5etree_26FallbackElementClassLookup_set_fallback[] = "set_fallback(self, lookup)\n\n        Sets the fallback scheme for this lookup method.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_26FallbackElementClassLookup_set_fallback(PyObject *__pyx_v_self, PyObject *__pyx_v_lookup) {
  PyObject *__pyx_r;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lookup), __pyx_ptype_4lxml_5etree_ElementClassLookup, 0, "lookup", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":111
 *         Sets the fallback scheme for this lookup method.
 *         """
 *         self._setFallback(lookup)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object _callLookupFallback(FallbackElementClassLookup lookup,
 */
  ((struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup *)((struct LxmlFallbackElementClassLookup *)__pyx_v_self)->__pyx_vtab)->_setFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_self), ((struct LxmlElementClassLookup *)__pyx_v_lookup));

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.FallbackElementClassLookup.set_fallback");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":113
 *         self._setFallback(lookup)
 * 
 * cdef inline object _callLookupFallback(FallbackElementClassLookup lookup,             # <<<<<<<<<<<<<<
 *                                        _Document doc, xmlNode* c_node):
 *     return lookup._fallback_function(lookup.fallback, doc, c_node)
 */

static INLINE PyObject *__pyx_f_4lxml_5etree__callLookupFallback(struct LxmlFallbackElementClassLookup *__pyx_v_lookup, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":115
 * cdef inline object _callLookupFallback(FallbackElementClassLookup lookup,
 *                                        _Document doc, xmlNode* c_node):
 *     return lookup._fallback_function(lookup.fallback, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = __pyx_v_lookup->_fallback_function(((PyObject *)__pyx_v_lookup->fallback), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._callLookupFallback");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":133
 *     cdef readonly object pi_class
 *     cdef readonly object entity_class
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._lookup_function = _lookupDefaultElementClass
 * 
 */

static int __pyx_pf_4lxml_5etree_25ElementDefaultClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_25ElementDefaultClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":134
 *     cdef readonly object entity_class
 *     def __cinit__(self):
 *         self._lookup_function = _lookupDefaultElementClass             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, element=None, comment=None, pi=None, entity=None):
 */
  ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->__pyx_base._lookup_function = __pyx_f_4lxml_5etree__lookupDefaultElementClass;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":136
 *         self._lookup_function = _lookupDefaultElementClass
 * 
 *     def __init__(self, element=None, comment=None, pi=None, entity=None):             # <<<<<<<<<<<<<<
 *         if element is None:
 *             self.element_class = _Element
 */

static int __pyx_pf_4lxml_5etree_25ElementDefaultClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_25ElementDefaultClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_element = 0;
  PyObject *__pyx_v_comment = 0;
  PyObject *__pyx_v_pi = 0;
  PyObject *__pyx_v_entity = 0;
  int __pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element,&__pyx_kp_comment,&__pyx_kp_pi,&__pyx_kp_entity,0};
  __pyx_v_element = Py_None;
  __pyx_v_comment = Py_None;
  __pyx_v_pi = Py_None;
  __pyx_v_entity = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_element = values[0];
    }
    if (values[1]) {
      __pyx_v_comment = values[1];
    }
    if (values[2]) {
      __pyx_v_pi = values[2];
    }
    if (values[3]) {
      __pyx_v_entity = values[3];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: __pyx_v_entity = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: __pyx_v_pi = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_comment = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_element = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ElementDefaultClassLookup.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":137
 * 
 *     def __init__(self, element=None, comment=None, pi=None, entity=None):
 *         if element is None:             # <<<<<<<<<<<<<<
 *             self.element_class = _Element
 *         elif issubclass(element, ElementBase):
 */
  __pyx_1 = (__pyx_v_element == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":138
 *     def __init__(self, element=None, comment=None, pi=None, entity=None):
 *         if element is None:
 *             self.element_class = _Element             # <<<<<<<<<<<<<<
 *         elif issubclass(element, ElementBase):
 *             self.element_class = element
 */
    Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element)));
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->element_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->element_class = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element));
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":139
 *         if element is None:
 *             self.element_class = _Element
 *         elif issubclass(element, ElementBase):             # <<<<<<<<<<<<<<
 *             self.element_class = element
 *         else:
 */
  __pyx_1 = PyObject_IsSubclass(__pyx_v_element, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementBase))); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":140
 *             self.element_class = _Element
 *         elif issubclass(element, ElementBase):
 *             self.element_class = element             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError, u"element class must be subclass of ElementBase"
 */
    Py_INCREF(__pyx_v_element);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->element_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->element_class = __pyx_v_element;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":142
 *             self.element_class = element
 *         else:
 *             raise TypeError, u"element class must be subclass of ElementBase"             # <<<<<<<<<<<<<<
 * 
 *         if comment is None:
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_377), 0);
    {__pyx_filename = __pyx_f[9]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":144
 *             raise TypeError, u"element class must be subclass of ElementBase"
 * 
 *         if comment is None:             # <<<<<<<<<<<<<<
 *             self.comment_class = _Comment
 *         elif issubclass(comment, CommentBase):
 */
  __pyx_1 = (__pyx_v_comment == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":145
 * 
 *         if comment is None:
 *             self.comment_class = _Comment             # <<<<<<<<<<<<<<
 *         elif issubclass(comment, CommentBase):
 *             self.comment_class = comment
 */
    Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Comment)));
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->comment_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->comment_class = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Comment));
    goto __pyx_L7;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":146
 *         if comment is None:
 *             self.comment_class = _Comment
 *         elif issubclass(comment, CommentBase):             # <<<<<<<<<<<<<<
 *             self.comment_class = comment
 *         else:
 */
  __pyx_1 = PyObject_IsSubclass(__pyx_v_comment, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_CommentBase))); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":147
 *             self.comment_class = _Comment
 *         elif issubclass(comment, CommentBase):
 *             self.comment_class = comment             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError, u"comment class must be subclass of CommentBase"
 */
    Py_INCREF(__pyx_v_comment);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->comment_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->comment_class = __pyx_v_comment;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":149
 *             self.comment_class = comment
 *         else:
 *             raise TypeError, u"comment class must be subclass of CommentBase"             # <<<<<<<<<<<<<<
 * 
 *         if entity is None:
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_378), 0);
    {__pyx_filename = __pyx_f[9]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":151
 *             raise TypeError, u"comment class must be subclass of CommentBase"
 * 
 *         if entity is None:             # <<<<<<<<<<<<<<
 *             self.entity_class = _Entity
 *         elif issubclass(entity, EntityBase):
 */
  __pyx_1 = (__pyx_v_entity == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":152
 * 
 *         if entity is None:
 *             self.entity_class = _Entity             # <<<<<<<<<<<<<<
 *         elif issubclass(entity, EntityBase):
 *             self.entity_class = entity
 */
    Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Entity)));
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->entity_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->entity_class = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Entity));
    goto __pyx_L8;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":153
 *         if entity is None:
 *             self.entity_class = _Entity
 *         elif issubclass(entity, EntityBase):             # <<<<<<<<<<<<<<
 *             self.entity_class = entity
 *         else:
 */
  __pyx_1 = PyObject_IsSubclass(__pyx_v_entity, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_EntityBase))); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":154
 *             self.entity_class = _Entity
 *         elif issubclass(entity, EntityBase):
 *             self.entity_class = entity             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError, u"Entity class must be subclass of EntityBase"
 */
    Py_INCREF(__pyx_v_entity);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->entity_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->entity_class = __pyx_v_entity;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":156
 *             self.entity_class = entity
 *         else:
 *             raise TypeError, u"Entity class must be subclass of EntityBase"             # <<<<<<<<<<<<<<
 * 
 *         if pi is None:
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_379), 0);
    {__pyx_filename = __pyx_f[9]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":158
 *             raise TypeError, u"Entity class must be subclass of EntityBase"
 * 
 *         if pi is None:             # <<<<<<<<<<<<<<
 *             self.pi_class = None # special case, see below
 *         elif issubclass(pi, PIBase):
 */
  __pyx_1 = (__pyx_v_pi == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":159
 * 
 *         if pi is None:
 *             self.pi_class = None # special case, see below             # <<<<<<<<<<<<<<
 *         elif issubclass(pi, PIBase):
 *             self.pi_class = pi
 */
    Py_INCREF(Py_None);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->pi_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->pi_class = Py_None;
    goto __pyx_L9;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":160
 *         if pi is None:
 *             self.pi_class = None # special case, see below
 *         elif issubclass(pi, PIBase):             # <<<<<<<<<<<<<<
 *             self.pi_class = pi
 *         else:
 */
  __pyx_1 = PyObject_IsSubclass(__pyx_v_pi, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_PIBase))); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":161
 *             self.pi_class = None # special case, see below
 *         elif issubclass(pi, PIBase):
 *             self.pi_class = pi             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError, u"PI class must be subclass of PIBase"
 */
    Py_INCREF(__pyx_v_pi);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->pi_class);
    ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_self)->pi_class = __pyx_v_pi;
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":163
 *             self.pi_class = pi
 *         else:
 *             raise TypeError, u"PI class must be subclass of PIBase"             # <<<<<<<<<<<<<<
 * 
 * cdef object _lookupDefaultElementClass(state, _Document _doc, xmlNode* c_node):
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_380), 0);
    {__pyx_filename = __pyx_f[9]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L9:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.ElementDefaultClassLookup.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":165
 *             raise TypeError, u"PI class must be subclass of PIBase"
 * 
 * cdef object _lookupDefaultElementClass(state, _Document _doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     u"Trivial class lookup function that always returns the default class."
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 */

static  PyObject *__pyx_f_4lxml_5etree__lookupDefaultElementClass(PyObject *__pyx_v_state, struct LxmlDocument *__pyx_v__doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_v_cls;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_cls = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":167
 * cdef object _lookupDefaultElementClass(state, _Document _doc, xmlNode* c_node):
 *     u"Trivial class lookup function that always returns the default class."
 *     if c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         if state is not None:
 *             return (<ElementDefaultClassLookup>state).element_class
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":168
 *     u"Trivial class lookup function that always returns the default class."
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         if state is not None:             # <<<<<<<<<<<<<<
 *             return (<ElementDefaultClassLookup>state).element_class
 *         else:
 */
    __pyx_1 = (__pyx_v_state != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":169
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         if state is not None:
 *             return (<ElementDefaultClassLookup>state).element_class             # <<<<<<<<<<<<<<
 *         else:
 *             return _Element
 */
      Py_INCREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->element_class);
      __pyx_r = ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->element_class;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":171
 *             return (<ElementDefaultClassLookup>state).element_class
 *         else:
 *             return _Element             # <<<<<<<<<<<<<<
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 *         if state is not None:
 */
      Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element)));
      __pyx_r = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element));
      goto __pyx_L0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":172
 *         else:
 *             return _Element
 *     elif c_node.type == tree.XML_COMMENT_NODE:             # <<<<<<<<<<<<<<
 *         if state is not None:
 *             return (<ElementDefaultClassLookup>state).comment_class
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_COMMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":173
 *             return _Element
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 *         if state is not None:             # <<<<<<<<<<<<<<
 *             return (<ElementDefaultClassLookup>state).comment_class
 *         else:
 */
    __pyx_1 = (__pyx_v_state != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":174
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 *         if state is not None:
 *             return (<ElementDefaultClassLookup>state).comment_class             # <<<<<<<<<<<<<<
 *         else:
 *             return _Comment
 */
      Py_INCREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->comment_class);
      __pyx_r = ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->comment_class;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":176
 *             return (<ElementDefaultClassLookup>state).comment_class
 *         else:
 *             return _Comment             # <<<<<<<<<<<<<<
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:
 *         if state is not None:
 */
      Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Comment)));
      __pyx_r = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Comment));
      goto __pyx_L0;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":177
 *         else:
 *             return _Comment
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:             # <<<<<<<<<<<<<<
 *         if state is not None:
 *             return (<ElementDefaultClassLookup>state).entity_class
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ENTITY_REF_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":178
 *             return _Comment
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:
 *         if state is not None:             # <<<<<<<<<<<<<<
 *             return (<ElementDefaultClassLookup>state).entity_class
 *         else:
 */
    __pyx_1 = (__pyx_v_state != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":179
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:
 *         if state is not None:
 *             return (<ElementDefaultClassLookup>state).entity_class             # <<<<<<<<<<<<<<
 *         else:
 *             return _Entity
 */
      Py_INCREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->entity_class);
      __pyx_r = ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->entity_class;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":181
 *             return (<ElementDefaultClassLookup>state).entity_class
 *         else:
 *             return _Entity             # <<<<<<<<<<<<<<
 *     elif c_node.type == tree.XML_PI_NODE:
 *         if state is not None:
 */
      Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Entity)));
      __pyx_r = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Entity));
      goto __pyx_L0;
    }
    __pyx_L6:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":182
 *         else:
 *             return _Entity
 *     elif c_node.type == tree.XML_PI_NODE:             # <<<<<<<<<<<<<<
 *         if state is not None:
 *             cls = (<ElementDefaultClassLookup>state).pi_class
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_PI_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":183
 *             return _Entity
 *     elif c_node.type == tree.XML_PI_NODE:
 *         if state is not None:             # <<<<<<<<<<<<<<
 *             cls = (<ElementDefaultClassLookup>state).pi_class
 *         if cls is None:
 */
    __pyx_1 = (__pyx_v_state != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":184
 *     elif c_node.type == tree.XML_PI_NODE:
 *         if state is not None:
 *             cls = (<ElementDefaultClassLookup>state).pi_class             # <<<<<<<<<<<<<<
 *         if cls is None:
 *             # special case XSLT-PI
 */
      Py_INCREF(((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->pi_class);
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)__pyx_v_state)->pi_class;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":185
 *         if state is not None:
 *             cls = (<ElementDefaultClassLookup>state).pi_class
 *         if cls is None:             # <<<<<<<<<<<<<<
 *             # special case XSLT-PI
 *             if c_node.name is not NULL and c_node.content is not NULL:
 */
    __pyx_1 = (__pyx_v_cls == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":187
 *         if cls is None:
 *             # special case XSLT-PI
 *             if c_node.name is not NULL and c_node.content is not NULL:             # <<<<<<<<<<<<<<
 *                 if cstd.strcmp(c_node.name, "xml-stylesheet") == 0:
 *                     if cstd.strstr(c_node.content, "text/xsl") is not NULL or \
 */
      __pyx_1 = (__pyx_v_c_node->name != NULL);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c_node->content != NULL);
      }
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":188
 *             # special case XSLT-PI
 *             if c_node.name is not NULL and c_node.content is not NULL:
 *                 if cstd.strcmp(c_node.name, "xml-stylesheet") == 0:             # <<<<<<<<<<<<<<
 *                     if cstd.strstr(c_node.content, "text/xsl") is not NULL or \
 *                            cstd.strstr(c_node.content, "text/xml") is not NULL:
 */
        __pyx_1 = (strcmp(__pyx_v_c_node->name, __pyx_k_381) == 0);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":189
 *             if c_node.name is not NULL and c_node.content is not NULL:
 *                 if cstd.strcmp(c_node.name, "xml-stylesheet") == 0:
 *                     if cstd.strstr(c_node.content, "text/xsl") is not NULL or \             # <<<<<<<<<<<<<<
 *                            cstd.strstr(c_node.content, "text/xml") is not NULL:
 *                         return _XSLTProcessingInstruction
 */
          __pyx_1 = (strstr(__pyx_v_c_node->content, __pyx_k_382) != NULL);
          if (!__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":190
 *                 if cstd.strcmp(c_node.name, "xml-stylesheet") == 0:
 *                     if cstd.strstr(c_node.content, "text/xsl") is not NULL or \
 *                            cstd.strstr(c_node.content, "text/xml") is not NULL:             # <<<<<<<<<<<<<<
 *                         return _XSLTProcessingInstruction
 *             return _ProcessingInstruction
 */
            __pyx_1 = (strstr(__pyx_v_c_node->content, __pyx_k_383) != NULL);
          }
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":191
 *                     if cstd.strstr(c_node.content, "text/xsl") is not NULL or \
 *                            cstd.strstr(c_node.content, "text/xml") is not NULL:
 *                         return _XSLTProcessingInstruction             # <<<<<<<<<<<<<<
 *             return _ProcessingInstruction
 *         else:
 */
            Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XSLTProcessingInstruction)));
            __pyx_r = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XSLTProcessingInstruction));
            goto __pyx_L0;
            goto __pyx_L11;
          }
          __pyx_L11:;
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":192
 *                            cstd.strstr(c_node.content, "text/xml") is not NULL:
 *                         return _XSLTProcessingInstruction
 *             return _ProcessingInstruction             # <<<<<<<<<<<<<<
 *         else:
 *             return cls
 */
      Py_INCREF(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ProcessingInstruction)));
      __pyx_r = ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ProcessingInstruction));
      goto __pyx_L0;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":194
 *             return _ProcessingInstruction
 *         else:
 *             return cls             # <<<<<<<<<<<<<<
 *     else:
 *         assert 0, u"Unknown node type: %s" % c_node.type
 */
      Py_INCREF(__pyx_v_cls);
      __pyx_r = __pyx_v_cls;
      goto __pyx_L0;
    }
    __pyx_L8:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":196
 *             return cls
 *     else:
 *         assert 0, u"Unknown node type: %s" % c_node.type             # <<<<<<<<<<<<<<
 * 
 * 
 */
    #ifndef PYREX_WITHOUT_ASSERTIONS
    if (unlikely(!0)) {
      __pyx_2 = PyInt_FromLong(__pyx_v_c_node->type); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_384), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[9]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._lookupDefaultElementClass");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_cls);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":219
 *     cdef char* _c_ns
 *     cdef char* _c_name
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._lookup_function = _attribute_class_lookup
 * 
 */

static int __pyx_pf_4lxml_5etree_32AttributeBasedElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_32AttributeBasedElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":220
 *     cdef char* _c_name
 *     def __cinit__(self):
 *         self._lookup_function = _attribute_class_lookup             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, attribute_name, class_mapping,
 */
  ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->__pyx_base.__pyx_base._lookup_function = __pyx_f_4lxml_5etree__attribute_class_lookup;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":222
 *         self._lookup_function = _attribute_class_lookup
 * 
 *     def __init__(self, attribute_name, class_mapping,             # <<<<<<<<<<<<<<
 *                  ElementClassLookup fallback=None):
 *         self._pytag = _getNsTag(attribute_name)
 */

static int __pyx_pf_4lxml_5etree_32AttributeBasedElementClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_32AttributeBasedElementClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_attribute_name = 0;
  PyObject *__pyx_v_class_mapping = 0;
  struct LxmlElementClassLookup *__pyx_v_fallback = 0;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_name;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_attribute_name,&__pyx_kp_class_mapping,&__pyx_kp_fallback,0};
  __pyx_v_fallback = ((struct LxmlElementClassLookup *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_attribute_name);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_class_mapping);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_attribute_name = values[0];
    __pyx_v_class_mapping = values[1];
    if (values[2]) {
      __pyx_v_fallback = ((struct LxmlElementClassLookup *)values[2]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_fallback = ((struct LxmlElementClassLookup *)PyTuple_GET_ITEM(__pyx_args, 2));
      case  2:
      __pyx_v_class_mapping = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_attribute_name = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.AttributeBasedElementClassLookup.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fallback), __pyx_ptype_4lxml_5etree_ElementClassLookup, 1, "fallback", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":224
 *     def __init__(self, attribute_name, class_mapping,
 *                  ElementClassLookup fallback=None):
 *         self._pytag = _getNsTag(attribute_name)             # <<<<<<<<<<<<<<
 *         ns, name = self._pytag
 *         if ns is None:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_attribute_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_pytag);
  ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_pytag = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":225
 *                  ElementClassLookup fallback=None):
 *         self._pytag = _getNsTag(attribute_name)
 *         ns, name = self._pytag             # <<<<<<<<<<<<<<
 *         if ns is None:
 *             self._c_ns = NULL
 */
  if (PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_pytag) && PyTuple_GET_SIZE(((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_pytag) == 2) {
    PyObject* tuple = ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_pytag;
    __pyx_2 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_2;
    __pyx_2 = 0;
  }
  else {
    __pyx_1 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_pytag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_2;
    __pyx_2 = 0;
    if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":226
 *         self._pytag = _getNsTag(attribute_name)
 *         ns, name = self._pytag
 *         if ns is None:             # <<<<<<<<<<<<<<
 *             self._c_ns = NULL
 *         else:
 */
  __pyx_3 = (__pyx_v_ns == Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":227
 *         ns, name = self._pytag
 *         if ns is None:
 *             self._c_ns = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             self._c_ns = _cstr(ns)
 */
    ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_c_ns = NULL;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":229
 *             self._c_ns = NULL
 *         else:
 *             self._c_ns = _cstr(ns)             # <<<<<<<<<<<<<<
 *         self._c_name = _cstr(name)
 *         self._class_mapping = dict(class_mapping)
 */
    ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_c_ns = PyString_AS_STRING(__pyx_v_ns);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":230
 *         else:
 *             self._c_ns = _cstr(ns)
 *         self._c_name = _cstr(name)             # <<<<<<<<<<<<<<
 *         self._class_mapping = dict(class_mapping)
 * 
 */
  ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_c_name = PyString_AS_STRING(__pyx_v_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":231
 *             self._c_ns = _cstr(ns)
 *         self._c_name = _cstr(name)
 *         self._class_mapping = dict(class_mapping)             # <<<<<<<<<<<<<<
 * 
 *         FallbackElementClassLookup.__init__(self, fallback)
 */
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_class_mapping);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_class_mapping);
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_class_mapping);
  ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_self)->_class_mapping = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":233
 *         self._class_mapping = dict(class_mapping)
 * 
 *         FallbackElementClassLookup.__init__(self, fallback)             # <<<<<<<<<<<<<<
 * 
 * cdef object _attribute_class_lookup(state, _Document doc, xmlNode* c_node):
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_FallbackElementClassLookup)), __pyx_kp___init__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(((PyObject *)__pyx_v_fallback));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_fallback));
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.AttributeBasedElementClassLookup.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":235
 *         FallbackElementClassLookup.__init__(self, fallback)
 * 
 * cdef object _attribute_class_lookup(state, _Document doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     cdef AttributeBasedElementClassLookup lookup
 *     cdef python.PyObject* dict_result
 */

static  PyObject *__pyx_f_4lxml_5etree__attribute_class_lookup(PyObject *__pyx_v_state, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *__pyx_v_lookup;
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)Py_None); Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":239
 *     cdef python.PyObject* dict_result
 * 
 *     lookup = <AttributeBasedElementClassLookup>state             # <<<<<<<<<<<<<<
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         value = _attributeValueFromNsName(
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_state)));
  Py_DECREF(((PyObject *)__pyx_v_lookup));
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)__pyx_v_state);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":240
 * 
 *     lookup = <AttributeBasedElementClassLookup>state
 *     if c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         value = _attributeValueFromNsName(
 *             c_node, lookup._c_ns, lookup._c_name)
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":242
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         value = _attributeValueFromNsName(
 *             c_node, lookup._c_ns, lookup._c_name)             # <<<<<<<<<<<<<<
 *         dict_result = python.PyDict_GetItem(lookup._class_mapping, value)
 *         if dict_result is not NULL:
 */
    __pyx_2 = __pyx_f_4lxml_5etree__attributeValueFromNsName(__pyx_v_c_node, __pyx_v_lookup->_c_ns, __pyx_v_lookup->_c_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":243
 *         value = _attributeValueFromNsName(
 *             c_node, lookup._c_ns, lookup._c_name)
 *         dict_result = python.PyDict_GetItem(lookup._class_mapping, value)             # <<<<<<<<<<<<<<
 *         if dict_result is not NULL:
 *             return <object>dict_result
 */
    __pyx_v_dict_result = PyDict_GetItem(__pyx_v_lookup->_class_mapping, __pyx_v_value);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":244
 *             c_node, lookup._c_ns, lookup._c_name)
 *         dict_result = python.PyDict_GetItem(lookup._class_mapping, value)
 *         if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *             return <object>dict_result
 *     return _callLookupFallback(lookup, doc, c_node)
 */
    __pyx_1 = (__pyx_v_dict_result != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":245
 *         dict_result = python.PyDict_GetItem(lookup._class_mapping, value)
 *         if dict_result is not NULL:
 *             return <object>dict_result             # <<<<<<<<<<<<<<
 *     return _callLookupFallback(lookup, doc, c_node)
 * 
 */
      Py_INCREF(((PyObject *)__pyx_v_dict_result));
      __pyx_r = ((PyObject *)__pyx_v_dict_result);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":246
 *         if dict_result is not NULL:
 *             return <object>dict_result
 *     return _callLookupFallback(lookup, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__callLookupFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_lookup), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._attribute_class_lookup");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_lookup);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":256
 *     Element class lookup based on the XML parser.
 *     """
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._lookup_function = _parser_class_lookup
 * 
 */

static int __pyx_pf_4lxml_5etree_29ParserBasedElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_29ParserBasedElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":257
 *     """
 *     def __cinit__(self):
 *         self._lookup_function = _parser_class_lookup             # <<<<<<<<<<<<<<
 * 
 * cdef object _parser_class_lookup(state, _Document doc, xmlNode* c_node):
 */
  ((struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup *)__pyx_v_self)->__pyx_base.__pyx_base._lookup_function = __pyx_f_4lxml_5etree__parser_class_lookup;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":259
 *         self._lookup_function = _parser_class_lookup
 * 
 * cdef object _parser_class_lookup(state, _Document doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     if doc._parser._class_lookup is not None:
 *         return doc._parser._class_lookup._lookup_function(
 */

static  PyObject *__pyx_f_4lxml_5etree__parser_class_lookup(PyObject *__pyx_v_state, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":260
 * 
 * cdef object _parser_class_lookup(state, _Document doc, xmlNode* c_node):
 *     if doc._parser._class_lookup is not None:             # <<<<<<<<<<<<<<
 *         return doc._parser._class_lookup._lookup_function(
 *             doc._parser._class_lookup, doc, c_node)
 */
  __pyx_1 = (((PyObject *)__pyx_v_doc->_parser->_class_lookup) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":262
 *     if doc._parser._class_lookup is not None:
 *         return doc._parser._class_lookup._lookup_function(
 *             doc._parser._class_lookup, doc, c_node)             # <<<<<<<<<<<<<<
 *     return _callLookupFallback(<FallbackElementClassLookup>state, doc, c_node)
 * 
 */
    __pyx_2 = __pyx_v_doc->_parser->_class_lookup->_lookup_function(((PyObject *)__pyx_v_doc->_parser->_class_lookup), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":263
 *         return doc._parser._class_lookup._lookup_function(
 *             doc._parser._class_lookup, doc, c_node)
 *     return _callLookupFallback(<FallbackElementClassLookup>state, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__callLookupFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_state), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._parser_class_lookup");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":285
 *     If you return None from this method, the fallback will be called.
 *     """
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._lookup_function = _custom_class_lookup
 * 
 */

static int __pyx_pf_4lxml_5etree_24CustomElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_24CustomElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":286
 *     """
 *     def __cinit__(self):
 *         self._lookup_function = _custom_class_lookup             # <<<<<<<<<<<<<<
 * 
 *     def lookup(self, type, doc, namespace, name):
 */
  ((struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *)__pyx_v_self)->__pyx_base.__pyx_base._lookup_function = __pyx_f_4lxml_5etree__custom_class_lookup;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":288
 *         self._lookup_function = _custom_class_lookup
 * 
 *     def lookup(self, type, doc, namespace, name):             # <<<<<<<<<<<<<<
 *         u"lookup(self, type, doc, namespace, name)"
 *         return None
 */

static PyObject *__pyx_pf_4lxml_5etree_24CustomElementClassLookup_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_24CustomElementClassLookup_lookup[] = "lookup(self, type, doc, namespace, name)";
static PyObject *__pyx_pf_4lxml_5etree_24CustomElementClassLookup_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_type = 0;
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_namespace = 0;
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_type,&__pyx_kp_doc,&__pyx_kp_namespace,&__pyx_kp_name,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_type);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_doc);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 1); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_namespace);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 2); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_name);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 3); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "lookup") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_type = values[0];
    __pyx_v_doc = values[1];
    __pyx_v_namespace = values[2];
    __pyx_v_name = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_type = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_doc = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_namespace = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_name = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.CustomElementClassLookup.lookup");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":290
 *     def lookup(self, type, doc, namespace, name):
 *         u"lookup(self, type, doc, namespace, name)"
 *         return None             # <<<<<<<<<<<<<<
 * 
 * cdef object _custom_class_lookup(state, _Document doc, xmlNode* c_node):
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":292
 *         return None
 * 
 * cdef object _custom_class_lookup(state, _Document doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     cdef CustomElementClassLookup lookup
 *     cdef char* c_str
 */

static  PyObject *__pyx_f_4lxml_5etree__custom_class_lookup(PyObject *__pyx_v_state, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *__pyx_v_lookup;
  char *__pyx_v_c_str;
  PyObject *__pyx_v_element_type;
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_cls;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element_type = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_cls = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":296
 *     cdef char* c_str
 * 
 *     lookup = <CustomElementClassLookup>state             # <<<<<<<<<<<<<<
 * 
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *)__pyx_v_state)));
  Py_DECREF(((PyObject *)__pyx_v_lookup));
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *)__pyx_v_state);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":298
 *     lookup = <CustomElementClassLookup>state
 * 
 *     if c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         element_type = u"element"
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":299
 * 
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         element_type = u"element"             # <<<<<<<<<<<<<<
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 *         element_type = u"comment"
 */
    Py_INCREF(((PyObject *)__pyx_kp_385));
    Py_DECREF(__pyx_v_element_type);
    __pyx_v_element_type = ((PyObject *)__pyx_kp_385);
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":300
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         element_type = u"element"
 *     elif c_node.type == tree.XML_COMMENT_NODE:             # <<<<<<<<<<<<<<
 *         element_type = u"comment"
 *     elif c_node.type == tree.XML_PI_NODE:
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_COMMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":301
 *         element_type = u"element"
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 *         element_type = u"comment"             # <<<<<<<<<<<<<<
 *     elif c_node.type == tree.XML_PI_NODE:
 *         element_type = u"PI"
 */
    Py_INCREF(((PyObject *)__pyx_kp_386));
    Py_DECREF(__pyx_v_element_type);
    __pyx_v_element_type = ((PyObject *)__pyx_kp_386);
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":302
 *     elif c_node.type == tree.XML_COMMENT_NODE:
 *         element_type = u"comment"
 *     elif c_node.type == tree.XML_PI_NODE:             # <<<<<<<<<<<<<<
 *         element_type = u"PI"
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_PI_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":303
 *         element_type = u"comment"
 *     elif c_node.type == tree.XML_PI_NODE:
 *         element_type = u"PI"             # <<<<<<<<<<<<<<
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:
 *         element_type = u"entity"
 */
    Py_INCREF(((PyObject *)__pyx_kp_387));
    Py_DECREF(__pyx_v_element_type);
    __pyx_v_element_type = ((PyObject *)__pyx_kp_387);
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":304
 *     elif c_node.type == tree.XML_PI_NODE:
 *         element_type = u"PI"
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:             # <<<<<<<<<<<<<<
 *         element_type = u"entity"
 *     else:
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ENTITY_REF_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":305
 *         element_type = u"PI"
 *     elif c_node.type == tree.XML_ENTITY_REF_NODE:
 *         element_type = u"entity"             # <<<<<<<<<<<<<<
 *     else:
 *         element_type = u"element"
 */
    Py_INCREF(((PyObject *)__pyx_kp_388));
    Py_DECREF(__pyx_v_element_type);
    __pyx_v_element_type = ((PyObject *)__pyx_kp_388);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":307
 *         element_type = u"entity"
 *     else:
 *         element_type = u"element"             # <<<<<<<<<<<<<<
 *     if c_node.name is NULL:
 *         name = None
 */
    Py_INCREF(((PyObject *)__pyx_kp_389));
    Py_DECREF(__pyx_v_element_type);
    __pyx_v_element_type = ((PyObject *)__pyx_kp_389);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":308
 *     else:
 *         element_type = u"element"
 *     if c_node.name is NULL:             # <<<<<<<<<<<<<<
 *         name = None
 *     else:
 */
  __pyx_1 = (__pyx_v_c_node->name == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":309
 *         element_type = u"element"
 *     if c_node.name is NULL:
 *         name = None             # <<<<<<<<<<<<<<
 *     else:
 *         name = funicode(c_node.name)
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = Py_None;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":311
 *         name = None
 *     else:
 *         name = funicode(c_node.name)             # <<<<<<<<<<<<<<
 *     c_str = tree._getNs(c_node)
 *     if c_str is NULL:
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_node->name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":312
 *     else:
 *         name = funicode(c_node.name)
 *     c_str = tree._getNs(c_node)             # <<<<<<<<<<<<<<
 *     if c_str is NULL:
 *         ns = None
 */
  __pyx_v_c_str = _getNs(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":313
 *         name = funicode(c_node.name)
 *     c_str = tree._getNs(c_node)
 *     if c_str is NULL:             # <<<<<<<<<<<<<<
 *         ns = None
 *     else:
 */
  __pyx_1 = (__pyx_v_c_str == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":314
 *     c_str = tree._getNs(c_node)
 *     if c_str is NULL:
 *         ns = None             # <<<<<<<<<<<<<<
 *     else:
 *         ns = funicode(c_str)
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = Py_None;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":316
 *         ns = None
 *     else:
 *         ns = funicode(c_str)             # <<<<<<<<<<<<<<
 * 
 *     cls = lookup.lookup(element_type, doc, ns, name)
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_str); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns);
    __pyx_v_ns = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":318
 *         ns = funicode(c_str)
 * 
 *     cls = lookup.lookup(element_type, doc, ns, name)             # <<<<<<<<<<<<<<
 *     if cls is not None:
 *         return cls
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_lookup), __pyx_kp_lookup); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_element_type);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_element_type);
  Py_INCREF(((PyObject *)__pyx_v_doc));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_doc));
  Py_INCREF(__pyx_v_ns);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_ns);
  Py_INCREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_3, 3, __pyx_v_name);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_v_cls);
  __pyx_v_cls = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":319
 * 
 *     cls = lookup.lookup(element_type, doc, ns, name)
 *     if cls is not None:             # <<<<<<<<<<<<<<
 *         return cls
 *     return _callLookupFallback(lookup, doc, c_node)
 */
  __pyx_1 = (__pyx_v_cls != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":320
 *     cls = lookup.lookup(element_type, doc, ns, name)
 *     if cls is not None:
 *         return cls             # <<<<<<<<<<<<<<
 *     return _callLookupFallback(lookup, doc, c_node)
 * 
 */
    Py_INCREF(__pyx_v_cls);
    __pyx_r = __pyx_v_cls;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":321
 *     if cls is not None:
 *         return cls
 *     return _callLookupFallback(lookup, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__callLookupFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_lookup), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._custom_class_lookup");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_lookup);
  Py_DECREF(__pyx_v_element_type);
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_cls);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":370
 *     See http://codespeak.net/lxml/element_classes.html
 *     """
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._lookup_function = _python_class_lookup
 * 
 */

static int __pyx_pf_4lxml_5etree_24PythonElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_24PythonElementClassLookup___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":371
 *     """
 *     def __cinit__(self):
 *         self._lookup_function = _python_class_lookup             # <<<<<<<<<<<<<<
 * 
 *     def lookup(self, doc, element):
 */
  ((struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *)__pyx_v_self)->__pyx_base.__pyx_base._lookup_function = __pyx_f_4lxml_5etree__python_class_lookup;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":373
 *         self._lookup_function = _python_class_lookup
 * 
 *     def lookup(self, doc, element):             # <<<<<<<<<<<<<<
 *         u"""lookup(self, doc, element)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_24PythonElementClassLookup_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_24PythonElementClassLookup_lookup[] = "lookup(self, doc, element)\n\n        Override this method to implement your own lookup scheme.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_24PythonElementClassLookup_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_doc = 0;
  PyObject *__pyx_v_element = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_doc,&__pyx_kp_element,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_doc);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("lookup", 1, 2, 2, 1); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "lookup") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_doc = values[0];
    __pyx_v_element = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_doc = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_element = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lookup", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.PythonElementClassLookup.lookup");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":378
 *         Override this method to implement your own lookup scheme.
 *         """
 *         return None             # <<<<<<<<<<<<<<
 * 
 * cdef object _python_class_lookup(state, _Document doc, tree.xmlNode* c_node):
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":380
 *         return None
 * 
 * cdef object _python_class_lookup(state, _Document doc, tree.xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     cdef PythonElementClassLookup lookup
 *     cdef _ReadOnlyElementProxy proxy
 */

static  PyObject *__pyx_f_4lxml_5etree__python_class_lookup(PyObject *__pyx_v_state, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *__pyx_v_lookup;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_proxy;
  PyObject *__pyx_v_cls;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *)Py_None); Py_INCREF(Py_None);
  __pyx_v_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  __pyx_v_cls = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":383
 *     cdef PythonElementClassLookup lookup
 *     cdef _ReadOnlyElementProxy proxy
 *     lookup = <PythonElementClassLookup>state             # <<<<<<<<<<<<<<
 * 
 *     proxy = _newReadOnlyProxy(None, c_node)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *)__pyx_v_state)));
  Py_DECREF(((PyObject *)__pyx_v_lookup));
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *)__pyx_v_state);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":385
 *     lookup = <PythonElementClassLookup>state
 * 
 *     proxy = _newReadOnlyProxy(None, c_node)             # <<<<<<<<<<<<<<
 *     cls = lookup.lookup(doc, proxy)
 *     _freeReadOnlyProxies(proxy)
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None), __pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_proxy));
  __pyx_v_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":386
 * 
 *     proxy = _newReadOnlyProxy(None, c_node)
 *     cls = lookup.lookup(doc, proxy)             # <<<<<<<<<<<<<<
 *     _freeReadOnlyProxies(proxy)
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_lookup), __pyx_kp_lookup); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_doc));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_doc));
  Py_INCREF(((PyObject *)__pyx_v_proxy));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_proxy));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_v_cls);
  __pyx_v_cls = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":387
 *     proxy = _newReadOnlyProxy(None, c_node)
 *     cls = lookup.lookup(doc, proxy)
 *     _freeReadOnlyProxies(proxy)             # <<<<<<<<<<<<<<
 * 
 *     if cls is not None:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__freeReadOnlyProxies(__pyx_v_proxy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":389
 *     _freeReadOnlyProxies(proxy)
 * 
 *     if cls is not None:             # <<<<<<<<<<<<<<
 *         return cls
 *     return _callLookupFallback(lookup, doc, c_node)
 */
  __pyx_4 = (__pyx_v_cls != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":390
 * 
 *     if cls is not None:
 *         return cls             # <<<<<<<<<<<<<<
 *     return _callLookupFallback(lookup, doc, c_node)
 * 
 */
    Py_INCREF(__pyx_v_cls);
    __pyx_r = __pyx_v_cls;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":391
 *     if cls is not None:
 *         return cls
 *     return _callLookupFallback(lookup, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  __pyx_2 = __pyx_f_4lxml_5etree__callLookupFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_lookup), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._python_class_lookup");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_lookup);
  Py_DECREF(__pyx_v_proxy);
  Py_DECREF(__pyx_v_cls);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":399
 * cdef object ELEMENT_CLASS_LOOKUP_STATE
 * 
 * cdef void _setElementClassLookupFunction(             # <<<<<<<<<<<<<<
 *     _element_class_lookup_function function, object state):
 *     global LOOKUP_ELEMENT_CLASS, ELEMENT_CLASS_LOOKUP_STATE
 */

static  void __pyx_f_4lxml_5etree__setElementClassLookupFunction(_element_class_lookup_function __pyx_v_function, PyObject *__pyx_v_state) {
  int __pyx_1;
  Py_INCREF(__pyx_v_state);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":402
 *     _element_class_lookup_function function, object state):
 *     global LOOKUP_ELEMENT_CLASS, ELEMENT_CLASS_LOOKUP_STATE
 *     if function is NULL:             # <<<<<<<<<<<<<<
 *         state    = DEFAULT_ELEMENT_CLASS_LOOKUP
 *         function = DEFAULT_ELEMENT_CLASS_LOOKUP._lookup_function
 */
  __pyx_1 = (__pyx_v_function == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":403
 *     global LOOKUP_ELEMENT_CLASS, ELEMENT_CLASS_LOOKUP_STATE
 *     if function is NULL:
 *         state    = DEFAULT_ELEMENT_CLASS_LOOKUP             # <<<<<<<<<<<<<<
 *         function = DEFAULT_ELEMENT_CLASS_LOOKUP._lookup_function
 * 
 */
    Py_INCREF(((PyObject *)__pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP));
    Py_DECREF(__pyx_v_state);
    __pyx_v_state = ((PyObject *)__pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":404
 *     if function is NULL:
 *         state    = DEFAULT_ELEMENT_CLASS_LOOKUP
 *         function = DEFAULT_ELEMENT_CLASS_LOOKUP._lookup_function             # <<<<<<<<<<<<<<
 * 
 *     ELEMENT_CLASS_LOOKUP_STATE = state
 */
    __pyx_v_function = __pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP->__pyx_base.__pyx_base._lookup_function;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":406
 *         function = DEFAULT_ELEMENT_CLASS_LOOKUP._lookup_function
 * 
 *     ELEMENT_CLASS_LOOKUP_STATE = state             # <<<<<<<<<<<<<<
 *     LOOKUP_ELEMENT_CLASS = function
 * 
 */
  Py_INCREF(__pyx_v_state);
  Py_DECREF(__pyx_v_4lxml_5etree_ELEMENT_CLASS_LOOKUP_STATE);
  __pyx_v_4lxml_5etree_ELEMENT_CLASS_LOOKUP_STATE = __pyx_v_state;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":407
 * 
 *     ELEMENT_CLASS_LOOKUP_STATE = state
 *     LOOKUP_ELEMENT_CLASS = function             # <<<<<<<<<<<<<<
 * 
 * def set_element_class_lookup(ElementClassLookup lookup = None):
 */
  __pyx_v_4lxml_5etree_LOOKUP_ELEMENT_CLASS = __pyx_v_function;

  Py_DECREF(__pyx_v_state);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":409
 *     LOOKUP_ELEMENT_CLASS = function
 * 
 * def set_element_class_lookup(ElementClassLookup lookup = None):             # <<<<<<<<<<<<<<
 *     u"""set_element_class_lookup(lookup = None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_set_element_class_lookup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_set_element_class_lookup[] = "set_element_class_lookup(lookup = None)\n\n    Set the global default element class lookup method.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_set_element_class_lookup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElementClassLookup *__pyx_v_lookup = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_lookup,0};
  __pyx_self = __pyx_self;
  __pyx_v_lookup = ((struct LxmlElementClassLookup *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_element_class_lookup") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_lookup = ((struct LxmlElementClassLookup *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_lookup = ((struct LxmlElementClassLookup *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_element_class_lookup", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.set_element_class_lookup");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lookup), __pyx_ptype_4lxml_5etree_ElementClassLookup, 1, "lookup", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":414
 *     Set the global default element class lookup method.
 *     """
 *     if lookup is None or lookup._lookup_function is NULL:             # <<<<<<<<<<<<<<
 *         _setElementClassLookupFunction(NULL, None)
 *     else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_lookup) == Py_None);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_lookup->_lookup_function == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":415
 *     """
 *     if lookup is None or lookup._lookup_function is NULL:
 *         _setElementClassLookupFunction(NULL, None)             # <<<<<<<<<<<<<<
 *     else:
 *         _setElementClassLookupFunction(lookup._lookup_function, lookup)
 */
    __pyx_f_4lxml_5etree__setElementClassLookupFunction(NULL, Py_None);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":417
 *         _setElementClassLookupFunction(NULL, None)
 *     else:
 *         _setElementClassLookupFunction(lookup._lookup_function, lookup)             # <<<<<<<<<<<<<<
 * 
 * # default setup: parser delegation
 */
    __pyx_f_4lxml_5etree__setElementClassLookupFunction(__pyx_v_lookup->_lookup_function, ((PyObject *)__pyx_v_lookup));
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.set_element_class_lookup");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":20
 *     cdef object _entries
 *     cdef char* _c_ns_uri_utf
 *     def __init__(self, ns_uri):             # <<<<<<<<<<<<<<
 *         self._ns_uri = ns_uri
 *         if ns_uri is None:
 */

static int __pyx_pf_4lxml_5etree_18_NamespaceRegistry___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_18_NamespaceRegistry___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ns_uri = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_ns_uri,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_ns_uri);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_ns_uri = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_ns_uri = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":21
 *     cdef char* _c_ns_uri_utf
 *     def __init__(self, ns_uri):
 *         self._ns_uri = ns_uri             # <<<<<<<<<<<<<<
 *         if ns_uri is None:
 *             self._ns_uri_utf = None
 */
  Py_INCREF(__pyx_v_ns_uri);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri);
  ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri = __pyx_v_ns_uri;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":22
 *     def __init__(self, ns_uri):
 *         self._ns_uri = ns_uri
 *         if ns_uri is None:             # <<<<<<<<<<<<<<
 *             self._ns_uri_utf = None
 *             self._c_ns_uri_utf = NULL
 */
  __pyx_1 = (__pyx_v_ns_uri == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":23
 *         self._ns_uri = ns_uri
 *         if ns_uri is None:
 *             self._ns_uri_utf = None             # <<<<<<<<<<<<<<
 *             self._c_ns_uri_utf = NULL
 *         else:
 */
    Py_INCREF(Py_None);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri_utf);
    ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri_utf = Py_None;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":24
 *         if ns_uri is None:
 *             self._ns_uri_utf = None
 *             self._c_ns_uri_utf = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             self._ns_uri_utf = _utf8(ns_uri)
 */
    ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_c_ns_uri_utf = NULL;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":26
 *             self._c_ns_uri_utf = NULL
 *         else:
 *             self._ns_uri_utf = _utf8(ns_uri)             # <<<<<<<<<<<<<<
 *             self._c_ns_uri_utf = _cstr(self._ns_uri_utf)
 *         self._entries = {}
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_ns_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri_utf);
    ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri_utf = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":27
 *         else:
 *             self._ns_uri_utf = _utf8(ns_uri)
 *             self._c_ns_uri_utf = _cstr(self._ns_uri_utf)             # <<<<<<<<<<<<<<
 *         self._entries = {}
 * 
 */
    ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_c_ns_uri_utf = PyString_AS_STRING(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_ns_uri_utf);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":28
 *             self._ns_uri_utf = _utf8(ns_uri)
 *             self._c_ns_uri_utf = _cstr(self._ns_uri_utf)
 *         self._entries = {}             # <<<<<<<<<<<<<<
 * 
 *     def update(self, class_dict_iterable):
 */
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries);
  ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":30
 *         self._entries = {}
 * 
 *     def update(self, class_dict_iterable):             # <<<<<<<<<<<<<<
 *         u"""update(self, class_dict_iterable)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_update(PyObject *__pyx_v_self, PyObject *__pyx_v_class_dict_iterable); /*proto*/
static char __pyx_doc_4lxml_5etree_18_NamespaceRegistry_update[] = "update(self, class_dict_iterable)\n\n        Forgivingly update the registry.\n\n        If registered values do not match the required type for this\n        registry, or if their name starts with '_', they will be\n        silently discarded. This allows registrations at the module or\n        class level using vars(), globals() etc.";
static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_update(PyObject *__pyx_v_self, PyObject *__pyx_v_class_dict_iterable) {
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  Py_INCREF(__pyx_v_class_dict_iterable);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":39
 *         silently discarded. This allows registrations at the module or
 *         class level using vars(), globals() etc."""
 *         if hasattr(class_dict_iterable, u'items'):             # <<<<<<<<<<<<<<
 *             class_dict_iterable = class_dict_iterable.items()
 *         for name, item in class_dict_iterable:
 */
  __pyx_1 = PyObject_HasAttr(__pyx_v_class_dict_iterable, ((PyObject *)__pyx_kp_390)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":40
 *         class level using vars(), globals() etc."""
 *         if hasattr(class_dict_iterable, u'items'):
 *             class_dict_iterable = class_dict_iterable.items()             # <<<<<<<<<<<<<<
 *         for name, item in class_dict_iterable:
 *             if (name is None or name[:1] != u'_') and callable(item):
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_class_dict_iterable, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_class_dict_iterable);
    __pyx_v_class_dict_iterable = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":41
 *         if hasattr(class_dict_iterable, u'items'):
 *             class_dict_iterable = class_dict_iterable.items()
 *         for name, item in class_dict_iterable:             # <<<<<<<<<<<<<<
 *             if (name is None or name[:1] != u'_') and callable(item):
 *                 self[name] = item
 */
  if (PyList_CheckExact(__pyx_v_class_dict_iterable) || PyTuple_CheckExact(__pyx_v_class_dict_iterable)) {
    __pyx_4 = 0; __pyx_2 = __pyx_v_class_dict_iterable; Py_INCREF(__pyx_2);
  } else {
    __pyx_4 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_class_dict_iterable); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_4 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_4); Py_INCREF(__pyx_3); __pyx_4++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_6);
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_6);
      Py_DECREF(__pyx_v_item);
      __pyx_v_item = __pyx_6;
      __pyx_6 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_5 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_item);
      __pyx_v_item = __pyx_6;
      __pyx_6 = 0;
      if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":42
 *             class_dict_iterable = class_dict_iterable.items()
 *         for name, item in class_dict_iterable:
 *             if (name is None or name[:1] != u'_') and callable(item):             # <<<<<<<<<<<<<<
 *                 self[name] = item
 * 
 */
    __pyx_1 = (__pyx_v_name == Py_None);
    if (!__pyx_1) {
      __pyx_6 = PySequence_GetSlice(__pyx_v_name, 0, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyObject_RichCompare(__pyx_6, ((PyObject *)__pyx_kp_391), Py_NE); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    if (__pyx_1) {
      __pyx_1 = PyCallable_Check(__pyx_v_item);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":43
 *         for name, item in class_dict_iterable:
 *             if (name is None or name[:1] != u'_') and callable(item):
 *                 self[name] = item             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, name):
 */
      if (PyObject_SetItem(__pyx_v_self, __pyx_v_name, __pyx_v_item) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.update");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_class_dict_iterable);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":45
 *                 self[name] = item
 * 
 *     def __getitem__(self, name):             # <<<<<<<<<<<<<<
 *         if name is not None:
 *             name = _utf8(name)
 */

static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":46
 * 
 *     def __getitem__(self, name):
 *         if name is not None:             # <<<<<<<<<<<<<<
 *             name = _utf8(name)
 *         return self._get(name)
 */
  __pyx_1 = (__pyx_v_name != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":47
 *     def __getitem__(self, name):
 *         if name is not None:
 *             name = _utf8(name)             # <<<<<<<<<<<<<<
 *         return self._get(name)
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":48
 *         if name is not None:
 *             name = _utf8(name)
 *         return self._get(name)             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, name):
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry *)((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->__pyx_vtab)->_get(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self), __pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":50
 *         return self._get(name)
 * 
 *     def __delitem__(self, name):             # <<<<<<<<<<<<<<
 *         if name is not None:
 *             name = _utf8(name)
 */

static int __pyx_pf_4lxml_5etree_18_NamespaceRegistry___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static int __pyx_pf_4lxml_5etree_18_NamespaceRegistry___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF(__pyx_v_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":51
 * 
 *     def __delitem__(self, name):
 *         if name is not None:             # <<<<<<<<<<<<<<
 *             name = _utf8(name)
 *         python.PyDict_DelItem(self._entries, name)
 */
  __pyx_1 = (__pyx_v_name != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":52
 *     def __delitem__(self, name):
 *         if name is not None:
 *             name = _utf8(name)             # <<<<<<<<<<<<<<
 *         python.PyDict_DelItem(self._entries, name)
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":53
 *         if name is not None:
 *             name = _utf8(name)
 *         python.PyDict_DelItem(self._entries, name)             # <<<<<<<<<<<<<<
 * 
 *     cdef object _get(self, object name):
 */
  __pyx_3 = PyDict_DelItem(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries, __pyx_v_name); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.__delitem__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":55
 *         python.PyDict_DelItem(self._entries, name)
 * 
 *     cdef object _get(self, object name):             # <<<<<<<<<<<<<<
 *         cdef python.PyObject* dict_result
 *         dict_result = python.PyDict_GetItem(self._entries, name)
 */

static  PyObject *__pyx_f_4lxml_5etree_18_NamespaceRegistry__get(struct __pyx_obj_4lxml_5etree__NamespaceRegistry *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":57
 *     cdef object _get(self, object name):
 *         cdef python.PyObject* dict_result
 *         dict_result = python.PyDict_GetItem(self._entries, name)             # <<<<<<<<<<<<<<
 *         if dict_result is NULL:
 *             raise KeyError, u"Name not registered."
 */
  __pyx_v_dict_result = PyDict_GetItem(__pyx_v_self->_entries, __pyx_v_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":58
 *         cdef python.PyObject* dict_result
 *         dict_result = python.PyDict_GetItem(self._entries, name)
 *         if dict_result is NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError, u"Name not registered."
 *         return <object>dict_result
 */
  __pyx_1 = (__pyx_v_dict_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":59
 *         dict_result = python.PyDict_GetItem(self._entries, name)
 *         if dict_result is NULL:
 *             raise KeyError, u"Name not registered."             # <<<<<<<<<<<<<<
 *         return <object>dict_result
 * 
 */
    __Pyx_Raise(__pyx_builtin_KeyError, ((PyObject *)__pyx_kp_392), 0);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":60
 *         if dict_result is NULL:
 *             raise KeyError, u"Name not registered."
 *         return <object>dict_result             # <<<<<<<<<<<<<<
 * 
 *     cdef object _getForString(self, char* name):
 */
  Py_INCREF(((PyObject *)__pyx_v_dict_result));
  __pyx_r = ((PyObject *)__pyx_v_dict_result);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry._get");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":62
 *         return <object>dict_result
 * 
 *     cdef object _getForString(self, char* name):             # <<<<<<<<<<<<<<
 *         cdef python.PyObject* dict_result
 *         dict_result = python.PyDict_GetItem(self._entries, name)
 */

static  PyObject *__pyx_f_4lxml_5etree_18_NamespaceRegistry__getForString(struct __pyx_obj_4lxml_5etree__NamespaceRegistry *__pyx_v_self, char *__pyx_v_name) {
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":64
 *     cdef object _getForString(self, char* name):
 *         cdef python.PyObject* dict_result
 *         dict_result = python.PyDict_GetItem(self._entries, name)             # <<<<<<<<<<<<<<
 *         if dict_result is NULL:
 *             raise KeyError, u"Name not registered."
 */
  __pyx_1 = __Pyx_PyBytes_FromString(__pyx_v_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_dict_result = PyDict_GetItem(__pyx_v_self->_entries, __pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":65
 *         cdef python.PyObject* dict_result
 *         dict_result = python.PyDict_GetItem(self._entries, name)
 *         if dict_result is NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError, u"Name not registered."
 *         return <object>dict_result
 */
  __pyx_2 = (__pyx_v_dict_result == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":66
 *         dict_result = python.PyDict_GetItem(self._entries, name)
 *         if dict_result is NULL:
 *             raise KeyError, u"Name not registered."             # <<<<<<<<<<<<<<
 *         return <object>dict_result
 * 
 */
    __Pyx_Raise(__pyx_builtin_KeyError, ((PyObject *)__pyx_kp_393), 0);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":67
 *         if dict_result is NULL:
 *             raise KeyError, u"Name not registered."
 *         return <object>dict_result             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_dict_result));
  __pyx_r = ((PyObject *)__pyx_v_dict_result);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry._getForString");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":69
 *         return <object>dict_result
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return iter(self._entries)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":70
 * 
 *     def __iter__(self):
 *         return iter(self._entries)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":72
 *         return iter(self._entries)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         return list(self._entries.items())
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_items(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_items(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":73
 * 
 *     def items(self):
 *         return list(self._entries.items())             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries, __pyx_kp_items); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)&PyList_Type)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.items");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":75
 *         return list(self._entries.items())
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         return iter(self._entries.items())
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_iteritems(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_iteritems(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":76
 * 
 *     def iteritems(self):
 *         return iter(self._entries.items())             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries, __pyx_kp_items); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._NamespaceRegistry.iteritems");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":78
 *         return iter(self._entries.items())
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         python.PyDict_Clear(self._entries)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_clear(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_18_NamespaceRegistry_clear(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":79
 * 
 *     def clear(self):
 *         python.PyDict_Clear(self._entries)             # <<<<<<<<<<<<<<
 * 
 * cdef class _ClassNamespaceRegistry(_NamespaceRegistry):
 */
  PyDict_Clear(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_self)->_entries);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":83
 * cdef class _ClassNamespaceRegistry(_NamespaceRegistry):
 *     u"Dictionary-like registry for namespace implementation classes"
 *     def __setitem__(self, name, item):             # <<<<<<<<<<<<<<
 *         if not python.PyType_Check(item) or not issubclass(item, ElementBase):
 *             raise NamespaceRegistryError, \
 */

static int __pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_item); /*proto*/
static int __pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_item) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":84
 *     u"Dictionary-like registry for namespace implementation classes"
 *     def __setitem__(self, name, item):
 *         if not python.PyType_Check(item) or not issubclass(item, ElementBase):             # <<<<<<<<<<<<<<
 *             raise NamespaceRegistryError, \
 *                 u"Registered element classes must be subtypes of ElementBase"
 */
  __pyx_1 = (!PyType_Check(__pyx_v_item));
  if (!__pyx_1) {
    __pyx_2 = PyObject_IsSubclass(__pyx_v_item, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ElementBase))); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = (!__pyx_2);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":85
 *     def __setitem__(self, name, item):
 *         if not python.PyType_Check(item) or not issubclass(item, ElementBase):
 *             raise NamespaceRegistryError, \             # <<<<<<<<<<<<<<
 *                 u"Registered element classes must be subtypes of ElementBase"
 *         if name is not None:
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_108); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":86
 *         if not python.PyType_Check(item) or not issubclass(item, ElementBase):
 *             raise NamespaceRegistryError, \
 *                 u"Registered element classes must be subtypes of ElementBase"             # <<<<<<<<<<<<<<
 *         if name is not None:
 *             name = _utf8(name)
 */
    __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_394), 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":87
 *             raise NamespaceRegistryError, \
 *                 u"Registered element classes must be subtypes of ElementBase"
 *         if name is not None:             # <<<<<<<<<<<<<<
 *             name = _utf8(name)
 *         self._entries[name] = item
 */
  __pyx_2 = (__pyx_v_name != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":88
 *                 u"Registered element classes must be subtypes of ElementBase"
 *         if name is not None:
 *             name = _utf8(name)             # <<<<<<<<<<<<<<
 *         self._entries[name] = item
 * 
 */
    __pyx_3 = __pyx_f_4lxml_5etree__utf8(__pyx_v_name); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":89
 *         if name is not None:
 *             name = _utf8(name)
 *         self._entries[name] = item             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  if (PyObject_SetItem(((struct __pyx_obj_4lxml_5etree__ClassNamespaceRegistry *)__pyx_v_self)->__pyx_base._entries, __pyx_v_name, __pyx_v_item) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ClassNamespaceRegistry.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":91
 *         self._entries[name] = item
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"Namespace(%r)" % self._ns_uri
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":92
 * 
 *     def __repr__(self):
 *         return u"Namespace(%r)" % self._ns_uri             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_395), ((struct __pyx_obj_4lxml_5etree__ClassNamespaceRegistry *)__pyx_v_self)->__pyx_base._ns_uri); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ClassNamespaceRegistry.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":102
 *     """
 *     cdef object _namespace_registries
 *     def __init__(self, ElementClassLookup fallback=None):             # <<<<<<<<<<<<<<
 *         self._namespace_registries = {}
 *         FallbackElementClassLookup.__init__(self, fallback)
 */

static int __pyx_pf_4lxml_5etree_27ElementNamespaceClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_27ElementNamespaceClassLookup___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElementClassLookup *__pyx_v_fallback = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_fallback,0};
  __pyx_v_fallback = ((struct LxmlElementClassLookup *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_fallback = ((struct LxmlElementClassLookup *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_fallback = ((struct LxmlElementClassLookup *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ElementNamespaceClassLookup.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fallback), __pyx_ptype_4lxml_5etree_ElementClassLookup, 1, "fallback", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":103
 *     cdef object _namespace_registries
 *     def __init__(self, ElementClassLookup fallback=None):
 *         self._namespace_registries = {}             # <<<<<<<<<<<<<<
 *         FallbackElementClassLookup.__init__(self, fallback)
 *         self._lookup_function = _find_nselement_class
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_self)->_namespace_registries);
  ((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_self)->_namespace_registries = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":104
 *     def __init__(self, ElementClassLookup fallback=None):
 *         self._namespace_registries = {}
 *         FallbackElementClassLookup.__init__(self, fallback)             # <<<<<<<<<<<<<<
 *         self._lookup_function = _find_nselement_class
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_FallbackElementClassLookup)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(((PyObject *)__pyx_v_fallback));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_fallback));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":105
 *         self._namespace_registries = {}
 *         FallbackElementClassLookup.__init__(self, fallback)
 *         self._lookup_function = _find_nselement_class             # <<<<<<<<<<<<<<
 * 
 *     def get_namespace(self, ns_uri):
 */
  ((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_self)->__pyx_base.__pyx_base._lookup_function = __pyx_f_4lxml_5etree__find_nselement_class;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.ElementNamespaceClassLookup.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":107
 *         self._lookup_function = _find_nselement_class
 * 
 *     def get_namespace(self, ns_uri):             # <<<<<<<<<<<<<<
 *         u"""get_namespace(self, ns_uri)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_27ElementNamespaceClassLookup_get_namespace(PyObject *__pyx_v_self, PyObject *__pyx_v_ns_uri); /*proto*/
static char __pyx_doc_4lxml_5etree_27ElementNamespaceClassLookup_get_namespace[] = "get_namespace(self, ns_uri)\n\n        Retrieve the namespace object associated with the given URI.\n\n        Creates a new one if it does not yet exist.";
static PyObject *__pyx_pf_4lxml_5etree_27ElementNamespaceClassLookup_get_namespace(PyObject *__pyx_v_self, PyObject *__pyx_v_ns_uri) {
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_registry;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_registry = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":113
 * 
 *         Creates a new one if it does not yet exist."""
 *         if ns_uri:             # <<<<<<<<<<<<<<
 *             ns_utf = _utf8(ns_uri)
 *         else:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_ns_uri); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":114
 *         Creates a new one if it does not yet exist."""
 *         if ns_uri:
 *             ns_utf = _utf8(ns_uri)             # <<<<<<<<<<<<<<
 *         else:
 *             ns_utf = None
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_ns_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":116
 *             ns_utf = _utf8(ns_uri)
 *         else:
 *             ns_utf = None             # <<<<<<<<<<<<<<
 *         try:
 *             return self._namespace_registries[ns_utf]
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = Py_None;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":117
 *         else:
 *             ns_utf = None
 *         try:             # <<<<<<<<<<<<<<
 *             return self._namespace_registries[ns_utf]
 *         except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":118
 *             ns_utf = None
 *         try:
 *             return self._namespace_registries[ns_utf]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             registry = self._namespace_registries[ns_utf] = \
 */
      __pyx_2 = PyObject_GetItem(((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_self)->_namespace_registries, __pyx_v_ns_utf); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":119
 *         try:
 *             return self._namespace_registries[ns_utf]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             registry = self._namespace_registries[ns_utf] = \
 *                        _ClassNamespaceRegistry(ns_uri)
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.get_namespace");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":121
 *         except KeyError:
 *             registry = self._namespace_registries[ns_utf] = \
 *                        _ClassNamespaceRegistry(ns_uri)             # <<<<<<<<<<<<<<
 *             return registry
 * 
 */
      __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_INCREF(__pyx_v_ns_uri);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_ns_uri);
      __pyx_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ClassNamespaceRegistry)), ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      Py_INCREF(__pyx_7);
      Py_DECREF(__pyx_v_registry);
      __pyx_v_registry = __pyx_7;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":120
 *             return self._namespace_registries[ns_utf]
 *         except KeyError:
 *             registry = self._namespace_registries[ns_utf] = \             # <<<<<<<<<<<<<<
 *                        _ClassNamespaceRegistry(ns_uri)
 *             return registry
 */
      if (PyObject_SetItem(((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_self)->_namespace_registries, __pyx_v_ns_utf, __pyx_7) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":122
 *             registry = self._namespace_registries[ns_utf] = \
 *                        _ClassNamespaceRegistry(ns_uri)
 *             return registry             # <<<<<<<<<<<<<<
 * 
 * cdef object _find_nselement_class(state, _Document doc, xmlNode* c_node):
 */
      Py_INCREF(__pyx_v_registry);
      __pyx_r = __pyx_v_registry;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L9_except_return;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree.ElementNamespaceClassLookup.get_namespace");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_registry);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":124
 *             return registry
 * 
 * cdef object _find_nselement_class(state, _Document doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     cdef python.PyObject* dict_result
 *     cdef ElementNamespaceClassLookup lookup
 */

static  PyObject *__pyx_f_4lxml_5etree__find_nselement_class(PyObject *__pyx_v_state, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_v_dict_result;
  struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *__pyx_v_lookup;
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry *__pyx_v_registry;
  char *__pyx_v_c_namespace_utf;
  PyObject *__pyx_v_classes;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)Py_None); Py_INCREF(Py_None);
  __pyx_v_registry = ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_classes = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":129
 *     cdef _NamespaceRegistry registry
 *     cdef char* c_namespace_utf
 *     if state is None:             # <<<<<<<<<<<<<<
 *         return _lookupDefaultElementClass(None, doc, c_node)
 * 
 */
  __pyx_1 = (__pyx_v_state == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":130
 *     cdef char* c_namespace_utf
 *     if state is None:
 *         return _lookupDefaultElementClass(None, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     lookup = <ElementNamespaceClassLookup>state
 */
    __pyx_2 = __pyx_f_4lxml_5etree__lookupDefaultElementClass(Py_None, __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":132
 *         return _lookupDefaultElementClass(None, doc, c_node)
 * 
 *     lookup = <ElementNamespaceClassLookup>state             # <<<<<<<<<<<<<<
 *     if c_node.type != tree.XML_ELEMENT_NODE:
 *         return _callLookupFallback(lookup, doc, c_node)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_state)));
  Py_DECREF(((PyObject *)__pyx_v_lookup));
  __pyx_v_lookup = ((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)__pyx_v_state);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":133
 * 
 *     lookup = <ElementNamespaceClassLookup>state
 *     if c_node.type != tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         return _callLookupFallback(lookup, doc, c_node)
 * 
 */
  __pyx_1 = (__pyx_v_c_node->type != XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":134
 *     lookup = <ElementNamespaceClassLookup>state
 *     if c_node.type != tree.XML_ELEMENT_NODE:
 *         return _callLookupFallback(lookup, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     c_namespace_utf = _getNs(c_node)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__callLookupFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_lookup), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":136
 *         return _callLookupFallback(lookup, doc, c_node)
 * 
 *     c_namespace_utf = _getNs(c_node)             # <<<<<<<<<<<<<<
 *     if c_namespace_utf is not NULL:
 *         dict_result = python.PyDict_GetItem(
 */
  __pyx_v_c_namespace_utf = _getNs(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":137
 * 
 *     c_namespace_utf = _getNs(c_node)
 *     if c_namespace_utf is not NULL:             # <<<<<<<<<<<<<<
 *         dict_result = python.PyDict_GetItem(
 *             lookup._namespace_registries, c_namespace_utf)
 */
  __pyx_1 = (__pyx_v_c_namespace_utf != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":139
 *     if c_namespace_utf is not NULL:
 *         dict_result = python.PyDict_GetItem(
 *             lookup._namespace_registries, c_namespace_utf)             # <<<<<<<<<<<<<<
 *     else:
 *         dict_result = python.PyDict_GetItem(
 */
    __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_c_namespace_utf); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_dict_result = PyDict_GetItem(__pyx_v_lookup->_namespace_registries, __pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":142
 *     else:
 *         dict_result = python.PyDict_GetItem(
 *             lookup._namespace_registries, None)             # <<<<<<<<<<<<<<
 *     if dict_result is not NULL:
 *         registry = <_NamespaceRegistry>dict_result
 */
    __pyx_v_dict_result = PyDict_GetItem(__pyx_v_lookup->_namespace_registries, Py_None);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":143
 *         dict_result = python.PyDict_GetItem(
 *             lookup._namespace_registries, None)
 *     if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *         registry = <_NamespaceRegistry>dict_result
 *         classes = registry._entries
 */
  __pyx_1 = (__pyx_v_dict_result != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":144
 *             lookup._namespace_registries, None)
 *     if dict_result is not NULL:
 *         registry = <_NamespaceRegistry>dict_result             # <<<<<<<<<<<<<<
 *         classes = registry._entries
 * 
 */
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_dict_result)));
    Py_DECREF(((PyObject *)__pyx_v_registry));
    __pyx_v_registry = ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_dict_result);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":145
 *     if dict_result is not NULL:
 *         registry = <_NamespaceRegistry>dict_result
 *         classes = registry._entries             # <<<<<<<<<<<<<<
 * 
 *         if c_node.name is not NULL:
 */
    Py_INCREF(__pyx_v_registry->_entries);
    Py_DECREF(__pyx_v_classes);
    __pyx_v_classes = __pyx_v_registry->_entries;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":147
 *         classes = registry._entries
 * 
 *         if c_node.name is not NULL:             # <<<<<<<<<<<<<<
 *             dict_result = python.PyDict_GetItem(
 *                 classes, c_node.name)
 */
    __pyx_1 = (__pyx_v_c_node->name != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":149
 *         if c_node.name is not NULL:
 *             dict_result = python.PyDict_GetItem(
 *                 classes, c_node.name)             # <<<<<<<<<<<<<<
 *         else:
 *             dict_result = NULL
 */
      __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_c_node->name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_dict_result = PyDict_GetItem(__pyx_v_classes, __pyx_2);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":151
 *                 classes, c_node.name)
 *         else:
 *             dict_result = NULL             # <<<<<<<<<<<<<<
 * 
 *         if dict_result is NULL:
 */
      __pyx_v_dict_result = NULL;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":153
 *             dict_result = NULL
 * 
 *         if dict_result is NULL:             # <<<<<<<<<<<<<<
 *             dict_result = python.PyDict_GetItem(classes, None)
 * 
 */
    __pyx_1 = (__pyx_v_dict_result == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":154
 * 
 *         if dict_result is NULL:
 *             dict_result = python.PyDict_GetItem(classes, None)             # <<<<<<<<<<<<<<
 * 
 *         if dict_result is not NULL:
 */
      __pyx_v_dict_result = PyDict_GetItem(__pyx_v_classes, Py_None);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":156
 *             dict_result = python.PyDict_GetItem(classes, None)
 * 
 *         if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *             return <object>dict_result
 *     return _callLookupFallback(lookup, doc, c_node)
 */
    __pyx_1 = (__pyx_v_dict_result != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":157
 * 
 *         if dict_result is not NULL:
 *             return <object>dict_result             # <<<<<<<<<<<<<<
 *     return _callLookupFallback(lookup, doc, c_node)
 * 
 */
      Py_INCREF(((PyObject *)__pyx_v_dict_result));
      __pyx_r = ((PyObject *)__pyx_v_dict_result);
      goto __pyx_L0;
      goto __pyx_L9;
    }
    __pyx_L9:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":158
 *         if dict_result is not NULL:
 *             return <object>dict_result
 *     return _callLookupFallback(lookup, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__callLookupFallback(((struct LxmlFallbackElementClassLookup *)__pyx_v_lookup), __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._find_nselement_class");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_lookup);
  Py_DECREF(__pyx_v_registry);
  Py_DECREF(__pyx_v_classes);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":167
 * __FUNCTION_NAMESPACE_REGISTRIES = {}
 * 
 * def FunctionNamespace(ns_uri):             # <<<<<<<<<<<<<<
 *     u"""FunctionNamespace(ns_uri)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_FunctionNamespace(PyObject *__pyx_self, PyObject *__pyx_v_ns_uri); /*proto*/
static char __pyx_doc_4lxml_5etree_FunctionNamespace[] = "FunctionNamespace(ns_uri)\n\n    Retrieve the function namespace object associated with the given\n    URI.\n\n    Creates a new one if it does not yet exist. A function namespace\n    can only be used to register extension functions.";
static PyObject *__pyx_pf_4lxml_5etree_FunctionNamespace(PyObject *__pyx_self, PyObject *__pyx_v_ns_uri) {
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_registry;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  __pyx_self = __pyx_self;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_registry = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":175
 *     Creates a new one if it does not yet exist. A function namespace
 *     can only be used to register extension functions."""
 *     if ns_uri:             # <<<<<<<<<<<<<<
 *         ns_utf = _utf8(ns_uri)
 *     else:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_ns_uri); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":176
 *     can only be used to register extension functions."""
 *     if ns_uri:
 *         ns_utf = _utf8(ns_uri)             # <<<<<<<<<<<<<<
 *     else:
 *         ns_utf = None
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_ns_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":178
 *         ns_utf = _utf8(ns_uri)
 *     else:
 *         ns_utf = None             # <<<<<<<<<<<<<<
 *     try:
 *         return __FUNCTION_NAMESPACE_REGISTRIES[ns_utf]
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_ns_utf);
    __pyx_v_ns_utf = Py_None;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":179
 *     else:
 *         ns_utf = None
 *     try:             # <<<<<<<<<<<<<<
 *         return __FUNCTION_NAMESPACE_REGISTRIES[ns_utf]
 *     except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":180
 *         ns_utf = None
 *     try:
 *         return __FUNCTION_NAMESPACE_REGISTRIES[ns_utf]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         registry = __FUNCTION_NAMESPACE_REGISTRIES[ns_utf] = \
 */
      __pyx_2 = PyObject_GetItem(__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES, __pyx_v_ns_utf); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":181
 *     try:
 *         return __FUNCTION_NAMESPACE_REGISTRIES[ns_utf]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         registry = __FUNCTION_NAMESPACE_REGISTRIES[ns_utf] = \
 *                    _XPathFunctionNamespaceRegistry(ns_uri)
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.FunctionNamespace");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":183
 *     except KeyError:
 *         registry = __FUNCTION_NAMESPACE_REGISTRIES[ns_utf] = \
 *                    _XPathFunctionNamespaceRegistry(ns_uri)             # <<<<<<<<<<<<<<
 *         return registry
 * 
 */
      __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_INCREF(__pyx_v_ns_uri);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_ns_uri);
      __pyx_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XPathFunctionNamespaceRegistry)), ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      Py_INCREF(__pyx_7);
      Py_DECREF(__pyx_v_registry);
      __pyx_v_registry = __pyx_7;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":182
 *         return __FUNCTION_NAMESPACE_REGISTRIES[ns_utf]
 *     except KeyError:
 *         registry = __FUNCTION_NAMESPACE_REGISTRIES[ns_utf] = \             # <<<<<<<<<<<<<<
 *                    _XPathFunctionNamespaceRegistry(ns_uri)
 *         return registry
 */
      if (PyObject_SetItem(__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES, __pyx_v_ns_utf, __pyx_7) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":184
 *         registry = __FUNCTION_NAMESPACE_REGISTRIES[ns_utf] = \
 *                    _XPathFunctionNamespaceRegistry(ns_uri)
 *         return registry             # <<<<<<<<<<<<<<
 * 
 * cdef class _FunctionNamespaceRegistry(_NamespaceRegistry):
 */
      Py_INCREF(__pyx_v_registry);
      __pyx_r = __pyx_v_registry;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L9_except_return;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree.FunctionNamespace");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_registry);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":187
 * 
 * cdef class _FunctionNamespaceRegistry(_NamespaceRegistry):
 *     def __setitem__(self, name, item):             # <<<<<<<<<<<<<<
 *         if not callable(item):
 *             raise NamespaceRegistryError, \
 */

static int __pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_item); /*proto*/
static int __pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_item) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":188
 * cdef class _FunctionNamespaceRegistry(_NamespaceRegistry):
 *     def __setitem__(self, name, item):
 *         if not callable(item):             # <<<<<<<<<<<<<<
 *             raise NamespaceRegistryError, \
 *                 u"Registered functions must be callable."
 */
  __pyx_1 = (!PyCallable_Check(__pyx_v_item));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":189
 *     def __setitem__(self, name, item):
 *         if not callable(item):
 *             raise NamespaceRegistryError, \             # <<<<<<<<<<<<<<
 *                 u"Registered functions must be callable."
 *         if not name:
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_108); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":190
 *         if not callable(item):
 *             raise NamespaceRegistryError, \
 *                 u"Registered functions must be callable."             # <<<<<<<<<<<<<<
 *         if not name:
 *             raise ValueError, \
 */
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_396), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":191
 *             raise NamespaceRegistryError, \
 *                 u"Registered functions must be callable."
 *         if not name:             # <<<<<<<<<<<<<<
 *             raise ValueError, \
 *                 u"extensions must have non empty names"
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = (!__pyx_1);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":193
 *         if not name:
 *             raise ValueError, \
 *                 u"extensions must have non empty names"             # <<<<<<<<<<<<<<
 *         self._entries[_utf8(name)] = item
 * 
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_397), 0);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":194
 *             raise ValueError, \
 *                 u"extensions must have non empty names"
 *         self._entries[_utf8(name)] = item             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetItem(((struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry *)__pyx_v_self)->__pyx_base._entries, __pyx_2, __pyx_v_item) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._FunctionNamespaceRegistry.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":196
 *         self._entries[_utf8(name)] = item
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return u"FunctionNamespace(%r)" % self._ns_uri
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":197
 * 
 *     def __repr__(self):
 *         return u"FunctionNamespace(%r)" % self._ns_uri             # <<<<<<<<<<<<<<
 * 
 * cdef class _XPathFunctionNamespaceRegistry(_FunctionNamespaceRegistry):
 */
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_398), ((struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry *)__pyx_v_self)->__pyx_base._ns_uri); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._FunctionNamespaceRegistry.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":205
 *     property prefix:
 *         u"Namespace prefix for extension functions."
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             self._prefix = None # no prefix configured
 *             self._prefix_utf = None
 */

static int __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___del__(PyObject *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":206
 *         u"Namespace prefix for extension functions."
 *         def __del__(self):
 *             self._prefix = None # no prefix configured             # <<<<<<<<<<<<<<
 *             self._prefix_utf = None
 *         def __get__(self):
 */
  Py_INCREF(Py_None);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix);
  ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":207
 *         def __del__(self):
 *             self._prefix = None # no prefix configured
 *             self._prefix_utf = None             # <<<<<<<<<<<<<<
 *         def __get__(self):
 *             if self._prefix is None:
 */
  Py_INCREF(Py_None);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix_utf);
  ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix_utf = Py_None;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":208
 *             self._prefix = None # no prefix configured
 *             self._prefix_utf = None
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._prefix is None:
 *                 return ''
 */

static PyObject *__pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":209
 *             self._prefix_utf = None
 *         def __get__(self):
 *             if self._prefix is None:             # <<<<<<<<<<<<<<
 *                 return ''
 *             else:
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":210
 *         def __get__(self):
 *             if self._prefix is None:
 *                 return ''             # <<<<<<<<<<<<<<
 *             else:
 *                 return self._prefix
 */
    Py_INCREF(__pyx_kp_399);
    __pyx_r = __pyx_kp_399;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":212
 *                 return ''
 *             else:
 *                 return self._prefix             # <<<<<<<<<<<<<<
 *         def __set__(self, prefix):
 *             if prefix == '':
 */
    Py_INCREF(((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix);
    __pyx_r = ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":213
 *             else:
 *                 return self._prefix
 *         def __set__(self, prefix):             # <<<<<<<<<<<<<<
 *             if prefix == '':
 *                 prefix = None # empty prefix
 */

static int __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix); /*proto*/
static int __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF(__pyx_v_prefix);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":214
 *                 return self._prefix
 *         def __set__(self, prefix):
 *             if prefix == '':             # <<<<<<<<<<<<<<
 *                 prefix = None # empty prefix
 *             if prefix is None:
 */
  __pyx_1 = PyObject_RichCompare(__pyx_v_prefix, __pyx_kp_400, Py_EQ); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":215
 *         def __set__(self, prefix):
 *             if prefix == '':
 *                 prefix = None # empty prefix             # <<<<<<<<<<<<<<
 *             if prefix is None:
 *                 self._prefix_utf = None
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_prefix);
    __pyx_v_prefix = Py_None;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":216
 *             if prefix == '':
 *                 prefix = None # empty prefix
 *             if prefix is None:             # <<<<<<<<<<<<<<
 *                 self._prefix_utf = None
 *             else:
 */
  __pyx_2 = (__pyx_v_prefix == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":217
 *                 prefix = None # empty prefix
 *             if prefix is None:
 *                 self._prefix_utf = None             # <<<<<<<<<<<<<<
 *             else:
 *                 self._prefix_utf = _utf8(prefix)
 */
    Py_INCREF(Py_None);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix_utf);
    ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix_utf = Py_None;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":219
 *                 self._prefix_utf = None
 *             else:
 *                 self._prefix_utf = _utf8(prefix)             # <<<<<<<<<<<<<<
 *             self._prefix = prefix
 * 
 */
    __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_prefix); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix_utf);
    ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix_utf = __pyx_1;
    __pyx_1 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":220
 *             else:
 *                 self._prefix_utf = _utf8(prefix)
 *             self._prefix = prefix             # <<<<<<<<<<<<<<
 * 
 * cdef object _find_all_extension_prefixes():
 */
  Py_INCREF(__pyx_v_prefix);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix);
  ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_v_self)->_prefix = __pyx_v_prefix;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XPathFunctionNamespaceRegistry.prefix.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":222
 *             self._prefix = prefix
 * 
 * cdef object _find_all_extension_prefixes():             # <<<<<<<<<<<<<<
 *     u"Internal lookup function to find all function prefixes for XSLT/XPath."
 *     cdef _XPathFunctionNamespaceRegistry registry
 */

static  PyObject *__pyx_f_4lxml_5etree__find_all_extension_prefixes(void) {
  struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *__pyx_v_registry;
  PyObject *__pyx_v_ns_prefixes;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_registry = ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_ns_prefixes = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":225
 *     u"Internal lookup function to find all function prefixes for XSLT/XPath."
 *     cdef _XPathFunctionNamespaceRegistry registry
 *     ns_prefixes = []             # <<<<<<<<<<<<<<
 *     for registry in __FUNCTION_NAMESPACE_REGISTRIES.values():
 *         if registry._prefix_utf is not None:
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_ns_prefixes);
  __pyx_v_ns_prefixes = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":226
 *     cdef _XPathFunctionNamespaceRegistry registry
 *     ns_prefixes = []
 *     for registry in __FUNCTION_NAMESPACE_REGISTRIES.values():             # <<<<<<<<<<<<<<
 *         if registry._prefix_utf is not None:
 *             if registry._ns_uri_utf is not None:
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES, __pyx_kp_values); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) {
    __pyx_2 = 0; __pyx_1 = __pyx_3; Py_INCREF(__pyx_1);
  } else {
    __pyx_2 = -1; __pyx_1 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_1, __pyx_2); Py_INCREF(__pyx_3); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_1, __pyx_2); Py_INCREF(__pyx_3); __pyx_2++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__XPathFunctionNamespaceRegistry))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_registry));
    __pyx_v_registry = ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)__pyx_3);
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":227
 *     ns_prefixes = []
 *     for registry in __FUNCTION_NAMESPACE_REGISTRIES.values():
 *         if registry._prefix_utf is not None:             # <<<<<<<<<<<<<<
 *             if registry._ns_uri_utf is not None:
 *                 python.PyList_Append(
 */
    __pyx_4 = (__pyx_v_registry->_prefix_utf != Py_None);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":228
 *     for registry in __FUNCTION_NAMESPACE_REGISTRIES.values():
 *         if registry._prefix_utf is not None:
 *             if registry._ns_uri_utf is not None:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(
 *                     ns_prefixes, (registry._prefix_utf, registry._ns_uri_utf))
 */
      __pyx_4 = (__pyx_v_registry->__pyx_base.__pyx_base._ns_uri_utf != Py_None);
      if (__pyx_4) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":230
 *             if registry._ns_uri_utf is not None:
 *                 python.PyList_Append(
 *                     ns_prefixes, (registry._prefix_utf, registry._ns_uri_utf))             # <<<<<<<<<<<<<<
 *     return ns_prefixes
 * 
 */
        __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_registry->_prefix_utf);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_registry->_prefix_utf);
        Py_INCREF(__pyx_v_registry->__pyx_base.__pyx_base._ns_uri_utf);
        PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_registry->__pyx_base.__pyx_base._ns_uri_utf);
        __pyx_5 = PyList_Append(__pyx_v_ns_prefixes, ((PyObject *)__pyx_3)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":231
 *                 python.PyList_Append(
 *                     ns_prefixes, (registry._prefix_utf, registry._ns_uri_utf))
 *     return ns_prefixes             # <<<<<<<<<<<<<<
 * 
 * cdef object _iter_ns_extension_functions():
 */
  Py_INCREF(__pyx_v_ns_prefixes);
  __pyx_r = __pyx_v_ns_prefixes;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._find_all_extension_prefixes");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_registry);
  Py_DECREF(__pyx_v_ns_prefixes);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":233
 *     return ns_prefixes
 * 
 * cdef object _iter_ns_extension_functions():             # <<<<<<<<<<<<<<
 *     return __FUNCTION_NAMESPACE_REGISTRIES.items()
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree__iter_ns_extension_functions(void) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":234
 * 
 * cdef object _iter_ns_extension_functions():
 *     return __FUNCTION_NAMESPACE_REGISTRIES.items()             # <<<<<<<<<<<<<<
 * 
 * cdef object _find_extension(ns_uri_utf, name_utf):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES, __pyx_kp_items); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._iter_ns_extension_functions");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":236
 *     return __FUNCTION_NAMESPACE_REGISTRIES.items()
 * 
 * cdef object _find_extension(ns_uri_utf, name_utf):             # <<<<<<<<<<<<<<
 *     cdef python.PyObject* dict_result
 *     dict_result = python.PyDict_GetItem(
 */

static  PyObject *__pyx_f_4lxml_5etree__find_extension(PyObject *__pyx_v_ns_uri_utf, PyObject *__pyx_v_name_utf) {
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_v_extensions;
  PyObject *__pyx_r;
  int __pyx_1;
  __pyx_v_extensions = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":239
 *     cdef python.PyObject* dict_result
 *     dict_result = python.PyDict_GetItem(
 *         __FUNCTION_NAMESPACE_REGISTRIES, ns_uri_utf)             # <<<<<<<<<<<<<<
 *     if dict_result is NULL:
 *         return None
 */
  __pyx_v_dict_result = PyDict_GetItem(__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES, __pyx_v_ns_uri_utf);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":240
 *     dict_result = python.PyDict_GetItem(
 *         __FUNCTION_NAMESPACE_REGISTRIES, ns_uri_utf)
 *     if dict_result is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     extensions = (<_NamespaceRegistry>dict_result)._entries
 */
  __pyx_1 = (__pyx_v_dict_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":241
 *         __FUNCTION_NAMESPACE_REGISTRIES, ns_uri_utf)
 *     if dict_result is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     extensions = (<_NamespaceRegistry>dict_result)._entries
 *     dict_result = python.PyDict_GetItem(extensions, name_utf)
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":242
 *     if dict_result is NULL:
 *         return None
 *     extensions = (<_NamespaceRegistry>dict_result)._entries             # <<<<<<<<<<<<<<
 *     dict_result = python.PyDict_GetItem(extensions, name_utf)
 *     if dict_result is NULL:
 */
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_dict_result)->_entries);
  Py_DECREF(__pyx_v_extensions);
  __pyx_v_extensions = ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)__pyx_v_dict_result)->_entries;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":243
 *         return None
 *     extensions = (<_NamespaceRegistry>dict_result)._entries
 *     dict_result = python.PyDict_GetItem(extensions, name_utf)             # <<<<<<<<<<<<<<
 *     if dict_result is NULL:
 *         return None
 */
  __pyx_v_dict_result = PyDict_GetItem(__pyx_v_extensions, __pyx_v_name_utf);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":244
 *     extensions = (<_NamespaceRegistry>dict_result)._entries
 *     dict_result = python.PyDict_GetItem(extensions, name_utf)
 *     if dict_result is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_1 = (__pyx_v_dict_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":245
 *     dict_result = python.PyDict_GetItem(extensions, name_utf)
 *     if dict_result is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>dict_result
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":247
 *         return None
 *     else:
 *         return <object>dict_result             # <<<<<<<<<<<<<<
 */
    Py_INCREF(((PyObject *)__pyx_v_dict_result));
    __pyx_r = ((PyObject *)__pyx_v_dict_result);
    goto __pyx_L0;
  }
  __pyx_L4:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  Py_DECREF(__pyx_v_extensions);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":17
 * cdef class Resolver:
 *     u"This is the base class of all resolvers."
 *     def resolve(self, system_url, public_id, context):             # <<<<<<<<<<<<<<
 *         u"""resolve(self, system_url, public_id, context)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8Resolver_resolve[] = "resolve(self, system_url, public_id, context)\n\n        Override this method to resolve an external source by\n        ``system_url`` and ``public_id``.  The third argument is an\n        opaque context object.\n\n        Return the result of one of the ``resolve_*()`` methods.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_system_url = 0;
  PyObject *__pyx_v_public_id = 0;
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_system_url,&__pyx_kp_public_id,&__pyx_kp_context,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_system_url);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_public_id);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve", 1, 3, 3, 1); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve", 1, 3, 3, 2); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "resolve") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_system_url = values[0];
    __pyx_v_public_id = values[1];
    __pyx_v_context = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_system_url = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_public_id = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resolve", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":26
 *         Return the result of one of the ``resolve_*()`` methods.
 *         """
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def resolve_empty(self, context):
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":28
 *         return None
 * 
 *     def resolve_empty(self, context):             # <<<<<<<<<<<<<<
 *         u"""resolve_empty(self, context)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_empty(PyObject *__pyx_v_self, PyObject *__pyx_v_context); /*proto*/
static char __pyx_doc_4lxml_5etree_8Resolver_resolve_empty[] = "resolve_empty(self, context)\n\n        Return an empty input document.\n\n        Pass context as parameter.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_empty(PyObject *__pyx_v_self, PyObject *__pyx_v_context) {
  struct __pyx_obj_4lxml_5etree__InputDocument *__pyx_v_doc_ref;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":36
 *         """
 *         cdef _InputDocument doc_ref
 *         doc_ref = _InputDocument()             # <<<<<<<<<<<<<<
 *         doc_ref._type = PARSER_DATA_EMPTY
 *         return doc_ref
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__InputDocument)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__InputDocument))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":37
 *         cdef _InputDocument doc_ref
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_EMPTY             # <<<<<<<<<<<<<<
 *         return doc_ref
 * 
 */
  __pyx_v_doc_ref->_type = __pyx_e_4lxml_5etree_PARSER_DATA_EMPTY;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":38
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_EMPTY
 *         return doc_ref             # <<<<<<<<<<<<<<
 * 
 *     def resolve_string(self, string, context, *, base_url=None):
 */
  Py_INCREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_r = ((PyObject *)__pyx_v_doc_ref);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_empty");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc_ref);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":40
 *         return doc_ref
 * 
 *     def resolve_string(self, string, context, *, base_url=None):             # <<<<<<<<<<<<<<
 *         u"""resolve_string(self, string, context, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_string(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8Resolver_resolve_string[] = "resolve_string(self, string, context, base_url=None)\n\n        Return a parsable string as input document.\n\n        Pass data string and context as parameters.\n\n        You can pass the source URL as 'base_url' keyword.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_string(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_string = 0;
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_v_base_url = 0;
  struct __pyx_obj_4lxml_5etree__InputDocument *__pyx_v_doc_ref;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_string,&__pyx_kp_context,&__pyx_kp_base_url,0};
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_string);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve_string", 1, 2, 2, 1); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "resolve_string") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_string = values[0];
    __pyx_v_context = values[1];
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_string = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resolve_string", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_string");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_string);
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":50
 *         """
 *         cdef _InputDocument doc_ref
 *         if python.PyUnicode_Check(string):             # <<<<<<<<<<<<<<
 *             string = python.PyUnicode_AsUTF8String(string)
 *         elif not python.PyString_Check(string):
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_string);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":51
 *         cdef _InputDocument doc_ref
 *         if python.PyUnicode_Check(string):
 *             string = python.PyUnicode_AsUTF8String(string)             # <<<<<<<<<<<<<<
 *         elif not python.PyString_Check(string):
 *             raise TypeError, "argument must be a byte string or unicode string"
 */
    __pyx_2 = PyUnicode_AsUTF8String(__pyx_v_string); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_string);
    __pyx_v_string = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":52
 *         if python.PyUnicode_Check(string):
 *             string = python.PyUnicode_AsUTF8String(string)
 *         elif not python.PyString_Check(string):             # <<<<<<<<<<<<<<
 *             raise TypeError, "argument must be a byte string or unicode string"
 *         doc_ref = _InputDocument()
 */
  __pyx_3 = (!PyString_Check(__pyx_v_string));
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":53
 *             string = python.PyUnicode_AsUTF8String(string)
 *         elif not python.PyString_Check(string):
 *             raise TypeError, "argument must be a byte string or unicode string"             # <<<<<<<<<<<<<<
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_STRING
 */
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_kp_401, 0);
    {__pyx_filename = __pyx_f[11]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":54
 *         elif not python.PyString_Check(string):
 *             raise TypeError, "argument must be a byte string or unicode string"
 *         doc_ref = _InputDocument()             # <<<<<<<<<<<<<<
 *         doc_ref._type = PARSER_DATA_STRING
 *         doc_ref._data_bytes = string
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__InputDocument)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__InputDocument))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":55
 *             raise TypeError, "argument must be a byte string or unicode string"
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_STRING             # <<<<<<<<<<<<<<
 *         doc_ref._data_bytes = string
 *         if base_url is not None:
 */
  __pyx_v_doc_ref->_type = __pyx_e_4lxml_5etree_PARSER_DATA_STRING;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":56
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_STRING
 *         doc_ref._data_bytes = string             # <<<<<<<<<<<<<<
 *         if base_url is not None:
 *             doc_ref._filename = _encodeFilename(base_url)
 */
  Py_INCREF(__pyx_v_string);
  Py_DECREF(__pyx_v_doc_ref->_data_bytes);
  __pyx_v_doc_ref->_data_bytes = __pyx_v_string;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":57
 *         doc_ref._type = PARSER_DATA_STRING
 *         doc_ref._data_bytes = string
 *         if base_url is not None:             # <<<<<<<<<<<<<<
 *             doc_ref._filename = _encodeFilename(base_url)
 *         return doc_ref
 */
  __pyx_3 = (__pyx_v_base_url != Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":58
 *         doc_ref._data_bytes = string
 *         if base_url is not None:
 *             doc_ref._filename = _encodeFilename(base_url)             # <<<<<<<<<<<<<<
 *         return doc_ref
 * 
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_base_url); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_doc_ref->_filename);
    __pyx_v_doc_ref->_filename = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":59
 *         if base_url is not None:
 *             doc_ref._filename = _encodeFilename(base_url)
 *         return doc_ref             # <<<<<<<<<<<<<<
 * 
 *     def resolve_filename(self, filename, context):
 */
  Py_INCREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_r = ((PyObject *)__pyx_v_doc_ref);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_string");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc_ref);
  Py_DECREF(__pyx_v_string);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":61
 *         return doc_ref
 * 
 *     def resolve_filename(self, filename, context):             # <<<<<<<<<<<<<<
 *         u"""resolve_filename(self, filename, context)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_filename(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8Resolver_resolve_filename[] = "resolve_filename(self, filename, context)\n\n        Return the name of a parsable file as input document.\n\n        Pass filename and context as parameters.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_filename(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_context = 0;
  struct __pyx_obj_4lxml_5etree__InputDocument *__pyx_v_doc_ref;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_filename,&__pyx_kp_context,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_filename);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve_filename", 1, 2, 2, 1); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "resolve_filename") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_filename = values[0];
    __pyx_v_context = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_filename = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resolve_filename", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_filename");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":69
 *         """
 *         cdef _InputDocument doc_ref
 *         doc_ref = _InputDocument()             # <<<<<<<<<<<<<<
 *         doc_ref._type = PARSER_DATA_FILENAME
 *         doc_ref._filename = _encodeFilename(filename)
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__InputDocument)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__InputDocument))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":70
 *         cdef _InputDocument doc_ref
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_FILENAME             # <<<<<<<<<<<<<<
 *         doc_ref._filename = _encodeFilename(filename)
 *         return doc_ref
 */
  __pyx_v_doc_ref->_type = __pyx_e_4lxml_5etree_PARSER_DATA_FILENAME;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":71
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_FILENAME
 *         doc_ref._filename = _encodeFilename(filename)             # <<<<<<<<<<<<<<
 *         return doc_ref
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_filename); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_doc_ref->_filename);
  __pyx_v_doc_ref->_filename = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":72
 *         doc_ref._type = PARSER_DATA_FILENAME
 *         doc_ref._filename = _encodeFilename(filename)
 *         return doc_ref             # <<<<<<<<<<<<<<
 * 
 *     def resolve_file(self, f, context, *, base_url=None):
 */
  Py_INCREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_r = ((PyObject *)__pyx_v_doc_ref);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_filename");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc_ref);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":74
 *         return doc_ref
 * 
 *     def resolve_file(self, f, context, *, base_url=None):             # <<<<<<<<<<<<<<
 *         u"""resolve_file(self, f, context, base_url=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_file(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8Resolver_resolve_file[] = "resolve_file(self, f, context, base_url=None)\n\n        Return an open file-like object as input document.\n\n        Pass open file and context as parameters.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_8Resolver_resolve_file(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_f = 0;
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_v_base_url = 0;
  struct __pyx_obj_4lxml_5etree__InputDocument *__pyx_v_doc_ref;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_f,&__pyx_kp_context,&__pyx_kp_base_url,0};
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_f);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve_file", 1, 2, 2, 1); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "resolve_file") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_f = values[0];
    __pyx_v_context = values[1];
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_f = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resolve_file", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_file");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":82
 *         """
 *         cdef _InputDocument doc_ref
 *         try:             # <<<<<<<<<<<<<<
 *             f.read
 *         except AttributeError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":83
 *         cdef _InputDocument doc_ref
 *         try:
 *             f.read             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             raise TypeError, u"Argument is not a file-like object"
 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_f, __pyx_kp_read); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":84
 *         try:
 *             f.read
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             raise TypeError, u"Argument is not a file-like object"
 *         doc_ref = _InputDocument()
 */
    __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree.resolve_file");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":85
 *             f.read
 *         except AttributeError:
 *             raise TypeError, u"Argument is not a file-like object"             # <<<<<<<<<<<<<<
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_FILE
 */
      __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_402), 0);
      {__pyx_filename = __pyx_f[11]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":86
 *         except AttributeError:
 *             raise TypeError, u"Argument is not a file-like object"
 *         doc_ref = _InputDocument()             # <<<<<<<<<<<<<<
 *         doc_ref._type = PARSER_DATA_FILE
 *         if base_url is not None:
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__InputDocument)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__InputDocument))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":87
 *             raise TypeError, u"Argument is not a file-like object"
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_FILE             # <<<<<<<<<<<<<<
 *         if base_url is not None:
 *             doc_ref._filename = _encodeFilename(base_url)
 */
  __pyx_v_doc_ref->_type = __pyx_e_4lxml_5etree_PARSER_DATA_FILE;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":88
 *         doc_ref = _InputDocument()
 *         doc_ref._type = PARSER_DATA_FILE
 *         if base_url is not None:             # <<<<<<<<<<<<<<
 *             doc_ref._filename = _encodeFilename(base_url)
 *         else:
 */
  __pyx_5 = (__pyx_v_base_url != Py_None);
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":89
 *         doc_ref._type = PARSER_DATA_FILE
 *         if base_url is not None:
 *             doc_ref._filename = _encodeFilename(base_url)             # <<<<<<<<<<<<<<
 *         else:
 *             doc_ref._filename = _getFilenameForFile(f)
 */
    __pyx_3 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_base_url); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_doc_ref->_filename);
    __pyx_v_doc_ref->_filename = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":91
 *             doc_ref._filename = _encodeFilename(base_url)
 *         else:
 *             doc_ref._filename = _getFilenameForFile(f)             # <<<<<<<<<<<<<<
 *         doc_ref._file = f
 *         return doc_ref
 */
    __pyx_4 = __pyx_f_4lxml_5etree__getFilenameForFile(__pyx_v_f); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_doc_ref->_filename);
    __pyx_v_doc_ref->_filename = __pyx_4;
    __pyx_4 = 0;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":92
 *         else:
 *             doc_ref._filename = _getFilenameForFile(f)
 *         doc_ref._file = f             # <<<<<<<<<<<<<<
 *         return doc_ref
 * 
 */
  Py_INCREF(__pyx_v_f);
  Py_DECREF(__pyx_v_doc_ref->_file);
  __pyx_v_doc_ref->_file = __pyx_v_f;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":93
 *             doc_ref._filename = _getFilenameForFile(f)
 *         doc_ref._file = f
 *         return doc_ref             # <<<<<<<<<<<<<<
 * 
 * cdef class _ResolverRegistry:
 */
  Py_INCREF(((PyObject *)__pyx_v_doc_ref));
  __pyx_r = ((PyObject *)__pyx_v_doc_ref);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.Resolver.resolve_file");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc_ref);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":98
 *     cdef object _resolvers
 *     cdef Resolver _default_resolver
 *     def __init__(self, Resolver default_resolver=None):             # <<<<<<<<<<<<<<
 *         self._resolvers = set()
 *         self._default_resolver = default_resolver
 */

static int __pyx_pf_4lxml_5etree_17_ResolverRegistry___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_17_ResolverRegistry___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4lxml_5etree_Resolver *__pyx_v_default_resolver = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_default_resolver,0};
  __pyx_v_default_resolver = ((struct __pyx_obj_4lxml_5etree_Resolver *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_default_resolver = ((struct __pyx_obj_4lxml_5etree_Resolver *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_default_resolver = ((struct __pyx_obj_4lxml_5etree_Resolver *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_default_resolver), __pyx_ptype_4lxml_5etree_Resolver, 1, "default_resolver", 0))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":99
 *     cdef Resolver _default_resolver
 *     def __init__(self, Resolver default_resolver=None):
 *         self._resolvers = set()             # <<<<<<<<<<<<<<
 *         self._default_resolver = default_resolver
 * 
 */
  __pyx_1 = PyObject_Call(__pyx_v_4lxml_5etree_set, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers);
  ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":100
 *     def __init__(self, Resolver default_resolver=None):
 *         self._resolvers = set()
 *         self._default_resolver = default_resolver             # <<<<<<<<<<<<<<
 * 
 *     def add(self, Resolver resolver not None):
 */
  Py_INCREF(((PyObject *)__pyx_v_default_resolver));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_default_resolver));
  ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_default_resolver = __pyx_v_default_resolver;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":102
 *         self._default_resolver = default_resolver
 * 
 *     def add(self, Resolver resolver not None):             # <<<<<<<<<<<<<<
 *         u"""add(self, resolver)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_add(PyObject *__pyx_v_self, PyObject *__pyx_v_resolver); /*proto*/
static char __pyx_doc_4lxml_5etree_17_ResolverRegistry_add[] = "add(self, resolver)\n\n        Register a resolver.\n\n        For each requested entity, the 'resolve' method of the resolver will\n        be called and the result will be passed to the parser.  If this method\n        returns None, the request will be delegated to other resolvers or the\n        default resolver.  The resolvers will be tested in an arbitrary order\n        until the first match is found.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_add(PyObject *__pyx_v_self, PyObject *__pyx_v_resolver) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_resolver), __pyx_ptype_4lxml_5etree_Resolver, 0, "resolver", 0))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":113
 *         until the first match is found.
 *         """
 *         self._resolvers.add(resolver)             # <<<<<<<<<<<<<<
 * 
 *     def remove(self, resolver):
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers, __pyx_kp_add); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_resolver);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_resolver);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.add");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":115
 *         self._resolvers.add(resolver)
 * 
 *     def remove(self, resolver):             # <<<<<<<<<<<<<<
 *         u"remove(self, resolver)"
 *         self._resolvers.discard(resolver)
 */

static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_remove(PyObject *__pyx_v_self, PyObject *__pyx_v_resolver); /*proto*/
static char __pyx_doc_4lxml_5etree_17_ResolverRegistry_remove[] = "remove(self, resolver)";
static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_remove(PyObject *__pyx_v_self, PyObject *__pyx_v_resolver) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":117
 *     def remove(self, resolver):
 *         u"remove(self, resolver)"
 *         self._resolvers.discard(resolver)             # <<<<<<<<<<<<<<
 * 
 *     cdef _ResolverRegistry _copy(self):
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers, __pyx_kp_discard); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_resolver);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_resolver);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.remove");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":119
 *         self._resolvers.discard(resolver)
 * 
 *     cdef _ResolverRegistry _copy(self):             # <<<<<<<<<<<<<<
 *         cdef _ResolverRegistry registry
 *         registry = _ResolverRegistry(self._default_resolver)
 */

static  struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_f_4lxml_5etree_17_ResolverRegistry__copy(struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_v_registry;
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_registry = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":121
 *     cdef _ResolverRegistry _copy(self):
 *         cdef _ResolverRegistry registry
 *         registry = _ResolverRegistry(self._default_resolver)             # <<<<<<<<<<<<<<
 *         registry._resolvers = self._resolvers.copy()
 *         return registry
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_self->_default_resolver));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_self->_default_resolver));
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ResolverRegistry)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ResolverRegistry))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_registry));
  __pyx_v_registry = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":122
 *         cdef _ResolverRegistry registry
 *         registry = _ResolverRegistry(self._default_resolver)
 *         registry._resolvers = self._resolvers.copy()             # <<<<<<<<<<<<<<
 *         return registry
 * 
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_resolvers, __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_registry->_resolvers);
  __pyx_v_registry->_resolvers = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":123
 *         registry = _ResolverRegistry(self._default_resolver)
 *         registry._resolvers = self._resolvers.copy()
 *         return registry             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_registry));
  __pyx_r = __pyx_v_registry;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_registry);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":125
 *         return registry
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         u"copy(self)"
 *         return self._copy()
 */

static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_17_ResolverRegistry_copy[] = "copy(self)";
static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":127
 *     def copy(self):
 *         u"copy(self)"
 *         return self._copy()             # <<<<<<<<<<<<<<
 * 
 *     def resolve(self, system_url, public_id, context):
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ResolverRegistry *)((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->__pyx_vtab)->_copy(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":129
 *         return self._copy()
 * 
 *     def resolve(self, system_url, public_id, context):             # <<<<<<<<<<<<<<
 *         u"resolve(self, system_url, public_id, context)"
 *         for resolver in self._resolvers:
 */

static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_resolve(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_17_ResolverRegistry_resolve[] = "resolve(self, system_url, public_id, context)";
static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry_resolve(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_system_url = 0;
  PyObject *__pyx_v_public_id = 0;
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_v_resolver;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_system_url,&__pyx_kp_public_id,&__pyx_kp_context,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_system_url);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_public_id);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve", 1, 3, 3, 1); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("resolve", 1, 3, 3, 2); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "resolve") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_system_url = values[0];
    __pyx_v_public_id = values[1];
    __pyx_v_context = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_system_url = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_public_id = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("resolve", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.resolve");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_resolver = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":131
 *     def resolve(self, system_url, public_id, context):
 *         u"resolve(self, system_url, public_id, context)"
 *         for resolver in self._resolvers:             # <<<<<<<<<<<<<<
 *             result = resolver.resolve(system_url, public_id, context)
 *             if result is not None:
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers)) {
    __pyx_1 = 0; __pyx_2 = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_resolver);
    __pyx_v_resolver = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":132
 *         u"resolve(self, system_url, public_id, context)"
 *         for resolver in self._resolvers:
 *             result = resolver.resolve(system_url, public_id, context)             # <<<<<<<<<<<<<<
 *             if result is not None:
 *                 return result
 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_resolver, __pyx_kp_resolve); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_system_url);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_system_url);
    Py_INCREF(__pyx_v_public_id);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_public_id);
    Py_INCREF(__pyx_v_context);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_context);
    __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_5;
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":133
 *         for resolver in self._resolvers:
 *             result = resolver.resolve(system_url, public_id, context)
 *             if result is not None:             # <<<<<<<<<<<<<<
 *                 return result
 *         if self._default_resolver is None:
 */
    __pyx_6 = (__pyx_v_result != Py_None);
    if (__pyx_6) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":134
 *             result = resolver.resolve(system_url, public_id, context)
 *             if result is not None:
 *                 return result             # <<<<<<<<<<<<<<
 *         if self._default_resolver is None:
 *             return None
 */
      Py_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":135
 *             if result is not None:
 *                 return result
 *         if self._default_resolver is None:             # <<<<<<<<<<<<<<
 *             return None
 *         return self._default_resolver.resolve(system_url, public_id, context)
 */
  __pyx_6 = (((PyObject *)((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_default_resolver) == Py_None);
  if (__pyx_6) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":136
 *                 return result
 *         if self._default_resolver is None:
 *             return None             # <<<<<<<<<<<<<<
 *         return self._default_resolver.resolve(system_url, public_id, context)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":137
 *         if self._default_resolver is None:
 *             return None
 *         return self._default_resolver.resolve(system_url, public_id, context)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_default_resolver), __pyx_kp_resolve); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_system_url);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_system_url);
  Py_INCREF(__pyx_v_public_id);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_public_id);
  Py_INCREF(__pyx_v_context);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_context);
  __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.resolve");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_resolver);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":139
 *         return self._default_resolver.resolve(system_url, public_id, context)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self._resolvers)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_17_ResolverRegistry___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":140
 * 
 *     def __repr__(self):
 *         return repr(self._resolvers)             # <<<<<<<<<<<<<<
 * 
 * cdef class _ResolverContext(_ExceptionContext):
 */
  __pyx_1 = PyObject_Repr(((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_v_self)->_resolvers); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ResolverRegistry.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":146
 *     cdef _TempStore _storage
 * 
 *     cdef void clear(self):             # <<<<<<<<<<<<<<
 *         _ExceptionContext.clear(self)
 *         self._storage.clear()
 */

static  void __pyx_f_4lxml_5etree_16_ResolverContext_clear(struct __pyx_obj_4lxml_5etree__ResolverContext *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":147
 * 
 *     cdef void clear(self):
 *         _ExceptionContext.clear(self)             # <<<<<<<<<<<<<<
 *         self._storage.clear()
 * 
 */
  __pyx_vtabptr_4lxml_5etree__ExceptionContext->clear(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_self));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":148
 *     cdef void clear(self):
 *         _ExceptionContext.clear(self)
 *         self._storage.clear()             # <<<<<<<<<<<<<<
 * 
 * cdef _initResolverContext(_ResolverContext context,
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_self->_storage->__pyx_vtab)->clear(__pyx_v_self->_storage); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("lxml.etree._ResolverContext.clear");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":150
 *         self._storage.clear()
 * 
 * cdef _initResolverContext(_ResolverContext context,             # <<<<<<<<<<<<<<
 *                           _ResolverRegistry resolvers):
 *     if resolvers is None:
 */

static  PyObject *__pyx_f_4lxml_5etree__initResolverContext(struct __pyx_obj_4lxml_5etree__ResolverContext *__pyx_v_context, struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_v_resolvers) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":152
 * cdef _initResolverContext(_ResolverContext context,
 *                           _ResolverRegistry resolvers):
 *     if resolvers is None:             # <<<<<<<<<<<<<<
 *         context._resolvers = _ResolverRegistry()
 *     else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_resolvers) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":153
 *                           _ResolverRegistry resolvers):
 *     if resolvers is None:
 *         context._resolvers = _ResolverRegistry()             # <<<<<<<<<<<<<<
 *     else:
 *         context._resolvers = resolvers
 */
    __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ResolverRegistry)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ResolverRegistry))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_context->_resolvers));
    __pyx_v_context->_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":155
 *         context._resolvers = _ResolverRegistry()
 *     else:
 *         context._resolvers = resolvers             # <<<<<<<<<<<<<<
 *     context._storage = _TempStore()
 */
    Py_INCREF(((PyObject *)__pyx_v_resolvers));
    Py_DECREF(((PyObject *)__pyx_v_context->_resolvers));
    __pyx_v_context->_resolvers = __pyx_v_resolvers;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/docloader.pxi":156
 *     else:
 *         context._resolvers = resolvers
 *     context._storage = _TempStore()             # <<<<<<<<<<<<<<
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__TempStore)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__TempStore))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context->_storage));
  __pyx_v_context->_storage = ((struct __pyx_obj_4lxml_5etree__TempStore *)__pyx_2);
  __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._initResolverContext");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":23
 *     u"""Syntax error while parsing an XML document.
 *     """
 *     def __init__(self, message, code, line, column):             # <<<<<<<<<<<<<<
 *         if python.PY_VERSION_HEX >= 0x02050000:
 *             # Python >= 2.5 uses new style class exceptions
 */

static PyObject *__pyx_pf_4lxml_5etree_14XMLSyntaxError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4lxml_5etree_14XMLSyntaxError___init__ = {"__init__", (PyCFunction)__pyx_pf_4lxml_5etree_14XMLSyntaxError___init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pf_4lxml_5etree_14XMLSyntaxError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_code = 0;
  PyObject *__pyx_v_line = 0;
  PyObject *__pyx_v_column = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_self,&__pyx_kp_message,&__pyx_kp_code,&__pyx_kp_line,&__pyx_kp_column,0};
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_message);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_code);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_line);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_kp_column);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_message = values[1];
    __pyx_v_code = values[2];
    __pyx_v_line = values[3];
    __pyx_v_column = values[4];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_message = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_code = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_line = PyTuple_GET_ITEM(__pyx_args, 3);
    __pyx_v_column = PyTuple_GET_ITEM(__pyx_args, 4);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XMLSyntaxError.__init__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":24
 *     """
 *     def __init__(self, message, code, line, column):
 *         if python.PY_VERSION_HEX >= 0x02050000:             # <<<<<<<<<<<<<<
 *             # Python >= 2.5 uses new style class exceptions
 *             super(_XMLSyntaxError, self).__init__(message)
 */
  __pyx_1 = (PY_VERSION_HEX >= 0x02050000);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":26
 *         if python.PY_VERSION_HEX >= 0x02050000:
 *             # Python >= 2.5 uses new style class exceptions
 *             super(_XMLSyntaxError, self).__init__(message)             # <<<<<<<<<<<<<<
 *         else:
 *             ParseError.__init__(self, message)
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_4lxml_5etree__XMLSyntaxError);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_4lxml_5etree__XMLSyntaxError);
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self);
    __pyx_3 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_kp___init__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":28
 *             super(_XMLSyntaxError, self).__init__(message)
 *         else:
 *             ParseError.__init__(self, message)             # <<<<<<<<<<<<<<
 *         self.position = (line, column)
 *         self.code = code
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ParseError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp___init__); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
    Py_INCREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_message);
    __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":29
 *         else:
 *             ParseError.__init__(self, message)
 *         self.position = (line, column)             # <<<<<<<<<<<<<<
 *         self.code = code
 * 
 */
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_line);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_line);
  Py_INCREF(__pyx_v_column);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_column);
  if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_position, ((PyObject *)__pyx_3)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":30
 *             ParseError.__init__(self, message)
 *         self.position = (line, column)
 *         self.code = code             # <<<<<<<<<<<<<<
 * 
 * cdef object _XMLSyntaxError
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_code, __pyx_v_code) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.XMLSyntaxError.__init__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":54
 *     cdef object _implied_parser_contexts
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._implied_parser_contexts = []
 * 
 */

static int __pyx_pf_4lxml_5etree_24_ParserDictionaryContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_24_ParserDictionaryContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":55
 * 
 *     def __init__(self):
 *         self._implied_parser_contexts = []             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self)->_implied_parser_contexts);
  ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self)->_implied_parser_contexts = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ParserDictionaryContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":57
 *         self._implied_parser_contexts = []
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._c_dict is not NULL:
 *             xmlparser.xmlDictFree(self._c_dict)
 */

static void __pyx_pf_4lxml_5etree_24_ParserDictionaryContext___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_24_ParserDictionaryContext___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":58
 * 
 *     def __dealloc__(self):
 *         if self._c_dict is not NULL:             # <<<<<<<<<<<<<<
 *             xmlparser.xmlDictFree(self._c_dict)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self)->_c_dict != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":59
 *     def __dealloc__(self):
 *         if self._c_dict is not NULL:
 *             xmlparser.xmlDictFree(self._c_dict)             # <<<<<<<<<<<<<<
 * 
 *     cdef void initMainParserContext(self):
 */
    xmlDictFree(((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self)->_c_dict);
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":61
 *             xmlparser.xmlDictFree(self._c_dict)
 * 
 *     cdef void initMainParserContext(self):             # <<<<<<<<<<<<<<
 *         u"""Put the global context into the thread dictionary of the main
 *         thread.  To be called once and only in the main thread."""
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_initMainParserContext(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self) {
  PyObject *__pyx_v_thread_dict;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":66
 *         cdef python.PyObject* thread_dict
 *         cdef python.PyObject* result
 *         thread_dict = python.PyThreadState_GetDict()             # <<<<<<<<<<<<<<
 *         if thread_dict is not NULL:
 *             (<object>thread_dict)[u"_ParserDictionaryContext"] = self
 */
  __pyx_v_thread_dict = PyThreadState_GetDict();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":67
 *         cdef python.PyObject* result
 *         thread_dict = python.PyThreadState_GetDict()
 *         if thread_dict is not NULL:             # <<<<<<<<<<<<<<
 *             (<object>thread_dict)[u"_ParserDictionaryContext"] = self
 * 
 */
  __pyx_1 = (__pyx_v_thread_dict != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":68
 *         thread_dict = python.PyThreadState_GetDict()
 *         if thread_dict is not NULL:
 *             (<object>thread_dict)[u"_ParserDictionaryContext"] = self             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserDictionaryContext _findThreadParserContext(self):
 */
    if (PyObject_SetItem(((PyObject *)__pyx_v_thread_dict), ((PyObject *)__pyx_kp_403), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("lxml.etree._ParserDictionaryContext.initMainParserContext");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":70
 *             (<object>thread_dict)[u"_ParserDictionaryContext"] = self
 * 
 *     cdef _ParserDictionaryContext _findThreadParserContext(self):             # <<<<<<<<<<<<<<
 *         u"Find (or create) the _ParserDictionaryContext object for the current thread"
 *         cdef python.PyObject* thread_dict
 */

static  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_f_4lxml_5etree_24_ParserDictionaryContext__findThreadParserContext(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self) {
  PyObject *__pyx_v_thread_dict;
  PyObject *__pyx_v_result;
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  PyObject *__pyx_v_d;
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_d = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":75
 *         cdef python.PyObject* result
 *         cdef _ParserDictionaryContext context
 *         thread_dict = python.PyThreadState_GetDict()             # <<<<<<<<<<<<<<
 *         if thread_dict is NULL:
 *             return self
 */
  __pyx_v_thread_dict = PyThreadState_GetDict();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":76
 *         cdef _ParserDictionaryContext context
 *         thread_dict = python.PyThreadState_GetDict()
 *         if thread_dict is NULL:             # <<<<<<<<<<<<<<
 *             return self
 *         d = <object>thread_dict
 */
  __pyx_1 = (__pyx_v_thread_dict == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":77
 *         thread_dict = python.PyThreadState_GetDict()
 *         if thread_dict is NULL:
 *             return self             # <<<<<<<<<<<<<<
 *         d = <object>thread_dict
 *         result = python.PyDict_GetItem(d, u"_ParserDictionaryContext")
 */
    Py_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":78
 *         if thread_dict is NULL:
 *             return self
 *         d = <object>thread_dict             # <<<<<<<<<<<<<<
 *         result = python.PyDict_GetItem(d, u"_ParserDictionaryContext")
 *         if result is not NULL:
 */
  Py_INCREF(((PyObject *)__pyx_v_thread_dict));
  Py_DECREF(__pyx_v_d);
  __pyx_v_d = ((PyObject *)__pyx_v_thread_dict);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":79
 *             return self
 *         d = <object>thread_dict
 *         result = python.PyDict_GetItem(d, u"_ParserDictionaryContext")             # <<<<<<<<<<<<<<
 *         if result is not NULL:
 *             return <object>result
 */
  __pyx_v_result = PyDict_GetItem(__pyx_v_d, ((PyObject *)__pyx_kp_404));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":80
 *         d = <object>thread_dict
 *         result = python.PyDict_GetItem(d, u"_ParserDictionaryContext")
 *         if result is not NULL:             # <<<<<<<<<<<<<<
 *             return <object>result
 *         context = _ParserDictionaryContext()
 */
  __pyx_1 = (__pyx_v_result != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":81
 *         result = python.PyDict_GetItem(d, u"_ParserDictionaryContext")
 *         if result is not NULL:
 *             return <object>result             # <<<<<<<<<<<<<<
 *         context = _ParserDictionaryContext()
 *         d[u"_ParserDictionaryContext"] = context
 */
    if (!(__Pyx_TypeTest(((PyObject *)__pyx_v_result), __pyx_ptype_4lxml_5etree__ParserDictionaryContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_result));
    __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)((PyObject *)__pyx_v_result));
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":82
 *         if result is not NULL:
 *             return <object>result
 *         context = _ParserDictionaryContext()             # <<<<<<<<<<<<<<
 *         d[u"_ParserDictionaryContext"] = context
 *         return context
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ParserDictionaryContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ParserDictionaryContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":83
 *             return <object>result
 *         context = _ParserDictionaryContext()
 *         d[u"_ParserDictionaryContext"] = context             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  if (PyObject_SetItem(__pyx_v_d, ((PyObject *)__pyx_kp_405), ((PyObject *)__pyx_v_context)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":84
 *         context = _ParserDictionaryContext()
 *         d[u"_ParserDictionaryContext"] = context
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     cdef void setDefaultParser(self, _BaseParser parser):
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = __pyx_v_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ParserDictionaryContext._findThreadParserContext");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  Py_DECREF(__pyx_v_d);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":86
 *         return context
 * 
 *     cdef void setDefaultParser(self, _BaseParser parser):             # <<<<<<<<<<<<<<
 *         u"Set the default parser for the current thread"
 *         cdef _ParserDictionaryContext context
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_setDefaultParser(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  PyObject *__pyx_1 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":89
 *         u"Set the default parser for the current thread"
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()             # <<<<<<<<<<<<<<
 *         context._default_parser = parser
 * 
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_findThreadParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":90
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()
 *         context._default_parser = parser             # <<<<<<<<<<<<<<
 * 
 *     cdef _BaseParser getDefaultParser(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_parser));
  Py_DECREF(((PyObject *)__pyx_v_context->_default_parser));
  __pyx_v_context->_default_parser = __pyx_v_parser;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("lxml.etree._ParserDictionaryContext.setDefaultParser");
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":92
 *         context._default_parser = parser
 * 
 *     cdef _BaseParser getDefaultParser(self):             # <<<<<<<<<<<<<<
 *         u"Return (or create) the default parser of the current thread"
 *         cdef _ParserDictionaryContext context
 */

static  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_f_4lxml_5etree_24_ParserDictionaryContext_getDefaultParser(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":95
 *         u"Return (or create) the default parser of the current thread"
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()             # <<<<<<<<<<<<<<
 *         if context._default_parser is None:
 *             if self._default_parser is None:
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_findThreadParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":96
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()
 *         if context._default_parser is None:             # <<<<<<<<<<<<<<
 *             if self._default_parser is None:
 *                 self._default_parser = __DEFAULT_XML_PARSER._copy()
 */
  __pyx_2 = (((PyObject *)__pyx_v_context->_default_parser) == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":97
 *         context = self._findThreadParserContext()
 *         if context._default_parser is None:
 *             if self._default_parser is None:             # <<<<<<<<<<<<<<
 *                 self._default_parser = __DEFAULT_XML_PARSER._copy()
 *             if context is not self:
 */
    __pyx_2 = (((PyObject *)__pyx_v_self->_default_parser) == Py_None);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":98
 *         if context._default_parser is None:
 *             if self._default_parser is None:
 *                 self._default_parser = __DEFAULT_XML_PARSER._copy()             # <<<<<<<<<<<<<<
 *             if context is not self:
 *                 context._default_parser = self._default_parser._copy()
 */
      __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_XMLParser *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._copy(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_self->_default_parser));
      __pyx_v_self->_default_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_1);
      __pyx_1 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":99
 *             if self._default_parser is None:
 *                 self._default_parser = __DEFAULT_XML_PARSER._copy()
 *             if context is not self:             # <<<<<<<<<<<<<<
 *                 context._default_parser = self._default_parser._copy()
 *         return context._default_parser
 */
    __pyx_2 = (__pyx_v_context != __pyx_v_self);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":100
 *                 self._default_parser = __DEFAULT_XML_PARSER._copy()
 *             if context is not self:
 *                 context._default_parser = self._default_parser._copy()             # <<<<<<<<<<<<<<
 *         return context._default_parser
 * 
 */
      __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->_default_parser->__pyx_vtab)->_copy(__pyx_v_self->_default_parser)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_context->_default_parser));
      __pyx_v_context->_default_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_1);
      __pyx_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":101
 *             if context is not self:
 *                 context._default_parser = self._default_parser._copy()
 *         return context._default_parser             # <<<<<<<<<<<<<<
 * 
 *     cdef tree.xmlDict* _getThreadDict(self, tree.xmlDict* default):
 */
  Py_INCREF(((PyObject *)__pyx_v_context->_default_parser));
  __pyx_r = __pyx_v_context->_default_parser;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ParserDictionaryContext.getDefaultParser");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":103
 *         return context._default_parser
 * 
 *     cdef tree.xmlDict* _getThreadDict(self, tree.xmlDict* default):             # <<<<<<<<<<<<<<
 *         u"Return the thread-local dict or create a new one if necessary."
 *         cdef _ParserDictionaryContext context
 */

static  xmlDict *__pyx_f_4lxml_5etree_24_ParserDictionaryContext__getThreadDict(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, xmlDict *__pyx_v_default) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  xmlDict *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":106
 *         u"Return the thread-local dict or create a new one if necessary."
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()             # <<<<<<<<<<<<<<
 *         if context._c_dict is NULL:
 *             # thread dict not yet set up => use default or create a new one
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_findThreadParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":107
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()
 *         if context._c_dict is NULL:             # <<<<<<<<<<<<<<
 *             # thread dict not yet set up => use default or create a new one
 *             if default is not NULL:
 */
  __pyx_2 = (__pyx_v_context->_c_dict == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":109
 *         if context._c_dict is NULL:
 *             # thread dict not yet set up => use default or create a new one
 *             if default is not NULL:             # <<<<<<<<<<<<<<
 *                 context._c_dict = default
 *                 xmlparser.xmlDictReference(default)
 */
    __pyx_2 = (__pyx_v_default != NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":110
 *             # thread dict not yet set up => use default or create a new one
 *             if default is not NULL:
 *                 context._c_dict = default             # <<<<<<<<<<<<<<
 *                 xmlparser.xmlDictReference(default)
 *                 return default
 */
      __pyx_v_context->_c_dict = __pyx_v_default;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":111
 *             if default is not NULL:
 *                 context._c_dict = default
 *                 xmlparser.xmlDictReference(default)             # <<<<<<<<<<<<<<
 *                 return default
 *             if self._c_dict is NULL:
 */
      xmlDictReference(__pyx_v_default);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":112
 *                 context._c_dict = default
 *                 xmlparser.xmlDictReference(default)
 *                 return default             # <<<<<<<<<<<<<<
 *             if self._c_dict is NULL:
 *                 self._c_dict = xmlparser.xmlDictCreate()
 */
      __pyx_r = __pyx_v_default;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":113
 *                 xmlparser.xmlDictReference(default)
 *                 return default
 *             if self._c_dict is NULL:             # <<<<<<<<<<<<<<
 *                 self._c_dict = xmlparser.xmlDictCreate()
 *             if context is not self:
 */
    __pyx_2 = (__pyx_v_self->_c_dict == NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":114
 *                 return default
 *             if self._c_dict is NULL:
 *                 self._c_dict = xmlparser.xmlDictCreate()             # <<<<<<<<<<<<<<
 *             if context is not self:
 *                 context._c_dict = xmlparser.xmlDictCreateSub(self._c_dict)
 */
      __pyx_v_self->_c_dict = xmlDictCreate();
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":115
 *             if self._c_dict is NULL:
 *                 self._c_dict = xmlparser.xmlDictCreate()
 *             if context is not self:             # <<<<<<<<<<<<<<
 *                 context._c_dict = xmlparser.xmlDictCreateSub(self._c_dict)
 *         return context._c_dict
 */
    __pyx_2 = (__pyx_v_context != __pyx_v_self);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":116
 *                 self._c_dict = xmlparser.xmlDictCreate()
 *             if context is not self:
 *                 context._c_dict = xmlparser.xmlDictCreateSub(self._c_dict)             # <<<<<<<<<<<<<<
 *         return context._c_dict
 * 
 */
      __pyx_v_context->_c_dict = xmlDictCreateSub(__pyx_v_self->_c_dict);
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":117
 *             if context is not self:
 *                 context._c_dict = xmlparser.xmlDictCreateSub(self._c_dict)
 *         return context._c_dict             # <<<<<<<<<<<<<<
 * 
 *     cdef void initThreadDictRef(self, tree.xmlDict** c_dict_ref):
 */
  __pyx_r = __pyx_v_context->_c_dict;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("lxml.etree._ParserDictionaryContext._getThreadDict");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":119
 *         return context._c_dict
 * 
 *     cdef void initThreadDictRef(self, tree.xmlDict** c_dict_ref):             # <<<<<<<<<<<<<<
 *         cdef tree.xmlDict* c_dict
 *         cdef tree.xmlDict* c_thread_dict
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_initThreadDictRef(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, xmlDict **__pyx_v_c_dict_ref) {
  xmlDict *__pyx_v_c_dict;
  xmlDict *__pyx_v_c_thread_dict;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":122
 *         cdef tree.xmlDict* c_dict
 *         cdef tree.xmlDict* c_thread_dict
 *         c_dict = c_dict_ref[0]             # <<<<<<<<<<<<<<
 *         c_thread_dict = self._getThreadDict(c_dict)
 *         if c_dict is c_thread_dict:
 */
  __pyx_v_c_dict = (__pyx_v_c_dict_ref[0]);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":123
 *         cdef tree.xmlDict* c_thread_dict
 *         c_dict = c_dict_ref[0]
 *         c_thread_dict = self._getThreadDict(c_dict)             # <<<<<<<<<<<<<<
 *         if c_dict is c_thread_dict:
 *             return
 */
  __pyx_v_c_thread_dict = ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_getThreadDict(__pyx_v_self, __pyx_v_c_dict);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":124
 *         c_dict = c_dict_ref[0]
 *         c_thread_dict = self._getThreadDict(c_dict)
 *         if c_dict is c_thread_dict:             # <<<<<<<<<<<<<<
 *             return
 *         if c_dict is not NULL:
 */
  __pyx_1 = (__pyx_v_c_dict == __pyx_v_c_thread_dict);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":125
 *         c_thread_dict = self._getThreadDict(c_dict)
 *         if c_dict is c_thread_dict:
 *             return             # <<<<<<<<<<<<<<
 *         if c_dict is not NULL:
 *             xmlparser.xmlDictFree(c_dict)
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":126
 *         if c_dict is c_thread_dict:
 *             return
 *         if c_dict is not NULL:             # <<<<<<<<<<<<<<
 *             xmlparser.xmlDictFree(c_dict)
 *         c_dict_ref[0] = c_thread_dict
 */
  __pyx_1 = (__pyx_v_c_dict != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":127
 *             return
 *         if c_dict is not NULL:
 *             xmlparser.xmlDictFree(c_dict)             # <<<<<<<<<<<<<<
 *         c_dict_ref[0] = c_thread_dict
 *         xmlparser.xmlDictReference(c_thread_dict)
 */
    xmlDictFree(__pyx_v_c_dict);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":128
 *         if c_dict is not NULL:
 *             xmlparser.xmlDictFree(c_dict)
 *         c_dict_ref[0] = c_thread_dict             # <<<<<<<<<<<<<<
 *         xmlparser.xmlDictReference(c_thread_dict)
 * 
 */
  (__pyx_v_c_dict_ref[0]) = __pyx_v_c_thread_dict;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":129
 *             xmlparser.xmlDictFree(c_dict)
 *         c_dict_ref[0] = c_thread_dict
 *         xmlparser.xmlDictReference(c_thread_dict)             # <<<<<<<<<<<<<<
 * 
 *     cdef void initParserDict(self, xmlparser.xmlParserCtxt* pctxt):
 */
  xmlDictReference(__pyx_v_c_thread_dict);

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":131
 *         xmlparser.xmlDictReference(c_thread_dict)
 * 
 *     cdef void initParserDict(self, xmlparser.xmlParserCtxt* pctxt):             # <<<<<<<<<<<<<<
 *         u"Assure we always use the same string dictionary."
 *         self.initThreadDictRef(&pctxt.dict)
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_initParserDict(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, xmlParserCtxt *__pyx_v_pctxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":133
 *     cdef void initParserDict(self, xmlparser.xmlParserCtxt* pctxt):
 *         u"Assure we always use the same string dictionary."
 *         self.initThreadDictRef(&pctxt.dict)             # <<<<<<<<<<<<<<
 * 
 *     cdef void initXPathParserDict(self, xpath.xmlXPathContext* pctxt):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->initThreadDictRef(__pyx_v_self, (&__pyx_v_pctxt->dict));

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":135
 *         self.initThreadDictRef(&pctxt.dict)
 * 
 *     cdef void initXPathParserDict(self, xpath.xmlXPathContext* pctxt):             # <<<<<<<<<<<<<<
 *         u"Assure we always use the same string dictionary."
 *         self.initThreadDictRef(&pctxt.dict)
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_initXPathParserDict(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, xmlXPathContext *__pyx_v_pctxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":137
 *     cdef void initXPathParserDict(self, xpath.xmlXPathContext* pctxt):
 *         u"Assure we always use the same string dictionary."
 *         self.initThreadDictRef(&pctxt.dict)             # <<<<<<<<<<<<<<
 * 
 *     cdef void initDocDict(self, xmlDoc* result):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->initThreadDictRef(__pyx_v_self, (&__pyx_v_pctxt->dict));

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":139
 *         self.initThreadDictRef(&pctxt.dict)
 * 
 *     cdef void initDocDict(self, xmlDoc* result):             # <<<<<<<<<<<<<<
 *         u"Store dict of last object parsed if no shared dict yet"
 *         # XXX We also free the result dict here if there already was one.
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_initDocDict(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, xmlDoc *__pyx_v_result) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":144
 *         # This case should only occur for new documents with empty dicts,
 *         # otherwise we'd free data that's in use => segfault
 *         self.initThreadDictRef(&result.dict)             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext findImpliedContext(self):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->initThreadDictRef(__pyx_v_self, (&__pyx_v_result->dict));

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":146
 *         self.initThreadDictRef(&result.dict)
 * 
 *     cdef _ParserContext findImpliedContext(self):             # <<<<<<<<<<<<<<
 *         u"""Return any current implied xml parser context for the current
 *         thread.  This is used when the resolver functions are called
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_24_ParserDictionaryContext_findImpliedContext(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_implied_context;
  Py_ssize_t __pyx_v_count;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_implied_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":157
 * 
 *         # see if we have a current implied parser
 *         context = self._findThreadParserContext()             # <<<<<<<<<<<<<<
 *         count = python.PyList_GET_SIZE(context._implied_parser_contexts)
 *         if count != 0:
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_findThreadParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":158
 *         # see if we have a current implied parser
 *         context = self._findThreadParserContext()
 *         count = python.PyList_GET_SIZE(context._implied_parser_contexts)             # <<<<<<<<<<<<<<
 *         if count != 0:
 *             implied_context = python.PyList_GET_ITEM(
 */
  __pyx_v_count = PyList_GET_SIZE(__pyx_v_context->_implied_parser_contexts);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":159
 *         context = self._findThreadParserContext()
 *         count = python.PyList_GET_SIZE(context._implied_parser_contexts)
 *         if count != 0:             # <<<<<<<<<<<<<<
 *             implied_context = python.PyList_GET_ITEM(
 *                 context._implied_parser_contexts, count - 1)
 */
  __pyx_2 = (__pyx_v_count != 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":161
 *         if count != 0:
 *             implied_context = python.PyList_GET_ITEM(
 *                 context._implied_parser_contexts, count - 1)             # <<<<<<<<<<<<<<
 *             python.Py_INCREF(implied_context) # borrowed reference
 *             return implied_context
 */
    __pyx_1 = PyList_GET_ITEM(__pyx_v_context->_implied_parser_contexts, (__pyx_v_count - 1)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ParserContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_implied_context));
    __pyx_v_implied_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":162
 *             implied_context = python.PyList_GET_ITEM(
 *                 context._implied_parser_contexts, count - 1)
 *             python.Py_INCREF(implied_context) # borrowed reference             # <<<<<<<<<<<<<<
 *             return implied_context
 *         return None
 */
    Py_INCREF(((PyObject *)__pyx_v_implied_context));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":163
 *                 context._implied_parser_contexts, count - 1)
 *             python.Py_INCREF(implied_context) # borrowed reference
 *             return implied_context             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
    Py_INCREF(((PyObject *)__pyx_v_implied_context));
    __pyx_r = __pyx_v_implied_context;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":164
 *             python.Py_INCREF(implied_context) # borrowed reference
 *             return implied_context
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     cdef void pushImpliedContextFromParser(self, _BaseParser parser):
 */
  Py_INCREF(Py_None);
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None);
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ParserDictionaryContext.findImpliedContext");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  Py_DECREF((PyObject *)__pyx_v_implied_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":166
 *         return None
 * 
 *     cdef void pushImpliedContextFromParser(self, _BaseParser parser):             # <<<<<<<<<<<<<<
 *         u"Push a new implied context object taken from the parser."
 *         if parser is not None:
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_pushImpliedContextFromParser(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":168
 *     cdef void pushImpliedContextFromParser(self, _BaseParser parser):
 *         u"Push a new implied context object taken from the parser."
 *         if parser is not None:             # <<<<<<<<<<<<<<
 *             self.pushImpliedContext(parser._getParserContext())
 *         else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":169
 *         u"Push a new implied context object taken from the parser."
 *         if parser is not None:
 *             self.pushImpliedContext(parser._getParserContext())             # <<<<<<<<<<<<<<
 *         else:
 *             self.pushImpliedContext(None)
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_parser->__pyx_vtab)->_getParserContext(__pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->pushImpliedContext(__pyx_v_self, ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2));
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":171
 *             self.pushImpliedContext(parser._getParserContext())
 *         else:
 *             self.pushImpliedContext(None)             # <<<<<<<<<<<<<<
 * 
 *     cdef void pushImpliedContext(self, _ParserContext parser_context):
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->pushImpliedContext(__pyx_v_self, ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None));
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._ParserDictionaryContext.pushImpliedContextFromParser");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":173
 *             self.pushImpliedContext(None)
 * 
 *     cdef void pushImpliedContext(self, _ParserContext parser_context):             # <<<<<<<<<<<<<<
 *         u"Push a new implied context object."
 *         cdef _ParserDictionaryContext context
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_pushImpliedContext(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_parser_context) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":176
 *         u"Push a new implied context object."
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()             # <<<<<<<<<<<<<<
 *         python.PyList_Append(context._implied_parser_contexts, parser_context)
 * 
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_findThreadParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":177
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()
 *         python.PyList_Append(context._implied_parser_contexts, parser_context)             # <<<<<<<<<<<<<<
 * 
 *     cdef void popImpliedContext(self):
 */
  __pyx_2 = PyList_Append(__pyx_v_context->_implied_parser_contexts, ((PyObject *)__pyx_v_parser_context)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("lxml.etree._ParserDictionaryContext.pushImpliedContext");
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":179
 *         python.PyList_Append(context._implied_parser_contexts, parser_context)
 * 
 *     cdef void popImpliedContext(self):             # <<<<<<<<<<<<<<
 *         u"Pop the current implied context object."
 *         cdef _ParserDictionaryContext context
 */

static  void __pyx_f_4lxml_5etree_24_ParserDictionaryContext_popImpliedContext(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *__pyx_v_context;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":182
 *         u"Pop the current implied context object."
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()             # <<<<<<<<<<<<<<
 *         context._implied_parser_contexts.pop()
 * 
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_self->__pyx_vtab)->_findThreadParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":183
 *         cdef _ParserDictionaryContext context
 *         context = self._findThreadParserContext()
 *         context._implied_parser_contexts.pop()             # <<<<<<<<<<<<<<
 * 
 * cdef _ParserDictionaryContext __GLOBAL_PARSER_CONTEXT
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_context->_implied_parser_contexts, __pyx_kp_pop); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._ParserDictionaryContext.popImpliedContext");
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":189
 * __GLOBAL_PARSER_CONTEXT.initMainParserContext()
 * 
 * cdef int _checkThreadDict(tree.xmlDict* c_dict):             # <<<<<<<<<<<<<<
 *     u"""Check that c_dict is either the local thread dictionary or the global
 *     parent dictionary.
 */

static  int __pyx_f_4lxml_5etree__checkThreadDict(xmlDict *__pyx_v_c_dict) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":195
 *     #if __GLOBAL_PARSER_CONTEXT._c_dict is c_dict:
 *     #    return 1 # main thread
 *     if __GLOBAL_PARSER_CONTEXT._getThreadDict(NULL) is c_dict:             # <<<<<<<<<<<<<<
 *         return 1 # local thread dict
 *     return 0
 */
  __pyx_1 = (((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->_getThreadDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, NULL) == __pyx_v_c_dict);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":196
 *     #    return 1 # main thread
 *     if __GLOBAL_PARSER_CONTEXT._getThreadDict(NULL) is c_dict:
 *         return 1 # local thread dict             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":197
 *     if __GLOBAL_PARSER_CONTEXT._getThreadDict(NULL) is c_dict:
 *         return 1 # local thread dict
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":207
 * _UNICODE_ENCODING = NULL
 * 
 * cdef void _setupPythonUnicode():             # <<<<<<<<<<<<<<
 *     u"""Sets _UNICODE_ENCODING to the internal encoding name of Python unicode
 *     strings if libxml2 supports reading native Python unicode.  This depends
 */

static  void __pyx_f_4lxml_5etree__setupPythonUnicode(void) {
  xmlCharEncodingHandler *__pyx_v_enchandler;
  Py_ssize_t __pyx_v_l;
  char *__pyx_v_buffer;
  char *__pyx_v_enc;
  PyObject *__pyx_v_utext;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_utext = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":217
 *     cdef char* buffer
 *     cdef char* enc
 *     utext = python.PyUnicode_DecodeUTF8("<test/>", 7, NULL)             # <<<<<<<<<<<<<<
 *     l = python.PyUnicode_GET_DATA_SIZE(utext)
 *     buffer = python.PyUnicode_AS_DATA(utext)
 */
  __pyx_1 = PyUnicode_DecodeUTF8(__pyx_k_406, 7, NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_utext);
  __pyx_v_utext = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":218
 *     cdef char* enc
 *     utext = python.PyUnicode_DecodeUTF8("<test/>", 7, NULL)
 *     l = python.PyUnicode_GET_DATA_SIZE(utext)             # <<<<<<<<<<<<<<
 *     buffer = python.PyUnicode_AS_DATA(utext)
 *     enc = _findEncodingName(buffer, l)
 */
  __pyx_v_l = PyUnicode_GET_DATA_SIZE(__pyx_v_utext);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":219
 *     utext = python.PyUnicode_DecodeUTF8("<test/>", 7, NULL)
 *     l = python.PyUnicode_GET_DATA_SIZE(utext)
 *     buffer = python.PyUnicode_AS_DATA(utext)             # <<<<<<<<<<<<<<
 *     enc = _findEncodingName(buffer, l)
 *     if enc == NULL:
 */
  __pyx_v_buffer = PyUnicode_AS_DATA(__pyx_v_utext);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":220
 *     l = python.PyUnicode_GET_DATA_SIZE(utext)
 *     buffer = python.PyUnicode_AS_DATA(utext)
 *     enc = _findEncodingName(buffer, l)             # <<<<<<<<<<<<<<
 *     if enc == NULL:
 *         # apparently, libxml2 can't detect UTF-16 on some systems
 */
  __pyx_v_enc = __pyx_f_4lxml_5etree__findEncodingName(__pyx_v_buffer, __pyx_v_l);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":221
 *     buffer = python.PyUnicode_AS_DATA(utext)
 *     enc = _findEncodingName(buffer, l)
 *     if enc == NULL:             # <<<<<<<<<<<<<<
 *         # apparently, libxml2 can't detect UTF-16 on some systems
 *         if l >= 4 and \
 */
  __pyx_2 = (__pyx_v_enc == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":223
 *     if enc == NULL:
 *         # apparently, libxml2 can't detect UTF-16 on some systems
 *         if l >= 4 and \             # <<<<<<<<<<<<<<
 *                buffer[0] == c'<' and buffer[1] == c'\0' and \
 *                buffer[2] == c't' and buffer[3] == c'\0':
 */
    __pyx_2 = (__pyx_v_l >= 4);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":224
 *         # apparently, libxml2 can't detect UTF-16 on some systems
 *         if l >= 4 and \
 *                buffer[0] == c'<' and buffer[1] == c'\0' and \             # <<<<<<<<<<<<<<
 *                buffer[2] == c't' and buffer[3] == c'\0':
 *             enc = "UTF-16LE"
 */
      __pyx_2 = ((__pyx_v_buffer[0]) == '<');
      if (__pyx_2) {
        __pyx_2 = ((__pyx_v_buffer[1]) == '\x00');
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":225
 *         if l >= 4 and \
 *                buffer[0] == c'<' and buffer[1] == c'\0' and \
 *                buffer[2] == c't' and buffer[3] == c'\0':             # <<<<<<<<<<<<<<
 *             enc = "UTF-16LE"
 *         elif l >= 4 and \
 */
          __pyx_2 = ((__pyx_v_buffer[2]) == 't');
          if (__pyx_2) {
            __pyx_2 = ((__pyx_v_buffer[3]) == '\x00');
          }
        }
      }
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":226
 *                buffer[0] == c'<' and buffer[1] == c'\0' and \
 *                buffer[2] == c't' and buffer[3] == c'\0':
 *             enc = "UTF-16LE"             # <<<<<<<<<<<<<<
 *         elif l >= 4 and \
 *                buffer[0] == c'\0' and buffer[1] == c'<' and \
 */
      __pyx_v_enc = __pyx_k_407;
      goto __pyx_L4;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":227
 *                buffer[2] == c't' and buffer[3] == c'\0':
 *             enc = "UTF-16LE"
 *         elif l >= 4 and \             # <<<<<<<<<<<<<<
 *                buffer[0] == c'\0' and buffer[1] == c'<' and \
 *                buffer[2] == c'\0' and buffer[3] == c't':
 */
    __pyx_2 = (__pyx_v_l >= 4);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":228
 *             enc = "UTF-16LE"
 *         elif l >= 4 and \
 *                buffer[0] == c'\0' and buffer[1] == c'<' and \             # <<<<<<<<<<<<<<
 *                buffer[2] == c'\0' and buffer[3] == c't':
 *             enc = "UTF-16BE"
 */
      __pyx_2 = ((__pyx_v_buffer[0]) == '\x00');
      if (__pyx_2) {
        __pyx_2 = ((__pyx_v_buffer[1]) == '<');
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":229
 *         elif l >= 4 and \
 *                buffer[0] == c'\0' and buffer[1] == c'<' and \
 *                buffer[2] == c'\0' and buffer[3] == c't':             # <<<<<<<<<<<<<<
 *             enc = "UTF-16BE"
 *         else:
 */
          __pyx_2 = ((__pyx_v_buffer[2]) == '\x00');
          if (__pyx_2) {
            __pyx_2 = ((__pyx_v_buffer[3]) == 't');
          }
        }
      }
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":230
 *                buffer[0] == c'\0' and buffer[1] == c'<' and \
 *                buffer[2] == c'\0' and buffer[3] == c't':
 *             enc = "UTF-16BE"             # <<<<<<<<<<<<<<
 *         else:
 *             # not my fault, it's YOUR broken system :)
 */
      __pyx_v_enc = __pyx_k_408;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":233
 *         else:
 *             # not my fault, it's YOUR broken system :)
 *             return             # <<<<<<<<<<<<<<
 *     enchandler = tree.xmlFindCharEncodingHandler(enc)
 *     if enchandler is not NULL:
 */
      goto __pyx_L0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":234
 *             # not my fault, it's YOUR broken system :)
 *             return
 *     enchandler = tree.xmlFindCharEncodingHandler(enc)             # <<<<<<<<<<<<<<
 *     if enchandler is not NULL:
 *         global _UNICODE_ENCODING
 */
  __pyx_v_enchandler = xmlFindCharEncodingHandler(__pyx_v_enc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":235
 *             return
 *     enchandler = tree.xmlFindCharEncodingHandler(enc)
 *     if enchandler is not NULL:             # <<<<<<<<<<<<<<
 *         global _UNICODE_ENCODING
 *         tree.xmlCharEncCloseFunc(enchandler)
 */
  __pyx_2 = (__pyx_v_enchandler != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":237
 *     if enchandler is not NULL:
 *         global _UNICODE_ENCODING
 *         tree.xmlCharEncCloseFunc(enchandler)             # <<<<<<<<<<<<<<
 *         _UNICODE_ENCODING = enc
 * 
 */
    xmlCharEncCloseFunc(__pyx_v_enchandler);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":238
 *         global _UNICODE_ENCODING
 *         tree.xmlCharEncCloseFunc(enchandler)
 *         _UNICODE_ENCODING = enc             # <<<<<<<<<<<<<<
 * 
 * cdef char* _findEncodingName(char* buffer, int size):
 */
    __pyx_v_4lxml_5etree__UNICODE_ENCODING = __pyx_v_enc;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("lxml.etree._setupPythonUnicode");
  __pyx_L0:;
  Py_DECREF(__pyx_v_utext);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":240
 *         _UNICODE_ENCODING = enc
 * 
 * cdef char* _findEncodingName(char* buffer, int size):             # <<<<<<<<<<<<<<
 *     u"Work around bug in libxml2: find iconv name of encoding on our own."
 *     cdef tree.xmlCharEncoding enc
 */

static  char *__pyx_f_4lxml_5etree__findEncodingName(char *__pyx_v_buffer, int __pyx_v_size) {
  xmlCharEncoding __pyx_v_enc;
  char *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":243
 *     u"Work around bug in libxml2: find iconv name of encoding on our own."
 *     cdef tree.xmlCharEncoding enc
 *     enc = tree.xmlDetectCharEncoding(buffer, size)             # <<<<<<<<<<<<<<
 *     if enc == tree.XML_CHAR_ENCODING_UTF16LE:
 *         return "UTF-16LE"
 */
  __pyx_v_enc = xmlDetectCharEncoding(__pyx_v_buffer, __pyx_v_size);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":244
 *     cdef tree.xmlCharEncoding enc
 *     enc = tree.xmlDetectCharEncoding(buffer, size)
 *     if enc == tree.XML_CHAR_ENCODING_UTF16LE:             # <<<<<<<<<<<<<<
 *         return "UTF-16LE"
 *     elif enc == tree.XML_CHAR_ENCODING_UTF16BE:
 */
  __pyx_1 = (__pyx_v_enc == XML_CHAR_ENCODING_UTF16LE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":245
 *     enc = tree.xmlDetectCharEncoding(buffer, size)
 *     if enc == tree.XML_CHAR_ENCODING_UTF16LE:
 *         return "UTF-16LE"             # <<<<<<<<<<<<<<
 *     elif enc == tree.XML_CHAR_ENCODING_UTF16BE:
 *         return "UTF-16BE"
 */
    __pyx_r = __pyx_k_409;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":246
 *     if enc == tree.XML_CHAR_ENCODING_UTF16LE:
 *         return "UTF-16LE"
 *     elif enc == tree.XML_CHAR_ENCODING_UTF16BE:             # <<<<<<<<<<<<<<
 *         return "UTF-16BE"
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4LE:
 */
  __pyx_1 = (__pyx_v_enc == XML_CHAR_ENCODING_UTF16BE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":247
 *         return "UTF-16LE"
 *     elif enc == tree.XML_CHAR_ENCODING_UTF16BE:
 *         return "UTF-16BE"             # <<<<<<<<<<<<<<
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4LE:
 *         return "UCS-4LE"
 */
    __pyx_r = __pyx_k_410;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":248
 *     elif enc == tree.XML_CHAR_ENCODING_UTF16BE:
 *         return "UTF-16BE"
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4LE:             # <<<<<<<<<<<<<<
 *         return "UCS-4LE"
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4BE:
 */
  __pyx_1 = (__pyx_v_enc == XML_CHAR_ENCODING_UCS4LE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":249
 *         return "UTF-16BE"
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4LE:
 *         return "UCS-4LE"             # <<<<<<<<<<<<<<
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4BE:
 *         return "UCS-4BE"
 */
    __pyx_r = __pyx_k_411;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":250
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4LE:
 *         return "UCS-4LE"
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4BE:             # <<<<<<<<<<<<<<
 *         return "UCS-4BE"
 *     elif enc == tree.XML_CHAR_ENCODING_NONE:
 */
  __pyx_1 = (__pyx_v_enc == XML_CHAR_ENCODING_UCS4BE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":251
 *         return "UCS-4LE"
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4BE:
 *         return "UCS-4BE"             # <<<<<<<<<<<<<<
 *     elif enc == tree.XML_CHAR_ENCODING_NONE:
 *         return NULL
 */
    __pyx_r = __pyx_k_412;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":252
 *     elif enc == tree.XML_CHAR_ENCODING_UCS4BE:
 *         return "UCS-4BE"
 *     elif enc == tree.XML_CHAR_ENCODING_NONE:             # <<<<<<<<<<<<<<
 *         return NULL
 *     else:
 */
  __pyx_1 = (__pyx_v_enc == XML_CHAR_ENCODING_NONE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":253
 *         return "UCS-4BE"
 *     elif enc == tree.XML_CHAR_ENCODING_NONE:
 *         return NULL             # <<<<<<<<<<<<<<
 *     else:
 *         return tree.xmlGetCharEncodingName(enc)
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":255
 *         return NULL
 *     else:
 *         return tree.xmlGetCharEncodingName(enc)             # <<<<<<<<<<<<<<
 * 
 * _setupPythonUnicode()
 */
    __pyx_r = xmlGetCharEncodingName(__pyx_v_enc);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":271
 *     cdef Py_ssize_t _bytes_read
 *     cdef char* _c_url
 *     def __init__(self, filelike, exc_context, url, encoding):             # <<<<<<<<<<<<<<
 *         self._exc_context = exc_context
 *         self._filelike = filelike
 */

static int __pyx_pf_4lxml_5etree_18_FileReaderContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_18_FileReaderContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filelike = 0;
  PyObject *__pyx_v_exc_context = 0;
  PyObject *__pyx_v_url = 0;
  PyObject *__pyx_v_encoding = 0;
  int __pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_filelike,&__pyx_kp_exc_context,&__pyx_kp_url,&__pyx_kp_encoding,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_filelike);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_exc_context);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_url);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_encoding);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_filelike = values[0];
    __pyx_v_exc_context = values[1];
    __pyx_v_url = values[2];
    __pyx_v_encoding = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_filelike = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_exc_context = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_url = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._FileReaderContext.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":272
 *     cdef char* _c_url
 *     def __init__(self, filelike, exc_context, url, encoding):
 *         self._exc_context = exc_context             # <<<<<<<<<<<<<<
 *         self._filelike = filelike
 *         self._encoding = encoding
 */
  if (!(__Pyx_TypeTest(__pyx_v_exc_context, __pyx_ptype_4lxml_5etree__ExceptionContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_exc_context);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_exc_context));
  ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_exc_context);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":273
 *     def __init__(self, filelike, exc_context, url, encoding):
 *         self._exc_context = exc_context
 *         self._filelike = filelike             # <<<<<<<<<<<<<<
 *         self._encoding = encoding
 *         self._url = url
 */
  Py_INCREF(__pyx_v_filelike);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_filelike);
  ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_filelike = __pyx_v_filelike;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":274
 *         self._exc_context = exc_context
 *         self._filelike = filelike
 *         self._encoding = encoding             # <<<<<<<<<<<<<<
 *         self._url = url
 *         if url is None:
 */
  Py_INCREF(__pyx_v_encoding);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_encoding);
  ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_encoding = __pyx_v_encoding;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":275
 *         self._filelike = filelike
 *         self._encoding = encoding
 *         self._url = url             # <<<<<<<<<<<<<<
 *         if url is None:
 *             self._c_url = NULL
 */
  Py_INCREF(__pyx_v_url);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_url);
  ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_url = __pyx_v_url;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":276
 *         self._encoding = encoding
 *         self._url = url
 *         if url is None:             # <<<<<<<<<<<<<<
 *             self._c_url = NULL
 *         else:
 */
  __pyx_1 = (__pyx_v_url == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":277
 *         self._url = url
 *         if url is None:
 *             self._c_url = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             self._c_url = _cstr(url)
 */
    ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_c_url = NULL;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":279
 *             self._c_url = NULL
 *         else:
 *             self._c_url = _cstr(url)             # <<<<<<<<<<<<<<
 *         self._bytes  = ''
 *         self._bytes_read = 0
 */
    ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_c_url = PyString_AS_STRING(__pyx_v_url);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":280
 *         else:
 *             self._c_url = _cstr(url)
 *         self._bytes  = ''             # <<<<<<<<<<<<<<
 *         self._bytes_read = 0
 * 
 */
  Py_INCREF(__pyx_kp_413);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_bytes);
  ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_bytes = __pyx_kp_413;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":281
 *             self._c_url = _cstr(url)
 *         self._bytes  = ''
 *         self._bytes_read = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlparser.xmlParserInputBuffer* _createParserInputBuffer(self):
 */
  ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_self)->_bytes_read = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._FileReaderContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":283
 *         self._bytes_read = 0
 * 
 *     cdef xmlparser.xmlParserInputBuffer* _createParserInputBuffer(self):             # <<<<<<<<<<<<<<
 *         cdef cstd.FILE* c_stream
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 */

static  xmlParserInputBuffer *__pyx_f_4lxml_5etree_18_FileReaderContext__createParserInputBuffer(struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_self) {
  FILE *__pyx_v_c_stream;
  xmlParserInputBuffer *__pyx_v_c_buffer;
  xmlParserInputBuffer *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":286
 *         cdef cstd.FILE* c_stream
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = xmlparser.xmlAllocParserInputBuffer(0)             # <<<<<<<<<<<<<<
 *         c_stream = python.PyFile_AsFile(self._filelike)
 *         if c_stream is NULL:
 */
  __pyx_v_c_buffer = xmlAllocParserInputBuffer(0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":287
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = xmlparser.xmlAllocParserInputBuffer(0)
 *         c_stream = python.PyFile_AsFile(self._filelike)             # <<<<<<<<<<<<<<
 *         if c_stream is NULL:
 *             c_buffer.readcallback  = _readFilelikeParser
 */
  __pyx_v_c_stream = PyFile_AsFile(__pyx_v_self->_filelike);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":288
 *         c_buffer = xmlparser.xmlAllocParserInputBuffer(0)
 *         c_stream = python.PyFile_AsFile(self._filelike)
 *         if c_stream is NULL:             # <<<<<<<<<<<<<<
 *             c_buffer.readcallback  = _readFilelikeParser
 *             c_buffer.context = <python.PyObject*>self
 */
  __pyx_1 = (__pyx_v_c_stream == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":289
 *         c_stream = python.PyFile_AsFile(self._filelike)
 *         if c_stream is NULL:
 *             c_buffer.readcallback  = _readFilelikeParser             # <<<<<<<<<<<<<<
 *             c_buffer.context = <python.PyObject*>self
 *         else:
 */
    __pyx_v_c_buffer->readcallback = __pyx_f_4lxml_5etree__readFilelikeParser;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":290
 *         if c_stream is NULL:
 *             c_buffer.readcallback  = _readFilelikeParser
 *             c_buffer.context = <python.PyObject*>self             # <<<<<<<<<<<<<<
 *         else:
 *             c_buffer.readcallback  = _readFileParser
 */
    __pyx_v_c_buffer->context = ((PyObject *)__pyx_v_self);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":292
 *             c_buffer.context = <python.PyObject*>self
 *         else:
 *             c_buffer.readcallback  = _readFileParser             # <<<<<<<<<<<<<<
 *             c_buffer.context = c_stream
 *         return c_buffer
 */
    __pyx_v_c_buffer->readcallback = __pyx_f_4lxml_5etree__readFileParser;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":293
 *         else:
 *             c_buffer.readcallback  = _readFileParser
 *             c_buffer.context = c_stream             # <<<<<<<<<<<<<<
 *         return c_buffer
 * 
 */
    __pyx_v_c_buffer->context = __pyx_v_c_stream;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":294
 *             c_buffer.readcallback  = _readFileParser
 *             c_buffer.context = c_stream
 *         return c_buffer             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlparser.xmlParserInput* _createParserInput(
 */
  __pyx_r = __pyx_v_c_buffer;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":296
 *         return c_buffer
 * 
 *     cdef xmlparser.xmlParserInput* _createParserInput(             # <<<<<<<<<<<<<<
 *             self, xmlparser.xmlParserCtxt* ctxt):
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 */

static  xmlParserInput *__pyx_f_4lxml_5etree_18_FileReaderContext__createParserInput(struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_self, xmlParserCtxt *__pyx_v_ctxt) {
  xmlParserInputBuffer *__pyx_v_c_buffer;
  xmlParserInput *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":299
 *             self, xmlparser.xmlParserCtxt* ctxt):
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = self._createParserInputBuffer()             # <<<<<<<<<<<<<<
 *         return xmlparser.xmlNewIOInputStream(ctxt, c_buffer, 0)
 * 
 */
  __pyx_v_c_buffer = ((struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *)__pyx_v_self->__pyx_vtab)->_createParserInputBuffer(__pyx_v_self);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":300
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = self._createParserInputBuffer()
 *         return xmlparser.xmlNewIOInputStream(ctxt, c_buffer, 0)             # <<<<<<<<<<<<<<
 * 
 *     cdef tree.xmlDtd* _readDtd(self):
 */
  __pyx_r = xmlNewIOInputStream(__pyx_v_ctxt, __pyx_v_c_buffer, 0);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":302
 *         return xmlparser.xmlNewIOInputStream(ctxt, c_buffer, 0)
 * 
 *     cdef tree.xmlDtd* _readDtd(self):             # <<<<<<<<<<<<<<
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = self._createParserInputBuffer()
 */

static  xmlDtd *__pyx_f_4lxml_5etree_18_FileReaderContext__readDtd(struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_self) {
  xmlParserInputBuffer *__pyx_v_c_buffer;
  xmlDtd *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":304
 *     cdef tree.xmlDtd* _readDtd(self):
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = self._createParserInputBuffer()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             return xmlparser.xmlIOParseDTD(NULL, c_buffer, 0)
 */
  __pyx_v_c_buffer = ((struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *)__pyx_v_self->__pyx_vtab)->_createParserInputBuffer(__pyx_v_self);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":305
 *         cdef xmlparser.xmlParserInputBuffer* c_buffer
 *         c_buffer = self._createParserInputBuffer()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             return xmlparser.xmlIOParseDTD(NULL, c_buffer, 0)
 * 
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":306
 *         c_buffer = self._createParserInputBuffer()
 *         with nogil:
 *             return xmlparser.xmlIOParseDTD(NULL, c_buffer, 0)             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _readDoc(self, xmlparser.xmlParserCtxt* ctxt, int options):
 */
      __pyx_r = xmlIOParseDTD(NULL, __pyx_v_c_buffer, 0);
      goto __pyx_L3;
    }
    /*finally:*/ {
      int __pyx_why;
      __pyx_why = 0; goto __pyx_L5;
      __pyx_L3: __pyx_why = 3; goto __pyx_L5;
      __pyx_L5:;
      Py_BLOCK_THREADS
      switch (__pyx_why) {
        case 3: goto __pyx_L0;
      }
    }
  }

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":308
 *             return xmlparser.xmlIOParseDTD(NULL, c_buffer, 0)
 * 
 *     cdef xmlDoc* _readDoc(self, xmlparser.xmlParserCtxt* ctxt, int options):             # <<<<<<<<<<<<<<
 *         cdef xmlDoc* result
 *         cdef char* c_encoding
 */

static  xmlDoc *__pyx_f_4lxml_5etree_18_FileReaderContext__readDoc(struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_self, xmlParserCtxt *__pyx_v_ctxt, int __pyx_v_options) {
  xmlDoc *__pyx_v_result;
  char *__pyx_v_c_encoding;
  FILE *__pyx_v_c_stream;
  xmlInputReadCallback __pyx_v_c_read_callback;
  void *__pyx_v_c_callback_context;
  xmlDoc *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":316
 *         cdef void* c_callback_context
 * 
 *         if self._encoding is None:             # <<<<<<<<<<<<<<
 *             c_encoding = NULL
 *         else:
 */
  __pyx_1 = (__pyx_v_self->_encoding == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":317
 * 
 *         if self._encoding is None:
 *             c_encoding = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             c_encoding = _cstr(self._encoding)
 */
    __pyx_v_c_encoding = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":319
 *             c_encoding = NULL
 *         else:
 *             c_encoding = _cstr(self._encoding)             # <<<<<<<<<<<<<<
 * 
 *         c_stream = python.PyFile_AsFile(self._filelike)
 */
    __pyx_v_c_encoding = PyString_AS_STRING(__pyx_v_self->_encoding);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":321
 *             c_encoding = _cstr(self._encoding)
 * 
 *         c_stream = python.PyFile_AsFile(self._filelike)             # <<<<<<<<<<<<<<
 *         if c_stream is NULL:
 *             c_read_callback  = _readFilelikeParser
 */
  __pyx_v_c_stream = PyFile_AsFile(__pyx_v_self->_filelike);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":322
 * 
 *         c_stream = python.PyFile_AsFile(self._filelike)
 *         if c_stream is NULL:             # <<<<<<<<<<<<<<
 *             c_read_callback  = _readFilelikeParser
 *             c_callback_context = <python.PyObject*>self
 */
  __pyx_1 = (__pyx_v_c_stream == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":323
 *         c_stream = python.PyFile_AsFile(self._filelike)
 *         if c_stream is NULL:
 *             c_read_callback  = _readFilelikeParser             # <<<<<<<<<<<<<<
 *             c_callback_context = <python.PyObject*>self
 *         else:
 */
    __pyx_v_c_read_callback = __pyx_f_4lxml_5etree__readFilelikeParser;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":324
 *         if c_stream is NULL:
 *             c_read_callback  = _readFilelikeParser
 *             c_callback_context = <python.PyObject*>self             # <<<<<<<<<<<<<<
 *         else:
 *             c_read_callback  = _readFileParser
 */
    __pyx_v_c_callback_context = ((PyObject *)__pyx_v_self);
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":326
 *             c_callback_context = <python.PyObject*>self
 *         else:
 *             c_read_callback  = _readFileParser             # <<<<<<<<<<<<<<
 *             c_callback_context = c_stream
 * 
 */
    __pyx_v_c_read_callback = __pyx_f_4lxml_5etree__readFileParser;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":327
 *         else:
 *             c_read_callback  = _readFileParser
 *             c_callback_context = c_stream             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_c_callback_context = __pyx_v_c_stream;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":329
 *             c_callback_context = c_stream
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if ctxt.html:
 *                 result = htmlparser.htmlCtxtReadIO(
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":330
 * 
 *         with nogil:
 *             if ctxt.html:             # <<<<<<<<<<<<<<
 *                 result = htmlparser.htmlCtxtReadIO(
 *                         ctxt, c_read_callback, NULL, c_callback_context,
 */
      __pyx_1 = __pyx_v_ctxt->html;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":333
 *                 result = htmlparser.htmlCtxtReadIO(
 *                         ctxt, c_read_callback, NULL, c_callback_context,
 *                         self._c_url, c_encoding, options)             # <<<<<<<<<<<<<<
 *                 if result is not NULL:
 *                     if _fixHtmlDictNames(ctxt.dict, result) < 0:
 */
        __pyx_v_result = htmlCtxtReadIO(__pyx_v_ctxt, __pyx_v_c_read_callback, NULL, __pyx_v_c_callback_context, __pyx_v_self->_c_url, __pyx_v_c_encoding, __pyx_v_options);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":334
 *                         ctxt, c_read_callback, NULL, c_callback_context,
 *                         self._c_url, c_encoding, options)
 *                 if result is not NULL:             # <<<<<<<<<<<<<<
 *                     if _fixHtmlDictNames(ctxt.dict, result) < 0:
 *                         tree.xmlFreeDoc(result)
 */
        __pyx_1 = (__pyx_v_result != NULL);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":335
 *                         self._c_url, c_encoding, options)
 *                 if result is not NULL:
 *                     if _fixHtmlDictNames(ctxt.dict, result) < 0:             # <<<<<<<<<<<<<<
 *                         tree.xmlFreeDoc(result)
 *                         result = NULL
 */
          __pyx_1 = (__pyx_f_4lxml_5etree__fixHtmlDictNames(__pyx_v_ctxt->dict, __pyx_v_result) < 0);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":336
 *                 if result is not NULL:
 *                     if _fixHtmlDictNames(ctxt.dict, result) < 0:
 *                         tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *                         result = NULL
 *             else:
 */
            xmlFreeDoc(__pyx_v_result);

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":337
 *                     if _fixHtmlDictNames(ctxt.dict, result) < 0:
 *                         tree.xmlFreeDoc(result)
 *                         result = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 result = xmlparser.xmlCtxtReadIO(
 */
            __pyx_v_result = NULL;
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":341
 *                 result = xmlparser.xmlCtxtReadIO(
 *                     ctxt, c_read_callback, NULL, c_callback_context,
 *                     self._c_url, c_encoding, options)             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
        __pyx_v_result = xmlCtxtReadIO(__pyx_v_ctxt, __pyx_v_c_read_callback, NULL, __pyx_v_c_callback_context, __pyx_v_self->_c_url, __pyx_v_c_encoding, __pyx_v_options);
      }
      __pyx_L8:;
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":343
 *                     self._c_url, c_encoding, options)
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef int copyToBuffer(self, char* c_buffer, int c_requested):
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":345
 *         return result
 * 
 *     cdef int copyToBuffer(self, char* c_buffer, int c_requested):             # <<<<<<<<<<<<<<
 *         cdef int c_byte_count
 *         cdef char* c_start
 */

static  int __pyx_f_4lxml_5etree_18_FileReaderContext_copyToBuffer(struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_self, char *__pyx_v_c_buffer, int __pyx_v_c_requested) {
  int __pyx_v_c_byte_count;
  char *__pyx_v_c_start;
  Py_ssize_t __pyx_v_byte_count;
  Py_ssize_t __pyx_v_remaining;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":349
 *         cdef char* c_start
 *         cdef Py_ssize_t byte_count, remaining
 *         if self._bytes_read < 0:             # <<<<<<<<<<<<<<
 *             return 0
 *         try:
 */
  __pyx_1 = (__pyx_v_self->_bytes_read < 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":350
 *         cdef Py_ssize_t byte_count, remaining
 *         if self._bytes_read < 0:
 *             return 0             # <<<<<<<<<<<<<<
 *         try:
 *             c_byte_count = 0
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":351
 *         if self._bytes_read < 0:
 *             return 0
 *         try:             # <<<<<<<<<<<<<<
 *             c_byte_count = 0
 *             byte_count = python.PyString_GET_SIZE(self._bytes)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":352
 *             return 0
 *         try:
 *             c_byte_count = 0             # <<<<<<<<<<<<<<
 *             byte_count = python.PyString_GET_SIZE(self._bytes)
 *             remaining  = byte_count - self._bytes_read
 */
      __pyx_v_c_byte_count = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":353
 *         try:
 *             c_byte_count = 0
 *             byte_count = python.PyString_GET_SIZE(self._bytes)             # <<<<<<<<<<<<<<
 *             remaining  = byte_count - self._bytes_read
 *             while c_requested > remaining:
 */
      __pyx_v_byte_count = PyString_GET_SIZE(__pyx_v_self->_bytes);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":354
 *             c_byte_count = 0
 *             byte_count = python.PyString_GET_SIZE(self._bytes)
 *             remaining  = byte_count - self._bytes_read             # <<<<<<<<<<<<<<
 *             while c_requested > remaining:
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 */
      __pyx_v_remaining = (__pyx_v_byte_count - __pyx_v_self->_bytes_read);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":355
 *             byte_count = python.PyString_GET_SIZE(self._bytes)
 *             remaining  = byte_count - self._bytes_read
 *             while c_requested > remaining:             # <<<<<<<<<<<<<<
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 *                 cstd.memcpy(c_buffer, c_start, remaining)
 */
      while (1) {
        __pyx_1 = (__pyx_v_c_requested > __pyx_v_remaining);
        if (!__pyx_1) break;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":356
 *             remaining  = byte_count - self._bytes_read
 *             while c_requested > remaining:
 *                 c_start = _cstr(self._bytes) + self._bytes_read             # <<<<<<<<<<<<<<
 *                 cstd.memcpy(c_buffer, c_start, remaining)
 *                 c_byte_count += remaining
 */
        __pyx_v_c_start = (PyString_AS_STRING(__pyx_v_self->_bytes) + __pyx_v_self->_bytes_read);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":357
 *             while c_requested > remaining:
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 *                 cstd.memcpy(c_buffer, c_start, remaining)             # <<<<<<<<<<<<<<
 *                 c_byte_count += remaining
 *                 c_buffer += remaining
 */
        memcpy(__pyx_v_c_buffer, __pyx_v_c_start, __pyx_v_remaining);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":358
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 *                 cstd.memcpy(c_buffer, c_start, remaining)
 *                 c_byte_count += remaining             # <<<<<<<<<<<<<<
 *                 c_buffer += remaining
 *                 c_requested -= remaining
 */
        __pyx_v_c_byte_count += __pyx_v_remaining;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":359
 *                 cstd.memcpy(c_buffer, c_start, remaining)
 *                 c_byte_count += remaining
 *                 c_buffer += remaining             # <<<<<<<<<<<<<<
 *                 c_requested -= remaining
 * 
 */
        __pyx_v_c_buffer += __pyx_v_remaining;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":360
 *                 c_byte_count += remaining
 *                 c_buffer += remaining
 *                 c_requested -= remaining             # <<<<<<<<<<<<<<
 * 
 *                 self._bytes = self._filelike.read(c_requested)
 */
        __pyx_v_c_requested -= __pyx_v_remaining;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":362
 *                 c_requested -= remaining
 * 
 *                 self._bytes = self._filelike.read(c_requested)             # <<<<<<<<<<<<<<
 *                 if not python.PyString_Check(self._bytes):
 *                     if python.PyUnicode_Check(self._bytes):
 */
        __pyx_2 = PyObject_GetAttr(__pyx_v_self->_filelike, __pyx_kp_read); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_3 = PyInt_FromLong(__pyx_v_c_requested); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
        Py_DECREF(__pyx_v_self->_bytes);
        __pyx_v_self->_bytes = __pyx_3;
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":363
 * 
 *                 self._bytes = self._filelike.read(c_requested)
 *                 if not python.PyString_Check(self._bytes):             # <<<<<<<<<<<<<<
 *                     if python.PyUnicode_Check(self._bytes):
 *                         if self._encoding is None:
 */
        __pyx_1 = (!PyString_Check(__pyx_v_self->_bytes));
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":364
 *                 self._bytes = self._filelike.read(c_requested)
 *                 if not python.PyString_Check(self._bytes):
 *                     if python.PyUnicode_Check(self._bytes):             # <<<<<<<<<<<<<<
 *                         if self._encoding is None:
 *                             self._bytes = python.PyUnicode_AsUTF8String(self._bytes)
 */
          __pyx_5 = PyUnicode_Check(__pyx_v_self->_bytes);
          if (__pyx_5) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":365
 *                 if not python.PyString_Check(self._bytes):
 *                     if python.PyUnicode_Check(self._bytes):
 *                         if self._encoding is None:             # <<<<<<<<<<<<<<
 *                             self._bytes = python.PyUnicode_AsUTF8String(self._bytes)
 *                         else:
 */
            __pyx_1 = (__pyx_v_self->_encoding == Py_None);
            if (__pyx_1) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":366
 *                     if python.PyUnicode_Check(self._bytes):
 *                         if self._encoding is None:
 *                             self._bytes = python.PyUnicode_AsUTF8String(self._bytes)             # <<<<<<<<<<<<<<
 *                         else:
 *                             self._bytes = python.PyUnicode_AsEncodedString(
 */
              __pyx_2 = PyUnicode_AsUTF8String(__pyx_v_self->_bytes); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
              Py_DECREF(__pyx_v_self->_bytes);
              __pyx_v_self->_bytes = __pyx_2;
              __pyx_2 = 0;
              goto __pyx_L13;
            }
            /*else*/ {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":369
 *                         else:
 *                             self._bytes = python.PyUnicode_AsEncodedString(
 *                                 self._bytes, _cstr(self._encoding), NULL)             # <<<<<<<<<<<<<<
 *                     else:
 *                         raise TypeError, \
 */
              __pyx_4 = PyUnicode_AsEncodedString(__pyx_v_self->_bytes, PyString_AS_STRING(__pyx_v_self->_encoding), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L4_error;}

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":368
 *                             self._bytes = python.PyUnicode_AsUTF8String(self._bytes)
 *                         else:
 *                             self._bytes = python.PyUnicode_AsEncodedString(             # <<<<<<<<<<<<<<
 *                                 self._bytes, _cstr(self._encoding), NULL)
 *                     else:
 */
              Py_DECREF(__pyx_v_self->_bytes);
              __pyx_v_self->_bytes = __pyx_4;
              __pyx_4 = 0;
            }
            __pyx_L13:;
            goto __pyx_L12;
          }
          /*else*/ {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":372
 *                     else:
 *                         raise TypeError, \
 *                             u"reading from file-like objects must return byte strings or unicode strings"             # <<<<<<<<<<<<<<
 * 
 *                 remaining = python.PyString_GET_SIZE(self._bytes)
 */
            __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_414), 0);
            {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":374
 *                             u"reading from file-like objects must return byte strings or unicode strings"
 * 
 *                 remaining = python.PyString_GET_SIZE(self._bytes)             # <<<<<<<<<<<<<<
 *                 if remaining == 0:
 *                     self._bytes_read = -1
 */
        __pyx_v_remaining = PyString_GET_SIZE(__pyx_v_self->_bytes);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":375
 * 
 *                 remaining = python.PyString_GET_SIZE(self._bytes)
 *                 if remaining == 0:             # <<<<<<<<<<<<<<
 *                     self._bytes_read = -1
 *                     return c_byte_count
 */
        __pyx_1 = (__pyx_v_remaining == 0);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":376
 *                 remaining = python.PyString_GET_SIZE(self._bytes)
 *                 if remaining == 0:
 *                     self._bytes_read = -1             # <<<<<<<<<<<<<<
 *                     return c_byte_count
 *                 self._bytes_read = 0
 */
          __pyx_v_self->_bytes_read = -1;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":377
 *                 if remaining == 0:
 *                     self._bytes_read = -1
 *                     return c_byte_count             # <<<<<<<<<<<<<<
 *                 self._bytes_read = 0
 * 
 */
          __pyx_r = __pyx_v_c_byte_count;
          goto __pyx_L0;
          goto __pyx_L14;
        }
        __pyx_L14:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":378
 *                     self._bytes_read = -1
 *                     return c_byte_count
 *                 self._bytes_read = 0             # <<<<<<<<<<<<<<
 * 
 *             if c_requested > 0:
 */
        __pyx_v_self->_bytes_read = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":380
 *                 self._bytes_read = 0
 * 
 *             if c_requested > 0:             # <<<<<<<<<<<<<<
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 *                 cstd.memcpy(c_buffer, c_start, c_requested)
 */
      __pyx_1 = (__pyx_v_c_requested > 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":381
 * 
 *             if c_requested > 0:
 *                 c_start = _cstr(self._bytes) + self._bytes_read             # <<<<<<<<<<<<<<
 *                 cstd.memcpy(c_buffer, c_start, c_requested)
 *                 c_byte_count += c_requested
 */
        __pyx_v_c_start = (PyString_AS_STRING(__pyx_v_self->_bytes) + __pyx_v_self->_bytes_read);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":382
 *             if c_requested > 0:
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 *                 cstd.memcpy(c_buffer, c_start, c_requested)             # <<<<<<<<<<<<<<
 *                 c_byte_count += c_requested
 *                 self._bytes_read += c_requested
 */
        memcpy(__pyx_v_c_buffer, __pyx_v_c_start, __pyx_v_c_requested);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":383
 *                 c_start = _cstr(self._bytes) + self._bytes_read
 *                 cstd.memcpy(c_buffer, c_start, c_requested)
 *                 c_byte_count += c_requested             # <<<<<<<<<<<<<<
 *                 self._bytes_read += c_requested
 *             return c_byte_count
 */
        __pyx_v_c_byte_count += __pyx_v_c_requested;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":384
 *                 cstd.memcpy(c_buffer, c_start, c_requested)
 *                 c_byte_count += c_requested
 *                 self._bytes_read += c_requested             # <<<<<<<<<<<<<<
 *             return c_byte_count
 *         except:
 */
        __pyx_v_self->_bytes_read += __pyx_v_c_requested;
        goto __pyx_L15;
      }
      __pyx_L15:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":385
 *                 c_byte_count += c_requested
 *                 self._bytes_read += c_requested
 *             return c_byte_count             # <<<<<<<<<<<<<<
 *         except:
 *             self._exc_context._store_raised()
 */
      __pyx_r = __pyx_v_c_byte_count;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L8_try;
    __pyx_L4_error:;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":386
 *                 self._bytes_read += c_requested
 *             return c_byte_count
 *         except:             # <<<<<<<<<<<<<<
 *             self._exc_context._store_raised()
 *             return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree.copyToBuffer");
      if (__Pyx_GetException(&__pyx_3, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":387
 *             return c_byte_count
 *         except:
 *             self._exc_context._store_raised()             # <<<<<<<<<<<<<<
 *             return -1
 * 
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_self->_exc_context->__pyx_vtab)->_store_raised(__pyx_v_self->_exc_context);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":388
 *         except:
 *             self._exc_context._store_raised()
 *             return -1             # <<<<<<<<<<<<<<
 * 
 * cdef int _readFilelikeParser(void* ctxt, char* c_buffer, int c_size) with gil:
 */
      __pyx_r = -1;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L7_except_return;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L7_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L8_try:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._FileReaderContext.copyToBuffer");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":390
 *             return -1
 * 
 * cdef int _readFilelikeParser(void* ctxt, char* c_buffer, int c_size) with gil:             # <<<<<<<<<<<<<<
 *     return (<_FileReaderContext>ctxt).copyToBuffer(c_buffer, c_size)
 * 
 */

static  int __pyx_f_4lxml_5etree__readFilelikeParser(void *__pyx_v_ctxt, char *__pyx_v_c_buffer, int __pyx_v_c_size) {
  int __pyx_r;
  PyGILState_STATE _save = PyGILState_Ensure();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":391
 * 
 * cdef int _readFilelikeParser(void* ctxt, char* c_buffer, int c_size) with gil:
 *     return (<_FileReaderContext>ctxt).copyToBuffer(c_buffer, c_size)             # <<<<<<<<<<<<<<
 * 
 * cdef int _readFileParser(void* ctxt, char* c_buffer, int c_size) nogil:
 */
  __pyx_r = ((struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *)((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_ctxt)->__pyx_vtab)->copyToBuffer(((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_v_ctxt), __pyx_v_c_buffer, __pyx_v_c_size);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  PyGILState_Release(_save);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":393
 *     return (<_FileReaderContext>ctxt).copyToBuffer(c_buffer, c_size)
 * 
 * cdef int _readFileParser(void* ctxt, char* c_buffer, int c_size) nogil:             # <<<<<<<<<<<<<<
 *     return cstd.fread(c_buffer, 1,  c_size, <cstd.FILE*>ctxt)
 * 
 */

static  int __pyx_f_4lxml_5etree__readFileParser(void *__pyx_v_ctxt, char *__pyx_v_c_buffer, int __pyx_v_c_size) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":394
 * 
 * cdef int _readFileParser(void* ctxt, char* c_buffer, int c_size) nogil:
 *     return cstd.fread(c_buffer, 1,  c_size, <cstd.FILE*>ctxt)             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_r = fread(__pyx_v_c_buffer, 1, __pyx_v_c_size, ((FILE *)__pyx_v_ctxt));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":400
 * ############################################################
 * 
 * cdef xmlparser.xmlParserInput* _local_resolver(char* c_url, char* c_pubid,             # <<<<<<<<<<<<<<
 *                                                xmlparser.xmlParserCtxt* c_context) with gil:
 *     cdef _ResolverContext context
 */

static  xmlParserInput *__pyx_f_4lxml_5etree__local_resolver(char *__pyx_v_c_url, char *__pyx_v_c_pubid, xmlParserCtxt *__pyx_v_c_context) {
  struct __pyx_obj_4lxml_5etree__ResolverContext *__pyx_v_context;
  xmlParserInput *__pyx_v_c_input;
  struct __pyx_obj_4lxml_5etree__InputDocument *__pyx_v_doc_ref;
  struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_file_context;
  PyObject *__pyx_v_url;
  PyObject *__pyx_v_pubid;
  PyObject *__pyx_v_data;
  xmlParserInput *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ResolverContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_file_context = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_url = Py_None; Py_INCREF(Py_None);
  __pyx_v_pubid = Py_None; Py_INCREF(Py_None);
  __pyx_v_data = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":409
 *     # passed, check to see if the thread state object has an implied
 *     # context.
 *     if c_context._private is not NULL:             # <<<<<<<<<<<<<<
 *         context = <_ResolverContext>c_context._private
 *     else:
 */
  __pyx_1 = (__pyx_v_c_context->_private != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":410
 *     # context.
 *     if c_context._private is not NULL:
 *         context = <_ResolverContext>c_context._private             # <<<<<<<<<<<<<<
 *     else:
 *         context = __GLOBAL_PARSER_CONTEXT.findImpliedContext()
 */
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ResolverContext *)__pyx_v_c_context->_private)));
    Py_DECREF(((PyObject *)__pyx_v_context));
    __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ResolverContext *)__pyx_v_c_context->_private);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":412
 *         context = <_ResolverContext>c_context._private
 *     else:
 *         context = __GLOBAL_PARSER_CONTEXT.findImpliedContext()             # <<<<<<<<<<<<<<
 * 
 *     if context is None:
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->findImpliedContext(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_context));
    __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ResolverContext *)__pyx_2);
    __pyx_2 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":414
 *         context = __GLOBAL_PARSER_CONTEXT.findImpliedContext()
 * 
 *     if context is None:             # <<<<<<<<<<<<<<
 *         if __DEFAULT_ENTITY_LOADER is NULL:
 *             return NULL
 */
  __pyx_1 = (((PyObject *)__pyx_v_context) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":415
 * 
 *     if context is None:
 *         if __DEFAULT_ENTITY_LOADER is NULL:             # <<<<<<<<<<<<<<
 *             return NULL
 *         return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)
 */
    __pyx_1 = (__pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":416
 *     if context is None:
 *         if __DEFAULT_ENTITY_LOADER is NULL:
 *             return NULL             # <<<<<<<<<<<<<<
 *         return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)
 * 
 */
      __pyx_r = NULL;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":417
 *         if __DEFAULT_ENTITY_LOADER is NULL:
 *             return NULL
 *         return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
    __pyx_r = __pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER(__pyx_v_c_url, __pyx_v_c_pubid, __pyx_v_c_context);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":419
 *         return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         if c_url is NULL:
 *             url = None
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":420
 * 
 *     try:
 *         if c_url is NULL:             # <<<<<<<<<<<<<<
 *             url = None
 *         else:
 */
      __pyx_1 = (__pyx_v_c_url == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":421
 *     try:
 *         if c_url is NULL:
 *             url = None             # <<<<<<<<<<<<<<
 *         else:
 *             # parsing a related document (DTD etc.) => UTF-8 encoded URL?
 */
        Py_INCREF(Py_None);
        Py_DECREF(__pyx_v_url);
        __pyx_v_url = Py_None;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":424
 *         else:
 *             # parsing a related document (DTD etc.) => UTF-8 encoded URL?
 *             url = _decodeFilename(c_url)             # <<<<<<<<<<<<<<
 *         if c_pubid is NULL:
 *             pubid = None
 */
        __pyx_2 = __pyx_f_4lxml_5etree__decodeFilename(__pyx_v_c_url); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        Py_DECREF(__pyx_v_url);
        __pyx_v_url = __pyx_2;
        __pyx_2 = 0;
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":425
 *             # parsing a related document (DTD etc.) => UTF-8 encoded URL?
 *             url = _decodeFilename(c_url)
 *         if c_pubid is NULL:             # <<<<<<<<<<<<<<
 *             pubid = None
 *         else:
 */
      __pyx_1 = (__pyx_v_c_pubid == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":426
 *             url = _decodeFilename(c_url)
 *         if c_pubid is NULL:
 *             pubid = None             # <<<<<<<<<<<<<<
 *         else:
 *             pubid = funicode(c_pubid) # always UTF-8
 */
        Py_INCREF(Py_None);
        Py_DECREF(__pyx_v_pubid);
        __pyx_v_pubid = Py_None;
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":428
 *             pubid = None
 *         else:
 *             pubid = funicode(c_pubid) # always UTF-8             # <<<<<<<<<<<<<<
 * 
 *         doc_ref = context._resolvers.resolve(url, pubid, context)
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_pubid); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        Py_DECREF(__pyx_v_pubid);
        __pyx_v_pubid = __pyx_2;
        __pyx_2 = 0;
      }
      __pyx_L12:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":430
 *             pubid = funicode(c_pubid) # always UTF-8
 * 
 *         doc_ref = context._resolvers.resolve(url, pubid, context)             # <<<<<<<<<<<<<<
 *     except:
 *         context._store_raised()
 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_context->_resolvers), __pyx_kp_resolve); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_INCREF(__pyx_v_url);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_url);
      Py_INCREF(__pyx_v_pubid);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_pubid);
      Py_INCREF(((PyObject *)__pyx_v_context));
      PyTuple_SET_ITEM(__pyx_3, 2, ((PyObject *)__pyx_v_context));
      __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__InputDocument))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc_ref));
      __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)__pyx_4);
      __pyx_4 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":431
 * 
 *         doc_ref = context._resolvers.resolve(url, pubid, context)
 *     except:             # <<<<<<<<<<<<<<
 *         context._store_raised()
 *         return NULL
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._local_resolver");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":432
 *         doc_ref = context._resolvers.resolve(url, pubid, context)
 *     except:
 *         context._store_raised()             # <<<<<<<<<<<<<<
 *         return NULL
 * 
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ResolverContext *)__pyx_v_context->__pyx_base.__pyx_vtab)->__pyx_base._store_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context));

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":433
 *     except:
 *         context._store_raised()
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 *     if doc_ref is not None:
 */
      __pyx_r = NULL;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L9_except_return;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":435
 *         return NULL
 * 
 *     if doc_ref is not None:             # <<<<<<<<<<<<<<
 *         if doc_ref._type == PARSER_DATA_STRING:
 *             data = doc_ref._data_bytes
 */
  __pyx_1 = (((PyObject *)__pyx_v_doc_ref) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":436
 * 
 *     if doc_ref is not None:
 *         if doc_ref._type == PARSER_DATA_STRING:             # <<<<<<<<<<<<<<
 *             data = doc_ref._data_bytes
 *             c_input = xmlparser.xmlNewInputStream(c_context)
 */
    __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_STRING);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":437
 *     if doc_ref is not None:
 *         if doc_ref._type == PARSER_DATA_STRING:
 *             data = doc_ref._data_bytes             # <<<<<<<<<<<<<<
 *             c_input = xmlparser.xmlNewInputStream(c_context)
 *             if c_input is not NULL:
 */
      Py_INCREF(__pyx_v_doc_ref->_data_bytes);
      Py_DECREF(__pyx_v_data);
      __pyx_v_data = __pyx_v_doc_ref->_data_bytes;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":438
 *         if doc_ref._type == PARSER_DATA_STRING:
 *             data = doc_ref._data_bytes
 *             c_input = xmlparser.xmlNewInputStream(c_context)             # <<<<<<<<<<<<<<
 *             if c_input is not NULL:
 *                 c_input.base = _cstr(data)
 */
      __pyx_v_c_input = xmlNewInputStream(__pyx_v_c_context);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":439
 *             data = doc_ref._data_bytes
 *             c_input = xmlparser.xmlNewInputStream(c_context)
 *             if c_input is not NULL:             # <<<<<<<<<<<<<<
 *                 c_input.base = _cstr(data)
 *                 c_input.length = python.PyString_GET_SIZE(data)
 */
      __pyx_1 = (__pyx_v_c_input != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":440
 *             c_input = xmlparser.xmlNewInputStream(c_context)
 *             if c_input is not NULL:
 *                 c_input.base = _cstr(data)             # <<<<<<<<<<<<<<
 *                 c_input.length = python.PyString_GET_SIZE(data)
 *                 c_input.cur = c_input.base
 */
        __pyx_v_c_input->base = PyString_AS_STRING(__pyx_v_data);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":441
 *             if c_input is not NULL:
 *                 c_input.base = _cstr(data)
 *                 c_input.length = python.PyString_GET_SIZE(data)             # <<<<<<<<<<<<<<
 *                 c_input.cur = c_input.base
 *                 c_input.end = &c_input.base[c_input.length]
 */
        __pyx_v_c_input->length = PyString_GET_SIZE(__pyx_v_data);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":442
 *                 c_input.base = _cstr(data)
 *                 c_input.length = python.PyString_GET_SIZE(data)
 *                 c_input.cur = c_input.base             # <<<<<<<<<<<<<<
 *                 c_input.end = &c_input.base[c_input.length]
 *         elif doc_ref._type == PARSER_DATA_FILENAME:
 */
        __pyx_v_c_input->cur = __pyx_v_c_input->base;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":443
 *                 c_input.length = python.PyString_GET_SIZE(data)
 *                 c_input.cur = c_input.base
 *                 c_input.end = &c_input.base[c_input.length]             # <<<<<<<<<<<<<<
 *         elif doc_ref._type == PARSER_DATA_FILENAME:
 *             c_input = xmlparser.xmlNewInputFromFile(
 */
        __pyx_v_c_input->end = (&(__pyx_v_c_input->base[__pyx_v_c_input->length]));
        goto __pyx_L15;
      }
      __pyx_L15:;
      goto __pyx_L14;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":444
 *                 c_input.cur = c_input.base
 *                 c_input.end = &c_input.base[c_input.length]
 *         elif doc_ref._type == PARSER_DATA_FILENAME:             # <<<<<<<<<<<<<<
 *             c_input = xmlparser.xmlNewInputFromFile(
 *                 c_context, _cstr(doc_ref._filename))
 */
    __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_FILENAME);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":446
 *         elif doc_ref._type == PARSER_DATA_FILENAME:
 *             c_input = xmlparser.xmlNewInputFromFile(
 *                 c_context, _cstr(doc_ref._filename))             # <<<<<<<<<<<<<<
 *         elif doc_ref._type == PARSER_DATA_FILE:
 *             file_context = _FileReaderContext(doc_ref._file, context, url, None)
 */
      __pyx_v_c_input = xmlNewInputFromFile(__pyx_v_c_context, PyString_AS_STRING(__pyx_v_doc_ref->_filename));
      goto __pyx_L14;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":447
 *             c_input = xmlparser.xmlNewInputFromFile(
 *                 c_context, _cstr(doc_ref._filename))
 *         elif doc_ref._type == PARSER_DATA_FILE:             # <<<<<<<<<<<<<<
 *             file_context = _FileReaderContext(doc_ref._file, context, url, None)
 *             c_input = file_context._createParserInput(c_context)
 */
    __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_FILE);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":448
 *                 c_context, _cstr(doc_ref._filename))
 *         elif doc_ref._type == PARSER_DATA_FILE:
 *             file_context = _FileReaderContext(doc_ref._file, context, url, None)             # <<<<<<<<<<<<<<
 *             c_input = file_context._createParserInput(c_context)
 *             data = file_context
 */
      __pyx_2 = PyTuple_New(4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_doc_ref->_file);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_doc_ref->_file);
      Py_INCREF(((PyObject *)__pyx_v_context));
      PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_context));
      Py_INCREF(__pyx_v_url);
      PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_url);
      Py_INCREF(Py_None);
      PyTuple_SET_ITEM(__pyx_2, 3, Py_None);
      __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__FileReaderContext)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__FileReaderContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_file_context));
      __pyx_v_file_context = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_3);
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":449
 *         elif doc_ref._type == PARSER_DATA_FILE:
 *             file_context = _FileReaderContext(doc_ref._file, context, url, None)
 *             c_input = file_context._createParserInput(c_context)             # <<<<<<<<<<<<<<
 *             data = file_context
 *         else:
 */
      __pyx_v_c_input = ((struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *)__pyx_v_file_context->__pyx_vtab)->_createParserInput(__pyx_v_file_context, __pyx_v_c_context);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":450
 *             file_context = _FileReaderContext(doc_ref._file, context, url, None)
 *             c_input = file_context._createParserInput(c_context)
 *             data = file_context             # <<<<<<<<<<<<<<
 *         else:
 *             data = None
 */
      Py_INCREF(((PyObject *)__pyx_v_file_context));
      Py_DECREF(__pyx_v_data);
      __pyx_v_data = ((PyObject *)__pyx_v_file_context);
      goto __pyx_L14;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":452
 *             data = file_context
 *         else:
 *             data = None             # <<<<<<<<<<<<<<
 *             c_input = NULL
 * 
 */
      Py_INCREF(Py_None);
      Py_DECREF(__pyx_v_data);
      __pyx_v_data = Py_None;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":453
 *         else:
 *             data = None
 *             c_input = NULL             # <<<<<<<<<<<<<<
 * 
 *         if data is not None:
 */
      __pyx_v_c_input = NULL;
    }
    __pyx_L14:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":455
 *             c_input = NULL
 * 
 *         if data is not None:             # <<<<<<<<<<<<<<
 *             context._storage.add(data)
 *         if c_input is not NULL:
 */
    __pyx_1 = (__pyx_v_data != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":456
 * 
 *         if data is not None:
 *             context._storage.add(data)             # <<<<<<<<<<<<<<
 *         if c_input is not NULL:
 *             return c_input
 */
      __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_context->_storage->__pyx_vtab)->add(__pyx_v_context->_storage, __pyx_v_data); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":457
 *         if data is not None:
 *             context._storage.add(data)
 *         if c_input is not NULL:             # <<<<<<<<<<<<<<
 *             return c_input
 * 
 */
    __pyx_1 = (__pyx_v_c_input != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":458
 *             context._storage.add(data)
 *         if c_input is not NULL:
 *             return c_input             # <<<<<<<<<<<<<<
 * 
 *     if __DEFAULT_ENTITY_LOADER is NULL:
 */
      __pyx_r = __pyx_v_c_input;
      goto __pyx_L0;
      goto __pyx_L17;
    }
    __pyx_L17:;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":460
 *             return c_input
 * 
 *     if __DEFAULT_ENTITY_LOADER is NULL:             # <<<<<<<<<<<<<<
 *         return NULL
 *     return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)
 */
  __pyx_1 = (__pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":461
 * 
 *     if __DEFAULT_ENTITY_LOADER is NULL:
 *         return NULL             # <<<<<<<<<<<<<<
 *     return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)
 * 
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    goto __pyx_L18;
  }
  __pyx_L18:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":462
 *     if __DEFAULT_ENTITY_LOADER is NULL:
 *         return NULL
 *     return __DEFAULT_ENTITY_LOADER(c_url, c_pubid, c_context)             # <<<<<<<<<<<<<<
 * 
 * cdef xmlparser.xmlExternalEntityLoader __DEFAULT_ENTITY_LOADER
 */
  __pyx_r = __pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER(__pyx_v_c_url, __pyx_v_c_pubid, __pyx_v_c_context);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._local_resolver");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_doc_ref);
  Py_DECREF(__pyx_v_file_context);
  Py_DECREF(__pyx_v_url);
  Py_DECREF(__pyx_v_pubid);
  Py_DECREF(__pyx_v_data);
  PyGILState_Release(_save);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":479
 *     cdef python.PyThread_type_lock _lock
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._validator is not None:
 *             self._validator.disconnect()
 */

static void __pyx_pf_4lxml_5etree_14_ParserContext___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_14_ParserContext___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":480
 * 
 *     def __dealloc__(self):
 *         if self._validator is not None:             # <<<<<<<<<<<<<<
 *             self._validator.disconnect()
 *         if self._lock is not NULL:
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_validator) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":481
 *     def __dealloc__(self):
 *         if self._validator is not None:
 *             self._validator.disconnect()             # <<<<<<<<<<<<<<
 *         if self._lock is not NULL:
 *             python.PyThread_free_lock(self._lock)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_validator->__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_validator);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":482
 *         if self._validator is not None:
 *             self._validator.disconnect()
 *         if self._lock is not NULL:             # <<<<<<<<<<<<<<
 *             python.PyThread_free_lock(self._lock)
 *         if self._c_ctxt is not NULL:
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_lock != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":483
 *             self._validator.disconnect()
 *         if self._lock is not NULL:
 *             python.PyThread_free_lock(self._lock)             # <<<<<<<<<<<<<<
 *         if self._c_ctxt is not NULL:
 *             xmlparser.xmlFreeParserCtxt(self._c_ctxt)
 */
    PyThread_free_lock(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_lock);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":484
 *         if self._lock is not NULL:
 *             python.PyThread_free_lock(self._lock)
 *         if self._c_ctxt is not NULL:             # <<<<<<<<<<<<<<
 *             xmlparser.xmlFreeParserCtxt(self._c_ctxt)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_c_ctxt != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":485
 *             python.PyThread_free_lock(self._lock)
 *         if self._c_ctxt is not NULL:
 *             xmlparser.xmlFreeParserCtxt(self._c_ctxt)             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext _copy(self):
 */
    xmlFreeParserCtxt(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self)->_c_ctxt);
    goto __pyx_L7;
  }
  __pyx_L7:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":487
 *             xmlparser.xmlFreeParserCtxt(self._c_ctxt)
 * 
 *     cdef _ParserContext _copy(self):             # <<<<<<<<<<<<<<
 *         cdef _ParserContext context
 *         context = self.__class__()
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_14_ParserContext__copy(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":489
 *     cdef _ParserContext _copy(self):
 *         cdef _ParserContext context
 *         context = self.__class__()             # <<<<<<<<<<<<<<
 *         context._validator = self._validator.copy()
 *         _initParserContext(context, self._resolvers._copy(), NULL)
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp___class__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ParserContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":490
 *         cdef _ParserContext context
 *         context = self.__class__()
 *         context._validator = self._validator.copy()             # <<<<<<<<<<<<<<
 *         _initParserContext(context, self._resolvers._copy(), NULL)
 *         return context
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self->_validator->__pyx_vtab)->copy(__pyx_v_self->_validator)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context->_validator));
  __pyx_v_context->_validator = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":491
 *         context = self.__class__()
 *         context._validator = self._validator.copy()
 *         _initParserContext(context, self._resolvers._copy(), NULL)             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ResolverRegistry *)__pyx_v_self->__pyx_base._resolvers->__pyx_vtab)->_copy(__pyx_v_self->__pyx_base._resolvers)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __pyx_f_4lxml_5etree__initParserContext(__pyx_v_context, ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":492
 *         context._validator = self._validator.copy()
 *         _initParserContext(context, self._resolvers._copy(), NULL)
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = __pyx_v_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ParserContext._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":494
 *         return context
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):             # <<<<<<<<<<<<<<
 *         self._c_ctxt = c_ctxt
 *         c_ctxt._private = <void*>self
 */

static  void __pyx_f_4lxml_5etree_14_ParserContext__initParserContext(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self, xmlParserCtxt *__pyx_v_c_ctxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":495
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):
 *         self._c_ctxt = c_ctxt             # <<<<<<<<<<<<<<
 *         c_ctxt._private = <void*>self
 * 
 */
  __pyx_v_self->_c_ctxt = __pyx_v_c_ctxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":496
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):
 *         self._c_ctxt = c_ctxt
 *         c_ctxt._private = <void*>self             # <<<<<<<<<<<<<<
 * 
 *     cdef void _resetParserContext(self):
 */
  __pyx_v_c_ctxt->_private = ((void *)__pyx_v_self);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":498
 *         c_ctxt._private = <void*>self
 * 
 *     cdef void _resetParserContext(self):             # <<<<<<<<<<<<<<
 *         if self._c_ctxt is not NULL:
 *             if self._c_ctxt.html:
 */

static  void __pyx_f_4lxml_5etree_14_ParserContext__resetParserContext(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":499
 * 
 *     cdef void _resetParserContext(self):
 *         if self._c_ctxt is not NULL:             # <<<<<<<<<<<<<<
 *             if self._c_ctxt.html:
 *                 htmlparser.htmlCtxtReset(self._c_ctxt)
 */
  __pyx_1 = (__pyx_v_self->_c_ctxt != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":500
 *     cdef void _resetParserContext(self):
 *         if self._c_ctxt is not NULL:
 *             if self._c_ctxt.html:             # <<<<<<<<<<<<<<
 *                 htmlparser.htmlCtxtReset(self._c_ctxt)
 *             elif self._c_ctxt.spaceTab is not NULL or \
 */
    __pyx_1 = __pyx_v_self->_c_ctxt->html;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":501
 *         if self._c_ctxt is not NULL:
 *             if self._c_ctxt.html:
 *                 htmlparser.htmlCtxtReset(self._c_ctxt)             # <<<<<<<<<<<<<<
 *             elif self._c_ctxt.spaceTab is not NULL or \
 *                     _LIBXML_VERSION_INT >= 20629: # work around bug in libxml2
 */
      htmlCtxtReset(__pyx_v_self->_c_ctxt);
      goto __pyx_L4;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":502
 *             if self._c_ctxt.html:
 *                 htmlparser.htmlCtxtReset(self._c_ctxt)
 *             elif self._c_ctxt.spaceTab is not NULL or \             # <<<<<<<<<<<<<<
 *                     _LIBXML_VERSION_INT >= 20629: # work around bug in libxml2
 *                 xmlparser.xmlClearParserCtxt(self._c_ctxt)
 */
    __pyx_1 = (__pyx_v_self->_c_ctxt->spaceTab != NULL);
    if (!__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":503
 *                 htmlparser.htmlCtxtReset(self._c_ctxt)
 *             elif self._c_ctxt.spaceTab is not NULL or \
 *                     _LIBXML_VERSION_INT >= 20629: # work around bug in libxml2             # <<<<<<<<<<<<<<
 *                 xmlparser.xmlClearParserCtxt(self._c_ctxt)
 * 
 */
      __pyx_1 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT >= 20629);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":504
 *             elif self._c_ctxt.spaceTab is not NULL or \
 *                     _LIBXML_VERSION_INT >= 20629: # work around bug in libxml2
 *                 xmlparser.xmlClearParserCtxt(self._c_ctxt)             # <<<<<<<<<<<<<<
 * 
 *     cdef int prepare(self) except -1:
 */
      xmlClearParserCtxt(__pyx_v_self->_c_ctxt);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":506
 *                 xmlparser.xmlClearParserCtxt(self._c_ctxt)
 * 
 *     cdef int prepare(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef int result
 *         if config.ENABLE_THREADING and self._lock is not NULL:
 */

static  int __pyx_f_4lxml_5etree_14_ParserContext_prepare(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self) {
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":508
 *     cdef int prepare(self) except -1:
 *         cdef int result
 *         if config.ENABLE_THREADING and self._lock is not NULL:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 result = python.PyThread_acquire_lock(
 */
  __pyx_1 = ENABLE_THREADING;
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_lock != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":509
 *         cdef int result
 *         if config.ENABLE_THREADING and self._lock is not NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = python.PyThread_acquire_lock(
 *                     self._lock, python.WAIT_LOCK)
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":511
 *             with nogil:
 *                 result = python.PyThread_acquire_lock(
 *                     self._lock, python.WAIT_LOCK)             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 raise ParserError, u"parser locking failed"
 */
        __pyx_v_result = PyThread_acquire_lock(__pyx_v_self->_lock, WAIT_LOCK);
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":512
 *                 result = python.PyThread_acquire_lock(
 *                     self._lock, python.WAIT_LOCK)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 raise ParserError, u"parser locking failed"
 *         self._error_log.connect()
 */
    __pyx_1 = (__pyx_v_result == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":513
 *                     self._lock, python.WAIT_LOCK)
 *             if result == 0:
 *                 raise ParserError, u"parser locking failed"             # <<<<<<<<<<<<<<
 *         self._error_log.connect()
 *         if self._validator is not None:
 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ParserError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_415), 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":514
 *             if result == 0:
 *                 raise ParserError, u"parser locking failed"
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         if self._validator is not None:
 *             self._validator.connect(self._c_ctxt)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_self->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(__pyx_v_self->_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":515
 *                 raise ParserError, u"parser locking failed"
 *         self._error_log.connect()
 *         if self._validator is not None:             # <<<<<<<<<<<<<<
 *             self._validator.connect(self._c_ctxt)
 *         return 0
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_validator) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":516
 *         self._error_log.connect()
 *         if self._validator is not None:
 *             self._validator.connect(self._c_ctxt)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self->_validator->__pyx_vtab)->connect(__pyx_v_self->_validator, __pyx_v_self->_c_ctxt); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":517
 *         if self._validator is not None:
 *             self._validator.connect(self._c_ctxt)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int cleanup(self) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ParserContext.prepare");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":519
 *         return 0
 * 
 *     cdef int cleanup(self) except -1:             # <<<<<<<<<<<<<<
 *         if self._validator is not None:
 *             self._validator.disconnect()
 */

static  int __pyx_f_4lxml_5etree_14_ParserContext_cleanup(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":520
 * 
 *     cdef int cleanup(self) except -1:
 *         if self._validator is not None:             # <<<<<<<<<<<<<<
 *             self._validator.disconnect()
 *         self._resetParserContext()
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_validator) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":521
 *     cdef int cleanup(self) except -1:
 *         if self._validator is not None:
 *             self._validator.disconnect()             # <<<<<<<<<<<<<<
 *         self._resetParserContext()
 *         self.clear()
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self->_validator->__pyx_vtab)->disconnect(__pyx_v_self->_validator);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":522
 *         if self._validator is not None:
 *             self._validator.disconnect()
 *         self._resetParserContext()             # <<<<<<<<<<<<<<
 *         self.clear()
 *         self._error_log.disconnect()
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_resetParserContext(__pyx_v_self);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":523
 *             self._validator.disconnect()
 *         self._resetParserContext()
 *         self.clear()             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 *         if config.ENABLE_THREADING and self._lock is not NULL:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.clear(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_self));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":524
 *         self._resetParserContext()
 *         self.clear()
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *         if config.ENABLE_THREADING and self._lock is not NULL:
 *             python.PyThread_release_lock(self._lock)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_self->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(__pyx_v_self->_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":525
 *         self.clear()
 *         self._error_log.disconnect()
 *         if config.ENABLE_THREADING and self._lock is not NULL:             # <<<<<<<<<<<<<<
 *             python.PyThread_release_lock(self._lock)
 *         return 0
 */
  __pyx_1 = ENABLE_THREADING;
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_lock != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":526
 *         self._error_log.disconnect()
 *         if config.ENABLE_THREADING and self._lock is not NULL:
 *             python.PyThread_release_lock(self._lock)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    PyThread_release_lock(__pyx_v_self->_lock);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":527
 *         if config.ENABLE_THREADING and self._lock is not NULL:
 *             python.PyThread_release_lock(self._lock)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef object _handleParseResult(self, _BaseParser parser,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":529
 *         return 0
 * 
 *     cdef object _handleParseResult(self, _BaseParser parser,             # <<<<<<<<<<<<<<
 *                                    xmlDoc* result, filename):
 *         cdef xmlDoc* c_doc
 */

static  PyObject *__pyx_f_4lxml_5etree_14_ParserContext__handleParseResult(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser, xmlDoc *__pyx_v_result, PyObject *__pyx_v_filename) {
  xmlDoc *__pyx_v_c_doc;
  int __pyx_v_recover;
  PyObject *__pyx_r;
  xmlDoc *__pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":533
 *         cdef xmlDoc* c_doc
 *         cdef bint recover
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER             # <<<<<<<<<<<<<<
 *         c_doc = _handleParseResult(self, self._c_ctxt, result,
 *                                    filename, recover)
 */
  __pyx_v_recover = (__pyx_v_parser->_parse_options & XML_PARSE_RECOVER);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":535
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER
 *         c_doc = _handleParseResult(self, self._c_ctxt, result,
 *                                    filename, recover)             # <<<<<<<<<<<<<<
 *         return _documentFactory(c_doc, parser)
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__handleParseResult(__pyx_v_self, __pyx_v_self->_c_ctxt, __pyx_v_result, __pyx_v_filename, __pyx_v_recover); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":536
 *         c_doc = _handleParseResult(self, self._c_ctxt, result,
 *                                    filename, recover)
 *         return _documentFactory(c_doc, parser)             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _handleParseResultDoc(self, _BaseParser parser,
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, __pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ParserContext._handleParseResult");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":538
 *         return _documentFactory(c_doc, parser)
 * 
 *     cdef xmlDoc* _handleParseResultDoc(self, _BaseParser parser,             # <<<<<<<<<<<<<<
 *                                        xmlDoc* result, filename) except NULL:
 *         cdef bint recover
 */

static  xmlDoc *__pyx_f_4lxml_5etree_14_ParserContext__handleParseResultDoc(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser, xmlDoc *__pyx_v_result, PyObject *__pyx_v_filename) {
  int __pyx_v_recover;
  xmlDoc *__pyx_r;
  xmlDoc *__pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":541
 *                                        xmlDoc* result, filename) except NULL:
 *         cdef bint recover
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER             # <<<<<<<<<<<<<<
 *         return _handleParseResult(self, self._c_ctxt, result,
 *                                    filename, recover)
 */
  __pyx_v_recover = (__pyx_v_parser->_parse_options & XML_PARSE_RECOVER);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":543
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER
 *         return _handleParseResult(self, self._c_ctxt, result,
 *                                    filename, recover)             # <<<<<<<<<<<<<<
 * 
 * cdef _initParserContext(_ParserContext context,
 */
  __pyx_1 = __pyx_f_4lxml_5etree__handleParseResult(__pyx_v_self, __pyx_v_self->_c_ctxt, __pyx_v_result, __pyx_v_filename, __pyx_v_recover); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._ParserContext._handleParseResultDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":545
 *                                    filename, recover)
 * 
 * cdef _initParserContext(_ParserContext context,             # <<<<<<<<<<<<<<
 *                         _ResolverRegistry resolvers,
 *                         xmlparser.xmlParserCtxt* c_ctxt):
 */

static  PyObject *__pyx_f_4lxml_5etree__initParserContext(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context, struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_v_resolvers, xmlParserCtxt *__pyx_v_c_ctxt) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":548
 *                         _ResolverRegistry resolvers,
 *                         xmlparser.xmlParserCtxt* c_ctxt):
 *     _initResolverContext(context, resolvers)             # <<<<<<<<<<<<<<
 *     if not config.ENABLE_THREADING:
 *         context._lock = NULL
 */
  __pyx_1 = __pyx_f_4lxml_5etree__initResolverContext(((struct __pyx_obj_4lxml_5etree__ResolverContext *)__pyx_v_context), __pyx_v_resolvers); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":549
 *                         xmlparser.xmlParserCtxt* c_ctxt):
 *     _initResolverContext(context, resolvers)
 *     if not config.ENABLE_THREADING:             # <<<<<<<<<<<<<<
 *         context._lock = NULL
 *     else:
 */
  __pyx_2 = (!ENABLE_THREADING);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":550
 *     _initResolverContext(context, resolvers)
 *     if not config.ENABLE_THREADING:
 *         context._lock = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         context._lock = python.PyThread_allocate_lock()
 */
    __pyx_v_context->_lock = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":552
 *         context._lock = NULL
 *     else:
 *         context._lock = python.PyThread_allocate_lock()             # <<<<<<<<<<<<<<
 *     if c_ctxt is not NULL:
 *         context._initParserContext(c_ctxt)
 */
    __pyx_v_context->_lock = PyThread_allocate_lock();
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":553
 *     else:
 *         context._lock = python.PyThread_allocate_lock()
 *     if c_ctxt is not NULL:             # <<<<<<<<<<<<<<
 *         context._initParserContext(c_ctxt)
 *     context._error_log = _ErrorLog()
 */
  __pyx_2 = (__pyx_v_c_ctxt != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":554
 *         context._lock = python.PyThread_allocate_lock()
 *     if c_ctxt is not NULL:
 *         context._initParserContext(c_ctxt)             # <<<<<<<<<<<<<<
 *     context._error_log = _ErrorLog()
 * 
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_initParserContext(__pyx_v_context, __pyx_v_c_ctxt);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":555
 *     if c_ctxt is not NULL:
 *         context._initParserContext(c_ctxt)
 *     context._error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 * 
 * cdef int _raiseParseError(xmlparser.xmlParserCtxt* ctxt, filename,
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context->_error_log));
  __pyx_v_context->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_1);
  __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._initParserContext");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":557
 *     context._error_log = _ErrorLog()
 * 
 * cdef int _raiseParseError(xmlparser.xmlParserCtxt* ctxt, filename,             # <<<<<<<<<<<<<<
 *                           _ErrorLog error_log) except 0:
 *     if filename is not None and \
 */

static  int __pyx_f_4lxml_5etree__raiseParseError(xmlParserCtxt *__pyx_v_ctxt, PyObject *__pyx_v_filename, struct __pyx_obj_4lxml_5etree__ErrorLog *__pyx_v_error_log) {
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_code;
  PyObject *__pyx_v_line;
  PyObject *__pyx_v_column;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_message = Py_None; Py_INCREF(Py_None);
  __pyx_v_code = Py_None; Py_INCREF(Py_None);
  __pyx_v_line = Py_None; Py_INCREF(Py_None);
  __pyx_v_column = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":559
 * cdef int _raiseParseError(xmlparser.xmlParserCtxt* ctxt, filename,
 *                           _ErrorLog error_log) except 0:
 *     if filename is not None and \             # <<<<<<<<<<<<<<
 *            ctxt.lastError.domain == xmlerror.XML_FROM_IO:
 *         if ctxt.lastError.message is not NULL:
 */
  __pyx_1 = (__pyx_v_filename != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":560
 *                           _ErrorLog error_log) except 0:
 *     if filename is not None and \
 *            ctxt.lastError.domain == xmlerror.XML_FROM_IO:             # <<<<<<<<<<<<<<
 *         if ctxt.lastError.message is not NULL:
 *             message = u"Error reading file '%s': %s" % (
 */
    __pyx_1 = (__pyx_v_ctxt->lastError.domain == XML_FROM_IO);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":561
 *     if filename is not None and \
 *            ctxt.lastError.domain == xmlerror.XML_FROM_IO:
 *         if ctxt.lastError.message is not NULL:             # <<<<<<<<<<<<<<
 *             message = u"Error reading file '%s': %s" % (
 *                 filename, (ctxt.lastError.message).strip())
 */
    __pyx_1 = (__pyx_v_ctxt->lastError.message != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":563
 *         if ctxt.lastError.message is not NULL:
 *             message = u"Error reading file '%s': %s" % (
 *                 filename, (ctxt.lastError.message).strip())             # <<<<<<<<<<<<<<
 *         else:
 *             message = u"Error reading '%s'" % filename
 */
      __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_ctxt->lastError.message); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_strip); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_filename);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_filename);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
      __pyx_2 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_416), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":565
 *                 filename, (ctxt.lastError.message).strip())
 *         else:
 *             message = u"Error reading '%s'" % filename             # <<<<<<<<<<<<<<
 *         raise IOError, message
 *     elif error_log:
 */
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_417), __pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":566
 *         else:
 *             message = u"Error reading '%s'" % filename
 *         raise IOError, message             # <<<<<<<<<<<<<<
 *     elif error_log:
 *         raise error_log._buildParseException(
 */
    __Pyx_Raise(__pyx_builtin_IOError, __pyx_v_message, 0);
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":567
 *             message = u"Error reading '%s'" % filename
 *         raise IOError, message
 *     elif error_log:             # <<<<<<<<<<<<<<
 *         raise error_log._buildParseException(
 *             XMLSyntaxError, u"Document is not well formed")
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_error_log)); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":569
 *     elif error_log:
 *         raise error_log._buildParseException(
 *             XMLSyntaxError, u"Document is not well formed")             # <<<<<<<<<<<<<<
 *     elif ctxt.lastError.message is not NULL:
 *         message = (ctxt.lastError.message).strip()
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSyntaxError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildParseException(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_error_log), __pyx_2, ((PyObject *)__pyx_kp_418)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":570
 *         raise error_log._buildParseException(
 *             XMLSyntaxError, u"Document is not well formed")
 *     elif ctxt.lastError.message is not NULL:             # <<<<<<<<<<<<<<
 *         message = (ctxt.lastError.message).strip()
 *         code = ctxt.lastError.code
 */
  __pyx_1 = (__pyx_v_ctxt->lastError.message != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":571
 *             XMLSyntaxError, u"Document is not well formed")
 *     elif ctxt.lastError.message is not NULL:
 *         message = (ctxt.lastError.message).strip()             # <<<<<<<<<<<<<<
 *         code = ctxt.lastError.code
 *         line = ctxt.lastError.line
 */
    __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_ctxt->lastError.message); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_strip); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":572
 *     elif ctxt.lastError.message is not NULL:
 *         message = (ctxt.lastError.message).strip()
 *         code = ctxt.lastError.code             # <<<<<<<<<<<<<<
 *         line = ctxt.lastError.line
 *         column = ctxt.lastError.int2
 */
    __pyx_3 = PyInt_FromLong(__pyx_v_ctxt->lastError.code); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_code);
    __pyx_v_code = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":573
 *         message = (ctxt.lastError.message).strip()
 *         code = ctxt.lastError.code
 *         line = ctxt.lastError.line             # <<<<<<<<<<<<<<
 *         column = ctxt.lastError.int2
 *         if ctxt.lastError.line > 0:
 */
    __pyx_2 = PyInt_FromLong(__pyx_v_ctxt->lastError.line); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_line);
    __pyx_v_line = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":574
 *         code = ctxt.lastError.code
 *         line = ctxt.lastError.line
 *         column = ctxt.lastError.int2             # <<<<<<<<<<<<<<
 *         if ctxt.lastError.line > 0:
 *             message = u"line %d: %s" % (line, message)
 */
    __pyx_3 = PyInt_FromLong(__pyx_v_ctxt->lastError.int2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_column);
    __pyx_v_column = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":575
 *         line = ctxt.lastError.line
 *         column = ctxt.lastError.int2
 *         if ctxt.lastError.line > 0:             # <<<<<<<<<<<<<<
 *             message = u"line %d: %s" % (line, message)
 *         raise XMLSyntaxError(message, code, line, column)
 */
    __pyx_1 = (__pyx_v_ctxt->lastError.line > 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":576
 *         column = ctxt.lastError.int2
 *         if ctxt.lastError.line > 0:
 *             message = u"line %d: %s" % (line, message)             # <<<<<<<<<<<<<<
 *         raise XMLSyntaxError(message, code, line, column)
 *     else:
 */
      __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_line);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_line);
      Py_INCREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_message);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_419), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":577
 *         if ctxt.lastError.line > 0:
 *             message = u"line %d: %s" % (line, message)
 *         raise XMLSyntaxError(message, code, line, column)             # <<<<<<<<<<<<<<
 *     else:
 *         raise XMLSyntaxError(None, xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSyntaxError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_message);
    Py_INCREF(__pyx_v_code);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_code);
    Py_INCREF(__pyx_v_line);
    PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_line);
    Py_INCREF(__pyx_v_column);
    PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_column);
    __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":579
 *         raise XMLSyntaxError(message, code, line, column)
 *     else:
 *         raise XMLSyntaxError(None, xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _handleParseResult(_ParserContext context,
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSyntaxError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyInt_FromLong(XML_ERR_INTERNAL_ERROR); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(4); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_4, 0, Py_None);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_int_0);
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_4, 3, __pyx_int_0);
    __pyx_2 = 0;
    __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._raiseParseError");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_message);
  Py_DECREF(__pyx_v_code);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_column);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":581
 *         raise XMLSyntaxError(None, xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)
 * 
 * cdef xmlDoc* _handleParseResult(_ParserContext context,             # <<<<<<<<<<<<<<
 *                                 xmlparser.xmlParserCtxt* c_ctxt,
 *                                 xmlDoc* result, filename,
 */

static  xmlDoc *__pyx_f_4lxml_5etree__handleParseResult(struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context, xmlParserCtxt *__pyx_v_c_ctxt, xmlDoc *__pyx_v_result, PyObject *__pyx_v_filename, int __pyx_v_recover) {
  int __pyx_v_well_formed;
  PyObject *__pyx_v_error;
  xmlDoc *__pyx_r;
  int __pyx_1;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  int __pyx_8;
  __pyx_v_error = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":586
 *                                 bint recover) except NULL:
 *     cdef bint well_formed
 *     if result is not NULL:             # <<<<<<<<<<<<<<
 *         __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 * 
 */
  __pyx_1 = (__pyx_v_result != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":587
 *     cdef bint well_formed
 *     if result is not NULL:
 *         __GLOBAL_PARSER_CONTEXT.initDocDict(result)             # <<<<<<<<<<<<<<
 * 
 *     if c_ctxt.myDoc is not NULL:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initDocDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_result);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":589
 *         __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 * 
 *     if c_ctxt.myDoc is not NULL:             # <<<<<<<<<<<<<<
 *         if c_ctxt.myDoc is not result:
 *             __GLOBAL_PARSER_CONTEXT.initDocDict(c_ctxt.myDoc)
 */
  __pyx_1 = (__pyx_v_c_ctxt->myDoc != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":590
 * 
 *     if c_ctxt.myDoc is not NULL:
 *         if c_ctxt.myDoc is not result:             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.initDocDict(c_ctxt.myDoc)
 *             tree.xmlFreeDoc(c_ctxt.myDoc)
 */
    __pyx_1 = (__pyx_v_c_ctxt->myDoc != __pyx_v_result);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":591
 *     if c_ctxt.myDoc is not NULL:
 *         if c_ctxt.myDoc is not result:
 *             __GLOBAL_PARSER_CONTEXT.initDocDict(c_ctxt.myDoc)             # <<<<<<<<<<<<<<
 *             tree.xmlFreeDoc(c_ctxt.myDoc)
 *         c_ctxt.myDoc = NULL
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initDocDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_c_ctxt->myDoc);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":592
 *         if c_ctxt.myDoc is not result:
 *             __GLOBAL_PARSER_CONTEXT.initDocDict(c_ctxt.myDoc)
 *             tree.xmlFreeDoc(c_ctxt.myDoc)             # <<<<<<<<<<<<<<
 *         c_ctxt.myDoc = NULL
 * 
 */
      xmlFreeDoc(__pyx_v_c_ctxt->myDoc);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":593
 *             __GLOBAL_PARSER_CONTEXT.initDocDict(c_ctxt.myDoc)
 *             tree.xmlFreeDoc(c_ctxt.myDoc)
 *         c_ctxt.myDoc = NULL             # <<<<<<<<<<<<<<
 * 
 *     if result is not NULL:
 */
    __pyx_v_c_ctxt->myDoc = NULL;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":595
 *         c_ctxt.myDoc = NULL
 * 
 *     if result is not NULL:             # <<<<<<<<<<<<<<
 *         if context._validator is not None and \
 *                 not context._validator.isvalid():
 */
  __pyx_1 = (__pyx_v_result != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":596
 * 
 *     if result is not NULL:
 *         if context._validator is not None and \             # <<<<<<<<<<<<<<
 *                 not context._validator.isvalid():
 *             well_formed = 0 # actually not 'valid', but anyway ...
 */
    __pyx_1 = (((PyObject *)__pyx_v_context->_validator) != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":597
 *     if result is not NULL:
 *         if context._validator is not None and \
 *                 not context._validator.isvalid():             # <<<<<<<<<<<<<<
 *             well_formed = 0 # actually not 'valid', but anyway ...
 *         elif recover or (c_ctxt.wellFormed and \
 */
      __pyx_1 = (!((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_context->_validator->__pyx_vtab)->isvalid(__pyx_v_context->_validator));
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":598
 *         if context._validator is not None and \
 *                 not context._validator.isvalid():
 *             well_formed = 0 # actually not 'valid', but anyway ...             # <<<<<<<<<<<<<<
 *         elif recover or (c_ctxt.wellFormed and \
 *                              c_ctxt.lastError.level < xmlerror.XML_ERR_ERROR):
 */
      __pyx_v_well_formed = 0;
      goto __pyx_L7;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":599
 *                 not context._validator.isvalid():
 *             well_formed = 0 # actually not 'valid', but anyway ...
 *         elif recover or (c_ctxt.wellFormed and \             # <<<<<<<<<<<<<<
 *                              c_ctxt.lastError.level < xmlerror.XML_ERR_ERROR):
 *             well_formed = 1
 */
    __pyx_1 = __pyx_v_recover;
    if (!__pyx_1) {
      __pyx_1 = __pyx_v_c_ctxt->wellFormed;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":600
 *             well_formed = 0 # actually not 'valid', but anyway ...
 *         elif recover or (c_ctxt.wellFormed and \
 *                              c_ctxt.lastError.level < xmlerror.XML_ERR_ERROR):             # <<<<<<<<<<<<<<
 *             well_formed = 1
 *         elif not c_ctxt.replaceEntities and not c_ctxt.validate \
 */
        __pyx_1 = (__pyx_v_c_ctxt->lastError.level < XML_ERR_ERROR);
      }
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":601
 *         elif recover or (c_ctxt.wellFormed and \
 *                              c_ctxt.lastError.level < xmlerror.XML_ERR_ERROR):
 *             well_formed = 1             # <<<<<<<<<<<<<<
 *         elif not c_ctxt.replaceEntities and not c_ctxt.validate \
 *                  and context is not None:
 */
      __pyx_v_well_formed = 1;
      goto __pyx_L7;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":602
 *                              c_ctxt.lastError.level < xmlerror.XML_ERR_ERROR):
 *             well_formed = 1
 *         elif not c_ctxt.replaceEntities and not c_ctxt.validate \             # <<<<<<<<<<<<<<
 *                  and context is not None:
 *             # in this mode, we ignore errors about undefined entities
 */
    __pyx_1 = (!__pyx_v_c_ctxt->replaceEntities);
    if (__pyx_1) {
      __pyx_1 = (!__pyx_v_c_ctxt->validate);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":603
 *             well_formed = 1
 *         elif not c_ctxt.replaceEntities and not c_ctxt.validate \
 *                  and context is not None:             # <<<<<<<<<<<<<<
 *             # in this mode, we ignore errors about undefined entities
 *             for error in context._error_log.filter_from_errors():
 */
        __pyx_1 = (((PyObject *)__pyx_v_context) != Py_None);
      }
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":605
 *                  and context is not None:
 *             # in this mode, we ignore errors about undefined entities
 *             for error in context._error_log.filter_from_errors():             # <<<<<<<<<<<<<<
 *                 if error.type != ErrorTypes.WAR_UNDECLARED_ENTITY and \
 *                        error.type != ErrorTypes.ERR_UNDECLARED_ENTITY:
 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_context->_error_log), __pyx_kp_filter_from_errors); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
        __pyx_2 = 0; __pyx_3 = __pyx_4; Py_INCREF(__pyx_3);
      } else {
        __pyx_2 = -1; __pyx_3 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_3))) {
          if (__pyx_2 >= PyList_GET_SIZE(__pyx_3)) break;
          __pyx_4 = PyList_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
        } else if (likely(PyTuple_CheckExact(__pyx_3))) {
          if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_3)) break;
          __pyx_4 = PyTuple_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
        } else {
          __pyx_4 = PyIter_Next(__pyx_3);
          if (!__pyx_4) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        Py_DECREF(__pyx_v_error);
        __pyx_v_error = __pyx_4;
        __pyx_4 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":606
 *             # in this mode, we ignore errors about undefined entities
 *             for error in context._error_log.filter_from_errors():
 *                 if error.type != ErrorTypes.WAR_UNDECLARED_ENTITY and \             # <<<<<<<<<<<<<<
 *                        error.type != ErrorTypes.ERR_UNDECLARED_ENTITY:
 *                     well_formed = 0
 */
        __pyx_4 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_type); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorTypes); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_kp_420); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_5 = PyObject_RichCompare(__pyx_4, __pyx_6, Py_NE); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_5); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":607
 *             for error in context._error_log.filter_from_errors():
 *                 if error.type != ErrorTypes.WAR_UNDECLARED_ENTITY and \
 *                        error.type != ErrorTypes.ERR_UNDECLARED_ENTITY:             # <<<<<<<<<<<<<<
 *                     well_formed = 0
 *                     break
 */
          __pyx_4 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_type); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp_ErrorTypes); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_5 = PyObject_GetAttr(__pyx_6, __pyx_kp_421); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __pyx_6 = PyObject_RichCompare(__pyx_4, __pyx_5, Py_NE); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
        }
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":608
 *                 if error.type != ErrorTypes.WAR_UNDECLARED_ENTITY and \
 *                        error.type != ErrorTypes.ERR_UNDECLARED_ENTITY:
 *                     well_formed = 0             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
          __pyx_v_well_formed = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":609
 *                        error.type != ErrorTypes.ERR_UNDECLARED_ENTITY:
 *                     well_formed = 0
 *                     break             # <<<<<<<<<<<<<<
 *             else:
 *                 well_formed = 1
 */
          goto __pyx_L9;
          goto __pyx_L10;
        }
        __pyx_L10:;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":611
 *                     break
 *             else:
 *                 well_formed = 1             # <<<<<<<<<<<<<<
 *         else:
 *             well_formed = 0
 */
        __pyx_v_well_formed = 1;
      }
      __pyx_L9:;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":613
 *                 well_formed = 1
 *         else:
 *             well_formed = 0             # <<<<<<<<<<<<<<
 * 
 *         if not well_formed:
 */
      __pyx_v_well_formed = 0;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":615
 *             well_formed = 0
 * 
 *         if not well_formed:             # <<<<<<<<<<<<<<
 *             # free broken document
 *             tree.xmlFreeDoc(result)
 */
    __pyx_7 = (!__pyx_v_well_formed);
    if (__pyx_7) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":617
 *         if not well_formed:
 *             # free broken document
 *             tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *             result = NULL
 * 
 */
      xmlFreeDoc(__pyx_v_result);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":618
 *             # free broken document
 *             tree.xmlFreeDoc(result)
 *             result = NULL             # <<<<<<<<<<<<<<
 * 
 *     if context is not None and context._has_raised():
 */
      __pyx_v_result = NULL;
      goto __pyx_L11;
    }
    __pyx_L11:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":620
 *             result = NULL
 * 
 *     if context is not None and context._has_raised():             # <<<<<<<<<<<<<<
 *         if result is not NULL:
 *             tree.xmlFreeDoc(result)
 */
  __pyx_1 = (((PyObject *)__pyx_v_context) != Py_None);
  if (__pyx_1) {
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._has_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":621
 * 
 *     if context is not None and context._has_raised():
 *         if result is not NULL:             # <<<<<<<<<<<<<<
 *             tree.xmlFreeDoc(result)
 *             result = NULL
 */
    __pyx_7 = (__pyx_v_result != NULL);
    if (__pyx_7) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":622
 *     if context is not None and context._has_raised():
 *         if result is not NULL:
 *             tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *             result = NULL
 *         context._raise_if_stored()
 */
      xmlFreeDoc(__pyx_v_result);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":623
 *         if result is not NULL:
 *             tree.xmlFreeDoc(result)
 *             result = NULL             # <<<<<<<<<<<<<<
 *         context._raise_if_stored()
 * 
 */
      __pyx_v_result = NULL;
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":624
 *             tree.xmlFreeDoc(result)
 *             result = NULL
 *         context._raise_if_stored()             # <<<<<<<<<<<<<<
 * 
 *     if result is NULL:
 */
    __pyx_8 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raise_if_stored(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context)); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":626
 *         context._raise_if_stored()
 * 
 *     if result is NULL:             # <<<<<<<<<<<<<<
 *         if context is not None:
 *             _raiseParseError(c_ctxt, filename, context._error_log)
 */
  __pyx_1 = (__pyx_v_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":627
 * 
 *     if result is NULL:
 *         if context is not None:             # <<<<<<<<<<<<<<
 *             _raiseParseError(c_ctxt, filename, context._error_log)
 *         else:
 */
    __pyx_7 = (((PyObject *)__pyx_v_context) != Py_None);
    if (__pyx_7) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":628
 *     if result is NULL:
 *         if context is not None:
 *             _raiseParseError(c_ctxt, filename, context._error_log)             # <<<<<<<<<<<<<<
 *         else:
 *             _raiseParseError(c_ctxt, filename, None)
 */
      __pyx_8 = __pyx_f_4lxml_5etree__raiseParseError(__pyx_v_c_ctxt, __pyx_v_filename, __pyx_v_context->_error_log); if (unlikely(__pyx_8 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L15;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":630
 *             _raiseParseError(c_ctxt, filename, context._error_log)
 *         else:
 *             _raiseParseError(c_ctxt, filename, None)             # <<<<<<<<<<<<<<
 *     else:
 *         if result.URL is NULL and filename is not None:
 */
      __pyx_8 = __pyx_f_4lxml_5etree__raiseParseError(__pyx_v_c_ctxt, __pyx_v_filename, ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None)); if (unlikely(__pyx_8 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L15:;
    goto __pyx_L14;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":632
 *             _raiseParseError(c_ctxt, filename, None)
 *     else:
 *         if result.URL is NULL and filename is not None:             # <<<<<<<<<<<<<<
 *             result.URL = tree.xmlStrdup(_cstr(filename))
 *         if result.encoding is NULL:
 */
    __pyx_1 = (__pyx_v_result->URL == NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_filename != Py_None);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":633
 *     else:
 *         if result.URL is NULL and filename is not None:
 *             result.URL = tree.xmlStrdup(_cstr(filename))             # <<<<<<<<<<<<<<
 *         if result.encoding is NULL:
 *             result.encoding = tree.xmlStrdup("UTF-8")
 */
      __pyx_v_result->URL = xmlStrdup(PyString_AS_STRING(__pyx_v_filename));
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":634
 *         if result.URL is NULL and filename is not None:
 *             result.URL = tree.xmlStrdup(_cstr(filename))
 *         if result.encoding is NULL:             # <<<<<<<<<<<<<<
 *             result.encoding = tree.xmlStrdup("UTF-8")
 *     return result
 */
    __pyx_7 = (__pyx_v_result->encoding == NULL);
    if (__pyx_7) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":635
 *             result.URL = tree.xmlStrdup(_cstr(filename))
 *         if result.encoding is NULL:
 *             result.encoding = tree.xmlStrdup("UTF-8")             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
      __pyx_v_result->encoding = xmlStrdup(__pyx_k_422);
      goto __pyx_L17;
    }
    __pyx_L17:;
  }
  __pyx_L14:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":636
 *         if result.encoding is NULL:
 *             result.encoding = tree.xmlStrdup("UTF-8")
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef int _fixHtmlDictNames(tree.xmlDict* c_dict, xmlDoc* c_doc) nogil:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._handleParseResult");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_error);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":638
 *     return result
 * 
 * cdef int _fixHtmlDictNames(tree.xmlDict* c_dict, xmlDoc* c_doc) nogil:             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     if c_doc is NULL:
 */

static  int __pyx_f_4lxml_5etree__fixHtmlDictNames(xmlDict *__pyx_v_c_dict, xmlDoc *__pyx_v_c_doc) {
  xmlNode *__pyx_v_c_node;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":640
 * cdef int _fixHtmlDictNames(tree.xmlDict* c_dict, xmlDoc* c_doc) nogil:
 *     cdef xmlNode* c_node
 *     if c_doc is NULL:             # <<<<<<<<<<<<<<
 *         return 0
 *     c_node = c_doc.children
 */
  __pyx_1 = (__pyx_v_c_doc == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":641
 *     cdef xmlNode* c_node
 *     if c_doc is NULL:
 *         return 0             # <<<<<<<<<<<<<<
 *     c_node = c_doc.children
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(<xmlNode*>c_doc, c_node, 0)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":642
 *     if c_doc is NULL:
 *         return 0
 *     c_node = c_doc.children             # <<<<<<<<<<<<<<
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(<xmlNode*>c_doc, c_node, 0)
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 */
  __pyx_v_c_node = __pyx_v_c_doc->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":643
 *         return 0
 *     c_node = c_doc.children
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(<xmlNode*>c_doc, c_node, 0)             # <<<<<<<<<<<<<<
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         if _fixHtmlDictNodeNames(c_dict, c_node) < 0:
 */
  BEGIN_FOR_EACH_ELEMENT_FROM(((xmlNode *)__pyx_v_c_doc), __pyx_v_c_node, 0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":644
 *     c_node = c_doc.children
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(<xmlNode*>c_doc, c_node, 0)
 *     if c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         if _fixHtmlDictNodeNames(c_dict, c_node) < 0:
 *             return -1
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":645
 *     tree.BEGIN_FOR_EACH_ELEMENT_FROM(<xmlNode*>c_doc, c_node, 0)
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         if _fixHtmlDictNodeNames(c_dict, c_node) < 0:             # <<<<<<<<<<<<<<
 *             return -1
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 */
    __pyx_1 = (__pyx_f_4lxml_5etree__fixHtmlDictNodeNames(__pyx_v_c_dict, __pyx_v_c_node) < 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":646
 *     if c_node.type == tree.XML_ELEMENT_NODE:
 *         if _fixHtmlDictNodeNames(c_dict, c_node) < 0:
 *             return -1             # <<<<<<<<<<<<<<
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *     return 0
 */
      __pyx_r = -1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":647
 *         if _fixHtmlDictNodeNames(c_dict, c_node) < 0:
 *             return -1
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  END_FOR_EACH_ELEMENT_FROM(__pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":648
 *             return -1
 *     tree.END_FOR_EACH_ELEMENT_FROM(c_node)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _fixHtmlDictNodeNames(tree.xmlDict* c_dict,
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":650
 *     return 0
 * 
 * cdef inline int _fixHtmlDictNodeNames(tree.xmlDict* c_dict,             # <<<<<<<<<<<<<<
 *                                       xmlNode* c_node) nogil:
 *     cdef xmlNode* c_attr
 */

static INLINE int __pyx_f_4lxml_5etree__fixHtmlDictNodeNames(xmlDict *__pyx_v_c_dict, xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_v_c_attr;
  char *__pyx_v_c_name;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":654
 *     cdef xmlNode* c_attr
 *     cdef char* c_name
 *     c_name = tree.xmlDictLookup(c_dict, c_node.name, -1)             # <<<<<<<<<<<<<<
 *     if c_name is NULL:
 *         return -1
 */
  __pyx_v_c_name = xmlDictLookup(__pyx_v_c_dict, __pyx_v_c_node->name, -1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":655
 *     cdef char* c_name
 *     c_name = tree.xmlDictLookup(c_dict, c_node.name, -1)
 *     if c_name is NULL:             # <<<<<<<<<<<<<<
 *         return -1
 *     if c_name is not c_node.name:
 */
  __pyx_1 = (__pyx_v_c_name == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":656
 *     c_name = tree.xmlDictLookup(c_dict, c_node.name, -1)
 *     if c_name is NULL:
 *         return -1             # <<<<<<<<<<<<<<
 *     if c_name is not c_node.name:
 *         tree.xmlFree(c_node.name)
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":657
 *     if c_name is NULL:
 *         return -1
 *     if c_name is not c_node.name:             # <<<<<<<<<<<<<<
 *         tree.xmlFree(c_node.name)
 *         c_node.name = c_name
 */
  __pyx_1 = (__pyx_v_c_name != __pyx_v_c_node->name);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":658
 *         return -1
 *     if c_name is not c_node.name:
 *         tree.xmlFree(c_node.name)             # <<<<<<<<<<<<<<
 *         c_node.name = c_name
 *     c_attr = <xmlNode*>c_node.properties
 */
    xmlFree(__pyx_v_c_node->name);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":659
 *     if c_name is not c_node.name:
 *         tree.xmlFree(c_node.name)
 *         c_node.name = c_name             # <<<<<<<<<<<<<<
 *     c_attr = <xmlNode*>c_node.properties
 *     while c_attr is not NULL:
 */
    __pyx_v_c_node->name = __pyx_v_c_name;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":660
 *         tree.xmlFree(c_node.name)
 *         c_node.name = c_name
 *     c_attr = <xmlNode*>c_node.properties             # <<<<<<<<<<<<<<
 *     while c_attr is not NULL:
 *         c_name = tree.xmlDictLookup(c_dict, c_attr.name, -1)
 */
  __pyx_v_c_attr = ((xmlNode *)__pyx_v_c_node->properties);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":661
 *         c_node.name = c_name
 *     c_attr = <xmlNode*>c_node.properties
 *     while c_attr is not NULL:             # <<<<<<<<<<<<<<
 *         c_name = tree.xmlDictLookup(c_dict, c_attr.name, -1)
 *         if c_name is NULL:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_attr != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":662
 *     c_attr = <xmlNode*>c_node.properties
 *     while c_attr is not NULL:
 *         c_name = tree.xmlDictLookup(c_dict, c_attr.name, -1)             # <<<<<<<<<<<<<<
 *         if c_name is NULL:
 *             return -1
 */
    __pyx_v_c_name = xmlDictLookup(__pyx_v_c_dict, __pyx_v_c_attr->name, -1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":663
 *     while c_attr is not NULL:
 *         c_name = tree.xmlDictLookup(c_dict, c_attr.name, -1)
 *         if c_name is NULL:             # <<<<<<<<<<<<<<
 *             return -1
 *         if c_name is not c_attr.name:
 */
    __pyx_1 = (__pyx_v_c_name == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":664
 *         c_name = tree.xmlDictLookup(c_dict, c_attr.name, -1)
 *         if c_name is NULL:
 *             return -1             # <<<<<<<<<<<<<<
 *         if c_name is not c_attr.name:
 *             tree.xmlFree(c_attr.name)
 */
      __pyx_r = -1;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":665
 *         if c_name is NULL:
 *             return -1
 *         if c_name is not c_attr.name:             # <<<<<<<<<<<<<<
 *             tree.xmlFree(c_attr.name)
 *             c_attr.name = c_name
 */
    __pyx_1 = (__pyx_v_c_name != __pyx_v_c_attr->name);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":666
 *             return -1
 *         if c_name is not c_attr.name:
 *             tree.xmlFree(c_attr.name)             # <<<<<<<<<<<<<<
 *             c_attr.name = c_name
 *         c_attr = c_attr.next
 */
      xmlFree(__pyx_v_c_attr->name);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":667
 *         if c_name is not c_attr.name:
 *             tree.xmlFree(c_attr.name)
 *             c_attr.name = c_name             # <<<<<<<<<<<<<<
 *         c_attr = c_attr.next
 *     return 0
 */
      __pyx_v_c_attr->name = __pyx_v_c_name;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":668
 *             tree.xmlFree(c_attr.name)
 *             c_attr.name = c_name
 *         c_attr = c_attr.next             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_v_c_attr = __pyx_v_c_attr->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":669
 *             c_attr.name = c_name
 *         c_attr = c_attr.next
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef class _BaseParser:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":686
 *     cdef object _default_encoding
 * 
 *     def __init__(self, int parse_options, bint for_html, XMLSchema schema,             # <<<<<<<<<<<<<<
 *                  remove_comments, remove_pis, strip_cdata, target,
 *                  filename, encoding):
 */

static int __pyx_pf_4lxml_5etree_11_BaseParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_11_BaseParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_parse_options;
  int __pyx_v_for_html;
  struct __pyx_obj_4lxml_5etree_XMLSchema *__pyx_v_schema = 0;
  PyObject *__pyx_v_remove_comments = 0;
  PyObject *__pyx_v_remove_pis = 0;
  PyObject *__pyx_v_strip_cdata = 0;
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_encoding = 0;
  xmlCharEncodingHandler *__pyx_v_enchandler;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_parse_options,&__pyx_kp_for_html,&__pyx_kp_schema,&__pyx_kp_remove_comments,&__pyx_kp_remove_pis,&__pyx_kp_strip_cdata,&__pyx_kp_target,&__pyx_kp_filename,&__pyx_kp_encoding,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_parse_options);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_for_html);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_schema);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_remove_comments);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_kp_remove_pis);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 4); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_kp_strip_cdata);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 5); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_kp_target);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 6); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_kp_filename);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 7); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_kp_encoding);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, 8); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_parse_options = __pyx_PyInt_int(values[0]); if (unlikely((__pyx_v_parse_options == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_for_html = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_for_html == (int)-1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)values[2]);
    __pyx_v_remove_comments = values[3];
    __pyx_v_remove_pis = values[4];
    __pyx_v_strip_cdata = values[5];
    __pyx_v_target = values[6];
    __pyx_v_filename = values[7];
    __pyx_v_encoding = values[8];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_parse_options = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_parse_options == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_for_html = __Pyx_PyObject_IsTrue(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_for_html == (int)-1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_remove_comments = PyTuple_GET_ITEM(__pyx_args, 3);
    __pyx_v_remove_pis = PyTuple_GET_ITEM(__pyx_args, 4);
    __pyx_v_strip_cdata = PyTuple_GET_ITEM(__pyx_args, 5);
    __pyx_v_target = PyTuple_GET_ITEM(__pyx_args, 6);
    __pyx_v_filename = PyTuple_GET_ITEM(__pyx_args, 7);
    __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 8);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._BaseParser.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_encoding);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), __pyx_ptype_4lxml_5etree_XMLSchema, 1, "schema", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":691
 *         cdef tree.xmlCharEncodingHandler* enchandler
 *         cdef int c_encoding
 *         if not isinstance(self, HTMLParser) and \             # <<<<<<<<<<<<<<
 *                 not isinstance(self, XMLParser) and \
 *                 not isinstance(self, iterparse):
 */
  __pyx_2 = PyObject_TypeCheck(__pyx_v_self, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_HTMLParser))); 
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":692
 *         cdef int c_encoding
 *         if not isinstance(self, HTMLParser) and \
 *                 not isinstance(self, XMLParser) and \             # <<<<<<<<<<<<<<
 *                 not isinstance(self, iterparse):
 *             raise TypeError, u"This class cannot be instantiated"
 */
    __pyx_2 = PyObject_TypeCheck(__pyx_v_self, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XMLParser))); 
    __pyx_1 = (!__pyx_2);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":693
 *         if not isinstance(self, HTMLParser) and \
 *                 not isinstance(self, XMLParser) and \
 *                 not isinstance(self, iterparse):             # <<<<<<<<<<<<<<
 *             raise TypeError, u"This class cannot be instantiated"
 * 
 */
      __pyx_2 = PyObject_TypeCheck(__pyx_v_self, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_iterparse))); 
      __pyx_1 = (!__pyx_2);
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":694
 *                 not isinstance(self, XMLParser) and \
 *                 not isinstance(self, iterparse):
 *             raise TypeError, u"This class cannot be instantiated"             # <<<<<<<<<<<<<<
 * 
 *         self._parse_options = parse_options
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_423), 0);
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":696
 *             raise TypeError, u"This class cannot be instantiated"
 * 
 *         self._parse_options = parse_options             # <<<<<<<<<<<<<<
 *         self._filename = filename
 *         self._target = target
 */
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_parse_options = __pyx_v_parse_options;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":697
 * 
 *         self._parse_options = parse_options
 *         self._filename = filename             # <<<<<<<<<<<<<<
 *         self._target = target
 *         self._for_html = for_html
 */
  Py_INCREF(__pyx_v_filename);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_filename);
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_filename = __pyx_v_filename;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":698
 *         self._parse_options = parse_options
 *         self._filename = filename
 *         self._target = target             # <<<<<<<<<<<<<<
 *         self._for_html = for_html
 *         self._remove_comments = remove_comments
 */
  Py_INCREF(__pyx_v_target);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_target);
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_target = __pyx_v_target;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":699
 *         self._filename = filename
 *         self._target = target
 *         self._for_html = for_html             # <<<<<<<<<<<<<<
 *         self._remove_comments = remove_comments
 *         self._remove_pis = remove_pis
 */
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_for_html = __pyx_v_for_html;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":700
 *         self._target = target
 *         self._for_html = for_html
 *         self._remove_comments = remove_comments             # <<<<<<<<<<<<<<
 *         self._remove_pis = remove_pis
 *         self._strip_cdata = strip_cdata
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_remove_comments); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_remove_comments = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":701
 *         self._for_html = for_html
 *         self._remove_comments = remove_comments
 *         self._remove_pis = remove_pis             # <<<<<<<<<<<<<<
 *         self._strip_cdata = strip_cdata
 *         self._schema = schema
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_remove_pis); if (unlikely((__pyx_1 == (int)-1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_remove_pis = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":702
 *         self._remove_comments = remove_comments
 *         self._remove_pis = remove_pis
 *         self._strip_cdata = strip_cdata             # <<<<<<<<<<<<<<
 *         self._schema = schema
 * 
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_strip_cdata); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_strip_cdata = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":703
 *         self._remove_pis = remove_pis
 *         self._strip_cdata = strip_cdata
 *         self._schema = schema             # <<<<<<<<<<<<<<
 * 
 *         self._resolvers = _ResolverRegistry()
 */
  Py_INCREF(((PyObject *)__pyx_v_schema));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_schema));
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_schema = __pyx_v_schema;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":705
 *         self._schema = schema
 * 
 *         self._resolvers = _ResolverRegistry()             # <<<<<<<<<<<<<<
 * 
 *         if encoding is None:
 */
  __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ResolverRegistry)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__ResolverRegistry))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_resolvers));
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_3);
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":707
 *         self._resolvers = _ResolverRegistry()
 * 
 *         if encoding is None:             # <<<<<<<<<<<<<<
 *             self._default_encoding = None
 *         else:
 */
  __pyx_1 = (__pyx_v_encoding == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":708
 * 
 *         if encoding is None:
 *             self._default_encoding = None             # <<<<<<<<<<<<<<
 *         else:
 *             encoding = _utf8(encoding)
 */
    Py_INCREF(Py_None);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_default_encoding);
    ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_default_encoding = Py_None;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":710
 *             self._default_encoding = None
 *         else:
 *             encoding = _utf8(encoding)             # <<<<<<<<<<<<<<
 *             enchandler = tree.xmlFindCharEncodingHandler(_cstr(encoding))
 *             if enchandler is NULL:
 */
    __pyx_3 = __pyx_f_4lxml_5etree__utf8(__pyx_v_encoding); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":711
 *         else:
 *             encoding = _utf8(encoding)
 *             enchandler = tree.xmlFindCharEncodingHandler(_cstr(encoding))             # <<<<<<<<<<<<<<
 *             if enchandler is NULL:
 *                 raise LookupError, u"unknown encoding: '%s'" % encoding
 */
    __pyx_v_enchandler = xmlFindCharEncodingHandler(PyString_AS_STRING(__pyx_v_encoding));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":712
 *             encoding = _utf8(encoding)
 *             enchandler = tree.xmlFindCharEncodingHandler(_cstr(encoding))
 *             if enchandler is NULL:             # <<<<<<<<<<<<<<
 *                 raise LookupError, u"unknown encoding: '%s'" % encoding
 *             tree.xmlCharEncCloseFunc(enchandler)
 */
    __pyx_2 = (__pyx_v_enchandler == NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":713
 *             enchandler = tree.xmlFindCharEncodingHandler(_cstr(encoding))
 *             if enchandler is NULL:
 *                 raise LookupError, u"unknown encoding: '%s'" % encoding             # <<<<<<<<<<<<<<
 *             tree.xmlCharEncCloseFunc(enchandler)
 *             self._default_encoding = encoding
 */
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_424), __pyx_v_encoding); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_builtin_LookupError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":714
 *             if enchandler is NULL:
 *                 raise LookupError, u"unknown encoding: '%s'" % encoding
 *             tree.xmlCharEncCloseFunc(enchandler)             # <<<<<<<<<<<<<<
 *             self._default_encoding = encoding
 * 
 */
    xmlCharEncCloseFunc(__pyx_v_enchandler);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":715
 *                 raise LookupError, u"unknown encoding: '%s'" % encoding
 *             tree.xmlCharEncCloseFunc(enchandler)
 *             self._default_encoding = encoding             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext _getParserContext(self):
 */
    Py_INCREF(__pyx_v_encoding);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_default_encoding);
    ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_default_encoding = __pyx_v_encoding;
  }
  __pyx_L7:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._BaseParser.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":717
 *             self._default_encoding = encoding
 * 
 *     cdef _ParserContext _getParserContext(self):             # <<<<<<<<<<<<<<
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         if self._parser_context is None:
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_11_BaseParser__getParserContext(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self) {
  xmlParserCtxt *__pyx_v_pctxt;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":719
 *     cdef _ParserContext _getParserContext(self):
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         if self._parser_context is None:             # <<<<<<<<<<<<<<
 *             self._parser_context = self._createContext(self._target)
 *             if self._schema is not None:
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_parser_context) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":720
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         if self._parser_context is None:
 *             self._parser_context = self._createContext(self._target)             # <<<<<<<<<<<<<<
 *             if self._schema is not None:
 *                 self._parser_context._validator = \
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_createContext(__pyx_v_self, __pyx_v_self->_target)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_self->_parser_context));
    __pyx_v_self->_parser_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":721
 *         if self._parser_context is None:
 *             self._parser_context = self._createContext(self._target)
 *             if self._schema is not None:             # <<<<<<<<<<<<<<
 *                 self._parser_context._validator = \
 *                     self._schema._newSaxValidator()
 */
    __pyx_1 = (((PyObject *)__pyx_v_self->_schema) != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":723
 *             if self._schema is not None:
 *                 self._parser_context._validator = \
 *                     self._schema._newSaxValidator()             # <<<<<<<<<<<<<<
 *             pctxt = self._newParserCtxt()
 *             if pctxt is NULL:
 */
      __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_XMLSchema *)__pyx_v_self->_schema->__pyx_vtab)->_newSaxValidator(__pyx_v_self->_schema)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":722
 *             self._parser_context = self._createContext(self._target)
 *             if self._schema is not None:
 *                 self._parser_context._validator = \             # <<<<<<<<<<<<<<
 *                     self._schema._newSaxValidator()
 *             pctxt = self._newParserCtxt()
 */
      Py_DECREF(((PyObject *)__pyx_v_self->_parser_context->_validator));
      __pyx_v_self->_parser_context->_validator = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_2);
      __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":724
 *                 self._parser_context._validator = \
 *                     self._schema._newSaxValidator()
 *             pctxt = self._newParserCtxt()             # <<<<<<<<<<<<<<
 *             if pctxt is NULL:
 *                 python.PyErr_NoMemory()
 */
    __pyx_v_pctxt = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_newParserCtxt(__pyx_v_self);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":725
 *                     self._schema._newSaxValidator()
 *             pctxt = self._newParserCtxt()
 *             if pctxt is NULL:             # <<<<<<<<<<<<<<
 *                 python.PyErr_NoMemory()
 *             _initParserContext(self._parser_context, self._resolvers, pctxt)
 */
    __pyx_1 = (__pyx_v_pctxt == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":726
 *             pctxt = self._newParserCtxt()
 *             if pctxt is NULL:
 *                 python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *             _initParserContext(self._parser_context, self._resolvers, pctxt)
 *             if self._remove_comments:
 */
      __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":727
 *             if pctxt is NULL:
 *                 python.PyErr_NoMemory()
 *             _initParserContext(self._parser_context, self._resolvers, pctxt)             # <<<<<<<<<<<<<<
 *             if self._remove_comments:
 *                 pctxt.sax.comment = NULL
 */
    __pyx_2 = __pyx_f_4lxml_5etree__initParserContext(__pyx_v_self->_parser_context, __pyx_v_self->_resolvers, __pyx_v_pctxt); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":728
 *                 python.PyErr_NoMemory()
 *             _initParserContext(self._parser_context, self._resolvers, pctxt)
 *             if self._remove_comments:             # <<<<<<<<<<<<<<
 *                 pctxt.sax.comment = NULL
 *             if self._remove_pis:
 */
    __pyx_1 = __pyx_v_self->_remove_comments;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":729
 *             _initParserContext(self._parser_context, self._resolvers, pctxt)
 *             if self._remove_comments:
 *                 pctxt.sax.comment = NULL             # <<<<<<<<<<<<<<
 *             if self._remove_pis:
 *                 pctxt.sax.processingInstruction = NULL
 */
      __pyx_v_pctxt->sax->comment = NULL;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":730
 *             if self._remove_comments:
 *                 pctxt.sax.comment = NULL
 *             if self._remove_pis:             # <<<<<<<<<<<<<<
 *                 pctxt.sax.processingInstruction = NULL
 *             if self._strip_cdata:
 */
    __pyx_1 = __pyx_v_self->_remove_pis;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":731
 *                 pctxt.sax.comment = NULL
 *             if self._remove_pis:
 *                 pctxt.sax.processingInstruction = NULL             # <<<<<<<<<<<<<<
 *             if self._strip_cdata:
 *                 # hard switch-off for CDATA nodes => makes them plain text
 */
      __pyx_v_pctxt->sax->processingInstruction = NULL;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":732
 *             if self._remove_pis:
 *                 pctxt.sax.processingInstruction = NULL
 *             if self._strip_cdata:             # <<<<<<<<<<<<<<
 *                 # hard switch-off for CDATA nodes => makes them plain text
 *                 pctxt.sax.cdataBlock = NULL
 */
    __pyx_1 = __pyx_v_self->_strip_cdata;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":734
 *             if self._strip_cdata:
 *                 # hard switch-off for CDATA nodes => makes them plain text
 *                 pctxt.sax.cdataBlock = NULL             # <<<<<<<<<<<<<<
 *         return self._parser_context
 * 
 */
      __pyx_v_pctxt->sax->cdataBlock = NULL;
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":735
 *                 # hard switch-off for CDATA nodes => makes them plain text
 *                 pctxt.sax.cdataBlock = NULL
 *         return self._parser_context             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext _getPushParserContext(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_parser_context));
  __pyx_r = __pyx_v_self->_parser_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser._getParserContext");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":737
 *         return self._parser_context
 * 
 *     cdef _ParserContext _getPushParserContext(self):             # <<<<<<<<<<<<<<
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         if self._push_parser_context is None:
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_11_BaseParser__getPushParserContext(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self) {
  xmlParserCtxt *__pyx_v_pctxt;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":739
 *     cdef _ParserContext _getPushParserContext(self):
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         if self._push_parser_context is None:             # <<<<<<<<<<<<<<
 *             self._push_parser_context = self._createContext(self._target)
 *             if self._schema is not None:
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_push_parser_context) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":740
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         if self._push_parser_context is None:
 *             self._push_parser_context = self._createContext(self._target)             # <<<<<<<<<<<<<<
 *             if self._schema is not None:
 *                 self._push_parser_context._validator = \
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_createContext(__pyx_v_self, __pyx_v_self->_target)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_self->_push_parser_context));
    __pyx_v_self->_push_parser_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":741
 *         if self._push_parser_context is None:
 *             self._push_parser_context = self._createContext(self._target)
 *             if self._schema is not None:             # <<<<<<<<<<<<<<
 *                 self._push_parser_context._validator = \
 *                     self._schema._newSaxValidator()
 */
    __pyx_1 = (((PyObject *)__pyx_v_self->_schema) != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":743
 *             if self._schema is not None:
 *                 self._push_parser_context._validator = \
 *                     self._schema._newSaxValidator()             # <<<<<<<<<<<<<<
 *             pctxt = self._newPushParserCtxt()
 *             if pctxt is NULL:
 */
      __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_XMLSchema *)__pyx_v_self->_schema->__pyx_vtab)->_newSaxValidator(__pyx_v_self->_schema)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":742
 *             self._push_parser_context = self._createContext(self._target)
 *             if self._schema is not None:
 *                 self._push_parser_context._validator = \             # <<<<<<<<<<<<<<
 *                     self._schema._newSaxValidator()
 *             pctxt = self._newPushParserCtxt()
 */
      Py_DECREF(((PyObject *)__pyx_v_self->_push_parser_context->_validator));
      __pyx_v_self->_push_parser_context->_validator = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_2);
      __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":744
 *                 self._push_parser_context._validator = \
 *                     self._schema._newSaxValidator()
 *             pctxt = self._newPushParserCtxt()             # <<<<<<<<<<<<<<
 *             if pctxt is NULL:
 *                 python.PyErr_NoMemory()
 */
    __pyx_v_pctxt = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_newPushParserCtxt(__pyx_v_self);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":745
 *                     self._schema._newSaxValidator()
 *             pctxt = self._newPushParserCtxt()
 *             if pctxt is NULL:             # <<<<<<<<<<<<<<
 *                 python.PyErr_NoMemory()
 *             _initParserContext(
 */
    __pyx_1 = (__pyx_v_pctxt == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":746
 *             pctxt = self._newPushParserCtxt()
 *             if pctxt is NULL:
 *                 python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *             _initParserContext(
 *                 self._push_parser_context, self._resolvers, pctxt)
 */
      __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":748
 *                 python.PyErr_NoMemory()
 *             _initParserContext(
 *                 self._push_parser_context, self._resolvers, pctxt)             # <<<<<<<<<<<<<<
 *             if self._remove_comments:
 *                 pctxt.sax.comment = NULL
 */
    __pyx_2 = __pyx_f_4lxml_5etree__initParserContext(__pyx_v_self->_push_parser_context, __pyx_v_self->_resolvers, __pyx_v_pctxt); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":749
 *             _initParserContext(
 *                 self._push_parser_context, self._resolvers, pctxt)
 *             if self._remove_comments:             # <<<<<<<<<<<<<<
 *                 pctxt.sax.comment = NULL
 *             if self._remove_pis:
 */
    __pyx_1 = __pyx_v_self->_remove_comments;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":750
 *                 self._push_parser_context, self._resolvers, pctxt)
 *             if self._remove_comments:
 *                 pctxt.sax.comment = NULL             # <<<<<<<<<<<<<<
 *             if self._remove_pis:
 *                 pctxt.sax.processingInstruction = NULL
 */
      __pyx_v_pctxt->sax->comment = NULL;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":751
 *             if self._remove_comments:
 *                 pctxt.sax.comment = NULL
 *             if self._remove_pis:             # <<<<<<<<<<<<<<
 *                 pctxt.sax.processingInstruction = NULL
 *             if self._strip_cdata:
 */
    __pyx_1 = __pyx_v_self->_remove_pis;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":752
 *                 pctxt.sax.comment = NULL
 *             if self._remove_pis:
 *                 pctxt.sax.processingInstruction = NULL             # <<<<<<<<<<<<<<
 *             if self._strip_cdata:
 *                 # hard switch-off for CDATA nodes => makes them plain text
 */
      __pyx_v_pctxt->sax->processingInstruction = NULL;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":753
 *             if self._remove_pis:
 *                 pctxt.sax.processingInstruction = NULL
 *             if self._strip_cdata:             # <<<<<<<<<<<<<<
 *                 # hard switch-off for CDATA nodes => makes them plain text
 *                 pctxt.sax.cdataBlock = NULL
 */
    __pyx_1 = __pyx_v_self->_strip_cdata;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":755
 *             if self._strip_cdata:
 *                 # hard switch-off for CDATA nodes => makes them plain text
 *                 pctxt.sax.cdataBlock = NULL             # <<<<<<<<<<<<<<
 *         return self._push_parser_context
 * 
 */
      __pyx_v_pctxt->sax->cdataBlock = NULL;
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":756
 *                 # hard switch-off for CDATA nodes => makes them plain text
 *                 pctxt.sax.cdataBlock = NULL
 *         return self._push_parser_context             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext _createContext(self, target):
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_push_parser_context));
  __pyx_r = __pyx_v_self->_push_parser_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser._getPushParserContext");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":758
 *         return self._push_parser_context
 * 
 *     cdef _ParserContext _createContext(self, target):             # <<<<<<<<<<<<<<
 *         cdef _TargetParserContext context
 *         if target is None:
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_11_BaseParser__createContext(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self, PyObject *__pyx_v_target) {
  struct __pyx_obj_4lxml_5etree__TargetParserContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__TargetParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":760
 *     cdef _ParserContext _createContext(self, target):
 *         cdef _TargetParserContext context
 *         if target is None:             # <<<<<<<<<<<<<<
 *             return _ParserContext()
 *         context = _TargetParserContext()
 */
  __pyx_1 = (__pyx_v_target == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":761
 *         cdef _TargetParserContext context
 *         if target is None:
 *             return _ParserContext()             # <<<<<<<<<<<<<<
 *         context = _TargetParserContext()
 *         context._setTarget(target)
 */
    __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ParserContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ParserContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":762
 *         if target is None:
 *             return _ParserContext()
 *         context = _TargetParserContext()             # <<<<<<<<<<<<<<
 *         context._setTarget(target)
 *         return context
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__TargetParserContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__TargetParserContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__TargetParserContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":763
 *             return _ParserContext()
 *         context = _TargetParserContext()
 *         context._setTarget(target)             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_setTarget(__pyx_v_context, __pyx_v_target); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":764
 *         context = _TargetParserContext()
 *         context._setTarget(target)
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlparser.xmlParserCtxt* _newParserCtxt(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_context);
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser._createContext");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":766
 *         return context
 * 
 *     cdef xmlparser.xmlParserCtxt* _newParserCtxt(self):             # <<<<<<<<<<<<<<
 *         if self._for_html:
 *             return htmlparser.htmlCreateMemoryParserCtxt('dummy', 5)
 */

static  xmlParserCtxt *__pyx_f_4lxml_5etree_11_BaseParser__newParserCtxt(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self) {
  xmlParserCtxt *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":767
 * 
 *     cdef xmlparser.xmlParserCtxt* _newParserCtxt(self):
 *         if self._for_html:             # <<<<<<<<<<<<<<
 *             return htmlparser.htmlCreateMemoryParserCtxt('dummy', 5)
 *         else:
 */
  __pyx_1 = __pyx_v_self->_for_html;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":768
 *     cdef xmlparser.xmlParserCtxt* _newParserCtxt(self):
 *         if self._for_html:
 *             return htmlparser.htmlCreateMemoryParserCtxt('dummy', 5)             # <<<<<<<<<<<<<<
 *         else:
 *             return xmlparser.xmlNewParserCtxt()
 */
    __pyx_r = htmlCreateMemoryParserCtxt(__pyx_k_425, 5);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":770
 *             return htmlparser.htmlCreateMemoryParserCtxt('dummy', 5)
 *         else:
 *             return xmlparser.xmlNewParserCtxt()             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlparser.xmlParserCtxt* _newPushParserCtxt(self):
 */
    __pyx_r = xmlNewParserCtxt();
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":772
 *             return xmlparser.xmlNewParserCtxt()
 * 
 *     cdef xmlparser.xmlParserCtxt* _newPushParserCtxt(self):             # <<<<<<<<<<<<<<
 *         cdef xmlparser.xmlParserCtxt* c_ctxt
 *         cdef char* c_filename
 */

static  xmlParserCtxt *__pyx_f_4lxml_5etree_11_BaseParser__newPushParserCtxt(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self) {
  xmlParserCtxt *__pyx_v_c_ctxt;
  char *__pyx_v_c_filename;
  xmlParserCtxt *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":775
 *         cdef xmlparser.xmlParserCtxt* c_ctxt
 *         cdef char* c_filename
 *         if self._filename is not None:             # <<<<<<<<<<<<<<
 *             c_filename = _cstr(self._filename)
 *         else:
 */
  __pyx_1 = (__pyx_v_self->_filename != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":776
 *         cdef char* c_filename
 *         if self._filename is not None:
 *             c_filename = _cstr(self._filename)             # <<<<<<<<<<<<<<
 *         else:
 *             c_filename = NULL
 */
    __pyx_v_c_filename = PyString_AS_STRING(__pyx_v_self->_filename);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":778
 *             c_filename = _cstr(self._filename)
 *         else:
 *             c_filename = NULL             # <<<<<<<<<<<<<<
 *         if self._for_html:
 *             c_ctxt = htmlparser.htmlCreatePushParserCtxt(
 */
    __pyx_v_c_filename = NULL;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":779
 *         else:
 *             c_filename = NULL
 *         if self._for_html:             # <<<<<<<<<<<<<<
 *             c_ctxt = htmlparser.htmlCreatePushParserCtxt(
 *                 NULL, NULL, NULL, 0, c_filename, tree.XML_CHAR_ENCODING_NONE)
 */
  __pyx_1 = __pyx_v_self->_for_html;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":781
 *         if self._for_html:
 *             c_ctxt = htmlparser.htmlCreatePushParserCtxt(
 *                 NULL, NULL, NULL, 0, c_filename, tree.XML_CHAR_ENCODING_NONE)             # <<<<<<<<<<<<<<
 *             if c_ctxt is not NULL:
 *                 htmlparser.htmlCtxtUseOptions(c_ctxt, self._parse_options)
 */
    __pyx_v_c_ctxt = htmlCreatePushParserCtxt(NULL, NULL, NULL, 0, __pyx_v_c_filename, XML_CHAR_ENCODING_NONE);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":782
 *             c_ctxt = htmlparser.htmlCreatePushParserCtxt(
 *                 NULL, NULL, NULL, 0, c_filename, tree.XML_CHAR_ENCODING_NONE)
 *             if c_ctxt is not NULL:             # <<<<<<<<<<<<<<
 *                 htmlparser.htmlCtxtUseOptions(c_ctxt, self._parse_options)
 *         else:
 */
    __pyx_1 = (__pyx_v_c_ctxt != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":783
 *                 NULL, NULL, NULL, 0, c_filename, tree.XML_CHAR_ENCODING_NONE)
 *             if c_ctxt is not NULL:
 *                 htmlparser.htmlCtxtUseOptions(c_ctxt, self._parse_options)             # <<<<<<<<<<<<<<
 *         else:
 *             c_ctxt = xmlparser.xmlCreatePushParserCtxt(
 */
      htmlCtxtUseOptions(__pyx_v_c_ctxt, __pyx_v_self->_parse_options);
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":786
 *         else:
 *             c_ctxt = xmlparser.xmlCreatePushParserCtxt(
 *                 NULL, NULL, NULL, 0, c_filename)             # <<<<<<<<<<<<<<
 *             if c_ctxt is not NULL:
 *                 xmlparser.xmlCtxtUseOptions(c_ctxt, self._parse_options)
 */
    __pyx_v_c_ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, __pyx_v_c_filename);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":787
 *             c_ctxt = xmlparser.xmlCreatePushParserCtxt(
 *                 NULL, NULL, NULL, 0, c_filename)
 *             if c_ctxt is not NULL:             # <<<<<<<<<<<<<<
 *                 xmlparser.xmlCtxtUseOptions(c_ctxt, self._parse_options)
 *         return c_ctxt
 */
    __pyx_1 = (__pyx_v_c_ctxt != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":788
 *                 NULL, NULL, NULL, 0, c_filename)
 *             if c_ctxt is not NULL:
 *                 xmlparser.xmlCtxtUseOptions(c_ctxt, self._parse_options)             # <<<<<<<<<<<<<<
 *         return c_ctxt
 * 
 */
      xmlCtxtUseOptions(__pyx_v_c_ctxt, __pyx_v_self->_parse_options);
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":789
 *             if c_ctxt is not NULL:
 *                 xmlparser.xmlCtxtUseOptions(c_ctxt, self._parse_options)
 *         return c_ctxt             # <<<<<<<<<<<<<<
 * 
 *     property error_log:
 */
  __pyx_r = __pyx_v_c_ctxt;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":794
 *         u"""The error log of the last parser run.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _ParserContext context
 *             context = self._getParserContext()
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_9error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_9error_log___get__(PyObject *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":796
 *         def __get__(self):
 *             cdef _ParserContext context
 *             context = self._getParserContext()             # <<<<<<<<<<<<<<
 *             return context._error_log.copy()
 * 
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->__pyx_vtab)->_getParserContext(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":797
 *             cdef _ParserContext context
 *             context = self._getParserContext()
 *             return context._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 *     property resolvers:
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_context->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser.error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":801
 *     property resolvers:
 *         u"The custom resolver registry of this parser."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._resolvers
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_9resolvers___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_9resolvers___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":802
 *         u"The custom resolver registry of this parser."
 *         def __get__(self):
 *             return self._resolvers             # <<<<<<<<<<<<<<
 * 
 *     property version:
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_resolvers));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_resolvers);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":806
 *     property version:
 *         u"The version of the underlying XML parser."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return u"libxml2 %d.%d.%d" % LIBXML_VERSION
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_7version___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_7version___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_t_1 = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":807
 *         u"The version of the underlying XML parser."
 *         def __get__(self):
 *             return u"libxml2 %d.%d.%d" % LIBXML_VERSION             # <<<<<<<<<<<<<<
 * 
 *     def setElementClassLookup(self, ElementClassLookup lookup = None):
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_LIBXML_VERSION); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_426), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._BaseParser.version.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":809
 *             return u"libxml2 %d.%d.%d" % LIBXML_VERSION
 * 
 *     def setElementClassLookup(self, ElementClassLookup lookup = None):             # <<<<<<<<<<<<<<
 *         u":deprecated: use ``parser.set_element_class_lookup(lookup)`` instead."
 *         self.set_element_class_lookup(lookup)
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_setElementClassLookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_11_BaseParser_setElementClassLookup[] = ":deprecated: use ``parser.set_element_class_lookup(lookup)`` instead.";
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_setElementClassLookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElementClassLookup *__pyx_v_lookup = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_lookup,0};
  __pyx_v_lookup = ((struct LxmlElementClassLookup *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setElementClassLookup") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_lookup = ((struct LxmlElementClassLookup *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_lookup = ((struct LxmlElementClassLookup *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("setElementClassLookup", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._BaseParser.setElementClassLookup");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lookup), __pyx_ptype_4lxml_5etree_ElementClassLookup, 1, "lookup", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":811
 *     def setElementClassLookup(self, ElementClassLookup lookup = None):
 *         u":deprecated: use ``parser.set_element_class_lookup(lookup)`` instead."
 *         self.set_element_class_lookup(lookup)             # <<<<<<<<<<<<<<
 * 
 *     def set_element_class_lookup(self, ElementClassLookup lookup = None):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_28); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_lookup));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_lookup));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._BaseParser.setElementClassLookup");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":813
 *         self.set_element_class_lookup(lookup)
 * 
 *     def set_element_class_lookup(self, ElementClassLookup lookup = None):             # <<<<<<<<<<<<<<
 *         u"""set_element_class_lookup(self, lookup = None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_set_element_class_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_11_BaseParser_set_element_class_lookup[] = "set_element_class_lookup(self, lookup = None)\n\n        Set a lookup scheme for element classes generated from this parser.\n\n        Reset it by passing None or nothing.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_set_element_class_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElementClassLookup *__pyx_v_lookup = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_lookup,0};
  __pyx_v_lookup = ((struct LxmlElementClassLookup *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_element_class_lookup") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_lookup = ((struct LxmlElementClassLookup *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_lookup = ((struct LxmlElementClassLookup *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_element_class_lookup", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._BaseParser.set_element_class_lookup");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lookup), __pyx_ptype_4lxml_5etree_ElementClassLookup, 1, "lookup", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":820
 *         Reset it by passing None or nothing.
 *         """
 *         self._class_lookup = lookup             # <<<<<<<<<<<<<<
 * 
 *     cdef _BaseParser _copy(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_lookup));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_class_lookup));
  ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->_class_lookup = __pyx_v_lookup;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._BaseParser.set_element_class_lookup");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":822
 *         self._class_lookup = lookup
 * 
 *     cdef _BaseParser _copy(self):             # <<<<<<<<<<<<<<
 *         u"Create a new parser with the same configuration."
 *         cdef _BaseParser parser
 */

static  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_f_4lxml_5etree_11_BaseParser__copy(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser;
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":825
 *         u"Create a new parser with the same configuration."
 *         cdef _BaseParser parser
 *         parser = self.__class__()             # <<<<<<<<<<<<<<
 *         parser._parse_options = self._parse_options
 *         parser._for_html = self._for_html
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp___class__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__BaseParser))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_parser));
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":826
 *         cdef _BaseParser parser
 *         parser = self.__class__()
 *         parser._parse_options = self._parse_options             # <<<<<<<<<<<<<<
 *         parser._for_html = self._for_html
 *         parser._remove_comments = self._remove_comments
 */
  __pyx_v_parser->_parse_options = __pyx_v_self->_parse_options;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":827
 *         parser = self.__class__()
 *         parser._parse_options = self._parse_options
 *         parser._for_html = self._for_html             # <<<<<<<<<<<<<<
 *         parser._remove_comments = self._remove_comments
 *         parser._remove_pis = self._remove_pis
 */
  __pyx_v_parser->_for_html = __pyx_v_self->_for_html;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":828
 *         parser._parse_options = self._parse_options
 *         parser._for_html = self._for_html
 *         parser._remove_comments = self._remove_comments             # <<<<<<<<<<<<<<
 *         parser._remove_pis = self._remove_pis
 *         parser._strip_cdata = self._strip_cdata
 */
  __pyx_v_parser->_remove_comments = __pyx_v_self->_remove_comments;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":829
 *         parser._for_html = self._for_html
 *         parser._remove_comments = self._remove_comments
 *         parser._remove_pis = self._remove_pis             # <<<<<<<<<<<<<<
 *         parser._strip_cdata = self._strip_cdata
 *         parser._filename = self._filename
 */
  __pyx_v_parser->_remove_pis = __pyx_v_self->_remove_pis;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":830
 *         parser._remove_comments = self._remove_comments
 *         parser._remove_pis = self._remove_pis
 *         parser._strip_cdata = self._strip_cdata             # <<<<<<<<<<<<<<
 *         parser._filename = self._filename
 *         parser._resolvers = self._resolvers
 */
  __pyx_v_parser->_strip_cdata = __pyx_v_self->_strip_cdata;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":831
 *         parser._remove_pis = self._remove_pis
 *         parser._strip_cdata = self._strip_cdata
 *         parser._filename = self._filename             # <<<<<<<<<<<<<<
 *         parser._resolvers = self._resolvers
 *         parser._target = self._target
 */
  Py_INCREF(__pyx_v_self->_filename);
  Py_DECREF(__pyx_v_parser->_filename);
  __pyx_v_parser->_filename = __pyx_v_self->_filename;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":832
 *         parser._strip_cdata = self._strip_cdata
 *         parser._filename = self._filename
 *         parser._resolvers = self._resolvers             # <<<<<<<<<<<<<<
 *         parser._target = self._target
 *         parser._class_lookup  = self._class_lookup
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_resolvers));
  Py_DECREF(((PyObject *)__pyx_v_parser->_resolvers));
  __pyx_v_parser->_resolvers = __pyx_v_self->_resolvers;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":833
 *         parser._filename = self._filename
 *         parser._resolvers = self._resolvers
 *         parser._target = self._target             # <<<<<<<<<<<<<<
 *         parser._class_lookup  = self._class_lookup
 *         return parser
 */
  Py_INCREF(__pyx_v_self->_target);
  Py_DECREF(__pyx_v_parser->_target);
  __pyx_v_parser->_target = __pyx_v_self->_target;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":834
 *         parser._resolvers = self._resolvers
 *         parser._target = self._target
 *         parser._class_lookup  = self._class_lookup             # <<<<<<<<<<<<<<
 *         return parser
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_class_lookup));
  Py_DECREF(((PyObject *)__pyx_v_parser->_class_lookup));
  __pyx_v_parser->_class_lookup = __pyx_v_self->_class_lookup;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":835
 *         parser._target = self._target
 *         parser._class_lookup  = self._class_lookup
 *         return parser             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_parser));
  __pyx_r = __pyx_v_parser;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":837
 *         return parser
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         u"""copy(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_11_BaseParser_copy[] = "copy(self)\n\n        Create a new parser with the same configuration.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":842
 *         Create a new parser with the same configuration.
 *         """
 *         return self._copy()             # <<<<<<<<<<<<<<
 * 
 *     def makeelement(self, _tag, attrib=None, nsmap=None, **_extra):
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self)->__pyx_vtab)->_copy(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._BaseParser.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":844
 *         return self._copy()
 * 
 *     def makeelement(self, _tag, attrib=None, nsmap=None, **_extra):             # <<<<<<<<<<<<<<
 *         u"""makeelement(self, _tag, attrib=None, nsmap=None, **_extra)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_makeelement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_11_BaseParser_makeelement[] = "makeelement(self, _tag, attrib=None, nsmap=None, **_extra)\n\n        Creates a new element associated with this parser.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11_BaseParser_makeelement(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__tag = 0;
  PyObject *__pyx_v_attrib = 0;
  PyObject *__pyx_v_nsmap = 0;
  PyObject *__pyx_v__extra = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__tag,&__pyx_kp_attrib,&__pyx_kp_nsmap,0};
  __pyx_v_attrib = Py_None;
  __pyx_v_nsmap = Py_None;
  __pyx_v__extra = PyDict_New(); if (unlikely(!__pyx_v__extra)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__tag);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__extra, values, PyTuple_GET_SIZE(__pyx_args), "makeelement") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__tag = values[0];
    if (values[1]) {
      __pyx_v_attrib = values[1];
    }
    if (values[2]) {
      __pyx_v_nsmap = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_nsmap = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_attrib = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v__tag = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("makeelement", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__extra);
  __Pyx_AddTraceback("lxml.etree._BaseParser.makeelement");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":850
 *         """
 *         return _makeElement(_tag, NULL, None, self, None, None,
 *                             attrib, nsmap, _extra)             # <<<<<<<<<<<<<<
 * 
 *     # internal parser methods
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__makeElement(__pyx_v__tag, NULL, ((struct LxmlDocument *)Py_None), ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self), Py_None, Py_None, __pyx_v_attrib, __pyx_v_nsmap, __pyx_v__extra)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._BaseParser.makeelement");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__extra);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":854
 *     # internal parser methods
 * 
 *     cdef xmlDoc* _parseUnicodeDoc(self, utext, char* c_filename) except NULL:             # <<<<<<<<<<<<<<
 *         u"""Parse unicode document, share dictionary if possible.
 *         """
 */

static  xmlDoc *__pyx_f_4lxml_5etree_11_BaseParser__parseUnicodeDoc(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self, PyObject *__pyx_v_utext, char *__pyx_v_c_filename) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  xmlDoc *__pyx_v_result;
  xmlParserCtxt *__pyx_v_pctxt;
  Py_ssize_t __pyx_v_py_buffer_len;
  int __pyx_v_buffer_len;
  char *__pyx_v_c_text;
  PyObject *__pyx_v_text_utf;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  xmlDoc *__pyx_3;
  int __pyx_4;
  xmlDoc *__pyx_5;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_text_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":863
 *         cdef int buffer_len
 *         cdef char* c_text
 *         py_buffer_len = python.PyUnicode_GET_DATA_SIZE(utext)             # <<<<<<<<<<<<<<
 *         if py_buffer_len > python.INT_MAX or _UNICODE_ENCODING is NULL:
 *             text_utf = python.PyUnicode_AsUTF8String(utext)
 */
  __pyx_v_py_buffer_len = PyUnicode_GET_DATA_SIZE(__pyx_v_utext);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":864
 *         cdef char* c_text
 *         py_buffer_len = python.PyUnicode_GET_DATA_SIZE(utext)
 *         if py_buffer_len > python.INT_MAX or _UNICODE_ENCODING is NULL:             # <<<<<<<<<<<<<<
 *             text_utf = python.PyUnicode_AsUTF8String(utext)
 *             py_buffer_len = python.PyString_GET_SIZE(text_utf)
 */
  __pyx_1 = (__pyx_v_py_buffer_len > INT_MAX);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_4lxml_5etree__UNICODE_ENCODING == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":865
 *         py_buffer_len = python.PyUnicode_GET_DATA_SIZE(utext)
 *         if py_buffer_len > python.INT_MAX or _UNICODE_ENCODING is NULL:
 *             text_utf = python.PyUnicode_AsUTF8String(utext)             # <<<<<<<<<<<<<<
 *             py_buffer_len = python.PyString_GET_SIZE(text_utf)
 *             return self._parseDoc(_cstr(text_utf), py_buffer_len, c_filename)
 */
    __pyx_2 = PyUnicode_AsUTF8String(__pyx_v_utext); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_text_utf);
    __pyx_v_text_utf = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":866
 *         if py_buffer_len > python.INT_MAX or _UNICODE_ENCODING is NULL:
 *             text_utf = python.PyUnicode_AsUTF8String(utext)
 *             py_buffer_len = python.PyString_GET_SIZE(text_utf)             # <<<<<<<<<<<<<<
 *             return self._parseDoc(_cstr(text_utf), py_buffer_len, c_filename)
 *         buffer_len = py_buffer_len
 */
    __pyx_v_py_buffer_len = PyString_GET_SIZE(__pyx_v_text_utf);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":867
 *             text_utf = python.PyUnicode_AsUTF8String(utext)
 *             py_buffer_len = python.PyString_GET_SIZE(text_utf)
 *             return self._parseDoc(_cstr(text_utf), py_buffer_len, c_filename)             # <<<<<<<<<<<<<<
 *         buffer_len = py_buffer_len
 * 
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_parseDoc(__pyx_v_self, PyString_AS_STRING(__pyx_v_text_utf), __pyx_v_py_buffer_len, __pyx_v_c_filename); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":868
 *             py_buffer_len = python.PyString_GET_SIZE(text_utf)
 *             return self._parseDoc(_cstr(text_utf), py_buffer_len, c_filename)
 *         buffer_len = py_buffer_len             # <<<<<<<<<<<<<<
 * 
 *         context = self._getParserContext()
 */
  __pyx_v_buffer_len = __pyx_v_py_buffer_len;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":870
 *         buffer_len = py_buffer_len
 * 
 *         context = self._getParserContext()             # <<<<<<<<<<<<<<
 *         context.prepare()
 *         try:
 */
  __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_getParserContext(__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":871
 * 
 *         context = self._getParserContext()
 *         context.prepare()             # <<<<<<<<<<<<<<
 *         try:
 *             pctxt = context._c_ctxt
 */
  __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->prepare(__pyx_v_context); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":872
 *         context = self._getParserContext()
 *         context.prepare()
 *         try:             # <<<<<<<<<<<<<<
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":873
 *         context.prepare()
 *         try:
 *             pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 */
    __pyx_v_pctxt = __pyx_v_context->_c_ctxt;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":874
 *         try:
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)             # <<<<<<<<<<<<<<
 * 
 *             c_text = python.PyUnicode_AS_DATA(utext)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_pctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":876
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 *             c_text = python.PyUnicode_AS_DATA(utext)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 if self._for_html:
 */
    __pyx_v_c_text = PyUnicode_AS_DATA(__pyx_v_utext);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":877
 * 
 *             c_text = python.PyUnicode_AS_DATA(utext)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 if self._for_html:
 *                     result = htmlparser.htmlCtxtReadMemory(
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":878
 *             c_text = python.PyUnicode_AS_DATA(utext)
 *             with nogil:
 *                 if self._for_html:             # <<<<<<<<<<<<<<
 *                     result = htmlparser.htmlCtxtReadMemory(
 *                         pctxt, c_text, buffer_len, c_filename, _UNICODE_ENCODING,
 */
        __pyx_1 = __pyx_v_self->_for_html;
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":881
 *                     result = htmlparser.htmlCtxtReadMemory(
 *                         pctxt, c_text, buffer_len, c_filename, _UNICODE_ENCODING,
 *                         self._parse_options)             # <<<<<<<<<<<<<<
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 */
          __pyx_v_result = htmlCtxtReadMemory(__pyx_v_pctxt, __pyx_v_c_text, __pyx_v_buffer_len, __pyx_v_c_filename, __pyx_v_4lxml_5etree__UNICODE_ENCODING, __pyx_v_self->_parse_options);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":882
 *                         pctxt, c_text, buffer_len, c_filename, _UNICODE_ENCODING,
 *                         self._parse_options)
 *                     if result is not NULL:             # <<<<<<<<<<<<<<
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)
 */
          __pyx_1 = (__pyx_v_result != NULL);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":883
 *                         self._parse_options)
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:             # <<<<<<<<<<<<<<
 *                             tree.xmlFreeDoc(result)
 *                             result = NULL
 */
            __pyx_1 = (__pyx_f_4lxml_5etree__fixHtmlDictNames(__pyx_v_pctxt->dict, __pyx_v_result) < 0);
            if (__pyx_1) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":884
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *                             result = NULL
 *                 else:
 */
              xmlFreeDoc(__pyx_v_result);

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":885
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)
 *                             result = NULL             # <<<<<<<<<<<<<<
 *                 else:
 *                     result = xmlparser.xmlCtxtReadMemory(
 */
              __pyx_v_result = NULL;
              goto __pyx_L12;
            }
            __pyx_L12:;
            goto __pyx_L11;
          }
          __pyx_L11:;
          goto __pyx_L10;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":889
 *                     result = xmlparser.xmlCtxtReadMemory(
 *                         pctxt, c_text, buffer_len, c_filename, _UNICODE_ENCODING,
 *                         self._parse_options)             # <<<<<<<<<<<<<<
 * 
 *             return context._handleParseResultDoc(self, result, None)
 */
          __pyx_v_result = xmlCtxtReadMemory(__pyx_v_pctxt, __pyx_v_c_text, __pyx_v_buffer_len, __pyx_v_c_filename, __pyx_v_4lxml_5etree__UNICODE_ENCODING, __pyx_v_self->_parse_options);
        }
        __pyx_L10:;
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":891
 *                         self._parse_options)
 * 
 *             return context._handleParseResultDoc(self, result, None)             # <<<<<<<<<<<<<<
 *         finally:
 *             context.cleanup()
 */
    __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_handleParseResultDoc(__pyx_v_context, __pyx_v_self, __pyx_v_result, Py_None); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L5;}
    __pyx_r = __pyx_5;
    goto __pyx_L4;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L6;
    __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L6;
    __pyx_L5: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":893
 *             return context._handleParseResultDoc(self, result, None)
 *         finally:
 *             context.cleanup()             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _parseDoc(self, char* c_text, Py_ssize_t c_len,
 */
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->cleanup(__pyx_v_context); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    goto __pyx_L14;
    __pyx_L13_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L14:;
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser._parseUnicodeDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_text_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":895
 *             context.cleanup()
 * 
 *     cdef xmlDoc* _parseDoc(self, char* c_text, Py_ssize_t c_len,             # <<<<<<<<<<<<<<
 *                            char* c_filename) except NULL:
 *         u"""Parse document, share dictionary if possible.
 */

static  xmlDoc *__pyx_f_4lxml_5etree_11_BaseParser__parseDoc(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self, char *__pyx_v_c_text, Py_ssize_t __pyx_v_c_len, char *__pyx_v_c_filename) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  xmlDoc *__pyx_v_result;
  xmlParserCtxt *__pyx_v_pctxt;
  char *__pyx_v_c_encoding;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  xmlDoc *__pyx_4;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":903
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         cdef char* c_encoding
 *         if c_len > python.INT_MAX:             # <<<<<<<<<<<<<<
 *             raise ParserError, u"string is too long to parse it with libxml2"
 * 
 */
  __pyx_1 = (__pyx_v_c_len > INT_MAX);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":904
 *         cdef char* c_encoding
 *         if c_len > python.INT_MAX:
 *             raise ParserError, u"string is too long to parse it with libxml2"             # <<<<<<<<<<<<<<
 * 
 *         context = self._getParserContext()
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ParserError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_427), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":906
 *             raise ParserError, u"string is too long to parse it with libxml2"
 * 
 *         context = self._getParserContext()             # <<<<<<<<<<<<<<
 *         context.prepare()
 *         try:
 */
  __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_getParserContext(__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":907
 * 
 *         context = self._getParserContext()
 *         context.prepare()             # <<<<<<<<<<<<<<
 *         try:
 *             pctxt = context._c_ctxt
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->prepare(__pyx_v_context); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":908
 *         context = self._getParserContext()
 *         context.prepare()
 *         try:             # <<<<<<<<<<<<<<
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":909
 *         context.prepare()
 *         try:
 *             pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 */
    __pyx_v_pctxt = __pyx_v_context->_c_ctxt;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":910
 *         try:
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)             # <<<<<<<<<<<<<<
 * 
 *             if self._default_encoding is None:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_pctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":912
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 *             if self._default_encoding is None:             # <<<<<<<<<<<<<<
 *                 c_encoding = NULL
 *             else:
 */
    __pyx_1 = (__pyx_v_self->_default_encoding == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":913
 * 
 *             if self._default_encoding is None:
 *                 c_encoding = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 c_encoding = _cstr(self._default_encoding)
 */
      __pyx_v_c_encoding = NULL;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":915
 *                 c_encoding = NULL
 *             else:
 *                 c_encoding = _cstr(self._default_encoding)             # <<<<<<<<<<<<<<
 * 
 *             with nogil:
 */
      __pyx_v_c_encoding = PyString_AS_STRING(__pyx_v_self->_default_encoding);
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":917
 *                 c_encoding = _cstr(self._default_encoding)
 * 
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 if self._for_html:
 *                     result = htmlparser.htmlCtxtReadMemory(
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":918
 * 
 *             with nogil:
 *                 if self._for_html:             # <<<<<<<<<<<<<<
 *                     result = htmlparser.htmlCtxtReadMemory(
 *                         pctxt, c_text, c_len, c_filename,
 */
        __pyx_1 = __pyx_v_self->_for_html;
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":921
 *                     result = htmlparser.htmlCtxtReadMemory(
 *                         pctxt, c_text, c_len, c_filename,
 *                         c_encoding, self._parse_options)             # <<<<<<<<<<<<<<
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 */
          __pyx_v_result = htmlCtxtReadMemory(__pyx_v_pctxt, __pyx_v_c_text, __pyx_v_c_len, __pyx_v_c_filename, __pyx_v_c_encoding, __pyx_v_self->_parse_options);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":922
 *                         pctxt, c_text, c_len, c_filename,
 *                         c_encoding, self._parse_options)
 *                     if result is not NULL:             # <<<<<<<<<<<<<<
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)
 */
          __pyx_1 = (__pyx_v_result != NULL);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":923
 *                         c_encoding, self._parse_options)
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:             # <<<<<<<<<<<<<<
 *                             tree.xmlFreeDoc(result)
 *                             result = NULL
 */
            __pyx_1 = (__pyx_f_4lxml_5etree__fixHtmlDictNames(__pyx_v_pctxt->dict, __pyx_v_result) < 0);
            if (__pyx_1) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":924
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *                             result = NULL
 *                 else:
 */
              xmlFreeDoc(__pyx_v_result);

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":925
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)
 *                             result = NULL             # <<<<<<<<<<<<<<
 *                 else:
 *                     result = xmlparser.xmlCtxtReadMemory(
 */
              __pyx_v_result = NULL;
              goto __pyx_L13;
            }
            __pyx_L13:;
            goto __pyx_L12;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":929
 *                     result = xmlparser.xmlCtxtReadMemory(
 *                         pctxt, c_text, c_len, c_filename,
 *                         c_encoding, self._parse_options)             # <<<<<<<<<<<<<<
 * 
 *             return context._handleParseResultDoc(self, result, None)
 */
          __pyx_v_result = xmlCtxtReadMemory(__pyx_v_pctxt, __pyx_v_c_text, __pyx_v_c_len, __pyx_v_c_filename, __pyx_v_c_encoding, __pyx_v_self->_parse_options);
        }
        __pyx_L11:;
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":931
 *                         c_encoding, self._parse_options)
 * 
 *             return context._handleParseResultDoc(self, result, None)             # <<<<<<<<<<<<<<
 *         finally:
 *             context.cleanup()
 */
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_handleParseResultDoc(__pyx_v_context, __pyx_v_self, __pyx_v_result, Py_None); if (unlikely(__pyx_4 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L5;}
    __pyx_r = __pyx_4;
    goto __pyx_L4;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L6;
    __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L6;
    __pyx_L5: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":933
 *             return context._handleParseResultDoc(self, result, None)
 *         finally:
 *             context.cleanup()             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _parseDocFromFile(self, char* c_filename) except NULL:
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->cleanup(__pyx_v_context); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
    goto __pyx_L15;
    __pyx_L14_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L15:;
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseParser._parseDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":935
 *             context.cleanup()
 * 
 *     cdef xmlDoc* _parseDocFromFile(self, char* c_filename) except NULL:             # <<<<<<<<<<<<<<
 *         cdef _ParserContext context
 *         cdef xmlDoc* result
 */

static  xmlDoc *__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFile(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self, char *__pyx_v_c_filename) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  xmlDoc *__pyx_v_result;
  xmlParserCtxt *__pyx_v_pctxt;
  int __pyx_v_orig_options;
  char *__pyx_v_c_encoding;
  xmlDoc *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  xmlDoc *__pyx_4;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":941
 *         cdef int orig_options
 *         cdef char* c_encoding
 *         result = NULL             # <<<<<<<<<<<<<<
 * 
 *         context = self._getParserContext()
 */
  __pyx_v_result = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":943
 *         result = NULL
 * 
 *         context = self._getParserContext()             # <<<<<<<<<<<<<<
 *         context.prepare()
 *         try:
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_getParserContext(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":944
 * 
 *         context = self._getParserContext()
 *         context.prepare()             # <<<<<<<<<<<<<<
 *         try:
 *             pctxt = context._c_ctxt
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->prepare(__pyx_v_context); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":945
 *         context = self._getParserContext()
 *         context.prepare()
 *         try:             # <<<<<<<<<<<<<<
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":946
 *         context.prepare()
 *         try:
 *             pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 */
    __pyx_v_pctxt = __pyx_v_context->_c_ctxt;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":947
 *         try:
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)             # <<<<<<<<<<<<<<
 * 
 *             if self._default_encoding is None:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_pctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":949
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 *             if self._default_encoding is None:             # <<<<<<<<<<<<<<
 *                 c_encoding = NULL
 *             else:
 */
    __pyx_3 = (__pyx_v_self->_default_encoding == Py_None);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":950
 * 
 *             if self._default_encoding is None:
 *                 c_encoding = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 c_encoding = _cstr(self._default_encoding)
 */
      __pyx_v_c_encoding = NULL;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":952
 *                 c_encoding = NULL
 *             else:
 *                 c_encoding = _cstr(self._default_encoding)             # <<<<<<<<<<<<<<
 * 
 *             orig_options = pctxt.options
 */
      __pyx_v_c_encoding = PyString_AS_STRING(__pyx_v_self->_default_encoding);
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":954
 *                 c_encoding = _cstr(self._default_encoding)
 * 
 *             orig_options = pctxt.options             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 if self._for_html:
 */
    __pyx_v_orig_options = __pyx_v_pctxt->options;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":955
 * 
 *             orig_options = pctxt.options
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 if self._for_html:
 *                     result = htmlparser.htmlCtxtReadFile(
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":956
 *             orig_options = pctxt.options
 *             with nogil:
 *                 if self._for_html:             # <<<<<<<<<<<<<<
 *                     result = htmlparser.htmlCtxtReadFile(
 *                         pctxt, c_filename, c_encoding, self._parse_options)
 */
        __pyx_3 = __pyx_v_self->_for_html;
        if (__pyx_3) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":958
 *                 if self._for_html:
 *                     result = htmlparser.htmlCtxtReadFile(
 *                         pctxt, c_filename, c_encoding, self._parse_options)             # <<<<<<<<<<<<<<
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 */
          __pyx_v_result = htmlCtxtReadFile(__pyx_v_pctxt, __pyx_v_c_filename, __pyx_v_c_encoding, __pyx_v_self->_parse_options);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":959
 *                     result = htmlparser.htmlCtxtReadFile(
 *                         pctxt, c_filename, c_encoding, self._parse_options)
 *                     if result is not NULL:             # <<<<<<<<<<<<<<
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)
 */
          __pyx_3 = (__pyx_v_result != NULL);
          if (__pyx_3) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":960
 *                         pctxt, c_filename, c_encoding, self._parse_options)
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:             # <<<<<<<<<<<<<<
 *                             tree.xmlFreeDoc(result)
 *                             result = NULL
 */
            __pyx_3 = (__pyx_f_4lxml_5etree__fixHtmlDictNames(__pyx_v_pctxt->dict, __pyx_v_result) < 0);
            if (__pyx_3) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":961
 *                     if result is not NULL:
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *                             result = NULL
 *                 else:
 */
              xmlFreeDoc(__pyx_v_result);

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":962
 *                         if _fixHtmlDictNames(pctxt.dict, result) < 0:
 *                             tree.xmlFreeDoc(result)
 *                             result = NULL             # <<<<<<<<<<<<<<
 *                 else:
 *                     result = xmlparser.xmlCtxtReadFile(
 */
              __pyx_v_result = NULL;
              goto __pyx_L12;
            }
            __pyx_L12:;
            goto __pyx_L11;
          }
          __pyx_L11:;
          goto __pyx_L10;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":965
 *                 else:
 *                     result = xmlparser.xmlCtxtReadFile(
 *                         pctxt, c_filename, c_encoding, self._parse_options)             # <<<<<<<<<<<<<<
 *             pctxt.options = orig_options # work around libxml2 problem
 * 
 */
          __pyx_v_result = xmlCtxtReadFile(__pyx_v_pctxt, __pyx_v_c_filename, __pyx_v_c_encoding, __pyx_v_self->_parse_options);
        }
        __pyx_L10:;
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":966
 *                     result = xmlparser.xmlCtxtReadFile(
 *                         pctxt, c_filename, c_encoding, self._parse_options)
 *             pctxt.options = orig_options # work around libxml2 problem             # <<<<<<<<<<<<<<
 * 
 *             return context._handleParseResultDoc(self, result, c_filename)
 */
    __pyx_v_pctxt->options = __pyx_v_orig_options;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":968
 *             pctxt.options = orig_options # work around libxml2 problem
 * 
 *             return context._handleParseResultDoc(self, result, c_filename)             # <<<<<<<<<<<<<<
 *         finally:
 *             context.cleanup()
 */
    __pyx_1 = __Pyx_PyBytes_FromString(__pyx_v_c_filename); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L4;}
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_handleParseResultDoc(__pyx_v_context, __pyx_v_self, __pyx_v_result, __pyx_1); if (unlikely(__pyx_4 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L4;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_r = __pyx_4;
    goto __pyx_L3;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":970
 *             return context._handleParseResultDoc(self, result, c_filename)
 *         finally:
 *             context.cleanup()             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _parseDocFromFilelike(self, filelike, filename) except NULL:
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->cleanup(__pyx_v_context); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
    goto __pyx_L14;
    __pyx_L13_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L14:;
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._BaseParser._parseDocFromFile");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":972
 *             context.cleanup()
 * 
 *     cdef xmlDoc* _parseDocFromFilelike(self, filelike, filename) except NULL:             # <<<<<<<<<<<<<<
 *         cdef _ParserContext context
 *         cdef _FileReaderContext file_context
 */

static  xmlDoc *__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFilelike(struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_self, PyObject *__pyx_v_filelike, PyObject *__pyx_v_filename) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_file_context;
  xmlDoc *__pyx_v_result;
  xmlParserCtxt *__pyx_v_pctxt;
  xmlDoc *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  xmlDoc *__pyx_6;
  Py_INCREF(__pyx_v_filename);
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_file_context = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":978
 *         cdef xmlparser.xmlParserCtxt* pctxt
 *         cdef char* c_filename
 *         if not filename:             # <<<<<<<<<<<<<<
 *             filename = None
 * 
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_filename); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":979
 *         cdef char* c_filename
 *         if not filename:
 *             filename = None             # <<<<<<<<<<<<<<
 * 
 *         context = self._getParserContext()
 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_filename);
    __pyx_v_filename = Py_None;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":981
 *             filename = None
 * 
 *         context = self._getParserContext()             # <<<<<<<<<<<<<<
 *         context.prepare()
 *         try:
 */
  __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)__pyx_v_self->__pyx_vtab)->_getParserContext(__pyx_v_self)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_3);
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":982
 * 
 *         context = self._getParserContext()
 *         context.prepare()             # <<<<<<<<<<<<<<
 *         try:
 *             pctxt = context._c_ctxt
 */
  __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->prepare(__pyx_v_context); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":983
 *         context = self._getParserContext()
 *         context.prepare()
 *         try:             # <<<<<<<<<<<<<<
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":984
 *         context.prepare()
 *         try:
 *             pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 *             file_context = _FileReaderContext(
 */
    __pyx_v_pctxt = __pyx_v_context->_c_ctxt;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":985
 *         try:
 *             pctxt = context._c_ctxt
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)             # <<<<<<<<<<<<<<
 *             file_context = _FileReaderContext(
 *                 filelike, context, filename, self._default_encoding)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_pctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":987
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 *             file_context = _FileReaderContext(
 *                 filelike, context, filename, self._default_encoding)             # <<<<<<<<<<<<<<
 *             result = file_context._readDoc(pctxt, self._parse_options)
 * 
 */
    __pyx_3 = PyTuple_New(4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L5;}
    Py_INCREF(__pyx_v_filelike);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_filelike);
    Py_INCREF(((PyObject *)__pyx_v_context));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_context));
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_filename);
    Py_INCREF(__pyx_v_self->_default_encoding);
    PyTuple_SET_ITEM(__pyx_3, 3, __pyx_v_self->_default_encoding);
    __pyx_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__FileReaderContext)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L5;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_4lxml_5etree__FileReaderContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L5;}
    Py_DECREF(((PyObject *)__pyx_v_file_context));
    __pyx_v_file_context = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_5);
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":988
 *             file_context = _FileReaderContext(
 *                 filelike, context, filename, self._default_encoding)
 *             result = file_context._readDoc(pctxt, self._parse_options)             # <<<<<<<<<<<<<<
 * 
 *             return context._handleParseResultDoc(
 */
    __pyx_v_result = ((struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *)__pyx_v_file_context->__pyx_vtab)->_readDoc(__pyx_v_file_context, __pyx_v_pctxt, __pyx_v_self->_parse_options);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":991
 * 
 *             return context._handleParseResultDoc(
 *                 self, result, filename)             # <<<<<<<<<<<<<<
 *         finally:
 *             context.cleanup()
 */
    __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_handleParseResultDoc(__pyx_v_context, __pyx_v_self, __pyx_v_result, __pyx_v_filename); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L5;}
    __pyx_r = __pyx_6;
    goto __pyx_L4;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L6;
    __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L6;
    __pyx_L5: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_5); __pyx_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":993
 *                 self, result, filename)
 *         finally:
 *             context.cleanup()             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->cleanup(__pyx_v_context); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
    goto __pyx_L8;
    __pyx_L7_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L8:;
    switch (__pyx_why) {
      case 3: goto __pyx_L0;
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._BaseParser._parseDocFromFilelike");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_file_context);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1008
 *         different from what the ``error_log`` property returns.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _ParserContext context
 *             context = self._getPushParserContext()
 */

static PyObject *__pyx_pf_4lxml_5etree_11_FeedParser_14feed_error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_11_FeedParser_14feed_error_log___get__(PyObject *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1010
 *         def __get__(self):
 *             cdef _ParserContext context
 *             context = self._getPushParserContext()             # <<<<<<<<<<<<<<
 *             return context._error_log.copy()
 * 
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__FeedParser *)((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._getPushParserContext(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1011
 *             cdef _ParserContext context
 *             context = self._getPushParserContext()
 *             return context._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 *     def feed(self, data):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_context->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._FeedParser.feed_error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1013
 *             return context._error_log.copy()
 * 
 *     def feed(self, data):             # <<<<<<<<<<<<<<
 *         u"""feed(self, data)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_FeedParser_feed(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
static char __pyx_doc_4lxml_5etree_11_FeedParser_feed[] = "feed(self, data)\n\n        Feeds data to the parser.  The argument should be an 8-bit string\n        buffer containing encoded data, although Unicode is supported as long\n        as both string types are not mixed.\n\n        This is the main entry point to the consumer interface of a\n        parser.  The parser will parse as much of the XML stream as it\n        can on each call.  To finish parsing or to reset the parser,\n        call the ``close()`` method.  Both methods may raise\n        ParseError if errors occur in the input data.  If an error is\n        raised, there is no longer a need to call ``close()``.\n\n        The feed parser interface is independent of the normal parser\n        usage.  You can use the same parser as a feed parser and in\n        the ``parse()`` function concurrently.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11_FeedParser_feed(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_pctxt;
  Py_ssize_t __pyx_v_py_buffer_len;
  char *__pyx_v_c_data;
  char *__pyx_v_c_encoding;
  int __pyx_v_buffer_len;
  int __pyx_v_error;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  char *__pyx_3;
  PyObject *__pyx_4 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1038
 *         cdef int buffer_len
 *         cdef int error
 *         if python.PyString_Check(data):             # <<<<<<<<<<<<<<
 *             if self._default_encoding is None:
 *                 c_encoding = NULL
 */
  __pyx_1 = PyString_Check(__pyx_v_data);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1039
 *         cdef int error
 *         if python.PyString_Check(data):
 *             if self._default_encoding is None:             # <<<<<<<<<<<<<<
 *                 c_encoding = NULL
 *             else:
 */
    __pyx_2 = (((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._default_encoding == Py_None);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1040
 *         if python.PyString_Check(data):
 *             if self._default_encoding is None:
 *                 c_encoding = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 c_encoding = self._default_encoding
 */
      __pyx_v_c_encoding = NULL;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1042
 *                 c_encoding = NULL
 *             else:
 *                 c_encoding = self._default_encoding             # <<<<<<<<<<<<<<
 *             c_data = _cstr(data)
 *             py_buffer_len = python.PyString_GET_SIZE(data)
 */
      __pyx_3 = __Pyx_PyBytes_AsString(((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._default_encoding); if (unlikely((!__pyx_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_c_encoding = __pyx_3;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1043
 *             else:
 *                 c_encoding = self._default_encoding
 *             c_data = _cstr(data)             # <<<<<<<<<<<<<<
 *             py_buffer_len = python.PyString_GET_SIZE(data)
 *         elif python.PyUnicode_Check(data):
 */
    __pyx_v_c_data = PyString_AS_STRING(__pyx_v_data);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1044
 *                 c_encoding = self._default_encoding
 *             c_data = _cstr(data)
 *             py_buffer_len = python.PyString_GET_SIZE(data)             # <<<<<<<<<<<<<<
 *         elif python.PyUnicode_Check(data):
 *             if _UNICODE_ENCODING is NULL:
 */
    __pyx_v_py_buffer_len = PyString_GET_SIZE(__pyx_v_data);
    goto __pyx_L5;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1045
 *             c_data = _cstr(data)
 *             py_buffer_len = python.PyString_GET_SIZE(data)
 *         elif python.PyUnicode_Check(data):             # <<<<<<<<<<<<<<
 *             if _UNICODE_ENCODING is NULL:
 *                 raise ParserError, \
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_data);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1046
 *             py_buffer_len = python.PyString_GET_SIZE(data)
 *         elif python.PyUnicode_Check(data):
 *             if _UNICODE_ENCODING is NULL:             # <<<<<<<<<<<<<<
 *                 raise ParserError, \
 *                     u"Unicode parsing is not supported on this platform"
 */
    __pyx_2 = (__pyx_v_4lxml_5etree__UNICODE_ENCODING == NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1047
 *         elif python.PyUnicode_Check(data):
 *             if _UNICODE_ENCODING is NULL:
 *                 raise ParserError, \             # <<<<<<<<<<<<<<
 *                     u"Unicode parsing is not supported on this platform"
 *             c_encoding = _UNICODE_ENCODING
 */
      __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_ParserError); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1048
 *             if _UNICODE_ENCODING is NULL:
 *                 raise ParserError, \
 *                     u"Unicode parsing is not supported on this platform"             # <<<<<<<<<<<<<<
 *             c_encoding = _UNICODE_ENCODING
 *             c_data = python.PyUnicode_AS_DATA(data)
 */
      __Pyx_Raise(__pyx_4, ((PyObject *)__pyx_kp_428), 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1049
 *                 raise ParserError, \
 *                     u"Unicode parsing is not supported on this platform"
 *             c_encoding = _UNICODE_ENCODING             # <<<<<<<<<<<<<<
 *             c_data = python.PyUnicode_AS_DATA(data)
 *             py_buffer_len = python.PyUnicode_GET_DATA_SIZE(data)
 */
    __pyx_v_c_encoding = __pyx_v_4lxml_5etree__UNICODE_ENCODING;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1050
 *                     u"Unicode parsing is not supported on this platform"
 *             c_encoding = _UNICODE_ENCODING
 *             c_data = python.PyUnicode_AS_DATA(data)             # <<<<<<<<<<<<<<
 *             py_buffer_len = python.PyUnicode_GET_DATA_SIZE(data)
 *         else:
 */
    __pyx_v_c_data = PyUnicode_AS_DATA(__pyx_v_data);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1051
 *             c_encoding = _UNICODE_ENCODING
 *             c_data = python.PyUnicode_AS_DATA(data)
 *             py_buffer_len = python.PyUnicode_GET_DATA_SIZE(data)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError, u"Parsing requires string data"
 */
    __pyx_v_py_buffer_len = PyUnicode_GET_DATA_SIZE(__pyx_v_data);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1053
 *             py_buffer_len = python.PyUnicode_GET_DATA_SIZE(data)
 *         else:
 *             raise TypeError, u"Parsing requires string data"             # <<<<<<<<<<<<<<
 * 
 *         context = self._getPushParserContext()
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_429), 0);
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1055
 *             raise TypeError, u"Parsing requires string data"
 * 
 *         context = self._getPushParserContext()             # <<<<<<<<<<<<<<
 *         pctxt = context._c_ctxt
 *         error = 0
 */
  __pyx_4 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__FeedParser *)((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._getPushParserContext(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_4);
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1056
 * 
 *         context = self._getPushParserContext()
 *         pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 *         error = 0
 *         if not self._feed_parser_running:
 */
  __pyx_v_pctxt = __pyx_v_context->_c_ctxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1057
 *         context = self._getPushParserContext()
 *         pctxt = context._c_ctxt
 *         error = 0             # <<<<<<<<<<<<<<
 *         if not self._feed_parser_running:
 *             context.prepare()
 */
  __pyx_v_error = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1058
 *         pctxt = context._c_ctxt
 *         error = 0
 *         if not self._feed_parser_running:             # <<<<<<<<<<<<<<
 *             context.prepare()
 *             self._feed_parser_running = 1
 */
  __pyx_2 = (!((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->_feed_parser_running);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1059
 *         error = 0
 *         if not self._feed_parser_running:
 *             context.prepare()             # <<<<<<<<<<<<<<
 *             self._feed_parser_running = 1
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->prepare(__pyx_v_context); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1060
 *         if not self._feed_parser_running:
 *             context.prepare()
 *             self._feed_parser_running = 1             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 */
    ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->_feed_parser_running = 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1061
 *             context.prepare()
 *             self._feed_parser_running = 1
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)             # <<<<<<<<<<<<<<
 * 
 *             if py_buffer_len > python.INT_MAX:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_pctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1063
 *             __GLOBAL_PARSER_CONTEXT.initParserDict(pctxt)
 * 
 *             if py_buffer_len > python.INT_MAX:             # <<<<<<<<<<<<<<
 *                 buffer_len = python.INT_MAX
 *             else:
 */
    __pyx_2 = (__pyx_v_py_buffer_len > INT_MAX);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1064
 * 
 *             if py_buffer_len > python.INT_MAX:
 *                 buffer_len = python.INT_MAX             # <<<<<<<<<<<<<<
 *             else:
 *                 buffer_len = <int>py_buffer_len
 */
      __pyx_v_buffer_len = INT_MAX;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1066
 *                 buffer_len = python.INT_MAX
 *             else:
 *                 buffer_len = <int>py_buffer_len             # <<<<<<<<<<<<<<
 *             if self._for_html:
 *                 error = _htmlCtxtResetPush(pctxt, c_data, buffer_len,
 */
      __pyx_v_buffer_len = ((int)__pyx_v_py_buffer_len);
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1067
 *             else:
 *                 buffer_len = <int>py_buffer_len
 *             if self._for_html:             # <<<<<<<<<<<<<<
 *                 error = _htmlCtxtResetPush(pctxt, c_data, buffer_len,
 *                                            c_encoding, self._parse_options)
 */
    __pyx_2 = ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._for_html;
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1069
 *             if self._for_html:
 *                 error = _htmlCtxtResetPush(pctxt, c_data, buffer_len,
 *                                            c_encoding, self._parse_options)             # <<<<<<<<<<<<<<
 *             else:
 *                 xmlparser.xmlCtxtUseOptions(pctxt, self._parse_options)
 */
      __pyx_1 = __pyx_f_4lxml_5etree__htmlCtxtResetPush(__pyx_v_pctxt, __pyx_v_c_data, __pyx_v_buffer_len, __pyx_v_c_encoding, ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._parse_options); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_error = __pyx_1;
      goto __pyx_L10;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1071
 *                                            c_encoding, self._parse_options)
 *             else:
 *                 xmlparser.xmlCtxtUseOptions(pctxt, self._parse_options)             # <<<<<<<<<<<<<<
 *                 error = xmlparser.xmlCtxtResetPush(
 *                     pctxt, c_data, buffer_len, NULL, c_encoding)
 */
      xmlCtxtUseOptions(__pyx_v_pctxt, ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._parse_options);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1073
 *                 xmlparser.xmlCtxtUseOptions(pctxt, self._parse_options)
 *                 error = xmlparser.xmlCtxtResetPush(
 *                     pctxt, c_data, buffer_len, NULL, c_encoding)             # <<<<<<<<<<<<<<
 *             py_buffer_len = py_buffer_len - buffer_len
 *             c_data = c_data + buffer_len
 */
      __pyx_v_error = xmlCtxtResetPush(__pyx_v_pctxt, __pyx_v_c_data, __pyx_v_buffer_len, NULL, __pyx_v_c_encoding);
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1074
 *                 error = xmlparser.xmlCtxtResetPush(
 *                     pctxt, c_data, buffer_len, NULL, c_encoding)
 *             py_buffer_len = py_buffer_len - buffer_len             # <<<<<<<<<<<<<<
 *             c_data = c_data + buffer_len
 * 
 */
    __pyx_v_py_buffer_len = (__pyx_v_py_buffer_len - __pyx_v_buffer_len);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1075
 *                     pctxt, c_data, buffer_len, NULL, c_encoding)
 *             py_buffer_len = py_buffer_len - buffer_len
 *             c_data = c_data + buffer_len             # <<<<<<<<<<<<<<
 * 
 *         while error == 0 and py_buffer_len > 0:
 */
    __pyx_v_c_data = (__pyx_v_c_data + __pyx_v_buffer_len);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1077
 *             c_data = c_data + buffer_len
 * 
 *         while error == 0 and py_buffer_len > 0:             # <<<<<<<<<<<<<<
 *             if py_buffer_len > python.INT_MAX:
 *                 buffer_len = python.INT_MAX
 */
  while (1) {
    __pyx_2 = (__pyx_v_error == 0);
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_py_buffer_len > 0);
    }
    if (!__pyx_2) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1078
 * 
 *         while error == 0 and py_buffer_len > 0:
 *             if py_buffer_len > python.INT_MAX:             # <<<<<<<<<<<<<<
 *                 buffer_len = python.INT_MAX
 *             else:
 */
    __pyx_2 = (__pyx_v_py_buffer_len > INT_MAX);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1079
 *         while error == 0 and py_buffer_len > 0:
 *             if py_buffer_len > python.INT_MAX:
 *                 buffer_len = python.INT_MAX             # <<<<<<<<<<<<<<
 *             else:
 *                 buffer_len = <int>py_buffer_len
 */
      __pyx_v_buffer_len = INT_MAX;
      goto __pyx_L13;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1081
 *                 buffer_len = python.INT_MAX
 *             else:
 *                 buffer_len = <int>py_buffer_len             # <<<<<<<<<<<<<<
 *             if self._for_html:
 *                 error = htmlparser.htmlParseChunk(pctxt, c_data, buffer_len, 0)
 */
      __pyx_v_buffer_len = ((int)__pyx_v_py_buffer_len);
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1082
 *             else:
 *                 buffer_len = <int>py_buffer_len
 *             if self._for_html:             # <<<<<<<<<<<<<<
 *                 error = htmlparser.htmlParseChunk(pctxt, c_data, buffer_len, 0)
 *             else:
 */
    __pyx_2 = ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._for_html;
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1083
 *                 buffer_len = <int>py_buffer_len
 *             if self._for_html:
 *                 error = htmlparser.htmlParseChunk(pctxt, c_data, buffer_len, 0)             # <<<<<<<<<<<<<<
 *             else:
 *                 error = xmlparser.xmlParseChunk(pctxt, c_data, buffer_len, 0)
 */
      __pyx_v_error = htmlParseChunk(__pyx_v_pctxt, __pyx_v_c_data, __pyx_v_buffer_len, 0);
      goto __pyx_L14;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1085
 *                 error = htmlparser.htmlParseChunk(pctxt, c_data, buffer_len, 0)
 *             else:
 *                 error = xmlparser.xmlParseChunk(pctxt, c_data, buffer_len, 0)             # <<<<<<<<<<<<<<
 *             py_buffer_len = py_buffer_len - buffer_len
 *             c_data = c_data + buffer_len
 */
      __pyx_v_error = xmlParseChunk(__pyx_v_pctxt, __pyx_v_c_data, __pyx_v_buffer_len, 0);
    }
    __pyx_L14:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1086
 *             else:
 *                 error = xmlparser.xmlParseChunk(pctxt, c_data, buffer_len, 0)
 *             py_buffer_len = py_buffer_len - buffer_len             # <<<<<<<<<<<<<<
 *             c_data = c_data + buffer_len
 * 
 */
    __pyx_v_py_buffer_len = (__pyx_v_py_buffer_len - __pyx_v_buffer_len);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1087
 *                 error = xmlparser.xmlParseChunk(pctxt, c_data, buffer_len, 0)
 *             py_buffer_len = py_buffer_len - buffer_len
 *             c_data = c_data + buffer_len             # <<<<<<<<<<<<<<
 * 
 *         if error or (not pctxt.wellFormed and
 */
    __pyx_v_c_data = (__pyx_v_c_data + __pyx_v_buffer_len);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1089
 *             c_data = c_data + buffer_len
 * 
 *         if error or (not pctxt.wellFormed and             # <<<<<<<<<<<<<<
 *                      not self._parse_options & xmlparser.XML_PARSE_RECOVER):
 *             self._feed_parser_running = 0
 */
  __pyx_2 = __pyx_v_error;
  if (!__pyx_2) {
    __pyx_2 = (!__pyx_v_pctxt->wellFormed);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1090
 * 
 *         if error or (not pctxt.wellFormed and
 *                      not self._parse_options & xmlparser.XML_PARSE_RECOVER):             # <<<<<<<<<<<<<<
 *             self._feed_parser_running = 0
 *             try:
 */
      __pyx_2 = (!(((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._parse_options & XML_PARSE_RECOVER));
    }
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1091
 *         if error or (not pctxt.wellFormed and
 *                      not self._parse_options & xmlparser.XML_PARSE_RECOVER):
 *             self._feed_parser_running = 0             # <<<<<<<<<<<<<<
 *             try:
 *                 context._handleParseResult(self, NULL, None)
 */
    ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->_feed_parser_running = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1092
 *                      not self._parse_options & xmlparser.XML_PARSE_RECOVER):
 *             self._feed_parser_running = 0
 *             try:             # <<<<<<<<<<<<<<
 *                 context._handleParseResult(self, NULL, None)
 *             finally:
 */
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1093
 *             self._feed_parser_running = 0
 *             try:
 *                 context._handleParseResult(self, NULL, None)             # <<<<<<<<<<<<<<
 *             finally:
 *                 context.cleanup()
 */
      __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_handleParseResult(__pyx_v_context, ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self), NULL, Py_None); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L17;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    /*finally:*/ {
      int __pyx_why;
      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
      int __pyx_exc_lineno;
      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 0; goto __pyx_L18;
      __pyx_L17: {
        __pyx_why = 4;
        Py_XDECREF(__pyx_4); __pyx_4 = 0;
        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
        __pyx_exc_lineno = __pyx_lineno;
        goto __pyx_L18;
      }
      __pyx_L18:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1095
 *                 context._handleParseResult(self, NULL, None)
 *             finally:
 *                 context.cleanup()             # <<<<<<<<<<<<<<
 * 
 *     def close(self):
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->cleanup(__pyx_v_context); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L19_error;}
      goto __pyx_L20;
      __pyx_L19_error:;
      if (__pyx_why == 4) {
        Py_XDECREF(__pyx_exc_type);
        Py_XDECREF(__pyx_exc_value);
        Py_XDECREF(__pyx_exc_tb);
      }
      goto __pyx_L1_error;
      __pyx_L20:;
      switch (__pyx_why) {
        case 4: {
          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
          __pyx_lineno = __pyx_exc_lineno;
          __pyx_exc_type = 0;
          __pyx_exc_value = 0;
          __pyx_exc_tb = 0;
          goto __pyx_L1_error;
        }
      }
    }
    goto __pyx_L15;
  }
  __pyx_L15:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._FeedParser.feed");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1097
 *                 context.cleanup()
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         u"""close(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11_FeedParser_close(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_11_FeedParser_close[] = "close(self)\n\n        Terminates feeding data to this parser.  This tells the parser to\n        process any remaining data in the feed buffer, and then returns the\n        root Element of the tree that was parsed.\n\n        This method must be called after passing the last chunk of data into\n        the ``feed()`` method.  It should only be called when using the feed\n        parser interface, all other usage is undefined.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11_FeedParser_close(PyObject *__pyx_v_self, PyObject *unused) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_pctxt;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1112
 *         cdef xmlDoc* c_doc
 *         cdef _Document doc
 *         if not self._feed_parser_running:             # <<<<<<<<<<<<<<
 *             raise XMLSyntaxError(u"no element found",
 *                                  xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)
 */
  __pyx_1 = (!((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->_feed_parser_running);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1113
 *         cdef _Document doc
 *         if not self._feed_parser_running:
 *             raise XMLSyntaxError(u"no element found",             # <<<<<<<<<<<<<<
 *                                  xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)
 * 
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSyntaxError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1114
 *         if not self._feed_parser_running:
 *             raise XMLSyntaxError(u"no element found",
 *                                  xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)             # <<<<<<<<<<<<<<
 * 
 *         context = self._getPushParserContext()
 */
    __pyx_3 = PyInt_FromLong(XML_ERR_INTERNAL_ERROR); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(4); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_430));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_kp_430));
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_int_0);
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_4, 3, __pyx_int_0);
    __pyx_3 = 0;
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1116
 *                                  xmlerror.XML_ERR_INTERNAL_ERROR, 0, 0)
 * 
 *         context = self._getPushParserContext()             # <<<<<<<<<<<<<<
 *         pctxt = context._c_ctxt
 * 
 */
  __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__FeedParser *)((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._getPushParserContext(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1117
 * 
 *         context = self._getPushParserContext()
 *         pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 * 
 *         self._feed_parser_running = 0
 */
  __pyx_v_pctxt = __pyx_v_context->_c_ctxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1119
 *         pctxt = context._c_ctxt
 * 
 *         self._feed_parser_running = 0             # <<<<<<<<<<<<<<
 *         if self._for_html:
 *             htmlparser.htmlParseChunk(pctxt, NULL, 0, 1)
 */
  ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->_feed_parser_running = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1120
 * 
 *         self._feed_parser_running = 0
 *         if self._for_html:             # <<<<<<<<<<<<<<
 *             htmlparser.htmlParseChunk(pctxt, NULL, 0, 1)
 *         else:
 */
  __pyx_1 = ((struct __pyx_obj_4lxml_5etree__FeedParser *)__pyx_v_self)->__pyx_base._for_html;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1121
 *         self._feed_parser_running = 0
 *         if self._for_html:
 *             htmlparser.htmlParseChunk(pctxt, NULL, 0, 1)             # <<<<<<<<<<<<<<
 *         else:
 *             xmlparser.xmlParseChunk(pctxt, NULL, 0, 1)
 */
    htmlParseChunk(__pyx_v_pctxt, NULL, 0, 1);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1123
 *             htmlparser.htmlParseChunk(pctxt, NULL, 0, 1)
 *         else:
 *             xmlparser.xmlParseChunk(pctxt, NULL, 0, 1)             # <<<<<<<<<<<<<<
 *         try:
 *             result = context._handleParseResult(self, pctxt.myDoc, None)
 */
    xmlParseChunk(__pyx_v_pctxt, NULL, 0, 1);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1124
 *         else:
 *             xmlparser.xmlParseChunk(pctxt, NULL, 0, 1)
 *         try:             # <<<<<<<<<<<<<<
 *             result = context._handleParseResult(self, pctxt.myDoc, None)
 *         finally:
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1125
 *             xmlparser.xmlParseChunk(pctxt, NULL, 0, 1)
 *         try:
 *             result = context._handleParseResult(self, pctxt.myDoc, None)             # <<<<<<<<<<<<<<
 *         finally:
 *             context.cleanup()
 */
    __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->_handleParseResult(__pyx_v_context, ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self), __pyx_v_pctxt->myDoc, Py_None); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L8;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_4;
    __pyx_4 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L9;
    __pyx_L8: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1127
 *             result = context._handleParseResult(self, pctxt.myDoc, None)
 *         finally:
 *             context.cleanup()             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(result, _Document):
 */
    __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__ParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->cleanup(__pyx_v_context); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
    goto __pyx_L11;
    __pyx_L10_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L11:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1129
 *             context.cleanup()
 * 
 *         if isinstance(result, _Document):             # <<<<<<<<<<<<<<
 *             return (<_Document>result).getroot()
 *         else:
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_result, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Document))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1130
 * 
 *         if isinstance(result, _Document):
 *             return (<_Document>result).getroot()             # <<<<<<<<<<<<<<
 *         else:
 *             return result
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct LxmlDocument *)__pyx_v_result)->__pyx_vtab)->getroot(((struct LxmlDocument *)__pyx_v_result)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1132
 *             return (<_Document>result).getroot()
 *         else:
 *             return result             # <<<<<<<<<<<<<<
 * 
 * cdef int _htmlCtxtResetPush(xmlparser.xmlParserCtxt* c_ctxt,
 */
    Py_INCREF(__pyx_v_result);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
  }
  __pyx_L12:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._FeedParser.close");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1134
 *             return result
 * 
 * cdef int _htmlCtxtResetPush(xmlparser.xmlParserCtxt* c_ctxt,             # <<<<<<<<<<<<<<
 *                              char* c_data, int buffer_len,
 *                              char* c_encoding, int parse_options) except -1:
 */

static  int __pyx_f_4lxml_5etree__htmlCtxtResetPush(xmlParserCtxt *__pyx_v_c_ctxt, char *__pyx_v_c_data, int __pyx_v_buffer_len, char *__pyx_v_c_encoding, int __pyx_v_parse_options) {
  PyObject *__pyx_v_error;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_error = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1139
 *     cdef xmlparser.xmlParserInput* c_input_stream
 *     # libxml2 crashes if spaceTab is not initialised
 *     if _LIBXML_VERSION_INT < 20629 and c_ctxt.spaceTab is NULL:             # <<<<<<<<<<<<<<
 *         c_ctxt.spaceTab = <int*>tree.xmlMalloc(10 * sizeof(int))
 *         c_ctxt.spaceMax = 10
 */
  __pyx_1 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT < 20629);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_ctxt->spaceTab == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1140
 *     # libxml2 crashes if spaceTab is not initialised
 *     if _LIBXML_VERSION_INT < 20629 and c_ctxt.spaceTab is NULL:
 *         c_ctxt.spaceTab = <int*>tree.xmlMalloc(10 * sizeof(int))             # <<<<<<<<<<<<<<
 *         c_ctxt.spaceMax = 10
 * 
 */
    __pyx_v_c_ctxt->spaceTab = ((int *)xmlMalloc((10 * (sizeof(int)))));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1141
 *     if _LIBXML_VERSION_INT < 20629 and c_ctxt.spaceTab is NULL:
 *         c_ctxt.spaceTab = <int*>tree.xmlMalloc(10 * sizeof(int))
 *         c_ctxt.spaceMax = 10             # <<<<<<<<<<<<<<
 * 
 *     # libxml2 lacks an HTML push parser setup function
 */
    __pyx_v_c_ctxt->spaceMax = 10;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1144
 * 
 *     # libxml2 lacks an HTML push parser setup function
 *     error = xmlparser.xmlCtxtResetPush(c_ctxt, NULL, 0, NULL, c_encoding)             # <<<<<<<<<<<<<<
 *     if error:
 *         return error
 */
  __pyx_2 = PyInt_FromLong(xmlCtxtResetPush(__pyx_v_c_ctxt, NULL, 0, NULL, __pyx_v_c_encoding)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_error);
  __pyx_v_error = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1145
 *     # libxml2 lacks an HTML push parser setup function
 *     error = xmlparser.xmlCtxtResetPush(c_ctxt, NULL, 0, NULL, c_encoding)
 *     if error:             # <<<<<<<<<<<<<<
 *         return error
 * 
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_error); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1146
 *     error = xmlparser.xmlCtxtResetPush(c_ctxt, NULL, 0, NULL, c_encoding)
 *     if error:
 *         return error             # <<<<<<<<<<<<<<
 * 
 *     # fix libxml2 setup for HTML
 */
    __pyx_3 = __pyx_PyInt_int(__pyx_v_error); if (unlikely((__pyx_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1149
 * 
 *     # fix libxml2 setup for HTML
 *     c_ctxt.progressive = 1             # <<<<<<<<<<<<<<
 *     c_ctxt.html = 1
 *     htmlparser.htmlCtxtUseOptions(c_ctxt, parse_options)
 */
  __pyx_v_c_ctxt->progressive = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1150
 *     # fix libxml2 setup for HTML
 *     c_ctxt.progressive = 1
 *     c_ctxt.html = 1             # <<<<<<<<<<<<<<
 *     htmlparser.htmlCtxtUseOptions(c_ctxt, parse_options)
 * 
 */
  __pyx_v_c_ctxt->html = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1151
 *     c_ctxt.progressive = 1
 *     c_ctxt.html = 1
 *     htmlparser.htmlCtxtUseOptions(c_ctxt, parse_options)             # <<<<<<<<<<<<<<
 * 
 *     if c_data is not NULL and buffer_len > 0:
 */
  htmlCtxtUseOptions(__pyx_v_c_ctxt, __pyx_v_parse_options);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1153
 *     htmlparser.htmlCtxtUseOptions(c_ctxt, parse_options)
 * 
 *     if c_data is not NULL and buffer_len > 0:             # <<<<<<<<<<<<<<
 *         return htmlparser.htmlParseChunk(c_ctxt, c_data, buffer_len, 0)
 *     return 0
 */
  __pyx_1 = (__pyx_v_c_data != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_buffer_len > 0);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1154
 * 
 *     if c_data is not NULL and buffer_len > 0:
 *         return htmlparser.htmlParseChunk(c_ctxt, c_data, buffer_len, 0)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_r = htmlParseChunk(__pyx_v_c_ctxt, __pyx_v_c_data, __pyx_v_buffer_len, 0);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1155
 *     if c_data is not NULL and buffer_len > 0:
 *         return htmlparser.htmlParseChunk(c_ctxt, c_data, buffer_len, 0)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._htmlCtxtResetPush");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_error);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1208
 *     apply to the default parser.
 *     """
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,             # <<<<<<<<<<<<<<
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,
 */

static int __pyx_pf_4lxml_5etree_9XMLParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_9XMLParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_attribute_defaults = 0;
  PyObject *__pyx_v_dtd_validation = 0;
  PyObject *__pyx_v_load_dtd = 0;
  PyObject *__pyx_v_no_network = 0;
  PyObject *__pyx_v_ns_clean = 0;
  PyObject *__pyx_v_recover = 0;
  PyObject *__pyx_v_remove_blank_text = 0;
  PyObject *__pyx_v_compact = 0;
  PyObject *__pyx_v_resolve_entities = 0;
  PyObject *__pyx_v_remove_comments = 0;
  PyObject *__pyx_v_remove_pis = 0;
  PyObject *__pyx_v_strip_cdata = 0;
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_encoding = 0;
  struct __pyx_obj_4lxml_5etree_XMLSchema *__pyx_v_schema = 0;
  int __pyx_v_parse_options;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_attribute_defaults,&__pyx_kp_dtd_validation,&__pyx_kp_load_dtd,&__pyx_kp_no_network,&__pyx_kp_ns_clean,&__pyx_kp_recover,&__pyx_kp_remove_blank_text,&__pyx_kp_compact,&__pyx_kp_resolve_entities,&__pyx_kp_remove_comments,&__pyx_kp_remove_pis,&__pyx_kp_strip_cdata,&__pyx_kp_target,&__pyx_kp_encoding,&__pyx_kp_schema,0};
  __pyx_v_attribute_defaults = __pyx_k_113;
  __pyx_v_dtd_validation = __pyx_k_114;
  __pyx_v_load_dtd = __pyx_k_115;
  __pyx_v_no_network = __pyx_k_116;
  __pyx_v_ns_clean = __pyx_k_117;
  __pyx_v_recover = __pyx_k_118;
  __pyx_v_remove_blank_text = __pyx_k_119;
  __pyx_v_compact = __pyx_k_120;
  __pyx_v_resolve_entities = __pyx_k_121;
  __pyx_v_remove_comments = __pyx_k_122;
  __pyx_v_remove_pis = __pyx_k_123;
  __pyx_v_strip_cdata = __pyx_k_124;
  __pyx_v_target = Py_None;
  __pyx_v_encoding = Py_None;
  __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_attribute_defaults = values[0];
    }
    if (values[1]) {
      __pyx_v_dtd_validation = values[1];
    }
    if (values[2]) {
      __pyx_v_load_dtd = values[2];
    }
    if (values[3]) {
      __pyx_v_no_network = values[3];
    }
    if (values[4]) {
      __pyx_v_ns_clean = values[4];
    }
    if (values[5]) {
      __pyx_v_recover = values[5];
    }
    if (values[6]) {
      __pyx_v_remove_blank_text = values[6];
    }
    if (values[7]) {
      __pyx_v_compact = values[7];
    }
    if (values[8]) {
      __pyx_v_resolve_entities = values[8];
    }
    if (values[9]) {
      __pyx_v_remove_comments = values[9];
    }
    if (values[10]) {
      __pyx_v_remove_pis = values[10];
    }
    if (values[11]) {
      __pyx_v_strip_cdata = values[11];
    }
    if (values[12]) {
      __pyx_v_target = values[12];
    }
    if (values[13]) {
      __pyx_v_encoding = values[13];
    }
    if (values[14]) {
      __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)values[14]);
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
    goto __pyx_L5_argtuple_error;
  } else {
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XMLParser.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), __pyx_ptype_4lxml_5etree_XMLSchema, 1, "schema", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1215
 *                  encoding=None, XMLSchema schema=None):
 *         cdef int parse_options
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS             # <<<<<<<<<<<<<<
 *         if load_dtd:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD
 */
  __pyx_v_parse_options = __pyx_v_4lxml_5etree__XML_DEFAULT_PARSE_OPTIONS;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1216
 *         cdef int parse_options
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS
 *         if load_dtd:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD
 *         if dtd_validation:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_load_dtd); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1217
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS
 *         if load_dtd:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD             # <<<<<<<<<<<<<<
 *         if dtd_validation:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | XML_PARSE_DTDLOAD);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1218
 *         if load_dtd:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD
 *         if dtd_validation:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_dtd_validation); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1220
 *         if dtd_validation:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 *                             xmlparser.XML_PARSE_DTDLOAD             # <<<<<<<<<<<<<<
 *         if attribute_defaults:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 */
    __pyx_v_parse_options = ((__pyx_v_parse_options | XML_PARSE_DTDVALID) | XML_PARSE_DTDLOAD);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1221
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 *         if attribute_defaults:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_defaults); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1223
 *         if attribute_defaults:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 *                             xmlparser.XML_PARSE_DTDLOAD             # <<<<<<<<<<<<<<
 *         if ns_clean:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NSCLEAN
 */
    __pyx_v_parse_options = ((__pyx_v_parse_options | XML_PARSE_DTDATTR) | XML_PARSE_DTDLOAD);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1224
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 *         if ns_clean:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_NSCLEAN
 *         if recover:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_ns_clean); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1225
 *                             xmlparser.XML_PARSE_DTDLOAD
 *         if ns_clean:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NSCLEAN             # <<<<<<<<<<<<<<
 *         if recover:
 *             parse_options = parse_options | xmlparser.XML_PARSE_RECOVER
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | XML_PARSE_NSCLEAN);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1226
 *         if ns_clean:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NSCLEAN
 *         if recover:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_RECOVER
 *         if remove_blank_text:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_recover); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1227
 *             parse_options = parse_options | xmlparser.XML_PARSE_NSCLEAN
 *         if recover:
 *             parse_options = parse_options | xmlparser.XML_PARSE_RECOVER             # <<<<<<<<<<<<<<
 *         if remove_blank_text:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | XML_PARSE_RECOVER);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1228
 *         if recover:
 *             parse_options = parse_options | xmlparser.XML_PARSE_RECOVER
 *         if remove_blank_text:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 *         if not no_network:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_remove_blank_text); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1229
 *             parse_options = parse_options | xmlparser.XML_PARSE_RECOVER
 *         if remove_blank_text:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS             # <<<<<<<<<<<<<<
 *         if not no_network:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | XML_PARSE_NOBLANKS);
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1230
 *         if remove_blank_text:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 *         if not no_network:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 *         if not compact:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_no_network); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1231
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 *         if not no_network:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET             # <<<<<<<<<<<<<<
 *         if not compact:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_NONET);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1232
 *         if not no_network:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 *         if not compact:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 *         if not resolve_entities:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_compact); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1233
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 *         if not compact:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT             # <<<<<<<<<<<<<<
 *         if not resolve_entities:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_COMPACT);
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1234
 *         if not compact:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 *         if not resolve_entities:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 *         if not strip_cdata:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_resolve_entities); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1235
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 *         if not resolve_entities:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT             # <<<<<<<<<<<<<<
 *         if not strip_cdata:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_NOENT);
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1236
 *         if not resolve_entities:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 *         if not strip_cdata:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA
 * 
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_strip_cdata); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1237
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 *         if not strip_cdata:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA             # <<<<<<<<<<<<<<
 * 
 *         _BaseParser.__init__(self, parse_options, 0, schema,
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_NOCDATA);
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1239
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA
 * 
 *         _BaseParser.__init__(self, parse_options, 0, schema,             # <<<<<<<<<<<<<<
 *                              remove_comments, remove_pis, strip_cdata,
 *                              target, None, encoding)
 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseParser)), __pyx_kp___init__); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyInt_FromLong(__pyx_v_parse_options); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1241
 *         _BaseParser.__init__(self, parse_options, 0, schema,
 *                              remove_comments, remove_pis, strip_cdata,
 *                              target, None, encoding)             # <<<<<<<<<<<<<<
 * 
 * cdef class ETCompatXMLParser(XMLParser):
 */
  __pyx_5 = PyTuple_New(10); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
  Py_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_int_0);
  Py_INCREF(((PyObject *)__pyx_v_schema));
  PyTuple_SET_ITEM(__pyx_5, 3, ((PyObject *)__pyx_v_schema));
  Py_INCREF(__pyx_v_remove_comments);
  PyTuple_SET_ITEM(__pyx_5, 4, __pyx_v_remove_comments);
  Py_INCREF(__pyx_v_remove_pis);
  PyTuple_SET_ITEM(__pyx_5, 5, __pyx_v_remove_pis);
  Py_INCREF(__pyx_v_strip_cdata);
  PyTuple_SET_ITEM(__pyx_5, 6, __pyx_v_strip_cdata);
  Py_INCREF(__pyx_v_target);
  PyTuple_SET_ITEM(__pyx_5, 7, __pyx_v_target);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_5, 8, Py_None);
  Py_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_5, 9, __pyx_v_encoding);
  __pyx_4 = 0;
  __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.XMLParser.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1252
 *     and thus ignores comments and processing instructions.
 *     """
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,             # <<<<<<<<<<<<<<
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,
 */

static int __pyx_pf_4lxml_5etree_17ETCompatXMLParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_17ETCompatXMLParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_attribute_defaults = 0;
  PyObject *__pyx_v_dtd_validation = 0;
  PyObject *__pyx_v_load_dtd = 0;
  PyObject *__pyx_v_no_network = 0;
  PyObject *__pyx_v_ns_clean = 0;
  PyObject *__pyx_v_recover = 0;
  PyObject *__pyx_v_remove_blank_text = 0;
  PyObject *__pyx_v_compact = 0;
  PyObject *__pyx_v_resolve_entities = 0;
  PyObject *__pyx_v_remove_comments = 0;
  PyObject *__pyx_v_remove_pis = 0;
  PyObject *__pyx_v_strip_cdata = 0;
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_schema = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_attribute_defaults,&__pyx_kp_dtd_validation,&__pyx_kp_load_dtd,&__pyx_kp_no_network,&__pyx_kp_ns_clean,&__pyx_kp_recover,&__pyx_kp_remove_blank_text,&__pyx_kp_compact,&__pyx_kp_resolve_entities,&__pyx_kp_remove_comments,&__pyx_kp_remove_pis,&__pyx_kp_strip_cdata,&__pyx_kp_target,&__pyx_kp_encoding,&__pyx_kp_schema,0};
  __pyx_v_attribute_defaults = __pyx_k_125;
  __pyx_v_dtd_validation = __pyx_k_126;
  __pyx_v_load_dtd = __pyx_k_127;
  __pyx_v_no_network = __pyx_k_128;
  __pyx_v_ns_clean = __pyx_k_129;
  __pyx_v_recover = __pyx_k_130;
  __pyx_v_remove_blank_text = __pyx_k_131;
  __pyx_v_compact = __pyx_k_132;
  __pyx_v_resolve_entities = __pyx_k_133;
  __pyx_v_remove_comments = __pyx_k_134;
  __pyx_v_remove_pis = __pyx_k_135;
  __pyx_v_strip_cdata = __pyx_k_136;
  __pyx_v_target = Py_None;
  __pyx_v_encoding = Py_None;
  __pyx_v_schema = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_attribute_defaults = values[0];
    }
    if (values[1]) {
      __pyx_v_dtd_validation = values[1];
    }
    if (values[2]) {
      __pyx_v_load_dtd = values[2];
    }
    if (values[3]) {
      __pyx_v_no_network = values[3];
    }
    if (values[4]) {
      __pyx_v_ns_clean = values[4];
    }
    if (values[5]) {
      __pyx_v_recover = values[5];
    }
    if (values[6]) {
      __pyx_v_remove_blank_text = values[6];
    }
    if (values[7]) {
      __pyx_v_compact = values[7];
    }
    if (values[8]) {
      __pyx_v_resolve_entities = values[8];
    }
    if (values[9]) {
      __pyx_v_remove_comments = values[9];
    }
    if (values[10]) {
      __pyx_v_remove_pis = values[10];
    }
    if (values[11]) {
      __pyx_v_strip_cdata = values[11];
    }
    if (values[12]) {
      __pyx_v_target = values[12];
    }
    if (values[13]) {
      __pyx_v_encoding = values[13];
    }
    if (values[14]) {
      __pyx_v_schema = values[14];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
    goto __pyx_L5_argtuple_error;
  } else {
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ETCompatXMLParser.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1258
 *                  remove_pis=True, strip_cdata=True, target=None,
 *                  encoding=None, schema=None):
 *         XMLParser.__init__(self,             # <<<<<<<<<<<<<<
 *                            attribute_defaults=attribute_defaults,
 *                            dtd_validation=dtd_validation,
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XMLParser)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1259
 *                  encoding=None, schema=None):
 *         XMLParser.__init__(self,
 *                            attribute_defaults=attribute_defaults,             # <<<<<<<<<<<<<<
 *                            dtd_validation=dtd_validation,
 *                            load_dtd=load_dtd,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_attribute_defaults, __pyx_v_attribute_defaults) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1260
 *         XMLParser.__init__(self,
 *                            attribute_defaults=attribute_defaults,
 *                            dtd_validation=dtd_validation,             # <<<<<<<<<<<<<<
 *                            load_dtd=load_dtd,
 *                            no_network=no_network,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_dtd_validation, __pyx_v_dtd_validation) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1261
 *                            attribute_defaults=attribute_defaults,
 *                            dtd_validation=dtd_validation,
 *                            load_dtd=load_dtd,             # <<<<<<<<<<<<<<
 *                            no_network=no_network,
 *                            ns_clean=ns_clean,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_load_dtd, __pyx_v_load_dtd) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1262
 *                            dtd_validation=dtd_validation,
 *                            load_dtd=load_dtd,
 *                            no_network=no_network,             # <<<<<<<<<<<<<<
 *                            ns_clean=ns_clean,
 *                            recover=recover,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_no_network, __pyx_v_no_network) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1263
 *                            load_dtd=load_dtd,
 *                            no_network=no_network,
 *                            ns_clean=ns_clean,             # <<<<<<<<<<<<<<
 *                            recover=recover,
 *                            remove_blank_text=remove_blank_text,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_ns_clean, __pyx_v_ns_clean) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1264
 *                            no_network=no_network,
 *                            ns_clean=ns_clean,
 *                            recover=recover,             # <<<<<<<<<<<<<<
 *                            remove_blank_text=remove_blank_text,
 *                            compact=compact,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_recover, __pyx_v_recover) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1265
 *                            ns_clean=ns_clean,
 *                            recover=recover,
 *                            remove_blank_text=remove_blank_text,             # <<<<<<<<<<<<<<
 *                            compact=compact,
 *                            resolve_entities=resolve_entities,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_remove_blank_text, __pyx_v_remove_blank_text) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1266
 *                            recover=recover,
 *                            remove_blank_text=remove_blank_text,
 *                            compact=compact,             # <<<<<<<<<<<<<<
 *                            resolve_entities=resolve_entities,
 *                            remove_comments=remove_comments,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_compact, __pyx_v_compact) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1267
 *                            remove_blank_text=remove_blank_text,
 *                            compact=compact,
 *                            resolve_entities=resolve_entities,             # <<<<<<<<<<<<<<
 *                            remove_comments=remove_comments,
 *                            remove_pis=remove_pis,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_resolve_entities, __pyx_v_resolve_entities) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1268
 *                            compact=compact,
 *                            resolve_entities=resolve_entities,
 *                            remove_comments=remove_comments,             # <<<<<<<<<<<<<<
 *                            remove_pis=remove_pis,
 *                            strip_cdata=strip_cdata,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_remove_comments, __pyx_v_remove_comments) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1269
 *                            resolve_entities=resolve_entities,
 *                            remove_comments=remove_comments,
 *                            remove_pis=remove_pis,             # <<<<<<<<<<<<<<
 *                            strip_cdata=strip_cdata,
 *                            target=target,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_remove_pis, __pyx_v_remove_pis) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1270
 *                            remove_comments=remove_comments,
 *                            remove_pis=remove_pis,
 *                            strip_cdata=strip_cdata,             # <<<<<<<<<<<<<<
 *                            target=target,
 *                            encoding=encoding,
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_strip_cdata, __pyx_v_strip_cdata) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1271
 *                            remove_pis=remove_pis,
 *                            strip_cdata=strip_cdata,
 *                            target=target,             # <<<<<<<<<<<<<<
 *                            encoding=encoding,
 *                            schema=schema)
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_target, __pyx_v_target) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1272
 *                            strip_cdata=strip_cdata,
 *                            target=target,
 *                            encoding=encoding,             # <<<<<<<<<<<<<<
 *                            schema=schema)
 * 
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_encoding, __pyx_v_encoding) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1273
 *                            target=target,
 *                            encoding=encoding,
 *                            schema=schema)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_schema, __pyx_v_schema) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.ETCompatXMLParser.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1281
 * __GLOBAL_PARSER_CONTEXT.setDefaultParser(__DEFAULT_XML_PARSER)
 * 
 * def set_default_parser(_BaseParser parser=None):             # <<<<<<<<<<<<<<
 *     u"""set_default_parser(parser=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_set_default_parser(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_set_default_parser[] = "set_default_parser(parser=None)\n\n    Set a default parser for the current thread.  This parser is used\n    globally whenever no parser is supplied to the various parse functions of\n    the lxml API.  If this function is called without a parser (or if it is\n    None), the default parser is reset to the original configuration.\n\n    Note that the pre-installed default parser is not thread-safe.  Avoid the\n    default parser in multi-threaded environments.  You can create a separate\n    parser for each thread explicitly or use a parser pool.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_set_default_parser(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_parser,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_default_parser") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)values[0]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)PyTuple_GET_ITEM(__pyx_args, 0));
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_default_parser", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.set_default_parser");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_parser);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_4lxml_5etree__BaseParser, 1, "parser", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1293
 *     parser for each thread explicitly or use a parser pool.
 *     """
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __DEFAULT_XML_PARSER
 *     __GLOBAL_PARSER_CONTEXT.setDefaultParser(parser)
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1294
 *     """
 *     if parser is None:
 *         parser = __DEFAULT_XML_PARSER             # <<<<<<<<<<<<<<
 *     __GLOBAL_PARSER_CONTEXT.setDefaultParser(parser)
 * 
 */
    Py_INCREF(((PyObject *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER));
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1295
 *     if parser is None:
 *         parser = __DEFAULT_XML_PARSER
 *     __GLOBAL_PARSER_CONTEXT.setDefaultParser(parser)             # <<<<<<<<<<<<<<
 * 
 * def get_default_parser():
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->setDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_parser);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.set_default_parser");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1297
 *     __GLOBAL_PARSER_CONTEXT.setDefaultParser(parser)
 * 
 * def get_default_parser():             # <<<<<<<<<<<<<<
 *     u"get_default_parser()"
 *     return __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 */

static PyObject *__pyx_pf_4lxml_5etree_get_default_parser(PyObject *__pyx_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_get_default_parser[] = "get_default_parser()";
static PyObject *__pyx_pf_4lxml_5etree_get_default_parser(PyObject *__pyx_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_self = __pyx_self;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1299
 * def get_default_parser():
 *     u"get_default_parser()"
 *     return __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.get_default_parser");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1340
 *     reasons.
 *     """
 *     def __init__(self, *, recover=True, no_network=True,             # <<<<<<<<<<<<<<
 *                  remove_blank_text=False, compact=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, target=None, encoding=None,
 */

static int __pyx_pf_4lxml_5etree_10HTMLParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_10HTMLParser___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_recover = 0;
  PyObject *__pyx_v_no_network = 0;
  PyObject *__pyx_v_remove_blank_text = 0;
  PyObject *__pyx_v_compact = 0;
  PyObject *__pyx_v_remove_comments = 0;
  PyObject *__pyx_v_remove_pis = 0;
  PyObject *__pyx_v_strip_cdata = 0;
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_encoding = 0;
  struct __pyx_obj_4lxml_5etree_XMLSchema *__pyx_v_schema = 0;
  int __pyx_v_parse_options;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_recover,&__pyx_kp_no_network,&__pyx_kp_remove_blank_text,&__pyx_kp_compact,&__pyx_kp_remove_comments,&__pyx_kp_remove_pis,&__pyx_kp_strip_cdata,&__pyx_kp_target,&__pyx_kp_encoding,&__pyx_kp_schema,0};
  __pyx_v_recover = __pyx_k_137;
  __pyx_v_no_network = __pyx_k_138;
  __pyx_v_remove_blank_text = __pyx_k_139;
  __pyx_v_compact = __pyx_k_140;
  __pyx_v_remove_comments = __pyx_k_141;
  __pyx_v_remove_pis = __pyx_k_142;
  __pyx_v_strip_cdata = __pyx_k_143;
  __pyx_v_target = Py_None;
  __pyx_v_encoding = Py_None;
  __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_recover = values[0];
    }
    if (values[1]) {
      __pyx_v_no_network = values[1];
    }
    if (values[2]) {
      __pyx_v_remove_blank_text = values[2];
    }
    if (values[3]) {
      __pyx_v_compact = values[3];
    }
    if (values[4]) {
      __pyx_v_remove_comments = values[4];
    }
    if (values[5]) {
      __pyx_v_remove_pis = values[5];
    }
    if (values[6]) {
      __pyx_v_strip_cdata = values[6];
    }
    if (values[7]) {
      __pyx_v_target = values[7];
    }
    if (values[8]) {
      __pyx_v_encoding = values[8];
    }
    if (values[9]) {
      __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)values[9]);
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
    goto __pyx_L5_argtuple_error;
  } else {
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.HTMLParser.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), __pyx_ptype_4lxml_5etree_XMLSchema, 1, "schema", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1345
 *                  XMLSchema schema=None):
 *         cdef int parse_options
 *         parse_options = _HTML_DEFAULT_PARSE_OPTIONS             # <<<<<<<<<<<<<<
 *         if remove_blank_text:
 *             parse_options = parse_options | htmlparser.HTML_PARSE_NOBLANKS
 */
  __pyx_v_parse_options = __pyx_v_4lxml_5etree__HTML_DEFAULT_PARSE_OPTIONS;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1346
 *         cdef int parse_options
 *         parse_options = _HTML_DEFAULT_PARSE_OPTIONS
 *         if remove_blank_text:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | htmlparser.HTML_PARSE_NOBLANKS
 *         if not recover:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_remove_blank_text); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1347
 *         parse_options = _HTML_DEFAULT_PARSE_OPTIONS
 *         if remove_blank_text:
 *             parse_options = parse_options | htmlparser.HTML_PARSE_NOBLANKS             # <<<<<<<<<<<<<<
 *         if not recover:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_RECOVER
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | HTML_PARSE_NOBLANKS);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1348
 *         if remove_blank_text:
 *             parse_options = parse_options | htmlparser.HTML_PARSE_NOBLANKS
 *         if not recover:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_RECOVER
 *         if not no_network:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_recover); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1349
 *             parse_options = parse_options | htmlparser.HTML_PARSE_NOBLANKS
 *         if not recover:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_RECOVER             # <<<<<<<<<<<<<<
 *         if not no_network:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_NONET
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ HTML_PARSE_RECOVER);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1350
 *         if not recover:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_RECOVER
 *         if not no_network:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_NONET
 *         if not compact:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_no_network); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1351
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_RECOVER
 *         if not no_network:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_NONET             # <<<<<<<<<<<<<<
 *         if not compact:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_COMPACT
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ HTML_PARSE_NONET);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1352
 *         if not no_network:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_NONET
 *         if not compact:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_COMPACT
 * 
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_compact); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1353
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_NONET
 *         if not compact:
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_COMPACT             # <<<<<<<<<<<<<<
 * 
 *         _BaseParser.__init__(self, parse_options, 1, schema,
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ HTML_PARSE_COMPACT);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1355
 *             parse_options = parse_options ^ htmlparser.HTML_PARSE_COMPACT
 * 
 *         _BaseParser.__init__(self, parse_options, 1, schema,             # <<<<<<<<<<<<<<
 *                              remove_comments, remove_pis, strip_cdata,
 *                              target, None, encoding)
 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseParser)), __pyx_kp___init__); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyInt_FromLong(__pyx_v_parse_options); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1357
 *         _BaseParser.__init__(self, parse_options, 1, schema,
 *                              remove_comments, remove_pis, strip_cdata,
 *                              target, None, encoding)             # <<<<<<<<<<<<<<
 * 
 * cdef HTMLParser __DEFAULT_HTML_PARSER
 */
  __pyx_5 = PyTuple_New(10); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
  Py_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_int_1);
  Py_INCREF(((PyObject *)__pyx_v_schema));
  PyTuple_SET_ITEM(__pyx_5, 3, ((PyObject *)__pyx_v_schema));
  Py_INCREF(__pyx_v_remove_comments);
  PyTuple_SET_ITEM(__pyx_5, 4, __pyx_v_remove_comments);
  Py_INCREF(__pyx_v_remove_pis);
  PyTuple_SET_ITEM(__pyx_5, 5, __pyx_v_remove_pis);
  Py_INCREF(__pyx_v_strip_cdata);
  PyTuple_SET_ITEM(__pyx_5, 6, __pyx_v_strip_cdata);
  Py_INCREF(__pyx_v_target);
  PyTuple_SET_ITEM(__pyx_5, 7, __pyx_v_target);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_5, 8, Py_None);
  Py_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_5, 9, __pyx_v_encoding);
  __pyx_4 = 0;
  __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.HTMLParser.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1366
 * ############################################################
 * 
 * cdef xmlDoc* _parseDoc(text, filename, _BaseParser parser) except NULL:             # <<<<<<<<<<<<<<
 *     cdef char* c_filename
 *     cdef char* c_text
 */

static  xmlDoc *__pyx_f_4lxml_5etree__parseDoc(PyObject *__pyx_v_text, PyObject *__pyx_v_filename, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  char *__pyx_v_c_filename;
  char *__pyx_v_c_text;
  Py_ssize_t __pyx_v_c_len;
  PyObject *__pyx_v_filename_utf;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  xmlDoc *__pyx_6;
  xmlDoc *__pyx_7;
  xmlDoc *__pyx_8;
  Py_INCREF(__pyx_v_parser);
  __pyx_v_filename_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1370
 *     cdef char* c_text
 *     cdef Py_ssize_t c_len
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     if not filename:
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1371
 *     cdef Py_ssize_t c_len
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *     if not filename:
 *         c_filename = NULL
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1372
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     if not filename:             # <<<<<<<<<<<<<<
 *         c_filename = NULL
 *     else:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_filename); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = (!__pyx_1);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1373
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     if not filename:
 *         c_filename = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         filename_utf = _encodeFilenameUTF8(filename)
 */
    __pyx_v_c_filename = NULL;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1375
 *         c_filename = NULL
 *     else:
 *         filename_utf = _encodeFilenameUTF8(filename)             # <<<<<<<<<<<<<<
 *         c_filename = _cstr(filename_utf)
 *     if python.PyUnicode_Check(text):
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilenameUTF8(__pyx_v_filename); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_filename_utf);
    __pyx_v_filename_utf = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1376
 *     else:
 *         filename_utf = _encodeFilenameUTF8(filename)
 *         c_filename = _cstr(filename_utf)             # <<<<<<<<<<<<<<
 *     if python.PyUnicode_Check(text):
 *         c_len = python.PyUnicode_GET_DATA_SIZE(text)
 */
    __pyx_v_c_filename = PyString_AS_STRING(__pyx_v_filename_utf);
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1377
 *         filename_utf = _encodeFilenameUTF8(filename)
 *         c_filename = _cstr(filename_utf)
 *     if python.PyUnicode_Check(text):             # <<<<<<<<<<<<<<
 *         c_len = python.PyUnicode_GET_DATA_SIZE(text)
 *         if c_len > python.INT_MAX:
 */
  __pyx_4 = PyUnicode_Check(__pyx_v_text);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1378
 *         c_filename = _cstr(filename_utf)
 *     if python.PyUnicode_Check(text):
 *         c_len = python.PyUnicode_GET_DATA_SIZE(text)             # <<<<<<<<<<<<<<
 *         if c_len > python.INT_MAX:
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 */
    __pyx_v_c_len = PyUnicode_GET_DATA_SIZE(__pyx_v_text);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1379
 *     if python.PyUnicode_Check(text):
 *         c_len = python.PyUnicode_GET_DATA_SIZE(text)
 *         if c_len > python.INT_MAX:             # <<<<<<<<<<<<<<
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 *                 StringIO(text), filename)
 */
    __pyx_1 = (__pyx_v_c_len > INT_MAX);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1381
 *         if c_len > python.INT_MAX:
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 *                 StringIO(text), filename)             # <<<<<<<<<<<<<<
 *         return (<_BaseParser>parser)._parseUnicodeDoc(text, c_filename)
 *     else:
 */
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_text);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_text);
      __pyx_5 = PyObject_Call(__pyx_v_4lxml_5etree_StringIO, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser)->__pyx_vtab)->_parseDocFromFilelike(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_5, __pyx_v_filename); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_r = __pyx_6;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1382
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 *                 StringIO(text), filename)
 *         return (<_BaseParser>parser)._parseUnicodeDoc(text, c_filename)             # <<<<<<<<<<<<<<
 *     else:
 *         c_len = python.PyString_GET_SIZE(text)
 */
    __pyx_7 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser)->__pyx_vtab)->_parseUnicodeDoc(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_v_text, __pyx_v_c_filename); if (unlikely(__pyx_7 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_7;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1384
 *         return (<_BaseParser>parser)._parseUnicodeDoc(text, c_filename)
 *     else:
 *         c_len = python.PyString_GET_SIZE(text)             # <<<<<<<<<<<<<<
 *         if c_len > python.INT_MAX:
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 */
    __pyx_v_c_len = PyString_GET_SIZE(__pyx_v_text);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1385
 *     else:
 *         c_len = python.PyString_GET_SIZE(text)
 *         if c_len > python.INT_MAX:             # <<<<<<<<<<<<<<
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 *                 BytesIO(text), filename)
 */
    __pyx_3 = (__pyx_v_c_len > INT_MAX);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1387
 *         if c_len > python.INT_MAX:
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 *                 BytesIO(text), filename)             # <<<<<<<<<<<<<<
 *         c_text = _cstr(text)
 *         return (<_BaseParser>parser)._parseDoc(c_text, c_len, c_filename)
 */
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_text);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_text);
      __pyx_5 = PyObject_Call(__pyx_v_4lxml_5etree_BytesIO, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser)->__pyx_vtab)->_parseDocFromFilelike(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_5, __pyx_v_filename); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_r = __pyx_6;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1388
 *             return (<_BaseParser>parser)._parseDocFromFilelike(
 *                 BytesIO(text), filename)
 *         c_text = _cstr(text)             # <<<<<<<<<<<<<<
 *         return (<_BaseParser>parser)._parseDoc(c_text, c_len, c_filename)
 * 
 */
    __pyx_v_c_text = PyString_AS_STRING(__pyx_v_text);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1389
 *                 BytesIO(text), filename)
 *         c_text = _cstr(text)
 *         return (<_BaseParser>parser)._parseDoc(c_text, c_len, c_filename)             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _parseDocFromFile(filename8, _BaseParser parser) except NULL:
 */
    __pyx_8 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser)->__pyx_vtab)->_parseDoc(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_v_c_text, __pyx_v_c_len, __pyx_v_c_filename); if (unlikely(__pyx_8 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_8;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._parseDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_filename_utf);
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1391
 *         return (<_BaseParser>parser)._parseDoc(c_text, c_len, c_filename)
 * 
 * cdef xmlDoc* _parseDocFromFile(filename8, _BaseParser parser) except NULL:             # <<<<<<<<<<<<<<
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 */

static  xmlDoc *__pyx_f_4lxml_5etree__parseDocFromFile(PyObject *__pyx_v_filename8, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  xmlDoc *__pyx_3;
  Py_INCREF(__pyx_v_parser);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1392
 * 
 * cdef xmlDoc* _parseDocFromFile(filename8, _BaseParser parser) except NULL:
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     return (<_BaseParser>parser)._parseDocFromFile(_cstr(filename8))
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1393
 * cdef xmlDoc* _parseDocFromFile(filename8, _BaseParser parser) except NULL:
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *     return (<_BaseParser>parser)._parseDocFromFile(_cstr(filename8))
 * 
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1394
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     return (<_BaseParser>parser)._parseDocFromFile(_cstr(filename8))             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _parseDocFromFilelike(source, filename,
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser)->__pyx_vtab)->_parseDocFromFile(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), PyString_AS_STRING(__pyx_v_filename8)); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._parseDocFromFile");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1396
 *     return (<_BaseParser>parser)._parseDocFromFile(_cstr(filename8))
 * 
 * cdef xmlDoc* _parseDocFromFilelike(source, filename,             # <<<<<<<<<<<<<<
 *                                    _BaseParser parser) except NULL:
 *     if parser is None:
 */

static  xmlDoc *__pyx_f_4lxml_5etree__parseDocFromFilelike(PyObject *__pyx_v_source, PyObject *__pyx_v_filename, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  xmlDoc *__pyx_3;
  Py_INCREF(__pyx_v_parser);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1398
 * cdef xmlDoc* _parseDocFromFilelike(source, filename,
 *                                    _BaseParser parser) except NULL:
 *     if parser is None:             # <<<<<<<<<<<<<<
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     return (<_BaseParser>parser)._parseDocFromFilelike(source, filename)
 */
  __pyx_1 = (((PyObject *)__pyx_v_parser) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1399
 *                                    _BaseParser parser) except NULL:
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()             # <<<<<<<<<<<<<<
 *     return (<_BaseParser>parser)._parseDocFromFilelike(source, filename)
 * 
 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->getDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parser));
    __pyx_v_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1400
 *     if parser is None:
 *         parser = __GLOBAL_PARSER_CONTEXT.getDefaultParser()
 *     return (<_BaseParser>parser)._parseDocFromFilelike(source, filename)             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _newXMLDoc() except NULL:
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseParser *)((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser)->__pyx_vtab)->_parseDocFromFilelike(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_v_source, __pyx_v_filename); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._parseDocFromFilelike");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parser);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1402
 *     return (<_BaseParser>parser)._parseDocFromFilelike(source, filename)
 * 
 * cdef xmlDoc* _newXMLDoc() except NULL:             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* result
 *     result = tree.xmlNewDoc(NULL)
 */

static  xmlDoc *__pyx_f_4lxml_5etree__newXMLDoc(void) {
  xmlDoc *__pyx_v_result;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1404
 * cdef xmlDoc* _newXMLDoc() except NULL:
 *     cdef xmlDoc* result
 *     result = tree.xmlNewDoc(NULL)             # <<<<<<<<<<<<<<
 *     if result is NULL:
 *         python.PyErr_NoMemory()
 */
  __pyx_v_result = xmlNewDoc(NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1405
 *     cdef xmlDoc* result
 *     result = tree.xmlNewDoc(NULL)
 *     if result is NULL:             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *     if result.encoding is NULL:
 */
  __pyx_1 = (__pyx_v_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1406
 *     result = tree.xmlNewDoc(NULL)
 *     if result is NULL:
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     if result.encoding is NULL:
 *         result.encoding = tree.xmlStrdup("UTF-8")
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1407
 *     if result is NULL:
 *         python.PyErr_NoMemory()
 *     if result.encoding is NULL:             # <<<<<<<<<<<<<<
 *         result.encoding = tree.xmlStrdup("UTF-8")
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 */
  __pyx_1 = (__pyx_v_result->encoding == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1408
 *         python.PyErr_NoMemory()
 *     if result.encoding is NULL:
 *         result.encoding = tree.xmlStrdup("UTF-8")             # <<<<<<<<<<<<<<
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     return result
 */
    __pyx_v_result->encoding = xmlStrdup(__pyx_k_431);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1409
 *     if result.encoding is NULL:
 *         result.encoding = tree.xmlStrdup("UTF-8")
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initDocDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_result);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1410
 *         result.encoding = tree.xmlStrdup("UTF-8")
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _newHTMLDoc() except NULL:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._newXMLDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1412
 *     return result
 * 
 * cdef xmlDoc* _newHTMLDoc() except NULL:             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* result
 *     result = tree.htmlNewDoc(NULL, NULL)
 */

static  xmlDoc *__pyx_f_4lxml_5etree__newHTMLDoc(void) {
  xmlDoc *__pyx_v_result;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1414
 * cdef xmlDoc* _newHTMLDoc() except NULL:
 *     cdef xmlDoc* result
 *     result = tree.htmlNewDoc(NULL, NULL)             # <<<<<<<<<<<<<<
 *     if result is NULL:
 *         python.PyErr_NoMemory()
 */
  __pyx_v_result = htmlNewDoc(NULL, NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1415
 *     cdef xmlDoc* result
 *     result = tree.htmlNewDoc(NULL, NULL)
 *     if result is NULL:             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 */
  __pyx_1 = (__pyx_v_result == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1416
 *     result = tree.htmlNewDoc(NULL, NULL)
 *     if result is NULL:
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     return result
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1417
 *     if result is NULL:
 *         python.PyErr_NoMemory()
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initDocDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_result);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1418
 *         python.PyErr_NoMemory()
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _copyDoc(xmlDoc* c_doc, int recursive) except NULL:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._newHTMLDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1420
 *     return result
 * 
 * cdef xmlDoc* _copyDoc(xmlDoc* c_doc, int recursive) except NULL:             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* result
 *     if recursive:
 */

static  xmlDoc *__pyx_f_4lxml_5etree__copyDoc(xmlDoc *__pyx_v_c_doc, int __pyx_v_recursive) {
  xmlDoc *__pyx_v_result;
  xmlDoc *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1422
 * cdef xmlDoc* _copyDoc(xmlDoc* c_doc, int recursive) except NULL:
 *     cdef xmlDoc* result
 *     if recursive:             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = tree.xmlCopyDoc(c_doc, recursive)
 */
  __pyx_1 = __pyx_v_recursive;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1423
 *     cdef xmlDoc* result
 *     if recursive:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = tree.xmlCopyDoc(c_doc, recursive)
 *     else:
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1424
 *     if recursive:
 *         with nogil:
 *             result = tree.xmlCopyDoc(c_doc, recursive)             # <<<<<<<<<<<<<<
 *     else:
 *         result = tree.xmlCopyDoc(c_doc, 0)
 */
        __pyx_v_result = xmlCopyDoc(__pyx_v_c_doc, __pyx_v_recursive);
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1426
 *             result = tree.xmlCopyDoc(c_doc, recursive)
 *     else:
 *         result = tree.xmlCopyDoc(c_doc, 0)             # <<<<<<<<<<<<<<
 *     if result is NULL:
 *         python.PyErr_NoMemory()
 */
    __pyx_v_result = xmlCopyDoc(__pyx_v_c_doc, 0);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1427
 *     else:
 *         result = tree.xmlCopyDoc(c_doc, 0)
 *     if result is NULL:             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 */
  __pyx_2 = (__pyx_v_result == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1428
 *         result = tree.xmlCopyDoc(c_doc, 0)
 *     if result is NULL:
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     return result
 */
    __pyx_3 = PyErr_NoMemory(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1429
 *     if result is NULL:
 *         python.PyErr_NoMemory()
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initDocDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_result);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1430
 *         python.PyErr_NoMemory()
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _copyDocRoot(xmlDoc* c_doc, xmlNode* c_new_root) except NULL:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._copyDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1432
 *     return result
 * 
 * cdef xmlDoc* _copyDocRoot(xmlDoc* c_doc, xmlNode* c_new_root) except NULL:             # <<<<<<<<<<<<<<
 *     u"Recursively copy the document and make c_new_root the new root node."
 *     cdef xmlDoc* result
 */

static  xmlDoc *__pyx_f_4lxml_5etree__copyDocRoot(xmlDoc *__pyx_v_c_doc, xmlNode *__pyx_v_c_new_root) {
  xmlDoc *__pyx_v_result;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1436
 *     cdef xmlDoc* result
 *     cdef xmlNode* c_node
 *     result = tree.xmlCopyDoc(c_doc, 0) # non recursive             # <<<<<<<<<<<<<<
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     with nogil:
 */
  __pyx_v_result = xmlCopyDoc(__pyx_v_c_doc, 0);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1437
 *     cdef xmlNode* c_node
 *     result = tree.xmlCopyDoc(c_doc, 0) # non recursive
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)             # <<<<<<<<<<<<<<
 *     with nogil:
 *         c_node = tree.xmlDocCopyNode(c_new_root, result, 1) # recursive
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initDocDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_result);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1438
 *     result = tree.xmlCopyDoc(c_doc, 0) # non recursive
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         c_node = tree.xmlDocCopyNode(c_new_root, result, 1) # recursive
 *     if c_node is NULL:
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1439
 *     __GLOBAL_PARSER_CONTEXT.initDocDict(result)
 *     with nogil:
 *         c_node = tree.xmlDocCopyNode(c_new_root, result, 1) # recursive             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         python.PyErr_NoMemory()
 */
      __pyx_v_c_node = xmlDocCopyNode(__pyx_v_c_new_root, __pyx_v_result, 1);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1440
 *     with nogil:
 *         c_node = tree.xmlDocCopyNode(c_new_root, result, 1) # recursive
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *     tree.xmlDocSetRootElement(result, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1441
 *         c_node = tree.xmlDocCopyNode(c_new_root, result, 1) # recursive
 *     if c_node is NULL:
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     tree.xmlDocSetRootElement(result, c_node)
 *     _copyTail(c_new_root.next, c_node)
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1442
 *     if c_node is NULL:
 *         python.PyErr_NoMemory()
 *     tree.xmlDocSetRootElement(result, c_node)             # <<<<<<<<<<<<<<
 *     _copyTail(c_new_root.next, c_node)
 *     return result
 */
  xmlDocSetRootElement(__pyx_v_result, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1443
 *         python.PyErr_NoMemory()
 *     tree.xmlDocSetRootElement(result, c_node)
 *     _copyTail(c_new_root.next, c_node)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_f_4lxml_5etree__copyTail(__pyx_v_c_new_root->next, __pyx_v_c_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1444
 *     tree.xmlDocSetRootElement(result, c_node)
 *     _copyTail(c_new_root.next, c_node)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef xmlNode* _copyNodeToDoc(xmlNode* c_node, xmlDoc* c_doc) except NULL:
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._copyDocRoot");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1446
 *     return result
 * 
 * cdef xmlNode* _copyNodeToDoc(xmlNode* c_node, xmlDoc* c_doc) except NULL:             # <<<<<<<<<<<<<<
 *     u"Recursively copy the element into the document. c_doc is not modified."
 *     cdef xmlNode* c_root
 */

static  xmlNode *__pyx_f_4lxml_5etree__copyNodeToDoc(xmlNode *__pyx_v_c_node, xmlDoc *__pyx_v_c_doc) {
  xmlNode *__pyx_v_c_root;
  xmlNode *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1449
 *     u"Recursively copy the element into the document. c_doc is not modified."
 *     cdef xmlNode* c_root
 *     c_root = tree.xmlDocCopyNode(c_node, c_doc, 1) # recursive             # <<<<<<<<<<<<<<
 *     if c_root is NULL:
 *         python.PyErr_NoMemory()
 */
  __pyx_v_c_root = xmlDocCopyNode(__pyx_v_c_node, __pyx_v_c_doc, 1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1450
 *     cdef xmlNode* c_root
 *     c_root = tree.xmlDocCopyNode(c_node, c_doc, 1) # recursive
 *     if c_root is NULL:             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *     _copyTail(c_node.next, c_root)
 */
  __pyx_1 = (__pyx_v_c_root == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1451
 *     c_root = tree.xmlDocCopyNode(c_node, c_doc, 1) # recursive
 *     if c_root is NULL:
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     _copyTail(c_node.next, c_root)
 *     return c_root
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1452
 *     if c_root is NULL:
 *         python.PyErr_NoMemory()
 *     _copyTail(c_node.next, c_root)             # <<<<<<<<<<<<<<
 *     return c_root
 * 
 */
  __pyx_f_4lxml_5etree__copyTail(__pyx_v_c_node->next, __pyx_v_c_root);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1453
 *         python.PyErr_NoMemory()
 *     _copyTail(c_node.next, c_root)
 *     return c_root             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_c_root;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._copyNodeToDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1461
 * ############################################################
 * 
 * cdef _Document _parseDocument(source, _BaseParser parser, base_url):             # <<<<<<<<<<<<<<
 *     cdef _Document doc
 *     if _isString(source):
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__parseDocument(PyObject *__pyx_v_source, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser, PyObject *__pyx_v_base_url) {
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_v_url;
  struct LxmlDocument *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_base_url);
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_url = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1463
 * cdef _Document _parseDocument(source, _BaseParser parser, base_url):
 *     cdef _Document doc
 *     if _isString(source):             # <<<<<<<<<<<<<<
 *         # parse the file directly from the filesystem
 *         doc = _parseDocumentFromURL(_encodeFilename(source), parser)
 */
  __pyx_1 = _isString(__pyx_v_source);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1465
 *     if _isString(source):
 *         # parse the file directly from the filesystem
 *         doc = _parseDocumentFromURL(_encodeFilename(source), parser)             # <<<<<<<<<<<<<<
 *         # fix base URL if requested
 *         if base_url is not None:
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_source); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocumentFromURL(__pyx_2, __pyx_v_parser)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlDocument *)__pyx_3);
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1467
 *         doc = _parseDocumentFromURL(_encodeFilename(source), parser)
 *         # fix base URL if requested
 *         if base_url is not None:             # <<<<<<<<<<<<<<
 *             base_url = _encodeFilenameUTF8(base_url)
 *             if doc._c_doc.URL is not NULL:
 */
    __pyx_1 = (__pyx_v_base_url != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1468
 *         # fix base URL if requested
 *         if base_url is not None:
 *             base_url = _encodeFilenameUTF8(base_url)             # <<<<<<<<<<<<<<
 *             if doc._c_doc.URL is not NULL:
 *                 tree.xmlFree(doc._c_doc.URL)
 */
      __pyx_2 = __pyx_f_4lxml_5etree__encodeFilenameUTF8(__pyx_v_base_url); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_base_url);
      __pyx_v_base_url = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1469
 *         if base_url is not None:
 *             base_url = _encodeFilenameUTF8(base_url)
 *             if doc._c_doc.URL is not NULL:             # <<<<<<<<<<<<<<
 *                 tree.xmlFree(doc._c_doc.URL)
 *             doc._c_doc.URL = tree.xmlStrdup(_cstr(base_url))
 */
      __pyx_1 = (__pyx_v_doc->_c_doc->URL != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1470
 *             base_url = _encodeFilenameUTF8(base_url)
 *             if doc._c_doc.URL is not NULL:
 *                 tree.xmlFree(doc._c_doc.URL)             # <<<<<<<<<<<<<<
 *             doc._c_doc.URL = tree.xmlStrdup(_cstr(base_url))
 *         return doc
 */
        xmlFree(__pyx_v_doc->_c_doc->URL);
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1471
 *             if doc._c_doc.URL is not NULL:
 *                 tree.xmlFree(doc._c_doc.URL)
 *             doc._c_doc.URL = tree.xmlStrdup(_cstr(base_url))             # <<<<<<<<<<<<<<
 *         return doc
 * 
 */
      __pyx_v_doc->_c_doc->URL = xmlStrdup(PyString_AS_STRING(__pyx_v_base_url));
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1472
 *                 tree.xmlFree(doc._c_doc.URL)
 *             doc._c_doc.URL = tree.xmlStrdup(_cstr(base_url))
 *         return doc             # <<<<<<<<<<<<<<
 * 
 *     if base_url is not None:
 */
    Py_INCREF(((PyObject *)__pyx_v_doc));
    __pyx_r = __pyx_v_doc;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1474
 *         return doc
 * 
 *     if base_url is not None:             # <<<<<<<<<<<<<<
 *         url = base_url
 *     else:
 */
  __pyx_1 = (__pyx_v_base_url != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1475
 * 
 *     if base_url is not None:
 *         url = base_url             # <<<<<<<<<<<<<<
 *     else:
 *         url = _getFilenameForFile(source)
 */
    Py_INCREF(__pyx_v_base_url);
    Py_DECREF(__pyx_v_url);
    __pyx_v_url = __pyx_v_base_url;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1477
 *         url = base_url
 *     else:
 *         url = _getFilenameForFile(source)             # <<<<<<<<<<<<<<
 * 
 *     if hasattr(source, u'getvalue') and hasattr(source, u'tell'):
 */
    __pyx_3 = __pyx_f_4lxml_5etree__getFilenameForFile(__pyx_v_source); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_url);
    __pyx_v_url = __pyx_3;
    __pyx_3 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1479
 *         url = _getFilenameForFile(source)
 * 
 *     if hasattr(source, u'getvalue') and hasattr(source, u'tell'):             # <<<<<<<<<<<<<<
 *         # StringIO - reading from start?
 *         if source.tell() == 0:
 */
  __pyx_1 = PyObject_HasAttr(__pyx_v_source, ((PyObject *)__pyx_kp_432)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {
    __pyx_1 = PyObject_HasAttr(__pyx_v_source, ((PyObject *)__pyx_kp_433)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1481
 *     if hasattr(source, u'getvalue') and hasattr(source, u'tell'):
 *         # StringIO - reading from start?
 *         if source.tell() == 0:             # <<<<<<<<<<<<<<
 *             return _parseMemoryDocument(
 *                 source.getvalue(), _encodeFilenameUTF8(url), parser)
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_source, __pyx_kp_tell); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyObject_RichCompare(__pyx_3, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1483
 *         if source.tell() == 0:
 *             return _parseMemoryDocument(
 *                 source.getvalue(), _encodeFilenameUTF8(url), parser)             # <<<<<<<<<<<<<<
 * 
 *     # Support for file-like objects (urlgrabber.urlopen, ...)
 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_source, __pyx_kp_getvalue); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_3 = __pyx_f_4lxml_5etree__encodeFilenameUTF8(__pyx_v_url); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = ((PyObject *)__pyx_f_4lxml_5etree__parseMemoryDocument(__pyx_2, __pyx_3, __pyx_v_parser)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_r = ((struct LxmlDocument *)__pyx_4);
      __pyx_4 = 0;
      goto __pyx_L0;
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1486
 * 
 *     # Support for file-like objects (urlgrabber.urlopen, ...)
 *     if hasattr(source, u'read'):             # <<<<<<<<<<<<<<
 *         return _parseFilelikeDocument(
 *             source, _encodeFilenameUTF8(url), parser)
 */
  __pyx_1 = PyObject_HasAttr(__pyx_v_source, ((PyObject *)__pyx_kp_434)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1488
 *     if hasattr(source, u'read'):
 *         return _parseFilelikeDocument(
 *             source, _encodeFilenameUTF8(url), parser)             # <<<<<<<<<<<<<<
 * 
 *     raise TypeError, u"cannot parse from '%s'" % funicode(python._fqtypename(source))
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilenameUTF8(__pyx_v_url); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__parseFilelikeDocument(__pyx_v_source, __pyx_2, __pyx_v_parser)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_r = ((struct LxmlDocument *)__pyx_3);
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1490
 *             source, _encodeFilenameUTF8(url), parser)
 * 
 *     raise TypeError, u"cannot parse from '%s'" % funicode(python._fqtypename(source))             # <<<<<<<<<<<<<<
 * 
 * cdef _Document _parseDocumentFromURL(url, _BaseParser parser):
 */
  __pyx_4 = __pyx_f_4lxml_5etree_funicode(_fqtypename(__pyx_v_source)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_435), __pyx_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._parseDocument");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_url);
  Py_DECREF(__pyx_v_base_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1492
 *     raise TypeError, u"cannot parse from '%s'" % funicode(python._fqtypename(source))
 * 
 * cdef _Document _parseDocumentFromURL(url, _BaseParser parser):             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* c_doc
 *     c_doc = _parseDocFromFile(url, parser)
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__parseDocumentFromURL(PyObject *__pyx_v_url, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  xmlDoc *__pyx_v_c_doc;
  struct LxmlDocument *__pyx_r;
  xmlDoc *__pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1494
 * cdef _Document _parseDocumentFromURL(url, _BaseParser parser):
 *     cdef xmlDoc* c_doc
 *     c_doc = _parseDocFromFile(url, parser)             # <<<<<<<<<<<<<<
 *     return _documentFactory(c_doc, parser)
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__parseDocFromFile(__pyx_v_url, __pyx_v_parser); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1495
 *     cdef xmlDoc* c_doc
 *     c_doc = _parseDocFromFile(url, parser)
 *     return _documentFactory(c_doc, parser)             # <<<<<<<<<<<<<<
 * 
 * cdef _Document _parseMemoryDocument(text, url, _BaseParser parser):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, __pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlDocument *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._parseDocumentFromURL");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1497
 *     return _documentFactory(c_doc, parser)
 * 
 * cdef _Document _parseMemoryDocument(text, url, _BaseParser parser):             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* c_doc
 *     if python.PyUnicode_Check(text):
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__parseMemoryDocument(PyObject *__pyx_v_text, PyObject *__pyx_v_url, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  xmlDoc *__pyx_v_c_doc;
  struct LxmlDocument *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  xmlDoc *__pyx_4;
  Py_INCREF(__pyx_v_text);
  Py_INCREF(__pyx_v_url);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1499
 * cdef _Document _parseMemoryDocument(text, url, _BaseParser parser):
 *     cdef xmlDoc* c_doc
 *     if python.PyUnicode_Check(text):             # <<<<<<<<<<<<<<
 *         if _hasEncodingDeclaration(text):
 *             raise ValueError, \
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_text);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1500
 *     cdef xmlDoc* c_doc
 *     if python.PyUnicode_Check(text):
 *         if _hasEncodingDeclaration(text):             # <<<<<<<<<<<<<<
 *             raise ValueError, \
 *                 u"Unicode strings with encoding declaration are not supported."
 */
    __pyx_1 = __pyx_f_4lxml_5etree__hasEncodingDeclaration(__pyx_v_text);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1502
 *         if _hasEncodingDeclaration(text):
 *             raise ValueError, \
 *                 u"Unicode strings with encoding declaration are not supported."             # <<<<<<<<<<<<<<
 *         # pass native unicode only if libxml2 can handle it
 *         if _UNICODE_ENCODING is NULL:
 */
      __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_436), 0);
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1504
 *                 u"Unicode strings with encoding declaration are not supported."
 *         # pass native unicode only if libxml2 can handle it
 *         if _UNICODE_ENCODING is NULL:             # <<<<<<<<<<<<<<
 *             text = python.PyUnicode_AsUTF8String(text)
 *     elif not python.PyString_Check(text):
 */
    __pyx_2 = (__pyx_v_4lxml_5etree__UNICODE_ENCODING == NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1505
 *         # pass native unicode only if libxml2 can handle it
 *         if _UNICODE_ENCODING is NULL:
 *             text = python.PyUnicode_AsUTF8String(text)             # <<<<<<<<<<<<<<
 *     elif not python.PyString_Check(text):
 *         raise ValueError, u"can only parse strings"
 */
      __pyx_3 = PyUnicode_AsUTF8String(__pyx_v_text); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_text);
      __pyx_v_text = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1506
 *         if _UNICODE_ENCODING is NULL:
 *             text = python.PyUnicode_AsUTF8String(text)
 *     elif not python.PyString_Check(text):             # <<<<<<<<<<<<<<
 *         raise ValueError, u"can only parse strings"
 *     if python.PyUnicode_Check(url):
 */
  __pyx_2 = (!PyString_Check(__pyx_v_text));
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1507
 *             text = python.PyUnicode_AsUTF8String(text)
 *     elif not python.PyString_Check(text):
 *         raise ValueError, u"can only parse strings"             # <<<<<<<<<<<<<<
 *     if python.PyUnicode_Check(url):
 *         url = python.PyUnicode_AsUTF8String(url)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_437), 0);
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1508
 *     elif not python.PyString_Check(text):
 *         raise ValueError, u"can only parse strings"
 *     if python.PyUnicode_Check(url):             # <<<<<<<<<<<<<<
 *         url = python.PyUnicode_AsUTF8String(url)
 *     c_doc = _parseDoc(text, url, parser)
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_url);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1509
 *         raise ValueError, u"can only parse strings"
 *     if python.PyUnicode_Check(url):
 *         url = python.PyUnicode_AsUTF8String(url)             # <<<<<<<<<<<<<<
 *     c_doc = _parseDoc(text, url, parser)
 *     return _documentFactory(c_doc, parser)
 */
    __pyx_3 = PyUnicode_AsUTF8String(__pyx_v_url); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_url);
    __pyx_v_url = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1510
 *     if python.PyUnicode_Check(url):
 *         url = python.PyUnicode_AsUTF8String(url)
 *     c_doc = _parseDoc(text, url, parser)             # <<<<<<<<<<<<<<
 *     return _documentFactory(c_doc, parser)
 * 
 */
  __pyx_4 = __pyx_f_4lxml_5etree__parseDoc(__pyx_v_text, __pyx_v_url, __pyx_v_parser); if (unlikely(__pyx_4 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_4;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1511
 *         url = python.PyUnicode_AsUTF8String(url)
 *     c_doc = _parseDoc(text, url, parser)
 *     return _documentFactory(c_doc, parser)             # <<<<<<<<<<<<<<
 * 
 * cdef _Document _parseFilelikeDocument(source, url, _BaseParser parser):
 */
  __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, __pyx_v_parser)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlDocument *)__pyx_3);
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._parseMemoryDocument");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  Py_DECREF(__pyx_v_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1513
 *     return _documentFactory(c_doc, parser)
 * 
 * cdef _Document _parseFilelikeDocument(source, url, _BaseParser parser):             # <<<<<<<<<<<<<<
 *     cdef xmlDoc* c_doc
 *     if python.PyUnicode_Check(url):
 */

static  struct LxmlDocument *__pyx_f_4lxml_5etree__parseFilelikeDocument(PyObject *__pyx_v_source, PyObject *__pyx_v_url, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  xmlDoc *__pyx_v_c_doc;
  struct LxmlDocument *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  xmlDoc *__pyx_3;
  Py_INCREF(__pyx_v_url);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1515
 * cdef _Document _parseFilelikeDocument(source, url, _BaseParser parser):
 *     cdef xmlDoc* c_doc
 *     if python.PyUnicode_Check(url):             # <<<<<<<<<<<<<<
 *         url = python.PyUnicode_AsUTF8String(url)
 *     c_doc = _parseDocFromFilelike(source, url, parser)
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_url);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1516
 *     cdef xmlDoc* c_doc
 *     if python.PyUnicode_Check(url):
 *         url = python.PyUnicode_AsUTF8String(url)             # <<<<<<<<<<<<<<
 *     c_doc = _parseDocFromFilelike(source, url, parser)
 *     return _documentFactory(c_doc, parser)
 */
    __pyx_2 = PyUnicode_AsUTF8String(__pyx_v_url); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_url);
    __pyx_v_url = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1517
 *     if python.PyUnicode_Check(url):
 *         url = python.PyUnicode_AsUTF8String(url)
 *     c_doc = _parseDocFromFilelike(source, url, parser)             # <<<<<<<<<<<<<<
 *     return _documentFactory(c_doc, parser)
 */
  __pyx_3 = __pyx_f_4lxml_5etree__parseDocFromFilelike(__pyx_v_source, __pyx_v_url, __pyx_v_parser); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1518
 *         url = python.PyUnicode_AsUTF8String(url)
 *     c_doc = _parseDocFromFilelike(source, url, parser)
 *     return _documentFactory(c_doc, parser)             # <<<<<<<<<<<<<<
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_doc, __pyx_v_parser)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlDocument *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._parseFilelikeDocument");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_url);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":14
 *     cdef int _sax_event_filter
 *     cdef int _sax_event_propagate
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self._sax_event_filter = 0
 *         self._sax_event_propagate = 0
 */

static int __pyx_pf_4lxml_5etree_16_SaxParserTarget___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_16_SaxParserTarget___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":15
 *     cdef int _sax_event_propagate
 *     def __cinit__(self):
 *         self._sax_event_filter = 0             # <<<<<<<<<<<<<<
 *         self._sax_event_propagate = 0
 * 
 */
  ((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self)->_sax_event_filter = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":16
 *     def __cinit__(self):
 *         self._sax_event_filter = 0
 *         self._sax_event_propagate = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 */
  ((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self)->_sax_event_propagate = 0;

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":18
 *         self._sax_event_propagate = 0
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):             # <<<<<<<<<<<<<<
 *         return None
 *     cdef _handleSaxEnd(self, tag):
 */

static  PyObject *__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxStart(struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_self, PyObject *__pyx_v_tag, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":19
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 *         return None             # <<<<<<<<<<<<<<
 *     cdef _handleSaxEnd(self, tag):
 *         return None
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":20
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 *         return None
 *     cdef _handleSaxEnd(self, tag):             # <<<<<<<<<<<<<<
 *         return None
 *     cdef int _handleSaxData(self, data) except -1:
 */

static  PyObject *__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxEnd(struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_self, PyObject *__pyx_v_tag) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":21
 *         return None
 *     cdef _handleSaxEnd(self, tag):
 *         return None             # <<<<<<<<<<<<<<
 *     cdef int _handleSaxData(self, data) except -1:
 *         return 0
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":22
 *     cdef _handleSaxEnd(self, tag):
 *         return None
 *     cdef int _handleSaxData(self, data) except -1:             # <<<<<<<<<<<<<<
 *         return 0
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:
 */

static  int __pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxData(struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_self, PyObject *__pyx_v_data) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":23
 *         return None
 *     cdef int _handleSaxData(self, data) except -1:
 *         return 0             # <<<<<<<<<<<<<<
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:
 *         return 0
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":24
 *     cdef int _handleSaxData(self, data) except -1:
 *         return 0
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:             # <<<<<<<<<<<<<<
 *         return 0
 *     cdef _handleSaxPi(self, target, data):
 */

static  int __pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxDoctype(struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_self, PyObject *__pyx_v_root_tag, PyObject *__pyx_v_public_id, PyObject *__pyx_v_system_id) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":25
 *         return 0
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:
 *         return 0             # <<<<<<<<<<<<<<
 *     cdef _handleSaxPi(self, target, data):
 *         return None
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":26
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:
 *         return 0
 *     cdef _handleSaxPi(self, target, data):             # <<<<<<<<<<<<<<
 *         return None
 *     cdef _handleSaxComment(self, comment):
 */

static  PyObject *__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxPi(struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_self, PyObject *__pyx_v_target, PyObject *__pyx_v_data) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":27
 *         return 0
 *     cdef _handleSaxPi(self, target, data):
 *         return None             # <<<<<<<<<<<<<<
 *     cdef _handleSaxComment(self, comment):
 *         return None
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":28
 *     cdef _handleSaxPi(self, target, data):
 *         return None
 *     cdef _handleSaxComment(self, comment):             # <<<<<<<<<<<<<<
 *         return None
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxComment(struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_self, PyObject *__pyx_v_comment) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":29
 *         return None
 *     cdef _handleSaxComment(self, comment):
 *         return None             # <<<<<<<<<<<<<<
 * 
 * cdef class _SaxParserContext(_ParserContext):
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":45
 *     cdef xmlparser.processingInstructionSAXFunc    _origSaxPi
 * 
 *     cdef void _setSaxParserTarget(self, _SaxParserTarget target):             # <<<<<<<<<<<<<<
 *         self._target = target
 * 
 */

static  void __pyx_f_4lxml_5etree_17_SaxParserContext__setSaxParserTarget(struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__SaxParserTarget *__pyx_v_target) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":46
 * 
 *     cdef void _setSaxParserTarget(self, _SaxParserTarget target):
 *         self._target = target             # <<<<<<<<<<<<<<
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):
 */
  Py_INCREF(((PyObject *)__pyx_v_target));
  Py_DECREF(((PyObject *)__pyx_v_self->_target));
  __pyx_v_self->_target = __pyx_v_target;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":48
 *         self._target = target
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):             # <<<<<<<<<<<<<<
 *         u"wrap original SAX2 callbacks"
 *         cdef xmlparser.xmlSAXHandler* sax
 */

static  void __pyx_f_4lxml_5etree_17_SaxParserContext__initParserContext(struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_self, xmlParserCtxt *__pyx_v_c_ctxt) {
  xmlSAXHandler *__pyx_v_sax;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":51
 *         u"wrap original SAX2 callbacks"
 *         cdef xmlparser.xmlSAXHandler* sax
 *         _ParserContext._initParserContext(self, c_ctxt)             # <<<<<<<<<<<<<<
 *         sax = c_ctxt.sax
 *         if self._target._sax_event_propagate & SAX_EVENT_START:
 */
  __pyx_vtabptr_4lxml_5etree__ParserContext->_initParserContext(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self), __pyx_v_c_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":52
 *         cdef xmlparser.xmlSAXHandler* sax
 *         _ParserContext._initParserContext(self, c_ctxt)
 *         sax = c_ctxt.sax             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_propagate & SAX_EVENT_START:
 *             # propagate => keep orig callback
 */
  __pyx_v_sax = __pyx_v_c_ctxt->sax;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":53
 *         _ParserContext._initParserContext(self, c_ctxt)
 *         sax = c_ctxt.sax
 *         if self._target._sax_event_propagate & SAX_EVENT_START:             # <<<<<<<<<<<<<<
 *             # propagate => keep orig callback
 *             self._origSaxStart = sax.startElementNs
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_propagate & __pyx_e_4lxml_5etree_SAX_EVENT_START);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":55
 *         if self._target._sax_event_propagate & SAX_EVENT_START:
 *             # propagate => keep orig callback
 *             self._origSaxStart = sax.startElementNs             # <<<<<<<<<<<<<<
 *             self._origSaxStartNoNs = sax.startElement
 *         else:
 */
    __pyx_v_self->_origSaxStart = __pyx_v_sax->startElementNs;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":56
 *             # propagate => keep orig callback
 *             self._origSaxStart = sax.startElementNs
 *             self._origSaxStartNoNs = sax.startElement             # <<<<<<<<<<<<<<
 *         else:
 *             # otherwise: never call orig callback
 */
    __pyx_v_self->_origSaxStartNoNs = __pyx_v_sax->startElement;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":59
 *         else:
 *             # otherwise: never call orig callback
 *             self._origSaxStart = sax.startElementNs = NULL             # <<<<<<<<<<<<<<
 *             self._origSaxStartNoNs = sax.startElement = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_START:
 */
    __pyx_v_self->_origSaxStart = NULL;
    __pyx_v_sax->startElementNs = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":60
 *             # otherwise: never call orig callback
 *             self._origSaxStart = sax.startElementNs = NULL
 *             self._origSaxStartNoNs = sax.startElement = NULL             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_filter & SAX_EVENT_START:
 *             # intercept => overwrite orig callback
 */
    __pyx_v_self->_origSaxStartNoNs = NULL;
    __pyx_v_sax->startElement = NULL;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":61
 *             self._origSaxStart = sax.startElementNs = NULL
 *             self._origSaxStartNoNs = sax.startElement = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_START:             # <<<<<<<<<<<<<<
 *             # intercept => overwrite orig callback
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_filter & __pyx_e_4lxml_5etree_SAX_EVENT_START);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":63
 *         if self._target._sax_event_filter & SAX_EVENT_START:
 *             # intercept => overwrite orig callback
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:             # <<<<<<<<<<<<<<
 *                 sax.startElementNs = _handleSaxStart
 *             sax.startElement = _handleSaxStartNoNs
 */
    __pyx_2 = (__pyx_v_sax->initialized == XML_SAX2_MAGIC);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":64
 *             # intercept => overwrite orig callback
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 *                 sax.startElementNs = _handleSaxStart             # <<<<<<<<<<<<<<
 *             sax.startElement = _handleSaxStartNoNs
 * 
 */
      __pyx_v_sax->startElementNs = __pyx_f_4lxml_5etree__handleSaxStart;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":65
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 *                 sax.startElementNs = _handleSaxStart
 *             sax.startElement = _handleSaxStartNoNs             # <<<<<<<<<<<<<<
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_END:
 */
    __pyx_v_sax->startElement = __pyx_f_4lxml_5etree__handleSaxStartNoNs;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":67
 *             sax.startElement = _handleSaxStartNoNs
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_END:             # <<<<<<<<<<<<<<
 *             self._origSaxEnd = sax.endElementNs
 *             self._origSaxEndNoNs = sax.endElement
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_propagate & __pyx_e_4lxml_5etree_SAX_EVENT_END);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":68
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_END:
 *             self._origSaxEnd = sax.endElementNs             # <<<<<<<<<<<<<<
 *             self._origSaxEndNoNs = sax.endElement
 *         else:
 */
    __pyx_v_self->_origSaxEnd = __pyx_v_sax->endElementNs;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":69
 *         if self._target._sax_event_propagate & SAX_EVENT_END:
 *             self._origSaxEnd = sax.endElementNs
 *             self._origSaxEndNoNs = sax.endElement             # <<<<<<<<<<<<<<
 *         else:
 *             self._origSaxEnd = sax.endElementNs = NULL
 */
    __pyx_v_self->_origSaxEndNoNs = __pyx_v_sax->endElement;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":71
 *             self._origSaxEndNoNs = sax.endElement
 *         else:
 *             self._origSaxEnd = sax.endElementNs = NULL             # <<<<<<<<<<<<<<
 *             self._origSaxEndNoNs = sax.endElement = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_END:
 */
    __pyx_v_self->_origSaxEnd = NULL;
    __pyx_v_sax->endElementNs = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":72
 *         else:
 *             self._origSaxEnd = sax.endElementNs = NULL
 *             self._origSaxEndNoNs = sax.endElement = NULL             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_filter & SAX_EVENT_END:
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 */
    __pyx_v_self->_origSaxEndNoNs = NULL;
    __pyx_v_sax->endElement = NULL;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":73
 *             self._origSaxEnd = sax.endElementNs = NULL
 *             self._origSaxEndNoNs = sax.endElement = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_END:             # <<<<<<<<<<<<<<
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 *                 sax.endElementNs = _handleSaxEnd
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_filter & __pyx_e_4lxml_5etree_SAX_EVENT_END);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":74
 *             self._origSaxEndNoNs = sax.endElement = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_END:
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:             # <<<<<<<<<<<<<<
 *                 sax.endElementNs = _handleSaxEnd
 *             sax.endElement = _handleSaxEndNoNs
 */
    __pyx_2 = (__pyx_v_sax->initialized == XML_SAX2_MAGIC);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":75
 *         if self._target._sax_event_filter & SAX_EVENT_END:
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 *                 sax.endElementNs = _handleSaxEnd             # <<<<<<<<<<<<<<
 *             sax.endElement = _handleSaxEndNoNs
 * 
 */
      __pyx_v_sax->endElementNs = __pyx_f_4lxml_5etree__handleSaxEnd;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":76
 *             if sax.initialized == xmlparser.XML_SAX2_MAGIC:
 *                 sax.endElementNs = _handleSaxEnd
 *             sax.endElement = _handleSaxEndNoNs             # <<<<<<<<<<<<<<
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_DATA:
 */
    __pyx_v_sax->endElement = __pyx_f_4lxml_5etree__handleSaxEndNoNs;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":78
 *             sax.endElement = _handleSaxEndNoNs
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_DATA:             # <<<<<<<<<<<<<<
 *             self._origSaxData = sax.characters
 *             self._origSaxCData = sax.cdataBlock
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_propagate & __pyx_e_4lxml_5etree_SAX_EVENT_DATA);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":79
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_DATA:
 *             self._origSaxData = sax.characters             # <<<<<<<<<<<<<<
 *             self._origSaxCData = sax.cdataBlock
 *         else:
 */
    __pyx_v_self->_origSaxData = __pyx_v_sax->characters;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":80
 *         if self._target._sax_event_propagate & SAX_EVENT_DATA:
 *             self._origSaxData = sax.characters
 *             self._origSaxCData = sax.cdataBlock             # <<<<<<<<<<<<<<
 *         else:
 *             self._origSaxData = sax.characters = sax.cdataBlock = NULL
 */
    __pyx_v_self->_origSaxCData = __pyx_v_sax->cdataBlock;
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":82
 *             self._origSaxCData = sax.cdataBlock
 *         else:
 *             self._origSaxData = sax.characters = sax.cdataBlock = NULL             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_filter & SAX_EVENT_DATA:
 *             sax.characters = _handleSaxData
 */
    __pyx_v_self->_origSaxData = NULL;
    __pyx_v_sax->characters = NULL;
    __pyx_v_sax->cdataBlock = NULL;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":83
 *         else:
 *             self._origSaxData = sax.characters = sax.cdataBlock = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_DATA:             # <<<<<<<<<<<<<<
 *             sax.characters = _handleSaxData
 *             sax.cdataBlock = _handleSaxCData
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_filter & __pyx_e_4lxml_5etree_SAX_EVENT_DATA);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":84
 *             self._origSaxData = sax.characters = sax.cdataBlock = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_DATA:
 *             sax.characters = _handleSaxData             # <<<<<<<<<<<<<<
 *             sax.cdataBlock = _handleSaxCData
 * 
 */
    __pyx_v_sax->characters = __pyx_f_4lxml_5etree__handleSaxData;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":85
 *         if self._target._sax_event_filter & SAX_EVENT_DATA:
 *             sax.characters = _handleSaxData
 *             sax.cdataBlock = _handleSaxCData             # <<<<<<<<<<<<<<
 * 
 *         # doctype propagation is always required for entity replacement
 */
    __pyx_v_sax->cdataBlock = __pyx_f_4lxml_5etree__handleSaxCData;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":88
 * 
 *         # doctype propagation is always required for entity replacement
 *         self._origSaxDoctype = sax.internalSubset             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_filter & SAX_EVENT_DOCTYPE:
 *             sax.internalSubset = _handleSaxDoctype
 */
  __pyx_v_self->_origSaxDoctype = __pyx_v_sax->internalSubset;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":89
 *         # doctype propagation is always required for entity replacement
 *         self._origSaxDoctype = sax.internalSubset
 *         if self._target._sax_event_filter & SAX_EVENT_DOCTYPE:             # <<<<<<<<<<<<<<
 *             sax.internalSubset = _handleSaxDoctype
 * 
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_filter & __pyx_e_4lxml_5etree_SAX_EVENT_DOCTYPE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":90
 *         self._origSaxDoctype = sax.internalSubset
 *         if self._target._sax_event_filter & SAX_EVENT_DOCTYPE:
 *             sax.internalSubset = _handleSaxDoctype             # <<<<<<<<<<<<<<
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_PI:
 */
    __pyx_v_sax->internalSubset = __pyx_f_4lxml_5etree__handleSaxDoctype;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":92
 *             sax.internalSubset = _handleSaxDoctype
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_PI:             # <<<<<<<<<<<<<<
 *             self._origSaxPi = sax.processingInstruction
 *         else:
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_propagate & __pyx_e_4lxml_5etree_SAX_EVENT_PI);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":93
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_PI:
 *             self._origSaxPi = sax.processingInstruction             # <<<<<<<<<<<<<<
 *         else:
 *             self._origSaxPi = sax.processingInstruction = NULL
 */
    __pyx_v_self->_origSaxPi = __pyx_v_sax->processingInstruction;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":95
 *             self._origSaxPi = sax.processingInstruction
 *         else:
 *             self._origSaxPi = sax.processingInstruction = NULL             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_filter & SAX_EVENT_PI:
 *             sax.processingInstruction = _handleSaxPI
 */
    __pyx_v_self->_origSaxPi = NULL;
    __pyx_v_sax->processingInstruction = NULL;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":96
 *         else:
 *             self._origSaxPi = sax.processingInstruction = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_PI:             # <<<<<<<<<<<<<<
 *             sax.processingInstruction = _handleSaxPI
 * 
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_filter & __pyx_e_4lxml_5etree_SAX_EVENT_PI);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":97
 *             self._origSaxPi = sax.processingInstruction = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_PI:
 *             sax.processingInstruction = _handleSaxPI             # <<<<<<<<<<<<<<
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_COMMENT:
 */
    __pyx_v_sax->processingInstruction = __pyx_f_4lxml_5etree__handleSaxPI;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":99
 *             sax.processingInstruction = _handleSaxPI
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_COMMENT:             # <<<<<<<<<<<<<<
 *             self._origSaxComment = sax.comment
 *         else:
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_propagate & __pyx_e_4lxml_5etree_SAX_EVENT_COMMENT);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":100
 * 
 *         if self._target._sax_event_propagate & SAX_EVENT_COMMENT:
 *             self._origSaxComment = sax.comment             # <<<<<<<<<<<<<<
 *         else:
 *             self._origSaxComment = sax.comment = NULL
 */
    __pyx_v_self->_origSaxComment = __pyx_v_sax->comment;
    goto __pyx_L14;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":102
 *             self._origSaxComment = sax.comment
 *         else:
 *             self._origSaxComment = sax.comment = NULL             # <<<<<<<<<<<<<<
 *         if self._target._sax_event_filter & SAX_EVENT_COMMENT:
 *             sax.comment = _handleSaxComment
 */
    __pyx_v_self->_origSaxComment = NULL;
    __pyx_v_sax->comment = NULL;
  }
  __pyx_L14:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":103
 *         else:
 *             self._origSaxComment = sax.comment = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_COMMENT:             # <<<<<<<<<<<<<<
 *             sax.comment = _handleSaxComment
 * 
 */
  __pyx_1 = (__pyx_v_self->_target->_sax_event_filter & __pyx_e_4lxml_5etree_SAX_EVENT_COMMENT);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":104
 *             self._origSaxComment = sax.comment = NULL
 *         if self._target._sax_event_filter & SAX_EVENT_COMMENT:
 *             sax.comment = _handleSaxComment             # <<<<<<<<<<<<<<
 * 
 *         # enforce entity replacement
 */
    __pyx_v_sax->comment = __pyx_f_4lxml_5etree__handleSaxComment;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":107
 * 
 *         # enforce entity replacement
 *         sax.reference = NULL             # <<<<<<<<<<<<<<
 *         c_ctxt.replaceEntities = 1
 * 
 */
  __pyx_v_sax->reference = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":108
 *         # enforce entity replacement
 *         sax.reference = NULL
 *         c_ctxt.replaceEntities = 1             # <<<<<<<<<<<<<<
 * 
 *     cdef void _handleSaxException(self, xmlparser.xmlParserCtxt* c_ctxt):
 */
  __pyx_v_c_ctxt->replaceEntities = 1;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":110
 *         c_ctxt.replaceEntities = 1
 * 
 *     cdef void _handleSaxException(self, xmlparser.xmlParserCtxt* c_ctxt):             # <<<<<<<<<<<<<<
 *         self._store_raised()
 *         if c_ctxt.errNo == xmlerror.XML_ERR_OK:
 */

static  void __pyx_f_4lxml_5etree_17_SaxParserContext__handleSaxException(struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_self, xmlParserCtxt *__pyx_v_c_ctxt) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":111
 * 
 *     cdef void _handleSaxException(self, xmlparser.xmlParserCtxt* c_ctxt):
 *         self._store_raised()             # <<<<<<<<<<<<<<
 *         if c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.__pyx_base._store_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_self));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":112
 *     cdef void _handleSaxException(self, xmlparser.xmlParserCtxt* c_ctxt):
 *         self._store_raised()
 *         if c_ctxt.errNo == xmlerror.XML_ERR_OK:             # <<<<<<<<<<<<<<
 *             c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         c_ctxt.disableSAX = 1
 */
  __pyx_1 = (__pyx_v_c_ctxt->errNo == XML_ERR_OK);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":113
 *         self._store_raised()
 *         if c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR             # <<<<<<<<<<<<<<
 *         c_ctxt.disableSAX = 1
 * 
 */
    __pyx_v_c_ctxt->errNo = XML_ERR_INTERNAL_ERROR;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":114
 *         if c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         c_ctxt.disableSAX = 1             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxStart(void* ctxt, char* c_localname, char* c_prefix,
 */
  __pyx_v_c_ctxt->disableSAX = 1;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":116
 *         c_ctxt.disableSAX = 1
 * 
 * cdef void _handleSaxStart(void* ctxt, char* c_localname, char* c_prefix,             # <<<<<<<<<<<<<<
 *                           char* c_namespace, int c_nb_namespaces,
 *                           char** c_namespaces,
 */

static  void __pyx_f_4lxml_5etree__handleSaxStart(void *__pyx_v_ctxt, char *__pyx_v_c_localname, char *__pyx_v_c_prefix, char *__pyx_v_c_namespace, int __pyx_v_c_nb_namespaces, char **__pyx_v_c_namespaces, int __pyx_v_c_nb_attributes, int __pyx_v_c_nb_defaulted, char **__pyx_v_c_attributes) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct LxmlElement *__pyx_v_element;
  int __pyx_v_i;
  PyObject *__pyx_v_tag;
  PyObject *__pyx_v_attrib;
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_nsmap;
  PyObject *__pyx_v_prefix;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);
  __pyx_v_attrib = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);
  __pyx_v_nsmap = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":125
 *     cdef _Element element
 *     cdef int i
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":126
 *     cdef int i
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":127
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxStart is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":128
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxStart is not NULL:
 *         context._origSaxStart(c_ctxt, c_localname, c_prefix, c_namespace,
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":129
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxStart is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxStart(c_ctxt, c_localname, c_prefix, c_namespace,
 *                               c_nb_namespaces, c_namespaces, c_nb_attributes,
 */
  __pyx_1 = (__pyx_v_context->_origSaxStart != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":132
 *         context._origSaxStart(c_ctxt, c_localname, c_prefix, c_namespace,
 *                               c_nb_namespaces, c_namespaces, c_nb_attributes,
 *                               c_nb_defaulted, c_attributes)             # <<<<<<<<<<<<<<
 *     try:
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 */
    __pyx_v_context->_origSaxStart(__pyx_v_c_ctxt, __pyx_v_c_localname, __pyx_v_c_prefix, __pyx_v_c_namespace, __pyx_v_c_nb_namespaces, __pyx_v_c_namespaces, __pyx_v_c_nb_attributes, __pyx_v_c_nb_defaulted, __pyx_v_c_attributes);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":133
 *                               c_nb_namespaces, c_namespaces, c_nb_attributes,
 *                               c_nb_defaulted, c_attributes)
 *     try:             # <<<<<<<<<<<<<<
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 *         if c_nb_defaulted > 0:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":134
 *                               c_nb_defaulted, c_attributes)
 *     try:
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)             # <<<<<<<<<<<<<<
 *         if c_nb_defaulted > 0:
 *             # only add default attributes if we asked for them
 */
      __pyx_2 = __pyx_f_4lxml_5etree__namespacedNameFromNsName(__pyx_v_c_namespace, __pyx_v_c_localname); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_v_tag);
      __pyx_v_tag = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":135
 *     try:
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 *         if c_nb_defaulted > 0:             # <<<<<<<<<<<<<<
 *             # only add default attributes if we asked for them
 *             if c_ctxt.loadsubset & xmlparser.XML_COMPLETE_ATTRS == 0:
 */
      __pyx_1 = (__pyx_v_c_nb_defaulted > 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":137
 *         if c_nb_defaulted > 0:
 *             # only add default attributes if we asked for them
 *             if c_ctxt.loadsubset & xmlparser.XML_COMPLETE_ATTRS == 0:             # <<<<<<<<<<<<<<
 *                 c_nb_attributes = c_nb_attributes - c_nb_defaulted
 *         if c_nb_attributes == 0:
 */
        __pyx_1 = ((__pyx_v_c_ctxt->loadsubset & XML_COMPLETE_ATTRS) == 0);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":138
 *             # only add default attributes if we asked for them
 *             if c_ctxt.loadsubset & xmlparser.XML_COMPLETE_ATTRS == 0:
 *                 c_nb_attributes = c_nb_attributes - c_nb_defaulted             # <<<<<<<<<<<<<<
 *         if c_nb_attributes == 0:
 *             attrib = EMPTY_READ_ONLY_DICT
 */
          __pyx_v_c_nb_attributes = (__pyx_v_c_nb_attributes - __pyx_v_c_nb_defaulted);
          goto __pyx_L11;
        }
        __pyx_L11:;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":139
 *             if c_ctxt.loadsubset & xmlparser.XML_COMPLETE_ATTRS == 0:
 *                 c_nb_attributes = c_nb_attributes - c_nb_defaulted
 *         if c_nb_attributes == 0:             # <<<<<<<<<<<<<<
 *             attrib = EMPTY_READ_ONLY_DICT
 *         else:
 */
      __pyx_1 = (__pyx_v_c_nb_attributes == 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":140
 *                 c_nb_attributes = c_nb_attributes - c_nb_defaulted
 *         if c_nb_attributes == 0:
 *             attrib = EMPTY_READ_ONLY_DICT             # <<<<<<<<<<<<<<
 *         else:
 *             attrib = {}
 */
        Py_INCREF(__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
        Py_DECREF(__pyx_v_attrib);
        __pyx_v_attrib = __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT;
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":142
 *             attrib = EMPTY_READ_ONLY_DICT
 *         else:
 *             attrib = {}             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < c_nb_attributes:
 *                 name = _namespacedNameFromNsName(
 */
        __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_attrib);
        __pyx_v_attrib = ((PyObject *)__pyx_2);
        __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":143
 *         else:
 *             attrib = {}
 *             for i from 0 <= i < c_nb_attributes:             # <<<<<<<<<<<<<<
 *                 name = _namespacedNameFromNsName(
 *                     c_attributes[2], c_attributes[0])
 */
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_c_nb_attributes; __pyx_v_i++) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":145
 *             for i from 0 <= i < c_nb_attributes:
 *                 name = _namespacedNameFromNsName(
 *                     c_attributes[2], c_attributes[0])             # <<<<<<<<<<<<<<
 *                 if c_attributes[3] is NULL:
 *                     if python.IS_PYTHON3:
 */
          __pyx_2 = __pyx_f_4lxml_5etree__namespacedNameFromNsName((__pyx_v_c_attributes[2]), (__pyx_v_c_attributes[0])); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          Py_DECREF(__pyx_v_name);
          __pyx_v_name = __pyx_2;
          __pyx_2 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":146
 *                 name = _namespacedNameFromNsName(
 *                     c_attributes[2], c_attributes[0])
 *                 if c_attributes[3] is NULL:             # <<<<<<<<<<<<<<
 *                     if python.IS_PYTHON3:
 *                         value = u''
 */
          __pyx_1 = ((__pyx_v_c_attributes[3]) == NULL);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":147
 *                     c_attributes[2], c_attributes[0])
 *                 if c_attributes[3] is NULL:
 *                     if python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *                         value = u''
 *                     else:
 */
            __pyx_1 = IS_PYTHON3;
            if (__pyx_1) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":148
 *                 if c_attributes[3] is NULL:
 *                     if python.IS_PYTHON3:
 *                         value = u''             # <<<<<<<<<<<<<<
 *                     else:
 *                         value = ''
 */
              Py_INCREF(((PyObject *)__pyx_kp_438));
              Py_DECREF(__pyx_v_value);
              __pyx_v_value = ((PyObject *)__pyx_kp_438);
              goto __pyx_L16;
            }
            /*else*/ {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":150
 *                         value = u''
 *                     else:
 *                         value = ''             # <<<<<<<<<<<<<<
 *                 else:
 *                     value = python.PyUnicode_DecodeUTF8(
 */
              Py_INCREF(__pyx_kp_439);
              Py_DECREF(__pyx_v_value);
              __pyx_v_value = __pyx_kp_439;
            }
            __pyx_L16:;
            goto __pyx_L15;
          }
          /*else*/ {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":154
 *                     value = python.PyUnicode_DecodeUTF8(
 *                         c_attributes[3], c_attributes[4] - c_attributes[3],
 *                         "strict")             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(attrib, name, value)
 *                 c_attributes += 5
 */
            __pyx_2 = PyUnicode_DecodeUTF8((__pyx_v_c_attributes[3]), ((__pyx_v_c_attributes[4]) - (__pyx_v_c_attributes[3])), __pyx_k_440); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_v_value);
            __pyx_v_value = __pyx_2;
            __pyx_2 = 0;
          }
          __pyx_L15:;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":155
 *                         c_attributes[3], c_attributes[4] - c_attributes[3],
 *                         "strict")
 *                 python.PyDict_SetItem(attrib, name, value)             # <<<<<<<<<<<<<<
 *                 c_attributes += 5
 *         if c_nb_namespaces == 0:
 */
          __pyx_3 = PyDict_SetItem(__pyx_v_attrib, __pyx_v_name, __pyx_v_value); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_error;}

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":156
 *                         "strict")
 *                 python.PyDict_SetItem(attrib, name, value)
 *                 c_attributes += 5             # <<<<<<<<<<<<<<
 *         if c_nb_namespaces == 0:
 *             nsmap = EMPTY_READ_ONLY_DICT
 */
          __pyx_v_c_attributes += 5;
        }
      }
      __pyx_L12:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":157
 *                 python.PyDict_SetItem(attrib, name, value)
 *                 c_attributes += 5
 *         if c_nb_namespaces == 0:             # <<<<<<<<<<<<<<
 *             nsmap = EMPTY_READ_ONLY_DICT
 *         else:
 */
      __pyx_1 = (__pyx_v_c_nb_namespaces == 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":158
 *                 c_attributes += 5
 *         if c_nb_namespaces == 0:
 *             nsmap = EMPTY_READ_ONLY_DICT             # <<<<<<<<<<<<<<
 *         else:
 *             nsmap = {}
 */
        Py_INCREF(__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
        Py_DECREF(__pyx_v_nsmap);
        __pyx_v_nsmap = __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT;
        goto __pyx_L17;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":160
 *             nsmap = EMPTY_READ_ONLY_DICT
 *         else:
 *             nsmap = {}             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < c_nb_namespaces:
 *                 if c_namespaces[0] is NULL:
 */
        __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_nsmap);
        __pyx_v_nsmap = ((PyObject *)__pyx_2);
        __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":161
 *         else:
 *             nsmap = {}
 *             for i from 0 <= i < c_nb_namespaces:             # <<<<<<<<<<<<<<
 *                 if c_namespaces[0] is NULL:
 *                     prefix = None
 */
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_c_nb_namespaces; __pyx_v_i++) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":162
 *             nsmap = {}
 *             for i from 0 <= i < c_nb_namespaces:
 *                 if c_namespaces[0] is NULL:             # <<<<<<<<<<<<<<
 *                     prefix = None
 *                 else:
 */
          __pyx_1 = ((__pyx_v_c_namespaces[0]) == NULL);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":163
 *             for i from 0 <= i < c_nb_namespaces:
 *                 if c_namespaces[0] is NULL:
 *                     prefix = None             # <<<<<<<<<<<<<<
 *                 else:
 *                     prefix = funicode(c_namespaces[0])
 */
            Py_INCREF(Py_None);
            Py_DECREF(__pyx_v_prefix);
            __pyx_v_prefix = Py_None;
            goto __pyx_L20;
          }
          /*else*/ {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":165
 *                     prefix = None
 *                 else:
 *                     prefix = funicode(c_namespaces[0])             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(
 *                     nsmap, prefix, funicode(c_namespaces[1]))
 */
            __pyx_2 = __pyx_f_4lxml_5etree_funicode((__pyx_v_c_namespaces[0])); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_v_prefix);
            __pyx_v_prefix = __pyx_2;
            __pyx_2 = 0;
          }
          __pyx_L20:;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":167
 *                     prefix = funicode(c_namespaces[0])
 *                 python.PyDict_SetItem(
 *                     nsmap, prefix, funicode(c_namespaces[1]))             # <<<<<<<<<<<<<<
 *                 c_namespaces += 2
 *         element = context._target._handleSaxStart(tag, attrib, nsmap)
 */
          __pyx_2 = __pyx_f_4lxml_5etree_funicode((__pyx_v_c_namespaces[1])); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_3 = PyDict_SetItem(__pyx_v_nsmap, __pyx_v_prefix, __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":168
 *                 python.PyDict_SetItem(
 *                     nsmap, prefix, funicode(c_namespaces[1]))
 *                 c_namespaces += 2             # <<<<<<<<<<<<<<
 *         element = context._target._handleSaxStart(tag, attrib, nsmap)
 *         if element is not None and c_ctxt.input is not NULL:
 */
          __pyx_v_c_namespaces += 2;
        }
      }
      __pyx_L17:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":169
 *                     nsmap, prefix, funicode(c_namespaces[1]))
 *                 c_namespaces += 2
 *         element = context._target._handleSaxStart(tag, attrib, nsmap)             # <<<<<<<<<<<<<<
 *         if element is not None and c_ctxt.input is not NULL:
 *             if c_ctxt.input.line < 65535:
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxStart(__pyx_v_context->_target, __pyx_v_tag, __pyx_v_attrib, __pyx_v_nsmap); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_2);
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":170
 *                 c_namespaces += 2
 *         element = context._target._handleSaxStart(tag, attrib, nsmap)
 *         if element is not None and c_ctxt.input is not NULL:             # <<<<<<<<<<<<<<
 *             if c_ctxt.input.line < 65535:
 *                 element._c_node.line = <short>c_ctxt.input.line
 */
      __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c_ctxt->input != NULL);
      }
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":171
 *         element = context._target._handleSaxStart(tag, attrib, nsmap)
 *         if element is not None and c_ctxt.input is not NULL:
 *             if c_ctxt.input.line < 65535:             # <<<<<<<<<<<<<<
 *                 element._c_node.line = <short>c_ctxt.input.line
 *             else:
 */
        __pyx_1 = (__pyx_v_c_ctxt->input->line < 65535);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":172
 *         if element is not None and c_ctxt.input is not NULL:
 *             if c_ctxt.input.line < 65535:
 *                 element._c_node.line = <short>c_ctxt.input.line             # <<<<<<<<<<<<<<
 *             else:
 *                 element._c_node.line = 65535
 */
          __pyx_v_element->_c_node->line = ((short)__pyx_v_c_ctxt->input->line);
          goto __pyx_L22;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":174
 *                 element._c_node.line = <short>c_ctxt.input.line
 *             else:
 *                 element._c_node.line = 65535             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
          __pyx_v_element->_c_node->line = 65535;
        }
        __pyx_L22:;
        goto __pyx_L21;
      }
      __pyx_L21:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":175
 *             else:
 *                 element._c_node.line = 65535
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxStart");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":176
 *                 element._c_node.line = 65535
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxStartNoNs(void* ctxt, char* c_name,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxStart");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_element);
  Py_DECREF(__pyx_v_tag);
  Py_DECREF(__pyx_v_attrib);
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_nsmap);
  Py_DECREF(__pyx_v_prefix);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":178
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxStartNoNs(void* ctxt, char* c_name,             # <<<<<<<<<<<<<<
 *                               char** c_attributes) with gil:
 *     cdef _SaxParserContext context
 */

static  void __pyx_f_4lxml_5etree__handleSaxStartNoNs(void *__pyx_v_ctxt, char *__pyx_v_c_name, char **__pyx_v_c_attributes) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct LxmlElement *__pyx_v_element;
  PyObject *__pyx_v_tag;
  PyObject *__pyx_v_attrib;
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_value;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);
  __pyx_v_attrib = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":183
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _Element element
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":184
 *     cdef _Element element
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":185
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxStartNoNs is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":186
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxStartNoNs is not NULL:
 *         context._origSaxStartNoNs(c_ctxt, c_name, c_attributes)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":187
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxStartNoNs is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxStartNoNs(c_ctxt, c_name, c_attributes)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxStartNoNs != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":188
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxStartNoNs is not NULL:
 *         context._origSaxStartNoNs(c_ctxt, c_name, c_attributes)             # <<<<<<<<<<<<<<
 *     try:
 *         tag = funicode(c_name)
 */
    __pyx_v_context->_origSaxStartNoNs(__pyx_v_c_ctxt, __pyx_v_c_name, __pyx_v_c_attributes);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":189
 *     if context._origSaxStartNoNs is not NULL:
 *         context._origSaxStartNoNs(c_ctxt, c_name, c_attributes)
 *     try:             # <<<<<<<<<<<<<<
 *         tag = funicode(c_name)
 *         if c_attributes is NULL:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":190
 *         context._origSaxStartNoNs(c_ctxt, c_name, c_attributes)
 *     try:
 *         tag = funicode(c_name)             # <<<<<<<<<<<<<<
 *         if c_attributes is NULL:
 *             attrib = EMPTY_READ_ONLY_DICT
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_v_tag);
      __pyx_v_tag = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":191
 *     try:
 *         tag = funicode(c_name)
 *         if c_attributes is NULL:             # <<<<<<<<<<<<<<
 *             attrib = EMPTY_READ_ONLY_DICT
 *         else:
 */
      __pyx_1 = (__pyx_v_c_attributes == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":192
 *         tag = funicode(c_name)
 *         if c_attributes is NULL:
 *             attrib = EMPTY_READ_ONLY_DICT             # <<<<<<<<<<<<<<
 *         else:
 *             attrib = {}
 */
        Py_INCREF(__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
        Py_DECREF(__pyx_v_attrib);
        __pyx_v_attrib = __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT;
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":194
 *             attrib = EMPTY_READ_ONLY_DICT
 *         else:
 *             attrib = {}             # <<<<<<<<<<<<<<
 *             while c_attributes[0] is not NULL:
 *                 name = funicode(c_attributes[0])
 */
        __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_attrib);
        __pyx_v_attrib = ((PyObject *)__pyx_2);
        __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":195
 *         else:
 *             attrib = {}
 *             while c_attributes[0] is not NULL:             # <<<<<<<<<<<<<<
 *                 name = funicode(c_attributes[0])
 *                 if c_attributes[1] is NULL:
 */
        while (1) {
          __pyx_1 = ((__pyx_v_c_attributes[0]) != NULL);
          if (!__pyx_1) break;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":196
 *             attrib = {}
 *             while c_attributes[0] is not NULL:
 *                 name = funicode(c_attributes[0])             # <<<<<<<<<<<<<<
 *                 if c_attributes[1] is NULL:
 *                     if python.IS_PYTHON3:
 */
          __pyx_2 = __pyx_f_4lxml_5etree_funicode((__pyx_v_c_attributes[0])); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          Py_DECREF(__pyx_v_name);
          __pyx_v_name = __pyx_2;
          __pyx_2 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":197
 *             while c_attributes[0] is not NULL:
 *                 name = funicode(c_attributes[0])
 *                 if c_attributes[1] is NULL:             # <<<<<<<<<<<<<<
 *                     if python.IS_PYTHON3:
 *                         value = u''
 */
          __pyx_1 = ((__pyx_v_c_attributes[1]) == NULL);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":198
 *                 name = funicode(c_attributes[0])
 *                 if c_attributes[1] is NULL:
 *                     if python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *                         value = u''
 *                     else:
 */
            __pyx_1 = IS_PYTHON3;
            if (__pyx_1) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":199
 *                 if c_attributes[1] is NULL:
 *                     if python.IS_PYTHON3:
 *                         value = u''             # <<<<<<<<<<<<<<
 *                     else:
 *                         value = ''
 */
              Py_INCREF(((PyObject *)__pyx_kp_441));
              Py_DECREF(__pyx_v_value);
              __pyx_v_value = ((PyObject *)__pyx_kp_441);
              goto __pyx_L14;
            }
            /*else*/ {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":201
 *                         value = u''
 *                     else:
 *                         value = ''             # <<<<<<<<<<<<<<
 *                 else:
 *                     value = funicode(c_attributes[1])
 */
              Py_INCREF(__pyx_kp_442);
              Py_DECREF(__pyx_v_value);
              __pyx_v_value = __pyx_kp_442;
            }
            __pyx_L14:;
            goto __pyx_L13;
          }
          /*else*/ {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":203
 *                         value = ''
 *                 else:
 *                     value = funicode(c_attributes[1])             # <<<<<<<<<<<<<<
 *                 c_attributes = c_attributes + 2
 *                 python.PyDict_SetItem(attrib, name, value)
 */
            __pyx_2 = __pyx_f_4lxml_5etree_funicode((__pyx_v_c_attributes[1])); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_v_value);
            __pyx_v_value = __pyx_2;
            __pyx_2 = 0;
          }
          __pyx_L13:;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":204
 *                 else:
 *                     value = funicode(c_attributes[1])
 *                 c_attributes = c_attributes + 2             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(attrib, name, value)
 *         element = context._target._handleSaxStart(
 */
          __pyx_v_c_attributes = (__pyx_v_c_attributes + 2);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":205
 *                     value = funicode(c_attributes[1])
 *                 c_attributes = c_attributes + 2
 *                 python.PyDict_SetItem(attrib, name, value)             # <<<<<<<<<<<<<<
 *         element = context._target._handleSaxStart(
 *             tag, attrib, EMPTY_READ_ONLY_DICT)
 */
          __pyx_3 = PyDict_SetItem(__pyx_v_attrib, __pyx_v_name, __pyx_v_value); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        }
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":207
 *                 python.PyDict_SetItem(attrib, name, value)
 *         element = context._target._handleSaxStart(
 *             tag, attrib, EMPTY_READ_ONLY_DICT)             # <<<<<<<<<<<<<<
 *         if element is not None and c_ctxt.input is not NULL:
 *             if c_ctxt.input.line < 65535:
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxStart(__pyx_v_context->_target, __pyx_v_tag, __pyx_v_attrib, __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(((PyObject *)__pyx_v_element));
      __pyx_v_element = ((struct LxmlElement *)__pyx_2);
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":208
 *         element = context._target._handleSaxStart(
 *             tag, attrib, EMPTY_READ_ONLY_DICT)
 *         if element is not None and c_ctxt.input is not NULL:             # <<<<<<<<<<<<<<
 *             if c_ctxt.input.line < 65535:
 *                 element._c_node.line = <short>c_ctxt.input.line
 */
      __pyx_1 = (((PyObject *)__pyx_v_element) != Py_None);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c_ctxt->input != NULL);
      }
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":209
 *             tag, attrib, EMPTY_READ_ONLY_DICT)
 *         if element is not None and c_ctxt.input is not NULL:
 *             if c_ctxt.input.line < 65535:             # <<<<<<<<<<<<<<
 *                 element._c_node.line = <short>c_ctxt.input.line
 *             else:
 */
        __pyx_1 = (__pyx_v_c_ctxt->input->line < 65535);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":210
 *         if element is not None and c_ctxt.input is not NULL:
 *             if c_ctxt.input.line < 65535:
 *                 element._c_node.line = <short>c_ctxt.input.line             # <<<<<<<<<<<<<<
 *             else:
 *                 element._c_node.line = 65535
 */
          __pyx_v_element->_c_node->line = ((short)__pyx_v_c_ctxt->input->line);
          goto __pyx_L16;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":212
 *                 element._c_node.line = <short>c_ctxt.input.line
 *             else:
 *                 element._c_node.line = 65535             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
          __pyx_v_element->_c_node->line = 65535;
        }
        __pyx_L16:;
        goto __pyx_L15;
      }
      __pyx_L15:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":213
 *             else:
 *                 element._c_node.line = 65535
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxStartNoNs");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":214
 *                 element._c_node.line = 65535
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxEnd(void* ctxt, char* c_localname, char* c_prefix,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxStartNoNs");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_element);
  Py_DECREF(__pyx_v_tag);
  Py_DECREF(__pyx_v_attrib);
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_value);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":216
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxEnd(void* ctxt, char* c_localname, char* c_prefix,             # <<<<<<<<<<<<<<
 *                         char* c_namespace) with gil:
 *     cdef _SaxParserContext context
 */

static  void __pyx_f_4lxml_5etree__handleSaxEnd(void *__pyx_v_ctxt, char *__pyx_v_c_localname, char *__pyx_v_c_prefix, char *__pyx_v_c_namespace) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  PyObject *__pyx_v_tag;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_tag = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":220
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":221
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":222
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxEnd is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":223
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxEnd is not NULL:
 *         context._origSaxEnd(c_ctxt, c_localname, c_prefix, c_namespace)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":224
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxEnd is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxEnd(c_ctxt, c_localname, c_prefix, c_namespace)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxEnd != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":225
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxEnd is not NULL:
 *         context._origSaxEnd(c_ctxt, c_localname, c_prefix, c_namespace)             # <<<<<<<<<<<<<<
 *     try:
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 */
    __pyx_v_context->_origSaxEnd(__pyx_v_c_ctxt, __pyx_v_c_localname, __pyx_v_c_prefix, __pyx_v_c_namespace);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":226
 *     if context._origSaxEnd is not NULL:
 *         context._origSaxEnd(c_ctxt, c_localname, c_prefix, c_namespace)
 *     try:             # <<<<<<<<<<<<<<
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 *         context._target._handleSaxEnd(tag)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":227
 *         context._origSaxEnd(c_ctxt, c_localname, c_prefix, c_namespace)
 *     try:
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)             # <<<<<<<<<<<<<<
 *         context._target._handleSaxEnd(tag)
 *     except:
 */
      __pyx_2 = __pyx_f_4lxml_5etree__namespacedNameFromNsName(__pyx_v_c_namespace, __pyx_v_c_localname); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_v_tag);
      __pyx_v_tag = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":228
 *     try:
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 *         context._target._handleSaxEnd(tag)             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxEnd(__pyx_v_context->_target, __pyx_v_tag); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":229
 *         tag = _namespacedNameFromNsName(c_namespace, c_localname)
 *         context._target._handleSaxEnd(tag)
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxEnd");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":230
 *         context._target._handleSaxEnd(tag)
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxEndNoNs(void* ctxt, char* c_name) with gil:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxEnd");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_tag);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":232
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxEndNoNs(void* ctxt, char* c_name) with gil:             # <<<<<<<<<<<<<<
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__handleSaxEndNoNs(void *__pyx_v_ctxt, char *__pyx_v_c_name) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":235
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":236
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":237
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxEndNoNs is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":238
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxEndNoNs is not NULL:
 *         context._origSaxEndNoNs(c_ctxt, c_name)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":239
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxEndNoNs is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxEndNoNs(c_ctxt, c_name)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxEndNoNs != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":240
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxEndNoNs is not NULL:
 *         context._origSaxEndNoNs(c_ctxt, c_name)             # <<<<<<<<<<<<<<
 *     try:
 *         context._target._handleSaxEnd(funicode(c_name))
 */
    __pyx_v_context->_origSaxEndNoNs(__pyx_v_c_ctxt, __pyx_v_c_name);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":241
 *     if context._origSaxEndNoNs is not NULL:
 *         context._origSaxEndNoNs(c_ctxt, c_name)
 *     try:             # <<<<<<<<<<<<<<
 *         context._target._handleSaxEnd(funicode(c_name))
 *     except:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":242
 *         context._origSaxEndNoNs(c_ctxt, c_name)
 *     try:
 *         context._target._handleSaxEnd(funicode(c_name))             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxEnd(__pyx_v_context->_target, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":243
 *     try:
 *         context._target._handleSaxEnd(funicode(c_name))
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxEndNoNs");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":244
 *         context._target._handleSaxEnd(funicode(c_name))
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxData(void* ctxt, char* c_data, int data_len) with gil:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxEndNoNs");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":246
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxData(void* ctxt, char* c_data, int data_len) with gil:             # <<<<<<<<<<<<<<
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__handleSaxData(void *__pyx_v_ctxt, char *__pyx_v_c_data, int __pyx_v_data_len) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":249
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":250
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":251
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxData is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":252
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxData is not NULL:
 *         context._origSaxData(c_ctxt, c_data, data_len)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":253
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxData is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxData(c_ctxt, c_data, data_len)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxData != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":254
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxData is not NULL:
 *         context._origSaxData(c_ctxt, c_data, data_len)             # <<<<<<<<<<<<<<
 *     try:
 *         context._target._handleSaxData(
 */
    __pyx_v_context->_origSaxData(__pyx_v_c_ctxt, __pyx_v_c_data, __pyx_v_data_len);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":255
 *     if context._origSaxData is not NULL:
 *         context._origSaxData(c_ctxt, c_data, data_len)
 *     try:             # <<<<<<<<<<<<<<
 *         context._target._handleSaxData(
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":257
 *     try:
 *         context._target._handleSaxData(
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = PyUnicode_DecodeUTF8(__pyx_v_c_data, __pyx_v_data_len, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxData(__pyx_v_context->_target, __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":258
 *         context._target._handleSaxData(
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxData");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":259
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxCData(void* ctxt, char* c_data, int data_len) with gil:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxData");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":261
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxCData(void* ctxt, char* c_data, int data_len) with gil:             # <<<<<<<<<<<<<<
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__handleSaxCData(void *__pyx_v_ctxt, char *__pyx_v_c_data, int __pyx_v_data_len) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":264
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":265
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":266
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxCData is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":267
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxCData is not NULL:
 *         context._origSaxCData(c_ctxt, c_data, data_len)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":268
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxCData is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxCData(c_ctxt, c_data, data_len)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxCData != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":269
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxCData is not NULL:
 *         context._origSaxCData(c_ctxt, c_data, data_len)             # <<<<<<<<<<<<<<
 *     try:
 *         context._target._handleSaxData(
 */
    __pyx_v_context->_origSaxCData(__pyx_v_c_ctxt, __pyx_v_c_data, __pyx_v_data_len);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":270
 *     if context._origSaxCData is not NULL:
 *         context._origSaxCData(c_ctxt, c_data, data_len)
 *     try:             # <<<<<<<<<<<<<<
 *         context._target._handleSaxData(
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":272
 *     try:
 *         context._target._handleSaxData(
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = PyUnicode_DecodeUTF8(__pyx_v_c_data, __pyx_v_data_len, NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxData(__pyx_v_context->_target, __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":273
 *         context._target._handleSaxData(
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxCData");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":274
 *             python.PyUnicode_DecodeUTF8(c_data, data_len, NULL))
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxDoctype(void* ctxt, char* c_name, char* c_public,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxCData");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":276
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxDoctype(void* ctxt, char* c_name, char* c_public,             # <<<<<<<<<<<<<<
 *                             char* c_system) with gil:
 *     cdef _SaxParserContext context
 */

static  void __pyx_f_4lxml_5etree__handleSaxDoctype(void *__pyx_v_ctxt, char *__pyx_v_c_name, char *__pyx_v_c_public, char *__pyx_v_c_system) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  PyObject *__pyx_v_public_id;
  PyObject *__pyx_v_system_id;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_public_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_system_id = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":280
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":281
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":282
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxDoctype is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":283
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxDoctype is not NULL:
 *         context._origSaxDoctype(c_ctxt, c_name, c_public, c_system)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":284
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxDoctype is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxDoctype(c_ctxt, c_name, c_public, c_system)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxDoctype != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":285
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxDoctype is not NULL:
 *         context._origSaxDoctype(c_ctxt, c_name, c_public, c_system)             # <<<<<<<<<<<<<<
 *     try:
 *         if c_public is not NULL:
 */
    __pyx_v_context->_origSaxDoctype(__pyx_v_c_ctxt, __pyx_v_c_name, __pyx_v_c_public, __pyx_v_c_system);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":286
 *     if context._origSaxDoctype is not NULL:
 *         context._origSaxDoctype(c_ctxt, c_name, c_public, c_system)
 *     try:             # <<<<<<<<<<<<<<
 *         if c_public is not NULL:
 *             public_id = funicode(c_public)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":287
 *         context._origSaxDoctype(c_ctxt, c_name, c_public, c_system)
 *     try:
 *         if c_public is not NULL:             # <<<<<<<<<<<<<<
 *             public_id = funicode(c_public)
 *         if c_system is not NULL:
 */
      __pyx_1 = (__pyx_v_c_public != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":288
 *     try:
 *         if c_public is not NULL:
 *             public_id = funicode(c_public)             # <<<<<<<<<<<<<<
 *         if c_system is not NULL:
 *             system_id = funicode(c_system)
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_public); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_public_id);
        __pyx_v_public_id = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":289
 *         if c_public is not NULL:
 *             public_id = funicode(c_public)
 *         if c_system is not NULL:             # <<<<<<<<<<<<<<
 *             system_id = funicode(c_system)
 *         context._target._handleSaxDoctype(
 */
      __pyx_1 = (__pyx_v_c_system != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":290
 *             public_id = funicode(c_public)
 *         if c_system is not NULL:
 *             system_id = funicode(c_system)             # <<<<<<<<<<<<<<
 *         context._target._handleSaxDoctype(
 *             funicode(c_name), public_id, system_id)
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_system); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_system_id);
        __pyx_v_system_id = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":292
 *             system_id = funicode(c_system)
 *         context._target._handleSaxDoctype(
 *             funicode(c_name), public_id, system_id)             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxDoctype(__pyx_v_context->_target, __pyx_2, __pyx_v_public_id, __pyx_v_system_id); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":293
 *         context._target._handleSaxDoctype(
 *             funicode(c_name), public_id, system_id)
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxDoctype");
      if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":294
 *             funicode(c_name), public_id, system_id)
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxPI(void* ctxt, char* c_target, char* c_data) with gil:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxDoctype");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_public_id);
  Py_DECREF(__pyx_v_system_id);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":296
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxPI(void* ctxt, char* c_target, char* c_data) with gil:             # <<<<<<<<<<<<<<
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__handleSaxPI(void *__pyx_v_ctxt, char *__pyx_v_c_target, char *__pyx_v_c_data) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  PyObject *__pyx_v_data;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_data = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":299
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":300
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":301
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxPi is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":302
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxPi is not NULL:
 *         context._origSaxPi(c_ctxt, c_target, c_data)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":303
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxPi is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxPi(c_ctxt, c_target, c_data)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxPi != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":304
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxPi is not NULL:
 *         context._origSaxPi(c_ctxt, c_target, c_data)             # <<<<<<<<<<<<<<
 *     try:
 *         if c_data is not NULL:
 */
    __pyx_v_context->_origSaxPi(__pyx_v_c_ctxt, __pyx_v_c_target, __pyx_v_c_data);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":305
 *     if context._origSaxPi is not NULL:
 *         context._origSaxPi(c_ctxt, c_target, c_data)
 *     try:             # <<<<<<<<<<<<<<
 *         if c_data is not NULL:
 *             data = funicode(c_data)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":306
 *         context._origSaxPi(c_ctxt, c_target, c_data)
 *     try:
 *         if c_data is not NULL:             # <<<<<<<<<<<<<<
 *             data = funicode(c_data)
 *         context._target._handleSaxPi(funicode(c_target), data)
 */
      __pyx_1 = (__pyx_v_c_data != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":307
 *     try:
 *         if c_data is not NULL:
 *             data = funicode(c_data)             # <<<<<<<<<<<<<<
 *         context._target._handleSaxPi(funicode(c_target), data)
 *     except:
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_data); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_data);
        __pyx_v_data = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":308
 *         if c_data is not NULL:
 *             data = funicode(c_data)
 *         context._target._handleSaxPi(funicode(c_target), data)             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_target); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxPi(__pyx_v_context->_target, __pyx_2, __pyx_v_data); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":309
 *             data = funicode(c_data)
 *         context._target._handleSaxPi(funicode(c_target), data)
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxPI");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":310
 *         context._target._handleSaxPi(funicode(c_target), data)
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef void _handleSaxComment(void* ctxt, char* c_data) with gil:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxPI");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_data);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":312
 *         context._handleSaxException(c_ctxt)
 * 
 * cdef void _handleSaxComment(void* ctxt, char* c_data) with gil:             # <<<<<<<<<<<<<<
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__handleSaxComment(void *__pyx_v_ctxt, char *__pyx_v_c_data) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_c_ctxt;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":315
 *     cdef _SaxParserContext context
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     if c_ctxt._private is NULL:
 *         return
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":316
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 */
  __pyx_1 = (__pyx_v_c_ctxt->_private == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":317
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     if c_ctxt._private is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxComment is not NULL:
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":318
 *     if c_ctxt._private is NULL:
 *         return
 *     context = <_SaxParserContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     if context._origSaxComment is not NULL:
 *         context._origSaxComment(c_ctxt, c_data)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":319
 *         return
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxComment is not NULL:             # <<<<<<<<<<<<<<
 *         context._origSaxComment(c_ctxt, c_data)
 *     try:
 */
  __pyx_1 = (__pyx_v_context->_origSaxComment != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":320
 *     context = <_SaxParserContext>c_ctxt._private
 *     if context._origSaxComment is not NULL:
 *         context._origSaxComment(c_ctxt, c_data)             # <<<<<<<<<<<<<<
 *     try:
 *         context._target._handleSaxComment(funicode(c_data))
 */
    __pyx_v_context->_origSaxComment(__pyx_v_c_ctxt, __pyx_v_c_data);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":321
 *     if context._origSaxComment is not NULL:
 *         context._origSaxComment(c_ctxt, c_data)
 *     try:             # <<<<<<<<<<<<<<
 *         context._target._handleSaxComment(funicode(c_data))
 *     except:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":322
 *         context._origSaxComment(c_ctxt, c_data)
 *     try:
 *         context._target._handleSaxComment(funicode(c_data))             # <<<<<<<<<<<<<<
 *     except:
 *         context._handleSaxException(c_ctxt)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_data); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget *)__pyx_v_context->_target->__pyx_vtab)->_handleSaxComment(__pyx_v_context->_target, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":323
 *     try:
 *         context._target._handleSaxComment(funicode(c_data))
 *     except:             # <<<<<<<<<<<<<<
 *         context._handleSaxException(c_ctxt)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._handleSaxComment");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":324
 *         context._target._handleSaxComment(funicode(c_data))
 *     except:
 *         context._handleSaxException(c_ctxt)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_handleSaxException(__pyx_v_context, __pyx_v_c_ctxt);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._handleSaxComment");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":345
 *     cdef bint _in_tail
 * 
 *     def __init__(self, *, element_factory=None, parser=None):             # <<<<<<<<<<<<<<
 *         self._sax_event_filter = \
 *             SAX_EVENT_START | SAX_EVENT_END | SAX_EVENT_DATA | \
 */

static int __pyx_pf_4lxml_5etree_11TreeBuilder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_11TreeBuilder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_element_factory = 0;
  PyObject *__pyx_v_parser = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element_factory,&__pyx_kp_parser,0};
  __pyx_v_element_factory = Py_None;
  __pyx_v_parser = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_element_factory = values[0];
    }
    if (values[1]) {
      __pyx_v_parser = values[1];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
    goto __pyx_L5_argtuple_error;
  } else {
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":346
 * 
 *     def __init__(self, *, element_factory=None, parser=None):
 *         self._sax_event_filter = \             # <<<<<<<<<<<<<<
 *             SAX_EVENT_START | SAX_EVENT_END | SAX_EVENT_DATA | \
 *             SAX_EVENT_PI | SAX_EVENT_COMMENT
 */
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->__pyx_base._sax_event_filter = ((((__pyx_e_4lxml_5etree_SAX_EVENT_START | __pyx_e_4lxml_5etree_SAX_EVENT_END) | __pyx_e_4lxml_5etree_SAX_EVENT_DATA) | __pyx_e_4lxml_5etree_SAX_EVENT_PI) | __pyx_e_4lxml_5etree_SAX_EVENT_COMMENT);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":349
 *             SAX_EVENT_START | SAX_EVENT_END | SAX_EVENT_DATA | \
 *             SAX_EVENT_PI | SAX_EVENT_COMMENT
 *         self._data = [] # data collector             # <<<<<<<<<<<<<<
 *         self._element_stack = [] # element stack
 *         self._element_stack_pop = self._element_stack.pop
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_data);
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_data = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":350
 *             SAX_EVENT_PI | SAX_EVENT_COMMENT
 *         self._data = [] # data collector
 *         self._element_stack = [] # element stack             # <<<<<<<<<<<<<<
 *         self._element_stack_pop = self._element_stack.pop
 *         self._last = None # last element
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_element_stack);
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_element_stack = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":351
 *         self._data = [] # data collector
 *         self._element_stack = [] # element stack
 *         self._element_stack_pop = self._element_stack.pop             # <<<<<<<<<<<<<<
 *         self._last = None # last element
 *         self._in_tail = 0 # true if we're after an end tag
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_element_stack, __pyx_kp_pop); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_element_stack_pop);
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_element_stack_pop = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":352
 *         self._element_stack = [] # element stack
 *         self._element_stack_pop = self._element_stack.pop
 *         self._last = None # last element             # <<<<<<<<<<<<<<
 *         self._in_tail = 0 # true if we're after an end tag
 *         self._factory = element_factory
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last));
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last = ((struct LxmlElement *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":353
 *         self._element_stack_pop = self._element_stack.pop
 *         self._last = None # last element
 *         self._in_tail = 0 # true if we're after an end tag             # <<<<<<<<<<<<<<
 *         self._factory = element_factory
 *         self._parser = parser
 */
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_in_tail = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":354
 *         self._last = None # last element
 *         self._in_tail = 0 # true if we're after an end tag
 *         self._factory = element_factory             # <<<<<<<<<<<<<<
 *         self._parser = parser
 * 
 */
  Py_INCREF(__pyx_v_element_factory);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_factory);
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_factory = __pyx_v_element_factory;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":355
 *         self._in_tail = 0 # true if we're after an end tag
 *         self._factory = element_factory
 *         self._parser = parser             # <<<<<<<<<<<<<<
 * 
 *     cdef int _flush(self) except -1:
 */
  if (!(__Pyx_TypeTest(__pyx_v_parser, __pyx_ptype_4lxml_5etree__BaseParser))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_parser);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_parser));
  ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":357
 *         self._parser = parser
 * 
 *     cdef int _flush(self) except -1:             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(self._data) > 0:
 *             if self._last is not None:
 */

static  int __pyx_f_4lxml_5etree_11TreeBuilder__flush(struct __pyx_obj_4lxml_5etree_TreeBuilder *__pyx_v_self) {
  PyObject *__pyx_v_text;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":358
 * 
 *     cdef int _flush(self) except -1:
 *         if python.PyList_GET_SIZE(self._data) > 0:             # <<<<<<<<<<<<<<
 *             if self._last is not None:
 *                 text = u"".join(self._data)
 */
  __pyx_1 = (PyList_GET_SIZE(__pyx_v_self->_data) > 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":359
 *     cdef int _flush(self) except -1:
 *         if python.PyList_GET_SIZE(self._data) > 0:
 *             if self._last is not None:             # <<<<<<<<<<<<<<
 *                 text = u"".join(self._data)
 *                 if self._in_tail:
 */
    __pyx_1 = (((PyObject *)__pyx_v_self->_last) != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":360
 *         if python.PyList_GET_SIZE(self._data) > 0:
 *             if self._last is not None:
 *                 text = u"".join(self._data)             # <<<<<<<<<<<<<<
 *                 if self._in_tail:
 *                     assert self._last.tail is None, u"internal error (tail)"
 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_443), __pyx_kp_join); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_self->_data);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self->_data);
      __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      Py_DECREF(__pyx_v_text);
      __pyx_v_text = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":361
 *             if self._last is not None:
 *                 text = u"".join(self._data)
 *                 if self._in_tail:             # <<<<<<<<<<<<<<
 *                     assert self._last.tail is None, u"internal error (tail)"
 *                     self._last.tail = text
 */
      __pyx_1 = __pyx_v_self->_in_tail;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":362
 *                 text = u"".join(self._data)
 *                 if self._in_tail:
 *                     assert self._last.tail is None, u"internal error (tail)"             # <<<<<<<<<<<<<<
 *                     self._last.tail = text
 *                 else:
 */
        #ifndef PYREX_WITHOUT_ASSERTIONS
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_last), __pyx_kp_tail); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_1 = (__pyx_2 == Py_None);
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        if (unlikely(!__pyx_1)) {
          PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_444));
          {__pyx_filename = __pyx_f[12]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #endif

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":363
 *                 if self._in_tail:
 *                     assert self._last.tail is None, u"internal error (tail)"
 *                     self._last.tail = text             # <<<<<<<<<<<<<<
 *                 else:
 *                     assert self._last.text is None, u"internal error (text)"
 */
        if (PyObject_SetAttr(((PyObject *)__pyx_v_self->_last), __pyx_kp_tail, __pyx_v_text) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":365
 *                     self._last.tail = text
 *                 else:
 *                     assert self._last.text is None, u"internal error (text)"             # <<<<<<<<<<<<<<
 *                     self._last.text = text
 *             del self._data[:]
 */
        #ifndef PYREX_WITHOUT_ASSERTIONS
        __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_last), __pyx_kp_text); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_1 = (__pyx_3 == Py_None);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (unlikely(!__pyx_1)) {
          PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_445));
          {__pyx_filename = __pyx_f[12]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #endif

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":366
 *                 else:
 *                     assert self._last.text is None, u"internal error (text)"
 *                     self._last.text = text             # <<<<<<<<<<<<<<
 *             del self._data[:]
 *         return 0
 */
        if (PyObject_SetAttr(((PyObject *)__pyx_v_self->_last), __pyx_kp_text, __pyx_v_text) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":367
 *                     assert self._last.text is None, u"internal error (text)"
 *                     self._last.text = text
 *             del self._data[:]             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
    if (PySequence_DelSlice(__pyx_v_self->_data, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":368
 *                     self._last.text = text
 *             del self._data[:]
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     # Python level event handlers
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder._flush");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":372
 *     # Python level event handlers
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         u"""close(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_close(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static char __pyx_doc_4lxml_5etree_11TreeBuilder_close[] = "close(self)\n\n        Flushes the builder buffers, and returns the toplevel document\n        element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_close(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":378
 *         element.
 *         """
 *         assert python.PyList_GET_SIZE(self._element_stack) == 0, u"missing end tags"             # <<<<<<<<<<<<<<
 *         assert self._last is not None, u"missing toplevel element"
 *         return self._last
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (unlikely(!(PyList_GET_SIZE(((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_element_stack) == 0))) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_446));
    {__pyx_filename = __pyx_f[12]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":379
 *         """
 *         assert python.PyList_GET_SIZE(self._element_stack) == 0, u"missing end tags"
 *         assert self._last is not None, u"missing toplevel element"             # <<<<<<<<<<<<<<
 *         return self._last
 * 
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last) != Py_None);
  if (unlikely(!__pyx_1)) {
    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_447));
    {__pyx_filename = __pyx_f[12]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":380
 *         assert python.PyList_GET_SIZE(self._element_stack) == 0, u"missing end tags"
 *         assert self._last is not None, u"missing toplevel element"
 *         return self._last             # <<<<<<<<<<<<<<
 * 
 *     def data(self, data):
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.close");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":382
 *         return self._last
 * 
 *     def data(self, data):             # <<<<<<<<<<<<<<
 *         u"""data(self, data)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_data(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
static char __pyx_doc_4lxml_5etree_11TreeBuilder_data[] = "data(self, data)\n\n        Adds text to the current element.  The value should be either an\n        8-bit string containing ASCII text, or a Unicode string.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_data(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":388
 *         8-bit string containing ASCII text, or a Unicode string.
 *         """
 *         self._handleSaxData(data)             # <<<<<<<<<<<<<<
 * 
 *     def start(self, tag, attrs, nsmap=None):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handleSaxData(((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self), __pyx_v_data); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.data");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":390
 *         self._handleSaxData(data)
 * 
 *     def start(self, tag, attrs, nsmap=None):             # <<<<<<<<<<<<<<
 *         u"""start(self, tag, attrs, nsmap=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_11TreeBuilder_start[] = "start(self, tag, attrs, nsmap=None)\n\n        Opens a new element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_attrs = 0;
  PyObject *__pyx_v_nsmap = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_tag,&__pyx_kp_attrs,&__pyx_kp_nsmap,0};
  __pyx_v_nsmap = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_tag);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_attrs);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("start", 0, 2, 3, 1); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "start") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_tag = values[0];
    __pyx_v_attrs = values[1];
    if (values[2]) {
      __pyx_v_nsmap = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_nsmap = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_attrs = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("start", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.start");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_nsmap);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":395
 *         Opens a new element.
 *         """
 *         if nsmap is None:             # <<<<<<<<<<<<<<
 *             nsmap = EMPTY_READ_ONLY_DICT
 *         return self._handleSaxStart(tag, attrs, nsmap)
 */
  __pyx_1 = (__pyx_v_nsmap == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":396
 *         """
 *         if nsmap is None:
 *             nsmap = EMPTY_READ_ONLY_DICT             # <<<<<<<<<<<<<<
 *         return self._handleSaxStart(tag, attrs, nsmap)
 * 
 */
    Py_INCREF(__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
    Py_DECREF(__pyx_v_nsmap);
    __pyx_v_nsmap = __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":397
 *         if nsmap is None:
 *             nsmap = EMPTY_READ_ONLY_DICT
 *         return self._handleSaxStart(tag, attrs, nsmap)             # <<<<<<<<<<<<<<
 * 
 *     def end(self, tag):
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handleSaxStart(((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self), __pyx_v_tag, __pyx_v_attrs, __pyx_v_nsmap); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.start");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_nsmap);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":399
 *         return self._handleSaxStart(tag, attrs, nsmap)
 * 
 *     def end(self, tag):             # <<<<<<<<<<<<<<
 *         u"""end(self, tag)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_end(PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /*proto*/
static char __pyx_doc_4lxml_5etree_11TreeBuilder_end[] = "end(self, tag)\n\n        Closes the current element.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_end(PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
  PyObject *__pyx_v_element;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":404
 *         Closes the current element.
 *         """
 *         element = self._handleSaxEnd(tag)             # <<<<<<<<<<<<<<
 *         assert self._last.tag == tag,\
 *                u"end tag mismatch (expected %s, got %s)" % (
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handleSaxEnd(((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self), __pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_element);
  __pyx_v_element = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":405
 *         """
 *         element = self._handleSaxEnd(tag)
 *         assert self._last.tag == tag,\             # <<<<<<<<<<<<<<
 *                u"end tag mismatch (expected %s, got %s)" % (
 *                    self._last.tag, tag)
 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last), __pyx_kp_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_RichCompare(__pyx_1, __pyx_v_tag, Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (unlikely(!__pyx_3)) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":407
 *         assert self._last.tag == tag,\
 *                u"end tag mismatch (expected %s, got %s)" % (
 *                    self._last.tag, tag)             # <<<<<<<<<<<<<<
 *         return element
 * 
 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->_last), __pyx_kp_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
    Py_INCREF(__pyx_v_tag);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_tag);
    __pyx_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_448), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[12]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":408
 *                u"end tag mismatch (expected %s, got %s)" % (
 *                    self._last.tag, tag)
 *         return element             # <<<<<<<<<<<<<<
 * 
 *     def pi(self, target, data):
 */
  Py_INCREF(__pyx_v_element);
  __pyx_r = __pyx_v_element;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.end");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":410
 *         return element
 * 
 *     def pi(self, target, data):             # <<<<<<<<<<<<<<
 *         u"""pi(self, target, data)
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_pi(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_11TreeBuilder_pi[] = "pi(self, target, data)\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_pi(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_target,&__pyx_kp_data,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_target);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_data);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("pi", 1, 2, 2, 1); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "pi") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_target = values[0];
    __pyx_v_data = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_target = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pi", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.pi");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":413
 *         u"""pi(self, target, data)
 *         """
 *         return self._handleSaxPi(target, data)             # <<<<<<<<<<<<<<
 * 
 *     def comment(self, comment):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handleSaxPi(((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self), __pyx_v_target, __pyx_v_data); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.pi");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":415
 *         return self._handleSaxPi(target, data)
 * 
 *     def comment(self, comment):             # <<<<<<<<<<<<<<
 *         u"""comment(self, comment)
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_comment(PyObject *__pyx_v_self, PyObject *__pyx_v_comment); /*proto*/
static char __pyx_doc_4lxml_5etree_11TreeBuilder_comment[] = "comment(self, comment)\n        ";
static PyObject *__pyx_pf_4lxml_5etree_11TreeBuilder_comment(PyObject *__pyx_v_self, PyObject *__pyx_v_comment) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":418
 *         u"""comment(self, comment)
 *         """
 *         return self._handleSaxComment(comment)             # <<<<<<<<<<<<<<
 * 
 *     # internal SAX event handlers
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)((struct __pyx_obj_4lxml_5etree_TreeBuilder *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handleSaxComment(((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_self), __pyx_v_comment); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder.comment");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":422
 *     # internal SAX event handlers
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):             # <<<<<<<<<<<<<<
 *         self._flush()
 *         if self._factory is not None:
 */

static  PyObject *__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxStart(struct __pyx_obj_4lxml_5etree_TreeBuilder *__pyx_v_self, PyObject *__pyx_v_tag, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":423
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 *         self._flush()             # <<<<<<<<<<<<<<
 *         if self._factory is not None:
 *             self._last = self._factory(tag, attrib)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_flush(__pyx_v_self); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":424
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 *         self._flush()
 *         if self._factory is not None:             # <<<<<<<<<<<<<<
 *             self._last = self._factory(tag, attrib)
 *             if python.PyList_GET_SIZE(self._element_stack) > 0:
 */
  __pyx_2 = (__pyx_v_self->_factory != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":425
 *         self._flush()
 *         if self._factory is not None:
 *             self._last = self._factory(tag, attrib)             # <<<<<<<<<<<<<<
 *             if python.PyList_GET_SIZE(self._element_stack) > 0:
 *                 _appendChild(self._element_stack[-1], self._last)
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_tag);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_tag);
    Py_INCREF(__pyx_v_attrib);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_attrib);
    __pyx_4 = PyObject_Call(__pyx_v_self->_factory, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_self->_last));
    __pyx_v_self->_last = ((struct LxmlElement *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":426
 *         if self._factory is not None:
 *             self._last = self._factory(tag, attrib)
 *             if python.PyList_GET_SIZE(self._element_stack) > 0:             # <<<<<<<<<<<<<<
 *                 _appendChild(self._element_stack[-1], self._last)
 *         elif python.PyList_GET_SIZE(self._element_stack) > 0:
 */
    __pyx_2 = (PyList_GET_SIZE(__pyx_v_self->_element_stack) > 0);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":427
 *             self._last = self._factory(tag, attrib)
 *             if python.PyList_GET_SIZE(self._element_stack) > 0:
 *                 _appendChild(self._element_stack[-1], self._last)             # <<<<<<<<<<<<<<
 *         elif python.PyList_GET_SIZE(self._element_stack) > 0:
 *             self._last = _makeSubElement(
 */
      __pyx_3 = __Pyx_GetItemInt(__pyx_v_self->_element_stack, -1, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_1 = __pyx_f_4lxml_5etree__appendChild(((struct LxmlElement *)__pyx_3), __pyx_v_self->_last); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":428
 *             if python.PyList_GET_SIZE(self._element_stack) > 0:
 *                 _appendChild(self._element_stack[-1], self._last)
 *         elif python.PyList_GET_SIZE(self._element_stack) > 0:             # <<<<<<<<<<<<<<
 *             self._last = _makeSubElement(
 *                 self._element_stack[-1], tag, None, None, attrib, nsmap, None)
 */
  __pyx_2 = (PyList_GET_SIZE(__pyx_v_self->_element_stack) > 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":430
 *         elif python.PyList_GET_SIZE(self._element_stack) > 0:
 *             self._last = _makeSubElement(
 *                 self._element_stack[-1], tag, None, None, attrib, nsmap, None)             # <<<<<<<<<<<<<<
 *         else:
 *             self._last = _makeElement(
 */
    __pyx_4 = __Pyx_GetItemInt(__pyx_v_self->_element_stack, -1, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__makeSubElement(((struct LxmlElement *)__pyx_4), __pyx_v_tag, Py_None, Py_None, __pyx_v_attrib, __pyx_v_nsmap, Py_None)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":429
 *                 _appendChild(self._element_stack[-1], self._last)
 *         elif python.PyList_GET_SIZE(self._element_stack) > 0:
 *             self._last = _makeSubElement(             # <<<<<<<<<<<<<<
 *                 self._element_stack[-1], tag, None, None, attrib, nsmap, None)
 *         else:
 */
    Py_DECREF(((PyObject *)__pyx_v_self->_last));
    __pyx_v_self->_last = ((struct LxmlElement *)__pyx_3);
    __pyx_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":433
 *         else:
 *             self._last = _makeElement(
 *                 tag, NULL, None, self._parser, None, None, attrib, nsmap, None)             # <<<<<<<<<<<<<<
 *         python.PyList_Append(self._element_stack, self._last)
 *         self._in_tail = 0
 */
    __pyx_4 = ((PyObject *)__pyx_f_4lxml_5etree__makeElement(__pyx_v_tag, NULL, ((struct LxmlDocument *)Py_None), __pyx_v_self->_parser, Py_None, Py_None, __pyx_v_attrib, __pyx_v_nsmap, Py_None)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":432
 *                 self._element_stack[-1], tag, None, None, attrib, nsmap, None)
 *         else:
 *             self._last = _makeElement(             # <<<<<<<<<<<<<<
 *                 tag, NULL, None, self._parser, None, None, attrib, nsmap, None)
 *         python.PyList_Append(self._element_stack, self._last)
 */
    Py_DECREF(((PyObject *)__pyx_v_self->_last));
    __pyx_v_self->_last = ((struct LxmlElement *)__pyx_4);
    __pyx_4 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":434
 *             self._last = _makeElement(
 *                 tag, NULL, None, self._parser, None, None, attrib, nsmap, None)
 *         python.PyList_Append(self._element_stack, self._last)             # <<<<<<<<<<<<<<
 *         self._in_tail = 0
 *         return self._last
 */
  __pyx_1 = PyList_Append(__pyx_v_self->_element_stack, ((PyObject *)__pyx_v_self->_last)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":435
 *                 tag, NULL, None, self._parser, None, None, attrib, nsmap, None)
 *         python.PyList_Append(self._element_stack, self._last)
 *         self._in_tail = 0             # <<<<<<<<<<<<<<
 *         return self._last
 * 
 */
  __pyx_v_self->_in_tail = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":436
 *         python.PyList_Append(self._element_stack, self._last)
 *         self._in_tail = 0
 *         return self._last             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxEnd(self, tag):
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_last));
  __pyx_r = ((PyObject *)__pyx_v_self->_last);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder._handleSaxStart");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":438
 *         return self._last
 * 
 *     cdef _handleSaxEnd(self, tag):             # <<<<<<<<<<<<<<
 *         self._flush()
 *         self._last = self._element_stack_pop()
 */

static  PyObject *__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxEnd(struct __pyx_obj_4lxml_5etree_TreeBuilder *__pyx_v_self, PyObject *__pyx_v_tag) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":439
 * 
 *     cdef _handleSaxEnd(self, tag):
 *         self._flush()             # <<<<<<<<<<<<<<
 *         self._last = self._element_stack_pop()
 *         self._in_tail = 1
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_flush(__pyx_v_self); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":440
 *     cdef _handleSaxEnd(self, tag):
 *         self._flush()
 *         self._last = self._element_stack_pop()             # <<<<<<<<<<<<<<
 *         self._in_tail = 1
 *         return self._last
 */
  __pyx_2 = PyObject_Call(__pyx_v_self->_element_stack_pop, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_self->_last));
  __pyx_v_self->_last = ((struct LxmlElement *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":441
 *         self._flush()
 *         self._last = self._element_stack_pop()
 *         self._in_tail = 1             # <<<<<<<<<<<<<<
 *         return self._last
 * 
 */
  __pyx_v_self->_in_tail = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":442
 *         self._last = self._element_stack_pop()
 *         self._in_tail = 1
 *         return self._last             # <<<<<<<<<<<<<<
 * 
 *     cdef int _handleSaxData(self, data) except -1:
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_last));
  __pyx_r = ((PyObject *)__pyx_v_self->_last);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder._handleSaxEnd");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":444
 *         return self._last
 * 
 *     cdef int _handleSaxData(self, data) except -1:             # <<<<<<<<<<<<<<
 *         python.PyList_Append(self._data, data)
 * 
 */

static  int __pyx_f_4lxml_5etree_11TreeBuilder__handleSaxData(struct __pyx_obj_4lxml_5etree_TreeBuilder *__pyx_v_self, PyObject *__pyx_v_data) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":445
 * 
 *     cdef int _handleSaxData(self, data) except -1:
 *         python.PyList_Append(self._data, data)             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxPi(self, target, data):
 */
  __pyx_1 = PyList_Append(__pyx_v_self->_data, __pyx_v_data); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.TreeBuilder._handleSaxData");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":447
 *         python.PyList_Append(self._data, data)
 * 
 *     cdef _handleSaxPi(self, target, data):             # <<<<<<<<<<<<<<
 *         self._flush()
 *         self._last = ProcessingInstruction(target, data)
 */

static  PyObject *__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxPi(struct __pyx_obj_4lxml_5etree_TreeBuilder *__pyx_v_self, PyObject *__pyx_v_target, PyObject *__pyx_v_data) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":448
 * 
 *     cdef _handleSaxPi(self, target, data):
 *         self._flush()             # <<<<<<<<<<<<<<
 *         self._last = ProcessingInstruction(target, data)
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_flush(__pyx_v_self); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":449
 *     cdef _handleSaxPi(self, target, data):
 *         self._flush()
 *         self._last = ProcessingInstruction(target, data)             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 *             _appendChild(self._element_stack[-1], self._last)
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_79); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_target);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_target);
  Py_INCREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_data);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_self->_last));
  __pyx_v_self->_last = ((struct LxmlElement *)__pyx_4);
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":450
 *         self._flush()
 *         self._last = ProcessingInstruction(target, data)
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:             # <<<<<<<<<<<<<<
 *             _appendChild(self._element_stack[-1], self._last)
 *         self._in_tail = 1
 */
  __pyx_5 = (PyList_GET_SIZE(__pyx_v_self->_element_stack) > 0);
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":451
 *         self._last = ProcessingInstruction(target, data)
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 *             _appendChild(self._element_stack[-1], self._last)             # <<<<<<<<<<<<<<
 *         self._in_tail = 1
 *         return self._last
 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_self->_element_stack, -1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __pyx_f_4lxml_5etree__appendChild(((struct LxmlElement *)__pyx_2), __pyx_v_self->_last); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":452
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 *             _appendChild(self._element_stack[-1], self._last)
 *         self._in_tail = 1             # <<<<<<<<<<<<<<
 *         return self._last
 * 
 */
  __pyx_v_self->_in_tail = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":453
 *             _appendChild(self._element_stack[-1], self._last)
 *         self._in_tail = 1
 *         return self._last             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxComment(self, comment):
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_last));
  __pyx_r = ((PyObject *)__pyx_v_self->_last);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder._handleSaxPi");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":455
 *         return self._last
 * 
 *     cdef _handleSaxComment(self, comment):             # <<<<<<<<<<<<<<
 *         self._flush()
 *         self._last = Comment(comment)
 */

static  PyObject *__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxComment(struct __pyx_obj_4lxml_5etree_TreeBuilder *__pyx_v_self, PyObject *__pyx_v_comment) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":456
 * 
 *     cdef _handleSaxComment(self, comment):
 *         self._flush()             # <<<<<<<<<<<<<<
 *         self._last = Comment(comment)
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder *)__pyx_v_self->__pyx_base.__pyx_vtab)->_flush(__pyx_v_self); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":457
 *     cdef _handleSaxComment(self, comment):
 *         self._flush()
 *         self._last = Comment(comment)             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 *             _appendChild(self._element_stack[-1], self._last)
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_Comment); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_comment);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_comment);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_self->_last));
  __pyx_v_self->_last = ((struct LxmlElement *)__pyx_4);
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":458
 *         self._flush()
 *         self._last = Comment(comment)
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:             # <<<<<<<<<<<<<<
 *             _appendChild(self._element_stack[-1], self._last)
 *         self._in_tail = 1
 */
  __pyx_5 = (PyList_GET_SIZE(__pyx_v_self->_element_stack) > 0);
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":459
 *         self._last = Comment(comment)
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 *             _appendChild(self._element_stack[-1], self._last)             # <<<<<<<<<<<<<<
 *         self._in_tail = 1
 *         return self._last
 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_self->_element_stack, -1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __pyx_f_4lxml_5etree__appendChild(((struct LxmlElement *)__pyx_2), __pyx_v_self->_last); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":460
 *         if python.PyList_GET_SIZE(self._element_stack) > 0:
 *             _appendChild(self._element_stack[-1], self._last)
 *         self._in_tail = 1             # <<<<<<<<<<<<<<
 *         return self._last
 */
  __pyx_v_self->_in_tail = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/saxparser.pxi":461
 *             _appendChild(self._element_stack[-1], self._last)
 *         self._in_tail = 1
 *         return self._last             # <<<<<<<<<<<<<<
 */
  Py_INCREF(((PyObject *)__pyx_v_self->_last));
  __pyx_r = ((PyObject *)__pyx_v_self->_last);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.TreeBuilder._handleSaxComment");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":10
 *     # to push the Python level parser result through the parser
 *     # machinery towards the API level functions
 *     def __init__(self, result):             # <<<<<<<<<<<<<<
 *         self.result = result
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_19_TargetParserResult___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4lxml_5etree_19_TargetParserResult___init__ = {"__init__", (PyCFunction)__pyx_pf_4lxml_5etree_19_TargetParserResult___init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pf_4lxml_5etree_19_TargetParserResult___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_self,&__pyx_kp_result,0};
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_result);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_result = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_result = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._TargetParserResult.__init__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":11
 *     # machinery towards the API level functions
 *     def __init__(self, result):
 *         self.result = result             # <<<<<<<<<<<<<<
 * 
 * cdef class _PythonSaxParserTarget(_SaxParserTarget):
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_result, __pyx_v_result) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._TargetParserResult.__init__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":22
 *     cdef bint _start_takes_nsmap
 * 
 *     def __init__(self, target):             # <<<<<<<<<<<<<<
 *         cdef int event_filter
 *         event_filter = 0
 */

static int __pyx_pf_4lxml_5etree_22_PythonSaxParserTarget___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_22_PythonSaxParserTarget___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_target = 0;
  int __pyx_v_event_filter;
  PyObject *__pyx_v_arguments;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_target,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_target);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_target = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_target = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_arguments = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":24
 *     def __init__(self, target):
 *         cdef int event_filter
 *         event_filter = 0             # <<<<<<<<<<<<<<
 *         self._start_takes_nsmap = 0
 *         try:
 */
  __pyx_v_event_filter = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":25
 *         cdef int event_filter
 *         event_filter = 0
 *         self._start_takes_nsmap = 0             # <<<<<<<<<<<<<<
 *         try:
 *             self._target_start = target.start
 */
  ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_start_takes_nsmap = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":26
 *         event_filter = 0
 *         self._start_takes_nsmap = 0
 *         try:             # <<<<<<<<<<<<<<
 *             self._target_start = target.start
 *             if self._target_start is not None:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":27
 *         self._start_takes_nsmap = 0
 *         try:
 *             self._target_start = target.start             # <<<<<<<<<<<<<<
 *             if self._target_start is not None:
 *                 event_filter = event_filter | SAX_EVENT_START
 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_target, __pyx_kp_start); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      Py_DECREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_start);
      ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_start = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":28
 *         try:
 *             self._target_start = target.start
 *             if self._target_start is not None:             # <<<<<<<<<<<<<<
 *                 event_filter = event_filter | SAX_EVENT_START
 *         except AttributeError:
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_start != Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":29
 *             self._target_start = target.start
 *             if self._target_start is not None:
 *                 event_filter = event_filter | SAX_EVENT_START             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
        __pyx_v_event_filter = (__pyx_v_event_filter | __pyx_e_4lxml_5etree_SAX_EVENT_START);
        goto __pyx_L11;
      }
      __pyx_L11:;
    }
    /*else:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":33
 *             pass
 *         else:
 *             try:             # <<<<<<<<<<<<<<
 *                 arguments = inspect_getargspec(self._target_start)
 *                 if len(arguments[0]) > 3 or arguments[1] is not None:
 */
      {
        PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
        __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
        /*try:*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":34
 *         else:
 *             try:
 *                 arguments = inspect_getargspec(self._target_start)             # <<<<<<<<<<<<<<
 *                 if len(arguments[0]) > 3 or arguments[1] is not None:
 *                     self._start_takes_nsmap = 1
 */
          __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
          Py_INCREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_start);
          PyTuple_SET_ITEM(__pyx_1, 0, ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_start);
          __pyx_4 = PyObject_Call(__pyx_v_4lxml_5etree_inspect_getargspec, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
          Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
          Py_DECREF(__pyx_v_arguments);
          __pyx_v_arguments = __pyx_4;
          __pyx_4 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":35
 *             try:
 *                 arguments = inspect_getargspec(self._target_start)
 *                 if len(arguments[0]) > 3 or arguments[1] is not None:             # <<<<<<<<<<<<<<
 *                     self._start_takes_nsmap = 1
 *             except TypeError:
 */
          __pyx_5 = __Pyx_GetItemInt(__pyx_v_arguments, 0, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
          __pyx_6 = PyObject_Length(__pyx_5); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_2 = (__pyx_6 > 3);
          if (!__pyx_2) {
            __pyx_1 = __Pyx_GetItemInt(__pyx_v_arguments, 1, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
            __pyx_2 = (__pyx_1 != Py_None);
            Py_DECREF(__pyx_1); __pyx_1 = 0;
          }
          if (__pyx_2) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":36
 *                 arguments = inspect_getargspec(self._target_start)
 *                 if len(arguments[0]) > 3 or arguments[1] is not None:
 *                     self._start_takes_nsmap = 1             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 pass
 */
            ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_start_takes_nsmap = 1;
            goto __pyx_L17;
          }
          __pyx_L17:;
        }
        Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
        Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
        Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
        goto __pyx_L16_try;
        __pyx_L12_error:;
        Py_XDECREF(__pyx_4); __pyx_4 = 0;
        Py_XDECREF(__pyx_5); __pyx_5 = 0;
        Py_XDECREF(__pyx_1); __pyx_1 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":37
 *                 if len(arguments[0]) > 3 or arguments[1] is not None:
 *                     self._start_takes_nsmap = 1
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 pass
 *         try:
 */
        __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
        if (__pyx_3) {
          __Pyx_AddTraceback("lxml.etree.__init__");
          if (__Pyx_GetException(&__pyx_4, &__pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          goto __pyx_L13_exception_handled;
        }
        __pyx_L14_except_error:;
        Py_XDECREF(__pyx_save_exc_type);
        Py_XDECREF(__pyx_save_exc_value);
        Py_XDECREF(__pyx_save_exc_tb);
        goto __pyx_L8_except_error;
        __pyx_L13_exception_handled:;
        __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
        __pyx_L16_try:;
      }
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try;
    __pyx_L6_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":30
 *             if self._target_start is not None:
 *                 event_filter = event_filter | SAX_EVENT_START
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 *         else:
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.__init__");
      if (__Pyx_GetException(&__pyx_1, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L7_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L10_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":39
 *             except TypeError:
 *                 pass
 *         try:             # <<<<<<<<<<<<<<
 *             self._target_end = target.end
 *             if self._target_end is not None:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":40
 *                 pass
 *         try:
 *             self._target_end = target.end             # <<<<<<<<<<<<<<
 *             if self._target_end is not None:
 *                 event_filter = event_filter | SAX_EVENT_END
 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_target, __pyx_kp_end); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
      Py_DECREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_end);
      ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_end = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":41
 *         try:
 *             self._target_end = target.end
 *             if self._target_end is not None:             # <<<<<<<<<<<<<<
 *                 event_filter = event_filter | SAX_EVENT_END
 *         except AttributeError:
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_end != Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":42
 *             self._target_end = target.end
 *             if self._target_end is not None:
 *                 event_filter = event_filter | SAX_EVENT_END             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
        __pyx_v_event_filter = (__pyx_v_event_filter | __pyx_e_4lxml_5etree_SAX_EVENT_END);
        goto __pyx_L23;
      }
      __pyx_L23:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L22_try;
    __pyx_L18_error:;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":43
 *             if self._target_end is not None:
 *                 event_filter = event_filter | SAX_EVENT_END
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 *         try:
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.__init__");
      if (__Pyx_GetException(&__pyx_5, &__pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L19_exception_handled;
    }
    __pyx_L20_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L19_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L22_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":45
 *         except AttributeError:
 *             pass
 *         try:             # <<<<<<<<<<<<<<
 *             self._target_data = target.data
 *             if self._target_data is not None:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":46
 *             pass
 *         try:
 *             self._target_data = target.data             # <<<<<<<<<<<<<<
 *             if self._target_data is not None:
 *                 event_filter = event_filter | SAX_EVENT_DATA
 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_target, __pyx_kp_data); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_data);
      ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_data = __pyx_5;
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":47
 *         try:
 *             self._target_data = target.data
 *             if self._target_data is not None:             # <<<<<<<<<<<<<<
 *                 event_filter = event_filter | SAX_EVENT_DATA
 *         except AttributeError:
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_data != Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":48
 *             self._target_data = target.data
 *             if self._target_data is not None:
 *                 event_filter = event_filter | SAX_EVENT_DATA             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
        __pyx_v_event_filter = (__pyx_v_event_filter | __pyx_e_4lxml_5etree_SAX_EVENT_DATA);
        goto __pyx_L29;
      }
      __pyx_L29:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L28_try;
    __pyx_L24_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":49
 *             if self._target_data is not None:
 *                 event_filter = event_filter | SAX_EVENT_DATA
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 *         try:
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.__init__");
      if (__Pyx_GetException(&__pyx_1, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L25_exception_handled;
    }
    __pyx_L26_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L25_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L28_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":51
 *         except AttributeError:
 *             pass
 *         try:             # <<<<<<<<<<<<<<
 *             self._target_doctype = target.doctype
 *             if self._target_doctype is not None:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":52
 *             pass
 *         try:
 *             self._target_doctype = target.doctype             # <<<<<<<<<<<<<<
 *             if self._target_doctype is not None:
 *                 event_filter = event_filter | SAX_EVENT_DOCTYPE
 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_target, __pyx_kp_doctype); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L30_error;}
      Py_DECREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_doctype);
      ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_doctype = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":53
 *         try:
 *             self._target_doctype = target.doctype
 *             if self._target_doctype is not None:             # <<<<<<<<<<<<<<
 *                 event_filter = event_filter | SAX_EVENT_DOCTYPE
 *         except AttributeError:
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_doctype != Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":54
 *             self._target_doctype = target.doctype
 *             if self._target_doctype is not None:
 *                 event_filter = event_filter | SAX_EVENT_DOCTYPE             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
        __pyx_v_event_filter = (__pyx_v_event_filter | __pyx_e_4lxml_5etree_SAX_EVENT_DOCTYPE);
        goto __pyx_L35;
      }
      __pyx_L35:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L34_try;
    __pyx_L30_error:;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":55
 *             if self._target_doctype is not None:
 *                 event_filter = event_filter | SAX_EVENT_DOCTYPE
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 *         try:
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.__init__");
      if (__Pyx_GetException(&__pyx_4, &__pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L32_except_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L31_exception_handled;
    }
    __pyx_L32_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L31_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L34_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":57
 *         except AttributeError:
 *             pass
 *         try:             # <<<<<<<<<<<<<<
 *             self._target_pi = target.pi
 *             if self._target_pi is not None:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":58
 *             pass
 *         try:
 *             self._target_pi = target.pi             # <<<<<<<<<<<<<<
 *             if self._target_pi is not None:
 *                 event_filter = event_filter | SAX_EVENT_PI
 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_target, __pyx_kp_pi); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L36_error;}
      Py_DECREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_pi);
      ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_pi = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":59
 *         try:
 *             self._target_pi = target.pi
 *             if self._target_pi is not None:             # <<<<<<<<<<<<<<
 *                 event_filter = event_filter | SAX_EVENT_PI
 *         except AttributeError:
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_pi != Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":60
 *             self._target_pi = target.pi
 *             if self._target_pi is not None:
 *                 event_filter = event_filter | SAX_EVENT_PI             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
        __pyx_v_event_filter = (__pyx_v_event_filter | __pyx_e_4lxml_5etree_SAX_EVENT_PI);
        goto __pyx_L41;
      }
      __pyx_L41:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L40_try;
    __pyx_L36_error:;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":61
 *             if self._target_pi is not None:
 *                 event_filter = event_filter | SAX_EVENT_PI
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 *         try:
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.__init__");
      if (__Pyx_GetException(&__pyx_5, &__pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L38_except_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L37_exception_handled;
    }
    __pyx_L38_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L37_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L40_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":63
 *         except AttributeError:
 *             pass
 *         try:             # <<<<<<<<<<<<<<
 *             self._target_comment = target.comment
 *             if self._target_comment is not None:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":64
 *             pass
 *         try:
 *             self._target_comment = target.comment             # <<<<<<<<<<<<<<
 *             if self._target_comment is not None:
 *                 event_filter = event_filter | SAX_EVENT_COMMENT
 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_target, __pyx_kp_comment); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L42_error;}
      Py_DECREF(((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_comment);
      ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_comment = __pyx_5;
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":65
 *         try:
 *             self._target_comment = target.comment
 *             if self._target_comment is not None:             # <<<<<<<<<<<<<<
 *                 event_filter = event_filter | SAX_EVENT_COMMENT
 *         except AttributeError:
 */
      __pyx_2 = (((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->_target_comment != Py_None);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":66
 *             self._target_comment = target.comment
 *             if self._target_comment is not None:
 *                 event_filter = event_filter | SAX_EVENT_COMMENT             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             pass
 */
        __pyx_v_event_filter = (__pyx_v_event_filter | __pyx_e_4lxml_5etree_SAX_EVENT_COMMENT);
        goto __pyx_L47;
      }
      __pyx_L47:;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L46_try;
    __pyx_L42_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":67
 *             if self._target_comment is not None:
 *                 event_filter = event_filter | SAX_EVENT_COMMENT
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             pass
 *         self._sax_event_filter = event_filter
 */
    __pyx_3 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_3) {
      __Pyx_AddTraceback("lxml.etree.__init__");
      if (__Pyx_GetException(&__pyx_1, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L44_except_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L43_exception_handled;
    }
    __pyx_L44_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L43_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L46_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":69
 *         except AttributeError:
 *             pass
 *         self._sax_event_filter = event_filter             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 */
  ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)__pyx_v_self)->__pyx_base._sax_event_filter = __pyx_v_event_filter;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_arguments);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":71
 *         self._sax_event_filter = event_filter
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):             # <<<<<<<<<<<<<<
 *         if self._start_takes_nsmap:
 *             return self._target_start(tag, attrib, nsmap)
 */

static  PyObject *__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxStart(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *__pyx_v_self, PyObject *__pyx_v_tag, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":72
 * 
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 *         if self._start_takes_nsmap:             # <<<<<<<<<<<<<<
 *             return self._target_start(tag, attrib, nsmap)
 *         else:
 */
  __pyx_1 = __pyx_v_self->_start_takes_nsmap;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":73
 *     cdef _handleSaxStart(self, tag, attrib, nsmap):
 *         if self._start_takes_nsmap:
 *             return self._target_start(tag, attrib, nsmap)             # <<<<<<<<<<<<<<
 *         else:
 *             return self._target_start(tag, attrib)
 */
    __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_tag);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_tag);
    Py_INCREF(__pyx_v_attrib);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_attrib);
    Py_INCREF(__pyx_v_nsmap);
    PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_nsmap);
    __pyx_3 = PyObject_Call(__pyx_v_self->_target_start, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":75
 *             return self._target_start(tag, attrib, nsmap)
 *         else:
 *             return self._target_start(tag, attrib)             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxEnd(self, tag):
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_tag);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_tag);
    Py_INCREF(__pyx_v_attrib);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_attrib);
    __pyx_3 = PyObject_Call(__pyx_v_self->_target_start, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget._handleSaxStart");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":77
 *             return self._target_start(tag, attrib)
 * 
 *     cdef _handleSaxEnd(self, tag):             # <<<<<<<<<<<<<<
 *         return self._target_end(tag)
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxEnd(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *__pyx_v_self, PyObject *__pyx_v_tag) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":78
 * 
 *     cdef _handleSaxEnd(self, tag):
 *         return self._target_end(tag)             # <<<<<<<<<<<<<<
 * 
 *     cdef int _handleSaxData(self, data) except -1:
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_tag);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_tag);
  __pyx_2 = PyObject_Call(__pyx_v_self->_target_end, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget._handleSaxEnd");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":80
 *         return self._target_end(tag)
 * 
 *     cdef int _handleSaxData(self, data) except -1:             # <<<<<<<<<<<<<<
 *         self._target_data(data)
 * 
 */

static  int __pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxData(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *__pyx_v_self, PyObject *__pyx_v_data) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":81
 * 
 *     cdef int _handleSaxData(self, data) except -1:
 *         self._target_data(data)             # <<<<<<<<<<<<<<
 * 
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_data);
  __pyx_2 = PyObject_Call(__pyx_v_self->_target_data, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget._handleSaxData");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":83
 *         self._target_data(data)
 * 
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:             # <<<<<<<<<<<<<<
 *         self._target_doctype(root_tag, public_id, system_id)
 * 
 */

static  int __pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxDoctype(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *__pyx_v_self, PyObject *__pyx_v_root_tag, PyObject *__pyx_v_public_id, PyObject *__pyx_v_system_id) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":84
 * 
 *     cdef int _handleSaxDoctype(self, root_tag, public_id, system_id) except -1:
 *         self._target_doctype(root_tag, public_id, system_id)             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxPi(self, target, data):
 */
  __pyx_1 = PyTuple_New(3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_root_tag);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_root_tag);
  Py_INCREF(__pyx_v_public_id);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_public_id);
  Py_INCREF(__pyx_v_system_id);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_system_id);
  __pyx_2 = PyObject_Call(__pyx_v_self->_target_doctype, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget._handleSaxDoctype");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":86
 *         self._target_doctype(root_tag, public_id, system_id)
 * 
 *     cdef _handleSaxPi(self, target, data):             # <<<<<<<<<<<<<<
 *         return self._target_pi(target, data)
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxPi(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *__pyx_v_self, PyObject *__pyx_v_target, PyObject *__pyx_v_data) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":87
 * 
 *     cdef _handleSaxPi(self, target, data):
 *         return self._target_pi(target, data)             # <<<<<<<<<<<<<<
 * 
 *     cdef _handleSaxComment(self, comment):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_target);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_target);
  Py_INCREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_data);
  __pyx_2 = PyObject_Call(__pyx_v_self->_target_pi, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget._handleSaxPi");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":89
 *         return self._target_pi(target, data)
 * 
 *     cdef _handleSaxComment(self, comment):             # <<<<<<<<<<<<<<
 *         return self._target_comment(comment)
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxComment(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *__pyx_v_self, PyObject *__pyx_v_comment) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":90
 * 
 *     cdef _handleSaxComment(self, comment):
 *         return self._target_comment(comment)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_comment);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_comment);
  __pyx_2 = PyObject_Call(__pyx_v_self->_target_comment, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._PythonSaxParserTarget._handleSaxComment");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":97
 *     """
 *     cdef object _python_target
 *     cdef int _setTarget(self, target) except -1:             # <<<<<<<<<<<<<<
 *         self._python_target = target
 *         if not isinstance(target, _SaxParserTarget) or \
 */

static  int __pyx_f_4lxml_5etree_20_TargetParserContext__setTarget(struct __pyx_obj_4lxml_5etree__TargetParserContext *__pyx_v_self, PyObject *__pyx_v_target) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_target);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":98
 *     cdef object _python_target
 *     cdef int _setTarget(self, target) except -1:
 *         self._python_target = target             # <<<<<<<<<<<<<<
 *         if not isinstance(target, _SaxParserTarget) or \
 *                 hasattr(target, u'__dict__'):
 */
  Py_INCREF(__pyx_v_target);
  Py_DECREF(__pyx_v_self->_python_target);
  __pyx_v_self->_python_target = __pyx_v_target;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":99
 *     cdef int _setTarget(self, target) except -1:
 *         self._python_target = target
 *         if not isinstance(target, _SaxParserTarget) or \             # <<<<<<<<<<<<<<
 *                 hasattr(target, u'__dict__'):
 *             target = _PythonSaxParserTarget(target)
 */
  __pyx_2 = PyObject_TypeCheck(__pyx_v_target, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__SaxParserTarget))); 
  __pyx_1 = (!__pyx_2);
  if (!__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":100
 *         self._python_target = target
 *         if not isinstance(target, _SaxParserTarget) or \
 *                 hasattr(target, u'__dict__'):             # <<<<<<<<<<<<<<
 *             target = _PythonSaxParserTarget(target)
 *         self._setSaxParserTarget(target)
 */
    __pyx_1 = PyObject_HasAttr(__pyx_v_target, ((PyObject *)__pyx_kp_449)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":101
 *         if not isinstance(target, _SaxParserTarget) or \
 *                 hasattr(target, u'__dict__'):
 *             target = _PythonSaxParserTarget(target)             # <<<<<<<<<<<<<<
 *         self._setSaxParserTarget(target)
 *         return 0
 */
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_target);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_target);
    __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__PythonSaxParserTarget)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_v_target);
    __pyx_v_target = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":102
 *                 hasattr(target, u'__dict__'):
 *             target = _PythonSaxParserTarget(target)
 *         self._setSaxParserTarget(target)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  if (!(__Pyx_TypeTest(__pyx_v_target, __pyx_ptype_4lxml_5etree__SaxParserTarget))) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._setSaxParserTarget(((struct __pyx_obj_4lxml_5etree__SaxParserContext *)__pyx_v_self), ((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)__pyx_v_target));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":103
 *             target = _PythonSaxParserTarget(target)
 *         self._setSaxParserTarget(target)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext _copy(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._TargetParserContext._setTarget");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_target);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":105
 *         return 0
 * 
 *     cdef _ParserContext _copy(self):             # <<<<<<<<<<<<<<
 *         cdef _TargetParserContext context
 *         context = _ParserContext._copy(self)
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_20_TargetParserContext__copy(struct __pyx_obj_4lxml_5etree__TargetParserContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__TargetParserContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__TargetParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":107
 *     cdef _ParserContext _copy(self):
 *         cdef _TargetParserContext context
 *         context = _ParserContext._copy(self)             # <<<<<<<<<<<<<<
 *         context._setTarget(self._python_target)
 *         return context
 */
  __pyx_1 = ((PyObject *)__pyx_vtabptr_4lxml_5etree__ParserContext->_copy(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__TargetParserContext))) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__TargetParserContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":108
 *         cdef _TargetParserContext context
 *         context = _ParserContext._copy(self)
 *         context._setTarget(self._python_target)             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_setTarget(__pyx_v_context, __pyx_v_self->_python_target); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":109
 *         context = _ParserContext._copy(self)
 *         context._setTarget(self._python_target)
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     cdef object _handleParseResult(self, _BaseParser parser, xmlDoc* result,
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_context);
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._TargetParserContext._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":111
 *         return context
 * 
 *     cdef object _handleParseResult(self, _BaseParser parser, xmlDoc* result,             # <<<<<<<<<<<<<<
 *                                    filename):
 *         cdef bint recover
 */

static  PyObject *__pyx_f_4lxml_5etree_20_TargetParserContext__handleParseResult(struct __pyx_obj_4lxml_5etree__TargetParserContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser, xmlDoc *__pyx_v_result, PyObject *__pyx_v_filename) {
  int __pyx_v_recover;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":114
 *                                    filename):
 *         cdef bint recover
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER             # <<<<<<<<<<<<<<
 *         if not self._c_ctxt.wellFormed and not recover:
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 */
  __pyx_v_recover = (__pyx_v_parser->_parse_options & XML_PARSE_RECOVER);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":115
 *         cdef bint recover
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER
 *         if not self._c_ctxt.wellFormed and not recover:             # <<<<<<<<<<<<<<
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 *         self._raise_if_stored()
 */
  __pyx_1 = (!__pyx_v_self->__pyx_base.__pyx_base._c_ctxt->wellFormed);
  if (__pyx_1) {
    __pyx_1 = (!__pyx_v_recover);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":116
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER
 *         if not self._c_ctxt.wellFormed and not recover:
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)             # <<<<<<<<<<<<<<
 *         self._raise_if_stored()
 *         return self._python_target.close()
 */
    __pyx_2 = __pyx_f_4lxml_5etree__raiseParseError(__pyx_v_self->__pyx_base.__pyx_base._c_ctxt, __pyx_v_filename, __pyx_v_self->__pyx_base.__pyx_base._error_log); if (unlikely(__pyx_2 == 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":117
 *         if not self._c_ctxt.wellFormed and not recover:
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 *         self._raise_if_stored()             # <<<<<<<<<<<<<<
 *         return self._python_target.close()
 * 
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._raise_if_stored(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_self)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":118
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 *         self._raise_if_stored()
 *         return self._python_target.close()             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _handleParseResultDoc(self, _BaseParser parser,
 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self->_python_target, __pyx_kp_close); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._TargetParserContext._handleParseResult");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":120
 *         return self._python_target.close()
 * 
 *     cdef xmlDoc* _handleParseResultDoc(self, _BaseParser parser,             # <<<<<<<<<<<<<<
 *                                        xmlDoc* result, filename) except NULL:
 *         cdef bint recover
 */

static  xmlDoc *__pyx_f_4lxml_5etree_20_TargetParserContext__handleParseResultDoc(struct __pyx_obj_4lxml_5etree__TargetParserContext *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser, xmlDoc *__pyx_v_result, PyObject *__pyx_v_filename) {
  int __pyx_v_recover;
  xmlDoc *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":123
 *                                        xmlDoc* result, filename) except NULL:
 *         cdef bint recover
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER             # <<<<<<<<<<<<<<
 *         if result is not NULL and result._private is NULL:
 *             # no _Document proxy => orphen
 */
  __pyx_v_recover = (__pyx_v_parser->_parse_options & XML_PARSE_RECOVER);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":124
 *         cdef bint recover
 *         recover = parser._parse_options & xmlparser.XML_PARSE_RECOVER
 *         if result is not NULL and result._private is NULL:             # <<<<<<<<<<<<<<
 *             # no _Document proxy => orphen
 *             tree.xmlFreeDoc(result)
 */
  __pyx_1 = (__pyx_v_result != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_result->_private == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":126
 *         if result is not NULL and result._private is NULL:
 *             # no _Document proxy => orphen
 *             tree.xmlFreeDoc(result)             # <<<<<<<<<<<<<<
 *         if self._c_ctxt.myDoc is not NULL:
 *             if self._c_ctxt.myDoc is not result and \
 */
    xmlFreeDoc(__pyx_v_result);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":127
 *             # no _Document proxy => orphen
 *             tree.xmlFreeDoc(result)
 *         if self._c_ctxt.myDoc is not NULL:             # <<<<<<<<<<<<<<
 *             if self._c_ctxt.myDoc is not result and \
 *                     self._c_ctxt.myDoc._private is NULL:
 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._c_ctxt->myDoc != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":128
 *             tree.xmlFreeDoc(result)
 *         if self._c_ctxt.myDoc is not NULL:
 *             if self._c_ctxt.myDoc is not result and \             # <<<<<<<<<<<<<<
 *                     self._c_ctxt.myDoc._private is NULL:
 *                 # no _Document proxy => orphen
 */
    __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._c_ctxt->myDoc != __pyx_v_result);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":129
 *         if self._c_ctxt.myDoc is not NULL:
 *             if self._c_ctxt.myDoc is not result and \
 *                     self._c_ctxt.myDoc._private is NULL:             # <<<<<<<<<<<<<<
 *                 # no _Document proxy => orphen
 *                 tree.xmlFreeDoc(self._c_ctxt.myDoc)
 */
      __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._c_ctxt->myDoc->_private == NULL);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":131
 *                     self._c_ctxt.myDoc._private is NULL:
 *                 # no _Document proxy => orphen
 *                 tree.xmlFreeDoc(self._c_ctxt.myDoc)             # <<<<<<<<<<<<<<
 *             self._c_ctxt.myDoc = NULL
 *         if not self._c_ctxt.wellFormed and not recover:
 */
      xmlFreeDoc(__pyx_v_self->__pyx_base.__pyx_base._c_ctxt->myDoc);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":132
 *                 # no _Document proxy => orphen
 *                 tree.xmlFreeDoc(self._c_ctxt.myDoc)
 *             self._c_ctxt.myDoc = NULL             # <<<<<<<<<<<<<<
 *         if not self._c_ctxt.wellFormed and not recover:
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 */
    __pyx_v_self->__pyx_base.__pyx_base._c_ctxt->myDoc = NULL;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":133
 *                 tree.xmlFreeDoc(self._c_ctxt.myDoc)
 *             self._c_ctxt.myDoc = NULL
 *         if not self._c_ctxt.wellFormed and not recover:             # <<<<<<<<<<<<<<
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 *         self._raise_if_stored()
 */
  __pyx_1 = (!__pyx_v_self->__pyx_base.__pyx_base._c_ctxt->wellFormed);
  if (__pyx_1) {
    __pyx_1 = (!__pyx_v_recover);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":134
 *             self._c_ctxt.myDoc = NULL
 *         if not self._c_ctxt.wellFormed and not recover:
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)             # <<<<<<<<<<<<<<
 *         self._raise_if_stored()
 *         raise _TargetParserResult(self._python_target.close())
 */
    __pyx_2 = __pyx_f_4lxml_5etree__raiseParseError(__pyx_v_self->__pyx_base.__pyx_base._c_ctxt, __pyx_v_filename, __pyx_v_self->__pyx_base.__pyx_base._error_log); if (unlikely(__pyx_2 == 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":135
 *         if not self._c_ctxt.wellFormed and not recover:
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 *         self._raise_if_stored()             # <<<<<<<<<<<<<<
 *         raise _TargetParserResult(self._python_target.close())
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._raise_if_stored(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_self)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":136
 *             _raiseParseError(self._c_ctxt, filename, self._error_log)
 *         self._raise_if_stored()
 *         raise _TargetParserResult(self._python_target.close())             # <<<<<<<<<<<<<<
 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp__TargetParserResult); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyObject_GetAttr(__pyx_v_self->_python_target, __pyx_kp_close); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
  __pyx_5 = 0;
  __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __Pyx_Raise(__pyx_5, 0, 0);
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  {__pyx_filename = __pyx_f[13]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._TargetParserContext._handleParseResultDoc");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":8
 *     OUTPUT_METHOD_TEXT
 * 
 * cdef int _findOutputMethod(method) except -1:             # <<<<<<<<<<<<<<
 *     if method is None:
 *         return OUTPUT_METHOD_XML
 */

static  int __pyx_f_4lxml_5etree__findOutputMethod(PyObject *__pyx_v_method) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_method);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":9
 * 
 * cdef int _findOutputMethod(method) except -1:
 *     if method is None:             # <<<<<<<<<<<<<<
 *         return OUTPUT_METHOD_XML
 *     method = method.lower()
 */
  __pyx_1 = (__pyx_v_method == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":10
 * cdef int _findOutputMethod(method) except -1:
 *     if method is None:
 *         return OUTPUT_METHOD_XML             # <<<<<<<<<<<<<<
 *     method = method.lower()
 *     if method == u"xml":
 */
    __pyx_r = __pyx_e_4lxml_5etree_OUTPUT_METHOD_XML;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":11
 *     if method is None:
 *         return OUTPUT_METHOD_XML
 *     method = method.lower()             # <<<<<<<<<<<<<<
 *     if method == u"xml":
 *         return OUTPUT_METHOD_XML
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_method, __pyx_kp_lower); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_method);
  __pyx_v_method = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":12
 *         return OUTPUT_METHOD_XML
 *     method = method.lower()
 *     if method == u"xml":             # <<<<<<<<<<<<<<
 *         return OUTPUT_METHOD_XML
 *     if method == u"html":
 */
  __pyx_2 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_kp_450), Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":13
 *     method = method.lower()
 *     if method == u"xml":
 *         return OUTPUT_METHOD_XML             # <<<<<<<<<<<<<<
 *     if method == u"html":
 *         return OUTPUT_METHOD_HTML
 */
    __pyx_r = __pyx_e_4lxml_5etree_OUTPUT_METHOD_XML;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":14
 *     if method == u"xml":
 *         return OUTPUT_METHOD_XML
 *     if method == u"html":             # <<<<<<<<<<<<<<
 *         return OUTPUT_METHOD_HTML
 *     if method == u"text":
 */
  __pyx_3 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_kp_451), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":15
 *         return OUTPUT_METHOD_XML
 *     if method == u"html":
 *         return OUTPUT_METHOD_HTML             # <<<<<<<<<<<<<<
 *     if method == u"text":
 *         return OUTPUT_METHOD_TEXT
 */
    __pyx_r = __pyx_e_4lxml_5etree_OUTPUT_METHOD_HTML;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":16
 *     if method == u"html":
 *         return OUTPUT_METHOD_HTML
 *     if method == u"text":             # <<<<<<<<<<<<<<
 *         return OUTPUT_METHOD_TEXT
 *     raise ValueError, u"unknown output method %r" % method
 */
  __pyx_2 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_kp_452), Py_EQ); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":17
 *         return OUTPUT_METHOD_HTML
 *     if method == u"text":
 *         return OUTPUT_METHOD_TEXT             # <<<<<<<<<<<<<<
 *     raise ValueError, u"unknown output method %r" % method
 * 
 */
    __pyx_r = __pyx_e_4lxml_5etree_OUTPUT_METHOD_TEXT;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":18
 *     if method == u"text":
 *         return OUTPUT_METHOD_TEXT
 *     raise ValueError, u"unknown output method %r" % method             # <<<<<<<<<<<<<<
 * 
 * cdef _textToString(xmlNode* c_node, encoding, bint with_tail):
 */
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_453), __pyx_v_method); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  {__pyx_filename = __pyx_f[3]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._findOutputMethod");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_method);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":20
 *     raise ValueError, u"unknown output method %r" % method
 * 
 * cdef _textToString(xmlNode* c_node, encoding, bint with_tail):             # <<<<<<<<<<<<<<
 *     cdef bint needs_conversion
 *     cdef char* c_text
 */

static  PyObject *__pyx_f_4lxml_5etree__textToString(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_encoding, int __pyx_v_with_tail) {
  int __pyx_v_needs_conversion;
  char *__pyx_v_c_text;
  xmlNode *__pyx_v_c_text_node;
  xmlBuffer *__pyx_v_c_buffer;
  PyObject *__pyx_v_text;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  char *__pyx_5;
  Py_INCREF(__pyx_v_encoding);
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":26
 *     cdef tree.xmlBuffer* c_buffer
 * 
 *     c_buffer = tree.xmlBufferCreate()             # <<<<<<<<<<<<<<
 *     if c_buffer is NULL:
 *         return python.PyErr_NoMemory()
 */
  __pyx_v_c_buffer = xmlBufferCreate();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":27
 * 
 *     c_buffer = tree.xmlBufferCreate()
 *     if c_buffer is NULL:             # <<<<<<<<<<<<<<
 *         return python.PyErr_NoMemory()
 * 
 */
  __pyx_1 = (__pyx_v_c_buffer == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":28
 *     c_buffer = tree.xmlBufferCreate()
 *     if c_buffer is NULL:
 *         return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":30
 *         return python.PyErr_NoMemory()
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         tree.xmlNodeBufGetContent(c_buffer, c_node)
 *         if with_tail:
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":31
 * 
 *     with nogil:
 *         tree.xmlNodeBufGetContent(c_buffer, c_node)             # <<<<<<<<<<<<<<
 *         if with_tail:
 *             c_text_node = _textNodeOrSkip(c_node.next)
 */
      xmlNodeBufGetContent(__pyx_v_c_buffer, __pyx_v_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":32
 *     with nogil:
 *         tree.xmlNodeBufGetContent(c_buffer, c_node)
 *         if with_tail:             # <<<<<<<<<<<<<<
 *             c_text_node = _textNodeOrSkip(c_node.next)
 *             while c_text_node is not NULL:
 */
      __pyx_1 = __pyx_v_with_tail;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":33
 *         tree.xmlNodeBufGetContent(c_buffer, c_node)
 *         if with_tail:
 *             c_text_node = _textNodeOrSkip(c_node.next)             # <<<<<<<<<<<<<<
 *             while c_text_node is not NULL:
 *                 tree.xmlBufferWriteChar(c_buffer, c_text_node.content)
 */
        __pyx_v_c_text_node = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_node->next);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":34
 *         if with_tail:
 *             c_text_node = _textNodeOrSkip(c_node.next)
 *             while c_text_node is not NULL:             # <<<<<<<<<<<<<<
 *                 tree.xmlBufferWriteChar(c_buffer, c_text_node.content)
 *                 c_text_node = _textNodeOrSkip(c_text_node.next)
 */
        while (1) {
          __pyx_1 = (__pyx_v_c_text_node != NULL);
          if (!__pyx_1) break;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":35
 *             c_text_node = _textNodeOrSkip(c_node.next)
 *             while c_text_node is not NULL:
 *                 tree.xmlBufferWriteChar(c_buffer, c_text_node.content)             # <<<<<<<<<<<<<<
 *                 c_text_node = _textNodeOrSkip(c_text_node.next)
 *         c_text = tree.xmlBufferContent(c_buffer)
 */
          xmlBufferWriteChar(__pyx_v_c_buffer, __pyx_v_c_text_node->content);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":36
 *             while c_text_node is not NULL:
 *                 tree.xmlBufferWriteChar(c_buffer, c_text_node.content)
 *                 c_text_node = _textNodeOrSkip(c_text_node.next)             # <<<<<<<<<<<<<<
 *         c_text = tree.xmlBufferContent(c_buffer)
 * 
 */
          __pyx_v_c_text_node = __pyx_f_4lxml_5etree__textNodeOrSkip(__pyx_v_c_text_node->next);
        }
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":37
 *                 tree.xmlBufferWriteChar(c_buffer, c_text_node.content)
 *                 c_text_node = _textNodeOrSkip(c_text_node.next)
 *         c_text = tree.xmlBufferContent(c_buffer)             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
      __pyx_v_c_text = xmlBufferContent(__pyx_v_c_buffer);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":39
 *         c_text = tree.xmlBufferContent(c_buffer)
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         needs_conversion = 0
 *         if encoding is _unicode:
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":40
 * 
 *     try:
 *         needs_conversion = 0             # <<<<<<<<<<<<<<
 *         if encoding is _unicode:
 *             needs_conversion = 1
 */
    __pyx_v_needs_conversion = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":41
 *     try:
 *         needs_conversion = 0
 *         if encoding is _unicode:             # <<<<<<<<<<<<<<
 *             needs_conversion = 1
 *         elif encoding is not None:
 */
    __pyx_1 = (__pyx_v_encoding == __pyx_v_4lxml_5etree__unicode);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":42
 *         needs_conversion = 0
 *         if encoding is _unicode:
 *             needs_conversion = 1             # <<<<<<<<<<<<<<
 *         elif encoding is not None:
 *             encoding = encoding.upper()
 */
      __pyx_v_needs_conversion = 1;
      goto __pyx_L13;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":43
 *         if encoding is _unicode:
 *             needs_conversion = 1
 *         elif encoding is not None:             # <<<<<<<<<<<<<<
 *             encoding = encoding.upper()
 *             if encoding != u'UTF-8':
 */
    __pyx_1 = (__pyx_v_encoding != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":44
 *             needs_conversion = 1
 *         elif encoding is not None:
 *             encoding = encoding.upper()             # <<<<<<<<<<<<<<
 *             if encoding != u'UTF-8':
 *                 if encoding == u'ASCII':
 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_encoding, __pyx_kp_upper); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L11;}
      __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L11;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_encoding);
      __pyx_v_encoding = __pyx_3;
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":45
 *         elif encoding is not None:
 *             encoding = encoding.upper()
 *             if encoding != u'UTF-8':             # <<<<<<<<<<<<<<
 *                 if encoding == u'ASCII':
 *                     if isutf8(c_text):
 */
      __pyx_2 = PyObject_RichCompare(__pyx_v_encoding, ((PyObject *)__pyx_kp_454), Py_NE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L11;}
      __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L11;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":46
 *             encoding = encoding.upper()
 *             if encoding != u'UTF-8':
 *                 if encoding == u'ASCII':             # <<<<<<<<<<<<<<
 *                     if isutf8(c_text):
 *                         # will raise a decode error below
 */
        __pyx_3 = PyObject_RichCompare(__pyx_v_encoding, ((PyObject *)__pyx_kp_455), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L11;}
        __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L11;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":47
 *             if encoding != u'UTF-8':
 *                 if encoding == u'ASCII':
 *                     if isutf8(c_text):             # <<<<<<<<<<<<<<
 *                         # will raise a decode error below
 *                         needs_conversion = 1
 */
          __pyx_4 = __pyx_f_4lxml_5etree_isutf8(__pyx_v_c_text);
          if (__pyx_4) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":49
 *                     if isutf8(c_text):
 *                         # will raise a decode error below
 *                         needs_conversion = 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     needs_conversion = 1
 */
            __pyx_v_needs_conversion = 1;
            goto __pyx_L16;
          }
          __pyx_L16:;
          goto __pyx_L15;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":51
 *                         needs_conversion = 1
 *                 else:
 *                     needs_conversion = 1             # <<<<<<<<<<<<<<
 * 
 *         if needs_conversion:
 */
          __pyx_v_needs_conversion = 1;
        }
        __pyx_L15:;
        goto __pyx_L14;
      }
      __pyx_L14:;
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":53
 *                     needs_conversion = 1
 * 
 *         if needs_conversion:             # <<<<<<<<<<<<<<
 *             text = python.PyUnicode_DecodeUTF8(
 *                 c_text, tree.xmlBufferLength(c_buffer), 'strict')
 */
    __pyx_1 = __pyx_v_needs_conversion;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":55
 *         if needs_conversion:
 *             text = python.PyUnicode_DecodeUTF8(
 *                 c_text, tree.xmlBufferLength(c_buffer), 'strict')             # <<<<<<<<<<<<<<
 *             if encoding is not _unicode:
 *                 encoding = _utf8(encoding)
 */
      __pyx_2 = PyUnicode_DecodeUTF8(__pyx_v_c_text, xmlBufferLength(__pyx_v_c_buffer), __pyx_k_456); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L11;}
      Py_DECREF(__pyx_v_text);
      __pyx_v_text = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":56
 *             text = python.PyUnicode_DecodeUTF8(
 *                 c_text, tree.xmlBufferLength(c_buffer), 'strict')
 *             if encoding is not _unicode:             # <<<<<<<<<<<<<<
 *                 encoding = _utf8(encoding)
 *                 text = python.PyUnicode_AsEncodedString(
 */
      __pyx_1 = (__pyx_v_encoding != __pyx_v_4lxml_5etree__unicode);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":57
 *                 c_text, tree.xmlBufferLength(c_buffer), 'strict')
 *             if encoding is not _unicode:
 *                 encoding = _utf8(encoding)             # <<<<<<<<<<<<<<
 *                 text = python.PyUnicode_AsEncodedString(
 *                     text, encoding, 'strict')
 */
        __pyx_3 = __pyx_f_4lxml_5etree__utf8(__pyx_v_encoding); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L11;}
        Py_DECREF(__pyx_v_encoding);
        __pyx_v_encoding = __pyx_3;
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":59
 *                 encoding = _utf8(encoding)
 *                 text = python.PyUnicode_AsEncodedString(
 *                     text, encoding, 'strict')             # <<<<<<<<<<<<<<
 *         else:
 *             text = c_text
 */
        __pyx_5 = __Pyx_PyBytes_AsString(__pyx_v_encoding); if (unlikely((!__pyx_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L11;}
        __pyx_2 = PyUnicode_AsEncodedString(__pyx_v_text, __pyx_5, __pyx_k_457); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L11;}
        Py_DECREF(__pyx_v_text);
        __pyx_v_text = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L18;
      }
      __pyx_L18:;
      goto __pyx_L17;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":61
 *                     text, encoding, 'strict')
 *         else:
 *             text = c_text             # <<<<<<<<<<<<<<
 *     finally:
 *         tree.xmlBufferFree(c_buffer);
 */
      __pyx_3 = __Pyx_PyBytes_FromString(__pyx_v_c_text); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L11;}
      Py_DECREF(__pyx_v_text);
      __pyx_v_text = __pyx_3;
      __pyx_3 = 0;
    }
    __pyx_L17:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L12;
    __pyx_L11: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":63
 *             text = c_text
 *     finally:
 *         tree.xmlBufferFree(c_buffer);             # <<<<<<<<<<<<<<
 *     return text
 * 
 */
    xmlBufferFree(__pyx_v_c_buffer);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":64
 *     finally:
 *         tree.xmlBufferFree(c_buffer);
 *     return text             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_text);
  __pyx_r = __pyx_v_text;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._textToString");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_text);
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":67
 * 
 * 
 * cdef _tostring(_Element element, encoding, method,             # <<<<<<<<<<<<<<
 *                bint write_xml_declaration, bint write_complete_document,
 *                bint pretty_print, bint with_tail):
 */

static  PyObject *__pyx_f_4lxml_5etree__tostring(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_encoding, PyObject *__pyx_v_method, int __pyx_v_write_xml_declaration, int __pyx_v_write_complete_document, int __pyx_v_pretty_print, int __pyx_v_with_tail) {
  xmlOutputBuffer *__pyx_v_c_buffer;
  xmlBuffer *__pyx_v_c_result_buffer;
  xmlCharEncodingHandler *__pyx_v_enchandler;
  char *__pyx_v_c_enc;
  int __pyx_v_c_method;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_encoding);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":79
 *     cdef char* c_version
 *     cdef int c_method
 *     if element is None:             # <<<<<<<<<<<<<<
 *         return None
 *     c_method = _findOutputMethod(method)
 */
  __pyx_1 = (((PyObject *)__pyx_v_element) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":80
 *     cdef int c_method
 *     if element is None:
 *         return None             # <<<<<<<<<<<<<<
 *     c_method = _findOutputMethod(method)
 *     if c_method == OUTPUT_METHOD_TEXT:
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":81
 *     if element is None:
 *         return None
 *     c_method = _findOutputMethod(method)             # <<<<<<<<<<<<<<
 *     if c_method == OUTPUT_METHOD_TEXT:
 *         return _textToString(element._c_node, encoding, with_tail)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__findOutputMethod(__pyx_v_method); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_method = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":82
 *         return None
 *     c_method = _findOutputMethod(method)
 *     if c_method == OUTPUT_METHOD_TEXT:             # <<<<<<<<<<<<<<
 *         return _textToString(element._c_node, encoding, with_tail)
 *     if encoding is None or encoding is _unicode:
 */
  __pyx_1 = (__pyx_v_c_method == __pyx_e_4lxml_5etree_OUTPUT_METHOD_TEXT);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":83
 *     c_method = _findOutputMethod(method)
 *     if c_method == OUTPUT_METHOD_TEXT:
 *         return _textToString(element._c_node, encoding, with_tail)             # <<<<<<<<<<<<<<
 *     if encoding is None or encoding is _unicode:
 *         c_enc = NULL
 */
    __pyx_3 = __pyx_f_4lxml_5etree__textToString(__pyx_v_element->_c_node, __pyx_v_encoding, __pyx_v_with_tail); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":84
 *     if c_method == OUTPUT_METHOD_TEXT:
 *         return _textToString(element._c_node, encoding, with_tail)
 *     if encoding is None or encoding is _unicode:             # <<<<<<<<<<<<<<
 *         c_enc = NULL
 *     else:
 */
  __pyx_1 = (__pyx_v_encoding == Py_None);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_encoding == __pyx_v_4lxml_5etree__unicode);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":85
 *         return _textToString(element._c_node, encoding, with_tail)
 *     if encoding is None or encoding is _unicode:
 *         c_enc = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         encoding = _utf8(encoding)
 */
    __pyx_v_c_enc = NULL;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":87
 *         c_enc = NULL
 *     else:
 *         encoding = _utf8(encoding)             # <<<<<<<<<<<<<<
 *         c_enc = _cstr(encoding)
 *     # it is necessary to *and* find the encoding handler *and* use
 */
    __pyx_3 = __pyx_f_4lxml_5etree__utf8(__pyx_v_encoding); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":88
 *     else:
 *         encoding = _utf8(encoding)
 *         c_enc = _cstr(encoding)             # <<<<<<<<<<<<<<
 *     # it is necessary to *and* find the encoding handler *and* use
 *     # encoding during output
 */
    __pyx_v_c_enc = PyString_AS_STRING(__pyx_v_encoding);
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":91
 *     # it is necessary to *and* find the encoding handler *and* use
 *     # encoding during output
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)             # <<<<<<<<<<<<<<
 *     if enchandler is NULL and c_enc is not NULL:
 *         if encoding is not None:
 */
  __pyx_v_enchandler = xmlFindCharEncodingHandler(__pyx_v_c_enc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":92
 *     # encoding during output
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)
 *     if enchandler is NULL and c_enc is not NULL:             # <<<<<<<<<<<<<<
 *         if encoding is not None:
 *             encoding = encoding.decode(u'UTF-8')
 */
  __pyx_1 = (__pyx_v_enchandler == NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_enc != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":93
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)
 *     if enchandler is NULL and c_enc is not NULL:
 *         if encoding is not None:             # <<<<<<<<<<<<<<
 *             encoding = encoding.decode(u'UTF-8')
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 */
    __pyx_1 = (__pyx_v_encoding != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":94
 *     if enchandler is NULL and c_enc is not NULL:
 *         if encoding is not None:
 *             encoding = encoding.decode(u'UTF-8')             # <<<<<<<<<<<<<<
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 *     c_buffer = tree.xmlAllocOutputBuffer(enchandler)
 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_encoding, __pyx_kp_decode); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_458));
      PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_kp_458));
      __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      Py_DECREF(__pyx_v_encoding);
      __pyx_v_encoding = __pyx_5;
      __pyx_5 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":95
 *         if encoding is not None:
 *             encoding = encoding.decode(u'UTF-8')
 *         raise LookupError, u"unknown encoding: '%s'" % encoding             # <<<<<<<<<<<<<<
 *     c_buffer = tree.xmlAllocOutputBuffer(enchandler)
 *     if c_buffer is NULL:
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_459), __pyx_v_encoding); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_builtin_LookupError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":96
 *             encoding = encoding.decode(u'UTF-8')
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 *     c_buffer = tree.xmlAllocOutputBuffer(enchandler)             # <<<<<<<<<<<<<<
 *     if c_buffer is NULL:
 *         tree.xmlCharEncCloseFunc(enchandler)
 */
  __pyx_v_c_buffer = xmlAllocOutputBuffer(__pyx_v_enchandler);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":97
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 *     c_buffer = tree.xmlAllocOutputBuffer(enchandler)
 *     if c_buffer is NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlCharEncCloseFunc(enchandler)
 *         return python.PyErr_NoMemory()
 */
  __pyx_1 = (__pyx_v_c_buffer == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":98
 *     c_buffer = tree.xmlAllocOutputBuffer(enchandler)
 *     if c_buffer is NULL:
 *         tree.xmlCharEncCloseFunc(enchandler)             # <<<<<<<<<<<<<<
 *         return python.PyErr_NoMemory()
 * 
 */
    xmlCharEncCloseFunc(__pyx_v_enchandler);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":99
 *     if c_buffer is NULL:
 *         tree.xmlCharEncCloseFunc(enchandler)
 *         return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
    __pyx_3 = PyErr_NoMemory(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":101
 *         return python.PyErr_NoMemory()
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         _writeNodeToBuffer(c_buffer, element._c_node, c_enc, c_method,
 *                            write_xml_declaration, write_complete_document,
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":104
 *         _writeNodeToBuffer(c_buffer, element._c_node, c_enc, c_method,
 *                            write_xml_declaration, write_complete_document,
 *                            pretty_print, with_tail)             # <<<<<<<<<<<<<<
 *         tree.xmlOutputBufferFlush(c_buffer)
 *         if c_buffer.conv is not NULL:
 */
      __pyx_f_4lxml_5etree__writeNodeToBuffer(__pyx_v_c_buffer, __pyx_v_element->_c_node, __pyx_v_c_enc, __pyx_v_c_method, __pyx_v_write_xml_declaration, __pyx_v_write_complete_document, __pyx_v_pretty_print, __pyx_v_with_tail);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":105
 *                            write_xml_declaration, write_complete_document,
 *                            pretty_print, with_tail)
 *         tree.xmlOutputBufferFlush(c_buffer)             # <<<<<<<<<<<<<<
 *         if c_buffer.conv is not NULL:
 *             c_result_buffer = c_buffer.conv
 */
      xmlOutputBufferFlush(__pyx_v_c_buffer);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":106
 *                            pretty_print, with_tail)
 *         tree.xmlOutputBufferFlush(c_buffer)
 *         if c_buffer.conv is not NULL:             # <<<<<<<<<<<<<<
 *             c_result_buffer = c_buffer.conv
 *         else:
 */
      __pyx_1 = (__pyx_v_c_buffer->conv != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":107
 *         tree.xmlOutputBufferFlush(c_buffer)
 *         if c_buffer.conv is not NULL:
 *             c_result_buffer = c_buffer.conv             # <<<<<<<<<<<<<<
 *         else:
 *             c_result_buffer = c_buffer.buffer
 */
        __pyx_v_c_result_buffer = __pyx_v_c_buffer->conv;
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":109
 *             c_result_buffer = c_buffer.conv
 *         else:
 *             c_result_buffer = c_buffer.buffer             # <<<<<<<<<<<<<<
 * 
 *     try:
 */
        __pyx_v_c_result_buffer = __pyx_v_c_buffer->buffer;
      }
      __pyx_L12:;
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":111
 *             c_result_buffer = c_buffer.buffer
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         if encoding is _unicode:
 *             result = python.PyUnicode_DecodeUTF8(
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":112
 * 
 *     try:
 *         if encoding is _unicode:             # <<<<<<<<<<<<<<
 *             result = python.PyUnicode_DecodeUTF8(
 *                 tree.xmlBufferContent(c_result_buffer),
 */
    __pyx_1 = (__pyx_v_encoding == __pyx_v_4lxml_5etree__unicode);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":116
 *                 tree.xmlBufferContent(c_result_buffer),
 *                 tree.xmlBufferLength(c_result_buffer),
 *                 'strict')             # <<<<<<<<<<<<<<
 *         else:
 *             result = python.PyString_FromStringAndSize(
 */
      __pyx_4 = PyUnicode_DecodeUTF8(xmlBufferContent(__pyx_v_c_result_buffer), xmlBufferLength(__pyx_v_c_result_buffer), __pyx_k_460); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L14;}
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_4;
      __pyx_4 = 0;
      goto __pyx_L16;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":120
 *             result = python.PyString_FromStringAndSize(
 *                 tree.xmlBufferContent(c_result_buffer),
 *                 tree.xmlBufferLength(c_result_buffer))             # <<<<<<<<<<<<<<
 *     finally:
 *         tree.xmlOutputBufferClose(c_buffer)
 */
      __pyx_5 = PyString_FromStringAndSize(xmlBufferContent(__pyx_v_c_result_buffer), xmlBufferLength(__pyx_v_c_result_buffer)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L14;}
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_5;
      __pyx_5 = 0;
    }
    __pyx_L16:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L15;
    __pyx_L14: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
      Py_XDECREF(__pyx_5); __pyx_5 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":122
 *                 tree.xmlBufferLength(c_result_buffer))
 *     finally:
 *         tree.xmlOutputBufferClose(c_buffer)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    xmlOutputBufferClose(__pyx_v_c_buffer);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":123
 *     finally:
 *         tree.xmlOutputBufferClose(c_buffer)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef void _writeNodeToBuffer(tree.xmlOutputBuffer* c_buffer,
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._tostring");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":125
 *     return result
 * 
 * cdef void _writeNodeToBuffer(tree.xmlOutputBuffer* c_buffer,             # <<<<<<<<<<<<<<
 *                              xmlNode* c_node, char* encoding, int c_method,
 *                              bint write_xml_declaration,
 */

static  void __pyx_f_4lxml_5etree__writeNodeToBuffer(xmlOutputBuffer *__pyx_v_c_buffer, xmlNode *__pyx_v_c_node, char *__pyx_v_encoding, int __pyx_v_c_method, int __pyx_v_write_xml_declaration, int __pyx_v_write_complete_document, int __pyx_v_pretty_print, int __pyx_v_with_tail) {
  xmlDoc *__pyx_v_c_doc;
  xmlNode *__pyx_v_c_nsdecl_node;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":132
 *     cdef xmlDoc* c_doc
 *     cdef xmlNode* c_nsdecl_node
 *     c_doc = c_node.doc             # <<<<<<<<<<<<<<
 *     if write_xml_declaration and c_method == OUTPUT_METHOD_XML:
 *         _writeDeclarationToBuffer(c_buffer, c_doc.version, encoding)
 */
  __pyx_v_c_doc = __pyx_v_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":133
 *     cdef xmlNode* c_nsdecl_node
 *     c_doc = c_node.doc
 *     if write_xml_declaration and c_method == OUTPUT_METHOD_XML:             # <<<<<<<<<<<<<<
 *         _writeDeclarationToBuffer(c_buffer, c_doc.version, encoding)
 * 
 */
  __pyx_1 = __pyx_v_write_xml_declaration;
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_method == __pyx_e_4lxml_5etree_OUTPUT_METHOD_XML);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":134
 *     c_doc = c_node.doc
 *     if write_xml_declaration and c_method == OUTPUT_METHOD_XML:
 *         _writeDeclarationToBuffer(c_buffer, c_doc.version, encoding)             # <<<<<<<<<<<<<<
 * 
 *     # write internal DTD subset, preceding PIs/comments, etc.
 */
    __pyx_f_4lxml_5etree__writeDeclarationToBuffer(__pyx_v_c_buffer, __pyx_v_c_doc->version, __pyx_v_encoding);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":137
 * 
 *     # write internal DTD subset, preceding PIs/comments, etc.
 *     if write_complete_document:             # <<<<<<<<<<<<<<
 *         _writeDtdToBuffer(c_buffer, c_doc, c_node.name, encoding)
 *         _writePrevSiblings(c_buffer, c_node, encoding, pretty_print)
 */
  __pyx_1 = __pyx_v_write_complete_document;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":138
 *     # write internal DTD subset, preceding PIs/comments, etc.
 *     if write_complete_document:
 *         _writeDtdToBuffer(c_buffer, c_doc, c_node.name, encoding)             # <<<<<<<<<<<<<<
 *         _writePrevSiblings(c_buffer, c_node, encoding, pretty_print)
 * 
 */
    __pyx_f_4lxml_5etree__writeDtdToBuffer(__pyx_v_c_buffer, __pyx_v_c_doc, __pyx_v_c_node->name, __pyx_v_encoding);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":139
 *     if write_complete_document:
 *         _writeDtdToBuffer(c_buffer, c_doc, c_node.name, encoding)
 *         _writePrevSiblings(c_buffer, c_node, encoding, pretty_print)             # <<<<<<<<<<<<<<
 * 
 *     c_nsdecl_node = c_node
 */
    __pyx_f_4lxml_5etree__writePrevSiblings(__pyx_v_c_buffer, __pyx_v_c_node, __pyx_v_encoding, __pyx_v_pretty_print);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":141
 *         _writePrevSiblings(c_buffer, c_node, encoding, pretty_print)
 * 
 *     c_nsdecl_node = c_node             # <<<<<<<<<<<<<<
 *     if c_node.parent is NULL or c_node.parent.type != tree.XML_DOCUMENT_NODE:
 *         # copy the node and add namespaces from parents
 */
  __pyx_v_c_nsdecl_node = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":142
 * 
 *     c_nsdecl_node = c_node
 *     if c_node.parent is NULL or c_node.parent.type != tree.XML_DOCUMENT_NODE:             # <<<<<<<<<<<<<<
 *         # copy the node and add namespaces from parents
 *         # this is required to make libxml write them
 */
  __pyx_1 = (__pyx_v_c_node->parent == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c_node->parent->type != XML_DOCUMENT_NODE);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":145
 *         # copy the node and add namespaces from parents
 *         # this is required to make libxml write them
 *         c_nsdecl_node = tree.xmlCopyNode(c_node, 2)             # <<<<<<<<<<<<<<
 *         _copyParentNamespaces(c_node, c_nsdecl_node)
 * 
 */
    __pyx_v_c_nsdecl_node = xmlCopyNode(__pyx_v_c_node, 2);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":146
 *         # this is required to make libxml write them
 *         c_nsdecl_node = tree.xmlCopyNode(c_node, 2)
 *         _copyParentNamespaces(c_node, c_nsdecl_node)             # <<<<<<<<<<<<<<
 * 
 *         c_nsdecl_node.parent = c_node.parent
 */
    __pyx_f_4lxml_5etree__copyParentNamespaces(__pyx_v_c_node, __pyx_v_c_nsdecl_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":148
 *         _copyParentNamespaces(c_node, c_nsdecl_node)
 * 
 *         c_nsdecl_node.parent = c_node.parent             # <<<<<<<<<<<<<<
 *         c_nsdecl_node.children = c_node.children
 *         c_nsdecl_node.last = c_node.last
 */
    __pyx_v_c_nsdecl_node->parent = __pyx_v_c_node->parent;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":149
 * 
 *         c_nsdecl_node.parent = c_node.parent
 *         c_nsdecl_node.children = c_node.children             # <<<<<<<<<<<<<<
 *         c_nsdecl_node.last = c_node.last
 * 
 */
    __pyx_v_c_nsdecl_node->children = __pyx_v_c_node->children;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":150
 *         c_nsdecl_node.parent = c_node.parent
 *         c_nsdecl_node.children = c_node.children
 *         c_nsdecl_node.last = c_node.last             # <<<<<<<<<<<<<<
 * 
 *     # write node
 */
    __pyx_v_c_nsdecl_node->last = __pyx_v_c_node->last;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":153
 * 
 *     # write node
 *     if c_method == OUTPUT_METHOD_XML:             # <<<<<<<<<<<<<<
 *         tree.xmlNodeDumpOutput(
 *             c_buffer, c_doc, c_nsdecl_node, 0, pretty_print, encoding)
 */
  __pyx_1 = (__pyx_v_c_method == __pyx_e_4lxml_5etree_OUTPUT_METHOD_XML);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":155
 *     if c_method == OUTPUT_METHOD_XML:
 *         tree.xmlNodeDumpOutput(
 *             c_buffer, c_doc, c_nsdecl_node, 0, pretty_print, encoding)             # <<<<<<<<<<<<<<
 *     else:
 *         tree.htmlNodeDumpFormatOutput(
 */
    xmlNodeDumpOutput(__pyx_v_c_buffer, __pyx_v_c_doc, __pyx_v_c_nsdecl_node, 0, __pyx_v_pretty_print, __pyx_v_encoding);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":158
 *     else:
 *         tree.htmlNodeDumpFormatOutput(
 *             c_buffer, c_doc, c_nsdecl_node, encoding, pretty_print)             # <<<<<<<<<<<<<<
 * 
 *     if c_nsdecl_node is not c_node:
 */
    htmlNodeDumpFormatOutput(__pyx_v_c_buffer, __pyx_v_c_doc, __pyx_v_c_nsdecl_node, __pyx_v_encoding, __pyx_v_pretty_print);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":160
 *             c_buffer, c_doc, c_nsdecl_node, encoding, pretty_print)
 * 
 *     if c_nsdecl_node is not c_node:             # <<<<<<<<<<<<<<
 *         # clean up
 *         c_nsdecl_node.children = c_nsdecl_node.last = NULL
 */
  __pyx_1 = (__pyx_v_c_nsdecl_node != __pyx_v_c_node);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":162
 *     if c_nsdecl_node is not c_node:
 *         # clean up
 *         c_nsdecl_node.children = c_nsdecl_node.last = NULL             # <<<<<<<<<<<<<<
 *         tree.xmlFreeNode(c_nsdecl_node)
 * 
 */
    __pyx_v_c_nsdecl_node->children = NULL;
    __pyx_v_c_nsdecl_node->last = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":163
 *         # clean up
 *         c_nsdecl_node.children = c_nsdecl_node.last = NULL
 *         tree.xmlFreeNode(c_nsdecl_node)             # <<<<<<<<<<<<<<
 * 
 *     # write tail, trailing comments, etc.
 */
    xmlFreeNode(__pyx_v_c_nsdecl_node);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":166
 * 
 *     # write tail, trailing comments, etc.
 *     if with_tail:             # <<<<<<<<<<<<<<
 *         _writeTail(c_buffer, c_node, encoding, pretty_print)
 *     if write_complete_document:
 */
  __pyx_1 = __pyx_v_with_tail;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":167
 *     # write tail, trailing comments, etc.
 *     if with_tail:
 *         _writeTail(c_buffer, c_node, encoding, pretty_print)             # <<<<<<<<<<<<<<
 *     if write_complete_document:
 *         _writeNextSiblings(c_buffer, c_node, encoding, pretty_print)
 */
    __pyx_f_4lxml_5etree__writeTail(__pyx_v_c_buffer, __pyx_v_c_node, __pyx_v_encoding, __pyx_v_pretty_print);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":168
 *     if with_tail:
 *         _writeTail(c_buffer, c_node, encoding, pretty_print)
 *     if write_complete_document:             # <<<<<<<<<<<<<<
 *         _writeNextSiblings(c_buffer, c_node, encoding, pretty_print)
 *     if pretty_print:
 */
  __pyx_1 = __pyx_v_write_complete_document;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":169
 *         _writeTail(c_buffer, c_node, encoding, pretty_print)
 *     if write_complete_document:
 *         _writeNextSiblings(c_buffer, c_node, encoding, pretty_print)             # <<<<<<<<<<<<<<
 *     if pretty_print:
 *         tree.xmlOutputBufferWriteString(c_buffer, "\n")
 */
    __pyx_f_4lxml_5etree__writeNextSiblings(__pyx_v_c_buffer, __pyx_v_c_node, __pyx_v_encoding, __pyx_v_pretty_print);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":170
 *     if write_complete_document:
 *         _writeNextSiblings(c_buffer, c_node, encoding, pretty_print)
 *     if pretty_print:             # <<<<<<<<<<<<<<
 *         tree.xmlOutputBufferWriteString(c_buffer, "\n")
 * 
 */
  __pyx_1 = __pyx_v_pretty_print;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":171
 *         _writeNextSiblings(c_buffer, c_node, encoding, pretty_print)
 *     if pretty_print:
 *         tree.xmlOutputBufferWriteString(c_buffer, "\n")             # <<<<<<<<<<<<<<
 * 
 * cdef void _writeDeclarationToBuffer(tree.xmlOutputBuffer* c_buffer,
 */
    xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_461);
    goto __pyx_L10;
  }
  __pyx_L10:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":173
 *         tree.xmlOutputBufferWriteString(c_buffer, "\n")
 * 
 * cdef void _writeDeclarationToBuffer(tree.xmlOutputBuffer* c_buffer,             # <<<<<<<<<<<<<<
 *                                     char* version, char* encoding) nogil:
 *     if version is NULL:
 */

static  void __pyx_f_4lxml_5etree__writeDeclarationToBuffer(xmlOutputBuffer *__pyx_v_c_buffer, char *__pyx_v_version, char *__pyx_v_encoding) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":175
 * cdef void _writeDeclarationToBuffer(tree.xmlOutputBuffer* c_buffer,
 *                                     char* version, char* encoding) nogil:
 *     if version is NULL:             # <<<<<<<<<<<<<<
 *         version = "1.0"
 *     tree.xmlOutputBufferWriteString(c_buffer, "<?xml version='")
 */
  __pyx_1 = (__pyx_v_version == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":176
 *                                     char* version, char* encoding) nogil:
 *     if version is NULL:
 *         version = "1.0"             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWriteString(c_buffer, "<?xml version='")
 *     tree.xmlOutputBufferWriteString(c_buffer, version)
 */
    __pyx_v_version = __pyx_k_462;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":177
 *     if version is NULL:
 *         version = "1.0"
 *     tree.xmlOutputBufferWriteString(c_buffer, "<?xml version='")             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWriteString(c_buffer, version)
 *     tree.xmlOutputBufferWriteString(c_buffer, "' encoding='")
 */
  xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_463);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":178
 *         version = "1.0"
 *     tree.xmlOutputBufferWriteString(c_buffer, "<?xml version='")
 *     tree.xmlOutputBufferWriteString(c_buffer, version)             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWriteString(c_buffer, "' encoding='")
 *     tree.xmlOutputBufferWriteString(c_buffer, encoding)
 */
  xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_v_version);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":179
 *     tree.xmlOutputBufferWriteString(c_buffer, "<?xml version='")
 *     tree.xmlOutputBufferWriteString(c_buffer, version)
 *     tree.xmlOutputBufferWriteString(c_buffer, "' encoding='")             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWriteString(c_buffer, encoding)
 *     tree.xmlOutputBufferWriteString(c_buffer, "'?>\n")
 */
  xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_464);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":180
 *     tree.xmlOutputBufferWriteString(c_buffer, version)
 *     tree.xmlOutputBufferWriteString(c_buffer, "' encoding='")
 *     tree.xmlOutputBufferWriteString(c_buffer, encoding)             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWriteString(c_buffer, "'?>\n")
 * 
 */
  xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_v_encoding);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":181
 *     tree.xmlOutputBufferWriteString(c_buffer, "' encoding='")
 *     tree.xmlOutputBufferWriteString(c_buffer, encoding)
 *     tree.xmlOutputBufferWriteString(c_buffer, "'?>\n")             # <<<<<<<<<<<<<<
 * 
 * cdef void _writeDtdToBuffer(tree.xmlOutputBuffer* c_buffer,
 */
  xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_465);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":183
 *     tree.xmlOutputBufferWriteString(c_buffer, "'?>\n")
 * 
 * cdef void _writeDtdToBuffer(tree.xmlOutputBuffer* c_buffer,             # <<<<<<<<<<<<<<
 *                             xmlDoc* c_doc, char* c_root_name,
 *                             char* encoding) nogil:
 */

static  void __pyx_f_4lxml_5etree__writeDtdToBuffer(xmlOutputBuffer *__pyx_v_c_buffer, xmlDoc *__pyx_v_c_doc, char *__pyx_v_c_root_name, char *__pyx_v_encoding) {
  xmlDtd *__pyx_v_c_dtd;
  xmlNode *__pyx_v_c_node;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":188
 *     cdef tree.xmlDtd* c_dtd
 *     cdef xmlNode* c_node
 *     c_dtd = c_doc.intSubset             # <<<<<<<<<<<<<<
 *     if c_dtd is NULL or c_dtd.name is NULL:
 *         return
 */
  __pyx_v_c_dtd = __pyx_v_c_doc->intSubset;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":189
 *     cdef xmlNode* c_node
 *     c_dtd = c_doc.intSubset
 *     if c_dtd is NULL or c_dtd.name is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     if cstd.strcmp(c_root_name, c_dtd.name) != 0:
 */
  __pyx_1 = (__pyx_v_c_dtd == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c_dtd->name == NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":190
 *     c_dtd = c_doc.intSubset
 *     if c_dtd is NULL or c_dtd.name is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     if cstd.strcmp(c_root_name, c_dtd.name) != 0:
 *         return
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":191
 *     if c_dtd is NULL or c_dtd.name is NULL:
 *         return
 *     if cstd.strcmp(c_root_name, c_dtd.name) != 0:             # <<<<<<<<<<<<<<
 *         return
 *     tree.xmlOutputBufferWrite(c_buffer, 10, "<!DOCTYPE ")
 */
  __pyx_1 = (strcmp(__pyx_v_c_root_name, __pyx_v_c_dtd->name) != 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":192
 *         return
 *     if cstd.strcmp(c_root_name, c_dtd.name) != 0:
 *         return             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWrite(c_buffer, 10, "<!DOCTYPE ")
 *     tree.xmlOutputBufferWriteString(c_buffer, c_dtd.name)
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":193
 *     if cstd.strcmp(c_root_name, c_dtd.name) != 0:
 *         return
 *     tree.xmlOutputBufferWrite(c_buffer, 10, "<!DOCTYPE ")             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWriteString(c_buffer, c_dtd.name)
 *     if c_dtd.SystemID != NULL and c_dtd.SystemID[0] != c'\0':
 */
  xmlOutputBufferWrite(__pyx_v_c_buffer, 10, __pyx_k_466);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":194
 *         return
 *     tree.xmlOutputBufferWrite(c_buffer, 10, "<!DOCTYPE ")
 *     tree.xmlOutputBufferWriteString(c_buffer, c_dtd.name)             # <<<<<<<<<<<<<<
 *     if c_dtd.SystemID != NULL and c_dtd.SystemID[0] != c'\0':
 *         if c_dtd.ExternalID != NULL and c_dtd.ExternalID[0] != c'\0':
 */
  xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_v_c_dtd->name);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":195
 *     tree.xmlOutputBufferWrite(c_buffer, 10, "<!DOCTYPE ")
 *     tree.xmlOutputBufferWriteString(c_buffer, c_dtd.name)
 *     if c_dtd.SystemID != NULL and c_dtd.SystemID[0] != c'\0':             # <<<<<<<<<<<<<<
 *         if c_dtd.ExternalID != NULL and c_dtd.ExternalID[0] != c'\0':
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' PUBLIC "')
 */
  __pyx_1 = (__pyx_v_c_dtd->SystemID != NULL);
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_c_dtd->SystemID[0]) != '\x00');
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":196
 *     tree.xmlOutputBufferWriteString(c_buffer, c_dtd.name)
 *     if c_dtd.SystemID != NULL and c_dtd.SystemID[0] != c'\0':
 *         if c_dtd.ExternalID != NULL and c_dtd.ExternalID[0] != c'\0':             # <<<<<<<<<<<<<<
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' PUBLIC "')
 *             tree.xmlOutputBufferWriteString(c_buffer, c_dtd.ExternalID)
 */
    __pyx_1 = (__pyx_v_c_dtd->ExternalID != NULL);
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_c_dtd->ExternalID[0]) != '\x00');
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":197
 *     if c_dtd.SystemID != NULL and c_dtd.SystemID[0] != c'\0':
 *         if c_dtd.ExternalID != NULL and c_dtd.ExternalID[0] != c'\0':
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' PUBLIC "')             # <<<<<<<<<<<<<<
 *             tree.xmlOutputBufferWriteString(c_buffer, c_dtd.ExternalID)
 *             tree.xmlOutputBufferWrite(c_buffer, 3, '" "')
 */
      xmlOutputBufferWrite(__pyx_v_c_buffer, 9, __pyx_k_467);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":198
 *         if c_dtd.ExternalID != NULL and c_dtd.ExternalID[0] != c'\0':
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' PUBLIC "')
 *             tree.xmlOutputBufferWriteString(c_buffer, c_dtd.ExternalID)             # <<<<<<<<<<<<<<
 *             tree.xmlOutputBufferWrite(c_buffer, 3, '" "')
 *         else:
 */
      xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_v_c_dtd->ExternalID);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":199
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' PUBLIC "')
 *             tree.xmlOutputBufferWriteString(c_buffer, c_dtd.ExternalID)
 *             tree.xmlOutputBufferWrite(c_buffer, 3, '" "')             # <<<<<<<<<<<<<<
 *         else:
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' SYSTEM "')
 */
      xmlOutputBufferWrite(__pyx_v_c_buffer, 3, __pyx_k_468);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":201
 *             tree.xmlOutputBufferWrite(c_buffer, 3, '" "')
 *         else:
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' SYSTEM "')             # <<<<<<<<<<<<<<
 *         tree.xmlOutputBufferWriteString(c_buffer, c_dtd.SystemID)
 *         tree.xmlOutputBufferWrite(c_buffer, 1, '"')
 */
      xmlOutputBufferWrite(__pyx_v_c_buffer, 9, __pyx_k_469);
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":202
 *         else:
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' SYSTEM "')
 *         tree.xmlOutputBufferWriteString(c_buffer, c_dtd.SystemID)             # <<<<<<<<<<<<<<
 *         tree.xmlOutputBufferWrite(c_buffer, 1, '"')
 *     if c_dtd.entities == NULL and c_dtd.elements == NULL and \
 */
    xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_v_c_dtd->SystemID);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":203
 *             tree.xmlOutputBufferWrite(c_buffer, 9, ' SYSTEM "')
 *         tree.xmlOutputBufferWriteString(c_buffer, c_dtd.SystemID)
 *         tree.xmlOutputBufferWrite(c_buffer, 1, '"')             # <<<<<<<<<<<<<<
 *     if c_dtd.entities == NULL and c_dtd.elements == NULL and \
 *            c_dtd.attributes == NULL and c_dtd.notations == NULL and \
 */
    xmlOutputBufferWrite(__pyx_v_c_buffer, 1, __pyx_k_470);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":204
 *         tree.xmlOutputBufferWriteString(c_buffer, c_dtd.SystemID)
 *         tree.xmlOutputBufferWrite(c_buffer, 1, '"')
 *     if c_dtd.entities == NULL and c_dtd.elements == NULL and \             # <<<<<<<<<<<<<<
 *            c_dtd.attributes == NULL and c_dtd.notations == NULL and \
 *            c_dtd.pentities == NULL:
 */
  __pyx_1 = (__pyx_v_c_dtd->entities == NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_dtd->elements == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":205
 *         tree.xmlOutputBufferWrite(c_buffer, 1, '"')
 *     if c_dtd.entities == NULL and c_dtd.elements == NULL and \
 *            c_dtd.attributes == NULL and c_dtd.notations == NULL and \             # <<<<<<<<<<<<<<
 *            c_dtd.pentities == NULL:
 *         tree.xmlOutputBufferWrite(c_buffer, 2, '>\n')
 */
      __pyx_1 = (__pyx_v_c_dtd->attributes == NULL);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_c_dtd->notations == NULL);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":206
 *     if c_dtd.entities == NULL and c_dtd.elements == NULL and \
 *            c_dtd.attributes == NULL and c_dtd.notations == NULL and \
 *            c_dtd.pentities == NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlOutputBufferWrite(c_buffer, 2, '>\n')
 *         return
 */
          __pyx_1 = (__pyx_v_c_dtd->pentities == NULL);
        }
      }
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":207
 *            c_dtd.attributes == NULL and c_dtd.notations == NULL and \
 *            c_dtd.pentities == NULL:
 *         tree.xmlOutputBufferWrite(c_buffer, 2, '>\n')             # <<<<<<<<<<<<<<
 *         return
 *     tree.xmlOutputBufferWrite(c_buffer, 3, ' [\n')
 */
    xmlOutputBufferWrite(__pyx_v_c_buffer, 2, __pyx_k_471);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":208
 *            c_dtd.pentities == NULL:
 *         tree.xmlOutputBufferWrite(c_buffer, 2, '>\n')
 *         return             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWrite(c_buffer, 3, ' [\n')
 *     if c_dtd.notations != NULL:
 */
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":209
 *         tree.xmlOutputBufferWrite(c_buffer, 2, '>\n')
 *         return
 *     tree.xmlOutputBufferWrite(c_buffer, 3, ' [\n')             # <<<<<<<<<<<<<<
 *     if c_dtd.notations != NULL:
 *         tree.xmlDumpNotationTable(c_buffer.buffer,
 */
  xmlOutputBufferWrite(__pyx_v_c_buffer, 3, __pyx_k_472);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":210
 *         return
 *     tree.xmlOutputBufferWrite(c_buffer, 3, ' [\n')
 *     if c_dtd.notations != NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlDumpNotationTable(c_buffer.buffer,
 *                                   <tree.xmlNotationTable*>c_dtd.notations)
 */
  __pyx_1 = (__pyx_v_c_dtd->notations != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":212
 *     if c_dtd.notations != NULL:
 *         tree.xmlDumpNotationTable(c_buffer.buffer,
 *                                   <tree.xmlNotationTable*>c_dtd.notations)             # <<<<<<<<<<<<<<
 *     c_node = c_dtd.children
 *     while c_node is not NULL:
 */
    xmlDumpNotationTable(__pyx_v_c_buffer->buffer, ((xmlNotationTable *)__pyx_v_c_dtd->notations));
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":213
 *         tree.xmlDumpNotationTable(c_buffer.buffer,
 *                                   <tree.xmlNotationTable*>c_dtd.notations)
 *     c_node = c_dtd.children             # <<<<<<<<<<<<<<
 *     while c_node is not NULL:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, 0, encoding)
 */
  __pyx_v_c_node = __pyx_v_c_dtd->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":214
 *                                   <tree.xmlNotationTable*>c_dtd.notations)
 *     c_node = c_dtd.children
 *     while c_node is not NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, 0, encoding)
 *         c_node = c_node.next
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":215
 *     c_node = c_dtd.children
 *     while c_node is not NULL:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, 0, encoding)             # <<<<<<<<<<<<<<
 *         c_node = c_node.next
 *     tree.xmlOutputBufferWrite(c_buffer, 3, "]>\n")
 */
    xmlNodeDumpOutput(__pyx_v_c_buffer, __pyx_v_c_node->doc, __pyx_v_c_node, 0, 0, __pyx_v_encoding);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":216
 *     while c_node is not NULL:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, 0, encoding)
 *         c_node = c_node.next             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferWrite(c_buffer, 3, "]>\n")
 * 
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":217
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, 0, encoding)
 *         c_node = c_node.next
 *     tree.xmlOutputBufferWrite(c_buffer, 3, "]>\n")             # <<<<<<<<<<<<<<
 * 
 * cdef void _writeTail(tree.xmlOutputBuffer* c_buffer, xmlNode* c_node,
 */
  xmlOutputBufferWrite(__pyx_v_c_buffer, 3, __pyx_k_473);

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":219
 *     tree.xmlOutputBufferWrite(c_buffer, 3, "]>\n")
 * 
 * cdef void _writeTail(tree.xmlOutputBuffer* c_buffer, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                      char* encoding, bint pretty_print) nogil:
 *     u"Write the element tail."
 */

static  void __pyx_f_4lxml_5etree__writeTail(xmlOutputBuffer *__pyx_v_c_buffer, xmlNode *__pyx_v_c_node, char *__pyx_v_encoding, int __pyx_v_pretty_print) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":222
 *                      char* encoding, bint pretty_print) nogil:
 *     u"Write the element tail."
 *     c_node = c_node.next             # <<<<<<<<<<<<<<
 *     while c_node is not NULL and c_node.type == tree.XML_TEXT_NODE:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0,
 */
  __pyx_v_c_node = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":223
 *     u"Write the element tail."
 *     c_node = c_node.next
 *     while c_node is not NULL and c_node.type == tree.XML_TEXT_NODE:             # <<<<<<<<<<<<<<
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0,
 *                                pretty_print, encoding)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_node != NULL);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_c_node->type == XML_TEXT_NODE);
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":225
 *     while c_node is not NULL and c_node.type == tree.XML_TEXT_NODE:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0,
 *                                pretty_print, encoding)             # <<<<<<<<<<<<<<
 *         c_node = c_node.next
 * 
 */
    xmlNodeDumpOutput(__pyx_v_c_buffer, __pyx_v_c_node->doc, __pyx_v_c_node, 0, __pyx_v_pretty_print, __pyx_v_encoding);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":226
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0,
 *                                pretty_print, encoding)
 *         c_node = c_node.next             # <<<<<<<<<<<<<<
 * 
 * cdef void _writePrevSiblings(tree.xmlOutputBuffer* c_buffer, xmlNode* c_node,
 */
    __pyx_v_c_node = __pyx_v_c_node->next;
  }

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":228
 *         c_node = c_node.next
 * 
 * cdef void _writePrevSiblings(tree.xmlOutputBuffer* c_buffer, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                              char* encoding, bint pretty_print) nogil:
 *     cdef xmlNode* c_sibling
 */

static  void __pyx_f_4lxml_5etree__writePrevSiblings(xmlOutputBuffer *__pyx_v_c_buffer, xmlNode *__pyx_v_c_node, char *__pyx_v_encoding, int __pyx_v_pretty_print) {
  xmlNode *__pyx_v_c_sibling;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":231
 *                              char* encoding, bint pretty_print) nogil:
 *     cdef xmlNode* c_sibling
 *     if c_node.parent is not NULL and _isElement(c_node.parent):             # <<<<<<<<<<<<<<
 *         return
 *     # we are at a root node, so add PI and comment siblings
 */
  __pyx_1 = (__pyx_v_c_node->parent != NULL);
  if (__pyx_1) {
    __pyx_1 = _isElement(__pyx_v_c_node->parent);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":232
 *     cdef xmlNode* c_sibling
 *     if c_node.parent is not NULL and _isElement(c_node.parent):
 *         return             # <<<<<<<<<<<<<<
 *     # we are at a root node, so add PI and comment siblings
 *     c_sibling = c_node
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":234
 *         return
 *     # we are at a root node, so add PI and comment siblings
 *     c_sibling = c_node             # <<<<<<<<<<<<<<
 *     while c_sibling.prev != NULL and \
 *             (c_sibling.prev.type == tree.XML_PI_NODE or \
 */
  __pyx_v_c_sibling = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":235
 *     # we are at a root node, so add PI and comment siblings
 *     c_sibling = c_node
 *     while c_sibling.prev != NULL and \             # <<<<<<<<<<<<<<
 *             (c_sibling.prev.type == tree.XML_PI_NODE or \
 *                  c_sibling.prev.type == tree.XML_COMMENT_NODE):
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_sibling->prev != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":236
 *     c_sibling = c_node
 *     while c_sibling.prev != NULL and \
 *             (c_sibling.prev.type == tree.XML_PI_NODE or \             # <<<<<<<<<<<<<<
 *                  c_sibling.prev.type == tree.XML_COMMENT_NODE):
 *         c_sibling = c_sibling.prev
 */
      __pyx_1 = (__pyx_v_c_sibling->prev->type == XML_PI_NODE);
      if (!__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":237
 *     while c_sibling.prev != NULL and \
 *             (c_sibling.prev.type == tree.XML_PI_NODE or \
 *                  c_sibling.prev.type == tree.XML_COMMENT_NODE):             # <<<<<<<<<<<<<<
 *         c_sibling = c_sibling.prev
 *     while c_sibling != c_node:
 */
        __pyx_1 = (__pyx_v_c_sibling->prev->type == XML_COMMENT_NODE);
      }
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":238
 *             (c_sibling.prev.type == tree.XML_PI_NODE or \
 *                  c_sibling.prev.type == tree.XML_COMMENT_NODE):
 *         c_sibling = c_sibling.prev             # <<<<<<<<<<<<<<
 *     while c_sibling != c_node:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 */
    __pyx_v_c_sibling = __pyx_v_c_sibling->prev;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":239
 *                  c_sibling.prev.type == tree.XML_COMMENT_NODE):
 *         c_sibling = c_sibling.prev
 *     while c_sibling != c_node:             # <<<<<<<<<<<<<<
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 *                                pretty_print, encoding)
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_sibling != __pyx_v_c_node);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":241
 *     while c_sibling != c_node:
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 *                                pretty_print, encoding)             # <<<<<<<<<<<<<<
 *         if pretty_print:
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")
 */
    xmlNodeDumpOutput(__pyx_v_c_buffer, __pyx_v_c_node->doc, __pyx_v_c_sibling, 0, __pyx_v_pretty_print, __pyx_v_encoding);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":242
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 *                                pretty_print, encoding)
 *         if pretty_print:             # <<<<<<<<<<<<<<
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")
 *         c_sibling = c_sibling.next
 */
    __pyx_1 = __pyx_v_pretty_print;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":243
 *                                pretty_print, encoding)
 *         if pretty_print:
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")             # <<<<<<<<<<<<<<
 *         c_sibling = c_sibling.next
 * 
 */
      xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_474);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":244
 *         if pretty_print:
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")
 *         c_sibling = c_sibling.next             # <<<<<<<<<<<<<<
 * 
 * cdef void _writeNextSiblings(tree.xmlOutputBuffer* c_buffer, xmlNode* c_node,
 */
    __pyx_v_c_sibling = __pyx_v_c_sibling->next;
  }

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":246
 *         c_sibling = c_sibling.next
 * 
 * cdef void _writeNextSiblings(tree.xmlOutputBuffer* c_buffer, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                              char* encoding, bint pretty_print) nogil:
 *     cdef xmlNode* c_sibling
 */

static  void __pyx_f_4lxml_5etree__writeNextSiblings(xmlOutputBuffer *__pyx_v_c_buffer, xmlNode *__pyx_v_c_node, char *__pyx_v_encoding, int __pyx_v_pretty_print) {
  xmlNode *__pyx_v_c_sibling;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":249
 *                              char* encoding, bint pretty_print) nogil:
 *     cdef xmlNode* c_sibling
 *     if c_node.parent is not NULL and _isElement(c_node.parent):             # <<<<<<<<<<<<<<
 *         return
 *     # we are at a root node, so add PI and comment siblings
 */
  __pyx_1 = (__pyx_v_c_node->parent != NULL);
  if (__pyx_1) {
    __pyx_1 = _isElement(__pyx_v_c_node->parent);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":250
 *     cdef xmlNode* c_sibling
 *     if c_node.parent is not NULL and _isElement(c_node.parent):
 *         return             # <<<<<<<<<<<<<<
 *     # we are at a root node, so add PI and comment siblings
 *     c_sibling = c_node.next
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":252
 *         return
 *     # we are at a root node, so add PI and comment siblings
 *     c_sibling = c_node.next             # <<<<<<<<<<<<<<
 *     while c_sibling != NULL and \
 *             (c_sibling.type == tree.XML_PI_NODE or \
 */
  __pyx_v_c_sibling = __pyx_v_c_node->next;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":253
 *     # we are at a root node, so add PI and comment siblings
 *     c_sibling = c_node.next
 *     while c_sibling != NULL and \             # <<<<<<<<<<<<<<
 *             (c_sibling.type == tree.XML_PI_NODE or \
 *                  c_sibling.type == tree.XML_COMMENT_NODE):
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_sibling != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":254
 *     c_sibling = c_node.next
 *     while c_sibling != NULL and \
 *             (c_sibling.type == tree.XML_PI_NODE or \             # <<<<<<<<<<<<<<
 *                  c_sibling.type == tree.XML_COMMENT_NODE):
 *         if pretty_print:
 */
      __pyx_1 = (__pyx_v_c_sibling->type == XML_PI_NODE);
      if (!__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":255
 *     while c_sibling != NULL and \
 *             (c_sibling.type == tree.XML_PI_NODE or \
 *                  c_sibling.type == tree.XML_COMMENT_NODE):             # <<<<<<<<<<<<<<
 *         if pretty_print:
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")
 */
        __pyx_1 = (__pyx_v_c_sibling->type == XML_COMMENT_NODE);
      }
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":256
 *             (c_sibling.type == tree.XML_PI_NODE or \
 *                  c_sibling.type == tree.XML_COMMENT_NODE):
 *         if pretty_print:             # <<<<<<<<<<<<<<
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 */
    __pyx_1 = __pyx_v_pretty_print;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":257
 *                  c_sibling.type == tree.XML_COMMENT_NODE):
 *         if pretty_print:
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")             # <<<<<<<<<<<<<<
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 *                                pretty_print, encoding)
 */
      xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_475);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":259
 *             tree.xmlOutputBufferWriteString(c_buffer, "\n")
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 *                                pretty_print, encoding)             # <<<<<<<<<<<<<<
 *         c_sibling = c_sibling.next
 * 
 */
    xmlNodeDumpOutput(__pyx_v_c_buffer, __pyx_v_c_node->doc, __pyx_v_c_sibling, 0, __pyx_v_pretty_print, __pyx_v_encoding);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":260
 *         tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_sibling, 0,
 *                                pretty_print, encoding)
 *         c_sibling = c_sibling.next             # <<<<<<<<<<<<<<
 * 
 * # output to file-like objects
 */
    __pyx_v_c_sibling = __pyx_v_c_sibling->next;
  }

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":268
 *     cdef _ExceptionContext _exc_context
 *     cdef _ErrorLog error_log
 *     def __init__(self, filelike, exc_context=None):             # <<<<<<<<<<<<<<
 *         self._filelike = filelike
 *         if exc_context is None:
 */

static int __pyx_pf_4lxml_5etree_15_FilelikeWriter___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_15_FilelikeWriter___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filelike = 0;
  PyObject *__pyx_v_exc_context = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_filelike,&__pyx_kp_exc_context,0};
  __pyx_v_exc_context = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_filelike);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_filelike = values[0];
    if (values[1]) {
      __pyx_v_exc_context = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_exc_context = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_filelike = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._FilelikeWriter.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":269
 *     cdef _ErrorLog error_log
 *     def __init__(self, filelike, exc_context=None):
 *         self._filelike = filelike             # <<<<<<<<<<<<<<
 *         if exc_context is None:
 *             self._exc_context = _ExceptionContext()
 */
  Py_INCREF(__pyx_v_filelike);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->_filelike);
  ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->_filelike = __pyx_v_filelike;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":270
 *     def __init__(self, filelike, exc_context=None):
 *         self._filelike = filelike
 *         if exc_context is None:             # <<<<<<<<<<<<<<
 *             self._exc_context = _ExceptionContext()
 *         else:
 */
  __pyx_1 = (__pyx_v_exc_context == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":271
 *         self._filelike = filelike
 *         if exc_context is None:
 *             self._exc_context = _ExceptionContext()             # <<<<<<<<<<<<<<
 *         else:
 *             self._exc_context = exc_context
 */
    __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ExceptionContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ExceptionContext))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->_exc_context));
    ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":273
 *             self._exc_context = _ExceptionContext()
 *         else:
 *             self._exc_context = exc_context             # <<<<<<<<<<<<<<
 *         self.error_log = _ErrorLog()
 * 
 */
    if (!(__Pyx_TypeTest(__pyx_v_exc_context, __pyx_ptype_4lxml_5etree__ExceptionContext))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_exc_context);
    Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->_exc_context));
    ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_exc_context);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":274
 *         else:
 *             self._exc_context = exc_context
 *         self.error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 * 
 *     cdef tree.xmlOutputBuffer* _createOutputBuffer(
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->error_log));
  ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_self)->error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_2);
  __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._FilelikeWriter.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":276
 *         self.error_log = _ErrorLog()
 * 
 *     cdef tree.xmlOutputBuffer* _createOutputBuffer(             # <<<<<<<<<<<<<<
 *         self, tree.xmlCharEncodingHandler* enchandler) except NULL:
 *         cdef tree.xmlOutputBuffer* c_buffer
 */

static  xmlOutputBuffer *__pyx_f_4lxml_5etree_15_FilelikeWriter__createOutputBuffer(struct __pyx_obj_4lxml_5etree__FilelikeWriter *__pyx_v_self, xmlCharEncodingHandler *__pyx_v_enchandler) {
  xmlOutputBuffer *__pyx_v_c_buffer;
  xmlOutputBuffer *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":281
 *         c_buffer = tree.xmlOutputBufferCreateIO(
 *             _writeFilelikeWriter, _closeFilelikeWriter,
 *             <python.PyObject*>self, enchandler)             # <<<<<<<<<<<<<<
 *         if c_buffer is NULL:
 *             raise IOError, u"Could not create I/O writer context."
 */
  __pyx_v_c_buffer = xmlOutputBufferCreateIO(__pyx_f_4lxml_5etree__writeFilelikeWriter, __pyx_f_4lxml_5etree__closeFilelikeWriter, ((PyObject *)__pyx_v_self), __pyx_v_enchandler);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":282
 *             _writeFilelikeWriter, _closeFilelikeWriter,
 *             <python.PyObject*>self, enchandler)
 *         if c_buffer is NULL:             # <<<<<<<<<<<<<<
 *             raise IOError, u"Could not create I/O writer context."
 *         return c_buffer
 */
  __pyx_1 = (__pyx_v_c_buffer == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":283
 *             <python.PyObject*>self, enchandler)
 *         if c_buffer is NULL:
 *             raise IOError, u"Could not create I/O writer context."             # <<<<<<<<<<<<<<
 *         return c_buffer
 * 
 */
    __Pyx_Raise(__pyx_builtin_IOError, ((PyObject *)__pyx_kp_476), 0);
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":284
 *         if c_buffer is NULL:
 *             raise IOError, u"Could not create I/O writer context."
 *         return c_buffer             # <<<<<<<<<<<<<<
 * 
 *     cdef int write(self, char* c_buffer, int size):
 */
  __pyx_r = __pyx_v_c_buffer;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._FilelikeWriter._createOutputBuffer");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":286
 *         return c_buffer
 * 
 *     cdef int write(self, char* c_buffer, int size):             # <<<<<<<<<<<<<<
 *         try:
 *             if self._filelike is None:
 */

static  int __pyx_f_4lxml_5etree_15_FilelikeWriter_write(struct __pyx_obj_4lxml_5etree__FilelikeWriter *__pyx_v_self, char *__pyx_v_c_buffer, int __pyx_v_size) {
  PyObject *__pyx_v_py_buffer;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_py_buffer = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":287
 * 
 *     cdef int write(self, char* c_buffer, int size):
 *         try:             # <<<<<<<<<<<<<<
 *             if self._filelike is None:
 *                 raise IOError, u"File is already closed"
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":288
 *     cdef int write(self, char* c_buffer, int size):
 *         try:
 *             if self._filelike is None:             # <<<<<<<<<<<<<<
 *                 raise IOError, u"File is already closed"
 *             py_buffer = python.PyString_FromStringAndSize(c_buffer, size)
 */
      __pyx_1 = (__pyx_v_self->_filelike == Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":289
 *         try:
 *             if self._filelike is None:
 *                 raise IOError, u"File is already closed"             # <<<<<<<<<<<<<<
 *             py_buffer = python.PyString_FromStringAndSize(c_buffer, size)
 *             self._filelike.write(py_buffer)
 */
        __Pyx_Raise(__pyx_builtin_IOError, ((PyObject *)__pyx_kp_477), 0);
        {__pyx_filename = __pyx_f[3]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":290
 *             if self._filelike is None:
 *                 raise IOError, u"File is already closed"
 *             py_buffer = python.PyString_FromStringAndSize(c_buffer, size)             # <<<<<<<<<<<<<<
 *             self._filelike.write(py_buffer)
 *             return size
 */
      __pyx_2 = PyString_FromStringAndSize(__pyx_v_c_buffer, __pyx_v_size); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(__pyx_v_py_buffer);
      __pyx_v_py_buffer = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":291
 *                 raise IOError, u"File is already closed"
 *             py_buffer = python.PyString_FromStringAndSize(c_buffer, size)
 *             self._filelike.write(py_buffer)             # <<<<<<<<<<<<<<
 *             return size
 *         except:
 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self->_filelike, __pyx_kp_write); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_INCREF(__pyx_v_py_buffer);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_py_buffer);
      __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":292
 *             py_buffer = python.PyString_FromStringAndSize(c_buffer, size)
 *             self._filelike.write(py_buffer)
 *             return size             # <<<<<<<<<<<<<<
 *         except:
 *             self._exc_context._store_raised()
 */
      __pyx_r = __pyx_v_size;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L7_try;
    __pyx_L3_error:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":293
 *             self._filelike.write(py_buffer)
 *             return size
 *         except:             # <<<<<<<<<<<<<<
 *             self._exc_context._store_raised()
 *             return -1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree.write");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":294
 *             return size
 *         except:
 *             self._exc_context._store_raised()             # <<<<<<<<<<<<<<
 *             return -1
 * 
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_self->_exc_context->__pyx_vtab)->_store_raised(__pyx_v_self->_exc_context);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":295
 *         except:
 *             self._exc_context._store_raised()
 *             return -1             # <<<<<<<<<<<<<<
 * 
 *     cdef int close(self):
 */
      __pyx_r = -1;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L6_except_return;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L7_try:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._FilelikeWriter.write");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_py_buffer);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":297
 *             return -1
 * 
 *     cdef int close(self):             # <<<<<<<<<<<<<<
 *         # we should not close the file here as we didn't open it
 *         self._filelike = None
 */

static  int __pyx_f_4lxml_5etree_15_FilelikeWriter_close(struct __pyx_obj_4lxml_5etree__FilelikeWriter *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":299
 *     cdef int close(self):
 *         # we should not close the file here as we didn't open it
 *         self._filelike = None             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_self->_filelike);
  __pyx_v_self->_filelike = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":300
 *         # we should not close the file here as we didn't open it
 *         self._filelike = None
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * cdef int _writeFilelikeWriter(void* ctxt, char* c_buffer, int len):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":302
 *         return 0
 * 
 * cdef int _writeFilelikeWriter(void* ctxt, char* c_buffer, int len):             # <<<<<<<<<<<<<<
 *     return (<_FilelikeWriter>ctxt).write(c_buffer, len)
 * 
 */

static  int __pyx_f_4lxml_5etree__writeFilelikeWriter(void *__pyx_v_ctxt, char *__pyx_v_c_buffer, int __pyx_v_len) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":303
 * 
 * cdef int _writeFilelikeWriter(void* ctxt, char* c_buffer, int len):
 *     return (<_FilelikeWriter>ctxt).write(c_buffer, len)             # <<<<<<<<<<<<<<
 * 
 * cdef int _closeFilelikeWriter(void* ctxt):
 */
  __pyx_r = ((struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter *)((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_ctxt)->__pyx_vtab)->write(((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_ctxt), __pyx_v_c_buffer, __pyx_v_len);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":305
 *     return (<_FilelikeWriter>ctxt).write(c_buffer, len)
 * 
 * cdef int _closeFilelikeWriter(void* ctxt):             # <<<<<<<<<<<<<<
 *     return (<_FilelikeWriter>ctxt).close()
 * 
 */

static  int __pyx_f_4lxml_5etree__closeFilelikeWriter(void *__pyx_v_ctxt) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":306
 * 
 * cdef int _closeFilelikeWriter(void* ctxt):
 *     return (<_FilelikeWriter>ctxt).close()             # <<<<<<<<<<<<<<
 * 
 * cdef _tofilelike(f, _Element element, encoding, method,
 */
  __pyx_r = ((struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter *)((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_ctxt)->__pyx_vtab)->close(((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_v_ctxt));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":308
 *     return (<_FilelikeWriter>ctxt).close()
 * 
 * cdef _tofilelike(f, _Element element, encoding, method,             # <<<<<<<<<<<<<<
 *                  bint write_xml_declaration, bint write_doctype,
 *                  bint pretty_print, bint with_tail):
 */

static  PyObject *__pyx_f_4lxml_5etree__tofilelike(PyObject *__pyx_v_f, struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_encoding, PyObject *__pyx_v_method, int __pyx_v_write_xml_declaration, int __pyx_v_write_doctype, int __pyx_v_pretty_print, int __pyx_v_with_tail) {
  PyThreadState *__pyx_v_state;
  struct __pyx_obj_4lxml_5etree__FilelikeWriter *__pyx_v_writer;
  xmlOutputBuffer *__pyx_v_c_buffer;
  xmlCharEncodingHandler *__pyx_v_enchandler;
  char *__pyx_v_c_enc;
  PyObject *__pyx_v_c_method;
  PyObject *__pyx_v_filename8;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  xmlOutputBuffer *__pyx_6;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_f);
  Py_INCREF(__pyx_v_encoding);
  __pyx_v_writer = ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)Py_None); Py_INCREF(Py_None);
  __pyx_v_c_method = Py_None; Py_INCREF(Py_None);
  __pyx_v_filename8 = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":316
 *     cdef tree.xmlCharEncodingHandler* enchandler
 *     cdef char* c_enc
 *     if encoding is None:             # <<<<<<<<<<<<<<
 *         c_enc = NULL
 *     else:
 */
  __pyx_1 = (__pyx_v_encoding == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":317
 *     cdef char* c_enc
 *     if encoding is None:
 *         c_enc = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         encoding = _utf8(encoding)
 */
    __pyx_v_c_enc = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":319
 *         c_enc = NULL
 *     else:
 *         encoding = _utf8(encoding)             # <<<<<<<<<<<<<<
 *         c_enc = _cstr(encoding)
 *     c_method = _findOutputMethod(method)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_encoding); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_encoding);
    __pyx_v_encoding = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":320
 *     else:
 *         encoding = _utf8(encoding)
 *         c_enc = _cstr(encoding)             # <<<<<<<<<<<<<<
 *     c_method = _findOutputMethod(method)
 *     if c_method == OUTPUT_METHOD_TEXT:
 */
    __pyx_v_c_enc = PyString_AS_STRING(__pyx_v_encoding);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":321
 *         encoding = _utf8(encoding)
 *         c_enc = _cstr(encoding)
 *     c_method = _findOutputMethod(method)             # <<<<<<<<<<<<<<
 *     if c_method == OUTPUT_METHOD_TEXT:
 *         if _isString(f):
 */
  __pyx_3 = __pyx_f_4lxml_5etree__findOutputMethod(__pyx_v_method); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyInt_FromLong(__pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_c_method);
  __pyx_v_c_method = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":322
 *         c_enc = _cstr(encoding)
 *     c_method = _findOutputMethod(method)
 *     if c_method == OUTPUT_METHOD_TEXT:             # <<<<<<<<<<<<<<
 *         if _isString(f):
 *             filename8 = _encodeFilename(f)
 */
  __pyx_2 = PyInt_FromLong(__pyx_e_4lxml_5etree_OUTPUT_METHOD_TEXT); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyObject_RichCompare(__pyx_v_c_method, __pyx_2, Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":323
 *     c_method = _findOutputMethod(method)
 *     if c_method == OUTPUT_METHOD_TEXT:
 *         if _isString(f):             # <<<<<<<<<<<<<<
 *             filename8 = _encodeFilename(f)
 *             f = open(filename8, u'wb')
 */
    __pyx_1 = _isString(__pyx_v_f);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":324
 *     if c_method == OUTPUT_METHOD_TEXT:
 *         if _isString(f):
 *             filename8 = _encodeFilename(f)             # <<<<<<<<<<<<<<
 *             f = open(filename8, u'wb')
 *             try:
 */
      __pyx_2 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_f); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_filename8);
      __pyx_v_filename8 = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":325
 *         if _isString(f):
 *             filename8 = _encodeFilename(f)
 *             f = open(filename8, u'wb')             # <<<<<<<<<<<<<<
 *             try:
 *                 f.write(_textToString(element._c_node, encoding, with_tail))
 */
      __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_filename8);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_filename8);
      Py_INCREF(((PyObject *)__pyx_kp_478));
      PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_kp_478));
      __pyx_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      Py_DECREF(__pyx_v_f);
      __pyx_v_f = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":326
 *             filename8 = _encodeFilename(f)
 *             f = open(filename8, u'wb')
 *             try:             # <<<<<<<<<<<<<<
 *                 f.write(_textToString(element._c_node, encoding, with_tail))
 *             finally:
 */
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":327
 *             f = open(filename8, u'wb')
 *             try:
 *                 f.write(_textToString(element._c_node, encoding, with_tail))             # <<<<<<<<<<<<<<
 *             finally:
 *                 f.close()
 */
        __pyx_4 = PyObject_GetAttr(__pyx_v_f, __pyx_kp_write); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __pyx_2 = __pyx_f_4lxml_5etree__textToString(__pyx_v_element->_c_node, __pyx_v_encoding, __pyx_v_with_tail); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L7;}
        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
        __pyx_2 = 0;
        __pyx_2 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L7;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      /*finally:*/ {
        int __pyx_why;
        PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
        int __pyx_exc_lineno;
        __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
        __pyx_why = 0; goto __pyx_L8;
        __pyx_L7: {
          __pyx_why = 4;
          Py_XDECREF(__pyx_4); __pyx_4 = 0;
          Py_XDECREF(__pyx_5); __pyx_5 = 0;
          Py_XDECREF(__pyx_2); __pyx_2 = 0;
          __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
          __pyx_exc_lineno = __pyx_lineno;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":329
 *                 f.write(_textToString(element._c_node, encoding, with_tail))
 *             finally:
 *                 f.close()             # <<<<<<<<<<<<<<
 *         else:
 *             f.write(_textToString(element._c_node, encoding, with_tail))
 */
        __pyx_4 = PyObject_GetAttr(__pyx_v_f, __pyx_kp_close); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        __pyx_5 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L10;
        __pyx_L9_error:;
        if (__pyx_why == 4) {
          Py_XDECREF(__pyx_exc_type);
          Py_XDECREF(__pyx_exc_value);
          Py_XDECREF(__pyx_exc_tb);
        }
        goto __pyx_L1_error;
        __pyx_L10:;
        switch (__pyx_why) {
          case 4: {
            __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
            __pyx_lineno = __pyx_exc_lineno;
            __pyx_exc_type = 0;
            __pyx_exc_value = 0;
            __pyx_exc_tb = 0;
            goto __pyx_L1_error;
          }
        }
      }
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":331
 *                 f.close()
 *         else:
 *             f.write(_textToString(element._c_node, encoding, with_tail))             # <<<<<<<<<<<<<<
 *         return
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)
 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_f, __pyx_kp_write); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = __pyx_f_4lxml_5etree__textToString(__pyx_v_element->_c_node, __pyx_v_encoding, __pyx_v_with_tail); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
      __pyx_4 = 0;
      __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":332
 *         else:
 *             f.write(_textToString(element._c_node, encoding, with_tail))
 *         return             # <<<<<<<<<<<<<<
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)
 *     if enchandler is NULL:
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":333
 *             f.write(_textToString(element._c_node, encoding, with_tail))
 *         return
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)             # <<<<<<<<<<<<<<
 *     if enchandler is NULL:
 *         if encoding is not None:
 */
  __pyx_v_enchandler = xmlFindCharEncodingHandler(__pyx_v_c_enc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":334
 *         return
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)
 *     if enchandler is NULL:             # <<<<<<<<<<<<<<
 *         if encoding is not None:
 *             encoding = encoding.decode(u'UTF-8')
 */
  __pyx_1 = (__pyx_v_enchandler == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":335
 *     enchandler = tree.xmlFindCharEncodingHandler(c_enc)
 *     if enchandler is NULL:
 *         if encoding is not None:             # <<<<<<<<<<<<<<
 *             encoding = encoding.decode(u'UTF-8')
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 */
    __pyx_1 = (__pyx_v_encoding != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":336
 *     if enchandler is NULL:
 *         if encoding is not None:
 *             encoding = encoding.decode(u'UTF-8')             # <<<<<<<<<<<<<<
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 * 
 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_encoding, __pyx_kp_decode); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_479));
      PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_kp_479));
      __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      Py_DECREF(__pyx_v_encoding);
      __pyx_v_encoding = __pyx_4;
      __pyx_4 = 0;
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":337
 *         if encoding is not None:
 *             encoding = encoding.decode(u'UTF-8')
 *         raise LookupError, u"unknown encoding: '%s'" % encoding             # <<<<<<<<<<<<<<
 * 
 *     if _isString(f):
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_480), __pyx_v_encoding); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_builtin_LookupError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":339
 *         raise LookupError, u"unknown encoding: '%s'" % encoding
 * 
 *     if _isString(f):             # <<<<<<<<<<<<<<
 *         filename8 = _encodeFilename(f)
 *         c_buffer = tree.xmlOutputBufferCreateFilename(
 */
  __pyx_1 = _isString(__pyx_v_f);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":340
 * 
 *     if _isString(f):
 *         filename8 = _encodeFilename(f)             # <<<<<<<<<<<<<<
 *         c_buffer = tree.xmlOutputBufferCreateFilename(
 *             _cstr(filename8), enchandler, 0)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_f); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_filename8);
    __pyx_v_filename8 = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":342
 *         filename8 = _encodeFilename(f)
 *         c_buffer = tree.xmlOutputBufferCreateFilename(
 *             _cstr(filename8), enchandler, 0)             # <<<<<<<<<<<<<<
 *         if c_buffer is NULL:
 *             return python.PyErr_SetFromErrno(IOError)
 */
    __pyx_v_c_buffer = xmlOutputBufferCreateFilename(PyString_AS_STRING(__pyx_v_filename8), __pyx_v_enchandler, 0);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":343
 *         c_buffer = tree.xmlOutputBufferCreateFilename(
 *             _cstr(filename8), enchandler, 0)
 *         if c_buffer is NULL:             # <<<<<<<<<<<<<<
 *             return python.PyErr_SetFromErrno(IOError)
 *         state = python.PyEval_SaveThread()
 */
    __pyx_1 = (__pyx_v_c_buffer == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":344
 *             _cstr(filename8), enchandler, 0)
 *         if c_buffer is NULL:
 *             return python.PyErr_SetFromErrno(IOError)             # <<<<<<<<<<<<<<
 *         state = python.PyEval_SaveThread()
 *     elif hasattr(f, u'write'):
 */
      __pyx_5 = PyErr_SetFromErrno(__pyx_builtin_IOError); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_5;
      __pyx_5 = 0;
      goto __pyx_L0;
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":345
 *         if c_buffer is NULL:
 *             return python.PyErr_SetFromErrno(IOError)
 *         state = python.PyEval_SaveThread()             # <<<<<<<<<<<<<<
 *     elif hasattr(f, u'write'):
 *         writer   = _FilelikeWriter(f)
 */
    __pyx_v_state = PyEval_SaveThread();
    goto __pyx_L13;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":346
 *             return python.PyErr_SetFromErrno(IOError)
 *         state = python.PyEval_SaveThread()
 *     elif hasattr(f, u'write'):             # <<<<<<<<<<<<<<
 *         writer   = _FilelikeWriter(f)
 *         c_buffer = writer._createOutputBuffer(enchandler)
 */
  __pyx_1 = PyObject_HasAttr(__pyx_v_f, ((PyObject *)__pyx_kp_481)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":347
 *         state = python.PyEval_SaveThread()
 *     elif hasattr(f, u'write'):
 *         writer   = _FilelikeWriter(f)             # <<<<<<<<<<<<<<
 *         c_buffer = writer._createOutputBuffer(enchandler)
 *     else:
 */
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_f);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_f);
    __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__FilelikeWriter)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__FilelikeWriter))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_writer));
    __pyx_v_writer = ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":348
 *     elif hasattr(f, u'write'):
 *         writer   = _FilelikeWriter(f)
 *         c_buffer = writer._createOutputBuffer(enchandler)             # <<<<<<<<<<<<<<
 *     else:
 *         tree.xmlCharEncCloseFunc(enchandler)
 */
    __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter *)__pyx_v_writer->__pyx_vtab)->_createOutputBuffer(__pyx_v_writer, __pyx_v_enchandler); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_buffer = __pyx_6;
    goto __pyx_L13;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":350
 *         c_buffer = writer._createOutputBuffer(enchandler)
 *     else:
 *         tree.xmlCharEncCloseFunc(enchandler)             # <<<<<<<<<<<<<<
 *         raise TypeError, \
 *             u"File or filename expected, got '%s'" % funicode(python._fqtypename(f))
 */
    xmlCharEncCloseFunc(__pyx_v_enchandler);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":352
 *         tree.xmlCharEncCloseFunc(enchandler)
 *         raise TypeError, \
 *             u"File or filename expected, got '%s'" % funicode(python._fqtypename(f))             # <<<<<<<<<<<<<<
 * 
 *     _writeNodeToBuffer(c_buffer, element._c_node, c_enc, c_method,
 */
    __pyx_5 = __pyx_f_4lxml_5etree_funicode(_fqtypename(__pyx_v_f)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_482), __pyx_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":354
 *             u"File or filename expected, got '%s'" % funicode(python._fqtypename(f))
 * 
 *     _writeNodeToBuffer(c_buffer, element._c_node, c_enc, c_method,             # <<<<<<<<<<<<<<
 *                        write_xml_declaration, write_doctype,
 *                        pretty_print, with_tail)
 */
  __pyx_3 = __pyx_PyInt_int(__pyx_v_c_method); if (unlikely((__pyx_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":356
 *     _writeNodeToBuffer(c_buffer, element._c_node, c_enc, c_method,
 *                        write_xml_declaration, write_doctype,
 *                        pretty_print, with_tail)             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferClose(c_buffer)
 *     if writer is None:
 */
  __pyx_f_4lxml_5etree__writeNodeToBuffer(__pyx_v_c_buffer, __pyx_v_element->_c_node, __pyx_v_c_enc, __pyx_3, __pyx_v_write_xml_declaration, __pyx_v_write_doctype, __pyx_v_pretty_print, __pyx_v_with_tail);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":357
 *                        write_xml_declaration, write_doctype,
 *                        pretty_print, with_tail)
 *     tree.xmlOutputBufferClose(c_buffer)             # <<<<<<<<<<<<<<
 *     if writer is None:
 *         python.PyEval_RestoreThread(state)
 */
  xmlOutputBufferClose(__pyx_v_c_buffer);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":358
 *                        pretty_print, with_tail)
 *     tree.xmlOutputBufferClose(c_buffer)
 *     if writer is None:             # <<<<<<<<<<<<<<
 *         python.PyEval_RestoreThread(state)
 *     else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_writer) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":359
 *     tree.xmlOutputBufferClose(c_buffer)
 *     if writer is None:
 *         python.PyEval_RestoreThread(state)             # <<<<<<<<<<<<<<
 *     else:
 *         writer._exc_context._raise_if_stored()
 */
    PyEval_RestoreThread(__pyx_v_state);
    goto __pyx_L15;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":361
 *         python.PyEval_RestoreThread(state)
 *     else:
 *         writer._exc_context._raise_if_stored()             # <<<<<<<<<<<<<<
 * 
 * cdef _tofilelikeC14N(f, _Element element):
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_writer->_exc_context->__pyx_vtab)->_raise_if_stored(__pyx_v_writer->_exc_context); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L15:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._tofilelike");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_writer);
  Py_DECREF(__pyx_v_c_method);
  Py_DECREF(__pyx_v_filename8);
  Py_DECREF(__pyx_v_f);
  Py_DECREF(__pyx_v_encoding);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":363
 *         writer._exc_context._raise_if_stored()
 * 
 * cdef _tofilelikeC14N(f, _Element element):             # <<<<<<<<<<<<<<
 *     cdef _FilelikeWriter writer
 *     cdef tree.xmlOutputBuffer* c_buffer
 */

static  PyObject *__pyx_f_4lxml_5etree__tofilelikeC14N(PyObject *__pyx_v_f, struct LxmlElement *__pyx_v_element) {
  struct __pyx_obj_4lxml_5etree__FilelikeWriter *__pyx_v_writer;
  xmlOutputBuffer *__pyx_v_c_buffer;
  char *__pyx_v_c_filename;
  xmlDoc *__pyx_v_c_base_doc;
  xmlDoc *__pyx_v_c_doc;
  int __pyx_v_bytes;
  PyObject *__pyx_v_filename8;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_errors;
  PyObject *__pyx_r;
  xmlDoc *__pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  xmlOutputBuffer *__pyx_5;
  int __pyx_6;
  Py_ssize_t __pyx_7 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_writer = ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filename8 = Py_None; Py_INCREF(Py_None);
  __pyx_v_message = Py_None; Py_INCREF(Py_None);
  __pyx_v_errors = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":371
 *     cdef int bytes
 * 
 *     c_base_doc = element._c_node.doc             # <<<<<<<<<<<<<<
 *     c_doc = _fakeRootDoc(c_base_doc, element._c_node)
 *     try:
 */
  __pyx_v_c_base_doc = __pyx_v_element->_c_node->doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":372
 * 
 *     c_base_doc = element._c_node.doc
 *     c_doc = _fakeRootDoc(c_base_doc, element._c_node)             # <<<<<<<<<<<<<<
 *     try:
 *         if _isString(f):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_c_base_doc, __pyx_v_element->_c_node); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":373
 *     c_base_doc = element._c_node.doc
 *     c_doc = _fakeRootDoc(c_base_doc, element._c_node)
 *     try:             # <<<<<<<<<<<<<<
 *         if _isString(f):
 *             filename8 = _encodeFilename(f)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":374
 *     c_doc = _fakeRootDoc(c_base_doc, element._c_node)
 *     try:
 *         if _isString(f):             # <<<<<<<<<<<<<<
 *             filename8 = _encodeFilename(f)
 *             c_filename = _cstr(filename8)
 */
    __pyx_2 = _isString(__pyx_v_f);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":375
 *     try:
 *         if _isString(f):
 *             filename8 = _encodeFilename(f)             # <<<<<<<<<<<<<<
 *             c_filename = _cstr(filename8)
 *             with nogil:
 */
      __pyx_3 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_f); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L4;}
      Py_DECREF(__pyx_v_filename8);
      __pyx_v_filename8 = __pyx_3;
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":376
 *         if _isString(f):
 *             filename8 = _encodeFilename(f)
 *             c_filename = _cstr(filename8)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 bytes = c14n.xmlC14NDocSave(c_doc, NULL, 0, NULL, 1,
 */
      __pyx_v_c_filename = PyString_AS_STRING(__pyx_v_filename8);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":377
 *             filename8 = _encodeFilename(f)
 *             c_filename = _cstr(filename8)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 bytes = c14n.xmlC14NDocSave(c_doc, NULL, 0, NULL, 1,
 *                                             c_filename, 0)
 */
      /*with nogil:*/ {
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":379
 *             with nogil:
 *                 bytes = c14n.xmlC14NDocSave(c_doc, NULL, 0, NULL, 1,
 *                                             c_filename, 0)             # <<<<<<<<<<<<<<
 *         elif hasattr(f, u'write'):
 *             writer   = _FilelikeWriter(f)
 */
          __pyx_v_bytes = xmlC14NDocSave(__pyx_v_c_doc, NULL, 0, NULL, 1, __pyx_v_c_filename, 0);
        }
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
      }
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":380
 *                 bytes = c14n.xmlC14NDocSave(c_doc, NULL, 0, NULL, 1,
 *                                             c_filename, 0)
 *         elif hasattr(f, u'write'):             # <<<<<<<<<<<<<<
 *             writer   = _FilelikeWriter(f)
 *             c_buffer = writer._createOutputBuffer(NULL)
 */
    __pyx_2 = PyObject_HasAttr(__pyx_v_f, ((PyObject *)__pyx_kp_483)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L4;}
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":381
 *                                             c_filename, 0)
 *         elif hasattr(f, u'write'):
 *             writer   = _FilelikeWriter(f)             # <<<<<<<<<<<<<<
 *             c_buffer = writer._createOutputBuffer(NULL)
 *             writer.error_log.connect()
 */
      __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L4;}
      Py_INCREF(__pyx_v_f);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_f);
      __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__FilelikeWriter)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L4;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__FilelikeWriter))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L4;}
      Py_DECREF(((PyObject *)__pyx_v_writer));
      __pyx_v_writer = ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)__pyx_4);
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":382
 *         elif hasattr(f, u'write'):
 *             writer   = _FilelikeWriter(f)
 *             c_buffer = writer._createOutputBuffer(NULL)             # <<<<<<<<<<<<<<
 *             writer.error_log.connect()
 *             bytes = c14n.xmlC14NDocSaveTo(c_doc, NULL, 0, NULL, 1, c_buffer)
 */
      __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter *)__pyx_v_writer->__pyx_vtab)->_createOutputBuffer(__pyx_v_writer, NULL); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L4;}
      __pyx_v_c_buffer = __pyx_5;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":383
 *             writer   = _FilelikeWriter(f)
 *             c_buffer = writer._createOutputBuffer(NULL)
 *             writer.error_log.connect()             # <<<<<<<<<<<<<<
 *             bytes = c14n.xmlC14NDocSaveTo(c_doc, NULL, 0, NULL, 1, c_buffer)
 *             writer.error_log.disconnect()
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_writer->error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(__pyx_v_writer->error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":384
 *             c_buffer = writer._createOutputBuffer(NULL)
 *             writer.error_log.connect()
 *             bytes = c14n.xmlC14NDocSaveTo(c_doc, NULL, 0, NULL, 1, c_buffer)             # <<<<<<<<<<<<<<
 *             writer.error_log.disconnect()
 *             tree.xmlOutputBufferClose(c_buffer)
 */
      __pyx_v_bytes = xmlC14NDocSaveTo(__pyx_v_c_doc, NULL, 0, NULL, 1, __pyx_v_c_buffer);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":385
 *             writer.error_log.connect()
 *             bytes = c14n.xmlC14NDocSaveTo(c_doc, NULL, 0, NULL, 1, c_buffer)
 *             writer.error_log.disconnect()             # <<<<<<<<<<<<<<
 *             tree.xmlOutputBufferClose(c_buffer)
 *         else:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_writer->error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(__pyx_v_writer->error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":386
 *             bytes = c14n.xmlC14NDocSaveTo(c_doc, NULL, 0, NULL, 1, c_buffer)
 *             writer.error_log.disconnect()
 *             tree.xmlOutputBufferClose(c_buffer)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError, \
 */
      xmlOutputBufferClose(__pyx_v_c_buffer);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":389
 *         else:
 *             raise TypeError, \
 *                 u"File or filename expected, got '%s'" % funicode(python._fqtypename(f))             # <<<<<<<<<<<<<<
 *     finally:
 *         _destroyFakeDoc(c_base_doc, c_doc)
 */
      __pyx_3 = __pyx_f_4lxml_5etree_funicode(_fqtypename(__pyx_v_f)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L4;}
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_484), __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L4;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L4;}
    }
    __pyx_L6:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L5;
    __pyx_L4: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":391
 *                 u"File or filename expected, got '%s'" % funicode(python._fqtypename(f))
 *     finally:
 *         _destroyFakeDoc(c_base_doc, c_doc)             # <<<<<<<<<<<<<<
 * 
 *     if writer is not None:
 */
    __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_c_base_doc, __pyx_v_c_doc);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":393
 *         _destroyFakeDoc(c_base_doc, c_doc)
 * 
 *     if writer is not None:             # <<<<<<<<<<<<<<
 *         writer._exc_context._raise_if_stored()
 * 
 */
  __pyx_2 = (((PyObject *)__pyx_v_writer) != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":394
 * 
 *     if writer is not None:
 *         writer._exc_context._raise_if_stored()             # <<<<<<<<<<<<<<
 * 
 *     if bytes < 0:
 */
    __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_writer->_exc_context->__pyx_vtab)->_raise_if_stored(__pyx_v_writer->_exc_context); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":396
 *         writer._exc_context._raise_if_stored()
 * 
 *     if bytes < 0:             # <<<<<<<<<<<<<<
 *         message = u"C14N failed"
 *         if writer is not None:
 */
  __pyx_2 = (__pyx_v_bytes < 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":397
 * 
 *     if bytes < 0:
 *         message = u"C14N failed"             # <<<<<<<<<<<<<<
 *         if writer is not None:
 *             errors = writer.error_log
 */
    Py_INCREF(((PyObject *)__pyx_kp_485));
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = ((PyObject *)__pyx_kp_485);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":398
 *     if bytes < 0:
 *         message = u"C14N failed"
 *         if writer is not None:             # <<<<<<<<<<<<<<
 *             errors = writer.error_log
 *             if len(errors):
 */
    __pyx_2 = (((PyObject *)__pyx_v_writer) != Py_None);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":399
 *         message = u"C14N failed"
 *         if writer is not None:
 *             errors = writer.error_log             # <<<<<<<<<<<<<<
 *             if len(errors):
 *                 message = errors[0].message
 */
      Py_INCREF(((PyObject *)__pyx_v_writer->error_log));
      Py_DECREF(__pyx_v_errors);
      __pyx_v_errors = ((PyObject *)__pyx_v_writer->error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":400
 *         if writer is not None:
 *             errors = writer.error_log
 *             if len(errors):             # <<<<<<<<<<<<<<
 *                 message = errors[0].message
 *         raise C14NError, message
 */
      __pyx_7 = PyObject_Length(__pyx_v_errors); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_7) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":401
 *             errors = writer.error_log
 *             if len(errors):
 *                 message = errors[0].message             # <<<<<<<<<<<<<<
 *         raise C14NError, message
 * 
 */
        __pyx_4 = __Pyx_GetItemInt(__pyx_v_errors, 0, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_kp_message); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_v_message);
        __pyx_v_message = __pyx_3;
        __pyx_3 = 0;
        goto __pyx_L14;
      }
      __pyx_L14:;
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":402
 *             if len(errors):
 *                 message = errors[0].message
 *         raise C14NError, message             # <<<<<<<<<<<<<<
 * 
 * # dump node to file (mainly for debug)
 */
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_59); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_4, __pyx_v_message, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L12;
  }
  __pyx_L12:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._tofilelikeC14N");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_writer);
  Py_DECREF(__pyx_v_filename8);
  Py_DECREF(__pyx_v_message);
  Py_DECREF(__pyx_v_errors);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":406
 * # dump node to file (mainly for debug)
 * 
 * cdef _dumpToFile(f, xmlNode* c_node, bint pretty_print, bint with_tail):             # <<<<<<<<<<<<<<
 *     cdef tree.xmlOutputBuffer* c_buffer
 *     cdef cstd.FILE* c_file
 */

static  PyObject *__pyx_f_4lxml_5etree__dumpToFile(PyObject *__pyx_v_f, xmlNode *__pyx_v_c_node, int __pyx_v_pretty_print, int __pyx_v_with_tail) {
  xmlOutputBuffer *__pyx_v_c_buffer;
  FILE *__pyx_v_c_file;
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":409
 *     cdef tree.xmlOutputBuffer* c_buffer
 *     cdef cstd.FILE* c_file
 *     c_file = python.PyFile_AsFile(f)             # <<<<<<<<<<<<<<
 *     if c_file is NULL:
 *         raise ValueError, u"not a file"
 */
  __pyx_v_c_file = PyFile_AsFile(__pyx_v_f);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":410
 *     cdef cstd.FILE* c_file
 *     c_file = python.PyFile_AsFile(f)
 *     if c_file is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError, u"not a file"
 *     c_buffer = tree.xmlOutputBufferCreateFile(c_file, NULL)
 */
  __pyx_1 = (__pyx_v_c_file == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":411
 *     c_file = python.PyFile_AsFile(f)
 *     if c_file is NULL:
 *         raise ValueError, u"not a file"             # <<<<<<<<<<<<<<
 *     c_buffer = tree.xmlOutputBufferCreateFile(c_file, NULL)
 *     tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, pretty_print, NULL)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_486), 0);
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":412
 *     if c_file is NULL:
 *         raise ValueError, u"not a file"
 *     c_buffer = tree.xmlOutputBufferCreateFile(c_file, NULL)             # <<<<<<<<<<<<<<
 *     tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, pretty_print, NULL)
 *     if with_tail:
 */
  __pyx_v_c_buffer = xmlOutputBufferCreateFile(__pyx_v_c_file, NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":413
 *         raise ValueError, u"not a file"
 *     c_buffer = tree.xmlOutputBufferCreateFile(c_file, NULL)
 *     tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, pretty_print, NULL)             # <<<<<<<<<<<<<<
 *     if with_tail:
 *         _writeTail(c_buffer, c_node, NULL, 0)
 */
  xmlNodeDumpOutput(__pyx_v_c_buffer, __pyx_v_c_node->doc, __pyx_v_c_node, 0, __pyx_v_pretty_print, NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":414
 *     c_buffer = tree.xmlOutputBufferCreateFile(c_file, NULL)
 *     tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, pretty_print, NULL)
 *     if with_tail:             # <<<<<<<<<<<<<<
 *         _writeTail(c_buffer, c_node, NULL, 0)
 *     if not pretty_print:
 */
  __pyx_1 = __pyx_v_with_tail;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":415
 *     tree.xmlNodeDumpOutput(c_buffer, c_node.doc, c_node, 0, pretty_print, NULL)
 *     if with_tail:
 *         _writeTail(c_buffer, c_node, NULL, 0)             # <<<<<<<<<<<<<<
 *     if not pretty_print:
 *         # not written yet
 */
    __pyx_f_4lxml_5etree__writeTail(__pyx_v_c_buffer, __pyx_v_c_node, NULL, 0);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":416
 *     if with_tail:
 *         _writeTail(c_buffer, c_node, NULL, 0)
 *     if not pretty_print:             # <<<<<<<<<<<<<<
 *         # not written yet
 *         tree.xmlOutputBufferWriteString(c_buffer, '\n')
 */
  __pyx_1 = (!__pyx_v_pretty_print);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":418
 *     if not pretty_print:
 *         # not written yet
 *         tree.xmlOutputBufferWriteString(c_buffer, '\n')             # <<<<<<<<<<<<<<
 *     tree.xmlOutputBufferFlush(c_buffer)
 */
    xmlOutputBufferWriteString(__pyx_v_c_buffer, __pyx_k_487);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/serializer.pxi":419
 *         # not written yet
 *         tree.xmlOutputBufferWriteString(c_buffer, '\n')
 *     tree.xmlOutputBufferFlush(c_buffer)             # <<<<<<<<<<<<<<
 */
  xmlOutputBufferFlush(__pyx_v_c_buffer);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._dumpToFile");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":13
 *     ITERPARSE_FILTER_PI        = 32
 * 
 * cdef int _buildIterparseEventFilter(events) except -1:             # <<<<<<<<<<<<<<
 *     cdef int event_filter
 *     event_filter = 0
 */

static  int __pyx_f_4lxml_5etree__buildIterparseEventFilter(PyObject *__pyx_v_events) {
  int __pyx_v_event_filter;
  PyObject *__pyx_v_event;
  int __pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_event = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":15
 * cdef int _buildIterparseEventFilter(events) except -1:
 *     cdef int event_filter
 *     event_filter = 0             # <<<<<<<<<<<<<<
 *     for event in events:
 *         if event == u'start':
 */
  __pyx_v_event_filter = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":16
 *     cdef int event_filter
 *     event_filter = 0
 *     for event in events:             # <<<<<<<<<<<<<<
 *         if event == u'start':
 *             event_filter |= ITERPARSE_FILTER_START
 */
  if (PyList_CheckExact(__pyx_v_events) || PyTuple_CheckExact(__pyx_v_events)) {
    __pyx_1 = 0; __pyx_2 = __pyx_v_events; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_events); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_event);
    __pyx_v_event = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":17
 *     event_filter = 0
 *     for event in events:
 *         if event == u'start':             # <<<<<<<<<<<<<<
 *             event_filter |= ITERPARSE_FILTER_START
 *         elif event == u'end':
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_488), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":18
 *     for event in events:
 *         if event == u'start':
 *             event_filter |= ITERPARSE_FILTER_START             # <<<<<<<<<<<<<<
 *         elif event == u'end':
 *             event_filter |= ITERPARSE_FILTER_END
 */
      __pyx_v_event_filter |= __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":19
 *         if event == u'start':
 *             event_filter |= ITERPARSE_FILTER_START
 *         elif event == u'end':             # <<<<<<<<<<<<<<
 *             event_filter |= ITERPARSE_FILTER_END
 *         elif event == u'start-ns':
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_489), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":20
 *             event_filter |= ITERPARSE_FILTER_START
 *         elif event == u'end':
 *             event_filter |= ITERPARSE_FILTER_END             # <<<<<<<<<<<<<<
 *         elif event == u'start-ns':
 *             event_filter |= ITERPARSE_FILTER_START_NS
 */
      __pyx_v_event_filter |= __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":21
 *         elif event == u'end':
 *             event_filter |= ITERPARSE_FILTER_END
 *         elif event == u'start-ns':             # <<<<<<<<<<<<<<
 *             event_filter |= ITERPARSE_FILTER_START_NS
 *         elif event == u'end-ns':
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_490), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":22
 *             event_filter |= ITERPARSE_FILTER_END
 *         elif event == u'start-ns':
 *             event_filter |= ITERPARSE_FILTER_START_NS             # <<<<<<<<<<<<<<
 *         elif event == u'end-ns':
 *             event_filter |= ITERPARSE_FILTER_END_NS
 */
      __pyx_v_event_filter |= __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":23
 *         elif event == u'start-ns':
 *             event_filter |= ITERPARSE_FILTER_START_NS
 *         elif event == u'end-ns':             # <<<<<<<<<<<<<<
 *             event_filter |= ITERPARSE_FILTER_END_NS
 *         elif event == u'comment':
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_491), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":24
 *             event_filter |= ITERPARSE_FILTER_START_NS
 *         elif event == u'end-ns':
 *             event_filter |= ITERPARSE_FILTER_END_NS             # <<<<<<<<<<<<<<
 *         elif event == u'comment':
 *             event_filter |= ITERPARSE_FILTER_COMMENT
 */
      __pyx_v_event_filter |= __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":25
 *         elif event == u'end-ns':
 *             event_filter |= ITERPARSE_FILTER_END_NS
 *         elif event == u'comment':             # <<<<<<<<<<<<<<
 *             event_filter |= ITERPARSE_FILTER_COMMENT
 *         elif event == u'pi':
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_492), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":26
 *             event_filter |= ITERPARSE_FILTER_END_NS
 *         elif event == u'comment':
 *             event_filter |= ITERPARSE_FILTER_COMMENT             # <<<<<<<<<<<<<<
 *         elif event == u'pi':
 *             event_filter |= ITERPARSE_FILTER_PI
 */
      __pyx_v_event_filter |= __pyx_e_4lxml_5etree_ITERPARSE_FILTER_COMMENT;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":27
 *         elif event == u'comment':
 *             event_filter |= ITERPARSE_FILTER_COMMENT
 *         elif event == u'pi':             # <<<<<<<<<<<<<<
 *             event_filter |= ITERPARSE_FILTER_PI
 *         else:
 */
    __pyx_3 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_493), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":28
 *             event_filter |= ITERPARSE_FILTER_COMMENT
 *         elif event == u'pi':
 *             event_filter |= ITERPARSE_FILTER_PI             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError, u"invalid event name '%s'" % event
 */
      __pyx_v_event_filter |= __pyx_e_4lxml_5etree_ITERPARSE_FILTER_PI;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":30
 *             event_filter |= ITERPARSE_FILTER_PI
 *         else:
 *             raise ValueError, u"invalid event name '%s'" % event             # <<<<<<<<<<<<<<
 *     return event_filter
 * 
 */
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_494), __pyx_v_event); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[14]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L5:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":31
 *         else:
 *             raise ValueError, u"invalid event name '%s'" % event
 *     return event_filter             # <<<<<<<<<<<<<<
 * 
 * cdef int _countNsDefs(xmlNode* c_node):
 */
  __pyx_r = __pyx_v_event_filter;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._buildIterparseEventFilter");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_event);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":33
 *     return event_filter
 * 
 * cdef int _countNsDefs(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     cdef xmlNs* c_ns
 *     cdef int count
 */

static  int __pyx_f_4lxml_5etree__countNsDefs(xmlNode *__pyx_v_c_node) {
  xmlNs *__pyx_v_c_ns;
  int __pyx_v_count;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":36
 *     cdef xmlNs* c_ns
 *     cdef int count
 *     count = 0             # <<<<<<<<<<<<<<
 *     c_ns = c_node.nsDef
 *     while c_ns is not NULL:
 */
  __pyx_v_count = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":37
 *     cdef int count
 *     count = 0
 *     c_ns = c_node.nsDef             # <<<<<<<<<<<<<<
 *     while c_ns is not NULL:
 *         count = count + 1
 */
  __pyx_v_c_ns = __pyx_v_c_node->nsDef;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":38
 *     count = 0
 *     c_ns = c_node.nsDef
 *     while c_ns is not NULL:             # <<<<<<<<<<<<<<
 *         count = count + 1
 *         c_ns = c_ns.next
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_ns != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":39
 *     c_ns = c_node.nsDef
 *     while c_ns is not NULL:
 *         count = count + 1             # <<<<<<<<<<<<<<
 *         c_ns = c_ns.next
 *     return count
 */
    __pyx_v_count = (__pyx_v_count + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":40
 *     while c_ns is not NULL:
 *         count = count + 1
 *         c_ns = c_ns.next             # <<<<<<<<<<<<<<
 *     return count
 * 
 */
    __pyx_v_c_ns = __pyx_v_c_ns->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":41
 *         count = count + 1
 *         c_ns = c_ns.next
 *     return count             # <<<<<<<<<<<<<<
 * 
 * cdef int _appendStartNsEvents(xmlNode* c_node, event_list):
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":43
 *     return count
 * 
 * cdef int _appendStartNsEvents(xmlNode* c_node, event_list):             # <<<<<<<<<<<<<<
 *     cdef xmlNs* c_ns
 *     cdef int count
 */

static  int __pyx_f_4lxml_5etree__appendStartNsEvents(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_event_list) {
  xmlNs *__pyx_v_c_ns;
  int __pyx_v_count;
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_v_ns_tuple;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_tuple = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":46
 *     cdef xmlNs* c_ns
 *     cdef int count
 *     count = 0             # <<<<<<<<<<<<<<
 *     c_ns = c_node.nsDef
 *     while c_ns is not NULL:
 */
  __pyx_v_count = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":47
 *     cdef int count
 *     count = 0
 *     c_ns = c_node.nsDef             # <<<<<<<<<<<<<<
 *     while c_ns is not NULL:
 *         if c_ns.prefix is NULL:
 */
  __pyx_v_c_ns = __pyx_v_c_node->nsDef;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":48
 *     count = 0
 *     c_ns = c_node.nsDef
 *     while c_ns is not NULL:             # <<<<<<<<<<<<<<
 *         if c_ns.prefix is NULL:
 *             if python.IS_PYTHON3:
 */
  while (1) {
    __pyx_1 = (__pyx_v_c_ns != NULL);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":49
 *     c_ns = c_node.nsDef
 *     while c_ns is not NULL:
 *         if c_ns.prefix is NULL:             # <<<<<<<<<<<<<<
 *             if python.IS_PYTHON3:
 *                 prefix = u''
 */
    __pyx_1 = (__pyx_v_c_ns->prefix == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":50
 *     while c_ns is not NULL:
 *         if c_ns.prefix is NULL:
 *             if python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *                 prefix = u''
 *             else:
 */
      __pyx_1 = IS_PYTHON3;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":51
 *         if c_ns.prefix is NULL:
 *             if python.IS_PYTHON3:
 *                 prefix = u''             # <<<<<<<<<<<<<<
 *             else:
 *                 prefix = ''
 */
        Py_INCREF(((PyObject *)__pyx_kp_495));
        Py_DECREF(__pyx_v_prefix);
        __pyx_v_prefix = ((PyObject *)__pyx_kp_495);
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":53
 *                 prefix = u''
 *             else:
 *                 prefix = ''             # <<<<<<<<<<<<<<
 *         else:
 *             prefix = funicode(c_ns.prefix)
 */
        Py_INCREF(__pyx_kp_496);
        Py_DECREF(__pyx_v_prefix);
        __pyx_v_prefix = __pyx_kp_496;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":55
 *                 prefix = ''
 *         else:
 *             prefix = funicode(c_ns.prefix)             # <<<<<<<<<<<<<<
 *         ns_tuple = (prefix, funicode(c_ns.href))
 *         python.PyList_Append(event_list, (u"start-ns", ns_tuple))
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_ns->prefix); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_2;
      __pyx_2 = 0;
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":56
 *         else:
 *             prefix = funicode(c_ns.prefix)
 *         ns_tuple = (prefix, funicode(c_ns.href))             # <<<<<<<<<<<<<<
 *         python.PyList_Append(event_list, (u"start-ns", ns_tuple))
 *         count = count + 1
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_ns->href); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_prefix);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_prefix);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
    __pyx_2 = 0;
    Py_DECREF(__pyx_v_ns_tuple);
    __pyx_v_ns_tuple = ((PyObject *)__pyx_3);
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":57
 *             prefix = funicode(c_ns.prefix)
 *         ns_tuple = (prefix, funicode(c_ns.href))
 *         python.PyList_Append(event_list, (u"start-ns", ns_tuple))             # <<<<<<<<<<<<<<
 *         count = count + 1
 *         c_ns = c_ns.next
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_497));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_497));
    Py_INCREF(__pyx_v_ns_tuple);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_ns_tuple);
    __pyx_4 = PyList_Append(__pyx_v_event_list, ((PyObject *)__pyx_2)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":58
 *         ns_tuple = (prefix, funicode(c_ns.href))
 *         python.PyList_Append(event_list, (u"start-ns", ns_tuple))
 *         count = count + 1             # <<<<<<<<<<<<<<
 *         c_ns = c_ns.next
 *     return count
 */
    __pyx_v_count = (__pyx_v_count + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":59
 *         python.PyList_Append(event_list, (u"start-ns", ns_tuple))
 *         count = count + 1
 *         c_ns = c_ns.next             # <<<<<<<<<<<<<<
 *     return count
 * 
 */
    __pyx_v_c_ns = __pyx_v_c_ns->next;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":60
 *         count = count + 1
 *         c_ns = c_ns.next
 *     return count             # <<<<<<<<<<<<<<
 * 
 * cdef class _IterparseContext(_ParserContext):
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("lxml.etree._appendStartNsEvents");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix);
  Py_DECREF(__pyx_v_ns_tuple);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":82
 *     cdef char*  _tag_name
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._ns_stack = []
 *         self._pop_ns = self._ns_stack.pop
 */

static int __pyx_pf_4lxml_5etree_17_IterparseContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_17_IterparseContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":83
 * 
 *     def __init__(self):
 *         self._ns_stack = []             # <<<<<<<<<<<<<<
 *         self._pop_ns = self._ns_stack.pop
 *         self._node_stack = []
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_ns_stack);
  ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_ns_stack = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":84
 *     def __init__(self):
 *         self._ns_stack = []
 *         self._pop_ns = self._ns_stack.pop             # <<<<<<<<<<<<<<
 *         self._node_stack = []
 *         self._pop_node = self._node_stack.pop
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_ns_stack, __pyx_kp_pop); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_pop_ns);
  ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_pop_ns = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":85
 *         self._ns_stack = []
 *         self._pop_ns = self._ns_stack.pop
 *         self._node_stack = []             # <<<<<<<<<<<<<<
 *         self._pop_node = self._node_stack.pop
 *         self._events = []
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_node_stack);
  ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_node_stack = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":86
 *         self._pop_ns = self._ns_stack.pop
 *         self._node_stack = []
 *         self._pop_node = self._node_stack.pop             # <<<<<<<<<<<<<<
 *         self._events = []
 *         self._event_index = 0
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_node_stack, __pyx_kp_pop); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_pop_node);
  ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_pop_node = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":87
 *         self._node_stack = []
 *         self._pop_node = self._node_stack.pop
 *         self._events = []             # <<<<<<<<<<<<<<
 *         self._event_index = 0
 * 
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_events);
  ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_events = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":88
 *         self._pop_node = self._node_stack.pop
 *         self._events = []
 *         self._event_index = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):
 */
  ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_self)->_event_index = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IterparseContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":90
 *         self._event_index = 0
 * 
 *     cdef void _initParserContext(self, xmlparser.xmlParserCtxt* c_ctxt):             # <<<<<<<<<<<<<<
 *         u"wrap original SAX2 callbacks"
 *         cdef xmlparser.xmlSAXHandler* sax
 */

static  void __pyx_f_4lxml_5etree_17_IterparseContext__initParserContext(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_self, xmlParserCtxt *__pyx_v_c_ctxt) {
  xmlSAXHandler *__pyx_v_sax;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":93
 *         u"wrap original SAX2 callbacks"
 *         cdef xmlparser.xmlSAXHandler* sax
 *         _ParserContext._initParserContext(self, c_ctxt)             # <<<<<<<<<<<<<<
 *         sax = c_ctxt.sax
 *         self._origSaxStart = sax.startElementNs
 */
  __pyx_vtabptr_4lxml_5etree__ParserContext->_initParserContext(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_self), __pyx_v_c_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":94
 *         cdef xmlparser.xmlSAXHandler* sax
 *         _ParserContext._initParserContext(self, c_ctxt)
 *         sax = c_ctxt.sax             # <<<<<<<<<<<<<<
 *         self._origSaxStart = sax.startElementNs
 *         self._origSaxStartNoNs = sax.startElement
 */
  __pyx_v_sax = __pyx_v_c_ctxt->sax;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":95
 *         _ParserContext._initParserContext(self, c_ctxt)
 *         sax = c_ctxt.sax
 *         self._origSaxStart = sax.startElementNs             # <<<<<<<<<<<<<<
 *         self._origSaxStartNoNs = sax.startElement
 *         # only override start event handler if needed
 */
  __pyx_v_self->_origSaxStart = __pyx_v_sax->startElementNs;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":96
 *         sax = c_ctxt.sax
 *         self._origSaxStart = sax.startElementNs
 *         self._origSaxStartNoNs = sax.startElement             # <<<<<<<<<<<<<<
 *         # only override start event handler if needed
 *         if self._event_filter == 0 or \
 */
  __pyx_v_self->_origSaxStartNoNs = __pyx_v_sax->startElement;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":98
 *         self._origSaxStartNoNs = sax.startElement
 *         # only override start event handler if needed
 *         if self._event_filter == 0 or \             # <<<<<<<<<<<<<<
 *                self._event_filter & (ITERPARSE_FILTER_START | \
 *                                      ITERPARSE_FILTER_START_NS | \
 */
  __pyx_1 = (__pyx_v_self->_event_filter == 0);
  if (!__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":101
 *                self._event_filter & (ITERPARSE_FILTER_START | \
 *                                      ITERPARSE_FILTER_START_NS | \
 *                                      ITERPARSE_FILTER_END_NS):             # <<<<<<<<<<<<<<
 *             sax.startElementNs = _iterparseSaxStart
 *             sax.startElement = _iterparseSaxStartNoNs
 */
    __pyx_1 = (__pyx_v_self->_event_filter & ((__pyx_e_4lxml_5etree_ITERPARSE_FILTER_START | __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS) | __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":102
 *                                      ITERPARSE_FILTER_START_NS | \
 *                                      ITERPARSE_FILTER_END_NS):
 *             sax.startElementNs = _iterparseSaxStart             # <<<<<<<<<<<<<<
 *             sax.startElement = _iterparseSaxStartNoNs
 * 
 */
    __pyx_v_sax->startElementNs = __pyx_f_4lxml_5etree__iterparseSaxStart;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":103
 *                                      ITERPARSE_FILTER_END_NS):
 *             sax.startElementNs = _iterparseSaxStart
 *             sax.startElement = _iterparseSaxStartNoNs             # <<<<<<<<<<<<<<
 * 
 *         self._origSaxEnd = sax.endElementNs
 */
    __pyx_v_sax->startElement = __pyx_f_4lxml_5etree__iterparseSaxStartNoNs;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":105
 *             sax.startElement = _iterparseSaxStartNoNs
 * 
 *         self._origSaxEnd = sax.endElementNs             # <<<<<<<<<<<<<<
 *         self._origSaxEndNoNs = sax.endElement
 *         # only override end event handler if needed
 */
  __pyx_v_self->_origSaxEnd = __pyx_v_sax->endElementNs;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":106
 * 
 *         self._origSaxEnd = sax.endElementNs
 *         self._origSaxEndNoNs = sax.endElement             # <<<<<<<<<<<<<<
 *         # only override end event handler if needed
 *         if self._event_filter == 0 or \
 */
  __pyx_v_self->_origSaxEndNoNs = __pyx_v_sax->endElement;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":108
 *         self._origSaxEndNoNs = sax.endElement
 *         # only override end event handler if needed
 *         if self._event_filter == 0 or \             # <<<<<<<<<<<<<<
 *                self._event_filter & (ITERPARSE_FILTER_END | \
 *                                      ITERPARSE_FILTER_END_NS):
 */
  __pyx_1 = (__pyx_v_self->_event_filter == 0);
  if (!__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":110
 *         if self._event_filter == 0 or \
 *                self._event_filter & (ITERPARSE_FILTER_END | \
 *                                      ITERPARSE_FILTER_END_NS):             # <<<<<<<<<<<<<<
 *             sax.endElementNs = _iterparseSaxEnd
 *             sax.endElement = _iterparseSaxEndNoNs
 */
    __pyx_1 = (__pyx_v_self->_event_filter & (__pyx_e_4lxml_5etree_ITERPARSE_FILTER_END | __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":111
 *                self._event_filter & (ITERPARSE_FILTER_END | \
 *                                      ITERPARSE_FILTER_END_NS):
 *             sax.endElementNs = _iterparseSaxEnd             # <<<<<<<<<<<<<<
 *             sax.endElement = _iterparseSaxEndNoNs
 * 
 */
    __pyx_v_sax->endElementNs = __pyx_f_4lxml_5etree__iterparseSaxEnd;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":112
 *                                      ITERPARSE_FILTER_END_NS):
 *             sax.endElementNs = _iterparseSaxEnd
 *             sax.endElement = _iterparseSaxEndNoNs             # <<<<<<<<<<<<<<
 * 
 *         self._origSaxComment = sax.comment
 */
    __pyx_v_sax->endElement = __pyx_f_4lxml_5etree__iterparseSaxEndNoNs;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":114
 *             sax.endElement = _iterparseSaxEndNoNs
 * 
 *         self._origSaxComment = sax.comment             # <<<<<<<<<<<<<<
 *         if self._event_filter & ITERPARSE_FILTER_COMMENT:
 *             sax.comment = _iterparseSaxComment
 */
  __pyx_v_self->_origSaxComment = __pyx_v_sax->comment;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":115
 * 
 *         self._origSaxComment = sax.comment
 *         if self._event_filter & ITERPARSE_FILTER_COMMENT:             # <<<<<<<<<<<<<<
 *             sax.comment = _iterparseSaxComment
 * 
 */
  __pyx_2 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_COMMENT);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":116
 *         self._origSaxComment = sax.comment
 *         if self._event_filter & ITERPARSE_FILTER_COMMENT:
 *             sax.comment = _iterparseSaxComment             # <<<<<<<<<<<<<<
 * 
 *         self._origSaxPI = sax.processingInstruction
 */
    __pyx_v_sax->comment = __pyx_f_4lxml_5etree__iterparseSaxComment;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":118
 *             sax.comment = _iterparseSaxComment
 * 
 *         self._origSaxPI = sax.processingInstruction             # <<<<<<<<<<<<<<
 *         if self._event_filter & ITERPARSE_FILTER_PI:
 *             sax.processingInstruction = _iterparseSaxPI
 */
  __pyx_v_self->_origSaxPI = __pyx_v_sax->processingInstruction;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":119
 * 
 *         self._origSaxPI = sax.processingInstruction
 *         if self._event_filter & ITERPARSE_FILTER_PI:             # <<<<<<<<<<<<<<
 *             sax.processingInstruction = _iterparseSaxPI
 * 
 */
  __pyx_2 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_PI);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":120
 *         self._origSaxPI = sax.processingInstruction
 *         if self._event_filter & ITERPARSE_FILTER_PI:
 *             sax.processingInstruction = _iterparseSaxPI             # <<<<<<<<<<<<<<
 * 
 *     cdef _setEventFilter(self, events, tag):
 */
    __pyx_v_sax->processingInstruction = __pyx_f_4lxml_5etree__iterparseSaxPI;
    goto __pyx_L6;
  }
  __pyx_L6:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":122
 *             sax.processingInstruction = _iterparseSaxPI
 * 
 *     cdef _setEventFilter(self, events, tag):             # <<<<<<<<<<<<<<
 *         self._event_filter = _buildIterparseEventFilter(events)
 *         if tag is None or tag == u'*':
 */

static  PyObject *__pyx_f_4lxml_5etree_17_IterparseContext__setEventFilter(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_self, PyObject *__pyx_v_events, PyObject *__pyx_v_tag) {
  PyObject *__pyx_v_href;
  PyObject *__pyx_v_name;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_v_href = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":123
 * 
 *     cdef _setEventFilter(self, events, tag):
 *         self._event_filter = _buildIterparseEventFilter(events)             # <<<<<<<<<<<<<<
 *         if tag is None or tag == u'*':
 *             self._tag_href  = NULL
 */
  __pyx_1 = __pyx_f_4lxml_5etree__buildIterparseEventFilter(__pyx_v_events); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_event_filter = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":124
 *     cdef _setEventFilter(self, events, tag):
 *         self._event_filter = _buildIterparseEventFilter(events)
 *         if tag is None or tag == u'*':             # <<<<<<<<<<<<<<
 *             self._tag_href  = NULL
 *             self._tag_name  = NULL
 */
  __pyx_2 = (__pyx_v_tag == Py_None);
  if (!__pyx_2) {
    __pyx_4 = PyObject_RichCompare(__pyx_v_tag, ((PyObject *)__pyx_kp_498), Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":125
 *         self._event_filter = _buildIterparseEventFilter(events)
 *         if tag is None or tag == u'*':
 *             self._tag_href  = NULL             # <<<<<<<<<<<<<<
 *             self._tag_name  = NULL
 *         else:
 */
    __pyx_v_self->_tag_href = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":126
 *         if tag is None or tag == u'*':
 *             self._tag_href  = NULL
 *             self._tag_name  = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             self._tag_tuple = _getNsTag(tag)
 */
    __pyx_v_self->_tag_name = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":128
 *             self._tag_name  = NULL
 *         else:
 *             self._tag_tuple = _getNsTag(tag)             # <<<<<<<<<<<<<<
 *             href, name = self._tag_tuple
 *             if href is None or href == '*':
 */
    __pyx_4 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_tag); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_self->_tag_tuple);
    __pyx_v_self->_tag_tuple = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":129
 *         else:
 *             self._tag_tuple = _getNsTag(tag)
 *             href, name = self._tag_tuple             # <<<<<<<<<<<<<<
 *             if href is None or href == '*':
 *                 self._tag_href = NULL
 */
    if (PyTuple_CheckExact(__pyx_v_self->_tag_tuple) && PyTuple_GET_SIZE(__pyx_v_self->_tag_tuple) == 2) {
      PyObject* tuple = __pyx_v_self->_tag_tuple;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_href);
      __pyx_v_href = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_5;
      __pyx_5 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_v_self->_tag_tuple); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_href);
      __pyx_v_href = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":130
 *             self._tag_tuple = _getNsTag(tag)
 *             href, name = self._tag_tuple
 *             if href is None or href == '*':             # <<<<<<<<<<<<<<
 *                 self._tag_href = NULL
 *             else:
 */
    __pyx_3 = (__pyx_v_href == Py_None);
    if (!__pyx_3) {
      __pyx_5 = PyObject_RichCompare(__pyx_v_href, __pyx_kp_499, Py_EQ); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_5); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":131
 *             href, name = self._tag_tuple
 *             if href is None or href == '*':
 *                 self._tag_href = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 self._tag_href = _cstr(href)
 */
      __pyx_v_self->_tag_href = NULL;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":133
 *                 self._tag_href = NULL
 *             else:
 *                 self._tag_href = _cstr(href)             # <<<<<<<<<<<<<<
 *             if name is None or name == '*':
 *                 self._tag_name = NULL
 */
      __pyx_v_self->_tag_href = PyString_AS_STRING(__pyx_v_href);
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":134
 *             else:
 *                 self._tag_href = _cstr(href)
 *             if name is None or name == '*':             # <<<<<<<<<<<<<<
 *                 self._tag_name = NULL
 *             else:
 */
    __pyx_2 = (__pyx_v_name == Py_None);
    if (!__pyx_2) {
      __pyx_4 = PyObject_RichCompare(__pyx_v_name, __pyx_kp_500, Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":135
 *                 self._tag_href = _cstr(href)
 *             if name is None or name == '*':
 *                 self._tag_name = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 self._tag_name = _cstr(name)
 */
      __pyx_v_self->_tag_name = NULL;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":137
 *                 self._tag_name = NULL
 *             else:
 *                 self._tag_name = _cstr(name)             # <<<<<<<<<<<<<<
 *             if self._tag_href is NULL and self._tag_name is NULL:
 *                 self._tag_tuple = None
 */
      __pyx_v_self->_tag_name = PyString_AS_STRING(__pyx_v_name);
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":138
 *             else:
 *                 self._tag_name = _cstr(name)
 *             if self._tag_href is NULL and self._tag_name is NULL:             # <<<<<<<<<<<<<<
 *                 self._tag_tuple = None
 * 
 */
    __pyx_3 = (__pyx_v_self->_tag_href == NULL);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_self->_tag_name == NULL);
    }
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":139
 *                 self._tag_name = _cstr(name)
 *             if self._tag_href is NULL and self._tag_name is NULL:
 *                 self._tag_tuple = None             # <<<<<<<<<<<<<<
 * 
 *     cdef int startNode(self, xmlNode* c_node) except -1:
 */
      Py_INCREF(Py_None);
      Py_DECREF(__pyx_v_self->_tag_tuple);
      __pyx_v_self->_tag_tuple = Py_None;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._IterparseContext._setEventFilter");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_href);
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":141
 *                 self._tag_tuple = None
 * 
 *     cdef int startNode(self, xmlNode* c_node) except -1:             # <<<<<<<<<<<<<<
 *         cdef xmlNs* c_ns
 *         cdef int ns_count
 */

static  int __pyx_f_4lxml_5etree_17_IterparseContext_startNode(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_self, xmlNode *__pyx_v_c_node) {
  int __pyx_v_ns_count;
  PyObject *__pyx_v_node;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_node = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":144
 *         cdef xmlNs* c_ns
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:             # <<<<<<<<<<<<<<
 *             ns_count = _appendStartNsEvents(c_node, self._events)
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":145
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:
 *             ns_count = _appendStartNsEvents(c_node, self._events)             # <<<<<<<<<<<<<<
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = _countNsDefs(c_node)
 */
    __pyx_v_ns_count = __pyx_f_4lxml_5etree__appendStartNsEvents(__pyx_v_c_node, __pyx_v_self->_events);
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":146
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:
 *             ns_count = _appendStartNsEvents(c_node, self._events)
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:             # <<<<<<<<<<<<<<
 *             ns_count = _countNsDefs(c_node)
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":147
 *             ns_count = _appendStartNsEvents(c_node, self._events)
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = _countNsDefs(c_node)             # <<<<<<<<<<<<<<
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             python.PyList_Append(self._ns_stack, ns_count)
 */
    __pyx_v_ns_count = __pyx_f_4lxml_5etree__countNsDefs(__pyx_v_c_node);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":148
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = _countNsDefs(c_node)
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:             # <<<<<<<<<<<<<<
 *             python.PyList_Append(self._ns_stack, ns_count)
 *         if self._root is None:
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":149
 *             ns_count = _countNsDefs(c_node)
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             python.PyList_Append(self._ns_stack, ns_count)             # <<<<<<<<<<<<<<
 *         if self._root is None:
 *             if self._doc is None:
 */
    __pyx_2 = PyInt_FromLong(__pyx_v_ns_count); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = PyList_Append(__pyx_v_self->_ns_stack, __pyx_2); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":150
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             python.PyList_Append(self._ns_stack, ns_count)
 *         if self._root is None:             # <<<<<<<<<<<<<<
 *             if self._doc is None:
 *                 self._doc = _documentFactory(c_node.doc, None)
 */
  __pyx_3 = (((PyObject *)__pyx_v_self->_root) == Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":151
 *             python.PyList_Append(self._ns_stack, ns_count)
 *         if self._root is None:
 *             if self._doc is None:             # <<<<<<<<<<<<<<
 *                 self._doc = _documentFactory(c_node.doc, None)
 *             self._root = self._doc.getroot()
 */
    __pyx_3 = (((PyObject *)__pyx_v_self->_doc) == Py_None);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":152
 *         if self._root is None:
 *             if self._doc is None:
 *                 self._doc = _documentFactory(c_node.doc, None)             # <<<<<<<<<<<<<<
 *             self._root = self._doc.getroot()
 *         if self._tag_tuple is None or \
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_node->doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_self->_doc));
      __pyx_v_self->_doc = ((struct LxmlDocument *)__pyx_2);
      __pyx_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":153
 *             if self._doc is None:
 *                 self._doc = _documentFactory(c_node.doc, None)
 *             self._root = self._doc.getroot()             # <<<<<<<<<<<<<<
 *         if self._tag_tuple is None or \
 *                _tagMatches(c_node, self._tag_href, self._tag_name):
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_self->_doc->__pyx_vtab)->getroot(__pyx_v_self->_doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_self->_root));
    __pyx_v_self->_root = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":154
 *                 self._doc = _documentFactory(c_node.doc, None)
 *             self._root = self._doc.getroot()
 *         if self._tag_tuple is None or \             # <<<<<<<<<<<<<<
 *                _tagMatches(c_node, self._tag_href, self._tag_name):
 *             node = _elementFactory(self._doc, c_node)
 */
  __pyx_3 = (__pyx_v_self->_tag_tuple == Py_None);
  if (!__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":155
 *             self._root = self._doc.getroot()
 *         if self._tag_tuple is None or \
 *                _tagMatches(c_node, self._tag_href, self._tag_name):             # <<<<<<<<<<<<<<
 *             node = _elementFactory(self._doc, c_node)
 *             if self._event_filter & ITERPARSE_FILTER_END:
 */
    __pyx_3 = __pyx_f_4lxml_5etree__tagMatches(__pyx_v_c_node, __pyx_v_self->_tag_href, __pyx_v_self->_tag_name);
  }
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":156
 *         if self._tag_tuple is None or \
 *                _tagMatches(c_node, self._tag_href, self._tag_name):
 *             node = _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 *             if self._event_filter & ITERPARSE_FILTER_END:
 *                 python.PyList_Append(self._node_stack, node)
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_self->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_node);
    __pyx_v_node = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":157
 *                _tagMatches(c_node, self._tag_href, self._tag_name):
 *             node = _elementFactory(self._doc, c_node)
 *             if self._event_filter & ITERPARSE_FILTER_END:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._node_stack, node)
 *             if self._event_filter & ITERPARSE_FILTER_START:
 */
    __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":158
 *             node = _elementFactory(self._doc, c_node)
 *             if self._event_filter & ITERPARSE_FILTER_END:
 *                 python.PyList_Append(self._node_stack, node)             # <<<<<<<<<<<<<<
 *             if self._event_filter & ITERPARSE_FILTER_START:
 *                 python.PyList_Append(self._events, (u"start", node))
 */
      __pyx_1 = PyList_Append(__pyx_v_self->_node_stack, __pyx_v_node); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":159
 *             if self._event_filter & ITERPARSE_FILTER_END:
 *                 python.PyList_Append(self._node_stack, node)
 *             if self._event_filter & ITERPARSE_FILTER_START:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._events, (u"start", node))
 *         return 0
 */
    __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":160
 *                 python.PyList_Append(self._node_stack, node)
 *             if self._event_filter & ITERPARSE_FILTER_START:
 *                 python.PyList_Append(self._events, (u"start", node))             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
      __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_501));
      PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_501));
      Py_INCREF(__pyx_v_node);
      PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_node);
      __pyx_1 = PyList_Append(__pyx_v_self->_events, ((PyObject *)__pyx_2)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      goto __pyx_L9;
    }
    __pyx_L9:;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":161
 *             if self._event_filter & ITERPARSE_FILTER_START:
 *                 python.PyList_Append(self._events, (u"start", node))
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int endNode(self, xmlNode* c_node) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IterparseContext.startNode");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":163
 *         return 0
 * 
 *     cdef int endNode(self, xmlNode* c_node) except -1:             # <<<<<<<<<<<<<<
 *         cdef xmlNs* c_ns
 *         cdef int ns_count
 */

static  int __pyx_f_4lxml_5etree_17_IterparseContext_endNode(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_self, xmlNode *__pyx_v_c_node) {
  int __pyx_v_ns_count;
  PyObject *__pyx_v_node;
  PyObject *__pyx_v_event;
  PyObject *__pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  long __pyx_4;
  __pyx_v_node = Py_None; Py_INCREF(Py_None);
  __pyx_v_event = Py_None; Py_INCREF(Py_None);
  __pyx_v_i = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":166
 *         cdef xmlNs* c_ns
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_END:             # <<<<<<<<<<<<<<
 *             if self._tag_tuple is None or \
 *                    _tagMatches(c_node, self._tag_href, self._tag_name):
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":167
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_END:
 *             if self._tag_tuple is None or \             # <<<<<<<<<<<<<<
 *                    _tagMatches(c_node, self._tag_href, self._tag_name):
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 */
    __pyx_2 = (__pyx_v_self->_tag_tuple == Py_None);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":168
 *         if self._event_filter & ITERPARSE_FILTER_END:
 *             if self._tag_tuple is None or \
 *                    _tagMatches(c_node, self._tag_href, self._tag_name):             # <<<<<<<<<<<<<<
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 *                                          ITERPARSE_FILTER_START_NS | \
 */
      __pyx_2 = __pyx_f_4lxml_5etree__tagMatches(__pyx_v_c_node, __pyx_v_self->_tag_href, __pyx_v_self->_tag_name);
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":171
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 *                                          ITERPARSE_FILTER_START_NS | \
 *                                          ITERPARSE_FILTER_END_NS):             # <<<<<<<<<<<<<<
 *                     node = self._pop_node()
 *                 else:
 */
      __pyx_1 = (__pyx_v_self->_event_filter & ((__pyx_e_4lxml_5etree_ITERPARSE_FILTER_START | __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS) | __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS));
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":172
 *                                          ITERPARSE_FILTER_START_NS | \
 *                                          ITERPARSE_FILTER_END_NS):
 *                     node = self._pop_node()             # <<<<<<<<<<<<<<
 *                 else:
 *                     if self._root is None:
 */
        __pyx_3 = PyObject_Call(__pyx_v_self->_pop_node, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_node);
        __pyx_v_node = __pyx_3;
        __pyx_3 = 0;
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":174
 *                     node = self._pop_node()
 *                 else:
 *                     if self._root is None:             # <<<<<<<<<<<<<<
 *                         if self._doc is None:
 *                             self._doc = _documentFactory(c_node.doc, None)
 */
        __pyx_2 = (((PyObject *)__pyx_v_self->_root) == Py_None);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":175
 *                 else:
 *                     if self._root is None:
 *                         if self._doc is None:             # <<<<<<<<<<<<<<
 *                             self._doc = _documentFactory(c_node.doc, None)
 *                         self._root = self._doc.getroot()
 */
          __pyx_2 = (((PyObject *)__pyx_v_self->_doc) == Py_None);
          if (__pyx_2) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":176
 *                     if self._root is None:
 *                         if self._doc is None:
 *                             self._doc = _documentFactory(c_node.doc, None)             # <<<<<<<<<<<<<<
 *                         self._root = self._doc.getroot()
 *                     node = _elementFactory(self._doc, c_node)
 */
            __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_node->doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(((PyObject *)__pyx_v_self->_doc));
            __pyx_v_self->_doc = ((struct LxmlDocument *)__pyx_3);
            __pyx_3 = 0;
            goto __pyx_L7;
          }
          __pyx_L7:;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":177
 *                         if self._doc is None:
 *                             self._doc = _documentFactory(c_node.doc, None)
 *                         self._root = self._doc.getroot()             # <<<<<<<<<<<<<<
 *                     node = _elementFactory(self._doc, c_node)
 *                 python.PyList_Append(self._events, (u"end", node))
 */
          __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_self->_doc->__pyx_vtab)->getroot(__pyx_v_self->_doc); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(((PyObject *)__pyx_v_self->_root));
          __pyx_v_self->_root = ((struct LxmlElement *)__pyx_3);
          __pyx_3 = 0;
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":178
 *                             self._doc = _documentFactory(c_node.doc, None)
 *                         self._root = self._doc.getroot()
 *                     node = _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._events, (u"end", node))
 * 
 */
        __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_self->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_node);
        __pyx_v_node = __pyx_3;
        __pyx_3 = 0;
      }
      __pyx_L5:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":179
 *                         self._root = self._doc.getroot()
 *                     node = _elementFactory(self._doc, c_node)
 *                 python.PyList_Append(self._events, (u"end", node))             # <<<<<<<<<<<<<<
 * 
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 */
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_502));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_502));
      Py_INCREF(__pyx_v_node);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_node);
      __pyx_1 = PyList_Append(__pyx_v_self->_events, ((PyObject *)__pyx_3)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":181
 *                 python.PyList_Append(self._events, (u"end", node))
 * 
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:             # <<<<<<<<<<<<<<
 *             ns_count = self._pop_ns()
 *             if ns_count > 0:
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":182
 * 
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = self._pop_ns()             # <<<<<<<<<<<<<<
 *             if ns_count > 0:
 *                 event = (u"end-ns", None)
 */
    __pyx_3 = PyObject_Call(__pyx_v_self->_pop_ns, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __pyx_PyInt_int(__pyx_3); if (unlikely((__pyx_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_ns_count = __pyx_1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":183
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = self._pop_ns()
 *             if ns_count > 0:             # <<<<<<<<<<<<<<
 *                 event = (u"end-ns", None)
 *                 for i from 0 <= i < ns_count:
 */
    __pyx_2 = (__pyx_v_ns_count > 0);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":184
 *             ns_count = self._pop_ns()
 *             if ns_count > 0:
 *                 event = (u"end-ns", None)             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < ns_count:
 *                     python.PyList_Append(self._events, event)
 */
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_503));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_503));
      Py_INCREF(Py_None);
      PyTuple_SET_ITEM(__pyx_3, 1, Py_None);
      Py_DECREF(__pyx_v_event);
      __pyx_v_event = ((PyObject *)__pyx_3);
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":185
 *             if ns_count > 0:
 *                 event = (u"end-ns", None)
 *                 for i from 0 <= i < ns_count:             # <<<<<<<<<<<<<<
 *                     python.PyList_Append(self._events, event)
 *         return 0
 */
      for (__pyx_4 = 0; __pyx_4 < __pyx_v_ns_count; __pyx_4++) {
        __pyx_3 = PyInt_FromLong(__pyx_4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_i);
        __pyx_v_i = __pyx_3;
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":186
 *                 event = (u"end-ns", None)
 *                 for i from 0 <= i < ns_count:
 *                     python.PyList_Append(self._events, event)             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
        __pyx_1 = PyList_Append(__pyx_v_self->_events, __pyx_v_event); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      goto __pyx_L9;
    }
    __pyx_L9:;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":187
 *                 for i from 0 <= i < ns_count:
 *                     python.PyList_Append(self._events, event)
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef int pushEvent(self, event, xmlNode* c_node) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._IterparseContext.endNode");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_node);
  Py_DECREF(__pyx_v_event);
  Py_DECREF(__pyx_v_i);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":189
 *         return 0
 * 
 *     cdef int pushEvent(self, event, xmlNode* c_node) except -1:             # <<<<<<<<<<<<<<
 *         cdef _Element root
 *         if self._doc is None:
 */

static  int __pyx_f_4lxml_5etree_17_IterparseContext_pushEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_self, PyObject *__pyx_v_event, xmlNode *__pyx_v_c_node) {
  struct LxmlElement *__pyx_v_root;
  PyObject *__pyx_v_node;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_root = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_node = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":191
 *     cdef int pushEvent(self, event, xmlNode* c_node) except -1:
 *         cdef _Element root
 *         if self._doc is None:             # <<<<<<<<<<<<<<
 *             self._doc = _documentFactory(c_node.doc, None)
 *             root = self._doc.getroot()
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_doc) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":192
 *         cdef _Element root
 *         if self._doc is None:
 *             self._doc = _documentFactory(c_node.doc, None)             # <<<<<<<<<<<<<<
 *             root = self._doc.getroot()
 *             if root is not None and root._c_node.type == tree.XML_ELEMENT_NODE:
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_node->doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_self->_doc));
    __pyx_v_self->_doc = ((struct LxmlDocument *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":193
 *         if self._doc is None:
 *             self._doc = _documentFactory(c_node.doc, None)
 *             root = self._doc.getroot()             # <<<<<<<<<<<<<<
 *             if root is not None and root._c_node.type == tree.XML_ELEMENT_NODE:
 *                 self._root = root
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_self->_doc->__pyx_vtab)->getroot(__pyx_v_self->_doc); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_root));
    __pyx_v_root = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":194
 *             self._doc = _documentFactory(c_node.doc, None)
 *             root = self._doc.getroot()
 *             if root is not None and root._c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *                 self._root = root
 *         node = _elementFactory(self._doc, c_node)
 */
    __pyx_1 = (((PyObject *)__pyx_v_root) != Py_None);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_root->_c_node->type == XML_ELEMENT_NODE);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":195
 *             root = self._doc.getroot()
 *             if root is not None and root._c_node.type == tree.XML_ELEMENT_NODE:
 *                 self._root = root             # <<<<<<<<<<<<<<
 *         node = _elementFactory(self._doc, c_node)
 *         python.PyList_Append(self._events, (event, node))
 */
      Py_INCREF(((PyObject *)__pyx_v_root));
      Py_DECREF(((PyObject *)__pyx_v_self->_root));
      __pyx_v_self->_root = __pyx_v_root;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":196
 *             if root is not None and root._c_node.type == tree.XML_ELEMENT_NODE:
 *                 self._root = root
 *         node = _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 *         python.PyList_Append(self._events, (event, node))
 *         return 0
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_self->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_node);
  __pyx_v_node = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":197
 *                 self._root = root
 *         node = _elementFactory(self._doc, c_node)
 *         python.PyList_Append(self._events, (event, node))             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_event);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_event);
  Py_INCREF(__pyx_v_node);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_node);
  __pyx_3 = PyList_Append(__pyx_v_self->_events, ((PyObject *)__pyx_2)); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":198
 *         node = _elementFactory(self._doc, c_node)
 *         python.PyList_Append(self._events, (event, node))
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void _assureDocGetsFreed(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IterparseContext.pushEvent");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":200
 *         return 0
 * 
 *     cdef void _assureDocGetsFreed(self):             # <<<<<<<<<<<<<<
 *         if self._c_ctxt.myDoc is not NULL and self._doc is None:
 *             tree.xmlFreeDoc(self._c_ctxt.myDoc)
 */

static  void __pyx_f_4lxml_5etree_17_IterparseContext__assureDocGetsFreed(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":201
 * 
 *     cdef void _assureDocGetsFreed(self):
 *         if self._c_ctxt.myDoc is not NULL and self._doc is None:             # <<<<<<<<<<<<<<
 *             tree.xmlFreeDoc(self._c_ctxt.myDoc)
 *             self._c_ctxt.myDoc = NULL
 */
  __pyx_1 = (__pyx_v_self->__pyx_base._c_ctxt->myDoc != NULL);
  if (__pyx_1) {
    __pyx_1 = (((PyObject *)__pyx_v_self->_doc) == Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":202
 *     cdef void _assureDocGetsFreed(self):
 *         if self._c_ctxt.myDoc is not NULL and self._doc is None:
 *             tree.xmlFreeDoc(self._c_ctxt.myDoc)             # <<<<<<<<<<<<<<
 *             self._c_ctxt.myDoc = NULL
 * 
 */
    xmlFreeDoc(__pyx_v_self->__pyx_base._c_ctxt->myDoc);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":203
 *         if self._c_ctxt.myDoc is not NULL and self._doc is None:
 *             tree.xmlFreeDoc(self._c_ctxt.myDoc)
 *             self._c_ctxt.myDoc = NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_self->__pyx_base._c_ctxt->myDoc = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":206
 * 
 * 
 * cdef inline void _pushSaxStartEvent(_IterparseContext context,             # <<<<<<<<<<<<<<
 *                                     xmlNode* c_node):
 *     try:
 */

static INLINE void __pyx_f_4lxml_5etree__pushSaxStartEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context, xmlNode *__pyx_v_c_node) {
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":208
 * cdef inline void _pushSaxStartEvent(_IterparseContext context,
 *                                     xmlNode* c_node):
 *     try:             # <<<<<<<<<<<<<<
 *         if context._c_ctxt.html:
 *             _fixHtmlDictNodeNames(context._c_ctxt.dict, c_node)
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":209
 *                                     xmlNode* c_node):
 *     try:
 *         if context._c_ctxt.html:             # <<<<<<<<<<<<<<
 *             _fixHtmlDictNodeNames(context._c_ctxt.dict, c_node)
 *         context.startNode(c_node)
 */
      __pyx_1 = __pyx_v_context->__pyx_base._c_ctxt->html;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":210
 *     try:
 *         if context._c_ctxt.html:
 *             _fixHtmlDictNodeNames(context._c_ctxt.dict, c_node)             # <<<<<<<<<<<<<<
 *         context.startNode(c_node)
 *     except:
 */
        __pyx_f_4lxml_5etree__fixHtmlDictNodeNames(__pyx_v_context->__pyx_base._c_ctxt->dict, __pyx_v_c_node);
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":211
 *         if context._c_ctxt.html:
 *             _fixHtmlDictNodeNames(context._c_ctxt.dict, c_node)
 *         context.startNode(c_node)             # <<<<<<<<<<<<<<
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->startNode(__pyx_v_context, __pyx_v_c_node); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L7_try;
    __pyx_L3_error:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":212
 *             _fixHtmlDictNodeNames(context._c_ctxt.dict, c_node)
 *         context.startNode(c_node)
 *     except:             # <<<<<<<<<<<<<<
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._pushSaxStartEvent");
      if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":213
 *         context.startNode(c_node)
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:             # <<<<<<<<<<<<<<
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1
 */
      __pyx_1 = (__pyx_v_context->__pyx_base._c_ctxt->errNo == XML_ERR_OK);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":214
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR             # <<<<<<<<<<<<<<
 *         context._c_ctxt.disableSAX = 1
 *         context._store_raised()
 */
        __pyx_v_context->__pyx_base._c_ctxt->errNo = XML_ERR_INTERNAL_ERROR;
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":215
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1             # <<<<<<<<<<<<<<
 *         context._store_raised()
 * 
 */
      __pyx_v_context->__pyx_base._c_ctxt->disableSAX = 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":216
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1
 *         context._store_raised()             # <<<<<<<<<<<<<<
 * 
 * cdef inline void _pushSaxEndEvent(_IterparseContext context,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.__pyx_base._store_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context));
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L7_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._pushSaxStartEvent");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":218
 *         context._store_raised()
 * 
 * cdef inline void _pushSaxEndEvent(_IterparseContext context,             # <<<<<<<<<<<<<<
 *                                   xmlNode* c_node):
 *     try:
 */

static INLINE void __pyx_f_4lxml_5etree__pushSaxEndEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context, xmlNode *__pyx_v_c_node) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":220
 * cdef inline void _pushSaxEndEvent(_IterparseContext context,
 *                                   xmlNode* c_node):
 *     try:             # <<<<<<<<<<<<<<
 *         context.endNode(c_node)
 *     except:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":221
 *                                   xmlNode* c_node):
 *     try:
 *         context.endNode(c_node)             # <<<<<<<<<<<<<<
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->endNode(__pyx_v_context, __pyx_v_c_node); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L7_try;
    __pyx_L3_error:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":222
 *     try:
 *         context.endNode(c_node)
 *     except:             # <<<<<<<<<<<<<<
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._pushSaxEndEvent");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":223
 *         context.endNode(c_node)
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:             # <<<<<<<<<<<<<<
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1
 */
      __pyx_5 = (__pyx_v_context->__pyx_base._c_ctxt->errNo == XML_ERR_OK);
      if (__pyx_5) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":224
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR             # <<<<<<<<<<<<<<
 *         context._c_ctxt.disableSAX = 1
 *         context._store_raised()
 */
        __pyx_v_context->__pyx_base._c_ctxt->errNo = XML_ERR_INTERNAL_ERROR;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":225
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1             # <<<<<<<<<<<<<<
 *         context._store_raised()
 * 
 */
      __pyx_v_context->__pyx_base._c_ctxt->disableSAX = 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":226
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1
 *         context._store_raised()             # <<<<<<<<<<<<<<
 * 
 * cdef inline void _pushSaxEvent(_IterparseContext context,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.__pyx_base._store_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context));
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L7_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._pushSaxEndEvent");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":228
 *         context._store_raised()
 * 
 * cdef inline void _pushSaxEvent(_IterparseContext context,             # <<<<<<<<<<<<<<
 *                                event, xmlNode* c_node):
 *     try:
 */

static INLINE void __pyx_f_4lxml_5etree__pushSaxEvent(struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context, PyObject *__pyx_v_event, xmlNode *__pyx_v_c_node) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":230
 * cdef inline void _pushSaxEvent(_IterparseContext context,
 *                                event, xmlNode* c_node):
 *     try:             # <<<<<<<<<<<<<<
 *         context.pushEvent(event, c_node)
 *     except:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":231
 *                                event, xmlNode* c_node):
 *     try:
 *         context.pushEvent(event, c_node)             # <<<<<<<<<<<<<<
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->pushEvent(__pyx_v_context, __pyx_v_event, __pyx_v_c_node); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L7_try;
    __pyx_L3_error:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":232
 *     try:
 *         context.pushEvent(event, c_node)
 *     except:             # <<<<<<<<<<<<<<
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._pushSaxEvent");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":233
 *         context.pushEvent(event, c_node)
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:             # <<<<<<<<<<<<<<
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1
 */
      __pyx_5 = (__pyx_v_context->__pyx_base._c_ctxt->errNo == XML_ERR_OK);
      if (__pyx_5) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":234
 *     except:
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR             # <<<<<<<<<<<<<<
 *         context._c_ctxt.disableSAX = 1
 *         context._store_raised()
 */
        __pyx_v_context->__pyx_base._c_ctxt->errNo = XML_ERR_INTERNAL_ERROR;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":235
 *         if context._c_ctxt.errNo == xmlerror.XML_ERR_OK:
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1             # <<<<<<<<<<<<<<
 *         context._store_raised()
 * 
 */
      __pyx_v_context->__pyx_base._c_ctxt->disableSAX = 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":236
 *             context._c_ctxt.errNo = xmlerror.XML_ERR_INTERNAL_ERROR
 *         context._c_ctxt.disableSAX = 1
 *         context._store_raised()             # <<<<<<<<<<<<<<
 * 
 * cdef void _iterparseSaxStart(void* ctxt, char* localname, char* prefix,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.__pyx_base._store_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context));
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L7_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._pushSaxEvent");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":238
 *         context._store_raised()
 * 
 * cdef void _iterparseSaxStart(void* ctxt, char* localname, char* prefix,             # <<<<<<<<<<<<<<
 *                              char* URI, int nb_namespaces, char** namespaces,
 *                              int nb_attributes, int nb_defaulted,
 */

static  void __pyx_f_4lxml_5etree__iterparseSaxStart(void *__pyx_v_ctxt, char *__pyx_v_localname, char *__pyx_v_prefix, char *__pyx_v_URI, int __pyx_v_nb_namespaces, char **__pyx_v_namespaces, int __pyx_v_nb_attributes, int __pyx_v_nb_defaulted, char **__pyx_v_attributes) {
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":244
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxStart(
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":245
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     context._origSaxStart(
 *         ctxt, localname, prefix, URI,
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":249
 *         ctxt, localname, prefix, URI,
 *         nb_namespaces, namespaces,
 *         nb_attributes, nb_defaulted, attributes)             # <<<<<<<<<<<<<<
 *     _pushSaxStartEvent(context, c_ctxt.node)
 * 
 */
  __pyx_v_context->_origSaxStart(__pyx_v_ctxt, __pyx_v_localname, __pyx_v_prefix, __pyx_v_URI, __pyx_v_nb_namespaces, __pyx_v_namespaces, __pyx_v_nb_attributes, __pyx_v_nb_defaulted, __pyx_v_attributes);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":250
 *         nb_namespaces, namespaces,
 *         nb_attributes, nb_defaulted, attributes)
 *     _pushSaxStartEvent(context, c_ctxt.node)             # <<<<<<<<<<<<<<
 * 
 * cdef void _iterparseSaxEnd(void* ctxt, char* localname, char* prefix, char* URI):
 */
  __pyx_f_4lxml_5etree__pushSaxStartEvent(__pyx_v_context, __pyx_v_c_ctxt->node);

  Py_DECREF((PyObject *)__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":252
 *     _pushSaxStartEvent(context, c_ctxt.node)
 * 
 * cdef void _iterparseSaxEnd(void* ctxt, char* localname, char* prefix, char* URI):             # <<<<<<<<<<<<<<
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 */

static  void __pyx_f_4lxml_5etree__iterparseSaxEnd(void *__pyx_v_ctxt, char *__pyx_v_localname, char *__pyx_v_prefix, char *__pyx_v_URI) {
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":255
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     context = <_IterparseContext>c_ctxt._private
 *     _pushSaxEndEvent(context, c_ctxt.node)
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":256
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     _pushSaxEndEvent(context, c_ctxt.node)
 *     context._origSaxEnd(ctxt, localname, prefix, URI)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":257
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private
 *     _pushSaxEndEvent(context, c_ctxt.node)             # <<<<<<<<<<<<<<
 *     context._origSaxEnd(ctxt, localname, prefix, URI)
 * 
 */
  __pyx_f_4lxml_5etree__pushSaxEndEvent(__pyx_v_context, __pyx_v_c_ctxt->node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":258
 *     context = <_IterparseContext>c_ctxt._private
 *     _pushSaxEndEvent(context, c_ctxt.node)
 *     context._origSaxEnd(ctxt, localname, prefix, URI)             # <<<<<<<<<<<<<<
 * 
 * cdef void _iterparseSaxStartNoNs(void* ctxt, char* name, char** attributes):
 */
  __pyx_v_context->_origSaxEnd(__pyx_v_ctxt, __pyx_v_localname, __pyx_v_prefix, __pyx_v_URI);

  Py_DECREF((PyObject *)__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":260
 *     context._origSaxEnd(ctxt, localname, prefix, URI)
 * 
 * cdef void _iterparseSaxStartNoNs(void* ctxt, char* name, char** attributes):             # <<<<<<<<<<<<<<
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 */

static  void __pyx_f_4lxml_5etree__iterparseSaxStartNoNs(void *__pyx_v_ctxt, char *__pyx_v_name, char **__pyx_v_attributes) {
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":263
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxStartNoNs(ctxt, name, attributes)
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":264
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     context._origSaxStartNoNs(ctxt, name, attributes)
 *     _pushSaxStartEvent(context, c_ctxt.node)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":265
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxStartNoNs(ctxt, name, attributes)             # <<<<<<<<<<<<<<
 *     _pushSaxStartEvent(context, c_ctxt.node)
 * 
 */
  __pyx_v_context->_origSaxStartNoNs(__pyx_v_ctxt, __pyx_v_name, __pyx_v_attributes);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":266
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxStartNoNs(ctxt, name, attributes)
 *     _pushSaxStartEvent(context, c_ctxt.node)             # <<<<<<<<<<<<<<
 * 
 * cdef void _iterparseSaxEndNoNs(void* ctxt, char* name):
 */
  __pyx_f_4lxml_5etree__pushSaxStartEvent(__pyx_v_context, __pyx_v_c_ctxt->node);

  Py_DECREF((PyObject *)__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":268
 *     _pushSaxStartEvent(context, c_ctxt.node)
 * 
 * cdef void _iterparseSaxEndNoNs(void* ctxt, char* name):             # <<<<<<<<<<<<<<
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 */

static  void __pyx_f_4lxml_5etree__iterparseSaxEndNoNs(void *__pyx_v_ctxt, char *__pyx_v_name) {
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":271
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     context = <_IterparseContext>c_ctxt._private
 *     _pushSaxEndEvent(context, c_ctxt.node)
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":272
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     _pushSaxEndEvent(context, c_ctxt.node)
 *     context._origSaxEndNoNs(ctxt, name)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":273
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private
 *     _pushSaxEndEvent(context, c_ctxt.node)             # <<<<<<<<<<<<<<
 *     context._origSaxEndNoNs(ctxt, name)
 * 
 */
  __pyx_f_4lxml_5etree__pushSaxEndEvent(__pyx_v_context, __pyx_v_c_ctxt->node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":274
 *     context = <_IterparseContext>c_ctxt._private
 *     _pushSaxEndEvent(context, c_ctxt.node)
 *     context._origSaxEndNoNs(ctxt, name)             # <<<<<<<<<<<<<<
 * 
 * cdef void _iterparseSaxComment(void* ctxt, char* text):
 */
  __pyx_v_context->_origSaxEndNoNs(__pyx_v_ctxt, __pyx_v_name);

  Py_DECREF((PyObject *)__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":276
 *     context._origSaxEndNoNs(ctxt, name)
 * 
 * cdef void _iterparseSaxComment(void* ctxt, char* text):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__iterparseSaxComment(void *__pyx_v_ctxt, char *__pyx_v_text) {
  xmlNode *__pyx_v_c_node;
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  int __pyx_1;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":280
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxComment(ctxt, text)
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":281
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     context._origSaxComment(ctxt, text)
 *     c_node = _iterparseFindLastNode(c_ctxt)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":282
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxComment(ctxt, text)             # <<<<<<<<<<<<<<
 *     c_node = _iterparseFindLastNode(c_ctxt)
 *     if c_node is not NULL:
 */
  __pyx_v_context->_origSaxComment(__pyx_v_ctxt, __pyx_v_text);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":283
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxComment(ctxt, text)
 *     c_node = _iterparseFindLastNode(c_ctxt)             # <<<<<<<<<<<<<<
 *     if c_node is not NULL:
 *         _pushSaxEvent(context, u"comment", c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__iterparseFindLastNode(__pyx_v_c_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":284
 *     context._origSaxComment(ctxt, text)
 *     c_node = _iterparseFindLastNode(c_ctxt)
 *     if c_node is not NULL:             # <<<<<<<<<<<<<<
 *         _pushSaxEvent(context, u"comment", c_node)
 * 
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":285
 *     c_node = _iterparseFindLastNode(c_ctxt)
 *     if c_node is not NULL:
 *         _pushSaxEvent(context, u"comment", c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef void _iterparseSaxPI(void* ctxt, char* target, char* data):
 */
    __pyx_f_4lxml_5etree__pushSaxEvent(__pyx_v_context, ((PyObject *)__pyx_kp_504), __pyx_v_c_node);
    goto __pyx_L3;
  }
  __pyx_L3:;

  Py_DECREF((PyObject *)__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":287
 *         _pushSaxEvent(context, u"comment", c_node)
 * 
 * cdef void _iterparseSaxPI(void* ctxt, char* target, char* data):             # <<<<<<<<<<<<<<
 *     cdef xmlNode* c_node
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 */

static  void __pyx_f_4lxml_5etree__iterparseSaxPI(void *__pyx_v_ctxt, char *__pyx_v_target, char *__pyx_v_data) {
  xmlNode *__pyx_v_c_node;
  xmlParserCtxt *__pyx_v_c_ctxt;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  int __pyx_1;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":291
 *     cdef xmlparser.xmlParserCtxt* c_ctxt
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt             # <<<<<<<<<<<<<<
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxPI(ctxt, target, data)
 */
  __pyx_v_c_ctxt = ((xmlParserCtxt *)__pyx_v_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":292
 *     cdef _IterparseContext context
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private             # <<<<<<<<<<<<<<
 *     context._origSaxPI(ctxt, target, data)
 *     c_node = _iterparseFindLastNode(c_ctxt)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_v_c_ctxt->_private);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":293
 *     c_ctxt = <xmlparser.xmlParserCtxt*>ctxt
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxPI(ctxt, target, data)             # <<<<<<<<<<<<<<
 *     c_node = _iterparseFindLastNode(c_ctxt)
 *     if c_node is not NULL:
 */
  __pyx_v_context->_origSaxPI(__pyx_v_ctxt, __pyx_v_target, __pyx_v_data);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":294
 *     context = <_IterparseContext>c_ctxt._private
 *     context._origSaxPI(ctxt, target, data)
 *     c_node = _iterparseFindLastNode(c_ctxt)             # <<<<<<<<<<<<<<
 *     if c_node is not NULL:
 *         _pushSaxEvent(context, u"pi", c_node)
 */
  __pyx_v_c_node = __pyx_f_4lxml_5etree__iterparseFindLastNode(__pyx_v_c_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":295
 *     context._origSaxPI(ctxt, target, data)
 *     c_node = _iterparseFindLastNode(c_ctxt)
 *     if c_node is not NULL:             # <<<<<<<<<<<<<<
 *         _pushSaxEvent(context, u"pi", c_node)
 * 
 */
  __pyx_1 = (__pyx_v_c_node != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":296
 *     c_node = _iterparseFindLastNode(c_ctxt)
 *     if c_node is not NULL:
 *         _pushSaxEvent(context, u"pi", c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef inline xmlNode* _iterparseFindLastNode(xmlparser.xmlParserCtxt* c_ctxt):
 */
    __pyx_f_4lxml_5etree__pushSaxEvent(__pyx_v_context, ((PyObject *)__pyx_kp_505), __pyx_v_c_node);
    goto __pyx_L3;
  }
  __pyx_L3:;

  Py_DECREF((PyObject *)__pyx_v_context);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":298
 *         _pushSaxEvent(context, u"pi", c_node)
 * 
 * cdef inline xmlNode* _iterparseFindLastNode(xmlparser.xmlParserCtxt* c_ctxt):             # <<<<<<<<<<<<<<
 *     # this mimics what libxml2 creates for comments/PIs
 *     if c_ctxt.inSubset == 1:
 */

static INLINE xmlNode *__pyx_f_4lxml_5etree__iterparseFindLastNode(xmlParserCtxt *__pyx_v_c_ctxt) {
  xmlNode *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":300
 * cdef inline xmlNode* _iterparseFindLastNode(xmlparser.xmlParserCtxt* c_ctxt):
 *     # this mimics what libxml2 creates for comments/PIs
 *     if c_ctxt.inSubset == 1:             # <<<<<<<<<<<<<<
 *         return c_ctxt.myDoc.intSubset.last
 *     elif c_ctxt.inSubset == 2:
 */
  __pyx_1 = (__pyx_v_c_ctxt->inSubset == 1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":301
 *     # this mimics what libxml2 creates for comments/PIs
 *     if c_ctxt.inSubset == 1:
 *         return c_ctxt.myDoc.intSubset.last             # <<<<<<<<<<<<<<
 *     elif c_ctxt.inSubset == 2:
 *         return c_ctxt.myDoc.extSubset.last
 */
    __pyx_r = __pyx_v_c_ctxt->myDoc->intSubset->last;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":302
 *     if c_ctxt.inSubset == 1:
 *         return c_ctxt.myDoc.intSubset.last
 *     elif c_ctxt.inSubset == 2:             # <<<<<<<<<<<<<<
 *         return c_ctxt.myDoc.extSubset.last
 *     elif c_ctxt.node is NULL:
 */
  __pyx_1 = (__pyx_v_c_ctxt->inSubset == 2);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":303
 *         return c_ctxt.myDoc.intSubset.last
 *     elif c_ctxt.inSubset == 2:
 *         return c_ctxt.myDoc.extSubset.last             # <<<<<<<<<<<<<<
 *     elif c_ctxt.node is NULL:
 *         return c_ctxt.myDoc.last
 */
    __pyx_r = __pyx_v_c_ctxt->myDoc->extSubset->last;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":304
 *     elif c_ctxt.inSubset == 2:
 *         return c_ctxt.myDoc.extSubset.last
 *     elif c_ctxt.node is NULL:             # <<<<<<<<<<<<<<
 *         return c_ctxt.myDoc.last
 *     elif c_ctxt.node.type == tree.XML_ELEMENT_NODE:
 */
  __pyx_1 = (__pyx_v_c_ctxt->node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":305
 *         return c_ctxt.myDoc.extSubset.last
 *     elif c_ctxt.node is NULL:
 *         return c_ctxt.myDoc.last             # <<<<<<<<<<<<<<
 *     elif c_ctxt.node.type == tree.XML_ELEMENT_NODE:
 *         return c_ctxt.node.last
 */
    __pyx_r = __pyx_v_c_ctxt->myDoc->last;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":306
 *     elif c_ctxt.node is NULL:
 *         return c_ctxt.myDoc.last
 *     elif c_ctxt.node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *         return c_ctxt.node.last
 *     else:
 */
  __pyx_1 = (__pyx_v_c_ctxt->node->type == XML_ELEMENT_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":307
 *         return c_ctxt.myDoc.last
 *     elif c_ctxt.node.type == tree.XML_ELEMENT_NODE:
 *         return c_ctxt.node.last             # <<<<<<<<<<<<<<
 *     else:
 *         return c_ctxt.node.next
 */
    __pyx_r = __pyx_v_c_ctxt->node->last;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":309
 *         return c_ctxt.node.last
 *     else:
 *         return c_ctxt.node.next             # <<<<<<<<<<<<<<
 * 
 * cdef class iterparse(_BaseParser):
 */
    __pyx_r = __pyx_v_c_ctxt->node->next;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":361
 *     cdef int (*_parse_chunk)(xmlparser.xmlParserCtxt* ctxt,
 *                              char* chunk, int size, int terminate) nogil
 *     def __init__(self, source, events=(u"end",), *, tag=None,             # <<<<<<<<<<<<<<
 *                  attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, remove_blank_text=False,
 */

static int __pyx_pf_4lxml_5etree_9iterparse___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_9iterparse___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_events = 0;
  PyObject *__pyx_v_tag = 0;
  PyObject *__pyx_v_attribute_defaults = 0;
  PyObject *__pyx_v_dtd_validation = 0;
  PyObject *__pyx_v_load_dtd = 0;
  PyObject *__pyx_v_no_network = 0;
  PyObject *__pyx_v_remove_blank_text = 0;
  PyObject *__pyx_v_compact = 0;
  PyObject *__pyx_v_resolve_entities = 0;
  PyObject *__pyx_v_remove_comments = 0;
  PyObject *__pyx_v_remove_pis = 0;
  PyObject *__pyx_v_strip_cdata = 0;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_html = 0;
  struct __pyx_obj_4lxml_5etree_XMLSchema *__pyx_v_schema = 0;
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  int __pyx_v_parse_options;
  PyObject *__pyx_v_filename;
  PyObject *__pyx_v_error;
  PyObject *__pyx_v_event;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_source,&__pyx_kp_events,&__pyx_kp_tag,&__pyx_kp_attribute_defaults,&__pyx_kp_dtd_validation,&__pyx_kp_load_dtd,&__pyx_kp_no_network,&__pyx_kp_remove_blank_text,&__pyx_kp_compact,&__pyx_kp_resolve_entities,&__pyx_kp_remove_comments,&__pyx_kp_remove_pis,&__pyx_kp_strip_cdata,&__pyx_kp_encoding,&__pyx_kp_html,&__pyx_kp_schema,0};
  __pyx_v_events = __pyx_k_145;
  __pyx_v_tag = Py_None;
  __pyx_v_attribute_defaults = __pyx_k_146;
  __pyx_v_dtd_validation = __pyx_k_147;
  __pyx_v_load_dtd = __pyx_k_148;
  __pyx_v_no_network = __pyx_k_149;
  __pyx_v_remove_blank_text = __pyx_k_150;
  __pyx_v_compact = __pyx_k_151;
  __pyx_v_resolve_entities = __pyx_k_152;
  __pyx_v_remove_comments = __pyx_k_153;
  __pyx_v_remove_pis = __pyx_k_154;
  __pyx_v_strip_cdata = __pyx_k_155;
  __pyx_v_encoding = Py_None;
  __pyx_v_html = __pyx_k_156;
  __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_source);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_source = values[0];
    if (values[1]) {
      __pyx_v_events = values[1];
    }
    if (values[2]) {
      __pyx_v_tag = values[2];
    }
    if (values[3]) {
      __pyx_v_attribute_defaults = values[3];
    }
    if (values[4]) {
      __pyx_v_dtd_validation = values[4];
    }
    if (values[5]) {
      __pyx_v_load_dtd = values[5];
    }
    if (values[6]) {
      __pyx_v_no_network = values[6];
    }
    if (values[7]) {
      __pyx_v_remove_blank_text = values[7];
    }
    if (values[8]) {
      __pyx_v_compact = values[8];
    }
    if (values[9]) {
      __pyx_v_resolve_entities = values[9];
    }
    if (values[10]) {
      __pyx_v_remove_comments = values[10];
    }
    if (values[11]) {
      __pyx_v_remove_pis = values[11];
    }
    if (values[12]) {
      __pyx_v_strip_cdata = values[12];
    }
    if (values[13]) {
      __pyx_v_encoding = values[13];
    }
    if (values[14]) {
      __pyx_v_html = values[14];
    }
    if (values[15]) {
      __pyx_v_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)values[15]);
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_events = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_source = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[14]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.iterparse.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_source);
  Py_INCREF(__pyx_v_events);
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filename = Py_None; Py_INCREF(Py_None);
  __pyx_v_error = Py_None; Py_INCREF(Py_None);
  __pyx_v_event = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), __pyx_ptype_4lxml_5etree_XMLSchema, 1, "schema", 0))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":370
 *         cdef char* c_encoding
 *         cdef int parse_options
 *         if not hasattr(source, u'read'):             # <<<<<<<<<<<<<<
 *             filename = _encodeFilename(source)
 *             if not python.IS_PYTHON3:
 */
  __pyx_1 = PyObject_HasAttr(__pyx_v_source, ((PyObject *)__pyx_kp_506)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":371
 *         cdef int parse_options
 *         if not hasattr(source, u'read'):
 *             filename = _encodeFilename(source)             # <<<<<<<<<<<<<<
 *             if not python.IS_PYTHON3:
 *                 source = filename
 */
    __pyx_3 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_source); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_filename);
    __pyx_v_filename = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":372
 *         if not hasattr(source, u'read'):
 *             filename = _encodeFilename(source)
 *             if not python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *                 source = filename
 *             source = open(source, u'rb')
 */
    __pyx_1 = (!IS_PYTHON3);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":373
 *             filename = _encodeFilename(source)
 *             if not python.IS_PYTHON3:
 *                 source = filename             # <<<<<<<<<<<<<<
 *             source = open(source, u'rb')
 *         else:
 */
      Py_INCREF(__pyx_v_filename);
      Py_DECREF(__pyx_v_source);
      __pyx_v_source = __pyx_v_filename;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":374
 *             if not python.IS_PYTHON3:
 *                 source = filename
 *             source = open(source, u'rb')             # <<<<<<<<<<<<<<
 *         else:
 *             filename = _encodeFilename(_getFilenameForFile(source))
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_source);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_source);
    Py_INCREF(((PyObject *)__pyx_kp_507));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_kp_507));
    __pyx_4 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_v_source);
    __pyx_v_source = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":376
 *             source = open(source, u'rb')
 *         else:
 *             filename = _encodeFilename(_getFilenameForFile(source))             # <<<<<<<<<<<<<<
 * 
 *         self._source = source
 */
    __pyx_3 = __pyx_f_4lxml_5etree__getFilenameForFile(__pyx_v_source); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_filename);
    __pyx_v_filename = __pyx_4;
    __pyx_4 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":378
 *             filename = _encodeFilename(_getFilenameForFile(source))
 * 
 *         self._source = source             # <<<<<<<<<<<<<<
 *         if html:
 *             # make sure we're not looking for namespaces
 */
  Py_INCREF(__pyx_v_source);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source);
  ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source = __pyx_v_source;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":379
 * 
 *         self._source = source
 *         if html:             # <<<<<<<<<<<<<<
 *             # make sure we're not looking for namespaces
 *             events = tuple([ event for event in events
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_html); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":381
 *         if html:
 *             # make sure we're not looking for namespaces
 *             events = tuple([ event for event in events             # <<<<<<<<<<<<<<
 *                              if event != u'start-ns' and event != u'end-ns' ])
 * 
 */
    __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":382
 *             # make sure we're not looking for namespaces
 *             events = tuple([ event for event in events
 *                              if event != u'start-ns' and event != u'end-ns' ])             # <<<<<<<<<<<<<<
 * 
 *         self._events = events
 */
    if (PyList_CheckExact(__pyx_v_events) || PyTuple_CheckExact(__pyx_v_events)) {
      __pyx_5 = 0; __pyx_4 = __pyx_v_events; Py_INCREF(__pyx_4);
    } else {
      __pyx_5 = -1; __pyx_4 = PyObject_GetIter(__pyx_v_events); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":381
 *         if html:
 *             # make sure we're not looking for namespaces
 *             events = tuple([ event for event in events             # <<<<<<<<<<<<<<
 *                              if event != u'start-ns' and event != u'end-ns' ])
 * 
 */
      if (likely(PyList_CheckExact(__pyx_4))) {
        if (__pyx_5 >= PyList_GET_SIZE(__pyx_4)) break;
        __pyx_6 = PyList_GET_ITEM(__pyx_4, __pyx_5); Py_INCREF(__pyx_6); __pyx_5++;
      } else if (likely(PyTuple_CheckExact(__pyx_4))) {
        if (__pyx_5 >= PyTuple_GET_SIZE(__pyx_4)) break;
        __pyx_6 = PyTuple_GET_ITEM(__pyx_4, __pyx_5); Py_INCREF(__pyx_6); __pyx_5++;
      } else {
        __pyx_6 = PyIter_Next(__pyx_4);
        if (!__pyx_6) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_event);
      __pyx_v_event = __pyx_6;
      __pyx_6 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":382
 *             # make sure we're not looking for namespaces
 *             events = tuple([ event for event in events
 *                              if event != u'start-ns' and event != u'end-ns' ])             # <<<<<<<<<<<<<<
 * 
 *         self._events = events
 */
      __pyx_6 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_508), Py_NE); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      if (__pyx_1) {
        __pyx_6 = PyObject_RichCompare(__pyx_v_event, ((PyObject *)__pyx_kp_509), Py_NE); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
      }
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":381
 *         if html:
 *             # make sure we're not looking for namespaces
 *             events = tuple([ event for event in events             # <<<<<<<<<<<<<<
 *                              if event != u'start-ns' and event != u'end-ns' ])
 * 
 */
        __pyx_7 = PyList_Append(__pyx_3, (PyObject*)__pyx_v_event); if (unlikely(__pyx_7)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L11;
      }
      __pyx_L11:;
    }
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)__pyx_3));
    __pyx_3 = 0;
    __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)&PyTuple_Type)), ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
    Py_DECREF(__pyx_v_events);
    __pyx_v_events = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":384
 *                              if event != u'start-ns' and event != u'end-ns' ])
 * 
 *         self._events = events             # <<<<<<<<<<<<<<
 *         self._tag = tag
 * 
 */
  Py_INCREF(__pyx_v_events);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_events);
  ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_events = __pyx_v_events;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":385
 * 
 *         self._events = events
 *         self._tag = tag             # <<<<<<<<<<<<<<
 * 
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS
 */
  Py_INCREF(__pyx_v_tag);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_tag);
  ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_tag = __pyx_v_tag;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":387
 *         self._tag = tag
 * 
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS             # <<<<<<<<<<<<<<
 *         if load_dtd:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD
 */
  __pyx_v_parse_options = __pyx_v_4lxml_5etree__XML_DEFAULT_PARSE_OPTIONS;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":388
 * 
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS
 *         if load_dtd:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD
 *         if dtd_validation:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_load_dtd); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":389
 *         parse_options = _XML_DEFAULT_PARSE_OPTIONS
 *         if load_dtd:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD             # <<<<<<<<<<<<<<
 *         if dtd_validation:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | XML_PARSE_DTDLOAD);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":390
 *         if load_dtd:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDLOAD
 *         if dtd_validation:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_dtd_validation); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":392
 *         if dtd_validation:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 *                             xmlparser.XML_PARSE_DTDLOAD             # <<<<<<<<<<<<<<
 *         if attribute_defaults:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 */
    __pyx_v_parse_options = ((__pyx_v_parse_options | XML_PARSE_DTDVALID) | XML_PARSE_DTDLOAD);
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":393
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDVALID | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 *         if attribute_defaults:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_attribute_defaults); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":395
 *         if attribute_defaults:
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 *                             xmlparser.XML_PARSE_DTDLOAD             # <<<<<<<<<<<<<<
 *         if remove_blank_text:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 */
    __pyx_v_parse_options = ((__pyx_v_parse_options | XML_PARSE_DTDATTR) | XML_PARSE_DTDLOAD);
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":396
 *             parse_options = parse_options | xmlparser.XML_PARSE_DTDATTR | \
 *                             xmlparser.XML_PARSE_DTDLOAD
 *         if remove_blank_text:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 *         if not no_network:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_remove_blank_text); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":397
 *                             xmlparser.XML_PARSE_DTDLOAD
 *         if remove_blank_text:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS             # <<<<<<<<<<<<<<
 *         if not no_network:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 */
    __pyx_v_parse_options = (__pyx_v_parse_options | XML_PARSE_NOBLANKS);
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":398
 *         if remove_blank_text:
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 *         if not no_network:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 *         if not compact:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_no_network); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":399
 *             parse_options = parse_options | xmlparser.XML_PARSE_NOBLANKS
 *         if not no_network:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET             # <<<<<<<<<<<<<<
 *         if not compact:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_NONET);
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":400
 *         if not no_network:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 *         if not compact:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 *         if not resolve_entities:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_compact); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":401
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NONET
 *         if not compact:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT             # <<<<<<<<<<<<<<
 *         if not resolve_entities:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_COMPACT);
    goto __pyx_L17;
  }
  __pyx_L17:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":402
 *         if not compact:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 *         if not resolve_entities:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 *         if not strip_cdata:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_resolve_entities); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":403
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_COMPACT
 *         if not resolve_entities:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT             # <<<<<<<<<<<<<<
 *         if not strip_cdata:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_NOENT);
    goto __pyx_L18;
  }
  __pyx_L18:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":404
 *         if not resolve_entities:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 *         if not strip_cdata:             # <<<<<<<<<<<<<<
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA
 * 
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_strip_cdata); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":405
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOENT
 *         if not strip_cdata:
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA             # <<<<<<<<<<<<<<
 * 
 *         _BaseParser.__init__(self, parse_options, html, schema,
 */
    __pyx_v_parse_options = (__pyx_v_parse_options ^ XML_PARSE_NOCDATA);
    goto __pyx_L19;
  }
  __pyx_L19:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":407
 *             parse_options = parse_options ^ xmlparser.XML_PARSE_NOCDATA
 * 
 *         _BaseParser.__init__(self, parse_options, html, schema,             # <<<<<<<<<<<<<<
 *                              remove_comments, remove_pis, strip_cdata,
 *                              None, filename, encoding)
 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseParser)), __pyx_kp___init__); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_6 = PyInt_FromLong(__pyx_v_parse_options); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":409
 *         _BaseParser.__init__(self, parse_options, html, schema,
 *                              remove_comments, remove_pis, strip_cdata,
 *                              None, filename, encoding)             # <<<<<<<<<<<<<<
 * 
 *         if self._for_html:
 */
  __pyx_4 = PyTuple_New(10); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_6);
  Py_INCREF(__pyx_v_html);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_html);
  Py_INCREF(((PyObject *)__pyx_v_schema));
  PyTuple_SET_ITEM(__pyx_4, 3, ((PyObject *)__pyx_v_schema));
  Py_INCREF(__pyx_v_remove_comments);
  PyTuple_SET_ITEM(__pyx_4, 4, __pyx_v_remove_comments);
  Py_INCREF(__pyx_v_remove_pis);
  PyTuple_SET_ITEM(__pyx_4, 5, __pyx_v_remove_pis);
  Py_INCREF(__pyx_v_strip_cdata);
  PyTuple_SET_ITEM(__pyx_4, 6, __pyx_v_strip_cdata);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_4, 7, Py_None);
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_4, 8, __pyx_v_filename);
  Py_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_4, 9, __pyx_v_encoding);
  __pyx_6 = 0;
  __pyx_6 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":411
 *                              None, filename, encoding)
 * 
 *         if self._for_html:             # <<<<<<<<<<<<<<
 *             self._parse_chunk = htmlparser.htmlParseChunk
 *         else:
 */
  __pyx_2 = ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._for_html;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":412
 * 
 *         if self._for_html:
 *             self._parse_chunk = htmlparser.htmlParseChunk             # <<<<<<<<<<<<<<
 *         else:
 *             self._parse_chunk = xmlparser.xmlParseChunk
 */
    ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_parse_chunk = htmlParseChunk;
    goto __pyx_L20;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":414
 *             self._parse_chunk = htmlparser.htmlParseChunk
 *         else:
 *             self._parse_chunk = xmlparser.xmlParseChunk             # <<<<<<<<<<<<<<
 * 
 *         context = <_IterparseContext>self._getPushParserContext()
 */
    ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_parse_chunk = xmlParseChunk;
  }
  __pyx_L20:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":416
 *             self._parse_chunk = xmlparser.xmlParseChunk
 * 
 *         context = <_IterparseContext>self._getPushParserContext()             # <<<<<<<<<<<<<<
 *         __GLOBAL_PARSER_CONTEXT.initParserDict(context._c_ctxt)
 * 
 */
  __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_iterparse *)((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._getPushParserContext(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_3)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_3);
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":417
 * 
 *         context = <_IterparseContext>self._getPushParserContext()
 *         __GLOBAL_PARSER_CONTEXT.initParserDict(context._c_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         if self._default_encoding is not None:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_context->__pyx_base._c_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":419
 *         __GLOBAL_PARSER_CONTEXT.initParserDict(context._c_ctxt)
 * 
 *         if self._default_encoding is not None:             # <<<<<<<<<<<<<<
 *             if self._for_html:
 *                 error = _htmlCtxtResetPush(
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._default_encoding != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":420
 * 
 *         if self._default_encoding is not None:
 *             if self._for_html:             # <<<<<<<<<<<<<<
 *                 error = _htmlCtxtResetPush(
 *                     context._c_ctxt, NULL, 0,
 */
    __pyx_2 = ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._for_html;
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":423
 *                 error = _htmlCtxtResetPush(
 *                     context._c_ctxt, NULL, 0,
 *                     _cstr(self._default_encoding), self._parse_options)             # <<<<<<<<<<<<<<
 *             else:
 *                 xmlparser.xmlCtxtUseOptions(
 */
      __pyx_7 = __pyx_f_4lxml_5etree__htmlCtxtResetPush(__pyx_v_context->__pyx_base._c_ctxt, NULL, 0, PyString_AS_STRING(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._default_encoding), ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._parse_options); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyInt_FromLong(__pyx_7); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_error);
      __pyx_v_error = __pyx_4;
      __pyx_4 = 0;
      goto __pyx_L22;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":426
 *             else:
 *                 xmlparser.xmlCtxtUseOptions(
 *                     context._c_ctxt, self._parse_options)             # <<<<<<<<<<<<<<
 *                 error = xmlparser.xmlCtxtResetPush(
 *                     context._c_ctxt, NULL, 0, NULL,
 */
      xmlCtxtUseOptions(__pyx_v_context->__pyx_base._c_ctxt, ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._parse_options);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":429
 *                 error = xmlparser.xmlCtxtResetPush(
 *                     context._c_ctxt, NULL, 0, NULL,
 *                     _cstr(self._default_encoding))             # <<<<<<<<<<<<<<
 * 
 *         context.prepare()
 */
      __pyx_6 = PyInt_FromLong(xmlCtxtResetPush(__pyx_v_context->__pyx_base._c_ctxt, NULL, 0, NULL, PyString_AS_STRING(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._default_encoding))); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_error);
      __pyx_v_error = __pyx_6;
      __pyx_6 = 0;
    }
    __pyx_L22:;
    goto __pyx_L21;
  }
  __pyx_L21:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":431
 *                     _cstr(self._default_encoding))
 * 
 *         context.prepare()             # <<<<<<<<<<<<<<
 *         # parser will not be unlocked - no other methods supported
 * 
 */
  __pyx_7 = ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.prepare(((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_context)); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree.iterparse.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_filename);
  Py_DECREF(__pyx_v_error);
  Py_DECREF(__pyx_v_event);
  Py_DECREF(__pyx_v_source);
  Py_DECREF(__pyx_v_events);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":437
 *         u"""The error log of the last (or current) parser run.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _ParserContext context
 *             context = self._getPushParserContext()
 */

static PyObject *__pyx_pf_4lxml_5etree_9iterparse_9error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9iterparse_9error_log___get__(PyObject *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_v_context;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":439
 *         def __get__(self):
 *             cdef _ParserContext context
 *             context = self._getPushParserContext()             # <<<<<<<<<<<<<<
 *             return context._error_log.copy()
 * 
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_iterparse *)((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._getPushParserContext(((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":440
 *             cdef _ParserContext context
 *             context = self._getPushParserContext()
 *             return context._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserContext _createContext(self, target):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_context->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.iterparse.error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":442
 *             return context._error_log.copy()
 * 
 *     cdef _ParserContext _createContext(self, target):             # <<<<<<<<<<<<<<
 *         cdef _IterparseContext context
 *         context = _IterparseContext()
 */

static  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_f_4lxml_5etree_9iterparse__createContext(struct __pyx_obj_4lxml_5etree_iterparse *__pyx_v_self, PyObject *__pyx_v_target) {
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ParserContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":444
 *     cdef _ParserContext _createContext(self, target):
 *         cdef _IterparseContext context
 *         context = _IterparseContext()             # <<<<<<<<<<<<<<
 *         context._setEventFilter(self._events, self._tag)
 *         return context
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__IterparseContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__IterparseContext))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":445
 *         cdef _IterparseContext context
 *         context = _IterparseContext()
 *         context._setEventFilter(self._events, self._tag)             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_setEventFilter(__pyx_v_context, __pyx_v_self->_events, __pyx_v_self->_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":446
 *         context = _IterparseContext()
 *         context._setEventFilter(self._events, self._tag)
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)__pyx_v_context);
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.iterparse._createContext");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":448
 *         return context
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         raise TypeError, u"iterparse parsers cannot be copied"
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_9iterparse_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9iterparse_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":449
 * 
 *     def copy(self):
 *         raise TypeError, u"iterparse parsers cannot be copied"             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_510), 0);
  {__pyx_filename = __pyx_f[14]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.iterparse.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":451
 *         raise TypeError, u"iterparse parsers cannot be copied"
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_9iterparse___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9iterparse___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":452
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":454
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef _IterparseContext context
 *         cdef xmlparser.xmlParserCtxt* pctxt
 */

static PyObject *__pyx_pf_4lxml_5etree_9iterparse___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_9iterparse___next__(PyObject *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__IterparseContext *__pyx_v_context;
  xmlParserCtxt *__pyx_v_pctxt;
  FILE *__pyx_v_c_stream;
  char *__pyx_v_c_data;
  Py_ssize_t __pyx_v_c_data_len;
  int __pyx_v_error;
  int __pyx_v_done;
  PyObject *__pyx_v_item;
  PyObject *__pyx_v_data;
  PyObject *__pyx_v_element;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);
  __pyx_v_data = Py_None; Py_INCREF(Py_None);
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":461
 *         cdef Py_ssize_t c_data_len
 *         cdef int error, done
 *         if self._source is None:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":462
 *         cdef int error, done
 *         if self._source is None:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         context = <_IterparseContext>self._push_parser_context
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[14]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":464
 *             raise StopIteration
 * 
 *         context = <_IterparseContext>self._push_parser_context             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(context._events) > context._event_index:
 *             item = python.PyList_GET_ITEM(context._events, context._event_index)
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IterparseContext *)((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._push_parser_context)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._push_parser_context);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":465
 * 
 *         context = <_IterparseContext>self._push_parser_context
 *         if python.PyList_GET_SIZE(context._events) > context._event_index:             # <<<<<<<<<<<<<<
 *             item = python.PyList_GET_ITEM(context._events, context._event_index)
 *             python.Py_INCREF(item) # 'borrowed reference' from PyList_GET_ITEM
 */
  __pyx_1 = (PyList_GET_SIZE(__pyx_v_context->_events) > __pyx_v_context->_event_index);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":466
 *         context = <_IterparseContext>self._push_parser_context
 *         if python.PyList_GET_SIZE(context._events) > context._event_index:
 *             item = python.PyList_GET_ITEM(context._events, context._event_index)             # <<<<<<<<<<<<<<
 *             python.Py_INCREF(item) # 'borrowed reference' from PyList_GET_ITEM
 *             context._event_index += 1
 */
    __pyx_2 = PyList_GET_ITEM(__pyx_v_context->_events, __pyx_v_context->_event_index); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":467
 *         if python.PyList_GET_SIZE(context._events) > context._event_index:
 *             item = python.PyList_GET_ITEM(context._events, context._event_index)
 *             python.Py_INCREF(item) # 'borrowed reference' from PyList_GET_ITEM             # <<<<<<<<<<<<<<
 *             context._event_index += 1
 *             return item
 */
    Py_INCREF(__pyx_v_item);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":468
 *             item = python.PyList_GET_ITEM(context._events, context._event_index)
 *             python.Py_INCREF(item) # 'borrowed reference' from PyList_GET_ITEM
 *             context._event_index += 1             # <<<<<<<<<<<<<<
 *             return item
 * 
 */
    __pyx_v_context->_event_index += 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":469
 *             python.Py_INCREF(item) # 'borrowed reference' from PyList_GET_ITEM
 *             context._event_index += 1
 *             return item             # <<<<<<<<<<<<<<
 * 
 *         del context._events[:]
 */
    Py_INCREF(__pyx_v_item);
    __pyx_r = __pyx_v_item;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":471
 *             return item
 * 
 *         del context._events[:]             # <<<<<<<<<<<<<<
 *         pctxt = context._c_ctxt
 *         error = done = 0
 */
  if (PySequence_DelSlice(__pyx_v_context->_events, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":472
 * 
 *         del context._events[:]
 *         pctxt = context._c_ctxt             # <<<<<<<<<<<<<<
 *         error = done = 0
 *         c_stream = python.PyFile_AsFile(self._source)
 */
  __pyx_v_pctxt = __pyx_v_context->__pyx_base._c_ctxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":473
 *         del context._events[:]
 *         pctxt = context._c_ctxt
 *         error = done = 0             # <<<<<<<<<<<<<<
 *         c_stream = python.PyFile_AsFile(self._source)
 *         while python.PyList_GET_SIZE(context._events) == 0:
 */
  __pyx_v_error = 0;
  __pyx_v_done = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":474
 *         pctxt = context._c_ctxt
 *         error = done = 0
 *         c_stream = python.PyFile_AsFile(self._source)             # <<<<<<<<<<<<<<
 *         while python.PyList_GET_SIZE(context._events) == 0:
 *             if c_stream is NULL:
 */
  __pyx_v_c_stream = PyFile_AsFile(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":475
 *         error = done = 0
 *         c_stream = python.PyFile_AsFile(self._source)
 *         while python.PyList_GET_SIZE(context._events) == 0:             # <<<<<<<<<<<<<<
 *             if c_stream is NULL:
 *                 data = self._source.read(__ITERPARSE_CHUNK_SIZE)
 */
  while (1) {
    __pyx_1 = (PyList_GET_SIZE(__pyx_v_context->_events) == 0);
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":476
 *         c_stream = python.PyFile_AsFile(self._source)
 *         while python.PyList_GET_SIZE(context._events) == 0:
 *             if c_stream is NULL:             # <<<<<<<<<<<<<<
 *                 data = self._source.read(__ITERPARSE_CHUNK_SIZE)
 *                 if not python.PyString_Check(data):
 */
    __pyx_1 = (__pyx_v_c_stream == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":477
 *         while python.PyList_GET_SIZE(context._events) == 0:
 *             if c_stream is NULL:
 *                 data = self._source.read(__ITERPARSE_CHUNK_SIZE)             # <<<<<<<<<<<<<<
 *                 if not python.PyString_Check(data):
 *                     self._source = None
 */
      __pyx_2 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source, __pyx_kp_read); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_int_32768);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_int_32768);
      __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      Py_DECREF(__pyx_v_data);
      __pyx_v_data = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":478
 *             if c_stream is NULL:
 *                 data = self._source.read(__ITERPARSE_CHUNK_SIZE)
 *                 if not python.PyString_Check(data):             # <<<<<<<<<<<<<<
 *                     self._source = None
 *                     raise TypeError, u"reading file objects must return plain strings"
 */
      __pyx_1 = (!PyString_Check(__pyx_v_data));
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":479
 *                 data = self._source.read(__ITERPARSE_CHUNK_SIZE)
 *                 if not python.PyString_Check(data):
 *                     self._source = None             # <<<<<<<<<<<<<<
 *                     raise TypeError, u"reading file objects must return plain strings"
 *                 c_data_len = python.PyString_GET_SIZE(data)
 */
        Py_INCREF(Py_None);
        Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source);
        ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source = Py_None;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":480
 *                 if not python.PyString_Check(data):
 *                     self._source = None
 *                     raise TypeError, u"reading file objects must return plain strings"             # <<<<<<<<<<<<<<
 *                 c_data_len = python.PyString_GET_SIZE(data)
 *                 c_data = _cstr(data)
 */
        __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_511), 0);
        {__pyx_filename = __pyx_f[14]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":481
 *                     self._source = None
 *                     raise TypeError, u"reading file objects must return plain strings"
 *                 c_data_len = python.PyString_GET_SIZE(data)             # <<<<<<<<<<<<<<
 *                 c_data = _cstr(data)
 *                 done = (c_data_len == 0)
 */
      __pyx_v_c_data_len = PyString_GET_SIZE(__pyx_v_data);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":482
 *                     raise TypeError, u"reading file objects must return plain strings"
 *                 c_data_len = python.PyString_GET_SIZE(data)
 *                 c_data = _cstr(data)             # <<<<<<<<<<<<<<
 *                 done = (c_data_len == 0)
 *                 error = self._parse_chunk(pctxt, c_data, c_data_len, done)
 */
      __pyx_v_c_data = PyString_AS_STRING(__pyx_v_data);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":483
 *                 c_data_len = python.PyString_GET_SIZE(data)
 *                 c_data = _cstr(data)
 *                 done = (c_data_len == 0)             # <<<<<<<<<<<<<<
 *                 error = self._parse_chunk(pctxt, c_data, c_data_len, done)
 *             else:
 */
      __pyx_v_done = (__pyx_v_c_data_len == 0);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":484
 *                 c_data = _cstr(data)
 *                 done = (c_data_len == 0)
 *                 error = self._parse_chunk(pctxt, c_data, c_data_len, done)             # <<<<<<<<<<<<<<
 *             else:
 *                 if self._buffer is None:
 */
      __pyx_v_error = ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_parse_chunk(__pyx_v_pctxt, __pyx_v_c_data, __pyx_v_c_data_len, __pyx_v_done);
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":486
 *                 error = self._parse_chunk(pctxt, c_data, c_data_len, done)
 *             else:
 *                 if self._buffer is None:             # <<<<<<<<<<<<<<
 *                     self._buffer = python.PyString_FromStringAndSize(
 *                         NULL, __ITERPARSE_CHUNK_SIZE)
 */
      __pyx_1 = (((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_buffer == Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":488
 *                 if self._buffer is None:
 *                     self._buffer = python.PyString_FromStringAndSize(
 *                         NULL, __ITERPARSE_CHUNK_SIZE)             # <<<<<<<<<<<<<<
 *                 c_data = _cstr(self._buffer)
 *                 with nogil:
 */
        __pyx_2 = PyString_FromStringAndSize(NULL, 32768); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":487
 *             else:
 *                 if self._buffer is None:
 *                     self._buffer = python.PyString_FromStringAndSize(             # <<<<<<<<<<<<<<
 *                         NULL, __ITERPARSE_CHUNK_SIZE)
 *                 c_data = _cstr(self._buffer)
 */
        Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_buffer);
        ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_buffer = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":489
 *                     self._buffer = python.PyString_FromStringAndSize(
 *                         NULL, __ITERPARSE_CHUNK_SIZE)
 *                 c_data = _cstr(self._buffer)             # <<<<<<<<<<<<<<
 *                 with nogil:
 *                     c_data_len = cstd.fread(
 */
      __pyx_v_c_data = PyString_AS_STRING(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_buffer);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":490
 *                         NULL, __ITERPARSE_CHUNK_SIZE)
 *                 c_data = _cstr(self._buffer)
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     c_data_len = cstd.fread(
 *                         c_data, 1, __ITERPARSE_CHUNK_SIZE, c_stream)
 */
      /*with nogil:*/ {
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":492
 *                 with nogil:
 *                     c_data_len = cstd.fread(
 *                         c_data, 1, __ITERPARSE_CHUNK_SIZE, c_stream)             # <<<<<<<<<<<<<<
 *                     if c_data_len < __ITERPARSE_CHUNK_SIZE:
 *                         if cstd.ferror(c_stream):
 */
          __pyx_v_c_data_len = fread(__pyx_v_c_data, 1, 32768, __pyx_v_c_stream);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":493
 *                     c_data_len = cstd.fread(
 *                         c_data, 1, __ITERPARSE_CHUNK_SIZE, c_stream)
 *                     if c_data_len < __ITERPARSE_CHUNK_SIZE:             # <<<<<<<<<<<<<<
 *                         if cstd.ferror(c_stream):
 *                             error = 1
 */
          __pyx_1 = (__pyx_v_c_data_len < 32768);
          if (__pyx_1) {

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":494
 *                         c_data, 1, __ITERPARSE_CHUNK_SIZE, c_stream)
 *                     if c_data_len < __ITERPARSE_CHUNK_SIZE:
 *                         if cstd.ferror(c_stream):             # <<<<<<<<<<<<<<
 *                             error = 1
 *                         elif cstd.feof(c_stream):
 */
            __pyx_5 = ferror(__pyx_v_c_stream);
            if (__pyx_5) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":495
 *                     if c_data_len < __ITERPARSE_CHUNK_SIZE:
 *                         if cstd.ferror(c_stream):
 *                             error = 1             # <<<<<<<<<<<<<<
 *                         elif cstd.feof(c_stream):
 *                             done = 1
 */
              __pyx_v_error = 1;
              goto __pyx_L18;
            }

            /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":496
 *                         if cstd.ferror(c_stream):
 *                             error = 1
 *                         elif cstd.feof(c_stream):             # <<<<<<<<<<<<<<
 *                             done = 1
 *                 if not error:
 */
            __pyx_5 = feof(__pyx_v_c_stream);
            if (__pyx_5) {

              /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":497
 *                             error = 1
 *                         elif cstd.feof(c_stream):
 *                             done = 1             # <<<<<<<<<<<<<<
 *                 if not error:
 *                     error = self._parse_chunk(
 */
              __pyx_v_done = 1;
              goto __pyx_L18;
            }
            __pyx_L18:;
            goto __pyx_L17;
          }
          __pyx_L17:;
        }
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":498
 *                         elif cstd.feof(c_stream):
 *                             done = 1
 *                 if not error:             # <<<<<<<<<<<<<<
 *                     error = self._parse_chunk(
 *                         pctxt, c_data, c_data_len, done)
 */
      __pyx_1 = (!__pyx_v_error);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":500
 *                 if not error:
 *                     error = self._parse_chunk(
 *                         pctxt, c_data, c_data_len, done)             # <<<<<<<<<<<<<<
 *             if error or done:
 *                 self._buffer = None
 */
        __pyx_v_error = ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_parse_chunk(__pyx_v_pctxt, __pyx_v_c_data, __pyx_v_c_data_len, __pyx_v_done);
        goto __pyx_L19;
      }
      __pyx_L19:;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":501
 *                     error = self._parse_chunk(
 *                         pctxt, c_data, c_data_len, done)
 *             if error or done:             # <<<<<<<<<<<<<<
 *                 self._buffer = None
 *                 break
 */
    __pyx_1 = __pyx_v_error;
    if (!__pyx_1) {
      __pyx_1 = __pyx_v_done;
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":502
 *                         pctxt, c_data, c_data_len, done)
 *             if error or done:
 *                 self._buffer = None             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      Py_INCREF(Py_None);
      Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_buffer);
      ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_buffer = Py_None;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":503
 *             if error or done:
 *                 self._buffer = None
 *                 break             # <<<<<<<<<<<<<<
 * 
 *         if not error and context._validator is not None:
 */
      goto __pyx_L8;
      goto __pyx_L20;
    }
    __pyx_L20:;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":505
 *                 break
 * 
 *         if not error and context._validator is not None:             # <<<<<<<<<<<<<<
 *             error = not context._validator.isvalid()
 *         if error:
 */
  __pyx_1 = (!__pyx_v_error);
  if (__pyx_1) {
    __pyx_1 = (((PyObject *)__pyx_v_context->__pyx_base._validator) != Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":506
 * 
 *         if not error and context._validator is not None:
 *             error = not context._validator.isvalid()             # <<<<<<<<<<<<<<
 *         if error:
 *             self._source = None
 */
    __pyx_v_error = (!((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_context->__pyx_base._validator->__pyx_vtab)->isvalid(__pyx_v_context->__pyx_base._validator));
    goto __pyx_L21;
  }
  __pyx_L21:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":507
 *         if not error and context._validator is not None:
 *             error = not context._validator.isvalid()
 *         if error:             # <<<<<<<<<<<<<<
 *             self._source = None
 *             del context._events[:]
 */
  __pyx_5 = __pyx_v_error;
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":508
 *             error = not context._validator.isvalid()
 *         if error:
 *             self._source = None             # <<<<<<<<<<<<<<
 *             del context._events[:]
 *             context._assureDocGetsFreed()
 */
    Py_INCREF(Py_None);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source);
    ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source = Py_None;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":509
 *         if error:
 *             self._source = None
 *             del context._events[:]             # <<<<<<<<<<<<<<
 *             context._assureDocGetsFreed()
 *             _raiseParseError(pctxt, self._filename, context._error_log)
 */
    if (PySequence_DelSlice(__pyx_v_context->_events, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":510
 *             self._source = None
 *             del context._events[:]
 *             context._assureDocGetsFreed()             # <<<<<<<<<<<<<<
 *             _raiseParseError(pctxt, self._filename, context._error_log)
 *         if python.PyList_GET_SIZE(context._events) == 0:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__IterparseContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_assureDocGetsFreed(__pyx_v_context);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":511
 *             del context._events[:]
 *             context._assureDocGetsFreed()
 *             _raiseParseError(pctxt, self._filename, context._error_log)             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(context._events) == 0:
 *             self.root = context._root
 */
    __pyx_5 = __pyx_f_4lxml_5etree__raiseParseError(__pyx_v_pctxt, ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->__pyx_base._filename, __pyx_v_context->__pyx_base._error_log); if (unlikely(__pyx_5 == 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L22;
  }
  __pyx_L22:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":512
 *             context._assureDocGetsFreed()
 *             _raiseParseError(pctxt, self._filename, context._error_log)
 *         if python.PyList_GET_SIZE(context._events) == 0:             # <<<<<<<<<<<<<<
 *             self.root = context._root
 *             self._source = None
 */
  __pyx_1 = (PyList_GET_SIZE(__pyx_v_context->_events) == 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":513
 *             _raiseParseError(pctxt, self._filename, context._error_log)
 *         if python.PyList_GET_SIZE(context._events) == 0:
 *             self.root = context._root             # <<<<<<<<<<<<<<
 *             self._source = None
 *             raise StopIteration
 */
    Py_INCREF(((PyObject *)__pyx_v_context->_root));
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->root);
    ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->root = ((PyObject *)__pyx_v_context->_root);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":514
 *         if python.PyList_GET_SIZE(context._events) == 0:
 *             self.root = context._root
 *             self._source = None             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
    Py_INCREF(Py_None);
    Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source);
    ((struct __pyx_obj_4lxml_5etree_iterparse *)__pyx_v_self)->_source = Py_None;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":515
 *             self.root = context._root
 *             self._source = None
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         context._event_index = 1
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
    {__pyx_filename = __pyx_f[14]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":517
 *             raise StopIteration
 * 
 *         context._event_index = 1             # <<<<<<<<<<<<<<
 *         element = python.PyList_GET_ITEM(context._events, 0)
 *         python.Py_INCREF(element) # 'borrowed reference' from PyList_GET_ITEM
 */
  __pyx_v_context->_event_index = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":518
 * 
 *         context._event_index = 1
 *         element = python.PyList_GET_ITEM(context._events, 0)             # <<<<<<<<<<<<<<
 *         python.Py_INCREF(element) # 'borrowed reference' from PyList_GET_ITEM
 *         return element
 */
  __pyx_3 = PyList_GET_ITEM(__pyx_v_context->_events, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_element);
  __pyx_v_element = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":519
 *         context._event_index = 1
 *         element = python.PyList_GET_ITEM(context._events, 0)
 *         python.Py_INCREF(element) # 'borrowed reference' from PyList_GET_ITEM             # <<<<<<<<<<<<<<
 *         return element
 * 
 */
  Py_INCREF(__pyx_v_element);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":520
 *         element = python.PyList_GET_ITEM(context._events, 0)
 *         python.Py_INCREF(element) # 'borrowed reference' from PyList_GET_ITEM
 *         return element             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_element);
  __pyx_r = __pyx_v_element;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.iterparse.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_data);
  Py_DECREF(__pyx_v_element);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":539
 *     cdef char*  _tag_name
 * 
 *     def __init__(self, element_or_tree, events=(u"end",), tag=None):             # <<<<<<<<<<<<<<
 *         cdef _Element root
 *         cdef int ns_count
 */

static int __pyx_pf_4lxml_5etree_8iterwalk___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_8iterwalk___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_element_or_tree = 0;
  PyObject *__pyx_v_events = 0;
  PyObject *__pyx_v_tag = 0;
  struct LxmlElement *__pyx_v_root;
  int __pyx_v_ns_count;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element_or_tree,&__pyx_kp_events,&__pyx_kp_tag,0};
  __pyx_v_events = __pyx_k_158;
  __pyx_v_tag = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element_or_tree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element_or_tree = values[0];
    if (values[1]) {
      __pyx_v_events = values[1];
    }
    if (values[2]) {
      __pyx_v_tag = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_tag = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_events = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_element_or_tree = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[14]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.iterwalk.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_root = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":542
 *         cdef _Element root
 *         cdef int ns_count
 *         root = _rootNodeOrRaise(element_or_tree)             # <<<<<<<<<<<<<<
 *         self._event_filter = _buildIterparseEventFilter(events)
 *         self._setTagFilter(tag)
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_element_or_tree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root));
  __pyx_v_root = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":543
 *         cdef int ns_count
 *         root = _rootNodeOrRaise(element_or_tree)
 *         self._event_filter = _buildIterparseEventFilter(events)             # <<<<<<<<<<<<<<
 *         self._setTagFilter(tag)
 *         self._node_stack  = []
 */
  __pyx_2 = __pyx_f_4lxml_5etree__buildIterparseEventFilter(__pyx_v_events); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_event_filter = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":544
 *         root = _rootNodeOrRaise(element_or_tree)
 *         self._event_filter = _buildIterparseEventFilter(events)
 *         self._setTagFilter(tag)             # <<<<<<<<<<<<<<
 *         self._node_stack  = []
 *         self._pop_node = self._node_stack.pop
 */
  ((struct __pyx_vtabstruct_4lxml_5etree_iterwalk *)((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->__pyx_vtab)->_setTagFilter(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self), __pyx_v_tag);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":545
 *         self._event_filter = _buildIterparseEventFilter(events)
 *         self._setTagFilter(tag)
 *         self._node_stack  = []             # <<<<<<<<<<<<<<
 *         self._pop_node = self._node_stack.pop
 *         self._events = []
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_node_stack);
  ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_node_stack = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":546
 *         self._setTagFilter(tag)
 *         self._node_stack  = []
 *         self._pop_node = self._node_stack.pop             # <<<<<<<<<<<<<<
 *         self._events = []
 *         self._pop_event = self._events.pop
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_node_stack, __pyx_kp_pop); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_pop_node);
  ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_pop_node = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":547
 *         self._node_stack  = []
 *         self._pop_node = self._node_stack.pop
 *         self._events = []             # <<<<<<<<<<<<<<
 *         self._pop_event = self._events.pop
 * 
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_events);
  ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_events = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":548
 *         self._pop_node = self._node_stack.pop
 *         self._events = []
 *         self._pop_event = self._events.pop             # <<<<<<<<<<<<<<
 * 
 *         if self._event_filter != 0:
 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_events, __pyx_kp_pop); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_pop_event);
  ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_pop_event = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":550
 *         self._pop_event = self._events.pop
 * 
 *         if self._event_filter != 0:             # <<<<<<<<<<<<<<
 *             self._index = 0
 *             ns_count = self._start_node(root)
 */
  __pyx_3 = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_event_filter != 0);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":551
 * 
 *         if self._event_filter != 0:
 *             self._index = 0             # <<<<<<<<<<<<<<
 *             ns_count = self._start_node(root)
 *             python.PyList_Append(self._node_stack, (root, ns_count))
 */
    ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":552
 *         if self._event_filter != 0:
 *             self._index = 0
 *             ns_count = self._start_node(root)             # <<<<<<<<<<<<<<
 *             python.PyList_Append(self._node_stack, (root, ns_count))
 *         else:
 */
    __pyx_v_ns_count = ((struct __pyx_vtabstruct_4lxml_5etree_iterwalk *)((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->__pyx_vtab)->_start_node(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self), __pyx_v_root);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":553
 *             self._index = 0
 *             ns_count = self._start_node(root)
 *             python.PyList_Append(self._node_stack, (root, ns_count))             # <<<<<<<<<<<<<<
 *         else:
 *             self._index = -1
 */
    __pyx_1 = PyInt_FromLong(__pyx_v_ns_count); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
    __pyx_1 = 0;
    __pyx_2 = PyList_Append(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_node_stack, ((PyObject *)__pyx_4)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":555
 *             python.PyList_Append(self._node_stack, (root, ns_count))
 *         else:
 *             self._index = -1             # <<<<<<<<<<<<<<
 * 
 *     cdef void _setTagFilter(self, tag):
 */
    ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index = -1;
  }
  __pyx_L6:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.iterwalk.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":557
 *             self._index = -1
 * 
 *     cdef void _setTagFilter(self, tag):             # <<<<<<<<<<<<<<
 *         if tag is None or tag == u'*':
 *             self._tag_href  = NULL
 */

static  void __pyx_f_4lxml_5etree_8iterwalk__setTagFilter(struct __pyx_obj_4lxml_5etree_iterwalk *__pyx_v_self, PyObject *__pyx_v_tag) {
  PyObject *__pyx_v_href;
  PyObject *__pyx_v_name;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_href = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":558
 * 
 *     cdef void _setTagFilter(self, tag):
 *         if tag is None or tag == u'*':             # <<<<<<<<<<<<<<
 *             self._tag_href  = NULL
 *             self._tag_name  = NULL
 */
  __pyx_1 = (__pyx_v_tag == Py_None);
  if (!__pyx_1) {
    __pyx_3 = PyObject_RichCompare(__pyx_v_tag, ((PyObject *)__pyx_kp_512), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":559
 *     cdef void _setTagFilter(self, tag):
 *         if tag is None or tag == u'*':
 *             self._tag_href  = NULL             # <<<<<<<<<<<<<<
 *             self._tag_name  = NULL
 *         else:
 */
    __pyx_v_self->_tag_href = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":560
 *         if tag is None or tag == u'*':
 *             self._tag_href  = NULL
 *             self._tag_name  = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             self._tag_tuple = _getNsTag(tag)
 */
    __pyx_v_self->_tag_name = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":562
 *             self._tag_name  = NULL
 *         else:
 *             self._tag_tuple = _getNsTag(tag)             # <<<<<<<<<<<<<<
 *             href, name = self._tag_tuple
 *             if href is None or href == u'*':
 */
    __pyx_3 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_tag); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_self->_tag_tuple);
    __pyx_v_self->_tag_tuple = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":563
 *         else:
 *             self._tag_tuple = _getNsTag(tag)
 *             href, name = self._tag_tuple             # <<<<<<<<<<<<<<
 *             if href is None or href == u'*':
 *                 self._tag_href = NULL
 */
    if (PyTuple_CheckExact(__pyx_v_self->_tag_tuple) && PyTuple_GET_SIZE(__pyx_v_self->_tag_tuple) == 2) {
      PyObject* tuple = __pyx_v_self->_tag_tuple;
      __pyx_4 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_4);
      Py_DECREF(__pyx_v_href);
      __pyx_v_href = __pyx_4;
      __pyx_4 = 0;
      __pyx_4 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_4);
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_4;
      __pyx_4 = 0;
    }
    else {
      __pyx_3 = PyObject_GetIter(__pyx_v_self->_tag_tuple); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_href);
      __pyx_v_href = __pyx_4;
      __pyx_4 = 0;
      __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_4;
      __pyx_4 = 0;
      if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":564
 *             self._tag_tuple = _getNsTag(tag)
 *             href, name = self._tag_tuple
 *             if href is None or href == u'*':             # <<<<<<<<<<<<<<
 *                 self._tag_href = NULL
 *             else:
 */
    __pyx_2 = (__pyx_v_href == Py_None);
    if (!__pyx_2) {
      __pyx_4 = PyObject_RichCompare(__pyx_v_href, ((PyObject *)__pyx_kp_513), Py_EQ); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_4); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":565
 *             href, name = self._tag_tuple
 *             if href is None or href == u'*':
 *                 self._tag_href = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 self._tag_href = _cstr(href)
 */
      __pyx_v_self->_tag_href = NULL;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":567
 *                 self._tag_href = NULL
 *             else:
 *                 self._tag_href = _cstr(href)             # <<<<<<<<<<<<<<
 *             if name is None or name == u'*':
 *                 self._tag_name = NULL
 */
      __pyx_v_self->_tag_href = PyString_AS_STRING(__pyx_v_href);
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":568
 *             else:
 *                 self._tag_href = _cstr(href)
 *             if name is None or name == u'*':             # <<<<<<<<<<<<<<
 *                 self._tag_name = NULL
 *             else:
 */
    __pyx_1 = (__pyx_v_name == Py_None);
    if (!__pyx_1) {
      __pyx_3 = PyObject_RichCompare(__pyx_v_name, ((PyObject *)__pyx_kp_514), Py_EQ); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":569
 *                 self._tag_href = _cstr(href)
 *             if name is None or name == u'*':
 *                 self._tag_name = NULL             # <<<<<<<<<<<<<<
 *             else:
 *                 self._tag_name = _cstr(name)
 */
      __pyx_v_self->_tag_name = NULL;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":571
 *                 self._tag_name = NULL
 *             else:
 *                 self._tag_name = _cstr(name)             # <<<<<<<<<<<<<<
 *             if self._tag_href is NULL and self._tag_name is NULL:
 *                 self._tag_tuple = None
 */
      __pyx_v_self->_tag_name = PyString_AS_STRING(__pyx_v_name);
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":572
 *             else:
 *                 self._tag_name = _cstr(name)
 *             if self._tag_href is NULL and self._tag_name is NULL:             # <<<<<<<<<<<<<<
 *                 self._tag_tuple = None
 * 
 */
    __pyx_2 = (__pyx_v_self->_tag_href == NULL);
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_self->_tag_name == NULL);
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":573
 *                 self._tag_name = _cstr(name)
 *             if self._tag_href is NULL and self._tag_name is NULL:
 *                 self._tag_tuple = None             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
      Py_INCREF(Py_None);
      Py_DECREF(__pyx_v_self->_tag_tuple);
      __pyx_v_self->_tag_tuple = Py_None;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree.iterwalk._setTagFilter");
  __pyx_L0:;
  Py_DECREF(__pyx_v_href);
  Py_DECREF(__pyx_v_name);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":575
 *                 self._tag_tuple = None
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8iterwalk___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8iterwalk___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":576
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":578
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_child
 *         cdef _Element node
 */

static PyObject *__pyx_pf_4lxml_5etree_8iterwalk___next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8iterwalk___next__(PyObject *__pyx_v_self) {
  xmlNode *__pyx_v_c_child;
  struct LxmlElement *__pyx_v_node;
  struct LxmlElement *__pyx_v_next_node;
  int __pyx_v_ns_count;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_next_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":583
 *         cdef _Element next_node
 *         cdef int ns_count
 *         if python.PyList_GET_SIZE(self._events):             # <<<<<<<<<<<<<<
 *             return self._pop_event(0)
 *         ns_count = 0
 */
  __pyx_1 = PyList_GET_SIZE(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_events);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":584
 *         cdef int ns_count
 *         if python.PyList_GET_SIZE(self._events):
 *             return self._pop_event(0)             # <<<<<<<<<<<<<<
 *         ns_count = 0
 *         # find next node
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_int_0);
    __pyx_3 = PyObject_Call(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_pop_event, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":585
 *         if python.PyList_GET_SIZE(self._events):
 *             return self._pop_event(0)
 *         ns_count = 0             # <<<<<<<<<<<<<<
 *         # find next node
 *         while self._index >= 0:
 */
  __pyx_v_ns_count = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":587
 *         ns_count = 0
 *         # find next node
 *         while self._index >= 0:             # <<<<<<<<<<<<<<
 *             node = self._node_stack[self._index][0]
 * 
 */
  while (1) {
    __pyx_4 = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index >= 0);
    if (!__pyx_4) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":588
 *         # find next node
 *         while self._index >= 0:
 *             node = self._node_stack[self._index][0]             # <<<<<<<<<<<<<<
 * 
 *             c_child = _findChildForwards(node._c_node, 0)
 */
    __pyx_2 = __Pyx_GetItemInt(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_node_stack, ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_GetItemInt(__pyx_2, 0, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_node));
    __pyx_v_node = ((struct LxmlElement *)__pyx_3);
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":590
 *             node = self._node_stack[self._index][0]
 * 
 *             c_child = _findChildForwards(node._c_node, 0)             # <<<<<<<<<<<<<<
 *             if c_child is not NULL:
 *                 # try children
 */
    __pyx_v_c_child = __pyx_f_4lxml_5etree__findChildForwards(__pyx_v_node->_c_node, 0);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":591
 * 
 *             c_child = _findChildForwards(node._c_node, 0)
 *             if c_child is not NULL:             # <<<<<<<<<<<<<<
 *                 # try children
 *                 next_node = _elementFactory(node._doc, c_child)
 */
    __pyx_4 = (__pyx_v_c_child != NULL);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":593
 *             if c_child is not NULL:
 *                 # try children
 *                 next_node = _elementFactory(node._doc, c_child)             # <<<<<<<<<<<<<<
 *             else:
 *                 # back off
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_node->_doc, __pyx_v_c_child)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_next_node));
      __pyx_v_next_node = ((struct LxmlElement *)__pyx_2);
      __pyx_2 = 0;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":596
 *             else:
 *                 # back off
 *                 next_node = None             # <<<<<<<<<<<<<<
 *                 while next_node is None:
 *                     # back off through parents
 */
      Py_INCREF(Py_None);
      Py_DECREF(((PyObject *)__pyx_v_next_node));
      __pyx_v_next_node = ((struct LxmlElement *)Py_None);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":597
 *                 # back off
 *                 next_node = None
 *                 while next_node is None:             # <<<<<<<<<<<<<<
 *                     # back off through parents
 *                     self._index = self._index - 1
 */
      while (1) {
        __pyx_4 = (((PyObject *)__pyx_v_next_node) == Py_None);
        if (!__pyx_4) break;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":599
 *                 while next_node is None:
 *                     # back off through parents
 *                     self._index = self._index - 1             # <<<<<<<<<<<<<<
 *                     node = self._end_node()
 *                     if self._index < 0:
 */
        ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index - 1);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":600
 *                     # back off through parents
 *                     self._index = self._index - 1
 *                     node = self._end_node()             # <<<<<<<<<<<<<<
 *                     if self._index < 0:
 *                         break
 */
        __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_iterwalk *)((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->__pyx_vtab)->_end_node(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self))); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_v_node));
        __pyx_v_node = ((struct LxmlElement *)__pyx_3);
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":601
 *                     self._index = self._index - 1
 *                     node = self._end_node()
 *                     if self._index < 0:             # <<<<<<<<<<<<<<
 *                         break
 *                     next_node = node.getnext()
 */
        __pyx_4 = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index < 0);
        if (__pyx_4) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":602
 *                     node = self._end_node()
 *                     if self._index < 0:
 *                         break             # <<<<<<<<<<<<<<
 *                     next_node = node.getnext()
 *             if next_node is not None:
 */
          goto __pyx_L10;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":603
 *                     if self._index < 0:
 *                         break
 *                     next_node = node.getnext()             # <<<<<<<<<<<<<<
 *             if next_node is not None:
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 */
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_node), __pyx_kp_getnext); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_v_next_node));
        __pyx_v_next_node = ((struct LxmlElement *)__pyx_3);
        __pyx_3 = 0;
      }
      __pyx_L10:;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":604
 *                         break
 *                     next_node = node.getnext()
 *             if next_node is not None:             # <<<<<<<<<<<<<<
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 *                                          ITERPARSE_FILTER_START_NS):
 */
    __pyx_4 = (((PyObject *)__pyx_v_next_node) != Py_None);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":606
 *             if next_node is not None:
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 *                                          ITERPARSE_FILTER_START_NS):             # <<<<<<<<<<<<<<
 *                     ns_count = self._start_node(next_node)
 *                 elif self._event_filter & ITERPARSE_FILTER_END_NS:
 */
      __pyx_5 = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_event_filter & (__pyx_e_4lxml_5etree_ITERPARSE_FILTER_START | __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS));
      if (__pyx_5) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":607
 *                 if self._event_filter & (ITERPARSE_FILTER_START | \
 *                                          ITERPARSE_FILTER_START_NS):
 *                     ns_count = self._start_node(next_node)             # <<<<<<<<<<<<<<
 *                 elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *                     ns_count = _countNsDefs(next_node._c_node)
 */
        __pyx_v_ns_count = ((struct __pyx_vtabstruct_4lxml_5etree_iterwalk *)((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->__pyx_vtab)->_start_node(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self), __pyx_v_next_node);
        goto __pyx_L13;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":608
 *                                          ITERPARSE_FILTER_START_NS):
 *                     ns_count = self._start_node(next_node)
 *                 elif self._event_filter & ITERPARSE_FILTER_END_NS:             # <<<<<<<<<<<<<<
 *                     ns_count = _countNsDefs(next_node._c_node)
 *                 python.PyList_Append(self._node_stack, (next_node, ns_count))
 */
      __pyx_5 = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS);
      if (__pyx_5) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":609
 *                     ns_count = self._start_node(next_node)
 *                 elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *                     ns_count = _countNsDefs(next_node._c_node)             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._node_stack, (next_node, ns_count))
 *                 self._index = self._index + 1
 */
        __pyx_v_ns_count = __pyx_f_4lxml_5etree__countNsDefs(__pyx_v_next_node->_c_node);
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":610
 *                 elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *                     ns_count = _countNsDefs(next_node._c_node)
 *                 python.PyList_Append(self._node_stack, (next_node, ns_count))             # <<<<<<<<<<<<<<
 *                 self._index = self._index + 1
 *             if python.PyList_GET_SIZE(self._events):
 */
      __pyx_2 = PyInt_FromLong(__pyx_v_ns_count); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_v_next_node));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_next_node));
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
      __pyx_2 = 0;
      __pyx_5 = PyList_Append(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_node_stack, ((PyObject *)__pyx_3)); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":611
 *                     ns_count = _countNsDefs(next_node._c_node)
 *                 python.PyList_Append(self._node_stack, (next_node, ns_count))
 *                 self._index = self._index + 1             # <<<<<<<<<<<<<<
 *             if python.PyList_GET_SIZE(self._events):
 *                 return self._pop_event(0)
 */
      ((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index = (((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_index + 1);
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":612
 *                 python.PyList_Append(self._node_stack, (next_node, ns_count))
 *                 self._index = self._index + 1
 *             if python.PyList_GET_SIZE(self._events):             # <<<<<<<<<<<<<<
 *                 return self._pop_event(0)
 *         raise StopIteration
 */
    __pyx_1 = PyList_GET_SIZE(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_events);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":613
 *                 self._index = self._index + 1
 *             if python.PyList_GET_SIZE(self._events):
 *                 return self._pop_event(0)             # <<<<<<<<<<<<<<
 *         raise StopIteration
 * 
 */
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_int_0);
      __pyx_3 = PyObject_Call(((struct __pyx_obj_4lxml_5etree_iterwalk *)__pyx_v_self)->_pop_event, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
      goto __pyx_L14;
    }
    __pyx_L14:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":614
 *             if python.PyList_GET_SIZE(self._events):
 *                 return self._pop_event(0)
 *         raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *     cdef int _start_node(self, _Element node):
 */
  __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
  {__pyx_filename = __pyx_f[14]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.iterwalk.__next__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_node);
  Py_DECREF(__pyx_v_next_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":616
 *         raise StopIteration
 * 
 *     cdef int _start_node(self, _Element node):             # <<<<<<<<<<<<<<
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:
 */

static  int __pyx_f_4lxml_5etree_8iterwalk__start_node(struct __pyx_obj_4lxml_5etree_iterwalk *__pyx_v_self, struct LxmlElement *__pyx_v_node) {
  int __pyx_v_ns_count;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":618
 *     cdef int _start_node(self, _Element node):
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:             # <<<<<<<<<<<<<<
 *             ns_count = _appendStartNsEvents(node._c_node, self._events)
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START_NS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":619
 *         cdef int ns_count
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:
 *             ns_count = _appendStartNsEvents(node._c_node, self._events)             # <<<<<<<<<<<<<<
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = _countNsDefs(node._c_node)
 */
    __pyx_v_ns_count = __pyx_f_4lxml_5etree__appendStartNsEvents(__pyx_v_node->_c_node, __pyx_v_self->_events);
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":620
 *         if self._event_filter & ITERPARSE_FILTER_START_NS:
 *             ns_count = _appendStartNsEvents(node._c_node, self._events)
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:             # <<<<<<<<<<<<<<
 *             ns_count = _countNsDefs(node._c_node)
 *         else:
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":621
 *             ns_count = _appendStartNsEvents(node._c_node, self._events)
 *         elif self._event_filter & ITERPARSE_FILTER_END_NS:
 *             ns_count = _countNsDefs(node._c_node)             # <<<<<<<<<<<<<<
 *         else:
 *             ns_count = 0
 */
    __pyx_v_ns_count = __pyx_f_4lxml_5etree__countNsDefs(__pyx_v_node->_c_node);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":623
 *             ns_count = _countNsDefs(node._c_node)
 *         else:
 *             ns_count = 0             # <<<<<<<<<<<<<<
 *         if self._event_filter & ITERPARSE_FILTER_START:
 *             if self._tag_tuple is None or \
 */
    __pyx_v_ns_count = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":624
 *         else:
 *             ns_count = 0
 *         if self._event_filter & ITERPARSE_FILTER_START:             # <<<<<<<<<<<<<<
 *             if self._tag_tuple is None or \
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 */
  __pyx_1 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_START);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":625
 *             ns_count = 0
 *         if self._event_filter & ITERPARSE_FILTER_START:
 *             if self._tag_tuple is None or \             # <<<<<<<<<<<<<<
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 *                 python.PyList_Append(self._events, (u"start", node))
 */
    __pyx_2 = (__pyx_v_self->_tag_tuple == Py_None);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":626
 *         if self._event_filter & ITERPARSE_FILTER_START:
 *             if self._tag_tuple is None or \
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._events, (u"start", node))
 *         return ns_count
 */
      __pyx_2 = __pyx_f_4lxml_5etree__tagMatches(__pyx_v_node->_c_node, __pyx_v_self->_tag_href, __pyx_v_self->_tag_name);
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":627
 *             if self._tag_tuple is None or \
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 *                 python.PyList_Append(self._events, (u"start", node))             # <<<<<<<<<<<<<<
 *         return ns_count
 * 
 */
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_515));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_515));
      Py_INCREF(((PyObject *)__pyx_v_node));
      PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_node));
      __pyx_1 = PyList_Append(__pyx_v_self->_events, ((PyObject *)__pyx_3)); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":628
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 *                 python.PyList_Append(self._events, (u"start", node))
 *         return ns_count             # <<<<<<<<<<<<<<
 * 
 *     cdef _Element _end_node(self):
 */
  __pyx_r = __pyx_v_ns_count;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("lxml.etree.iterwalk._start_node");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":630
 *         return ns_count
 * 
 *     cdef _Element _end_node(self):             # <<<<<<<<<<<<<<
 *         cdef _Element node
 *         cdef int i, ns_count
 */

static  struct LxmlElement *__pyx_f_4lxml_5etree_8iterwalk__end_node(struct __pyx_obj_4lxml_5etree_iterwalk *__pyx_v_self) {
  struct LxmlElement *__pyx_v_node;
  int __pyx_v_i;
  int __pyx_v_ns_count;
  PyObject *__pyx_v_event;
  struct LxmlElement *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_event = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":633
 *         cdef _Element node
 *         cdef int i, ns_count
 *         node, ns_count = self._pop_node()             # <<<<<<<<<<<<<<
 *         if self._event_filter & ITERPARSE_FILTER_END:
 *             if self._tag_tuple is None or \
 */
  __pyx_1 = PyObject_Call(__pyx_v_self->_pop_node, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_node));
    __pyx_v_node = ((struct LxmlElement *)__pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    __pyx_4 = __pyx_PyInt_int(__pyx_3); if (unlikely((__pyx_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_ns_count = __pyx_4;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_node));
    __pyx_v_node = ((struct LxmlElement *)__pyx_3);
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = __pyx_PyInt_int(__pyx_3); if (unlikely((__pyx_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_ns_count = __pyx_4;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":634
 *         cdef int i, ns_count
 *         node, ns_count = self._pop_node()
 *         if self._event_filter & ITERPARSE_FILTER_END:             # <<<<<<<<<<<<<<
 *             if self._tag_tuple is None or \
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 */
  __pyx_4 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":635
 *         node, ns_count = self._pop_node()
 *         if self._event_filter & ITERPARSE_FILTER_END:
 *             if self._tag_tuple is None or \             # <<<<<<<<<<<<<<
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 *                 python.PyList_Append(self._events, (u"end", node))
 */
    __pyx_5 = (__pyx_v_self->_tag_tuple == Py_None);
    if (!__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":636
 *         if self._event_filter & ITERPARSE_FILTER_END:
 *             if self._tag_tuple is None or \
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._events, (u"end", node))
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 */
      __pyx_5 = __pyx_f_4lxml_5etree__tagMatches(__pyx_v_node->_c_node, __pyx_v_self->_tag_href, __pyx_v_self->_tag_name);
    }
    if (__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":637
 *             if self._tag_tuple is None or \
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 *                 python.PyList_Append(self._events, (u"end", node))             # <<<<<<<<<<<<<<
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             event = (u"end-ns", None)
 */
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(((PyObject *)__pyx_kp_516));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_516));
      Py_INCREF(((PyObject *)__pyx_v_node));
      PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_node));
      __pyx_4 = PyList_Append(__pyx_v_self->_events, ((PyObject *)__pyx_3)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":638
 *                    _tagMatches(node._c_node, self._tag_href, self._tag_name):
 *                 python.PyList_Append(self._events, (u"end", node))
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:             # <<<<<<<<<<<<<<
 *             event = (u"end-ns", None)
 *             for i from 0 <= i < ns_count:
 */
  __pyx_4 = (__pyx_v_self->_event_filter & __pyx_e_4lxml_5etree_ITERPARSE_FILTER_END_NS);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":639
 *                 python.PyList_Append(self._events, (u"end", node))
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             event = (u"end-ns", None)             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < ns_count:
 *                 python.PyList_Append(self._events, event)
 */
    __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_517));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_kp_517));
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_1, 1, Py_None);
    Py_DECREF(__pyx_v_event);
    __pyx_v_event = ((PyObject *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":640
 *         if self._event_filter & ITERPARSE_FILTER_END_NS:
 *             event = (u"end-ns", None)
 *             for i from 0 <= i < ns_count:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._events, event)
 *         return node
 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_ns_count; __pyx_v_i++) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":641
 *             event = (u"end-ns", None)
 *             for i from 0 <= i < ns_count:
 *                 python.PyList_Append(self._events, event)             # <<<<<<<<<<<<<<
 *         return node
 */
      __pyx_4 = PyList_Append(__pyx_v_self->_events, __pyx_v_event); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":642
 *             for i from 0 <= i < ns_count:
 *                 python.PyList_Append(self._events, event)
 *         return node             # <<<<<<<<<<<<<<
 */
  Py_INCREF(((PyObject *)__pyx_v_node));
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.iterwalk._end_node");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_node);
  Py_DECREF(__pyx_v_event);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":3
 * cdef object _find_id_attributes
 * 
 * def XMLID(text):             # <<<<<<<<<<<<<<
 *     u"""XMLID(text)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_XMLID(PyObject *__pyx_self, PyObject *__pyx_v_text); /*proto*/
static char __pyx_doc_4lxml_5etree_XMLID[] = "XMLID(text)\n\n    Parse the text and return a tuple (root node, ID dictionary).  The root\n    node is the same as returned by the XML() function.  The dictionary\n    contains string-element pairs.  The dictionary keys are the values of 'id'\n    attributes.  The elements referenced by the ID are stored as dictionary\n    values.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_XMLID(PyObject *__pyx_self, PyObject *__pyx_v_text) {
  PyObject *__pyx_v_root;
  PyObject *__pyx_v_dic;
  PyObject *__pyx_v_elem;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  __pyx_self = __pyx_self;
  __pyx_v_root = Py_None; Py_INCREF(Py_None);
  __pyx_v_dic = Py_None; Py_INCREF(Py_None);
  __pyx_v_elem = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":13
 *     """
 *     global _find_id_attributes
 *     if _find_id_attributes is None:             # <<<<<<<<<<<<<<
 *         _find_id_attributes = XPath(u'//*[string(@id)]')
 * 
 */
  __pyx_1 = (__pyx_v_4lxml_5etree__find_id_attributes == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":14
 *     global _find_id_attributes
 *     if _find_id_attributes is None:
 *         _find_id_attributes = XPath(u'//*[string(@id)]')             # <<<<<<<<<<<<<<
 * 
 *     # ElementTree compatible implementation: parse and look for 'id' attributes
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_518));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_518));
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPath)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(__pyx_v_4lxml_5etree__find_id_attributes);
    __pyx_v_4lxml_5etree__find_id_attributes = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":17
 * 
 *     # ElementTree compatible implementation: parse and look for 'id' attributes
 *     root = XML(text)             # <<<<<<<<<<<<<<
 *     dic = {}
 *     for elem in _find_id_attributes(root):
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XML); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_text);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_text);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":18
 *     # ElementTree compatible implementation: parse and look for 'id' attributes
 *     root = XML(text)
 *     dic = {}             # <<<<<<<<<<<<<<
 *     for elem in _find_id_attributes(root):
 *         python.PyDict_SetItem(dic, elem.get(u'id'), elem)
 */
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_dic);
  __pyx_v_dic = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":19
 *     root = XML(text)
 *     dic = {}
 *     for elem in _find_id_attributes(root):             # <<<<<<<<<<<<<<
 *         python.PyDict_SetItem(dic, elem.get(u'id'), elem)
 *     return (root, dic)
 */
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_root);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_root);
  __pyx_4 = PyObject_Call(__pyx_v_4lxml_5etree__find_id_attributes, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
    __pyx_5 = 0; __pyx_2 = __pyx_4; Py_INCREF(__pyx_2);
  } else {
    __pyx_5 = -1; __pyx_2 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_5 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_5); Py_INCREF(__pyx_3); __pyx_5++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_5 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_5); Py_INCREF(__pyx_3); __pyx_5++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_elem);
    __pyx_v_elem = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":20
 *     dic = {}
 *     for elem in _find_id_attributes(root):
 *         python.PyDict_SetItem(dic, elem.get(u'id'), elem)             # <<<<<<<<<<<<<<
 *     return (root, dic)
 * 
 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_elem, __pyx_kp_get); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_519));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_519));
    __pyx_6 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_7 = PyDict_SetItem(__pyx_v_dic, __pyx_6, __pyx_v_elem); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":21
 *     for elem in _find_id_attributes(root):
 *         python.PyDict_SetItem(dic, elem.get(u'id'), elem)
 *     return (root, dic)             # <<<<<<<<<<<<<<
 * 
 * def XMLDTDID(text):
 */
  __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_root);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_root);
  Py_INCREF(__pyx_v_dic);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_dic);
  __pyx_r = ((PyObject *)__pyx_4);
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree.XMLID");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_dic);
  Py_DECREF(__pyx_v_elem);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":23
 *     return (root, dic)
 * 
 * def XMLDTDID(text):             # <<<<<<<<<<<<<<
 *     u"""XMLDTDID(text)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_XMLDTDID(PyObject *__pyx_self, PyObject *__pyx_v_text); /*proto*/
static char __pyx_doc_4lxml_5etree_XMLDTDID[] = "XMLDTDID(text)\n\n    Parse the text and return a tuple (root node, ID dictionary).  The root\n    node is the same as returned by the XML() function.  The dictionary\n    contains string-element pairs.  The dictionary keys are the values of ID\n    attributes as defined by the DTD.  The elements referenced by the ID are\n    stored as dictionary values.\n\n    Note that you must not modify the XML tree if you use the ID dictionary.\n    The results are undefined.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_XMLDTDID(PyObject *__pyx_self, PyObject *__pyx_v_text) {
  struct LxmlElement *__pyx_v_root;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_self = __pyx_self;
  __pyx_v_root = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":36
 *     """
 *     cdef _Element root
 *     root = XML(text)             # <<<<<<<<<<<<<<
 *     # xml:id spec compatible implementation: use DTD ID attributes from libxml2
 *     if root._doc._c_doc.ids is NULL:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_XML); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_text);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_text);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root));
  __pyx_v_root = ((struct LxmlElement *)__pyx_3);
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":38
 *     root = XML(text)
 *     # xml:id spec compatible implementation: use DTD ID attributes from libxml2
 *     if root._doc._c_doc.ids is NULL:             # <<<<<<<<<<<<<<
 *         return (root, {})
 *     else:
 */
  __pyx_4 = (__pyx_v_root->_doc->_c_doc->ids == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":39
 *     # xml:id spec compatible implementation: use DTD ID attributes from libxml2
 *     if root._doc._c_doc.ids is NULL:
 *         return (root, {})             # <<<<<<<<<<<<<<
 *     else:
 *         return (root, _IDDict(root))
 */
    __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_1));
    __pyx_1 = 0;
    __pyx_r = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":41
 *         return (root, {})
 *     else:
 *         return (root, _IDDict(root))             # <<<<<<<<<<<<<<
 * 
 * def parseid(source, parser=None, *, base_url=None):
 */
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_root));
    __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__IDDict)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_1);
    __pyx_1 = 0;
    __pyx_r = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.XMLDTDID");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":43
 *         return (root, _IDDict(root))
 * 
 * def parseid(source, parser=None, *, base_url=None):             # <<<<<<<<<<<<<<
 *     u"""parseid(source, parser=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_parseid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_parseid[] = "parseid(source, parser=None)\n\n    Parses the source into a tuple containing an ElementTree object and an\n    ID dictionary.  If no parser is provided as second argument, the default\n    parser is used.\n\n    Note that you must not modify the XML tree if you use the ID dictionary.\n    The results are undefined.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_parseid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_parser = 0;
  PyObject *__pyx_v_base_url = 0;
  struct LxmlDocument *__pyx_v_doc;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_source,&__pyx_kp_parser,&__pyx_kp_base_url,0};
  __pyx_self = __pyx_self;
  __pyx_v_parser = Py_None;
  __pyx_v_base_url = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_source);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parseid") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_source = values[0];
    if (values[1]) {
      __pyx_v_parser = values[1];
    }
    if (values[2]) {
      __pyx_v_base_url = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_parser = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_source = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("parseid", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.parseid");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":54
 *     """
 *     cdef _Document doc
 *     doc = _parseDocument(source, parser, base_url)             # <<<<<<<<<<<<<<
 *     return (_elementTreeFactory(doc, None), _IDDict(doc))
 * 
 */
  if (!(__Pyx_TypeTest(__pyx_v_parser, __pyx_ptype_4lxml_5etree__BaseParser))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocument(__pyx_v_source, ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_v_base_url)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":55
 *     cdef _Document doc
 *     doc = _parseDocument(source, parser, base_url)
 *     return (_elementTreeFactory(doc, None), _IDDict(doc))             # <<<<<<<<<<<<<<
 * 
 * cdef class _IDDict:
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(__pyx_v_doc, ((struct LxmlElement *)Py_None))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_doc));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_doc));
  __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__IDDict)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  __pyx_1 = 0;
  __pyx_3 = 0;
  __pyx_r = ((PyObject *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.parseid");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":68
 *     cdef object _keys
 *     cdef object _items
 *     def __init__(self, etree):             # <<<<<<<<<<<<<<
 *         cdef _Document doc
 *         doc = _documentOrRaise(etree)
 */

static int __pyx_pf_4lxml_5etree_7_IDDict___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_7_IDDict___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  struct LxmlDocument *__pyx_v_doc;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._IDDict.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":70
 *     def __init__(self, etree):
 *         cdef _Document doc
 *         doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *         if doc._c_doc.ids is NULL:
 *             raise ValueError, u"No ID dictionary available."
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":71
 *         cdef _Document doc
 *         doc = _documentOrRaise(etree)
 *         if doc._c_doc.ids is NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"No ID dictionary available."
 *         self._doc = doc
 */
  __pyx_2 = (__pyx_v_doc->_c_doc->ids == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":72
 *         doc = _documentOrRaise(etree)
 *         if doc._c_doc.ids is NULL:
 *             raise ValueError, u"No ID dictionary available."             # <<<<<<<<<<<<<<
 *         self._doc = doc
 *         self._keys  = None
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_520), 0);
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":73
 *         if doc._c_doc.ids is NULL:
 *             raise ValueError, u"No ID dictionary available."
 *         self._doc = doc             # <<<<<<<<<<<<<<
 *         self._keys  = None
 *         self._items = None
 */
  Py_INCREF(((PyObject *)__pyx_v_doc));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc));
  ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc = __pyx_v_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":74
 *             raise ValueError, u"No ID dictionary available."
 *         self._doc = doc
 *         self._keys  = None             # <<<<<<<<<<<<<<
 *         self._items = None
 * 
 */
  Py_INCREF(Py_None);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys);
  ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":75
 *         self._doc = doc
 *         self._keys  = None
 *         self._items = None             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  Py_INCREF(Py_None);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items);
  ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items = Py_None;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IDDict.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":77
 *         self._items = None
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         return _IDDict(self._doc)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_copy(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_copy(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":78
 * 
 *     def copy(self):
 *         return _IDDict(self._doc)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, id_name):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc));
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__IDDict)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.copy");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":80
 *         return _IDDict(self._doc)
 * 
 *     def __getitem__(self, id_name):             # <<<<<<<<<<<<<<
 *         cdef tree.xmlHashTable* c_ids
 *         cdef tree.xmlID* c_id
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name) {
  xmlHashTable *__pyx_v_c_ids;
  xmlID *__pyx_v_c_id;
  xmlAttr *__pyx_v_c_attr;
  PyObject *__pyx_v_id_utf;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_id_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":84
 *         cdef tree.xmlID* c_id
 *         cdef xmlAttr* c_attr
 *         c_ids = self._doc._c_doc.ids             # <<<<<<<<<<<<<<
 *         id_utf = _utf8(id_name)
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _cstr(id_utf))
 */
  __pyx_v_c_ids = ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc->_c_doc->ids;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":85
 *         cdef xmlAttr* c_attr
 *         c_ids = self._doc._c_doc.ids
 *         id_utf = _utf8(id_name)             # <<<<<<<<<<<<<<
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _cstr(id_utf))
 *         if c_id is NULL:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_id_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_id_utf);
  __pyx_v_id_utf = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":86
 *         c_ids = self._doc._c_doc.ids
 *         id_utf = _utf8(id_name)
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _cstr(id_utf))             # <<<<<<<<<<<<<<
 *         if c_id is NULL:
 *             raise KeyError, u"key not found."
 */
  __pyx_v_c_id = ((xmlID *)xmlHashLookup(__pyx_v_c_ids, PyString_AS_STRING(__pyx_v_id_utf)));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":87
 *         id_utf = _utf8(id_name)
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _cstr(id_utf))
 *         if c_id is NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError, u"key not found."
 *         c_attr = c_id.attr
 */
  __pyx_2 = (__pyx_v_c_id == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":88
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _cstr(id_utf))
 *         if c_id is NULL:
 *             raise KeyError, u"key not found."             # <<<<<<<<<<<<<<
 *         c_attr = c_id.attr
 *         if c_attr is NULL or c_attr.parent is NULL:
 */
    __Pyx_Raise(__pyx_builtin_KeyError, ((PyObject *)__pyx_kp_521), 0);
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":89
 *         if c_id is NULL:
 *             raise KeyError, u"key not found."
 *         c_attr = c_id.attr             # <<<<<<<<<<<<<<
 *         if c_attr is NULL or c_attr.parent is NULL:
 *             raise KeyError, u"ID attribute not found."
 */
  __pyx_v_c_attr = __pyx_v_c_id->attr;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":90
 *             raise KeyError, u"key not found."
 *         c_attr = c_id.attr
 *         if c_attr is NULL or c_attr.parent is NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError, u"ID attribute not found."
 *         return _elementFactory(self._doc, c_attr.parent)
 */
  __pyx_2 = (__pyx_v_c_attr == NULL);
  if (!__pyx_2) {
    __pyx_2 = (__pyx_v_c_attr->parent == NULL);
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":91
 *         c_attr = c_id.attr
 *         if c_attr is NULL or c_attr.parent is NULL:
 *             raise KeyError, u"ID attribute not found."             # <<<<<<<<<<<<<<
 *         return _elementFactory(self._doc, c_attr.parent)
 * 
 */
    __Pyx_Raise(__pyx_builtin_KeyError, ((PyObject *)__pyx_kp_522), 0);
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":92
 *         if c_attr is NULL or c_attr.parent is NULL:
 *             raise KeyError, u"ID attribute not found."
 *         return _elementFactory(self._doc, c_attr.parent)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, id_name):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc, __pyx_v_c_attr->parent)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IDDict.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_id_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":94
 *         return _elementFactory(self._doc, c_attr.parent)
 * 
 *     def get(self, id_name):             # <<<<<<<<<<<<<<
 *         return self[id_name]
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_get(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_get(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":95
 * 
 *     def get(self, id_name):
 *         return self[id_name]             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, id_name):
 */
  __pyx_1 = PyObject_GetItem(__pyx_v_self, __pyx_v_id_name); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IDDict.get");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":97
 *         return self[id_name]
 * 
 *     def __contains__(self, id_name):             # <<<<<<<<<<<<<<
 *         cdef tree.xmlID* c_id
 *         id_utf = _utf8(id_name)
 */

static int __pyx_pf_4lxml_5etree_7_IDDict___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name); /*proto*/
static int __pyx_pf_4lxml_5etree_7_IDDict___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name) {
  xmlID *__pyx_v_c_id;
  PyObject *__pyx_v_id_utf;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_id_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":99
 *     def __contains__(self, id_name):
 *         cdef tree.xmlID* c_id
 *         id_utf = _utf8(id_name)             # <<<<<<<<<<<<<<
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(
 *             self._doc._c_doc.ids, _cstr(id_utf))
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_id_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_id_utf);
  __pyx_v_id_utf = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":101
 *         id_utf = _utf8(id_name)
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(
 *             self._doc._c_doc.ids, _cstr(id_utf))             # <<<<<<<<<<<<<<
 *         return c_id is not NULL
 * 
 */
  __pyx_v_c_id = ((xmlID *)xmlHashLookup(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_doc->_c_doc->ids, PyString_AS_STRING(__pyx_v_id_utf)));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":102
 *         c_id = <tree.xmlID*>tree.xmlHashLookup(
 *             self._doc._c_doc.ids, _cstr(id_utf))
 *         return c_id is not NULL             # <<<<<<<<<<<<<<
 * 
 *     def has_key(self, id_name):
 */
  __pyx_r = (__pyx_v_c_id != NULL);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IDDict.__contains__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_id_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":104
 *         return c_id is not NULL
 * 
 *     def has_key(self, id_name):             # <<<<<<<<<<<<<<
 *         return id_name in self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_has_key(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_has_key(PyObject *__pyx_v_self, PyObject *__pyx_v_id_name) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":105
 * 
 *     def has_key(self, id_name):
 *         return id_name in self             # <<<<<<<<<<<<<<
 * 
 *     def __cmp__(self, other):
 */
  __pyx_1 = (PySequence_Contains(__pyx_v_self, __pyx_v_id_name)); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyBool_FromLong(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.has_key");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":107
 *         return id_name in self
 * 
 *     def __cmp__(self, other):             # <<<<<<<<<<<<<<
 *         if other is None:
 *             return 1
 */

static int __pyx_pf_4lxml_5etree_7_IDDict___cmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static int __pyx_pf_4lxml_5etree_7_IDDict___cmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":108
 * 
 *     def __cmp__(self, other):
 *         if other is None:             # <<<<<<<<<<<<<<
 *             return 1
 *         else:
 */
  __pyx_1 = (__pyx_v_other == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":109
 *     def __cmp__(self, other):
 *         if other is None:
 *             return 1             # <<<<<<<<<<<<<<
 *         else:
 *             return cmp(dict(self), other)
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":111
 *             return 1
 *         else:
 *             return cmp(dict(self), other)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_other);
    __pyx_3 = 0;
    __pyx_3 = PyObject_Call(__pyx_builtin_cmp, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_4 = __pyx_PyInt_int(__pyx_3); if (unlikely((__pyx_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_r = __pyx_4;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._IDDict.__cmp__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":113
 *             return cmp(dict(self), other)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(dict(self))
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":114
 * 
 *     def __repr__(self):
 *         return repr(dict(self))             # <<<<<<<<<<<<<<
 * 
 *     def keys(self):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)&PyDict_Type)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_1 = PyObject_Repr(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":116
 *         return repr(dict(self))
 * 
 *     def keys(self):             # <<<<<<<<<<<<<<
 *         if self._keys is None:
 *             self._keys = self._build_keys()
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_keys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_keys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":117
 * 
 *     def keys(self):
 *         if self._keys is None:             # <<<<<<<<<<<<<<
 *             self._keys = self._build_keys()
 *         return self._keys[:]
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":118
 *     def keys(self):
 *         if self._keys is None:
 *             self._keys = self._build_keys()             # <<<<<<<<<<<<<<
 *         return self._keys[:]
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IDDict *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->__pyx_vtab)->_build_keys(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys);
    ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":119
 *         if self._keys is None:
 *             self._keys = self._build_keys()
 *         return self._keys[:]             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_2 = PySequence_GetSlice(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.keys");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":121
 *         return self._keys[:]
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self._keys is None:
 *             self._keys = self._build_keys()
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":122
 * 
 *     def __iter__(self):
 *         if self._keys is None:             # <<<<<<<<<<<<<<
 *             self._keys = self._build_keys()
 *         return iter(self._keys)
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":123
 *     def __iter__(self):
 *         if self._keys is None:
 *             self._keys = self._build_keys()             # <<<<<<<<<<<<<<
 *         return iter(self._keys)
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IDDict *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->__pyx_vtab)->_build_keys(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys);
    ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":124
 *         if self._keys is None:
 *             self._keys = self._build_keys()
 *         return iter(self._keys)             # <<<<<<<<<<<<<<
 * 
 *     def iterkeys(self):
 */
  __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.__iter__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":126
 *         return iter(self._keys)
 * 
 *     def iterkeys(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_iterkeys(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_iterkeys(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":127
 * 
 *     def iterkeys(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  Py_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":129
 *         return self
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self._keys is None:
 *             self._keys = self._build_keys()
 */

static Py_ssize_t __pyx_pf_4lxml_5etree_7_IDDict___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_4lxml_5etree_7_IDDict___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":130
 * 
 *     def __len__(self):
 *         if self._keys is None:             # <<<<<<<<<<<<<<
 *             self._keys = self._build_keys()
 *         return len(self._keys)
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":131
 *     def __len__(self):
 *         if self._keys is None:
 *             self._keys = self._build_keys()             # <<<<<<<<<<<<<<
 *         return len(self._keys)
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IDDict *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->__pyx_vtab)->_build_keys(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys);
    ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":132
 *         if self._keys is None:
 *             self._keys = self._build_keys()
 *         return len(self._keys)             # <<<<<<<<<<<<<<
 * 
 *     def items(self):
 */
  __pyx_3 = PyObject_Length(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_keys); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":134
 *         return len(self._keys)
 * 
 *     def items(self):             # <<<<<<<<<<<<<<
 *         if self._items is None:
 *             self._items = self._build_items()
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_items(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_items(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":135
 * 
 *     def items(self):
 *         if self._items is None:             # <<<<<<<<<<<<<<
 *             self._items = self._build_items()
 *         return self._items[:]
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":136
 *     def items(self):
 *         if self._items is None:
 *             self._items = self._build_items()             # <<<<<<<<<<<<<<
 *         return self._items[:]
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IDDict *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->__pyx_vtab)->_build_items(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items);
    ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":137
 *         if self._items is None:
 *             self._items = self._build_items()
 *         return self._items[:]             # <<<<<<<<<<<<<<
 * 
 *     def iteritems(self):
 */
  __pyx_2 = PySequence_GetSlice(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.items");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":139
 *         return self._items[:]
 * 
 *     def iteritems(self):             # <<<<<<<<<<<<<<
 *         if self._items is None:
 *             self._items = self._build_items()
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_iteritems(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_iteritems(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":140
 * 
 *     def iteritems(self):
 *         if self._items is None:             # <<<<<<<<<<<<<<
 *             self._items = self._build_items()
 *         return iter(self._items)
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":141
 *     def iteritems(self):
 *         if self._items is None:
 *             self._items = self._build_items()             # <<<<<<<<<<<<<<
 *         return iter(self._items)
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IDDict *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->__pyx_vtab)->_build_items(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items);
    ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":142
 *         if self._items is None:
 *             self._items = self._build_items()
 *         return iter(self._items)             # <<<<<<<<<<<<<<
 * 
 *     def values(self):
 */
  __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.iteritems");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":144
 *         return iter(self._items)
 * 
 *     def values(self):             # <<<<<<<<<<<<<<
 *         if self._items is None:
 *             self._items = self._build_items()
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_values(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_values(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_v_values;
  PyObject *__pyx_v_item;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  __pyx_v_values = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":145
 * 
 *     def values(self):
 *         if self._items is None:             # <<<<<<<<<<<<<<
 *             self._items = self._build_items()
 *         values = []
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":146
 *     def values(self):
 *         if self._items is None:
 *             self._items = self._build_items()             # <<<<<<<<<<<<<<
 *         values = []
 *         for item in self._items:
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__IDDict *)((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->__pyx_vtab)->_build_items(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items);
    ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":147
 *         if self._items is None:
 *             self._items = self._build_items()
 *         values = []             # <<<<<<<<<<<<<<
 *         for item in self._items:
 *             value = python.PyTuple_GET_ITEM(item, 1)
 */
  __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_values);
  __pyx_v_values = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":148
 *             self._items = self._build_items()
 *         values = []
 *         for item in self._items:             # <<<<<<<<<<<<<<
 *             value = python.PyTuple_GET_ITEM(item, 1)
 *             python.Py_INCREF(value)
 */
  if (PyList_CheckExact(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items) || PyTuple_CheckExact(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items)) {
    __pyx_3 = 0; __pyx_2 = ((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items; Py_INCREF(__pyx_2);
  } else {
    __pyx_3 = -1; __pyx_2 = PyObject_GetIter(((struct __pyx_obj_4lxml_5etree__IDDict *)__pyx_v_self)->_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_2);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":149
 *         values = []
 *         for item in self._items:
 *             value = python.PyTuple_GET_ITEM(item, 1)             # <<<<<<<<<<<<<<
 *             python.Py_INCREF(value)
 *             python.PyList_Append(values, value)
 */
    __pyx_4 = PyTuple_GET_ITEM(__pyx_v_item, 1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":150
 *         for item in self._items:
 *             value = python.PyTuple_GET_ITEM(item, 1)
 *             python.Py_INCREF(value)             # <<<<<<<<<<<<<<
 *             python.PyList_Append(values, value)
 *         return values
 */
    Py_INCREF(__pyx_v_value);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":151
 *             value = python.PyTuple_GET_ITEM(item, 1)
 *             python.Py_INCREF(value)
 *             python.PyList_Append(values, value)             # <<<<<<<<<<<<<<
 *         return values
 * 
 */
    __pyx_5 = PyList_Append(__pyx_v_values, __pyx_v_value); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":152
 *             python.Py_INCREF(value)
 *             python.PyList_Append(values, value)
 *         return values             # <<<<<<<<<<<<<<
 * 
 *     def itervalues(self):
 */
  Py_INCREF(__pyx_v_values);
  __pyx_r = __pyx_v_values;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._IDDict.values");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_values);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":154
 *         return values
 * 
 *     def itervalues(self):             # <<<<<<<<<<<<<<
 *         return iter(self.values())
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_itervalues(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_7_IDDict_itervalues(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":155
 * 
 *     def itervalues(self):
 *         return iter(self.values())             # <<<<<<<<<<<<<<
 * 
 *     cdef object _build_keys(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_values); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._IDDict.itervalues");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":157
 *         return iter(self.values())
 * 
 *     cdef object _build_keys(self):             # <<<<<<<<<<<<<<
 *         keys = []
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 */

static  PyObject *__pyx_f_4lxml_5etree_7_IDDict__build_keys(struct __pyx_obj_4lxml_5etree__IDDict *__pyx_v_self) {
  PyObject *__pyx_v_keys;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_keys = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":158
 * 
 *     cdef object _build_keys(self):
 *         keys = []             # <<<<<<<<<<<<<<
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 *                          _collectIdHashKeys, <python.PyObject*>keys)
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_keys);
  __pyx_v_keys = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":160
 *         keys = []
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 *                          _collectIdHashKeys, <python.PyObject*>keys)             # <<<<<<<<<<<<<<
 *         return keys
 * 
 */
  xmlHashScan(((xmlHashTable *)__pyx_v_self->_doc->_c_doc->ids), __pyx_f_4lxml_5etree__collectIdHashKeys, ((PyObject *)__pyx_v_keys));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":161
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 *                          _collectIdHashKeys, <python.PyObject*>keys)
 *         return keys             # <<<<<<<<<<<<<<
 * 
 *     cdef object _build_items(self):
 */
  Py_INCREF(__pyx_v_keys);
  __pyx_r = __pyx_v_keys;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IDDict._build_keys");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_keys);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":163
 *         return keys
 * 
 *     cdef object _build_items(self):             # <<<<<<<<<<<<<<
 *         items = []
 *         context = (items, self._doc)
 */

static  PyObject *__pyx_f_4lxml_5etree_7_IDDict__build_items(struct __pyx_obj_4lxml_5etree__IDDict *__pyx_v_self) {
  PyObject *__pyx_v_items;
  PyObject *__pyx_v_context;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_items = Py_None; Py_INCREF(Py_None);
  __pyx_v_context = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":164
 * 
 *     cdef object _build_items(self):
 *         items = []             # <<<<<<<<<<<<<<
 *         context = (items, self._doc)
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_items);
  __pyx_v_items = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":165
 *     cdef object _build_items(self):
 *         items = []
 *         context = (items, self._doc)             # <<<<<<<<<<<<<<
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 *                          _collectIdHashItemList, <python.PyObject*>context)
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_items);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_items);
  Py_INCREF(((PyObject *)__pyx_v_self->_doc));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_self->_doc));
  Py_DECREF(__pyx_v_context);
  __pyx_v_context = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":167
 *         context = (items, self._doc)
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 *                          _collectIdHashItemList, <python.PyObject*>context)             # <<<<<<<<<<<<<<
 *         return items
 * 
 */
  xmlHashScan(((xmlHashTable *)__pyx_v_self->_doc->_c_doc->ids), __pyx_f_4lxml_5etree__collectIdHashItemList, ((PyObject *)__pyx_v_context));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":168
 *         tree.xmlHashScan(<tree.xmlHashTable*>self._doc._c_doc.ids,
 *                          _collectIdHashItemList, <python.PyObject*>context)
 *         return items             # <<<<<<<<<<<<<<
 * 
 * cdef void _collectIdHashItemDict(void* payload, void* context, char* name):
 */
  Py_INCREF(__pyx_v_items);
  __pyx_r = __pyx_v_items;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._IDDict._build_items");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_items);
  Py_DECREF(__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":170
 *         return items
 * 
 * cdef void _collectIdHashItemDict(void* payload, void* context, char* name):             # <<<<<<<<<<<<<<
 *     # collect elements from ID attribute hash table
 *     cdef tree.xmlID* c_id
 */

static  void __pyx_f_4lxml_5etree__collectIdHashItemDict(void *__pyx_v_payload, void *__pyx_v_context, char *__pyx_v_name) {
  xmlID *__pyx_v_c_id;
  PyObject *__pyx_v_dic;
  PyObject *__pyx_v_doc;
  PyObject *__pyx_v_element;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_dic = Py_None; Py_INCREF(Py_None);
  __pyx_v_doc = Py_None; Py_INCREF(Py_None);
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":173
 *     # collect elements from ID attribute hash table
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload             # <<<<<<<<<<<<<<
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return
 */
  __pyx_v_c_id = ((xmlID *)__pyx_v_payload);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":174
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     dic, doc = <object>context
 */
  __pyx_1 = (__pyx_v_c_id == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c_id->attr == NULL);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_c_id->attr->parent == NULL);
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":175
 *     c_id = <tree.xmlID*>payload
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     dic, doc = <object>context
 *     element = _elementFactory(doc, c_id.attr.parent)
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":176
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return
 *     dic, doc = <object>context             # <<<<<<<<<<<<<<
 *     element = _elementFactory(doc, c_id.attr.parent)
 *     python.PyDict_SetItem(dic, funicode(name), element)
 */
  if (PyTuple_CheckExact(((PyObject *)__pyx_v_context)) && PyTuple_GET_SIZE(((PyObject *)__pyx_v_context)) == 2) {
    PyObject* tuple = ((PyObject *)__pyx_v_context);
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_dic);
    __pyx_v_dic = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_doc);
    __pyx_v_doc = __pyx_3;
    __pyx_3 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(((PyObject *)__pyx_v_context)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_dic);
    __pyx_v_dic = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_doc);
    __pyx_v_doc = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":177
 *         return
 *     dic, doc = <object>context
 *     element = _elementFactory(doc, c_id.attr.parent)             # <<<<<<<<<<<<<<
 *     python.PyDict_SetItem(dic, funicode(name), element)
 * 
 */
  if (!(__Pyx_TypeTest(__pyx_v_doc, __pyx_ptype_4lxml_5etree__Document))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlDocument *)__pyx_v_doc), __pyx_v_c_id->attr->parent)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_element);
  __pyx_v_element = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":178
 *     dic, doc = <object>context
 *     element = _elementFactory(doc, c_id.attr.parent)
 *     python.PyDict_SetItem(dic, funicode(name), element)             # <<<<<<<<<<<<<<
 * 
 * cdef void _collectIdHashItemList(void* payload, void* context, char* name):
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyDict_SetItem(__pyx_v_dic, __pyx_2, __pyx_v_element); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("lxml.etree._collectIdHashItemDict");
  __pyx_L0:;
  Py_DECREF(__pyx_v_dic);
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_element);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":180
 *     python.PyDict_SetItem(dic, funicode(name), element)
 * 
 * cdef void _collectIdHashItemList(void* payload, void* context, char* name):             # <<<<<<<<<<<<<<
 *     # collect elements from ID attribute hash table
 *     cdef tree.xmlID* c_id
 */

static  void __pyx_f_4lxml_5etree__collectIdHashItemList(void *__pyx_v_payload, void *__pyx_v_context, char *__pyx_v_name) {
  xmlID *__pyx_v_c_id;
  PyObject *__pyx_v_lst;
  PyObject *__pyx_v_doc;
  PyObject *__pyx_v_element;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_lst = Py_None; Py_INCREF(Py_None);
  __pyx_v_doc = Py_None; Py_INCREF(Py_None);
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":183
 *     # collect elements from ID attribute hash table
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload             # <<<<<<<<<<<<<<
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return
 */
  __pyx_v_c_id = ((xmlID *)__pyx_v_payload);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":184
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     lst, doc = <object>context
 */
  __pyx_1 = (__pyx_v_c_id == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c_id->attr == NULL);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_c_id->attr->parent == NULL);
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":185
 *     c_id = <tree.xmlID*>payload
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     lst, doc = <object>context
 *     element = _elementFactory(doc, c_id.attr.parent)
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":186
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return
 *     lst, doc = <object>context             # <<<<<<<<<<<<<<
 *     element = _elementFactory(doc, c_id.attr.parent)
 *     python.PyList_Append(lst, (funicode(name), element))
 */
  if (PyTuple_CheckExact(((PyObject *)__pyx_v_context)) && PyTuple_GET_SIZE(((PyObject *)__pyx_v_context)) == 2) {
    PyObject* tuple = ((PyObject *)__pyx_v_context);
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_lst);
    __pyx_v_lst = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_doc);
    __pyx_v_doc = __pyx_3;
    __pyx_3 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(((PyObject *)__pyx_v_context)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_lst);
    __pyx_v_lst = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_doc);
    __pyx_v_doc = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":187
 *         return
 *     lst, doc = <object>context
 *     element = _elementFactory(doc, c_id.attr.parent)             # <<<<<<<<<<<<<<
 *     python.PyList_Append(lst, (funicode(name), element))
 * 
 */
  if (!(__Pyx_TypeTest(__pyx_v_doc, __pyx_ptype_4lxml_5etree__Document))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct LxmlDocument *)__pyx_v_doc), __pyx_v_c_id->attr->parent)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_element);
  __pyx_v_element = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":188
 *     lst, doc = <object>context
 *     element = _elementFactory(doc, c_id.attr.parent)
 *     python.PyList_Append(lst, (funicode(name), element))             # <<<<<<<<<<<<<<
 * 
 * cdef void _collectIdHashKeys(void* payload, void* collect_list, char* name):
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  Py_INCREF(__pyx_v_element);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_element);
  __pyx_2 = 0;
  __pyx_4 = PyList_Append(__pyx_v_lst, ((PyObject *)__pyx_3)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("lxml.etree._collectIdHashItemList");
  __pyx_L0:;
  Py_DECREF(__pyx_v_lst);
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_element);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":190
 *     python.PyList_Append(lst, (funicode(name), element))
 * 
 * cdef void _collectIdHashKeys(void* payload, void* collect_list, char* name):             # <<<<<<<<<<<<<<
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload
 */

static  void __pyx_f_4lxml_5etree__collectIdHashKeys(void *__pyx_v_payload, void *__pyx_v_collect_list, char *__pyx_v_name) {
  xmlID *__pyx_v_c_id;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":192
 * cdef void _collectIdHashKeys(void* payload, void* collect_list, char* name):
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload             # <<<<<<<<<<<<<<
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return
 */
  __pyx_v_c_id = ((xmlID *)__pyx_v_payload);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":193
 *     cdef tree.xmlID* c_id
 *     c_id = <tree.xmlID*>payload
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:             # <<<<<<<<<<<<<<
 *         return
 *     python.PyList_Append(<object>collect_list, funicode(name))
 */
  __pyx_1 = (__pyx_v_c_id == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_c_id->attr == NULL);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_c_id->attr->parent == NULL);
    }
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":194
 *     c_id = <tree.xmlID*>payload
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return             # <<<<<<<<<<<<<<
 *     python.PyList_Append(<object>collect_list, funicode(name))
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlid.pxi":195
 *     if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
 *         return
 *     python.PyList_Append(<object>collect_list, funicode(name))             # <<<<<<<<<<<<<<
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyList_Append(((PyObject *)__pyx_v_collect_list), __pyx_2); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._collectIdHashKeys");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":18
 *     """
 *     cdef _ErrorLog _error_log
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._error_log = _ErrorLog()
 * 
 */

static int __pyx_pf_4lxml_5etree_8XInclude___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_8XInclude___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":19
 *     cdef _ErrorLog _error_log
 *     def __init__(self):
 *         self._error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 * 
 *     property error_log:
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log));
  ((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_1);
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XInclude.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":22
 * 
 *     property error_log:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._error_log.copy()
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_8XInclude_9error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_8XInclude_9error_log___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":23
 *     property error_log:
 *         def __get__(self):
 *             return self._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, _Element node not None):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XInclude.error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":25
 *             return self._error_log.copy()
 * 
 *     def __call__(self, _Element node not None):             # <<<<<<<<<<<<<<
 *         u"__call__(self, node)"
 *         # We cannot pass the XML_PARSE_NOXINCNODE option as this would free
 */

static PyObject *__pyx_pf_4lxml_5etree_8XInclude___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_8XInclude___call__[] = "__call__(self, node)";
static PyObject *__pyx_pf_4lxml_5etree_8XInclude___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_node = 0;
  int __pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_node,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_node);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_node = ((struct LxmlElement *)values[0]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_node = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[15]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XInclude.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_node), __pyx_ptype_4lxml_5etree__Element, 0, "node", 0))) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":35
 *         # i.e. as a sibling, which does not conflict with traversal.
 *         cdef int result
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         __GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(
 *             node._doc._parser)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":37
 *         self._error_log.connect()
 *         __GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(
 *             node._doc._parser)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             if node._doc._parser is not None:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->pushImpliedContextFromParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_node->_doc->_parser);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":38
 *         __GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(
 *             node._doc._parser)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if node._doc._parser is not None:
 *                 result = xinclude.xmlXIncludeProcessTreeFlags(
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":39
 *             node._doc._parser)
 *         with nogil:
 *             if node._doc._parser is not None:             # <<<<<<<<<<<<<<
 *                 result = xinclude.xmlXIncludeProcessTreeFlags(
 *                     node._c_node, node._doc._parser._parse_options)
 */
      __pyx_1 = (((PyObject *)__pyx_v_node->_doc->_parser) != Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":41
 *             if node._doc._parser is not None:
 *                 result = xinclude.xmlXIncludeProcessTreeFlags(
 *                     node._c_node, node._doc._parser._parse_options)             # <<<<<<<<<<<<<<
 *             else:
 *                 result = xinclude.xmlXIncludeProcessTree(node._c_node)
 */
        __pyx_v_result = xmlXIncludeProcessTreeFlags(__pyx_v_node->_c_node, __pyx_v_node->_doc->_parser->_parse_options);
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":43
 *                     node._c_node, node._doc._parser._parse_options)
 *             else:
 *                 result = xinclude.xmlXIncludeProcessTree(node._c_node)             # <<<<<<<<<<<<<<
 *         __GLOBAL_PARSER_CONTEXT.popImpliedContext()
 *         self._error_log.disconnect()
 */
        __pyx_v_result = xmlXIncludeProcessTree(__pyx_v_node->_c_node);
      }
      __pyx_L9:;
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":44
 *             else:
 *                 result = xinclude.xmlXIncludeProcessTree(node._c_node)
 *         __GLOBAL_PARSER_CONTEXT.popImpliedContext()             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->popImpliedContext(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":45
 *                 result = xinclude.xmlXIncludeProcessTree(node._c_node)
 *         __GLOBAL_PARSER_CONTEXT.popImpliedContext()
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         if result == -1:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":47
 *         self._error_log.disconnect()
 * 
 *         if result == -1:             # <<<<<<<<<<<<<<
 *             raise XIncludeError(
 *                 self._error_log._buildExceptionMessage(
 */
  __pyx_1 = (__pyx_v_result == -1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":48
 * 
 *         if result == -1:
 *             raise XIncludeError(             # <<<<<<<<<<<<<<
 *                 self._error_log._buildExceptionMessage(
 *                     u"XInclude processing failed"),
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XIncludeError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":50
 *             raise XIncludeError(
 *                 self._error_log._buildExceptionMessage(
 *                     u"XInclude processing failed"),             # <<<<<<<<<<<<<<
 *                 self._error_log)
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log), ((PyObject *)__pyx_kp_523)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":51
 *                 self._error_log._buildExceptionMessage(
 *                     u"XInclude processing failed"),
 *                 self._error_log)             # <<<<<<<<<<<<<<
 */
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_XInclude *)__pyx_v_self)->_error_log));
    __pyx_3 = 0;
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.XInclude.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":45
 *     cdef _ExceptionContext _exc
 * 
 *     def __init__(self, namespaces, extensions, enable_regexp,             # <<<<<<<<<<<<<<
 *                  build_smart_strings):
 *         cdef _ExsltRegExp _regexp
 */

static int __pyx_pf_4lxml_5etree_12_BaseContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_12_BaseContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_enable_regexp = 0;
  PyObject *__pyx_v_build_smart_strings = 0;
  struct __pyx_obj_4lxml_5etree__ExsltRegExp *__pyx_v__regexp;
  PyObject *__pyx_v_new_extensions;
  PyObject *__pyx_v_extension;
  PyObject *__pyx_v_ns_uri;
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_function;
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_v_ns;
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_v_prefix_utf;
  PyObject *__pyx_v_ns_uri_utf;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  int __pyx_11;
  int __pyx_12;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_enable_regexp,&__pyx_kp_build_smart_strings,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_namespaces);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_extensions);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_enable_regexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_build_smart_strings);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_namespaces = values[0];
    __pyx_v_extensions = values[1];
    __pyx_v_enable_regexp = values[2];
    __pyx_v_build_smart_strings = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_namespaces = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_extensions = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_enable_regexp = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_build_smart_strings = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._BaseContext.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_namespaces);
  Py_INCREF(__pyx_v_extensions);
  __pyx_v__regexp = ((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)Py_None); Py_INCREF(Py_None);
  __pyx_v_new_extensions = Py_None; Py_INCREF(Py_None);
  __pyx_v_extension = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_uri = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_function = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_uri_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":48
 *                  build_smart_strings):
 *         cdef _ExsltRegExp _regexp
 *         self._utf_refs = {}             # <<<<<<<<<<<<<<
 *         self._global_namespaces = []
 *         self._function_cache = {}
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_utf_refs);
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_utf_refs = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":49
 *         cdef _ExsltRegExp _regexp
 *         self._utf_refs = {}
 *         self._global_namespaces = []             # <<<<<<<<<<<<<<
 *         self._function_cache = {}
 *         self._eval_context_dict = None
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_global_namespaces);
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_global_namespaces = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":50
 *         self._utf_refs = {}
 *         self._global_namespaces = []
 *         self._function_cache = {}             # <<<<<<<<<<<<<<
 *         self._eval_context_dict = None
 * 
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_function_cache);
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_function_cache = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":51
 *         self._global_namespaces = []
 *         self._function_cache = {}
 *         self._eval_context_dict = None             # <<<<<<<<<<<<<<
 * 
 *         if extensions is not None:
 */
  Py_INCREF(Py_None);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict);
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":53
 *         self._eval_context_dict = None
 * 
 *         if extensions is not None:             # <<<<<<<<<<<<<<
 *             # convert extensions to UTF-8
 *             if python.PyDict_Check(extensions):
 */
  __pyx_2 = (__pyx_v_extensions != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":55
 *         if extensions is not None:
 *             # convert extensions to UTF-8
 *             if python.PyDict_Check(extensions):             # <<<<<<<<<<<<<<
 *                 extensions = (extensions,)
 *             # format: [ {(ns, name):function} ] -> {(ns_utf, name_utf):function}
 */
    __pyx_2 = PyDict_Check(__pyx_v_extensions);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":56
 *             # convert extensions to UTF-8
 *             if python.PyDict_Check(extensions):
 *                 extensions = (extensions,)             # <<<<<<<<<<<<<<
 *             # format: [ {(ns, name):function} ] -> {(ns_utf, name_utf):function}
 *             new_extensions = {}
 */
      __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_extensions);
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_extensions);
      Py_DECREF(__pyx_v_extensions);
      __pyx_v_extensions = ((PyObject *)__pyx_1);
      __pyx_1 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":58
 *                 extensions = (extensions,)
 *             # format: [ {(ns, name):function} ] -> {(ns_utf, name_utf):function}
 *             new_extensions = {}             # <<<<<<<<<<<<<<
 *             for extension in extensions:
 *                 for (ns_uri, name), function in extension.items():
 */
    __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_new_extensions);
    __pyx_v_new_extensions = ((PyObject *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":59
 *             # format: [ {(ns, name):function} ] -> {(ns_utf, name_utf):function}
 *             new_extensions = {}
 *             for extension in extensions:             # <<<<<<<<<<<<<<
 *                 for (ns_uri, name), function in extension.items():
 *                     if name is None:
 */
    if (PyList_CheckExact(__pyx_v_extensions) || PyTuple_CheckExact(__pyx_v_extensions)) {
      __pyx_3 = 0; __pyx_1 = __pyx_v_extensions; Py_INCREF(__pyx_1);
    } else {
      __pyx_3 = -1; __pyx_1 = PyObject_GetIter(__pyx_v_extensions); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_1))) {
        if (__pyx_3 >= PyList_GET_SIZE(__pyx_1)) break;
        __pyx_4 = PyList_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else if (likely(PyTuple_CheckExact(__pyx_1))) {
        if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_1)) break;
        __pyx_4 = PyTuple_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else {
        __pyx_4 = PyIter_Next(__pyx_1);
        if (!__pyx_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_extension);
      __pyx_v_extension = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":60
 *             new_extensions = {}
 *             for extension in extensions:
 *                 for (ns_uri, name), function in extension.items():             # <<<<<<<<<<<<<<
 *                     if name is None:
 *                         raise ValueError, u"extensions must have non empty names"
 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_extension, __pyx_kp_items); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_6 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (PyList_CheckExact(__pyx_6) || PyTuple_CheckExact(__pyx_6)) {
        __pyx_5 = 0; __pyx_4 = __pyx_6; Py_INCREF(__pyx_4);
      } else {
        __pyx_5 = -1; __pyx_4 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_4))) {
          if (__pyx_5 >= PyList_GET_SIZE(__pyx_4)) break;
          __pyx_6 = PyList_GET_ITEM(__pyx_4, __pyx_5); Py_INCREF(__pyx_6); __pyx_5++;
        } else if (likely(PyTuple_CheckExact(__pyx_4))) {
          if (__pyx_5 >= PyTuple_GET_SIZE(__pyx_4)) break;
          __pyx_6 = PyTuple_GET_ITEM(__pyx_4, __pyx_5); Py_INCREF(__pyx_6); __pyx_5++;
        } else {
          __pyx_6 = PyIter_Next(__pyx_4);
          if (!__pyx_6) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        if (PyTuple_CheckExact(__pyx_6) && PyTuple_GET_SIZE(__pyx_6) == 2) {
          PyObject* tuple = __pyx_6;
          __pyx_8 = PyTuple_GET_ITEM(tuple, 0);
          Py_INCREF(__pyx_8);
          if (PyTuple_CheckExact(__pyx_8) && PyTuple_GET_SIZE(__pyx_8) == 2) {
            PyObject* tuple = __pyx_8;
            __pyx_10 = PyTuple_GET_ITEM(tuple, 0);
            Py_INCREF(__pyx_10);
            Py_DECREF(__pyx_v_ns_uri);
            __pyx_v_ns_uri = __pyx_10;
            __pyx_10 = 0;
            __pyx_10 = PyTuple_GET_ITEM(tuple, 1);
            Py_INCREF(__pyx_10);
            Py_DECREF(__pyx_v_name);
            __pyx_v_name = __pyx_10;
            __pyx_10 = 0;
            Py_DECREF(__pyx_8); __pyx_8 = 0;
          }
          else {
            __pyx_9 = PyObject_GetIter(__pyx_8); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_8); __pyx_8 = 0;
            __pyx_10 = __Pyx_UnpackItem(__pyx_9, 0); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_v_ns_uri);
            __pyx_v_ns_uri = __pyx_10;
            __pyx_10 = 0;
            __pyx_10 = __Pyx_UnpackItem(__pyx_9, 1); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_v_name);
            __pyx_v_name = __pyx_10;
            __pyx_10 = 0;
            if (__Pyx_EndUnpack(__pyx_9) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_9); __pyx_9 = 0;
          }
          __pyx_10 = PyTuple_GET_ITEM(tuple, 1);
          Py_INCREF(__pyx_10);
          Py_DECREF(__pyx_v_function);
          __pyx_v_function = __pyx_10;
          __pyx_10 = 0;
          Py_DECREF(__pyx_6); __pyx_6 = 0;
        }
        else {
          __pyx_7 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __pyx_8 = __Pyx_UnpackItem(__pyx_7, 0); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          if (PyTuple_CheckExact(__pyx_8) && PyTuple_GET_SIZE(__pyx_8) == 2) {
            PyObject* tuple = __pyx_8;
            __pyx_10 = PyTuple_GET_ITEM(tuple, 0);
            Py_INCREF(__pyx_10);
            Py_DECREF(__pyx_v_ns_uri);
            __pyx_v_ns_uri = __pyx_10;
            __pyx_10 = 0;
            __pyx_10 = PyTuple_GET_ITEM(tuple, 1);
            Py_INCREF(__pyx_10);
            Py_DECREF(__pyx_v_name);
            __pyx_v_name = __pyx_10;
            __pyx_10 = 0;
            Py_DECREF(__pyx_8); __pyx_8 = 0;
          }
          else {
            __pyx_9 = PyObject_GetIter(__pyx_8); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_8); __pyx_8 = 0;
            __pyx_10 = __Pyx_UnpackItem(__pyx_9, 0); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_v_ns_uri);
            __pyx_v_ns_uri = __pyx_10;
            __pyx_10 = 0;
            __pyx_10 = __Pyx_UnpackItem(__pyx_9, 1); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_v_name);
            __pyx_v_name = __pyx_10;
            __pyx_10 = 0;
            if (__Pyx_EndUnpack(__pyx_9) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            Py_DECREF(__pyx_9); __pyx_9 = 0;
          }
          __pyx_10 = __Pyx_UnpackItem(__pyx_7, 1); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_function);
          __pyx_v_function = __pyx_10;
          __pyx_10 = 0;
          if (__Pyx_EndUnpack(__pyx_7) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":61
 *             for extension in extensions:
 *                 for (ns_uri, name), function in extension.items():
 *                     if name is None:             # <<<<<<<<<<<<<<
 *                         raise ValueError, u"extensions must have non empty names"
 *                     ns_utf   = self._to_utf(ns_uri)
 */
        __pyx_2 = (__pyx_v_name == Py_None);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":62
 *                 for (ns_uri, name), function in extension.items():
 *                     if name is None:
 *                         raise ValueError, u"extensions must have non empty names"             # <<<<<<<<<<<<<<
 *                     ns_utf   = self._to_utf(ns_uri)
 *                     name_utf = self._to_utf(name)
 */
          __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_524), 0);
          {__pyx_filename = __pyx_f[5]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L12;
        }
        __pyx_L12:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":63
 *                     if name is None:
 *                         raise ValueError, u"extensions must have non empty names"
 *                     ns_utf   = self._to_utf(ns_uri)             # <<<<<<<<<<<<<<
 *                     name_utf = self._to_utf(name)
 *                     python.PyDict_SetItem(
 */
        __pyx_8 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->__pyx_vtab)->_to_utf(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_ns_uri); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_ns_utf);
        __pyx_v_ns_utf = __pyx_8;
        __pyx_8 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":64
 *                         raise ValueError, u"extensions must have non empty names"
 *                     ns_utf   = self._to_utf(ns_uri)
 *                     name_utf = self._to_utf(name)             # <<<<<<<<<<<<<<
 *                     python.PyDict_SetItem(
 *                         new_extensions, (ns_utf, name_utf), function)
 */
        __pyx_9 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->__pyx_vtab)->_to_utf(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_name); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_9;
        __pyx_9 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":66
 *                     name_utf = self._to_utf(name)
 *                     python.PyDict_SetItem(
 *                         new_extensions, (ns_utf, name_utf), function)             # <<<<<<<<<<<<<<
 *             extensions = new_extensions or None
 * 
 */
        __pyx_10 = PyTuple_New(2); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_ns_utf);
        PyTuple_SET_ITEM(__pyx_10, 0, __pyx_v_ns_utf);
        Py_INCREF(__pyx_v_name_utf);
        PyTuple_SET_ITEM(__pyx_10, 1, __pyx_v_name_utf);
        __pyx_11 = PyDict_SetItem(__pyx_v_new_extensions, ((PyObject *)__pyx_10), __pyx_v_function); if (unlikely(__pyx_11 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_10)); __pyx_10 = 0;
      }
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":67
 *                     python.PyDict_SetItem(
 *                         new_extensions, (ns_utf, name_utf), function)
 *             extensions = new_extensions or None             # <<<<<<<<<<<<<<
 * 
 *         if namespaces is not None:
 */
    __pyx_6 = __pyx_v_new_extensions;
    Py_INCREF(__pyx_6);
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!__pyx_2) {
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_6 = Py_None;
      Py_INCREF(__pyx_6);
    }
    Py_DECREF(__pyx_v_extensions);
    __pyx_v_extensions = __pyx_6;
    __pyx_6 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":69
 *             extensions = new_extensions or None
 * 
 *         if namespaces is not None:             # <<<<<<<<<<<<<<
 *             if python.PyDict_Check(namespaces):
 *                 namespaces = namespaces.items()
 */
  __pyx_2 = (__pyx_v_namespaces != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":70
 * 
 *         if namespaces is not None:
 *             if python.PyDict_Check(namespaces):             # <<<<<<<<<<<<<<
 *                 namespaces = namespaces.items()
 *             if namespaces:
 */
    __pyx_2 = PyDict_Check(__pyx_v_namespaces);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":71
 *         if namespaces is not None:
 *             if python.PyDict_Check(namespaces):
 *                 namespaces = namespaces.items()             # <<<<<<<<<<<<<<
 *             if namespaces:
 *                 ns = []
 */
      __pyx_7 = PyObject_GetAttr(__pyx_v_namespaces, __pyx_kp_items); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_8 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_v_namespaces);
      __pyx_v_namespaces = __pyx_8;
      __pyx_8 = 0;
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":72
 *             if python.PyDict_Check(namespaces):
 *                 namespaces = namespaces.items()
 *             if namespaces:             # <<<<<<<<<<<<<<
 *                 ns = []
 *                 for prefix, ns_uri in namespaces:
 */
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_namespaces); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":73
 *                 namespaces = namespaces.items()
 *             if namespaces:
 *                 ns = []             # <<<<<<<<<<<<<<
 *                 for prefix, ns_uri in namespaces:
 *                     if prefix is None or not prefix:
 */
      __pyx_9 = PyList_New(0); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns);
      __pyx_v_ns = ((PyObject *)__pyx_9);
      __pyx_9 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":74
 *             if namespaces:
 *                 ns = []
 *                 for prefix, ns_uri in namespaces:             # <<<<<<<<<<<<<<
 *                     if prefix is None or not prefix:
 *                         raise TypeError, \
 */
      if (PyList_CheckExact(__pyx_v_namespaces) || PyTuple_CheckExact(__pyx_v_namespaces)) {
        __pyx_5 = 0; __pyx_10 = __pyx_v_namespaces; Py_INCREF(__pyx_10);
      } else {
        __pyx_5 = -1; __pyx_10 = PyObject_GetIter(__pyx_v_namespaces); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_10))) {
          if (__pyx_5 >= PyList_GET_SIZE(__pyx_10)) break;
          __pyx_4 = PyList_GET_ITEM(__pyx_10, __pyx_5); Py_INCREF(__pyx_4); __pyx_5++;
        } else if (likely(PyTuple_CheckExact(__pyx_10))) {
          if (__pyx_5 >= PyTuple_GET_SIZE(__pyx_10)) break;
          __pyx_4 = PyTuple_GET_ITEM(__pyx_10, __pyx_5); Py_INCREF(__pyx_4); __pyx_5++;
        } else {
          __pyx_4 = PyIter_Next(__pyx_10);
          if (!__pyx_4) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        if (PyTuple_CheckExact(__pyx_4) && PyTuple_GET_SIZE(__pyx_4) == 2) {
          PyObject* tuple = __pyx_4;
          __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
          Py_INCREF(__pyx_6);
          Py_DECREF(__pyx_v_prefix);
          __pyx_v_prefix = __pyx_6;
          __pyx_6 = 0;
          __pyx_7 = PyTuple_GET_ITEM(tuple, 1);
          Py_INCREF(__pyx_7);
          Py_DECREF(__pyx_v_ns_uri);
          __pyx_v_ns_uri = __pyx_7;
          __pyx_7 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
        }
        else {
          __pyx_1 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_6 = __Pyx_UnpackItem(__pyx_1, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_prefix);
          __pyx_v_prefix = __pyx_6;
          __pyx_6 = 0;
          __pyx_7 = __Pyx_UnpackItem(__pyx_1, 1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_ns_uri);
          __pyx_v_ns_uri = __pyx_7;
          __pyx_7 = 0;
          if (__Pyx_EndUnpack(__pyx_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":75
 *                 ns = []
 *                 for prefix, ns_uri in namespaces:
 *                     if prefix is None or not prefix:             # <<<<<<<<<<<<<<
 *                         raise TypeError, \
 *                             u"empty namespace prefix is not supported in XPath"
 */
        __pyx_2 = (__pyx_v_prefix == Py_None);
        if (!__pyx_2) {
          __pyx_12 = __Pyx_PyObject_IsTrue(__pyx_v_prefix); if (unlikely(__pyx_12 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_2 = (!__pyx_12);
        }
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":77
 *                     if prefix is None or not prefix:
 *                         raise TypeError, \
 *                             u"empty namespace prefix is not supported in XPath"             # <<<<<<<<<<<<<<
 *                     if ns_uri is None or not ns_uri:
 *                         raise TypeError, \
 */
          __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_525), 0);
          {__pyx_filename = __pyx_f[5]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L18;
        }
        __pyx_L18:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":78
 *                         raise TypeError, \
 *                             u"empty namespace prefix is not supported in XPath"
 *                     if ns_uri is None or not ns_uri:             # <<<<<<<<<<<<<<
 *                         raise TypeError, \
 *                             u"setting default namespace is not supported in XPath"
 */
        __pyx_12 = (__pyx_v_ns_uri == Py_None);
        if (!__pyx_12) {
          __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_ns_uri); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_12 = (!__pyx_2);
        }
        if (__pyx_12) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":80
 *                     if ns_uri is None or not ns_uri:
 *                         raise TypeError, \
 *                             u"setting default namespace is not supported in XPath"             # <<<<<<<<<<<<<<
 *                     prefix_utf = self._to_utf(prefix)
 *                     ns_uri_utf = self._to_utf(ns_uri)
 */
          __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_526), 0);
          {__pyx_filename = __pyx_f[5]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L19;
        }
        __pyx_L19:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":81
 *                         raise TypeError, \
 *                             u"setting default namespace is not supported in XPath"
 *                     prefix_utf = self._to_utf(prefix)             # <<<<<<<<<<<<<<
 *                     ns_uri_utf = self._to_utf(ns_uri)
 *                     python.PyList_Append(ns, (prefix_utf, ns_uri_utf))
 */
        __pyx_8 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->__pyx_vtab)->_to_utf(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_prefix); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_prefix_utf);
        __pyx_v_prefix_utf = __pyx_8;
        __pyx_8 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":82
 *                             u"setting default namespace is not supported in XPath"
 *                     prefix_utf = self._to_utf(prefix)
 *                     ns_uri_utf = self._to_utf(ns_uri)             # <<<<<<<<<<<<<<
 *                     python.PyList_Append(ns, (prefix_utf, ns_uri_utf))
 *                 namespaces = ns
 */
        __pyx_9 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->__pyx_vtab)->_to_utf(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_ns_uri); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_ns_uri_utf);
        __pyx_v_ns_uri_utf = __pyx_9;
        __pyx_9 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":83
 *                     prefix_utf = self._to_utf(prefix)
 *                     ns_uri_utf = self._to_utf(ns_uri)
 *                     python.PyList_Append(ns, (prefix_utf, ns_uri_utf))             # <<<<<<<<<<<<<<
 *                 namespaces = ns
 *             else:
 */
        __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_prefix_utf);
        PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_prefix_utf);
        Py_INCREF(__pyx_v_ns_uri_utf);
        PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_ns_uri_utf);
        __pyx_11 = PyList_Append(__pyx_v_ns, ((PyObject *)__pyx_6)); if (unlikely(__pyx_11 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      }
      Py_DECREF(__pyx_10); __pyx_10 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":84
 *                     ns_uri_utf = self._to_utf(ns_uri)
 *                     python.PyList_Append(ns, (prefix_utf, ns_uri_utf))
 *                 namespaces = ns             # <<<<<<<<<<<<<<
 *             else:
 *                 namespaces = None
 */
      Py_INCREF(__pyx_v_ns);
      Py_DECREF(__pyx_v_namespaces);
      __pyx_v_namespaces = __pyx_v_ns;
      goto __pyx_L15;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":86
 *                 namespaces = ns
 *             else:
 *                 namespaces = None             # <<<<<<<<<<<<<<
 * 
 *         self._doc        = None
 */
      Py_INCREF(Py_None);
      Py_DECREF(__pyx_v_namespaces);
      __pyx_v_namespaces = Py_None;
    }
    __pyx_L15:;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":88
 *                 namespaces = None
 * 
 *         self._doc        = None             # <<<<<<<<<<<<<<
 *         self._exc        = _ExceptionContext()
 *         self._extensions = extensions
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_doc));
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_doc = ((struct LxmlDocument *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":89
 * 
 *         self._doc        = None
 *         self._exc        = _ExceptionContext()             # <<<<<<<<<<<<<<
 *         self._extensions = extensions
 *         self._namespaces = namespaces
 */
  __pyx_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ExceptionContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_7, __pyx_ptype_4lxml_5etree__ExceptionContext))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_exc));
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_exc = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_7);
  __pyx_7 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":90
 *         self._doc        = None
 *         self._exc        = _ExceptionContext()
 *         self._extensions = extensions             # <<<<<<<<<<<<<<
 *         self._namespaces = namespaces
 *         self._temp_refs  = _TempStore()
 */
  Py_INCREF(__pyx_v_extensions);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_extensions);
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_extensions = __pyx_v_extensions;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":91
 *         self._exc        = _ExceptionContext()
 *         self._extensions = extensions
 *         self._namespaces = namespaces             # <<<<<<<<<<<<<<
 *         self._temp_refs  = _TempStore()
 *         self._build_smart_strings = build_smart_strings
 */
  Py_INCREF(__pyx_v_namespaces);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_namespaces);
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_namespaces = __pyx_v_namespaces;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":92
 *         self._extensions = extensions
 *         self._namespaces = namespaces
 *         self._temp_refs  = _TempStore()             # <<<<<<<<<<<<<<
 *         self._build_smart_strings = build_smart_strings
 * 
 */
  __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__TempStore)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__TempStore))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_temp_refs));
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_temp_refs = ((struct __pyx_obj_4lxml_5etree__TempStore *)__pyx_4);
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":93
 *         self._namespaces = namespaces
 *         self._temp_refs  = _TempStore()
 *         self._build_smart_strings = build_smart_strings             # <<<<<<<<<<<<<<
 * 
 *         if enable_regexp:
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_build_smart_strings); if (unlikely((__pyx_2 == (int)-1))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_build_smart_strings = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":95
 *         self._build_smart_strings = build_smart_strings
 * 
 *         if enable_regexp:             # <<<<<<<<<<<<<<
 *             _regexp = _ExsltRegExp()
 *             _regexp._register_in_context(self)
 */
  __pyx_12 = __Pyx_PyObject_IsTrue(__pyx_v_enable_regexp); if (unlikely(__pyx_12 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_12) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":96
 * 
 *         if enable_regexp:
 *             _regexp = _ExsltRegExp()             # <<<<<<<<<<<<<<
 *             _regexp._register_in_context(self)
 * 
 */
    __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ExsltRegExp)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ExsltRegExp))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v__regexp));
    __pyx_v__regexp = ((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":97
 *         if enable_regexp:
 *             _regexp = _ExsltRegExp()
 *             _regexp._register_in_context(self)             # <<<<<<<<<<<<<<
 * 
 *     cdef _BaseContext _copy(self):
 */
    __pyx_8 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)__pyx_v__regexp->__pyx_vtab)->_register_in_context(__pyx_v__regexp, ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_8); __pyx_8 = 0;
    goto __pyx_L20;
  }
  __pyx_L20:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  __Pyx_AddTraceback("lxml.etree._BaseContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v__regexp);
  Py_DECREF(__pyx_v_new_extensions);
  Py_DECREF(__pyx_v_extension);
  Py_DECREF(__pyx_v_ns_uri);
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_function);
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_name_utf);
  Py_DECREF(__pyx_v_ns);
  Py_DECREF(__pyx_v_prefix);
  Py_DECREF(__pyx_v_prefix_utf);
  Py_DECREF(__pyx_v_ns_uri_utf);
  Py_DECREF(__pyx_v_namespaces);
  Py_DECREF(__pyx_v_extensions);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":99
 *             _regexp._register_in_context(self)
 * 
 *     cdef _BaseContext _copy(self):             # <<<<<<<<<<<<<<
 *         cdef _BaseContext context
 *         if self._namespaces is not None:
 */

static  struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_BaseContext__copy(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_context;
  PyObject *__pyx_v_namespaces;
  struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__BaseContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_namespaces = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":101
 *     cdef _BaseContext _copy(self):
 *         cdef _BaseContext context
 *         if self._namespaces is not None:             # <<<<<<<<<<<<<<
 *             namespaces = self._namespaces[:]
 *         context = self.__class__(namespaces, None, False,
 */
  __pyx_1 = (__pyx_v_self->_namespaces != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":102
 *         cdef _BaseContext context
 *         if self._namespaces is not None:
 *             namespaces = self._namespaces[:]             # <<<<<<<<<<<<<<
 *         context = self.__class__(namespaces, None, False,
 *                                  self._build_smart_strings)
 */
    __pyx_2 = PySequence_GetSlice(__pyx_v_self->_namespaces, 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_namespaces);
    __pyx_v_namespaces = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":103
 *         if self._namespaces is not None:
 *             namespaces = self._namespaces[:]
 *         context = self.__class__(namespaces, None, False,             # <<<<<<<<<<<<<<
 *                                  self._build_smart_strings)
 *         if self._extensions is not None:
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp___class__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":104
 *             namespaces = self._namespaces[:]
 *         context = self.__class__(namespaces, None, False,
 *                                  self._build_smart_strings)             # <<<<<<<<<<<<<<
 *         if self._extensions is not None:
 *             context._extensions = python.PyDict_Copy(self._extensions)
 */
  __pyx_4 = __Pyx_PyBool_FromLong(__pyx_v_self->_build_smart_strings); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyTuple_New(4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_namespaces);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_5, 1, Py_None);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
  if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__BaseContext))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_3);
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":105
 *         context = self.__class__(namespaces, None, False,
 *                                  self._build_smart_strings)
 *         if self._extensions is not None:             # <<<<<<<<<<<<<<
 *             context._extensions = python.PyDict_Copy(self._extensions)
 *         return context
 */
  __pyx_1 = (__pyx_v_self->_extensions != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":106
 *                                  self._build_smart_strings)
 *         if self._extensions is not None:
 *             context._extensions = python.PyDict_Copy(self._extensions)             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
    __pyx_4 = PyDict_Copy(__pyx_v_self->_extensions); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_context->_extensions);
    __pyx_v_context->_extensions = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":107
 *         if self._extensions is not None:
 *             context._extensions = python.PyDict_Copy(self._extensions)
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     cdef object _to_utf(self, s):
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = __pyx_v_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__BaseContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._BaseContext._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  Py_DECREF(__pyx_v_namespaces);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":109
 *         return context
 * 
 *     cdef object _to_utf(self, s):             # <<<<<<<<<<<<<<
 *         u"Convert to UTF-8 and keep a reference to the encoded string"
 *         cdef python.PyObject* dict_result
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__to_utf(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, PyObject *__pyx_v_s) {
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_v_utf;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":112
 *         u"Convert to UTF-8 and keep a reference to the encoded string"
 *         cdef python.PyObject* dict_result
 *         if s is None:             # <<<<<<<<<<<<<<
 *             return None
 *         dict_result = python.PyDict_GetItem(self._utf_refs, s)
 */
  __pyx_1 = (__pyx_v_s == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":113
 *         cdef python.PyObject* dict_result
 *         if s is None:
 *             return None             # <<<<<<<<<<<<<<
 *         dict_result = python.PyDict_GetItem(self._utf_refs, s)
 *         if dict_result is not NULL:
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":114
 *         if s is None:
 *             return None
 *         dict_result = python.PyDict_GetItem(self._utf_refs, s)             # <<<<<<<<<<<<<<
 *         if dict_result is not NULL:
 *             return <object>dict_result
 */
  __pyx_v_dict_result = PyDict_GetItem(__pyx_v_self->_utf_refs, __pyx_v_s);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":115
 *             return None
 *         dict_result = python.PyDict_GetItem(self._utf_refs, s)
 *         if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *             return <object>dict_result
 *         utf = _utf8(s)
 */
  __pyx_1 = (__pyx_v_dict_result != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":116
 *         dict_result = python.PyDict_GetItem(self._utf_refs, s)
 *         if dict_result is not NULL:
 *             return <object>dict_result             # <<<<<<<<<<<<<<
 *         utf = _utf8(s)
 *         python.PyDict_SetItem(self._utf_refs, s, utf)
 */
    Py_INCREF(((PyObject *)__pyx_v_dict_result));
    __pyx_r = ((PyObject *)__pyx_v_dict_result);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":117
 *         if dict_result is not NULL:
 *             return <object>dict_result
 *         utf = _utf8(s)             # <<<<<<<<<<<<<<
 *         python.PyDict_SetItem(self._utf_refs, s, utf)
 *         return utf
 */
  __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_s); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_utf);
  __pyx_v_utf = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":118
 *             return <object>dict_result
 *         utf = _utf8(s)
 *         python.PyDict_SetItem(self._utf_refs, s, utf)             # <<<<<<<<<<<<<<
 *         return utf
 * 
 */
  __pyx_3 = PyDict_SetItem(__pyx_v_self->_utf_refs, __pyx_v_s, __pyx_v_utf); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":119
 *         utf = _utf8(s)
 *         python.PyDict_SetItem(self._utf_refs, s, utf)
 *         return utf             # <<<<<<<<<<<<<<
 * 
 *     cdef void _set_xpath_context(self, xpath.xmlXPathContext* xpathCtxt):
 */
  Py_INCREF(__pyx_v_utf);
  __pyx_r = __pyx_v_utf;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseContext._to_utf");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":121
 *         return utf
 * 
 *     cdef void _set_xpath_context(self, xpath.xmlXPathContext* xpathCtxt):             # <<<<<<<<<<<<<<
 *         self._xpathCtxt = xpathCtxt
 *         xpathCtxt.userData = <void*>self
 */

static  void __pyx_f_4lxml_5etree_12_BaseContext__set_xpath_context(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, xmlXPathContext *__pyx_v_xpathCtxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":122
 * 
 *     cdef void _set_xpath_context(self, xpath.xmlXPathContext* xpathCtxt):
 *         self._xpathCtxt = xpathCtxt             # <<<<<<<<<<<<<<
 *         xpathCtxt.userData = <void*>self
 * 
 */
  __pyx_v_self->_xpathCtxt = __pyx_v_xpathCtxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":123
 *     cdef void _set_xpath_context(self, xpath.xmlXPathContext* xpathCtxt):
 *         self._xpathCtxt = xpathCtxt
 *         xpathCtxt.userData = <void*>self             # <<<<<<<<<<<<<<
 * 
 *     cdef _register_context(self, _Document doc):
 */
  __pyx_v_xpathCtxt->userData = ((void *)__pyx_v_self);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":125
 *         xpathCtxt.userData = <void*>self
 * 
 *     cdef _register_context(self, _Document doc):             # <<<<<<<<<<<<<<
 *         self._doc = doc
 *         self._exc.clear()
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__register_context(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, struct LxmlDocument *__pyx_v_doc) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":126
 * 
 *     cdef _register_context(self, _Document doc):
 *         self._doc = doc             # <<<<<<<<<<<<<<
 *         self._exc.clear()
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_doc));
  Py_DECREF(((PyObject *)__pyx_v_self->_doc));
  __pyx_v_self->_doc = __pyx_v_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":127
 *     cdef _register_context(self, _Document doc):
 *         self._doc = doc
 *         self._exc.clear()             # <<<<<<<<<<<<<<
 * 
 *     cdef _cleanup_context(self):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_self->_exc->__pyx_vtab)->clear(__pyx_v_self->_exc);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":129
 *         self._exc.clear()
 * 
 *     cdef _cleanup_context(self):             # <<<<<<<<<<<<<<
 *         #xpath.xmlXPathRegisteredNsCleanup(self._xpathCtxt)
 *         #self.unregisterGlobalNamespaces()
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__cleanup_context(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":132
 *         #xpath.xmlXPathRegisteredNsCleanup(self._xpathCtxt)
 *         #self.unregisterGlobalNamespaces()
 *         python.PyDict_Clear(self._utf_refs)             # <<<<<<<<<<<<<<
 *         self._eval_context_dict = None
 *         self._doc = None
 */
  PyDict_Clear(__pyx_v_self->_utf_refs);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":133
 *         #self.unregisterGlobalNamespaces()
 *         python.PyDict_Clear(self._utf_refs)
 *         self._eval_context_dict = None             # <<<<<<<<<<<<<<
 *         self._doc = None
 * 
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_self->_eval_context_dict);
  __pyx_v_self->_eval_context_dict = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":134
 *         python.PyDict_Clear(self._utf_refs)
 *         self._eval_context_dict = None
 *         self._doc = None             # <<<<<<<<<<<<<<
 * 
 *     cdef _release_context(self):
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)__pyx_v_self->_doc));
  __pyx_v_self->_doc = ((struct LxmlDocument *)Py_None);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":136
 *         self._doc = None
 * 
 *     cdef _release_context(self):             # <<<<<<<<<<<<<<
 *         if self._xpathCtxt is not NULL:
 *             self._xpathCtxt.userData = NULL
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__release_context(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":137
 * 
 *     cdef _release_context(self):
 *         if self._xpathCtxt is not NULL:             # <<<<<<<<<<<<<<
 *             self._xpathCtxt.userData = NULL
 *             self._xpathCtxt = NULL
 */
  __pyx_1 = (__pyx_v_self->_xpathCtxt != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":138
 *     cdef _release_context(self):
 *         if self._xpathCtxt is not NULL:
 *             self._xpathCtxt.userData = NULL             # <<<<<<<<<<<<<<
 *             self._xpathCtxt = NULL
 * 
 */
    __pyx_v_self->_xpathCtxt->userData = NULL;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":139
 *         if self._xpathCtxt is not NULL:
 *             self._xpathCtxt.userData = NULL
 *             self._xpathCtxt = NULL             # <<<<<<<<<<<<<<
 * 
 *     # namespaces (internal UTF-8 methods with leading '_')
 */
    __pyx_v_self->_xpathCtxt = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":143
 *     # namespaces (internal UTF-8 methods with leading '_')
 * 
 *     cdef addNamespace(self, prefix, ns_uri):             # <<<<<<<<<<<<<<
 *         if prefix is None:
 *             raise TypeError, u"empty prefix is not supported in XPath"
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_addNamespace(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, PyObject *__pyx_v_prefix, PyObject *__pyx_v_ns_uri) {
  PyObject *__pyx_v_prefix_utf;
  PyObject *__pyx_v_ns_uri_utf;
  PyObject *__pyx_v_new_item;
  PyObject *__pyx_v_namespaces;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_uri_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_new_item = Py_None; Py_INCREF(Py_None);
  __pyx_v_namespaces = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":144
 * 
 *     cdef addNamespace(self, prefix, ns_uri):
 *         if prefix is None:             # <<<<<<<<<<<<<<
 *             raise TypeError, u"empty prefix is not supported in XPath"
 *         prefix_utf = self._to_utf(prefix)
 */
  __pyx_1 = (__pyx_v_prefix == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":145
 *     cdef addNamespace(self, prefix, ns_uri):
 *         if prefix is None:
 *             raise TypeError, u"empty prefix is not supported in XPath"             # <<<<<<<<<<<<<<
 *         prefix_utf = self._to_utf(prefix)
 *         ns_uri_utf = self._to_utf(ns_uri)
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_527), 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":146
 *         if prefix is None:
 *             raise TypeError, u"empty prefix is not supported in XPath"
 *         prefix_utf = self._to_utf(prefix)             # <<<<<<<<<<<<<<
 *         ns_uri_utf = self._to_utf(ns_uri)
 *         new_item = (prefix_utf, ns_uri_utf)
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_self->__pyx_vtab)->_to_utf(__pyx_v_self, __pyx_v_prefix); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_prefix_utf);
  __pyx_v_prefix_utf = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":147
 *             raise TypeError, u"empty prefix is not supported in XPath"
 *         prefix_utf = self._to_utf(prefix)
 *         ns_uri_utf = self._to_utf(ns_uri)             # <<<<<<<<<<<<<<
 *         new_item = (prefix_utf, ns_uri_utf)
 *         if self._namespaces is None:
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_self->__pyx_vtab)->_to_utf(__pyx_v_self, __pyx_v_ns_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_ns_uri_utf);
  __pyx_v_ns_uri_utf = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":148
 *         prefix_utf = self._to_utf(prefix)
 *         ns_uri_utf = self._to_utf(ns_uri)
 *         new_item = (prefix_utf, ns_uri_utf)             # <<<<<<<<<<<<<<
 *         if self._namespaces is None:
 *             self._namespaces = [new_item]
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_prefix_utf);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_prefix_utf);
  Py_INCREF(__pyx_v_ns_uri_utf);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_ns_uri_utf);
  Py_DECREF(__pyx_v_new_item);
  __pyx_v_new_item = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":149
 *         ns_uri_utf = self._to_utf(ns_uri)
 *         new_item = (prefix_utf, ns_uri_utf)
 *         if self._namespaces is None:             # <<<<<<<<<<<<<<
 *             self._namespaces = [new_item]
 *         else:
 */
  __pyx_1 = (__pyx_v_self->_namespaces == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":150
 *         new_item = (prefix_utf, ns_uri_utf)
 *         if self._namespaces is None:
 *             self._namespaces = [new_item]             # <<<<<<<<<<<<<<
 *         else:
 *             namespaces = []
 */
    __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_new_item);
    PyList_SET_ITEM(__pyx_2, 0, __pyx_v_new_item);
    Py_DECREF(__pyx_v_self->_namespaces);
    __pyx_v_self->_namespaces = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":152
 *             self._namespaces = [new_item]
 *         else:
 *             namespaces = []             # <<<<<<<<<<<<<<
 *             for item in self._namespaces:
 *                 if item[0] == prefix_utf:
 */
    __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_namespaces);
    __pyx_v_namespaces = ((PyObject *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":153
 *         else:
 *             namespaces = []
 *             for item in self._namespaces:             # <<<<<<<<<<<<<<
 *                 if item[0] == prefix_utf:
 *                     item = new_item
 */
    if (PyList_CheckExact(__pyx_v_self->_namespaces) || PyTuple_CheckExact(__pyx_v_self->_namespaces)) {
      __pyx_3 = 0; __pyx_2 = __pyx_v_self->_namespaces; Py_INCREF(__pyx_2);
    } else {
      __pyx_3 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_self->_namespaces); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_2))) {
        if (__pyx_3 >= PyList_GET_SIZE(__pyx_2)) break;
        __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else if (likely(PyTuple_CheckExact(__pyx_2))) {
        if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_2)) break;
        __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else {
        __pyx_4 = PyIter_Next(__pyx_2);
        if (!__pyx_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_item);
      __pyx_v_item = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":154
 *             namespaces = []
 *             for item in self._namespaces:
 *                 if item[0] == prefix_utf:             # <<<<<<<<<<<<<<
 *                     item = new_item
 *                     new_item = None
 */
      __pyx_4 = __Pyx_GetItemInt(__pyx_v_item, 0, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_5 = PyObject_RichCompare(__pyx_4, __pyx_v_prefix_utf, Py_EQ); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_5); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":155
 *             for item in self._namespaces:
 *                 if item[0] == prefix_utf:
 *                     item = new_item             # <<<<<<<<<<<<<<
 *                     new_item = None
 *                 python.PyList_Append(namespaces, item)
 */
        Py_INCREF(__pyx_v_new_item);
        Py_DECREF(__pyx_v_item);
        __pyx_v_item = __pyx_v_new_item;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":156
 *                 if item[0] == prefix_utf:
 *                     item = new_item
 *                     new_item = None             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(namespaces, item)
 *             if new_item is not None:
 */
        Py_INCREF(Py_None);
        Py_DECREF(__pyx_v_new_item);
        __pyx_v_new_item = Py_None;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":157
 *                     item = new_item
 *                     new_item = None
 *                 python.PyList_Append(namespaces, item)             # <<<<<<<<<<<<<<
 *             if new_item is not None:
 *                 python.PyList_Append(namespaces, new_item)
 */
      __pyx_6 = PyList_Append(__pyx_v_namespaces, __pyx_v_item); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":158
 *                     new_item = None
 *                 python.PyList_Append(namespaces, item)
 *             if new_item is not None:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(namespaces, new_item)
 *             self._namespaces = namespaces
 */
    __pyx_1 = (__pyx_v_new_item != Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":159
 *                 python.PyList_Append(namespaces, item)
 *             if new_item is not None:
 *                 python.PyList_Append(namespaces, new_item)             # <<<<<<<<<<<<<<
 *             self._namespaces = namespaces
 *         if self._xpathCtxt is not NULL:
 */
      __pyx_6 = PyList_Append(__pyx_v_namespaces, __pyx_v_new_item); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":160
 *             if new_item is not None:
 *                 python.PyList_Append(namespaces, new_item)
 *             self._namespaces = namespaces             # <<<<<<<<<<<<<<
 *         if self._xpathCtxt is not NULL:
 *             xpath.xmlXPathRegisterNs(
 */
    Py_INCREF(__pyx_v_namespaces);
    Py_DECREF(__pyx_v_self->_namespaces);
    __pyx_v_self->_namespaces = __pyx_v_namespaces;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":161
 *                 python.PyList_Append(namespaces, new_item)
 *             self._namespaces = namespaces
 *         if self._xpathCtxt is not NULL:             # <<<<<<<<<<<<<<
 *             xpath.xmlXPathRegisterNs(
 *                 self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))
 */
  __pyx_1 = (__pyx_v_self->_xpathCtxt != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":163
 *         if self._xpathCtxt is not NULL:
 *             xpath.xmlXPathRegisterNs(
 *                 self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))             # <<<<<<<<<<<<<<
 * 
 *     cdef registerNamespace(self, prefix, ns_uri):
 */
    xmlXPathRegisterNs(__pyx_v_self->_xpathCtxt, PyString_AS_STRING(__pyx_v_prefix_utf), PyString_AS_STRING(__pyx_v_ns_uri_utf));
    goto __pyx_L9;
  }
  __pyx_L9:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._BaseContext.addNamespace");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix_utf);
  Py_DECREF(__pyx_v_ns_uri_utf);
  Py_DECREF(__pyx_v_new_item);
  Py_DECREF(__pyx_v_namespaces);
  Py_DECREF(__pyx_v_item);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":165
 *                 self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))
 * 
 *     cdef registerNamespace(self, prefix, ns_uri):             # <<<<<<<<<<<<<<
 *         if prefix is None:
 *             raise TypeError, u"empty prefix is not supported in XPath"
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_registerNamespace(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, PyObject *__pyx_v_prefix, PyObject *__pyx_v_ns_uri) {
  PyObject *__pyx_v_prefix_utf;
  PyObject *__pyx_v_ns_uri_utf;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_uri_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":166
 * 
 *     cdef registerNamespace(self, prefix, ns_uri):
 *         if prefix is None:             # <<<<<<<<<<<<<<
 *             raise TypeError, u"empty prefix is not supported in XPath"
 *         prefix_utf = self._to_utf(prefix)
 */
  __pyx_1 = (__pyx_v_prefix == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":167
 *     cdef registerNamespace(self, prefix, ns_uri):
 *         if prefix is None:
 *             raise TypeError, u"empty prefix is not supported in XPath"             # <<<<<<<<<<<<<<
 *         prefix_utf = self._to_utf(prefix)
 *         ns_uri_utf = self._to_utf(ns_uri)
 */
    __Pyx_Raise(__pyx_builtin_TypeError, ((PyObject *)__pyx_kp_528), 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":168
 *         if prefix is None:
 *             raise TypeError, u"empty prefix is not supported in XPath"
 *         prefix_utf = self._to_utf(prefix)             # <<<<<<<<<<<<<<
 *         ns_uri_utf = self._to_utf(ns_uri)
 *         python.PyList_Append(self._global_namespaces, prefix_utf)
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_self->__pyx_vtab)->_to_utf(__pyx_v_self, __pyx_v_prefix); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_prefix_utf);
  __pyx_v_prefix_utf = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":169
 *             raise TypeError, u"empty prefix is not supported in XPath"
 *         prefix_utf = self._to_utf(prefix)
 *         ns_uri_utf = self._to_utf(ns_uri)             # <<<<<<<<<<<<<<
 *         python.PyList_Append(self._global_namespaces, prefix_utf)
 *         xpath.xmlXPathRegisterNs(self._xpathCtxt,
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_self->__pyx_vtab)->_to_utf(__pyx_v_self, __pyx_v_ns_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_ns_uri_utf);
  __pyx_v_ns_uri_utf = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":170
 *         prefix_utf = self._to_utf(prefix)
 *         ns_uri_utf = self._to_utf(ns_uri)
 *         python.PyList_Append(self._global_namespaces, prefix_utf)             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                  _cstr(prefix_utf), _cstr(ns_uri_utf))
 */
  __pyx_3 = PyList_Append(__pyx_v_self->_global_namespaces, __pyx_v_prefix_utf); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":172
 *         python.PyList_Append(self._global_namespaces, prefix_utf)
 *         xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                  _cstr(prefix_utf), _cstr(ns_uri_utf))             # <<<<<<<<<<<<<<
 * 
 *     cdef registerLocalNamespaces(self):
 */
  xmlXPathRegisterNs(__pyx_v_self->_xpathCtxt, PyString_AS_STRING(__pyx_v_prefix_utf), PyString_AS_STRING(__pyx_v_ns_uri_utf));

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseContext.registerNamespace");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix_utf);
  Py_DECREF(__pyx_v_ns_uri_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":174
 *                                  _cstr(prefix_utf), _cstr(ns_uri_utf))
 * 
 *     cdef registerLocalNamespaces(self):             # <<<<<<<<<<<<<<
 *         if self._namespaces is None:
 *             return
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_registerLocalNamespaces(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  PyObject *__pyx_v_prefix_utf;
  PyObject *__pyx_v_ns_uri_utf;
  PyObject *__pyx_r;
  int __pyx_1;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_uri_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":175
 * 
 *     cdef registerLocalNamespaces(self):
 *         if self._namespaces is None:             # <<<<<<<<<<<<<<
 *             return
 *         for prefix_utf, ns_uri_utf in self._namespaces:
 */
  __pyx_1 = (__pyx_v_self->_namespaces == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":176
 *     cdef registerLocalNamespaces(self):
 *         if self._namespaces is None:
 *             return             # <<<<<<<<<<<<<<
 *         for prefix_utf, ns_uri_utf in self._namespaces:
 *             xpath.xmlXPathRegisterNs(
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":177
 *         if self._namespaces is None:
 *             return
 *         for prefix_utf, ns_uri_utf in self._namespaces:             # <<<<<<<<<<<<<<
 *             xpath.xmlXPathRegisterNs(
 *                 self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))
 */
  if (PyList_CheckExact(__pyx_v_self->_namespaces) || PyTuple_CheckExact(__pyx_v_self->_namespaces)) {
    __pyx_2 = 0; __pyx_3 = __pyx_v_self->_namespaces; Py_INCREF(__pyx_3);
  } else {
    __pyx_2 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_self->_namespaces); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_3);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_4) && PyTuple_GET_SIZE(__pyx_4) == 2) {
      PyObject* tuple = __pyx_4;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_6);
      Py_DECREF(__pyx_v_prefix_utf);
      __pyx_v_prefix_utf = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_6);
      Py_DECREF(__pyx_v_ns_uri_utf);
      __pyx_v_ns_uri_utf = __pyx_6;
      __pyx_6 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    else {
      __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix_utf);
      __pyx_v_prefix_utf = __pyx_6;
      __pyx_6 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns_uri_utf);
      __pyx_v_ns_uri_utf = __pyx_6;
      __pyx_6 = 0;
      if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":179
 *         for prefix_utf, ns_uri_utf in self._namespaces:
 *             xpath.xmlXPathRegisterNs(
 *                 self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))             # <<<<<<<<<<<<<<
 * 
 *     cdef registerGlobalNamespaces(self):
 */
    xmlXPathRegisterNs(__pyx_v_self->_xpathCtxt, PyString_AS_STRING(__pyx_v_prefix_utf), PyString_AS_STRING(__pyx_v_ns_uri_utf));
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._BaseContext.registerLocalNamespaces");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix_utf);
  Py_DECREF(__pyx_v_ns_uri_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":181
 *                 self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))
 * 
 *     cdef registerGlobalNamespaces(self):             # <<<<<<<<<<<<<<
 *         ns_prefixes = _find_all_extension_prefixes()
 *         if python.PyList_GET_SIZE(ns_prefixes) > 0:
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_registerGlobalNamespaces(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  PyObject *__pyx_v_ns_prefixes;
  PyObject *__pyx_v_prefix_utf;
  PyObject *__pyx_v_ns_uri_utf;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  __pyx_v_ns_prefixes = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_uri_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":182
 * 
 *     cdef registerGlobalNamespaces(self):
 *         ns_prefixes = _find_all_extension_prefixes()             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(ns_prefixes) > 0:
 *             for prefix_utf, ns_uri_utf in ns_prefixes:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__find_all_extension_prefixes(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_ns_prefixes);
  __pyx_v_ns_prefixes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":183
 *     cdef registerGlobalNamespaces(self):
 *         ns_prefixes = _find_all_extension_prefixes()
 *         if python.PyList_GET_SIZE(ns_prefixes) > 0:             # <<<<<<<<<<<<<<
 *             for prefix_utf, ns_uri_utf in ns_prefixes:
 *                 python.PyList_Append(self._global_namespaces, prefix_utf)
 */
  __pyx_2 = (PyList_GET_SIZE(__pyx_v_ns_prefixes) > 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":184
 *         ns_prefixes = _find_all_extension_prefixes()
 *         if python.PyList_GET_SIZE(ns_prefixes) > 0:
 *             for prefix_utf, ns_uri_utf in ns_prefixes:             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(self._global_namespaces, prefix_utf)
 *                 xpath.xmlXPathRegisterNs(
 */
    if (PyList_CheckExact(__pyx_v_ns_prefixes) || PyTuple_CheckExact(__pyx_v_ns_prefixes)) {
      __pyx_3 = 0; __pyx_1 = __pyx_v_ns_prefixes; Py_INCREF(__pyx_1);
    } else {
      __pyx_3 = -1; __pyx_1 = PyObject_GetIter(__pyx_v_ns_prefixes); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_1))) {
        if (__pyx_3 >= PyList_GET_SIZE(__pyx_1)) break;
        __pyx_4 = PyList_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else if (likely(PyTuple_CheckExact(__pyx_1))) {
        if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_1)) break;
        __pyx_4 = PyTuple_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else {
        __pyx_4 = PyIter_Next(__pyx_1);
        if (!__pyx_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (PyTuple_CheckExact(__pyx_4) && PyTuple_GET_SIZE(__pyx_4) == 2) {
        PyObject* tuple = __pyx_4;
        __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_6);
        Py_DECREF(__pyx_v_prefix_utf);
        __pyx_v_prefix_utf = __pyx_6;
        __pyx_6 = 0;
        __pyx_6 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_6);
        Py_DECREF(__pyx_v_ns_uri_utf);
        __pyx_v_ns_uri_utf = __pyx_6;
        __pyx_6 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
      }
      else {
        __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_prefix_utf);
        __pyx_v_prefix_utf = __pyx_6;
        __pyx_6 = 0;
        __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_ns_uri_utf);
        __pyx_v_ns_uri_utf = __pyx_6;
        __pyx_6 = 0;
        if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":185
 *         if python.PyList_GET_SIZE(ns_prefixes) > 0:
 *             for prefix_utf, ns_uri_utf in ns_prefixes:
 *                 python.PyList_Append(self._global_namespaces, prefix_utf)             # <<<<<<<<<<<<<<
 *                 xpath.xmlXPathRegisterNs(
 *                     self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))
 */
      __pyx_7 = PyList_Append(__pyx_v_self->_global_namespaces, __pyx_v_prefix_utf); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":187
 *                 python.PyList_Append(self._global_namespaces, prefix_utf)
 *                 xpath.xmlXPathRegisterNs(
 *                     self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))             # <<<<<<<<<<<<<<
 * 
 *     cdef unregisterGlobalNamespaces(self):
 */
      xmlXPathRegisterNs(__pyx_v_self->_xpathCtxt, PyString_AS_STRING(__pyx_v_prefix_utf), PyString_AS_STRING(__pyx_v_ns_uri_utf));
    }
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._BaseContext.registerGlobalNamespaces");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_prefixes);
  Py_DECREF(__pyx_v_prefix_utf);
  Py_DECREF(__pyx_v_ns_uri_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":189
 *                     self._xpathCtxt, _cstr(prefix_utf), _cstr(ns_uri_utf))
 * 
 *     cdef unregisterGlobalNamespaces(self):             # <<<<<<<<<<<<<<
 *         if python.PyList_GET_SIZE(self._global_namespaces) > 0:
 *             for prefix_utf in self._global_namespaces:
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_unregisterGlobalNamespaces(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  PyObject *__pyx_v_prefix_utf;
  PyObject *__pyx_r;
  int __pyx_1;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_prefix_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":190
 * 
 *     cdef unregisterGlobalNamespaces(self):
 *         if python.PyList_GET_SIZE(self._global_namespaces) > 0:             # <<<<<<<<<<<<<<
 *             for prefix_utf in self._global_namespaces:
 *                 xpath.xmlXPathRegisterNs(self._xpathCtxt,
 */
  __pyx_1 = (PyList_GET_SIZE(__pyx_v_self->_global_namespaces) > 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":191
 *     cdef unregisterGlobalNamespaces(self):
 *         if python.PyList_GET_SIZE(self._global_namespaces) > 0:
 *             for prefix_utf in self._global_namespaces:             # <<<<<<<<<<<<<<
 *                 xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                          _cstr(prefix_utf), NULL)
 */
    if (PyList_CheckExact(__pyx_v_self->_global_namespaces) || PyTuple_CheckExact(__pyx_v_self->_global_namespaces)) {
      __pyx_2 = 0; __pyx_3 = __pyx_v_self->_global_namespaces; Py_INCREF(__pyx_3);
    } else {
      __pyx_2 = -1; __pyx_3 = PyObject_GetIter(__pyx_v_self->_global_namespaces); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_3))) {
        if (__pyx_2 >= PyList_GET_SIZE(__pyx_3)) break;
        __pyx_4 = PyList_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
      } else if (likely(PyTuple_CheckExact(__pyx_3))) {
        if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_3)) break;
        __pyx_4 = PyTuple_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
      } else {
        __pyx_4 = PyIter_Next(__pyx_3);
        if (!__pyx_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_prefix_utf);
      __pyx_v_prefix_utf = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":193
 *             for prefix_utf in self._global_namespaces:
 *                 xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                          _cstr(prefix_utf), NULL)             # <<<<<<<<<<<<<<
 *             del self._global_namespaces[:]
 * 
 */
      xmlXPathRegisterNs(__pyx_v_self->_xpathCtxt, PyString_AS_STRING(__pyx_v_prefix_utf), NULL);
    }
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":194
 *                 xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                          _cstr(prefix_utf), NULL)
 *             del self._global_namespaces[:]             # <<<<<<<<<<<<<<
 * 
 *     cdef void _unregisterNamespace(self, prefix_utf):
 */
    if (PySequence_DelSlice(__pyx_v_self->_global_namespaces, 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._BaseContext.unregisterGlobalNamespaces");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":196
 *             del self._global_namespaces[:]
 * 
 *     cdef void _unregisterNamespace(self, prefix_utf):             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                  _cstr(prefix_utf), NULL)
 */

static  void __pyx_f_4lxml_5etree_12_BaseContext__unregisterNamespace(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, PyObject *__pyx_v_prefix_utf) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":198
 *     cdef void _unregisterNamespace(self, prefix_utf):
 *         xpath.xmlXPathRegisterNs(self._xpathCtxt,
 *                                  _cstr(prefix_utf), NULL)             # <<<<<<<<<<<<<<
 * 
 *     # extension functions
 */
  xmlXPathRegisterNs(__pyx_v_self->_xpathCtxt, PyString_AS_STRING(__pyx_v_prefix_utf), NULL);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":202
 *     # extension functions
 * 
 *     cdef void _addLocalExtensionFunction(self, ns_utf, name_utf, function):             # <<<<<<<<<<<<<<
 *         if self._extensions is None:
 *             self._extensions = {}
 */

static  void __pyx_f_4lxml_5etree_12_BaseContext__addLocalExtensionFunction(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, PyObject *__pyx_v_ns_utf, PyObject *__pyx_v_name_utf, PyObject *__pyx_v_function) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":203
 * 
 *     cdef void _addLocalExtensionFunction(self, ns_utf, name_utf, function):
 *         if self._extensions is None:             # <<<<<<<<<<<<<<
 *             self._extensions = {}
 *         python.PyDict_SetItem(self._extensions, (ns_utf, name_utf), function)
 */
  __pyx_1 = (__pyx_v_self->_extensions == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":204
 *     cdef void _addLocalExtensionFunction(self, ns_utf, name_utf, function):
 *         if self._extensions is None:
 *             self._extensions = {}             # <<<<<<<<<<<<<<
 *         python.PyDict_SetItem(self._extensions, (ns_utf, name_utf), function)
 * 
 */
    __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_self->_extensions);
    __pyx_v_self->_extensions = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":205
 *         if self._extensions is None:
 *             self._extensions = {}
 *         python.PyDict_SetItem(self._extensions, (ns_utf, name_utf), function)             # <<<<<<<<<<<<<<
 * 
 *     cdef void registerGlobalFunctions(self, void* ctxt,
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_ns_utf);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_ns_utf);
  Py_INCREF(__pyx_v_name_utf);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_name_utf);
  __pyx_3 = PyDict_SetItem(__pyx_v_self->_extensions, ((PyObject *)__pyx_2), __pyx_v_function); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("lxml.etree._BaseContext._addLocalExtensionFunction");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":207
 *         python.PyDict_SetItem(self._extensions, (ns_utf, name_utf), function)
 * 
 *     cdef void registerGlobalFunctions(self, void* ctxt,             # <<<<<<<<<<<<<<
 *                                     _register_function reg_func):
 *         cdef python.PyObject* dict_result
 */

static  void __pyx_f_4lxml_5etree_12_BaseContext_registerGlobalFunctions(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, void *__pyx_v_ctxt, __pyx_t_4lxml_5etree__register_function __pyx_v_reg_func) {
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_ns_functions;
  PyObject *__pyx_v_d;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_v_function;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  int __pyx_7;
  Py_ssize_t __pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_functions = Py_None; Py_INCREF(Py_None);
  __pyx_v_d = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_function = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":210
 *                                     _register_function reg_func):
 *         cdef python.PyObject* dict_result
 *         for ns_utf, ns_functions in _iter_ns_extension_functions():             # <<<<<<<<<<<<<<
 *             dict_result = python.PyDict_GetItem(
 *                 self._function_cache, ns_utf)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__iter_ns_extension_functions(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyList_CheckExact(__pyx_2) || PyTuple_CheckExact(__pyx_2)) {
    __pyx_1 = 0; __pyx_3 = __pyx_2; Py_INCREF(__pyx_3);
  } else {
    __pyx_1 = -1; __pyx_3 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_3))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_3)) break;
      __pyx_2 = PyList_GET_ITEM(__pyx_3, __pyx_1); Py_INCREF(__pyx_2); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_3))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_3)) break;
      __pyx_2 = PyTuple_GET_ITEM(__pyx_3, __pyx_1); Py_INCREF(__pyx_2); __pyx_1++;
    } else {
      __pyx_2 = PyIter_Next(__pyx_3);
      if (!__pyx_2) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
      PyObject* tuple = __pyx_2;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_ns_functions);
      __pyx_v_ns_functions = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns_functions);
      __pyx_v_ns_functions = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":212
 *         for ns_utf, ns_functions in _iter_ns_extension_functions():
 *             dict_result = python.PyDict_GetItem(
 *                 self._function_cache, ns_utf)             # <<<<<<<<<<<<<<
 *             if dict_result is not NULL:
 *                 d = <object>dict_result
 */
    __pyx_v_dict_result = PyDict_GetItem(__pyx_v_self->_function_cache, __pyx_v_ns_utf);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":213
 *             dict_result = python.PyDict_GetItem(
 *                 self._function_cache, ns_utf)
 *             if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *                 d = <object>dict_result
 *             else:
 */
    __pyx_6 = (__pyx_v_dict_result != NULL);
    if (__pyx_6) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":214
 *                 self._function_cache, ns_utf)
 *             if dict_result is not NULL:
 *                 d = <object>dict_result             # <<<<<<<<<<<<<<
 *             else:
 *                 d = {}
 */
      Py_INCREF(((PyObject *)__pyx_v_dict_result));
      Py_DECREF(__pyx_v_d);
      __pyx_v_d = ((PyObject *)__pyx_v_dict_result);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":216
 *                 d = <object>dict_result
 *             else:
 *                 d = {}             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(
 *                     self._function_cache, ns_utf, d)
 */
      __pyx_5 = PyDict_New(); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_d);
      __pyx_v_d = ((PyObject *)__pyx_5);
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":218
 *                 d = {}
 *                 python.PyDict_SetItem(
 *                     self._function_cache, ns_utf, d)             # <<<<<<<<<<<<<<
 *             for name_utf, function in ns_functions.items():
 *                 python.PyDict_SetItem(d, name_utf, function)
 */
      __pyx_7 = PyDict_SetItem(__pyx_v_self->_function_cache, __pyx_v_ns_utf, __pyx_v_d); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L5:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":219
 *                 python.PyDict_SetItem(
 *                     self._function_cache, ns_utf, d)
 *             for name_utf, function in ns_functions.items():             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(d, name_utf, function)
 *                 reg_func(ctxt, name_utf, ns_utf)
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_ns_functions, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
      __pyx_8 = 0; __pyx_5 = __pyx_4; Py_INCREF(__pyx_5);
    } else {
      __pyx_8 = -1; __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_5))) {
        if (__pyx_8 >= PyList_GET_SIZE(__pyx_5)) break;
        __pyx_2 = PyList_GET_ITEM(__pyx_5, __pyx_8); Py_INCREF(__pyx_2); __pyx_8++;
      } else if (likely(PyTuple_CheckExact(__pyx_5))) {
        if (__pyx_8 >= PyTuple_GET_SIZE(__pyx_5)) break;
        __pyx_2 = PyTuple_GET_ITEM(__pyx_5, __pyx_8); Py_INCREF(__pyx_2); __pyx_8++;
      } else {
        __pyx_2 = PyIter_Next(__pyx_5);
        if (!__pyx_2) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (PyTuple_CheckExact(__pyx_2) && PyTuple_GET_SIZE(__pyx_2) == 2) {
        PyObject* tuple = __pyx_2;
        __pyx_9 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_9);
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_9;
        __pyx_9 = 0;
        __pyx_9 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_9);
        Py_DECREF(__pyx_v_function);
        __pyx_v_function = __pyx_9;
        __pyx_9 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      else {
        __pyx_4 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_9 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_9;
        __pyx_9 = 0;
        __pyx_9 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_function);
        __pyx_v_function = __pyx_9;
        __pyx_9 = 0;
        if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":220
 *                     self._function_cache, ns_utf, d)
 *             for name_utf, function in ns_functions.items():
 *                 python.PyDict_SetItem(d, name_utf, function)             # <<<<<<<<<<<<<<
 *                 reg_func(ctxt, name_utf, ns_utf)
 * 
 */
      __pyx_7 = PyDict_SetItem(__pyx_v_d, __pyx_v_name_utf, __pyx_v_function); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":221
 *             for name_utf, function in ns_functions.items():
 *                 python.PyDict_SetItem(d, name_utf, function)
 *                 reg_func(ctxt, name_utf, ns_utf)             # <<<<<<<<<<<<<<
 * 
 *     cdef void registerLocalFunctions(self, void* ctxt,
 */
      __pyx_v_reg_func(__pyx_v_ctxt, __pyx_v_name_utf, __pyx_v_ns_utf);
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_9);
  __Pyx_WriteUnraisable("lxml.etree._BaseContext.registerGlobalFunctions");
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_ns_functions);
  Py_DECREF(__pyx_v_d);
  Py_DECREF(__pyx_v_name_utf);
  Py_DECREF(__pyx_v_function);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":223
 *                 reg_func(ctxt, name_utf, ns_utf)
 * 
 *     cdef void registerLocalFunctions(self, void* ctxt,             # <<<<<<<<<<<<<<
 *                                       _register_function reg_func):
 *         cdef python.PyObject* dict_result
 */

static  void __pyx_f_4lxml_5etree_12_BaseContext_registerLocalFunctions(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, void *__pyx_v_ctxt, __pyx_t_4lxml_5etree__register_function __pyx_v_reg_func) {
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_v_last_ns;
  PyObject *__pyx_v_d;
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_v_function;
  int __pyx_1;
  Py_ssize_t __pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  int __pyx_9;
  __pyx_v_last_ns = Py_None; Py_INCREF(Py_None);
  __pyx_v_d = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_function = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":226
 *                                       _register_function reg_func):
 *         cdef python.PyObject* dict_result
 *         if self._extensions is None:             # <<<<<<<<<<<<<<
 *             return # done
 *         last_ns = None
 */
  __pyx_1 = (__pyx_v_self->_extensions == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":227
 *         cdef python.PyObject* dict_result
 *         if self._extensions is None:
 *             return # done             # <<<<<<<<<<<<<<
 *         last_ns = None
 *         d = None
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":228
 *         if self._extensions is None:
 *             return # done
 *         last_ns = None             # <<<<<<<<<<<<<<
 *         d = None
 *         for (ns_utf, name_utf), function in self._extensions.items():
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_last_ns);
  __pyx_v_last_ns = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":229
 *             return # done
 *         last_ns = None
 *         d = None             # <<<<<<<<<<<<<<
 *         for (ns_utf, name_utf), function in self._extensions.items():
 *             if ns_utf is not last_ns or d is None:
 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_d);
  __pyx_v_d = Py_None;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":230
 *         last_ns = None
 *         d = None
 *         for (ns_utf, name_utf), function in self._extensions.items():             # <<<<<<<<<<<<<<
 *             if ns_utf is not last_ns or d is None:
 *                 last_ns = ns_utf
 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self->_extensions, __pyx_kp_items); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
    __pyx_2 = 0; __pyx_3 = __pyx_4; Py_INCREF(__pyx_3);
  } else {
    __pyx_2 = -1; __pyx_3 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyList_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyList_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_3))) {
      if (__pyx_2 >= PyTuple_GET_SIZE(__pyx_3)) break;
      __pyx_4 = PyTuple_GET_ITEM(__pyx_3, __pyx_2); Py_INCREF(__pyx_4); __pyx_2++;
    } else {
      __pyx_4 = PyIter_Next(__pyx_3);
      if (!__pyx_4) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_4) && PyTuple_GET_SIZE(__pyx_4) == 2) {
      PyObject* tuple = __pyx_4;
      __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_6);
      if (PyTuple_CheckExact(__pyx_6) && PyTuple_GET_SIZE(__pyx_6) == 2) {
        PyObject* tuple = __pyx_6;
        __pyx_8 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_8);
        Py_DECREF(__pyx_v_ns_utf);
        __pyx_v_ns_utf = __pyx_8;
        __pyx_8 = 0;
        __pyx_8 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_8);
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_8;
        __pyx_8 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
      }
      else {
        __pyx_7 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_8 = __Pyx_UnpackItem(__pyx_7, 0); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_ns_utf);
        __pyx_v_ns_utf = __pyx_8;
        __pyx_8 = 0;
        __pyx_8 = __Pyx_UnpackItem(__pyx_7, 1); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_8;
        __pyx_8 = 0;
        if (__Pyx_EndUnpack(__pyx_7) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
      }
      __pyx_8 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_8);
      Py_DECREF(__pyx_v_function);
      __pyx_v_function = __pyx_8;
      __pyx_8 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    else {
      __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (PyTuple_CheckExact(__pyx_6) && PyTuple_GET_SIZE(__pyx_6) == 2) {
        PyObject* tuple = __pyx_6;
        __pyx_8 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_8);
        Py_DECREF(__pyx_v_ns_utf);
        __pyx_v_ns_utf = __pyx_8;
        __pyx_8 = 0;
        __pyx_8 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_8);
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_8;
        __pyx_8 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
      }
      else {
        __pyx_7 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_8 = __Pyx_UnpackItem(__pyx_7, 0); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_ns_utf);
        __pyx_v_ns_utf = __pyx_8;
        __pyx_8 = 0;
        __pyx_8 = __Pyx_UnpackItem(__pyx_7, 1); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_8;
        __pyx_8 = 0;
        if (__Pyx_EndUnpack(__pyx_7) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
      }
      __pyx_8 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_function);
      __pyx_v_function = __pyx_8;
      __pyx_8 = 0;
      if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":231
 *         d = None
 *         for (ns_utf, name_utf), function in self._extensions.items():
 *             if ns_utf is not last_ns or d is None:             # <<<<<<<<<<<<<<
 *                 last_ns = ns_utf
 *                 dict_result = python.PyDict_GetItem(
 */
    __pyx_1 = (__pyx_v_ns_utf != __pyx_v_last_ns);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_d == Py_None);
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":232
 *         for (ns_utf, name_utf), function in self._extensions.items():
 *             if ns_utf is not last_ns or d is None:
 *                 last_ns = ns_utf             # <<<<<<<<<<<<<<
 *                 dict_result = python.PyDict_GetItem(
 *                     self._function_cache, ns_utf)
 */
      Py_INCREF(__pyx_v_ns_utf);
      Py_DECREF(__pyx_v_last_ns);
      __pyx_v_last_ns = __pyx_v_ns_utf;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":234
 *                 last_ns = ns_utf
 *                 dict_result = python.PyDict_GetItem(
 *                     self._function_cache, ns_utf)             # <<<<<<<<<<<<<<
 *                 if dict_result is not NULL:
 *                     d = <object>dict_result
 */
      __pyx_v_dict_result = PyDict_GetItem(__pyx_v_self->_function_cache, __pyx_v_ns_utf);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":235
 *                 dict_result = python.PyDict_GetItem(
 *                     self._function_cache, ns_utf)
 *                 if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *                     d = <object>dict_result
 *                 else:
 */
      __pyx_1 = (__pyx_v_dict_result != NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":236
 *                     self._function_cache, ns_utf)
 *                 if dict_result is not NULL:
 *                     d = <object>dict_result             # <<<<<<<<<<<<<<
 *                 else:
 *                     d = {}
 */
        Py_INCREF(((PyObject *)__pyx_v_dict_result));
        Py_DECREF(__pyx_v_d);
        __pyx_v_d = ((PyObject *)__pyx_v_dict_result);
        goto __pyx_L7;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":238
 *                     d = <object>dict_result
 *                 else:
 *                     d = {}             # <<<<<<<<<<<<<<
 *                     python.PyDict_SetItem(self._function_cache,
 *                                           ns_utf, d)
 */
        __pyx_6 = PyDict_New(); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_d);
        __pyx_v_d = ((PyObject *)__pyx_6);
        __pyx_6 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":240
 *                     d = {}
 *                     python.PyDict_SetItem(self._function_cache,
 *                                           ns_utf, d)             # <<<<<<<<<<<<<<
 *             python.PyDict_SetItem(d, name_utf, function)
 *             reg_func(ctxt, name_utf, ns_utf)
 */
        __pyx_9 = PyDict_SetItem(__pyx_v_self->_function_cache, __pyx_v_ns_utf, __pyx_v_d); if (unlikely(__pyx_9 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":241
 *                     python.PyDict_SetItem(self._function_cache,
 *                                           ns_utf, d)
 *             python.PyDict_SetItem(d, name_utf, function)             # <<<<<<<<<<<<<<
 *             reg_func(ctxt, name_utf, ns_utf)
 * 
 */
    __pyx_9 = PyDict_SetItem(__pyx_v_d, __pyx_v_name_utf, __pyx_v_function); if (unlikely(__pyx_9 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":242
 *                                           ns_utf, d)
 *             python.PyDict_SetItem(d, name_utf, function)
 *             reg_func(ctxt, name_utf, ns_utf)             # <<<<<<<<<<<<<<
 * 
 *     cdef unregisterAllFunctions(self, void* ctxt,
 */
    __pyx_v_reg_func(__pyx_v_ctxt, __pyx_v_name_utf, __pyx_v_ns_utf);
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_WriteUnraisable("lxml.etree._BaseContext.registerLocalFunctions");
  __pyx_L0:;
  Py_DECREF(__pyx_v_last_ns);
  Py_DECREF(__pyx_v_d);
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_name_utf);
  Py_DECREF(__pyx_v_function);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":244
 *             reg_func(ctxt, name_utf, ns_utf)
 * 
 *     cdef unregisterAllFunctions(self, void* ctxt,             # <<<<<<<<<<<<<<
 *                                       _register_function unreg_func):
 *         for ns_utf, functions in self._function_cache.items():
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_unregisterAllFunctions(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, void *__pyx_v_ctxt, __pyx_t_4lxml_5etree__register_function __pyx_v_unreg_func) {
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_functions;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6 = 0;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_functions = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":246
 *     cdef unregisterAllFunctions(self, void* ctxt,
 *                                       _register_function unreg_func):
 *         for ns_utf, functions in self._function_cache.items():             # <<<<<<<<<<<<<<
 *             for name_utf in functions:
 *                 unreg_func(ctxt, name_utf, ns_utf)
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_function_cache, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) {
    __pyx_1 = 0; __pyx_2 = __pyx_3; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_functions);
      __pyx_v_functions = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_functions);
      __pyx_v_functions = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":247
 *                                       _register_function unreg_func):
 *         for ns_utf, functions in self._function_cache.items():
 *             for name_utf in functions:             # <<<<<<<<<<<<<<
 *                 unreg_func(ctxt, name_utf, ns_utf)
 * 
 */
    if (PyList_CheckExact(__pyx_v_functions) || PyTuple_CheckExact(__pyx_v_functions)) {
      __pyx_6 = 0; __pyx_5 = __pyx_v_functions; Py_INCREF(__pyx_5);
    } else {
      __pyx_6 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_functions); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_5))) {
        if (__pyx_6 >= PyList_GET_SIZE(__pyx_5)) break;
        __pyx_3 = PyList_GET_ITEM(__pyx_5, __pyx_6); Py_INCREF(__pyx_3); __pyx_6++;
      } else if (likely(PyTuple_CheckExact(__pyx_5))) {
        if (__pyx_6 >= PyTuple_GET_SIZE(__pyx_5)) break;
        __pyx_3 = PyTuple_GET_ITEM(__pyx_5, __pyx_6); Py_INCREF(__pyx_3); __pyx_6++;
      } else {
        __pyx_3 = PyIter_Next(__pyx_5);
        if (!__pyx_3) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_name_utf);
      __pyx_v_name_utf = __pyx_3;
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":248
 *         for ns_utf, functions in self._function_cache.items():
 *             for name_utf in functions:
 *                 unreg_func(ctxt, name_utf, ns_utf)             # <<<<<<<<<<<<<<
 * 
 *     cdef unregisterGlobalFunctions(self, void* ctxt,
 */
      __pyx_v_unreg_func(__pyx_v_ctxt, __pyx_v_name_utf, __pyx_v_ns_utf);
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._BaseContext.unregisterAllFunctions");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_functions);
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":250
 *                 unreg_func(ctxt, name_utf, ns_utf)
 * 
 *     cdef unregisterGlobalFunctions(self, void* ctxt,             # <<<<<<<<<<<<<<
 *                                          _register_function unreg_func):
 *         for ns_utf, functions in self._function_cache.items():
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext_unregisterGlobalFunctions(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, void *__pyx_v_ctxt, __pyx_t_4lxml_5etree__register_function __pyx_v_unreg_func) {
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_functions;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_ssize_t __pyx_6 = 0;
  int __pyx_7;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_functions = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":252
 *     cdef unregisterGlobalFunctions(self, void* ctxt,
 *                                          _register_function unreg_func):
 *         for ns_utf, functions in self._function_cache.items():             # <<<<<<<<<<<<<<
 *             for name_utf in functions:
 *                 if self._extensions is None or \
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_function_cache, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) {
    __pyx_1 = 0; __pyx_2 = __pyx_3; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_functions);
      __pyx_v_functions = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_functions);
      __pyx_v_functions = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":253
 *                                          _register_function unreg_func):
 *         for ns_utf, functions in self._function_cache.items():
 *             for name_utf in functions:             # <<<<<<<<<<<<<<
 *                 if self._extensions is None or \
 *                        (ns_utf, name_utf) not in self._extensions:
 */
    if (PyList_CheckExact(__pyx_v_functions) || PyTuple_CheckExact(__pyx_v_functions)) {
      __pyx_6 = 0; __pyx_5 = __pyx_v_functions; Py_INCREF(__pyx_5);
    } else {
      __pyx_6 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_functions); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_5))) {
        if (__pyx_6 >= PyList_GET_SIZE(__pyx_5)) break;
        __pyx_3 = PyList_GET_ITEM(__pyx_5, __pyx_6); Py_INCREF(__pyx_3); __pyx_6++;
      } else if (likely(PyTuple_CheckExact(__pyx_5))) {
        if (__pyx_6 >= PyTuple_GET_SIZE(__pyx_5)) break;
        __pyx_3 = PyTuple_GET_ITEM(__pyx_5, __pyx_6); Py_INCREF(__pyx_3); __pyx_6++;
      } else {
        __pyx_3 = PyIter_Next(__pyx_5);
        if (!__pyx_3) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_name_utf);
      __pyx_v_name_utf = __pyx_3;
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":254
 *         for ns_utf, functions in self._function_cache.items():
 *             for name_utf in functions:
 *                 if self._extensions is None or \             # <<<<<<<<<<<<<<
 *                        (ns_utf, name_utf) not in self._extensions:
 *                     unreg_func(ctxt, name_utf, ns_utf)
 */
      __pyx_7 = (__pyx_v_self->_extensions == Py_None);
      if (!__pyx_7) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":255
 *             for name_utf in functions:
 *                 if self._extensions is None or \
 *                        (ns_utf, name_utf) not in self._extensions:             # <<<<<<<<<<<<<<
 *                     unreg_func(ctxt, name_utf, ns_utf)
 * 
 */
        __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_ns_utf);
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_ns_utf);
        Py_INCREF(__pyx_v_name_utf);
        PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_name_utf);
        __pyx_7 = (!PySequence_Contains(__pyx_v_self->_extensions, ((PyObject *)__pyx_4))); if (unlikely(__pyx_7 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      }
      if (__pyx_7) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":256
 *                 if self._extensions is None or \
 *                        (ns_utf, name_utf) not in self._extensions:
 *                     unreg_func(ctxt, name_utf, ns_utf)             # <<<<<<<<<<<<<<
 * 
 *     cdef _find_cached_function(self, char* c_ns_uri, char* c_name):
 */
        __pyx_v_unreg_func(__pyx_v_ctxt, __pyx_v_name_utf, __pyx_v_ns_utf);
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._BaseContext.unregisterGlobalFunctions");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_functions);
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":258
 *                     unreg_func(ctxt, name_utf, ns_utf)
 * 
 *     cdef _find_cached_function(self, char* c_ns_uri, char* c_name):             # <<<<<<<<<<<<<<
 *         u"""Lookup an extension function in the cache and return it.
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__find_cached_function(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, char *__pyx_v_c_ns_uri, char *__pyx_v_c_name) {
  PyObject *__pyx_v_c_dict;
  PyObject *__pyx_v_dict_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":265
 *         cdef python.PyObject* c_dict
 *         cdef python.PyObject* dict_result
 *         if c_ns_uri is NULL:             # <<<<<<<<<<<<<<
 *             c_dict = python.PyDict_GetItem(
 *                 self._function_cache, None)
 */
  __pyx_1 = (__pyx_v_c_ns_uri == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":267
 *         if c_ns_uri is NULL:
 *             c_dict = python.PyDict_GetItem(
 *                 self._function_cache, None)             # <<<<<<<<<<<<<<
 *         else:
 *             c_dict = python.PyDict_GetItem(
 */
    __pyx_v_c_dict = PyDict_GetItem(__pyx_v_self->_function_cache, Py_None);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":270
 *         else:
 *             c_dict = python.PyDict_GetItem(
 *                 self._function_cache, c_ns_uri)             # <<<<<<<<<<<<<<
 * 
 *         if c_dict is not NULL:
 */
    __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_c_ns_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_dict = PyDict_GetItem(__pyx_v_self->_function_cache, __pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":272
 *                 self._function_cache, c_ns_uri)
 * 
 *         if c_dict is not NULL:             # <<<<<<<<<<<<<<
 *             dict_result = python.PyDict_GetItem(
 *                 <object>c_dict, c_name)
 */
  __pyx_1 = (__pyx_v_c_dict != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":274
 *         if c_dict is not NULL:
 *             dict_result = python.PyDict_GetItem(
 *                 <object>c_dict, c_name)             # <<<<<<<<<<<<<<
 *             if dict_result is not NULL:
 *                 return <object>dict_result
 */
    __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_c_name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_dict_result = PyDict_GetItem(((PyObject *)__pyx_v_c_dict), __pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":275
 *             dict_result = python.PyDict_GetItem(
 *                 <object>c_dict, c_name)
 *             if dict_result is not NULL:             # <<<<<<<<<<<<<<
 *                 return <object>dict_result
 *         return None
 */
    __pyx_1 = (__pyx_v_dict_result != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":276
 *                 <object>c_dict, c_name)
 *             if dict_result is not NULL:
 *                 return <object>dict_result             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
      Py_INCREF(((PyObject *)__pyx_v_dict_result));
      __pyx_r = ((PyObject *)__pyx_v_dict_result);
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":277
 *             if dict_result is not NULL:
 *                 return <object>dict_result
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     # Python access to the XPath context for extension functions
 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseContext._find_cached_function");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":282
 * 
 *     property context_node:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef xmlNode* c_node
 *             if self._xpathCtxt is NULL:
 */

static PyObject *__pyx_pf_4lxml_5etree_12_BaseContext_12context_node___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_BaseContext_12context_node___get__(PyObject *__pyx_v_self) {
  xmlNode *__pyx_v_c_node;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":284
 *         def __get__(self):
 *             cdef xmlNode* c_node
 *             if self._xpathCtxt is NULL:             # <<<<<<<<<<<<<<
 *                 raise XPathError, \
 *                     u"XPath context is only usable during the evaluation"
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_xpathCtxt == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":285
 *             cdef xmlNode* c_node
 *             if self._xpathCtxt is NULL:
 *                 raise XPathError, \             # <<<<<<<<<<<<<<
 *                     u"XPath context is only usable during the evaluation"
 *             c_node = self._xpathCtxt.node
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":286
 *             if self._xpathCtxt is NULL:
 *                 raise XPathError, \
 *                     u"XPath context is only usable during the evaluation"             # <<<<<<<<<<<<<<
 *             c_node = self._xpathCtxt.node
 *             if c_node is NULL:
 */
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_529), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":287
 *                 raise XPathError, \
 *                     u"XPath context is only usable during the evaluation"
 *             c_node = self._xpathCtxt.node             # <<<<<<<<<<<<<<
 *             if c_node is NULL:
 *                 raise XPathError, u"no context node"
 */
  __pyx_v_c_node = ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_xpathCtxt->node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":288
 *                     u"XPath context is only usable during the evaluation"
 *             c_node = self._xpathCtxt.node
 *             if c_node is NULL:             # <<<<<<<<<<<<<<
 *                 raise XPathError, u"no context node"
 *             if c_node.doc != self._xpathCtxt.doc:
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":289
 *             c_node = self._xpathCtxt.node
 *             if c_node is NULL:
 *                 raise XPathError, u"no context node"             # <<<<<<<<<<<<<<
 *             if c_node.doc != self._xpathCtxt.doc:
 *                 raise XPathError, \
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_530), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":290
 *             if c_node is NULL:
 *                 raise XPathError, u"no context node"
 *             if c_node.doc != self._xpathCtxt.doc:             # <<<<<<<<<<<<<<
 *                 raise XPathError, \
 *                     u"document-external context nodes are not supported"
 */
  __pyx_1 = (__pyx_v_c_node->doc != ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_xpathCtxt->doc);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":291
 *                 raise XPathError, u"no context node"
 *             if c_node.doc != self._xpathCtxt.doc:
 *                 raise XPathError, \             # <<<<<<<<<<<<<<
 *                     u"document-external context nodes are not supported"
 *             if self._doc is None:
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":292
 *             if c_node.doc != self._xpathCtxt.doc:
 *                 raise XPathError, \
 *                     u"document-external context nodes are not supported"             # <<<<<<<<<<<<<<
 *             if self._doc is None:
 *                 raise XPathError, u"document context is missing"
 */
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_531), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":293
 *                 raise XPathError, \
 *                     u"document-external context nodes are not supported"
 *             if self._doc is None:             # <<<<<<<<<<<<<<
 *                 raise XPathError, u"document context is missing"
 *             return _elementFactory(self._doc, c_node)
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_doc) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":294
 *                     u"document-external context nodes are not supported"
 *             if self._doc is None:
 *                 raise XPathError, u"document context is missing"             # <<<<<<<<<<<<<<
 *             return _elementFactory(self._doc, c_node)
 * 
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_532), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":295
 *             if self._doc is None:
 *                 raise XPathError, u"document context is missing"
 *             return _elementFactory(self._doc, c_node)             # <<<<<<<<<<<<<<
 * 
 *     property eval_context:
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseContext.context_node.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":298
 * 
 *     property eval_context:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._eval_context_dict is None:
 *                 self._eval_context_dict = {}
 */

static PyObject *__pyx_pf_4lxml_5etree_12_BaseContext_12eval_context___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_BaseContext_12eval_context___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":299
 *     property eval_context:
 *         def __get__(self):
 *             if self._eval_context_dict is None:             # <<<<<<<<<<<<<<
 *                 self._eval_context_dict = {}
 *             return self._eval_context_dict
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":300
 *         def __get__(self):
 *             if self._eval_context_dict is None:
 *                 self._eval_context_dict = {}             # <<<<<<<<<<<<<<
 *             return self._eval_context_dict
 * 
 */
    __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict);
    ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict = ((PyObject *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":301
 *             if self._eval_context_dict is None:
 *                 self._eval_context_dict = {}
 *             return self._eval_context_dict             # <<<<<<<<<<<<<<
 * 
 *     # Python reference keeping during XPath function evaluation
 */
  Py_INCREF(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict);
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)->_eval_context_dict;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._BaseContext.eval_context.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":305
 *     # Python reference keeping during XPath function evaluation
 * 
 *     cdef _release_temp_refs(self):             # <<<<<<<<<<<<<<
 *         u"Free temporarily referenced objects from this context."
 *         self._temp_refs.clear()
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__release_temp_refs(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":307
 *     cdef _release_temp_refs(self):
 *         u"Free temporarily referenced objects from this context."
 *         self._temp_refs.clear()             # <<<<<<<<<<<<<<
 * 
 *     cdef _hold(self, obj):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_self->_temp_refs->__pyx_vtab)->clear(__pyx_v_self->_temp_refs); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree._BaseContext._release_temp_refs");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":309
 *         self._temp_refs.clear()
 * 
 *     cdef _hold(self, obj):             # <<<<<<<<<<<<<<
 *         u"""A way to temporarily hold references to nodes in the evaluator.
 * 
 */

static  PyObject *__pyx_f_4lxml_5etree_12_BaseContext__hold(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_v_o;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_v_o = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":317
 *         """
 *         cdef _Element element
 *         if isinstance(obj, _Element):             # <<<<<<<<<<<<<<
 *             self._temp_refs.add(obj)
 *             self._temp_refs.add((<_Element>obj)._doc)
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_obj, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":318
 *         cdef _Element element
 *         if isinstance(obj, _Element):
 *             self._temp_refs.add(obj)             # <<<<<<<<<<<<<<
 *             self._temp_refs.add((<_Element>obj)._doc)
 *             return
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_self->_temp_refs->__pyx_vtab)->add(__pyx_v_self->_temp_refs, __pyx_v_obj); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":319
 *         if isinstance(obj, _Element):
 *             self._temp_refs.add(obj)
 *             self._temp_refs.add((<_Element>obj)._doc)             # <<<<<<<<<<<<<<
 *             return
 *         elif _isString(obj) or not python.PySequence_Check(obj):
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_self->_temp_refs->__pyx_vtab)->add(__pyx_v_self->_temp_refs, ((PyObject *)((struct LxmlElement *)__pyx_v_obj)->_doc)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":320
 *             self._temp_refs.add(obj)
 *             self._temp_refs.add((<_Element>obj)._doc)
 *             return             # <<<<<<<<<<<<<<
 *         elif _isString(obj) or not python.PySequence_Check(obj):
 *             return
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":321
 *             self._temp_refs.add((<_Element>obj)._doc)
 *             return
 *         elif _isString(obj) or not python.PySequence_Check(obj):             # <<<<<<<<<<<<<<
 *             return
 *         for o in obj:
 */
  __pyx_1 = _isString(__pyx_v_obj);
  if (!__pyx_1) {
    __pyx_1 = (!PySequence_Check(__pyx_v_obj));
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":322
 *             return
 *         elif _isString(obj) or not python.PySequence_Check(obj):
 *             return             # <<<<<<<<<<<<<<
 *         for o in obj:
 *             if isinstance(o, _Element):
 */
    __pyx_r = Py_None; Py_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":323
 *         elif _isString(obj) or not python.PySequence_Check(obj):
 *             return
 *         for o in obj:             # <<<<<<<<<<<<<<
 *             if isinstance(o, _Element):
 *                 #print "Holding element:", <int>element._c_node
 */
  if (PyList_CheckExact(__pyx_v_obj) || PyTuple_CheckExact(__pyx_v_obj)) {
    __pyx_3 = 0; __pyx_4 = __pyx_v_obj; Py_INCREF(__pyx_4);
  } else {
    __pyx_3 = -1; __pyx_4 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_4))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_4)) break;
      __pyx_5 = PyList_GET_ITEM(__pyx_4, __pyx_3); Py_INCREF(__pyx_5); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_4))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_4)) break;
      __pyx_5 = PyTuple_GET_ITEM(__pyx_4, __pyx_3); Py_INCREF(__pyx_5); __pyx_3++;
    } else {
      __pyx_5 = PyIter_Next(__pyx_4);
      if (!__pyx_5) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_o);
    __pyx_v_o = __pyx_5;
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":324
 *             return
 *         for o in obj:
 *             if isinstance(o, _Element):             # <<<<<<<<<<<<<<
 *                 #print "Holding element:", <int>element._c_node
 *                 self._temp_refs.add(o)
 */
    __pyx_1 = PyObject_TypeCheck(__pyx_v_o, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":326
 *             if isinstance(o, _Element):
 *                 #print "Holding element:", <int>element._c_node
 *                 self._temp_refs.add(o)             # <<<<<<<<<<<<<<
 *                 #print "Holding document:", <int>element._doc._c_doc
 *                 self._temp_refs.add((<_Element>o)._doc)
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_self->_temp_refs->__pyx_vtab)->add(__pyx_v_self->_temp_refs, __pyx_v_o); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":328
 *                 self._temp_refs.add(o)
 *                 #print "Holding document:", <int>element._doc._c_doc
 *                 self._temp_refs.add((<_Element>o)._doc)             # <<<<<<<<<<<<<<
 * 
 * def Extension(module, function_mapping=None, *, ns=None):
 */
      __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__TempStore *)__pyx_v_self->_temp_refs->__pyx_vtab)->add(__pyx_v_self->_temp_refs, ((PyObject *)((struct LxmlElement *)__pyx_v_o)->_doc)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._BaseContext._hold");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_o);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":330
 *                 self._temp_refs.add((<_Element>o)._doc)
 * 
 * def Extension(module, function_mapping=None, *, ns=None):             # <<<<<<<<<<<<<<
 *     u"""Extension(module, function_mapping=None, ns=None)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_Extension(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_Extension[] = "Extension(module, function_mapping=None, ns=None)\n\n    Build a dictionary of extension functions from the functions\n    defined in a module or the methods of an object.\n\n    As second argument, you can pass an additional mapping of\n    attribute names to XPath function names, or a list of function\n    names that should be taken.\n\n    The ``ns`` keyword argument accepts a namespace URI for the XPath\n    functions.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_Extension(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_module = 0;
  PyObject *__pyx_v_function_mapping = 0;
  PyObject *__pyx_v_ns = 0;
  PyObject *__pyx_v_functions;
  PyObject *__pyx_v_function_name;
  PyObject *__pyx_v_xpath_name;
  PyObject *__pyx_v_name;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  PyObject *__pyx_8 = 0;
  int __pyx_9;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_module,&__pyx_kp_function_mapping,&__pyx_kp_ns,0};
  __pyx_self = __pyx_self;
  __pyx_v_function_mapping = Py_None;
  __pyx_v_ns = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[3] = {0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_module);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "Extension") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_module = values[0];
    if (values[1]) {
      __pyx_v_function_mapping = values[1];
    }
    if (values[2]) {
      __pyx_v_ns = values[2];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_function_mapping = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_module = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Extension", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Extension");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_function_mapping);
  __pyx_v_functions = Py_None; Py_INCREF(Py_None);
  __pyx_v_function_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_xpath_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_name = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":343
 *     functions.
 *     """
 *     functions = {}             # <<<<<<<<<<<<<<
 *     if python.PyDict_Check(function_mapping):
 *         for function_name, xpath_name in function_mapping.items():
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_functions);
  __pyx_v_functions = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":344
 *     """
 *     functions = {}
 *     if python.PyDict_Check(function_mapping):             # <<<<<<<<<<<<<<
 *         for function_name, xpath_name in function_mapping.items():
 *             python.PyDict_SetItem(functions, (ns, xpath_name),
 */
  __pyx_2 = PyDict_Check(__pyx_v_function_mapping);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":345
 *     functions = {}
 *     if python.PyDict_Check(function_mapping):
 *         for function_name, xpath_name in function_mapping.items():             # <<<<<<<<<<<<<<
 *             python.PyDict_SetItem(functions, (ns, xpath_name),
 *                                   getattr(module, function_name))
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_function_mapping, __pyx_kp_items); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
      __pyx_3 = 0; __pyx_1 = __pyx_4; Py_INCREF(__pyx_1);
    } else {
      __pyx_3 = -1; __pyx_1 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_1))) {
        if (__pyx_3 >= PyList_GET_SIZE(__pyx_1)) break;
        __pyx_4 = PyList_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else if (likely(PyTuple_CheckExact(__pyx_1))) {
        if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_1)) break;
        __pyx_4 = PyTuple_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
      } else {
        __pyx_4 = PyIter_Next(__pyx_1);
        if (!__pyx_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (PyTuple_CheckExact(__pyx_4) && PyTuple_GET_SIZE(__pyx_4) == 2) {
        PyObject* tuple = __pyx_4;
        __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_6);
        Py_DECREF(__pyx_v_function_name);
        __pyx_v_function_name = __pyx_6;
        __pyx_6 = 0;
        __pyx_6 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_6);
        Py_DECREF(__pyx_v_xpath_name);
        __pyx_v_xpath_name = __pyx_6;
        __pyx_6 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
      }
      else {
        __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_function_name);
        __pyx_v_function_name = __pyx_6;
        __pyx_6 = 0;
        __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_xpath_name);
        __pyx_v_xpath_name = __pyx_6;
        __pyx_6 = 0;
        if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":346
 *     if python.PyDict_Check(function_mapping):
 *         for function_name, xpath_name in function_mapping.items():
 *             python.PyDict_SetItem(functions, (ns, xpath_name),             # <<<<<<<<<<<<<<
 *                                   getattr(module, function_name))
 *     else:
 */
      __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_ns);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_ns);
      Py_INCREF(__pyx_v_xpath_name);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_xpath_name);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":347
 *         for function_name, xpath_name in function_mapping.items():
 *             python.PyDict_SetItem(functions, (ns, xpath_name),
 *                                   getattr(module, function_name))             # <<<<<<<<<<<<<<
 *     else:
 *         if function_mapping is None:
 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_module, __pyx_v_function_name); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_7 = PyDict_SetItem(__pyx_v_functions, ((PyObject *)__pyx_6), __pyx_4); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":349
 *                                   getattr(module, function_name))
 *     else:
 *         if function_mapping is None:             # <<<<<<<<<<<<<<
 *             function_mapping = [ name for name in dir(module)
 *                                  if not name.startswith(u'_') ]
 */
    __pyx_2 = (__pyx_v_function_mapping == Py_None);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":350
 *     else:
 *         if function_mapping is None:
 *             function_mapping = [ name for name in dir(module)             # <<<<<<<<<<<<<<
 *                                  if not name.startswith(u'_') ]
 *         for function_name in function_mapping:
 */
      __pyx_5 = PyList_New(0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_6 = PyObject_Dir(__pyx_v_module); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (PyList_CheckExact(__pyx_6) || PyTuple_CheckExact(__pyx_6)) {
        __pyx_3 = 0; __pyx_4 = __pyx_6; Py_INCREF(__pyx_4);
      } else {
        __pyx_3 = -1; __pyx_4 = PyObject_GetIter(__pyx_6); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      for (;;) {
        if (likely(PyList_CheckExact(__pyx_4))) {
          if (__pyx_3 >= PyList_GET_SIZE(__pyx_4)) break;
          __pyx_1 = PyList_GET_ITEM(__pyx_4, __pyx_3); Py_INCREF(__pyx_1); __pyx_3++;
        } else if (likely(PyTuple_CheckExact(__pyx_4))) {
          if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_4)) break;
          __pyx_1 = PyTuple_GET_ITEM(__pyx_4, __pyx_3); Py_INCREF(__pyx_1); __pyx_3++;
        } else {
          __pyx_1 = PyIter_Next(__pyx_4);
          if (!__pyx_1) {
            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            break;
          }
        }
        Py_DECREF(__pyx_v_name);
        __pyx_v_name = __pyx_1;
        __pyx_1 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":351
 *         if function_mapping is None:
 *             function_mapping = [ name for name in dir(module)
 *                                  if not name.startswith(u'_') ]             # <<<<<<<<<<<<<<
 *         for function_name in function_mapping:
 *             python.PyDict_SetItem(functions, (ns, function_name),
 */
        __pyx_6 = PyObject_GetAttr(__pyx_v_name, __pyx_kp_startswith); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(((PyObject *)__pyx_kp_533));
        PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_kp_533));
        __pyx_8 = PyObject_Call(__pyx_6, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
        __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_8); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        __pyx_9 = (!__pyx_2);
        if (__pyx_9) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":350
 *     else:
 *         if function_mapping is None:
 *             function_mapping = [ name for name in dir(module)             # <<<<<<<<<<<<<<
 *                                  if not name.startswith(u'_') ]
 *         for function_name in function_mapping:
 */
          __pyx_7 = PyList_Append(__pyx_5, (PyObject*)__pyx_v_name); if (unlikely(__pyx_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L12;
        }
        __pyx_L12:;
      }
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_v_function_mapping);
      __pyx_v_function_mapping = ((PyObject *)__pyx_5);
      __pyx_5 = 0;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":352
 *             function_mapping = [ name for name in dir(module)
 *                                  if not name.startswith(u'_') ]
 *         for function_name in function_mapping:             # <<<<<<<<<<<<<<
 *             python.PyDict_SetItem(functions, (ns, function_name),
 *                                   getattr(module, function_name))
 */
    if (PyList_CheckExact(__pyx_v_function_mapping) || PyTuple_CheckExact(__pyx_v_function_mapping)) {
      __pyx_3 = 0; __pyx_6 = __pyx_v_function_mapping; Py_INCREF(__pyx_6);
    } else {
      __pyx_3 = -1; __pyx_6 = PyObject_GetIter(__pyx_v_function_mapping); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_6))) {
        if (__pyx_3 >= PyList_GET_SIZE(__pyx_6)) break;
        __pyx_1 = PyList_GET_ITEM(__pyx_6, __pyx_3); Py_INCREF(__pyx_1); __pyx_3++;
      } else if (likely(PyTuple_CheckExact(__pyx_6))) {
        if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_6)) break;
        __pyx_1 = PyTuple_GET_ITEM(__pyx_6, __pyx_3); Py_INCREF(__pyx_1); __pyx_3++;
      } else {
        __pyx_1 = PyIter_Next(__pyx_6);
        if (!__pyx_1) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_function_name);
      __pyx_v_function_name = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":353
 *                                  if not name.startswith(u'_') ]
 *         for function_name in function_mapping:
 *             python.PyDict_SetItem(functions, (ns, function_name),             # <<<<<<<<<<<<<<
 *                                   getattr(module, function_name))
 *     return functions
 */
      __pyx_8 = PyTuple_New(2); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_ns);
      PyTuple_SET_ITEM(__pyx_8, 0, __pyx_v_ns);
      Py_INCREF(__pyx_v_function_name);
      PyTuple_SET_ITEM(__pyx_8, 1, __pyx_v_function_name);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":354
 *         for function_name in function_mapping:
 *             python.PyDict_SetItem(functions, (ns, function_name),
 *                                   getattr(module, function_name))             # <<<<<<<<<<<<<<
 *     return functions
 * 
 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_module, __pyx_v_function_name); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_7 = PyDict_SetItem(__pyx_v_functions, ((PyObject *)__pyx_8), __pyx_4); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_8)); __pyx_8 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    Py_DECREF(__pyx_6); __pyx_6 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":355
 *             python.PyDict_SetItem(functions, (ns, function_name),
 *                                   getattr(module, function_name))
 *     return functions             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  Py_INCREF(__pyx_v_functions);
  __pyx_r = __pyx_v_functions;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("lxml.etree.Extension");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_functions);
  Py_DECREF(__pyx_v_function_name);
  Py_DECREF(__pyx_v_xpath_name);
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_function_mapping);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":362
 * cdef class _ExsltRegExp:
 *     cdef object _compile_map
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._compile_map = {}
 * 
 */

static int __pyx_pf_4lxml_5etree_12_ExsltRegExp___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_12_ExsltRegExp___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":363
 *     cdef object _compile_map
 *     def __init__(self):
 *         self._compile_map = {}             # <<<<<<<<<<<<<<
 * 
 *     cdef _make_string(self, value):
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->_compile_map);
  ((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->_compile_map = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":365
 *         self._compile_map = {}
 * 
 *     cdef _make_string(self, value):             # <<<<<<<<<<<<<<
 *         cdef char* c_text
 *         if _isString(value):
 */

static  PyObject *__pyx_f_4lxml_5etree_12_ExsltRegExp__make_string(struct __pyx_obj_4lxml_5etree__ExsltRegExp *__pyx_v_self, PyObject *__pyx_v_value) {
  char *__pyx_v_c_text;
  PyObject *__pyx_v_firstnode;
  PyObject *__pyx_v_s;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_firstnode = Py_None; Py_INCREF(Py_None);
  __pyx_v_s = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":367
 *     cdef _make_string(self, value):
 *         cdef char* c_text
 *         if _isString(value):             # <<<<<<<<<<<<<<
 *             return value
 *         elif python.PyList_Check(value):
 */
  __pyx_1 = _isString(__pyx_v_value);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":368
 *         cdef char* c_text
 *         if _isString(value):
 *             return value             # <<<<<<<<<<<<<<
 *         elif python.PyList_Check(value):
 *             # node set: take recursive text concatenation of first element
 */
    Py_INCREF(__pyx_v_value);
    __pyx_r = __pyx_v_value;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":369
 *         if _isString(value):
 *             return value
 *         elif python.PyList_Check(value):             # <<<<<<<<<<<<<<
 *             # node set: take recursive text concatenation of first element
 *             if python.PyList_GET_SIZE(value) == 0:
 */
  __pyx_1 = PyList_Check(__pyx_v_value);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":371
 *         elif python.PyList_Check(value):
 *             # node set: take recursive text concatenation of first element
 *             if python.PyList_GET_SIZE(value) == 0:             # <<<<<<<<<<<<<<
 *                 return u''
 *             firstnode = value[0]
 */
    __pyx_1 = (PyList_GET_SIZE(__pyx_v_value) == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":372
 *             # node set: take recursive text concatenation of first element
 *             if python.PyList_GET_SIZE(value) == 0:
 *                 return u''             # <<<<<<<<<<<<<<
 *             firstnode = value[0]
 *             if _isString(firstnode):
 */
      Py_INCREF(((PyObject *)__pyx_kp_534));
      __pyx_r = ((PyObject *)__pyx_kp_534);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":373
 *             if python.PyList_GET_SIZE(value) == 0:
 *                 return u''
 *             firstnode = value[0]             # <<<<<<<<<<<<<<
 *             if _isString(firstnode):
 *                 return firstnode
 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_value, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_firstnode);
    __pyx_v_firstnode = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":374
 *                 return u''
 *             firstnode = value[0]
 *             if _isString(firstnode):             # <<<<<<<<<<<<<<
 *                 return firstnode
 *             elif isinstance(firstnode, _Element):
 */
    __pyx_1 = _isString(__pyx_v_firstnode);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":375
 *             firstnode = value[0]
 *             if _isString(firstnode):
 *                 return firstnode             # <<<<<<<<<<<<<<
 *             elif isinstance(firstnode, _Element):
 *                 c_text = tree.xmlNodeGetContent((<_Element>firstnode)._c_node)
 */
      Py_INCREF(__pyx_v_firstnode);
      __pyx_r = __pyx_v_firstnode;
      goto __pyx_L0;
      goto __pyx_L5;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":376
 *             if _isString(firstnode):
 *                 return firstnode
 *             elif isinstance(firstnode, _Element):             # <<<<<<<<<<<<<<
 *                 c_text = tree.xmlNodeGetContent((<_Element>firstnode)._c_node)
 *                 if c_text is NULL:
 */
    __pyx_1 = PyObject_TypeCheck(__pyx_v_firstnode, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":377
 *                 return firstnode
 *             elif isinstance(firstnode, _Element):
 *                 c_text = tree.xmlNodeGetContent((<_Element>firstnode)._c_node)             # <<<<<<<<<<<<<<
 *                 if c_text is NULL:
 *                     python.PyErr_NoMemory()
 */
      __pyx_v_c_text = xmlNodeGetContent(((struct LxmlElement *)__pyx_v_firstnode)->_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":378
 *             elif isinstance(firstnode, _Element):
 *                 c_text = tree.xmlNodeGetContent((<_Element>firstnode)._c_node)
 *                 if c_text is NULL:             # <<<<<<<<<<<<<<
 *                     python.PyErr_NoMemory()
 *                 try:
 */
      __pyx_1 = (__pyx_v_c_text == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":379
 *                 c_text = tree.xmlNodeGetContent((<_Element>firstnode)._c_node)
 *                 if c_text is NULL:
 *                     python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *                 try:
 *                     s = funicode(c_text)
 */
        __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":380
 *                 if c_text is NULL:
 *                     python.PyErr_NoMemory()
 *                 try:             # <<<<<<<<<<<<<<
 *                     s = funicode(c_text)
 *                 finally:
 */
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":381
 *                     python.PyErr_NoMemory()
 *                 try:
 *                     s = funicode(c_text)             # <<<<<<<<<<<<<<
 *                 finally:
 *                     tree.xmlFree(c_text)
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_text); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L8;}
        Py_DECREF(__pyx_v_s);
        __pyx_v_s = __pyx_2;
        __pyx_2 = 0;
      }
      /*finally:*/ {
        int __pyx_why;
        PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
        int __pyx_exc_lineno;
        __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
        __pyx_why = 0; goto __pyx_L9;
        __pyx_L8: {
          __pyx_why = 4;
          Py_XDECREF(__pyx_2); __pyx_2 = 0;
          __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
          __pyx_exc_lineno = __pyx_lineno;
          goto __pyx_L9;
        }
        __pyx_L9:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":383
 *                     s = funicode(c_text)
 *                 finally:
 *                     tree.xmlFree(c_text)             # <<<<<<<<<<<<<<
 *                 return s
 *             else:
 */
        xmlFree(__pyx_v_c_text);
        switch (__pyx_why) {
          case 4: {
            __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
            __pyx_lineno = __pyx_exc_lineno;
            __pyx_exc_type = 0;
            __pyx_exc_value = 0;
            __pyx_exc_tb = 0;
            goto __pyx_L1_error;
          }
        }
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":384
 *                 finally:
 *                     tree.xmlFree(c_text)
 *                 return s             # <<<<<<<<<<<<<<
 *             else:
 *                 return unicode(firstnode)
 */
      Py_INCREF(__pyx_v_s);
      __pyx_r = __pyx_v_s;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":386
 *                 return s
 *             else:
 *                 return unicode(firstnode)             # <<<<<<<<<<<<<<
 *         else:
 *             return unicode(value)
 */
      __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_firstnode);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_firstnode);
      __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":388
 *                 return unicode(firstnode)
 *         else:
 *             return unicode(value)             # <<<<<<<<<<<<<<
 * 
 *     cdef _compile(self, rexp, ignore_case):
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_value);
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp._make_string");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_firstnode);
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":390
 *             return unicode(value)
 * 
 *     cdef _compile(self, rexp, ignore_case):             # <<<<<<<<<<<<<<
 *         cdef python.PyObject* c_result
 *         rexp = self._make_string(rexp)
 */

static  PyObject *__pyx_f_4lxml_5etree_12_ExsltRegExp__compile(struct __pyx_obj_4lxml_5etree__ExsltRegExp *__pyx_v_self, PyObject *__pyx_v_rexp, PyObject *__pyx_v_ignore_case) {
  PyObject *__pyx_v_c_result;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_py_flags;
  PyObject *__pyx_v_rexp_compiled;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_rexp);
  __pyx_v_key = Py_None; Py_INCREF(Py_None);
  __pyx_v_py_flags = Py_None; Py_INCREF(Py_None);
  __pyx_v_rexp_compiled = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":392
 *     cdef _compile(self, rexp, ignore_case):
 *         cdef python.PyObject* c_result
 *         rexp = self._make_string(rexp)             # <<<<<<<<<<<<<<
 *         key = (rexp, ignore_case)
 *         c_result = python.PyDict_GetItem(self._compile_map, key)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)__pyx_v_self->__pyx_vtab)->_make_string(__pyx_v_self, __pyx_v_rexp); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_rexp);
  __pyx_v_rexp = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":393
 *         cdef python.PyObject* c_result
 *         rexp = self._make_string(rexp)
 *         key = (rexp, ignore_case)             # <<<<<<<<<<<<<<
 *         c_result = python.PyDict_GetItem(self._compile_map, key)
 *         if c_result is not NULL:
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_rexp);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_rexp);
  Py_INCREF(__pyx_v_ignore_case);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_ignore_case);
  Py_DECREF(__pyx_v_key);
  __pyx_v_key = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":394
 *         rexp = self._make_string(rexp)
 *         key = (rexp, ignore_case)
 *         c_result = python.PyDict_GetItem(self._compile_map, key)             # <<<<<<<<<<<<<<
 *         if c_result is not NULL:
 *             return <object>c_result
 */
  __pyx_v_c_result = PyDict_GetItem(__pyx_v_self->_compile_map, __pyx_v_key);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":395
 *         key = (rexp, ignore_case)
 *         c_result = python.PyDict_GetItem(self._compile_map, key)
 *         if c_result is not NULL:             # <<<<<<<<<<<<<<
 *             return <object>c_result
 *         py_flags = re.UNICODE
 */
  __pyx_2 = (__pyx_v_c_result != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":396
 *         c_result = python.PyDict_GetItem(self._compile_map, key)
 *         if c_result is not NULL:
 *             return <object>c_result             # <<<<<<<<<<<<<<
 *         py_flags = re.UNICODE
 *         if ignore_case:
 */
    Py_INCREF(((PyObject *)__pyx_v_c_result));
    __pyx_r = ((PyObject *)__pyx_v_c_result);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":397
 *         if c_result is not NULL:
 *             return <object>c_result
 *         py_flags = re.UNICODE             # <<<<<<<<<<<<<<
 *         if ignore_case:
 *             py_flags = py_flags | re.IGNORECASE
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_UNICODE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_py_flags);
  __pyx_v_py_flags = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":398
 *             return <object>c_result
 *         py_flags = re.UNICODE
 *         if ignore_case:             # <<<<<<<<<<<<<<
 *             py_flags = py_flags | re.IGNORECASE
 *         rexp_compiled = re.compile(rexp, py_flags)
 */
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_case); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":399
 *         py_flags = re.UNICODE
 *         if ignore_case:
 *             py_flags = py_flags | re.IGNORECASE             # <<<<<<<<<<<<<<
 *         rexp_compiled = re.compile(rexp, py_flags)
 *         python.PyDict_SetItem(self._compile_map, key, rexp_compiled)
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_IGNORECASE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Or(__pyx_v_py_flags, __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_v_py_flags);
    __pyx_v_py_flags = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":400
 *         if ignore_case:
 *             py_flags = py_flags | re.IGNORECASE
 *         rexp_compiled = re.compile(rexp, py_flags)             # <<<<<<<<<<<<<<
 *         python.PyDict_SetItem(self._compile_map, key, rexp_compiled)
 *         return rexp_compiled
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_rexp);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_rexp);
  Py_INCREF(__pyx_v_py_flags);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_py_flags);
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_v_rexp_compiled);
  __pyx_v_rexp_compiled = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":401
 *             py_flags = py_flags | re.IGNORECASE
 *         rexp_compiled = re.compile(rexp, py_flags)
 *         python.PyDict_SetItem(self._compile_map, key, rexp_compiled)             # <<<<<<<<<<<<<<
 *         return rexp_compiled
 * 
 */
  __pyx_5 = PyDict_SetItem(__pyx_v_self->_compile_map, __pyx_v_key, __pyx_v_rexp_compiled); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":402
 *         rexp_compiled = re.compile(rexp, py_flags)
 *         python.PyDict_SetItem(self._compile_map, key, rexp_compiled)
 *         return rexp_compiled             # <<<<<<<<<<<<<<
 * 
 *     def test(self, ctxt, s, rexp, flags=u''):
 */
  Py_INCREF(__pyx_v_rexp_compiled);
  __pyx_r = __pyx_v_rexp_compiled;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp._compile");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_py_flags);
  Py_DECREF(__pyx_v_rexp_compiled);
  Py_DECREF(__pyx_v_rexp);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":404
 *         return rexp_compiled
 * 
 *     def test(self, ctxt, s, rexp, flags=u''):             # <<<<<<<<<<<<<<
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ExsltRegExp_test(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ExsltRegExp_test(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ctxt = 0;
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_rexp = 0;
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_rexpc;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_ctxt,&__pyx_kp_s,&__pyx_kp_rexp,&__pyx_kp_flags,0};
  __pyx_v_flags = ((PyObject *)__pyx_kp_164);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_ctxt);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_s);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("test", 0, 3, 4, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_rexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("test", 0, 3, 4, 2); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "test") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_ctxt = values[0];
    __pyx_v_s = values[1];
    __pyx_v_rexp = values[2];
    if (values[3]) {
      __pyx_v_flags = values[3];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4:
      __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_rexp = PyTuple_GET_ITEM(__pyx_args, 2);
      __pyx_v_s = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_ctxt = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("test", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.test");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_s);
  Py_INCREF(__pyx_v_flags);
  __pyx_v_rexpc = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":405
 * 
 *     def test(self, ctxt, s, rexp, flags=u''):
 *         flags = self._make_string(flags)             # <<<<<<<<<<<<<<
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_flags); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_flags);
  __pyx_v_flags = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":406
 *     def test(self, ctxt, s, rexp, flags=u''):
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)             # <<<<<<<<<<<<<<
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if rexpc.search(s) is None:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_s); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":407
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)             # <<<<<<<<<<<<<<
 *         if rexpc.search(s) is None:
 *             return False
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_flags, ((PyObject *)__pyx_kp_535))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyBool_FromLong(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_compile(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_rexp, __pyx_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_rexpc);
  __pyx_v_rexpc = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":408
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if rexpc.search(s) is None:             # <<<<<<<<<<<<<<
 *             return False
 *         else:
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_rexpc, __pyx_kp_search); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_2 = (__pyx_4 == Py_None);
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":409
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if rexpc.search(s) is None:
 *             return False             # <<<<<<<<<<<<<<
 *         else:
 *             return True
 */
    __pyx_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":411
 *             return False
 *         else:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     def match(self, ctxt, s, rexp, flags=u''):
 */
    __pyx_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.test");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_rexpc);
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_flags);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":413
 *             return True
 * 
 *     def match(self, ctxt, s, rexp, flags=u''):             # <<<<<<<<<<<<<<
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ExsltRegExp_match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ExsltRegExp_match(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ctxt = 0;
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_rexp = 0;
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_rexpc;
  PyObject *__pyx_v_results;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_result_list;
  PyObject *__pyx_v_root;
  PyObject *__pyx_v_join_groups;
  PyObject *__pyx_v_s_match;
  PyObject *__pyx_v_elem;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  Py_ssize_t __pyx_7 = 0;
  int __pyx_8;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_ctxt,&__pyx_kp_s,&__pyx_kp_rexp,&__pyx_kp_flags,0};
  __pyx_v_flags = ((PyObject *)__pyx_kp_165);
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_ctxt);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_s);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("match", 0, 3, 4, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_rexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("match", 0, 3, 4, 2); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "match") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_ctxt = values[0];
    __pyx_v_s = values[1];
    __pyx_v_rexp = values[2];
    if (values[3]) {
      __pyx_v_flags = values[3];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4:
      __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3:
      __pyx_v_rexp = PyTuple_GET_ITEM(__pyx_args, 2);
      __pyx_v_s = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_ctxt = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("match", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.match");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_s);
  Py_INCREF(__pyx_v_flags);
  __pyx_v_rexpc = Py_None; Py_INCREF(Py_None);
  __pyx_v_results = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_result_list = Py_None; Py_INCREF(Py_None);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);
  __pyx_v_join_groups = Py_None; Py_INCREF(Py_None);
  __pyx_v_s_match = Py_None; Py_INCREF(Py_None);
  __pyx_v_elem = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":414
 * 
 *     def match(self, ctxt, s, rexp, flags=u''):
 *         flags = self._make_string(flags)             # <<<<<<<<<<<<<<
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_flags); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_flags);
  __pyx_v_flags = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":415
 *     def match(self, ctxt, s, rexp, flags=u''):
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)             # <<<<<<<<<<<<<<
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if u'g' in flags:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_s); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":416
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)             # <<<<<<<<<<<<<<
 *         if u'g' in flags:
 *             results = rexpc.findall(s)
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_flags, ((PyObject *)__pyx_kp_536))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyBool_FromLong(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_compile(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_rexp, __pyx_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_rexpc);
  __pyx_v_rexpc = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":417
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if u'g' in flags:             # <<<<<<<<<<<<<<
 *             results = rexpc.findall(s)
 *             if not results:
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_flags, ((PyObject *)__pyx_kp_537))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":418
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if u'g' in flags:
 *             results = rexpc.findall(s)             # <<<<<<<<<<<<<<
 *             if not results:
 *                 return ()
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_rexpc, __pyx_kp_findall); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_v_results);
    __pyx_v_results = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":419
 *         if u'g' in flags:
 *             results = rexpc.findall(s)
 *             if not results:             # <<<<<<<<<<<<<<
 *                 return ()
 *         else:
 */
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_results); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_5 = (!__pyx_2);
    if (__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":420
 *             results = rexpc.findall(s)
 *             if not results:
 *                 return ()             # <<<<<<<<<<<<<<
 *         else:
 *             result = rexpc.search(s)
 */
      Py_INCREF(((PyObject *)__pyx_empty_tuple));
      __pyx_r = ((PyObject *)__pyx_empty_tuple);
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":422
 *                 return ()
 *         else:
 *             result = rexpc.search(s)             # <<<<<<<<<<<<<<
 *             if not result:
 *                 return ()
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_rexpc, __pyx_kp_search); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":423
 *         else:
 *             result = rexpc.search(s)
 *             if not result:             # <<<<<<<<<<<<<<
 *                 return ()
 *             results = [ result.group() ]
 */
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_result); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_5 = (!__pyx_2);
    if (__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":424
 *             result = rexpc.search(s)
 *             if not result:
 *                 return ()             # <<<<<<<<<<<<<<
 *             results = [ result.group() ]
 *             results.extend( result.groups(u'') )
 */
      Py_INCREF(((PyObject *)__pyx_empty_tuple));
      __pyx_r = ((PyObject *)__pyx_empty_tuple);
      goto __pyx_L0;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":425
 *             if not result:
 *                 return ()
 *             results = [ result.group() ]             # <<<<<<<<<<<<<<
 *             results.extend( result.groups(u'') )
 *         result_list = []
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_result, __pyx_kp_group); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_4 = PyList_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyList_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    Py_DECREF(__pyx_v_results);
    __pyx_v_results = ((PyObject *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":426
 *                 return ()
 *             results = [ result.group() ]
 *             results.extend( result.groups(u'') )             # <<<<<<<<<<<<<<
 *         result_list = []
 *         root = Element(u'matches')
 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_results, __pyx_kp_extend); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_kp_groups); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_538));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_kp_538));
    __pyx_6 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6);
    __pyx_6 = 0;
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":427
 *             results = [ result.group() ]
 *             results.extend( result.groups(u'') )
 *         result_list = []             # <<<<<<<<<<<<<<
 *         root = Element(u'matches')
 *         join_groups = u''.join
 */
  __pyx_6 = PyList_New(0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result_list);
  __pyx_v_result_list = ((PyObject *)__pyx_6);
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":428
 *             results.extend( result.groups(u'') )
 *         result_list = []
 *         root = Element(u'matches')             # <<<<<<<<<<<<<<
 *         join_groups = u''.join
 *         for s_match in results:
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_Element); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_539));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_539));
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":429
 *         result_list = []
 *         root = Element(u'matches')
 *         join_groups = u''.join             # <<<<<<<<<<<<<<
 *         for s_match in results:
 *             if python.PyTuple_CheckExact(s_match):
 */
  __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_kp_540), __pyx_kp_join); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_join_groups);
  __pyx_v_join_groups = __pyx_6;
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":430
 *         root = Element(u'matches')
 *         join_groups = u''.join
 *         for s_match in results:             # <<<<<<<<<<<<<<
 *             if python.PyTuple_CheckExact(s_match):
 *                 s_match = join_groups(s_match)
 */
  if (PyList_CheckExact(__pyx_v_results) || PyTuple_CheckExact(__pyx_v_results)) {
    __pyx_7 = 0; __pyx_1 = __pyx_v_results; Py_INCREF(__pyx_1);
  } else {
    __pyx_7 = -1; __pyx_1 = PyObject_GetIter(__pyx_v_results); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_7 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_1, __pyx_7); Py_INCREF(__pyx_3); __pyx_7++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_7 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_1, __pyx_7); Py_INCREF(__pyx_3); __pyx_7++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_s_match);
    __pyx_v_s_match = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":431
 *         join_groups = u''.join
 *         for s_match in results:
 *             if python.PyTuple_CheckExact(s_match):             # <<<<<<<<<<<<<<
 *                 s_match = join_groups(s_match)
 *             elem = SubElement(root, u'match')
 */
    __pyx_2 = PyTuple_CheckExact(__pyx_v_s_match);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":432
 *         for s_match in results:
 *             if python.PyTuple_CheckExact(s_match):
 *                 s_match = join_groups(s_match)             # <<<<<<<<<<<<<<
 *             elem = SubElement(root, u'match')
 *             elem.text = s_match
 */
      __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_s_match);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_s_match);
      __pyx_6 = PyObject_Call(__pyx_v_join_groups, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      Py_DECREF(__pyx_v_s_match);
      __pyx_v_s_match = __pyx_6;
      __pyx_6 = 0;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":433
 *             if python.PyTuple_CheckExact(s_match):
 *                 s_match = join_groups(s_match)
 *             elem = SubElement(root, u'match')             # <<<<<<<<<<<<<<
 *             elem.text = s_match
 *             python.PyList_Append(result_list, elem)
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_SubElement); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_root);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_root);
    Py_INCREF(((PyObject *)__pyx_kp_541));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_kp_541));
    __pyx_6 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    Py_DECREF(__pyx_v_elem);
    __pyx_v_elem = __pyx_6;
    __pyx_6 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":434
 *                 s_match = join_groups(s_match)
 *             elem = SubElement(root, u'match')
 *             elem.text = s_match             # <<<<<<<<<<<<<<
 *             python.PyList_Append(result_list, elem)
 *         return result_list
 */
    if (PyObject_SetAttr(__pyx_v_elem, __pyx_kp_text, __pyx_v_s_match) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":435
 *             elem = SubElement(root, u'match')
 *             elem.text = s_match
 *             python.PyList_Append(result_list, elem)             # <<<<<<<<<<<<<<
 *         return result_list
 * 
 */
    __pyx_8 = PyList_Append(__pyx_v_result_list, __pyx_v_elem); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":436
 *             elem.text = s_match
 *             python.PyList_Append(result_list, elem)
 *         return result_list             # <<<<<<<<<<<<<<
 * 
 *     def replace(self, ctxt, s, rexp, flags, replacement):
 */
  Py_INCREF(__pyx_v_result_list);
  __pyx_r = __pyx_v_result_list;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.match");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_rexpc);
  Py_DECREF(__pyx_v_results);
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_result_list);
  Py_DECREF(__pyx_v_root);
  Py_DECREF(__pyx_v_join_groups);
  Py_DECREF(__pyx_v_s_match);
  Py_DECREF(__pyx_v_elem);
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_flags);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":438
 *         return result_list
 * 
 *     def replace(self, ctxt, s, rexp, flags, replacement):             # <<<<<<<<<<<<<<
 *         replacement = self._make_string(replacement)
 *         flags = self._make_string(flags)
 */

static PyObject *__pyx_pf_4lxml_5etree_12_ExsltRegExp_replace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_12_ExsltRegExp_replace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ctxt = 0;
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_v_rexp = 0;
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_replacement = 0;
  PyObject *__pyx_v_rexpc;
  PyObject *__pyx_v_count;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_ctxt,&__pyx_kp_s,&__pyx_kp_rexp,&__pyx_kp_flags,&__pyx_kp_replacement,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_ctxt);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_s);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("replace", 1, 5, 5, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_rexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("replace", 1, 5, 5, 2); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_flags);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("replace", 1, 5, 5, 3); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_kp_replacement);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("replace", 1, 5, 5, 4); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "replace") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_ctxt = values[0];
    __pyx_v_s = values[1];
    __pyx_v_rexp = values[2];
    __pyx_v_flags = values[3];
    __pyx_v_replacement = values[4];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_ctxt = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_s = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_rexp = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 3);
    __pyx_v_replacement = PyTuple_GET_ITEM(__pyx_args, 4);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("replace", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.replace");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_s);
  Py_INCREF(__pyx_v_flags);
  Py_INCREF(__pyx_v_replacement);
  __pyx_v_rexpc = Py_None; Py_INCREF(Py_None);
  __pyx_v_count = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":439
 * 
 *     def replace(self, ctxt, s, rexp, flags, replacement):
 *         replacement = self._make_string(replacement)             # <<<<<<<<<<<<<<
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_replacement); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_replacement);
  __pyx_v_replacement = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":440
 *     def replace(self, ctxt, s, rexp, flags, replacement):
 *         replacement = self._make_string(replacement)
 *         flags = self._make_string(flags)             # <<<<<<<<<<<<<<
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_flags); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_flags);
  __pyx_v_flags = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":441
 *         replacement = self._make_string(replacement)
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)             # <<<<<<<<<<<<<<
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if u'g' in flags:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_make_string(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_s); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":442
 *         flags = self._make_string(flags)
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)             # <<<<<<<<<<<<<<
 *         if u'g' in flags:
 *             count = 0
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_flags, ((PyObject *)__pyx_kp_542))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_PyBool_FromLong(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp *)((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self)->__pyx_vtab)->_compile(((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)__pyx_v_self), __pyx_v_rexp, __pyx_1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_rexpc);
  __pyx_v_rexpc = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":443
 *         s = self._make_string(s)
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if u'g' in flags:             # <<<<<<<<<<<<<<
 *             count = 0
 *         else:
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_flags, ((PyObject *)__pyx_kp_543))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":444
 *         rexpc = self._compile(rexp, u'i' in flags)
 *         if u'g' in flags:
 *             count = 0             # <<<<<<<<<<<<<<
 *         else:
 *             count = 1
 */
    Py_INCREF(__pyx_int_0);
    Py_DECREF(__pyx_v_count);
    __pyx_v_count = __pyx_int_0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":446
 *             count = 0
 *         else:
 *             count = 1             # <<<<<<<<<<<<<<
 *         return rexpc.sub(replacement, s, count)
 * 
 */
    Py_INCREF(__pyx_int_1);
    Py_DECREF(__pyx_v_count);
    __pyx_v_count = __pyx_int_1;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":447
 *         else:
 *             count = 1
 *         return rexpc.sub(replacement, s, count)             # <<<<<<<<<<<<<<
 * 
 *     cdef _register_in_context(self, _BaseContext context):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_rexpc, __pyx_kp_sub); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_replacement);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_replacement);
  Py_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_s);
  Py_INCREF(__pyx_v_count);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_count);
  __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp.replace");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_rexpc);
  Py_DECREF(__pyx_v_count);
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_flags);
  Py_DECREF(__pyx_v_replacement);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":449
 *         return rexpc.sub(replacement, s, count)
 * 
 *     cdef _register_in_context(self, _BaseContext context):             # <<<<<<<<<<<<<<
 *         ns = "http://exslt.org/regular-expressions"
 *         context._addLocalExtensionFunction(ns, "test",    self.test)
 */

static  PyObject *__pyx_f_4lxml_5etree_12_ExsltRegExp__register_in_context(struct __pyx_obj_4lxml_5etree__ExsltRegExp *__pyx_v_self, struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_context) {
  PyObject *__pyx_v_ns;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_ns = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":450
 * 
 *     cdef _register_in_context(self, _BaseContext context):
 *         ns = "http://exslt.org/regular-expressions"             # <<<<<<<<<<<<<<
 *         context._addLocalExtensionFunction(ns, "test",    self.test)
 *         context._addLocalExtensionFunction(ns, "match",   self.match)
 */
  Py_INCREF(__pyx_kp_544);
  Py_DECREF(__pyx_v_ns);
  __pyx_v_ns = __pyx_kp_544;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":451
 *     cdef _register_in_context(self, _BaseContext context):
 *         ns = "http://exslt.org/regular-expressions"
 *         context._addLocalExtensionFunction(ns, "test",    self.test)             # <<<<<<<<<<<<<<
 *         context._addLocalExtensionFunction(ns, "match",   self.match)
 *         context._addLocalExtensionFunction(ns, "replace", self.replace)
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_test); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_context->__pyx_vtab)->_addLocalExtensionFunction(__pyx_v_context, __pyx_v_ns, __pyx_kp_545, __pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":452
 *         ns = "http://exslt.org/regular-expressions"
 *         context._addLocalExtensionFunction(ns, "test",    self.test)
 *         context._addLocalExtensionFunction(ns, "match",   self.match)             # <<<<<<<<<<<<<<
 *         context._addLocalExtensionFunction(ns, "replace", self.replace)
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_match); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_context->__pyx_vtab)->_addLocalExtensionFunction(__pyx_v_context, __pyx_v_ns, __pyx_kp_546, __pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":453
 *         context._addLocalExtensionFunction(ns, "test",    self.test)
 *         context._addLocalExtensionFunction(ns, "match",   self.match)
 *         context._addLocalExtensionFunction(ns, "replace", self.replace)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_replace); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_context->__pyx_vtab)->_addLocalExtensionFunction(__pyx_v_context, __pyx_v_ns, __pyx_kp_547, __pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ExsltRegExp._register_in_context");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":459
 * # helper functions
 * 
 * cdef xpath.xmlXPathObject* _wrapXPathObject(object obj) except NULL:             # <<<<<<<<<<<<<<
 *     cdef xpath.xmlNodeSet* resultSet
 *     cdef _Element node
 */

static  xmlXPathObject *__pyx_f_4lxml_5etree__wrapXPathObject(PyObject *__pyx_v_obj) {
  xmlNodeSet *__pyx_v_resultSet;
  struct LxmlElement *__pyx_v_node;
  PyObject *__pyx_v_element;
  xmlXPathObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  double __pyx_4;
  Py_ssize_t __pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_obj);
  __pyx_v_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":462
 *     cdef xpath.xmlNodeSet* resultSet
 *     cdef _Element node
 *     if python.PyUnicode_Check(obj):             # <<<<<<<<<<<<<<
 *         obj = _utf8(obj)
 *     if python.PyString_Check(obj):
 */
  __pyx_1 = PyUnicode_Check(__pyx_v_obj);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":463
 *     cdef _Element node
 *     if python.PyUnicode_Check(obj):
 *         obj = _utf8(obj)             # <<<<<<<<<<<<<<
 *     if python.PyString_Check(obj):
 *         return xpath.xmlXPathNewCString(_cstr(obj))
 */
    __pyx_2 = __pyx_f_4lxml_5etree__utf8(__pyx_v_obj); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_obj);
    __pyx_v_obj = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":464
 *     if python.PyUnicode_Check(obj):
 *         obj = _utf8(obj)
 *     if python.PyString_Check(obj):             # <<<<<<<<<<<<<<
 *         return xpath.xmlXPathNewCString(_cstr(obj))
 *     if python.PyBool_Check(obj):
 */
  __pyx_1 = PyString_Check(__pyx_v_obj);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":465
 *         obj = _utf8(obj)
 *     if python.PyString_Check(obj):
 *         return xpath.xmlXPathNewCString(_cstr(obj))             # <<<<<<<<<<<<<<
 *     if python.PyBool_Check(obj):
 *         return xpath.xmlXPathNewBoolean(obj)
 */
    __pyx_r = xmlXPathNewCString(PyString_AS_STRING(__pyx_v_obj));
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":466
 *     if python.PyString_Check(obj):
 *         return xpath.xmlXPathNewCString(_cstr(obj))
 *     if python.PyBool_Check(obj):             # <<<<<<<<<<<<<<
 *         return xpath.xmlXPathNewBoolean(obj)
 *     if python.PyNumber_Check(obj):
 */
  __pyx_3 = PyBool_Check(__pyx_v_obj);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":467
 *         return xpath.xmlXPathNewCString(_cstr(obj))
 *     if python.PyBool_Check(obj):
 *         return xpath.xmlXPathNewBoolean(obj)             # <<<<<<<<<<<<<<
 *     if python.PyNumber_Check(obj):
 *         return xpath.xmlXPathNewFloat(obj)
 */
    __pyx_1 = __pyx_PyInt_int(__pyx_v_obj); if (unlikely((__pyx_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = xmlXPathNewBoolean(__pyx_1);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":468
 *     if python.PyBool_Check(obj):
 *         return xpath.xmlXPathNewBoolean(obj)
 *     if python.PyNumber_Check(obj):             # <<<<<<<<<<<<<<
 *         return xpath.xmlXPathNewFloat(obj)
 *     if obj is None:
 */
  __pyx_3 = PyNumber_Check(__pyx_v_obj);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":469
 *         return xpath.xmlXPathNewBoolean(obj)
 *     if python.PyNumber_Check(obj):
 *         return xpath.xmlXPathNewFloat(obj)             # <<<<<<<<<<<<<<
 *     if obj is None:
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 */
    __pyx_4 = __pyx_PyFloat_AsDouble(__pyx_v_obj); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = xmlXPathNewFloat(__pyx_4);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":470
 *     if python.PyNumber_Check(obj):
 *         return xpath.xmlXPathNewFloat(obj)
 *     if obj is None:             # <<<<<<<<<<<<<<
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 *     elif isinstance(obj, _Element):
 */
  __pyx_3 = (__pyx_v_obj == Py_None);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":471
 *         return xpath.xmlXPathNewFloat(obj)
 *     if obj is None:
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)             # <<<<<<<<<<<<<<
 *     elif isinstance(obj, _Element):
 *         resultSet = xpath.xmlXPathNodeSetCreate((<_Element>obj)._c_node)
 */
    __pyx_v_resultSet = xmlXPathNodeSetCreate(NULL);
    goto __pyx_L7;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":472
 *     if obj is None:
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 *     elif isinstance(obj, _Element):             # <<<<<<<<<<<<<<
 *         resultSet = xpath.xmlXPathNodeSetCreate((<_Element>obj)._c_node)
 *     elif python.PySequence_Check(obj):
 */
  __pyx_3 = PyObject_TypeCheck(__pyx_v_obj, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":473
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 *     elif isinstance(obj, _Element):
 *         resultSet = xpath.xmlXPathNodeSetCreate((<_Element>obj)._c_node)             # <<<<<<<<<<<<<<
 *     elif python.PySequence_Check(obj):
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 */
    __pyx_v_resultSet = xmlXPathNodeSetCreate(((struct LxmlElement *)__pyx_v_obj)->_c_node);
    goto __pyx_L7;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":474
 *     elif isinstance(obj, _Element):
 *         resultSet = xpath.xmlXPathNodeSetCreate((<_Element>obj)._c_node)
 *     elif python.PySequence_Check(obj):             # <<<<<<<<<<<<<<
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 *         for element in obj:
 */
  __pyx_3 = PySequence_Check(__pyx_v_obj);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":475
 *         resultSet = xpath.xmlXPathNodeSetCreate((<_Element>obj)._c_node)
 *     elif python.PySequence_Check(obj):
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)             # <<<<<<<<<<<<<<
 *         for element in obj:
 *             if isinstance(element, _Element):
 */
    __pyx_v_resultSet = xmlXPathNodeSetCreate(NULL);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":476
 *     elif python.PySequence_Check(obj):
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 *         for element in obj:             # <<<<<<<<<<<<<<
 *             if isinstance(element, _Element):
 *                 node = <_Element>element
 */
    if (PyList_CheckExact(__pyx_v_obj) || PyTuple_CheckExact(__pyx_v_obj)) {
      __pyx_5 = 0; __pyx_2 = __pyx_v_obj; Py_INCREF(__pyx_2);
    } else {
      __pyx_5 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_obj); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_2))) {
        if (__pyx_5 >= PyList_GET_SIZE(__pyx_2)) break;
        __pyx_6 = PyList_GET_ITEM(__pyx_2, __pyx_5); Py_INCREF(__pyx_6); __pyx_5++;
      } else if (likely(PyTuple_CheckExact(__pyx_2))) {
        if (__pyx_5 >= PyTuple_GET_SIZE(__pyx_2)) break;
        __pyx_6 = PyTuple_GET_ITEM(__pyx_2, __pyx_5); Py_INCREF(__pyx_6); __pyx_5++;
      } else {
        __pyx_6 = PyIter_Next(__pyx_2);
        if (!__pyx_6) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      Py_DECREF(__pyx_v_element);
      __pyx_v_element = __pyx_6;
      __pyx_6 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":477
 *         resultSet = xpath.xmlXPathNodeSetCreate(NULL)
 *         for element in obj:
 *             if isinstance(element, _Element):             # <<<<<<<<<<<<<<
 *                 node = <_Element>element
 *                 xpath.xmlXPathNodeSetAdd(resultSet, node._c_node)
 */
      __pyx_3 = PyObject_TypeCheck(__pyx_v_element, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Element))); 
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":478
 *         for element in obj:
 *             if isinstance(element, _Element):
 *                 node = <_Element>element             # <<<<<<<<<<<<<<
 *                 xpath.xmlXPathNodeSetAdd(resultSet, node._c_node)
 *             else:
 */
        Py_INCREF(((PyObject *)((struct LxmlElement *)__pyx_v_element)));
        Py_DECREF(((PyObject *)__pyx_v_node));
        __pyx_v_node = ((struct LxmlElement *)__pyx_v_element);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":479
 *             if isinstance(element, _Element):
 *                 node = <_Element>element
 *                 xpath.xmlXPathNodeSetAdd(resultSet, node._c_node)             # <<<<<<<<<<<<<<
 *             else:
 *                 xpath.xmlXPathFreeNodeSet(resultSet)
 */
        xmlXPathNodeSetAdd(__pyx_v_resultSet, __pyx_v_node->_c_node);
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":481
 *                 xpath.xmlXPathNodeSetAdd(resultSet, node._c_node)
 *             else:
 *                 xpath.xmlXPathFreeNodeSet(resultSet)             # <<<<<<<<<<<<<<
 *                 raise XPathResultError, u"This is not a node: %r" % element
 *     else:
 */
        xmlXPathFreeNodeSet(__pyx_v_resultSet);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":482
 *             else:
 *                 xpath.xmlXPathFreeNodeSet(resultSet)
 *                 raise XPathResultError, u"This is not a node: %r" % element             # <<<<<<<<<<<<<<
 *     else:
 *         raise XPathResultError, u"Unknown return type: %s" % \
 */
        __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathResultError); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_548), __pyx_v_element); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_Raise(__pyx_6, __pyx_t_1, 0);
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        {__pyx_filename = __pyx_f[5]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L10:;
    }
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":484
 *                 raise XPathResultError, u"This is not a node: %r" % element
 *     else:
 *         raise XPathResultError, u"Unknown return type: %s" % \             # <<<<<<<<<<<<<<
 *             python._fqtypename(obj)
 *     return xpath.xmlXPathWrapNodeSet(resultSet)
 */
    __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathResultError); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":485
 *     else:
 *         raise XPathResultError, u"Unknown return type: %s" % \
 *             python._fqtypename(obj)             # <<<<<<<<<<<<<<
 *     return xpath.xmlXPathWrapNodeSet(resultSet)
 * 
 */
    __pyx_2 = __Pyx_PyBytes_FromString(_fqtypename(__pyx_v_obj)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_549), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_6, __pyx_t_1, 0);
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":486
 *         raise XPathResultError, u"Unknown return type: %s" % \
 *             python._fqtypename(obj)
 *     return xpath.xmlXPathWrapNodeSet(resultSet)             # <<<<<<<<<<<<<<
 * 
 * cdef object _unwrapXPathObject(xpath.xmlXPathObject* xpathObj,
 */
  __pyx_r = xmlXPathWrapNodeSet(__pyx_v_resultSet);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree._wrapXPathObject");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_node);
  Py_DECREF(__pyx_v_element);
  Py_DECREF(__pyx_v_obj);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":488
 *     return xpath.xmlXPathWrapNodeSet(resultSet)
 * 
 * cdef object _unwrapXPathObject(xpath.xmlXPathObject* xpathObj,             # <<<<<<<<<<<<<<
 *                                _Document doc, bint smart_string):
 *     if xpathObj.type == xpath.XPATH_UNDEFINED:
 */

static  PyObject *__pyx_f_4lxml_5etree__unwrapXPathObject(xmlXPathObject *__pyx_v_xpathObj, struct LxmlDocument *__pyx_v_doc, int __pyx_v_smart_string) {
  PyObject *__pyx_v_stringval;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_stringval = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":490
 * cdef object _unwrapXPathObject(xpath.xmlXPathObject* xpathObj,
 *                                _Document doc, bint smart_string):
 *     if xpathObj.type == xpath.XPATH_UNDEFINED:             # <<<<<<<<<<<<<<
 *         raise XPathResultError, u"Undefined xpath result"
 *     elif xpathObj.type == xpath.XPATH_NODESET:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_UNDEFINED);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":491
 *                                _Document doc, bint smart_string):
 *     if xpathObj.type == xpath.XPATH_UNDEFINED:
 *         raise XPathResultError, u"Undefined xpath result"             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_NODESET:
 *         return _createNodeSetResult(xpathObj, doc, smart_string)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathResultError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_550), 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":492
 *     if xpathObj.type == xpath.XPATH_UNDEFINED:
 *         raise XPathResultError, u"Undefined xpath result"
 *     elif xpathObj.type == xpath.XPATH_NODESET:             # <<<<<<<<<<<<<<
 *         return _createNodeSetResult(xpathObj, doc, smart_string)
 *     elif xpathObj.type == xpath.XPATH_BOOLEAN:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_NODESET);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":493
 *         raise XPathResultError, u"Undefined xpath result"
 *     elif xpathObj.type == xpath.XPATH_NODESET:
 *         return _createNodeSetResult(xpathObj, doc, smart_string)             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_BOOLEAN:
 *         return xpathObj.boolval
 */
    __pyx_2 = __pyx_f_4lxml_5etree__createNodeSetResult(__pyx_v_xpathObj, __pyx_v_doc, __pyx_v_smart_string); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":494
 *     elif xpathObj.type == xpath.XPATH_NODESET:
 *         return _createNodeSetResult(xpathObj, doc, smart_string)
 *     elif xpathObj.type == xpath.XPATH_BOOLEAN:             # <<<<<<<<<<<<<<
 *         return xpathObj.boolval
 *     elif xpathObj.type == xpath.XPATH_NUMBER:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_BOOLEAN);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":495
 *         return _createNodeSetResult(xpathObj, doc, smart_string)
 *     elif xpathObj.type == xpath.XPATH_BOOLEAN:
 *         return xpathObj.boolval             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_NUMBER:
 *         return xpathObj.floatval
 */
    __pyx_2 = __Pyx_PyBool_FromLong(__pyx_v_xpathObj->boolval); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":496
 *     elif xpathObj.type == xpath.XPATH_BOOLEAN:
 *         return xpathObj.boolval
 *     elif xpathObj.type == xpath.XPATH_NUMBER:             # <<<<<<<<<<<<<<
 *         return xpathObj.floatval
 *     elif xpathObj.type == xpath.XPATH_STRING:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_NUMBER);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":497
 *         return xpathObj.boolval
 *     elif xpathObj.type == xpath.XPATH_NUMBER:
 *         return xpathObj.floatval             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_STRING:
 *         stringval = funicode(xpathObj.stringval)
 */
    __pyx_2 = PyFloat_FromDouble(__pyx_v_xpathObj->floatval); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":498
 *     elif xpathObj.type == xpath.XPATH_NUMBER:
 *         return xpathObj.floatval
 *     elif xpathObj.type == xpath.XPATH_STRING:             # <<<<<<<<<<<<<<
 *         stringval = funicode(xpathObj.stringval)
 *         if smart_string:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_STRING);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":499
 *         return xpathObj.floatval
 *     elif xpathObj.type == xpath.XPATH_STRING:
 *         stringval = funicode(xpathObj.stringval)             # <<<<<<<<<<<<<<
 *         if smart_string:
 *             stringval = _elementStringResultFactory(
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_xpathObj->stringval); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_stringval);
    __pyx_v_stringval = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":500
 *     elif xpathObj.type == xpath.XPATH_STRING:
 *         stringval = funicode(xpathObj.stringval)
 *         if smart_string:             # <<<<<<<<<<<<<<
 *             stringval = _elementStringResultFactory(
 *                 stringval, None, 0, 0)
 */
    __pyx_1 = __pyx_v_smart_string;
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":502
 *         if smart_string:
 *             stringval = _elementStringResultFactory(
 *                 stringval, None, 0, 0)             # <<<<<<<<<<<<<<
 *         return stringval
 *     elif xpathObj.type == xpath.XPATH_POINT:
 */
      __pyx_2 = __pyx_f_4lxml_5etree__elementStringResultFactory(__pyx_v_stringval, ((struct LxmlElement *)Py_None), 0, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_stringval);
      __pyx_v_stringval = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":503
 *             stringval = _elementStringResultFactory(
 *                 stringval, None, 0, 0)
 *         return stringval             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_POINT:
 *         raise NotImplementedError
 */
    Py_INCREF(__pyx_v_stringval);
    __pyx_r = __pyx_v_stringval;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":504
 *                 stringval, None, 0, 0)
 *         return stringval
 *     elif xpathObj.type == xpath.XPATH_POINT:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_RANGE:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_POINT);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":505
 *         return stringval
 *     elif xpathObj.type == xpath.XPATH_POINT:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_RANGE:
 *         raise NotImplementedError
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":506
 *     elif xpathObj.type == xpath.XPATH_POINT:
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_RANGE:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_LOCATIONSET:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_RANGE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":507
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_RANGE:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_LOCATIONSET:
 *         raise NotImplementedError
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":508
 *     elif xpathObj.type == xpath.XPATH_RANGE:
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_LOCATIONSET:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_USERS:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_LOCATIONSET);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":509
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_LOCATIONSET:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_USERS:
 *         raise NotImplementedError
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":510
 *     elif xpathObj.type == xpath.XPATH_LOCATIONSET:
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_USERS:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_XSLT_TREE:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_USERS);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":511
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_USERS:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     elif xpathObj.type == xpath.XPATH_XSLT_TREE:
 *         raise NotImplementedError
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":512
 *     elif xpathObj.type == xpath.XPATH_USERS:
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_XSLT_TREE:             # <<<<<<<<<<<<<<
 *         raise NotImplementedError
 *     else:
 */
  __pyx_1 = (__pyx_v_xpathObj->type == XPATH_XSLT_TREE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":513
 *         raise NotImplementedError
 *     elif xpathObj.type == xpath.XPATH_XSLT_TREE:
 *         raise NotImplementedError             # <<<<<<<<<<<<<<
 *     else:
 *         raise XPathResultError, u"Unknown xpath result %s" % unicode(xpathObj.type)
 */
    __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0);
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":515
 *         raise NotImplementedError
 *     else:
 *         raise XPathResultError, u"Unknown xpath result %s" % unicode(xpathObj.type)             # <<<<<<<<<<<<<<
 * 
 * cdef object _createNodeSetResult(xpath.xmlXPathObject* xpathObj,
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathResultError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyInt_FromLong(__pyx_v_xpathObj->type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_551), __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, __pyx_t_1, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._unwrapXPathObject");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_stringval);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":517
 *         raise XPathResultError, u"Unknown xpath result %s" % unicode(xpathObj.type)
 * 
 * cdef object _createNodeSetResult(xpath.xmlXPathObject* xpathObj,             # <<<<<<<<<<<<<<
 *                                  _Document doc, bint smart_string):
 *     cdef xmlNode* c_node
 */

static  PyObject *__pyx_f_4lxml_5etree__createNodeSetResult(xmlXPathObject *__pyx_v_xpathObj, struct LxmlDocument *__pyx_v_doc, int __pyx_v_smart_string) {
  xmlNode *__pyx_v_c_node;
  char *__pyx_v_s;
  int __pyx_v_i;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_href;
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);
  __pyx_v_href = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":522
 *     cdef char* s
 *     cdef int i
 *     result = []             # <<<<<<<<<<<<<<
 *     if xpathObj.nodesetval is NULL:
 *         return result
 */
  __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":523
 *     cdef int i
 *     result = []
 *     if xpathObj.nodesetval is NULL:             # <<<<<<<<<<<<<<
 *         return result
 *     for i from 0 <= i < xpathObj.nodesetval.nodeNr:
 */
  __pyx_2 = (__pyx_v_xpathObj->nodesetval == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":524
 *     result = []
 *     if xpathObj.nodesetval is NULL:
 *         return result             # <<<<<<<<<<<<<<
 *     for i from 0 <= i < xpathObj.nodesetval.nodeNr:
 *         c_node = xpathObj.nodesetval.nodeTab[i]
 */
    Py_INCREF(__pyx_v_result);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":525
 *     if xpathObj.nodesetval is NULL:
 *         return result
 *     for i from 0 <= i < xpathObj.nodesetval.nodeNr:             # <<<<<<<<<<<<<<
 *         c_node = xpathObj.nodesetval.nodeTab[i]
 *         if _isElement(c_node):
 */
  __pyx_3 = __pyx_v_xpathObj->nodesetval->nodeNr;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; __pyx_v_i++) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":526
 *         return result
 *     for i from 0 <= i < xpathObj.nodesetval.nodeNr:
 *         c_node = xpathObj.nodesetval.nodeTab[i]             # <<<<<<<<<<<<<<
 *         if _isElement(c_node):
 *             if c_node.doc != doc._c_doc and c_node.doc._private is NULL:
 */
    __pyx_v_c_node = (__pyx_v_xpathObj->nodesetval->nodeTab[__pyx_v_i]);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":527
 *     for i from 0 <= i < xpathObj.nodesetval.nodeNr:
 *         c_node = xpathObj.nodesetval.nodeTab[i]
 *         if _isElement(c_node):             # <<<<<<<<<<<<<<
 *             if c_node.doc != doc._c_doc and c_node.doc._private is NULL:
 *                 # XXX: works, but maybe not always the right thing to do?
 */
    __pyx_2 = _isElement(__pyx_v_c_node);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":528
 *         c_node = xpathObj.nodesetval.nodeTab[i]
 *         if _isElement(c_node):
 *             if c_node.doc != doc._c_doc and c_node.doc._private is NULL:             # <<<<<<<<<<<<<<
 *                 # XXX: works, but maybe not always the right thing to do?
 *                 # XPath: only runs when extensions create or copy trees
 */
      __pyx_2 = (__pyx_v_c_node->doc != __pyx_v_doc->_c_doc);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_c_node->doc->_private == NULL);
      }
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":533
 *                 #        -> we store Python refs to these, so that is OK
 *                 # XSLT: can it leak when merging trees from multiple sources?
 *                 c_node = tree.xmlDocCopyNode(c_node, doc._c_doc, 1)             # <<<<<<<<<<<<<<
 *             value = _fakeDocElementFactory(doc, c_node)
 *         elif c_node.type == tree.XML_TEXT_NODE or \
 */
        __pyx_v_c_node = xmlDocCopyNode(__pyx_v_c_node, __pyx_v_doc->_c_doc, 1);
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":534
 *                 # XSLT: can it leak when merging trees from multiple sources?
 *                 c_node = tree.xmlDocCopyNode(c_node, doc._c_doc, 1)
 *             value = _fakeDocElementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 *         elif c_node.type == tree.XML_TEXT_NODE or \
 *                 c_node.type == tree.XML_ATTRIBUTE_NODE:
 */
      __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__fakeDocElementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_1;
      __pyx_1 = 0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":535
 *                 c_node = tree.xmlDocCopyNode(c_node, doc._c_doc, 1)
 *             value = _fakeDocElementFactory(doc, c_node)
 *         elif c_node.type == tree.XML_TEXT_NODE or \             # <<<<<<<<<<<<<<
 *                 c_node.type == tree.XML_ATTRIBUTE_NODE:
 *             value = _buildElementStringResult(doc, c_node, smart_string)
 */
    __pyx_2 = (__pyx_v_c_node->type == XML_TEXT_NODE);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":536
 *             value = _fakeDocElementFactory(doc, c_node)
 *         elif c_node.type == tree.XML_TEXT_NODE or \
 *                 c_node.type == tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *             value = _buildElementStringResult(doc, c_node, smart_string)
 *         elif c_node.type == tree.XML_NAMESPACE_DECL:
 */
      __pyx_2 = (__pyx_v_c_node->type == XML_ATTRIBUTE_NODE);
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":537
 *         elif c_node.type == tree.XML_TEXT_NODE or \
 *                 c_node.type == tree.XML_ATTRIBUTE_NODE:
 *             value = _buildElementStringResult(doc, c_node, smart_string)             # <<<<<<<<<<<<<<
 *         elif c_node.type == tree.XML_NAMESPACE_DECL:
 *             s = (<xmlNs*>c_node).href
 */
      __pyx_1 = __pyx_f_4lxml_5etree__buildElementStringResult(__pyx_v_doc, __pyx_v_c_node, __pyx_v_smart_string); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_1;
      __pyx_1 = 0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":538
 *                 c_node.type == tree.XML_ATTRIBUTE_NODE:
 *             value = _buildElementStringResult(doc, c_node, smart_string)
 *         elif c_node.type == tree.XML_NAMESPACE_DECL:             # <<<<<<<<<<<<<<
 *             s = (<xmlNs*>c_node).href
 *             if s is NULL:
 */
    __pyx_2 = (__pyx_v_c_node->type == XML_NAMESPACE_DECL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":539
 *             value = _buildElementStringResult(doc, c_node, smart_string)
 *         elif c_node.type == tree.XML_NAMESPACE_DECL:
 *             s = (<xmlNs*>c_node).href             # <<<<<<<<<<<<<<
 *             if s is NULL:
 *                 href = None
 */
      __pyx_v_s = ((xmlNs *)__pyx_v_c_node)->href;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":540
 *         elif c_node.type == tree.XML_NAMESPACE_DECL:
 *             s = (<xmlNs*>c_node).href
 *             if s is NULL:             # <<<<<<<<<<<<<<
 *                 href = None
 *             else:
 */
      __pyx_2 = (__pyx_v_s == NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":541
 *             s = (<xmlNs*>c_node).href
 *             if s is NULL:
 *                 href = None             # <<<<<<<<<<<<<<
 *             else:
 *                 href = funicode(s)
 */
        Py_INCREF(Py_None);
        Py_DECREF(__pyx_v_href);
        __pyx_v_href = Py_None;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":543
 *                 href = None
 *             else:
 *                 href = funicode(s)             # <<<<<<<<<<<<<<
 *             s = (<xmlNs*>c_node).prefix
 *             if s is NULL:
 */
        __pyx_1 = __pyx_f_4lxml_5etree_funicode(__pyx_v_s); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_href);
        __pyx_v_href = __pyx_1;
        __pyx_1 = 0;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":544
 *             else:
 *                 href = funicode(s)
 *             s = (<xmlNs*>c_node).prefix             # <<<<<<<<<<<<<<
 *             if s is NULL:
 *                 prefix = None
 */
      __pyx_v_s = ((xmlNs *)__pyx_v_c_node)->prefix;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":545
 *                 href = funicode(s)
 *             s = (<xmlNs*>c_node).prefix
 *             if s is NULL:             # <<<<<<<<<<<<<<
 *                 prefix = None
 *             else:
 */
      __pyx_2 = (__pyx_v_s == NULL);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":546
 *             s = (<xmlNs*>c_node).prefix
 *             if s is NULL:
 *                 prefix = None             # <<<<<<<<<<<<<<
 *             else:
 *                 prefix = funicode(s)
 */
        Py_INCREF(Py_None);
        Py_DECREF(__pyx_v_prefix);
        __pyx_v_prefix = Py_None;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":548
 *                 prefix = None
 *             else:
 *                 prefix = funicode(s)             # <<<<<<<<<<<<<<
 *             value = (prefix, href)
 *         elif c_node.type == tree.XML_DOCUMENT_NODE or \
 */
        __pyx_1 = __pyx_f_4lxml_5etree_funicode(__pyx_v_s); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_prefix);
        __pyx_v_prefix = __pyx_1;
        __pyx_1 = 0;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":549
 *             else:
 *                 prefix = funicode(s)
 *             value = (prefix, href)             # <<<<<<<<<<<<<<
 *         elif c_node.type == tree.XML_DOCUMENT_NODE or \
 *                  c_node.type == tree.XML_HTML_DOCUMENT_NODE or \
 */
      __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_prefix);
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_prefix);
      Py_INCREF(__pyx_v_href);
      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_href);
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = ((PyObject *)__pyx_1);
      __pyx_1 = 0;
      goto __pyx_L6;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":550
 *                 prefix = funicode(s)
 *             value = (prefix, href)
 *         elif c_node.type == tree.XML_DOCUMENT_NODE or \             # <<<<<<<<<<<<<<
 *                  c_node.type == tree.XML_HTML_DOCUMENT_NODE or \
 *                  c_node.type == tree.XML_XINCLUDE_START or \
 */
    __pyx_2 = (__pyx_v_c_node->type == XML_DOCUMENT_NODE);
    if (!__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":551
 *             value = (prefix, href)
 *         elif c_node.type == tree.XML_DOCUMENT_NODE or \
 *                  c_node.type == tree.XML_HTML_DOCUMENT_NODE or \             # <<<<<<<<<<<<<<
 *                  c_node.type == tree.XML_XINCLUDE_START or \
 *                  c_node.type == tree.XML_XINCLUDE_END:
 */
      __pyx_2 = (__pyx_v_c_node->type == XML_HTML_DOCUMENT_NODE);
      if (!__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":552
 *         elif c_node.type == tree.XML_DOCUMENT_NODE or \
 *                  c_node.type == tree.XML_HTML_DOCUMENT_NODE or \
 *                  c_node.type == tree.XML_XINCLUDE_START or \             # <<<<<<<<<<<<<<
 *                  c_node.type == tree.XML_XINCLUDE_END:
 *             continue
 */
        __pyx_2 = (__pyx_v_c_node->type == XML_XINCLUDE_START);
        if (!__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":553
 *                  c_node.type == tree.XML_HTML_DOCUMENT_NODE or \
 *                  c_node.type == tree.XML_XINCLUDE_START or \
 *                  c_node.type == tree.XML_XINCLUDE_END:             # <<<<<<<<<<<<<<
 *             continue
 *         else:
 */
          __pyx_2 = (__pyx_v_c_node->type == XML_XINCLUDE_END);
        }
      }
    }
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":554
 *                  c_node.type == tree.XML_XINCLUDE_START or \
 *                  c_node.type == tree.XML_XINCLUDE_END:
 *             continue             # <<<<<<<<<<<<<<
 *         else:
 *             raise NotImplementedError, \
 */
      goto __pyx_L4;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":557
 *         else:
 *             raise NotImplementedError, \
 *                 u"Not yet implemented result node type: %d" % unicode(c_node.type)             # <<<<<<<<<<<<<<
 *         python.PyList_Append(result, value)
 *     return result
 */
      __pyx_1 = PyInt_FromLong(__pyx_v_c_node->type); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
      __pyx_1 = 0;
      __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_552), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_Raise(__pyx_builtin_NotImplementedError, __pyx_t_1, 0);
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[5]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L6:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":558
 *             raise NotImplementedError, \
 *                 u"Not yet implemented result node type: %d" % unicode(c_node.type)
 *         python.PyList_Append(result, value)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_5 = PyList_Append(__pyx_v_result, __pyx_v_value); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":559
 *                 u"Not yet implemented result node type: %d" % unicode(c_node.type)
 *         python.PyList_Append(result, value)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef void _freeXPathObject(xpath.xmlXPathObject* xpathObj):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._createNodeSetResult");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_href);
  Py_DECREF(__pyx_v_prefix);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":561
 *     return result
 * 
 * cdef void _freeXPathObject(xpath.xmlXPathObject* xpathObj):             # <<<<<<<<<<<<<<
 *     u"""Free the XPath object, but *never* free the *content* of node sets.
 *     Python dealloc will do that for us.
 */

static  void __pyx_f_4lxml_5etree__freeXPathObject(xmlXPathObject *__pyx_v_xpathObj) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":565
 *     Python dealloc will do that for us.
 *     """
 *     if xpathObj.nodesetval is not NULL:             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathFreeNodeSet(xpathObj.nodesetval)
 *         xpathObj.nodesetval = NULL
 */
  __pyx_1 = (__pyx_v_xpathObj->nodesetval != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":566
 *     """
 *     if xpathObj.nodesetval is not NULL:
 *         xpath.xmlXPathFreeNodeSet(xpathObj.nodesetval)             # <<<<<<<<<<<<<<
 *         xpathObj.nodesetval = NULL
 *     xpath.xmlXPathFreeObject(xpathObj)
 */
    xmlXPathFreeNodeSet(__pyx_v_xpathObj->nodesetval);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":567
 *     if xpathObj.nodesetval is not NULL:
 *         xpath.xmlXPathFreeNodeSet(xpathObj.nodesetval)
 *         xpathObj.nodesetval = NULL             # <<<<<<<<<<<<<<
 *     xpath.xmlXPathFreeObject(xpathObj)
 * 
 */
    __pyx_v_xpathObj->nodesetval = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":568
 *         xpath.xmlXPathFreeNodeSet(xpathObj.nodesetval)
 *         xpathObj.nodesetval = NULL
 *     xpath.xmlXPathFreeObject(xpathObj)             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  xmlXPathFreeObject(__pyx_v_xpathObj);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":579
 *     cdef readonly object is_attribute
 * 
 *     def getparent(self):             # <<<<<<<<<<<<<<
 *         return self._parent
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_21_ElementUnicodeResult_getparent(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_21_ElementUnicodeResult_getparent(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":580
 * 
 *     def getparent(self):
 *         return self._parent             # <<<<<<<<<<<<<<
 * 
 * class _ElementStringResult(str):
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)__pyx_v_self)->_parent));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)__pyx_v_self)->_parent);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":585
 *     # we need to use a Python class here, str cannot be C-subclassed
 *     # in Pyrex/Cython
 *     def getparent(self):             # <<<<<<<<<<<<<<
 *         return self._parent
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_20_ElementStringResult_getparent(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4lxml_5etree_20_ElementStringResult_getparent = {"getparent", (PyCFunction)__pyx_pf_4lxml_5etree_20_ElementStringResult_getparent, METH_O, 0};
static PyObject *__pyx_pf_4lxml_5etree_20_ElementStringResult_getparent(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_self = __pyx_self;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":586
 *     # in Pyrex/Cython
 *     def getparent(self):
 *         return self._parent             # <<<<<<<<<<<<<<
 * 
 * cdef object _elementStringResultFactory(string_value, _Element parent,
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp__parent); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ElementStringResult.getparent");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":588
 *         return self._parent
 * 
 * cdef object _elementStringResultFactory(string_value, _Element parent,             # <<<<<<<<<<<<<<
 *                                         bint is_attribute, bint is_tail):
 *     cdef _ElementUnicodeResult uresult
 */

static  PyObject *__pyx_f_4lxml_5etree__elementStringResultFactory(PyObject *__pyx_v_string_value, struct LxmlElement *__pyx_v_parent, int __pyx_v_is_attribute, int __pyx_v_is_tail) {
  struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *__pyx_v_uresult;
  int __pyx_v_is_text;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_v_uresult = ((struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":592
 *     cdef _ElementUnicodeResult uresult
 *     cdef bint is_text
 *     if parent is None:             # <<<<<<<<<<<<<<
 *         is_text = 0
 *     else:
 */
  __pyx_1 = (((PyObject *)__pyx_v_parent) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":593
 *     cdef bint is_text
 *     if parent is None:
 *         is_text = 0             # <<<<<<<<<<<<<<
 *     else:
 *         is_text = not (is_tail or is_attribute)
 */
    __pyx_v_is_text = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":595
 *         is_text = 0
 *     else:
 *         is_text = not (is_tail or is_attribute)             # <<<<<<<<<<<<<<
 * 
 *     if python.PyString_CheckExact(string_value):
 */
    __pyx_1 = __pyx_v_is_tail;
    if (!__pyx_1) {
      __pyx_1 = __pyx_v_is_attribute;
    }
    __pyx_v_is_text = (!__pyx_1);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":597
 *         is_text = not (is_tail or is_attribute)
 * 
 *     if python.PyString_CheckExact(string_value):             # <<<<<<<<<<<<<<
 *         result = _ElementStringResult(string_value)
 *         result._parent = parent
 */
  __pyx_2 = PyString_CheckExact(__pyx_v_string_value);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":598
 * 
 *     if python.PyString_CheckExact(string_value):
 *         result = _ElementStringResult(string_value)             # <<<<<<<<<<<<<<
 *         result._parent = parent
 *         result.is_attribute = is_attribute
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_166); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_string_value);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_string_value);
    __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_5;
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":599
 *     if python.PyString_CheckExact(string_value):
 *         result = _ElementStringResult(string_value)
 *         result._parent = parent             # <<<<<<<<<<<<<<
 *         result.is_attribute = is_attribute
 *         result.is_tail = is_tail
 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_kp__parent, ((PyObject *)__pyx_v_parent)) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":600
 *         result = _ElementStringResult(string_value)
 *         result._parent = parent
 *         result.is_attribute = is_attribute             # <<<<<<<<<<<<<<
 *         result.is_tail = is_tail
 *         result.is_text = is_text
 */
    __pyx_3 = __Pyx_PyBool_FromLong(__pyx_v_is_attribute); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyObject_SetAttr(__pyx_v_result, __pyx_kp_is_attribute, __pyx_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":601
 *         result._parent = parent
 *         result.is_attribute = is_attribute
 *         result.is_tail = is_tail             # <<<<<<<<<<<<<<
 *         result.is_text = is_text
 *         return result
 */
    __pyx_4 = __Pyx_PyBool_FromLong(__pyx_v_is_tail); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyObject_SetAttr(__pyx_v_result, __pyx_kp_is_tail, __pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":602
 *         result.is_attribute = is_attribute
 *         result.is_tail = is_tail
 *         result.is_text = is_text             # <<<<<<<<<<<<<<
 *         return result
 *     else:
 */
    __pyx_5 = __Pyx_PyBool_FromLong(__pyx_v_is_text); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyObject_SetAttr(__pyx_v_result, __pyx_kp_is_text, __pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":603
 *         result.is_tail = is_tail
 *         result.is_text = is_text
 *         return result             # <<<<<<<<<<<<<<
 *     else:
 *         uresult = _ElementUnicodeResult(string_value)
 */
    Py_INCREF(__pyx_v_result);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":605
 *         return result
 *     else:
 *         uresult = _ElementUnicodeResult(string_value)             # <<<<<<<<<<<<<<
 *         uresult._parent = parent
 *         uresult.is_attribute = is_attribute
 */
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_string_value);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_string_value);
    __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementUnicodeResult)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__ElementUnicodeResult))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_uresult));
    __pyx_v_uresult = ((struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":606
 *     else:
 *         uresult = _ElementUnicodeResult(string_value)
 *         uresult._parent = parent             # <<<<<<<<<<<<<<
 *         uresult.is_attribute = is_attribute
 *         uresult.is_tail = is_tail
 */
    Py_INCREF(((PyObject *)__pyx_v_parent));
    Py_DECREF(((PyObject *)__pyx_v_uresult->_parent));
    __pyx_v_uresult->_parent = __pyx_v_parent;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":607
 *         uresult = _ElementUnicodeResult(string_value)
 *         uresult._parent = parent
 *         uresult.is_attribute = is_attribute             # <<<<<<<<<<<<<<
 *         uresult.is_tail = is_tail
 *         uresult.is_text = is_text
 */
    __pyx_5 = __Pyx_PyBool_FromLong(__pyx_v_is_attribute); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_uresult->is_attribute);
    __pyx_v_uresult->is_attribute = __pyx_5;
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":608
 *         uresult._parent = parent
 *         uresult.is_attribute = is_attribute
 *         uresult.is_tail = is_tail             # <<<<<<<<<<<<<<
 *         uresult.is_text = is_text
 *         return uresult
 */
    __pyx_3 = __Pyx_PyBool_FromLong(__pyx_v_is_tail); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_uresult->is_tail);
    __pyx_v_uresult->is_tail = __pyx_3;
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":609
 *         uresult.is_attribute = is_attribute
 *         uresult.is_tail = is_tail
 *         uresult.is_text = is_text             # <<<<<<<<<<<<<<
 *         return uresult
 * 
 */
    __pyx_4 = __Pyx_PyBool_FromLong(__pyx_v_is_text); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_uresult->is_text);
    __pyx_v_uresult->is_text = __pyx_4;
    __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":610
 *         uresult.is_tail = is_tail
 *         uresult.is_text = is_text
 *         return uresult             # <<<<<<<<<<<<<<
 * 
 * cdef object _buildElementStringResult(_Document doc, xmlNode* c_node,
 */
    Py_INCREF(((PyObject *)__pyx_v_uresult));
    __pyx_r = ((PyObject *)__pyx_v_uresult);
    goto __pyx_L0;
  }
  __pyx_L4:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._elementStringResultFactory");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_uresult);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":612
 *         return uresult
 * 
 * cdef object _buildElementStringResult(_Document doc, xmlNode* c_node,             # <<<<<<<<<<<<<<
 *                                       bint smart_string):
 *     cdef _Element parent
 */

static  PyObject *__pyx_f_4lxml_5etree__buildElementStringResult(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node, int __pyx_v_smart_string) {
  struct LxmlElement *__pyx_v_parent;
  xmlNode *__pyx_v_c_element;
  char *__pyx_v_s;
  int __pyx_v_is_attribute;
  int __pyx_v_is_tail;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_parent = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":619
 *     cdef bint is_attribute, is_text, is_tail
 * 
 *     if c_node.type == tree.XML_ATTRIBUTE_NODE:             # <<<<<<<<<<<<<<
 *         is_attribute = 1
 *         is_tail = 0
 */
  __pyx_1 = (__pyx_v_c_node->type == XML_ATTRIBUTE_NODE);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":620
 * 
 *     if c_node.type == tree.XML_ATTRIBUTE_NODE:
 *         is_attribute = 1             # <<<<<<<<<<<<<<
 *         is_tail = 0
 *         s = tree.xmlNodeGetContent(c_node)
 */
    __pyx_v_is_attribute = 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":621
 *     if c_node.type == tree.XML_ATTRIBUTE_NODE:
 *         is_attribute = 1
 *         is_tail = 0             # <<<<<<<<<<<<<<
 *         s = tree.xmlNodeGetContent(c_node)
 *         try:
 */
    __pyx_v_is_tail = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":622
 *         is_attribute = 1
 *         is_tail = 0
 *         s = tree.xmlNodeGetContent(c_node)             # <<<<<<<<<<<<<<
 *         try:
 *             value = funicode(s)
 */
    __pyx_v_s = xmlNodeGetContent(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":623
 *         is_tail = 0
 *         s = tree.xmlNodeGetContent(c_node)
 *         try:             # <<<<<<<<<<<<<<
 *             value = funicode(s)
 *         finally:
 */
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":624
 *         s = tree.xmlNodeGetContent(c_node)
 *         try:
 *             value = funicode(s)             # <<<<<<<<<<<<<<
 *         finally:
 *             tree.xmlFree(s)
 */
      __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_s); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L5;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_2;
      __pyx_2 = 0;
    }
    /*finally:*/ {
      int __pyx_why;
      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
      int __pyx_exc_lineno;
      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 0; goto __pyx_L6;
      __pyx_L5: {
        __pyx_why = 4;
        Py_XDECREF(__pyx_2); __pyx_2 = 0;
        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
        __pyx_exc_lineno = __pyx_lineno;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":626
 *             value = funicode(s)
 *         finally:
 *             tree.xmlFree(s)             # <<<<<<<<<<<<<<
 *         c_element = NULL
 *     else:
 */
      xmlFree(__pyx_v_s);
      switch (__pyx_why) {
        case 4: {
          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
          __pyx_lineno = __pyx_exc_lineno;
          __pyx_exc_type = 0;
          __pyx_exc_value = 0;
          __pyx_exc_tb = 0;
          goto __pyx_L1_error;
        }
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":627
 *         finally:
 *             tree.xmlFree(s)
 *         c_element = NULL             # <<<<<<<<<<<<<<
 *     else:
 *         #assert c_node.type == tree.XML_TEXT_NODE, "invalid node type"
 */
    __pyx_v_c_element = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":630
 *     else:
 *         #assert c_node.type == tree.XML_TEXT_NODE, "invalid node type"
 *         is_attribute = 0             # <<<<<<<<<<<<<<
 *         # may be tail text or normal text
 *         value = funicode(c_node.content)
 */
    __pyx_v_is_attribute = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":632
 *         is_attribute = 0
 *         # may be tail text or normal text
 *         value = funicode(c_node.content)             # <<<<<<<<<<<<<<
 *         c_element = _previousElement(c_node)
 *         is_tail = c_element is not NULL
 */
    __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_node->content); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":633
 *         # may be tail text or normal text
 *         value = funicode(c_node.content)
 *         c_element = _previousElement(c_node)             # <<<<<<<<<<<<<<
 *         is_tail = c_element is not NULL
 * 
 */
    __pyx_v_c_element = __pyx_f_4lxml_5etree__previousElement(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":634
 *         value = funicode(c_node.content)
 *         c_element = _previousElement(c_node)
 *         is_tail = c_element is not NULL             # <<<<<<<<<<<<<<
 * 
 *     if not smart_string:
 */
    __pyx_v_is_tail = (__pyx_v_c_element != NULL);
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":636
 *         is_tail = c_element is not NULL
 * 
 *     if not smart_string:             # <<<<<<<<<<<<<<
 *         return value
 * 
 */
  __pyx_1 = (!__pyx_v_smart_string);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":637
 * 
 *     if not smart_string:
 *         return value             # <<<<<<<<<<<<<<
 * 
 *     if c_element is NULL:
 */
    Py_INCREF(__pyx_v_value);
    __pyx_r = __pyx_v_value;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":639
 *         return value
 * 
 *     if c_element is NULL:             # <<<<<<<<<<<<<<
 *         # non-tail text or attribute text
 *         c_element = c_node.parent
 */
  __pyx_1 = (__pyx_v_c_element == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":641
 *     if c_element is NULL:
 *         # non-tail text or attribute text
 *         c_element = c_node.parent             # <<<<<<<<<<<<<<
 *         while c_element is not NULL and not _isElement(c_element):
 *             c_element = c_element.parent
 */
    __pyx_v_c_element = __pyx_v_c_node->parent;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":642
 *         # non-tail text or attribute text
 *         c_element = c_node.parent
 *         while c_element is not NULL and not _isElement(c_element):             # <<<<<<<<<<<<<<
 *             c_element = c_element.parent
 * 
 */
    while (1) {
      __pyx_1 = (__pyx_v_c_element != NULL);
      if (__pyx_1) {
        __pyx_1 = (!_isElement(__pyx_v_c_element));
      }
      if (!__pyx_1) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":643
 *         c_element = c_node.parent
 *         while c_element is not NULL and not _isElement(c_element):
 *             c_element = c_element.parent             # <<<<<<<<<<<<<<
 * 
 *     if c_element is not NULL:
 */
      __pyx_v_c_element = __pyx_v_c_element->parent;
    }
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":645
 *             c_element = c_element.parent
 * 
 *     if c_element is not NULL:             # <<<<<<<<<<<<<<
 *         parent = _fakeDocElementFactory(doc, c_element)
 * 
 */
  __pyx_1 = (__pyx_v_c_element != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":646
 * 
 *     if c_element is not NULL:
 *         parent = _fakeDocElementFactory(doc, c_element)             # <<<<<<<<<<<<<<
 * 
 *     return _elementStringResultFactory(
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__fakeDocElementFactory(__pyx_v_doc, __pyx_v_c_element)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_parent));
    __pyx_v_parent = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":649
 * 
 *     return _elementStringResultFactory(
 *         value, parent, is_attribute, is_tail)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree__elementStringResultFactory(__pyx_v_value, __pyx_v_parent, __pyx_v_is_attribute, __pyx_v_is_tail); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._buildElementStringResult");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_parent);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":655
 * # callbacks for XPath/XSLT extension functions
 * 
 * cdef void _extension_function_call(_BaseContext context, function,             # <<<<<<<<<<<<<<
 *                                    xpath.xmlXPathParserContext* ctxt, int nargs):
 *     cdef _Document doc
 */

static  void __pyx_f_4lxml_5etree__extension_function_call(struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_context, PyObject *__pyx_v_function, xmlXPathParserContext *__pyx_v_ctxt, int __pyx_v_nargs) {
  struct LxmlDocument *__pyx_v_doc;
  xmlXPathObject *__pyx_v_obj;
  int __pyx_v_i;
  PyObject *__pyx_v_args;
  PyObject *__pyx_v_o;
  PyObject *__pyx_v_res;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  xmlXPathObject *__pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_args = Py_None; Py_INCREF(Py_None);
  __pyx_v_o = Py_None; Py_INCREF(Py_None);
  __pyx_v_res = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":660
 *     cdef xpath.xmlXPathObject* obj
 *     cdef int i
 *     doc = context._doc             # <<<<<<<<<<<<<<
 *     try:
 *         args = []
 */
  Py_INCREF(((PyObject *)__pyx_v_context->_doc));
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = __pyx_v_context->_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":661
 *     cdef int i
 *     doc = context._doc
 *     try:             # <<<<<<<<<<<<<<
 *         args = []
 *         for i from 0 <= i < nargs:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":662
 *     doc = context._doc
 *     try:
 *         args = []             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < nargs:
 *             obj = xpath.valuePop(ctxt)
 */
      __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(__pyx_v_args);
      __pyx_v_args = ((PyObject *)__pyx_1);
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":663
 *     try:
 *         args = []
 *         for i from 0 <= i < nargs:             # <<<<<<<<<<<<<<
 *             obj = xpath.valuePop(ctxt)
 *             o = _unwrapXPathObject(obj, doc, context._build_smart_strings)
 */
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nargs; __pyx_v_i++) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":664
 *         args = []
 *         for i from 0 <= i < nargs:
 *             obj = xpath.valuePop(ctxt)             # <<<<<<<<<<<<<<
 *             o = _unwrapXPathObject(obj, doc, context._build_smart_strings)
 *             _freeXPathObject(obj)
 */
        __pyx_v_obj = valuePop(__pyx_v_ctxt);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":665
 *         for i from 0 <= i < nargs:
 *             obj = xpath.valuePop(ctxt)
 *             o = _unwrapXPathObject(obj, doc, context._build_smart_strings)             # <<<<<<<<<<<<<<
 *             _freeXPathObject(obj)
 *             python.PyList_Append(args, o)
 */
        __pyx_1 = __pyx_f_4lxml_5etree__unwrapXPathObject(__pyx_v_obj, __pyx_v_doc, __pyx_v_context->_build_smart_strings); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        Py_DECREF(__pyx_v_o);
        __pyx_v_o = __pyx_1;
        __pyx_1 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":666
 *             obj = xpath.valuePop(ctxt)
 *             o = _unwrapXPathObject(obj, doc, context._build_smart_strings)
 *             _freeXPathObject(obj)             # <<<<<<<<<<<<<<
 *             python.PyList_Append(args, o)
 *         python.PyList_Reverse(args)
 */
        __pyx_f_4lxml_5etree__freeXPathObject(__pyx_v_obj);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":667
 *             o = _unwrapXPathObject(obj, doc, context._build_smart_strings)
 *             _freeXPathObject(obj)
 *             python.PyList_Append(args, o)             # <<<<<<<<<<<<<<
 *         python.PyList_Reverse(args)
 * 
 */
        __pyx_2 = PyList_Append(__pyx_v_args, __pyx_v_o); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":668
 *             _freeXPathObject(obj)
 *             python.PyList_Append(args, o)
 *         python.PyList_Reverse(args)             # <<<<<<<<<<<<<<
 * 
 *         res = function(context, *args)
 */
      __pyx_2 = PyList_Reverse(__pyx_v_args); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L3_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":670
 *         python.PyList_Reverse(args)
 * 
 *         res = function(context, *args)             # <<<<<<<<<<<<<<
 *         # wrap result for XPath consumption
 *         obj = _wrapXPathObject(res)
 */
      __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_INCREF(((PyObject *)__pyx_v_context));
      PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_context));
      __pyx_3 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_1), __pyx_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = PyObject_Call(__pyx_v_function, __pyx_t_1, NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      Py_DECREF(__pyx_v_res);
      __pyx_v_res = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":672
 *         res = function(context, *args)
 *         # wrap result for XPath consumption
 *         obj = _wrapXPathObject(res)             # <<<<<<<<<<<<<<
 *         # prevent Python from deallocating elements handed to libxml2
 *         context._hold(res)
 */
      __pyx_4 = __pyx_f_4lxml_5etree__wrapXPathObject(__pyx_v_res); if (unlikely(__pyx_4 == NULL)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_obj = __pyx_4;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":674
 *         obj = _wrapXPathObject(res)
 *         # prevent Python from deallocating elements handed to libxml2
 *         context._hold(res)             # <<<<<<<<<<<<<<
 *         xpath.valuePush(ctxt, obj)
 *     except:
 */
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_context->__pyx_vtab)->_hold(__pyx_v_context, __pyx_v_res); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":675
 *         # prevent Python from deallocating elements handed to libxml2
 *         context._hold(res)
 *         xpath.valuePush(ctxt, obj)             # <<<<<<<<<<<<<<
 *     except:
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_EXPR_ERROR)
 */
      valuePush(__pyx_v_ctxt, __pyx_v_obj);
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L7_try;
    __pyx_L3_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":676
 *         context._hold(res)
 *         xpath.valuePush(ctxt, obj)
 *     except:             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_EXPR_ERROR)
 *         context._exc._store_raised()
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._extension_function_call");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":677
 *         xpath.valuePush(ctxt, obj)
 *     except:
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_EXPR_ERROR)             # <<<<<<<<<<<<<<
 *         context._exc._store_raised()
 * 
 */
      xmlXPathErr(__pyx_v_ctxt, XPATH_EXPR_ERROR);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":678
 *     except:
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_EXPR_ERROR)
 *         context._exc._store_raised()             # <<<<<<<<<<<<<<
 * 
 * # lookup the function by name and call it
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_context->_exc->__pyx_vtab)->_store_raised(__pyx_v_context->_exc);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L7_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._extension_function_call");
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_args);
  Py_DECREF(__pyx_v_o);
  Py_DECREF(__pyx_v_res);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":682
 * # lookup the function by name and call it
 * 
 * cdef void _xpath_function_call(xpath.xmlXPathParserContext* ctxt,             # <<<<<<<<<<<<<<
 *                                int nargs) with gil:
 *     cdef xpath.xmlXPathContext* rctxt
 */

static  void __pyx_f_4lxml_5etree__xpath_function_call(xmlXPathParserContext *__pyx_v_ctxt, int __pyx_v_nargs) {
  xmlXPathContext *__pyx_v_rctxt;
  struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_v_context;
  PyObject *__pyx_v_function;
  PyObject *__pyx_v_fref;
  PyObject *__pyx_v_exception;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__BaseContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_function = Py_None; Py_INCREF(Py_None);
  __pyx_v_fref = Py_None; Py_INCREF(Py_None);
  __pyx_v_exception = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":686
 *     cdef xpath.xmlXPathContext* rctxt
 *     cdef _BaseContext context
 *     rctxt = ctxt.context             # <<<<<<<<<<<<<<
 *     context = <_BaseContext>(rctxt.userData)
 *     function = context._find_cached_function(rctxt.functionURI, rctxt.function)
 */
  __pyx_v_rctxt = __pyx_v_ctxt->context;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":687
 *     cdef _BaseContext context
 *     rctxt = ctxt.context
 *     context = <_BaseContext>(rctxt.userData)             # <<<<<<<<<<<<<<
 *     function = context._find_cached_function(rctxt.functionURI, rctxt.function)
 *     if function is not None:
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_rctxt->userData)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_rctxt->userData);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":688
 *     rctxt = ctxt.context
 *     context = <_BaseContext>(rctxt.userData)
 *     function = context._find_cached_function(rctxt.functionURI, rctxt.function)             # <<<<<<<<<<<<<<
 *     if function is not None:
 *         _extension_function_call(context, function, ctxt, nargs)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseContext *)__pyx_v_context->__pyx_vtab)->_find_cached_function(__pyx_v_context, __pyx_v_rctxt->functionURI, __pyx_v_rctxt->function); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_function);
  __pyx_v_function = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":689
 *     context = <_BaseContext>(rctxt.userData)
 *     function = context._find_cached_function(rctxt.functionURI, rctxt.function)
 *     if function is not None:             # <<<<<<<<<<<<<<
 *         _extension_function_call(context, function, ctxt, nargs)
 *     else:
 */
  __pyx_2 = (__pyx_v_function != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":690
 *     function = context._find_cached_function(rctxt.functionURI, rctxt.function)
 *     if function is not None:
 *         _extension_function_call(context, function, ctxt, nargs)             # <<<<<<<<<<<<<<
 *     else:
 *         if rctxt.functionURI is not NULL:
 */
    __pyx_f_4lxml_5etree__extension_function_call(__pyx_v_context, __pyx_v_function, __pyx_v_ctxt, __pyx_v_nargs);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":692
 *         _extension_function_call(context, function, ctxt, nargs)
 *     else:
 *         if rctxt.functionURI is not NULL:             # <<<<<<<<<<<<<<
 *             fref = u"{%s}%s" % (rctxt.functionURI, rctxt.function)
 *         else:
 */
    __pyx_2 = (__pyx_v_rctxt->functionURI != NULL);
    if (__pyx_2) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":693
 *     else:
 *         if rctxt.functionURI is not NULL:
 *             fref = u"{%s}%s" % (rctxt.functionURI, rctxt.function)             # <<<<<<<<<<<<<<
 *         else:
 *             fref = rctxt.function
 */
      __pyx_1 = __Pyx_PyBytes_FromString(__pyx_v_rctxt->functionURI); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = __Pyx_PyBytes_FromString(__pyx_v_rctxt->function); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
      __pyx_1 = 0;
      __pyx_3 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_553), ((PyObject *)__pyx_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      Py_DECREF(__pyx_v_fref);
      __pyx_v_fref = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":695
 *             fref = u"{%s}%s" % (rctxt.functionURI, rctxt.function)
 *         else:
 *             fref = rctxt.function             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_UNKNOWN_FUNC_ERROR)
 *         exception = XPathFunctionError(u"XPath function '%s' not found" % fref)
 */
      __pyx_1 = __Pyx_PyBytes_FromString(__pyx_v_rctxt->function); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_fref);
      __pyx_v_fref = __pyx_1;
      __pyx_1 = 0;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":696
 *         else:
 *             fref = rctxt.function
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_UNKNOWN_FUNC_ERROR)             # <<<<<<<<<<<<<<
 *         exception = XPathFunctionError(u"XPath function '%s' not found" % fref)
 *         context._exc._store_exception(exception)
 */
    xmlXPathErr(__pyx_v_ctxt, XPATH_UNKNOWN_FUNC_ERROR);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":697
 *             fref = rctxt.function
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_UNKNOWN_FUNC_ERROR)
 *         exception = XPathFunctionError(u"XPath function '%s' not found" % fref)             # <<<<<<<<<<<<<<
 *         context._exc._store_exception(exception)
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathFunctionError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_554), __pyx_v_fref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    Py_DECREF(__pyx_v_exception);
    __pyx_v_exception = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":698
 *         xpath.xmlXPathErr(ctxt, xpath.XPATH_UNKNOWN_FUNC_ERROR)
 *         exception = XPathFunctionError(u"XPath function '%s' not found" % fref)
 *         context._exc._store_exception(exception)             # <<<<<<<<<<<<<<
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_context->_exc->__pyx_vtab)->_store_exception(__pyx_v_context->_exc, __pyx_v_exception);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._xpath_function_call");
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  Py_DECREF(__pyx_v_function);
  Py_DECREF(__pyx_v_fref);
  Py_DECREF(__pyx_v_exception);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":31
 * )
 * 
 * cdef int _register_xpath_function(void* ctxt, name_utf, ns_utf):             # <<<<<<<<<<<<<<
 *     if ns_utf is None:
 *         return xpath.xmlXPathRegisterFunc(
 */

static  int __pyx_f_4lxml_5etree__register_xpath_function(void *__pyx_v_ctxt, PyObject *__pyx_v_name_utf, PyObject *__pyx_v_ns_utf) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":32
 * 
 * cdef int _register_xpath_function(void* ctxt, name_utf, ns_utf):
 *     if ns_utf is None:             # <<<<<<<<<<<<<<
 *         return xpath.xmlXPathRegisterFunc(
 *             <xpath.xmlXPathContext*>ctxt, _cstr(name_utf),
 */
  __pyx_1 = (__pyx_v_ns_utf == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":35
 *         return xpath.xmlXPathRegisterFunc(
 *             <xpath.xmlXPathContext*>ctxt, _cstr(name_utf),
 *             _xpath_function_call)             # <<<<<<<<<<<<<<
 *     else:
 *         return xpath.xmlXPathRegisterFuncNS(
 */
    __pyx_r = xmlXPathRegisterFunc(((xmlXPathContext *)__pyx_v_ctxt), PyString_AS_STRING(__pyx_v_name_utf), __pyx_f_4lxml_5etree__xpath_function_call);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":39
 *         return xpath.xmlXPathRegisterFuncNS(
 *             <xpath.xmlXPathContext*>ctxt, _cstr(name_utf), _cstr(ns_utf),
 *             _xpath_function_call)             # <<<<<<<<<<<<<<
 * 
 * cdef int _unregister_xpath_function(void* ctxt, name_utf, ns_utf):
 */
    __pyx_r = xmlXPathRegisterFuncNS(((xmlXPathContext *)__pyx_v_ctxt), PyString_AS_STRING(__pyx_v_name_utf), PyString_AS_STRING(__pyx_v_ns_utf), __pyx_f_4lxml_5etree__xpath_function_call);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":41
 *             _xpath_function_call)
 * 
 * cdef int _unregister_xpath_function(void* ctxt, name_utf, ns_utf):             # <<<<<<<<<<<<<<
 *     if ns_utf is None:
 *         return xpath.xmlXPathRegisterFunc(
 */

static  int __pyx_f_4lxml_5etree__unregister_xpath_function(void *__pyx_v_ctxt, PyObject *__pyx_v_name_utf, PyObject *__pyx_v_ns_utf) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":42
 * 
 * cdef int _unregister_xpath_function(void* ctxt, name_utf, ns_utf):
 *     if ns_utf is None:             # <<<<<<<<<<<<<<
 *         return xpath.xmlXPathRegisterFunc(
 *             <xpath.xmlXPathContext*>ctxt, _cstr(name_utf), NULL)
 */
  __pyx_1 = (__pyx_v_ns_utf == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":44
 *     if ns_utf is None:
 *         return xpath.xmlXPathRegisterFunc(
 *             <xpath.xmlXPathContext*>ctxt, _cstr(name_utf), NULL)             # <<<<<<<<<<<<<<
 *     else:
 *         return xpath.xmlXPathRegisterFuncNS(
 */
    __pyx_r = xmlXPathRegisterFunc(((xmlXPathContext *)__pyx_v_ctxt), PyString_AS_STRING(__pyx_v_name_utf), NULL);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":47
 *     else:
 *         return xpath.xmlXPathRegisterFuncNS(
 *             <xpath.xmlXPathContext*>ctxt, _cstr(name_utf), _cstr(ns_utf), NULL)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = xmlXPathRegisterFuncNS(((xmlXPathContext *)__pyx_v_ctxt), PyString_AS_STRING(__pyx_v_name_utf), PyString_AS_STRING(__pyx_v_ns_utf), NULL);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":52
 * cdef class _XPathContext(_BaseContext):
 *     cdef object _variables
 *     def __init__(self, namespaces, extensions, enable_regexp, variables,             # <<<<<<<<<<<<<<
 *                  build_smart_strings):
 *         self._variables = variables
 */

static int __pyx_pf_4lxml_5etree_13_XPathContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_13_XPathContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_enable_regexp = 0;
  PyObject *__pyx_v_variables = 0;
  PyObject *__pyx_v_build_smart_strings = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_enable_regexp,&__pyx_kp_variables,&__pyx_kp_build_smart_strings,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_namespaces);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_extensions);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_enable_regexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_variables);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_kp_build_smart_strings);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_namespaces = values[0];
    __pyx_v_extensions = values[1];
    __pyx_v_enable_regexp = values[2];
    __pyx_v_variables = values[3];
    __pyx_v_build_smart_strings = values[4];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_namespaces = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_extensions = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_enable_regexp = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_variables = PyTuple_GET_ITEM(__pyx_args, 3);
    __pyx_v_build_smart_strings = PyTuple_GET_ITEM(__pyx_args, 4);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._XPathContext.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":54
 *     def __init__(self, namespaces, extensions, enable_regexp, variables,
 *                  build_smart_strings):
 *         self._variables = variables             # <<<<<<<<<<<<<<
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,
 *                               build_smart_strings)
 */
  Py_INCREF(__pyx_v_variables);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__XPathContext *)__pyx_v_self)->_variables);
  ((struct __pyx_obj_4lxml_5etree__XPathContext *)__pyx_v_self)->_variables = __pyx_v_variables;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":55
 *                  build_smart_strings):
 *         self._variables = variables
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,             # <<<<<<<<<<<<<<
 *                               build_smart_strings)
 * 
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseContext)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":56
 *         self._variables = variables
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,
 *                               build_smart_strings)             # <<<<<<<<<<<<<<
 * 
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):
 */
  __pyx_2 = PyTuple_New(5); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_namespaces);
  Py_INCREF(__pyx_v_extensions);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_extensions);
  Py_INCREF(__pyx_v_enable_regexp);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_enable_regexp);
  Py_INCREF(__pyx_v_build_smart_strings);
  PyTuple_SET_ITEM(__pyx_2, 4, __pyx_v_build_smart_strings);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._XPathContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":58
 *                               build_smart_strings)
 * 
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):             # <<<<<<<<<<<<<<
 *         self._set_xpath_context(xpathCtxt)
 *         self._setupDict(xpathCtxt)
 */

static  PyObject *__pyx_f_4lxml_5etree_13_XPathContext_set_context(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self, xmlXPathContext *__pyx_v_xpathCtxt) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":59
 * 
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):
 *         self._set_xpath_context(xpathCtxt)             # <<<<<<<<<<<<<<
 *         self._setupDict(xpathCtxt)
 *         self.registerLocalNamespaces()
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_xpath_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_xpathCtxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":60
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):
 *         self._set_xpath_context(xpathCtxt)
 *         self._setupDict(xpathCtxt)             # <<<<<<<<<<<<<<
 *         self.registerLocalNamespaces()
 *         self.registerLocalFunctions(xpathCtxt, _register_xpath_function)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->_setupDict(__pyx_v_self, __pyx_v_xpathCtxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":61
 *         self._set_xpath_context(xpathCtxt)
 *         self._setupDict(xpathCtxt)
 *         self.registerLocalNamespaces()             # <<<<<<<<<<<<<<
 *         self.registerLocalFunctions(xpathCtxt, _register_xpath_function)
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.registerLocalNamespaces(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":62
 *         self._setupDict(xpathCtxt)
 *         self.registerLocalNamespaces()
 *         self.registerLocalFunctions(xpathCtxt, _register_xpath_function)             # <<<<<<<<<<<<<<
 * 
 *     cdef register_context(self, _Document doc):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.registerLocalFunctions(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_xpathCtxt, __pyx_f_4lxml_5etree__register_xpath_function);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XPathContext.set_context");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":64
 *         self.registerLocalFunctions(xpathCtxt, _register_xpath_function)
 * 
 *     cdef register_context(self, _Document doc):             # <<<<<<<<<<<<<<
 *         self._register_context(doc)
 *         self.registerGlobalNamespaces()
 */

static  PyObject *__pyx_f_4lxml_5etree_13_XPathContext_register_context(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self, struct LxmlDocument *__pyx_v_doc) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":65
 * 
 *     cdef register_context(self, _Document doc):
 *         self._register_context(doc)             # <<<<<<<<<<<<<<
 *         self.registerGlobalNamespaces()
 *         self.registerGlobalFunctions(self._xpathCtxt, _register_xpath_function)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._register_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":66
 *     cdef register_context(self, _Document doc):
 *         self._register_context(doc)
 *         self.registerGlobalNamespaces()             # <<<<<<<<<<<<<<
 *         self.registerGlobalFunctions(self._xpathCtxt, _register_xpath_function)
 *         if self._variables is not None:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.registerGlobalNamespaces(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":67
 *         self._register_context(doc)
 *         self.registerGlobalNamespaces()
 *         self.registerGlobalFunctions(self._xpathCtxt, _register_xpath_function)             # <<<<<<<<<<<<<<
 *         if self._variables is not None:
 *             self.registerVariables(self._variables)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.registerGlobalFunctions(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_self->__pyx_base._xpathCtxt, __pyx_f_4lxml_5etree__register_xpath_function);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":68
 *         self.registerGlobalNamespaces()
 *         self.registerGlobalFunctions(self._xpathCtxt, _register_xpath_function)
 *         if self._variables is not None:             # <<<<<<<<<<<<<<
 *             self.registerVariables(self._variables)
 * 
 */
  __pyx_2 = (__pyx_v_self->_variables != Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":69
 *         self.registerGlobalFunctions(self._xpathCtxt, _register_xpath_function)
 *         if self._variables is not None:
 *             self.registerVariables(self._variables)             # <<<<<<<<<<<<<<
 * 
 *     cdef unregister_context(self):
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->registerVariables(__pyx_v_self, __pyx_v_self->_variables); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XPathContext.register_context");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":71
 *             self.registerVariables(self._variables)
 * 
 *     cdef unregister_context(self):             # <<<<<<<<<<<<<<
 *         self.unregisterGlobalFunctions(
 *             self._xpathCtxt, _unregister_xpath_function)
 */

static  PyObject *__pyx_f_4lxml_5etree_13_XPathContext_unregister_context(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":73
 *     cdef unregister_context(self):
 *         self.unregisterGlobalFunctions(
 *             self._xpathCtxt, _unregister_xpath_function)             # <<<<<<<<<<<<<<
 *         self.unregisterGlobalNamespaces()
 *         xpath.xmlXPathRegisteredVariablesCleanup(self._xpathCtxt)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.unregisterGlobalFunctions(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_self->__pyx_base._xpathCtxt, __pyx_f_4lxml_5etree__unregister_xpath_function); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":74
 *         self.unregisterGlobalFunctions(
 *             self._xpathCtxt, _unregister_xpath_function)
 *         self.unregisterGlobalNamespaces()             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathRegisteredVariablesCleanup(self._xpathCtxt)
 *         self._cleanup_context()
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.unregisterGlobalNamespaces(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":75
 *             self._xpathCtxt, _unregister_xpath_function)
 *         self.unregisterGlobalNamespaces()
 *         xpath.xmlXPathRegisteredVariablesCleanup(self._xpathCtxt)             # <<<<<<<<<<<<<<
 *         self._cleanup_context()
 * 
 */
  xmlXPathRegisteredVariablesCleanup(__pyx_v_self->__pyx_base._xpathCtxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":76
 *         self.unregisterGlobalNamespaces()
 *         xpath.xmlXPathRegisteredVariablesCleanup(self._xpathCtxt)
 *         self._cleanup_context()             # <<<<<<<<<<<<<<
 * 
 *     cdef registerVariables(self, variable_dict):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._cleanup_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XPathContext.unregister_context");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":78
 *         self._cleanup_context()
 * 
 *     cdef registerVariables(self, variable_dict):             # <<<<<<<<<<<<<<
 *         for name, value in variable_dict.items():
 *             name_utf = self._to_utf(name)
 */

static  PyObject *__pyx_f_4lxml_5etree_13_XPathContext_registerVariables(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self, PyObject *__pyx_v_variable_dict) {
  PyObject *__pyx_v_name;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  xmlXPathObject *__pyx_6;
  __pyx_v_name = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":79
 * 
 *     cdef registerVariables(self, variable_dict):
 *         for name, value in variable_dict.items():             # <<<<<<<<<<<<<<
 *             name_utf = self._to_utf(name)
 *             xpath.xmlXPathRegisterVariable(
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_variable_dict, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) {
    __pyx_1 = 0; __pyx_2 = __pyx_3; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_name);
      __pyx_v_name = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":80
 *     cdef registerVariables(self, variable_dict):
 *         for name, value in variable_dict.items():
 *             name_utf = self._to_utf(name)             # <<<<<<<<<<<<<<
 *             xpath.xmlXPathRegisterVariable(
 *                 self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))
 */
    __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._to_utf(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_name); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_name_utf);
    __pyx_v_name_utf = __pyx_5;
    __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":82
 *             name_utf = self._to_utf(name)
 *             xpath.xmlXPathRegisterVariable(
 *                 self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))             # <<<<<<<<<<<<<<
 * 
 *     cdef registerVariable(self, name, value):
 */
    __pyx_6 = __pyx_f_4lxml_5etree__wrapXPathObject(__pyx_v_value); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    xmlXPathRegisterVariable(__pyx_v_self->__pyx_base._xpathCtxt, PyString_AS_STRING(__pyx_v_name_utf), __pyx_6);
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._XPathContext.registerVariables");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":84
 *                 self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))
 * 
 *     cdef registerVariable(self, name, value):             # <<<<<<<<<<<<<<
 *         name_utf = self._to_utf(name)
 *         xpath.xmlXPathRegisterVariable(
 */

static  PyObject *__pyx_f_4lxml_5etree_13_XPathContext_registerVariable(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  xmlXPathObject *__pyx_2;
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":85
 * 
 *     cdef registerVariable(self, name, value):
 *         name_utf = self._to_utf(name)             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathRegisterVariable(
 *             self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._to_utf(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_name_utf);
  __pyx_v_name_utf = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":87
 *         name_utf = self._to_utf(name)
 *         xpath.xmlXPathRegisterVariable(
 *             self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))             # <<<<<<<<<<<<<<
 * 
 *     cdef void _registerVariable(self, name_utf, value):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__wrapXPathObject(__pyx_v_value); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  xmlXPathRegisterVariable(__pyx_v_self->__pyx_base._xpathCtxt, PyString_AS_STRING(__pyx_v_name_utf), __pyx_2);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XPathContext.registerVariable");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":89
 *             self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))
 * 
 *     cdef void _registerVariable(self, name_utf, value):             # <<<<<<<<<<<<<<
 *         xpath.xmlXPathRegisterVariable(
 *             self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))
 */

static  void __pyx_f_4lxml_5etree_13_XPathContext__registerVariable(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self, PyObject *__pyx_v_name_utf, PyObject *__pyx_v_value) {
  xmlXPathObject *__pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":91
 *     cdef void _registerVariable(self, name_utf, value):
 *         xpath.xmlXPathRegisterVariable(
 *             self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))             # <<<<<<<<<<<<<<
 * 
 *     cdef void _setupDict(self, xpath.xmlXPathContext* xpathCtxt):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__wrapXPathObject(__pyx_v_value); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  xmlXPathRegisterVariable(__pyx_v_self->__pyx_base._xpathCtxt, PyString_AS_STRING(__pyx_v_name_utf), __pyx_1);

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("lxml.etree._XPathContext._registerVariable");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":93
 *             self._xpathCtxt, _cstr(name_utf), _wrapXPathObject(value))
 * 
 *     cdef void _setupDict(self, xpath.xmlXPathContext* xpathCtxt):             # <<<<<<<<<<<<<<
 *         __GLOBAL_PARSER_CONTEXT.initXPathParserDict(xpathCtxt)
 * 
 */

static  void __pyx_f_4lxml_5etree_13_XPathContext__setupDict(struct __pyx_obj_4lxml_5etree__XPathContext *__pyx_v_self, xmlXPathContext *__pyx_v_xpathCtxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":94
 * 
 *     cdef void _setupDict(self, xpath.xmlXPathContext* xpathCtxt):
 *         __GLOBAL_PARSER_CONTEXT.initXPathParserDict(xpathCtxt)             # <<<<<<<<<<<<<<
 * 
 * cdef bint _XPATH_VERSION_WARNING_REQUIRED
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initXPathParserDict(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_xpathCtxt);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":108
 *     cdef _ErrorLog _error_log
 * 
 *     def __init__(self, namespaces, extensions, enable_regexp,             # <<<<<<<<<<<<<<
 *                  smart_strings):
 *         global _XPATH_VERSION_WARNING_REQUIRED
 */

static int __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_enable_regexp = 0;
  PyObject *__pyx_v_smart_strings = 0;
  PyObject *__pyx_v_warnings;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_enable_regexp,&__pyx_kp_smart_strings,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_namespaces);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_extensions);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_enable_regexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_smart_strings);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_namespaces = values[0];
    __pyx_v_extensions = values[1];
    __pyx_v_enable_regexp = values[2];
    __pyx_v_smart_strings = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_namespaces = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_extensions = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_enable_regexp = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_smart_strings = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_warnings = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":111
 *                  smart_strings):
 *         global _XPATH_VERSION_WARNING_REQUIRED
 *         if _XPATH_VERSION_WARNING_REQUIRED:             # <<<<<<<<<<<<<<
 *             _XPATH_VERSION_WARNING_REQUIRED = 0
 *             import warnings
 */
  __pyx_1 = __pyx_v_4lxml_5etree__XPATH_VERSION_WARNING_REQUIRED;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":112
 *         global _XPATH_VERSION_WARNING_REQUIRED
 *         if _XPATH_VERSION_WARNING_REQUIRED:
 *             _XPATH_VERSION_WARNING_REQUIRED = 0             # <<<<<<<<<<<<<<
 *             import warnings
 *             warnings.warn(u"This version of libxml2 has a known XPath bug. " + \
 */
    __pyx_v_4lxml_5etree__XPATH_VERSION_WARNING_REQUIRED = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":113
 *         if _XPATH_VERSION_WARNING_REQUIRED:
 *             _XPATH_VERSION_WARNING_REQUIRED = 0
 *             import warnings             # <<<<<<<<<<<<<<
 *             warnings.warn(u"This version of libxml2 has a known XPath bug. " + \
 *                           u"Use it at your own risk.")
 */
    __pyx_2 = __Pyx_Import(__pyx_kp_warnings, 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_warnings);
    __pyx_v_warnings = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":114
 *             _XPATH_VERSION_WARNING_REQUIRED = 0
 *             import warnings
 *             warnings.warn(u"This version of libxml2 has a known XPath bug. " + \             # <<<<<<<<<<<<<<
 *                           u"Use it at your own risk.")
 *         self._error_log = _ErrorLog()
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_warnings, __pyx_kp_warn); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":115
 *             import warnings
 *             warnings.warn(u"This version of libxml2 has a known XPath bug. " + \
 *                           u"Use it at your own risk.")             # <<<<<<<<<<<<<<
 *         self._error_log = _ErrorLog()
 *         self._context = _XPathContext(namespaces, extensions,
 */
    __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_555), ((PyObject *)__pyx_kp_556)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":116
 *             warnings.warn(u"This version of libxml2 has a known XPath bug. " + \
 *                           u"Use it at your own risk.")
 *         self._error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 *         self._context = _XPathContext(namespaces, extensions,
 *                                       enable_regexp, None, smart_strings)
 */
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_error_log));
  ((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":118
 *         self._error_log = _ErrorLog()
 *         self._context = _XPathContext(namespaces, extensions,
 *                                       enable_regexp, None, smart_strings)             # <<<<<<<<<<<<<<
 * 
 *     property error_log:
 */
  __pyx_3 = PyTuple_New(5); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_namespaces);
  Py_INCREF(__pyx_v_extensions);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_extensions);
  Py_INCREF(__pyx_v_enable_regexp);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_enable_regexp);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_3, 3, Py_None);
  Py_INCREF(__pyx_v_smart_strings);
  PyTuple_SET_ITEM(__pyx_3, 4, __pyx_v_smart_strings);
  __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XPathContext)), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__XPathContext))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":117
 *                           u"Use it at your own risk.")
 *         self._error_log = _ErrorLog()
 *         self._context = _XPathContext(namespaces, extensions,             # <<<<<<<<<<<<<<
 *                                       enable_regexp, None, smart_strings)
 * 
 */
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_context));
  ((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_context = ((struct __pyx_obj_4lxml_5etree__XPathContext *)__pyx_4);
  __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_warnings);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":121
 * 
 *     property error_log:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._error_log.copy()
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_19_XPathEvaluatorBase_9error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_19_XPathEvaluatorBase_9error_log___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":122
 *     property error_log:
 *         def __get__(self):
 *             return self._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase.error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":124
 *             return self._error_log.copy()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._xpathCtxt is not NULL:
 *             xpath.xmlXPathFreeContext(self._xpathCtxt)
 */

static void __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":125
 * 
 *     def __dealloc__(self):
 *         if self._xpathCtxt is not NULL:             # <<<<<<<<<<<<<<
 *             xpath.xmlXPathFreeContext(self._xpathCtxt)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_xpathCtxt != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":126
 *     def __dealloc__(self):
 *         if self._xpathCtxt is not NULL:
 *             xpath.xmlXPathFreeContext(self._xpathCtxt)             # <<<<<<<<<<<<<<
 * 
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):
 */
    xmlXPathFreeContext(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)->_xpathCtxt);
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":128
 *             xpath.xmlXPathFreeContext(self._xpathCtxt)
 * 
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):             # <<<<<<<<<<<<<<
 *         self._xpathCtxt = xpathCtxt
 *         self._context.set_context(xpathCtxt)
 */

static  PyObject *__pyx_f_4lxml_5etree_19_XPathEvaluatorBase_set_context(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self, xmlXPathContext *__pyx_v_xpathCtxt) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":129
 * 
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):
 *         self._xpathCtxt = xpathCtxt             # <<<<<<<<<<<<<<
 *         self._context.set_context(xpathCtxt)
 * 
 */
  __pyx_v_self->_xpathCtxt = __pyx_v_xpathCtxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":130
 *     cdef set_context(self, xpath.xmlXPathContext* xpathCtxt):
 *         self._xpathCtxt = xpathCtxt
 *         self._context.set_context(xpathCtxt)             # <<<<<<<<<<<<<<
 * 
 *     def evaluate(self, _eval_arg, **_variables):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->_context->__pyx_base.__pyx_vtab)->set_context(__pyx_v_self->_context, __pyx_v_xpathCtxt); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase.set_context");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":132
 *         self._context.set_context(xpathCtxt)
 * 
 *     def evaluate(self, _eval_arg, **_variables):             # <<<<<<<<<<<<<<
 *         u"""evaluate(self, _eval_arg, **_variables)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_19_XPathEvaluatorBase_evaluate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_19_XPathEvaluatorBase_evaluate[] = "evaluate(self, _eval_arg, **_variables)\n\n        Evaluate an XPath expression.\n\n        Instead of calling this method, you can also call the evaluator object\n        itself.\n\n        Variables may be provided as keyword arguments.  Note that namespaces\n        are currently not supported for variables.\n\n        :deprecated: call the object, not its method.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_19_XPathEvaluatorBase_evaluate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__eval_arg = 0;
  PyObject *__pyx_v__variables = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__eval_arg,0};
  __pyx_v__variables = PyDict_New(); if (unlikely(!__pyx_v__variables)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__eval_arg);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__variables, values, PyTuple_GET_SIZE(__pyx_args), "evaluate") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__eval_arg = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__eval_arg = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("evaluate", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__variables);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase.evaluate");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":145
 *         :deprecated: call the object, not its method.
 *         """
 *         return self(_eval_arg, **_variables)             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _checkAbsolutePath(self, char* path):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v__eval_arg);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v__eval_arg);
  __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_v_self, ((PyObject *)__pyx_1), __pyx_v__variables); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase.evaluate");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__variables);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":147
 *         return self(_eval_arg, **_variables)
 * 
 *     cdef bint _checkAbsolutePath(self, char* path):             # <<<<<<<<<<<<<<
 *         cdef char c
 *         if path is NULL:
 */

static  int __pyx_f_4lxml_5etree_19_XPathEvaluatorBase__checkAbsolutePath(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self, char *__pyx_v_path) {
  char __pyx_v_c;
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":149
 *     cdef bint _checkAbsolutePath(self, char* path):
 *         cdef char c
 *         if path is NULL:             # <<<<<<<<<<<<<<
 *             return 0
 *         c = path[0]
 */
  __pyx_1 = (__pyx_v_path == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":150
 *         cdef char c
 *         if path is NULL:
 *             return 0             # <<<<<<<<<<<<<<
 *         c = path[0]
 *         while c == c' ' or c == c'\t':
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":151
 *         if path is NULL:
 *             return 0
 *         c = path[0]             # <<<<<<<<<<<<<<
 *         while c == c' ' or c == c'\t':
 *             path = path + 1
 */
  __pyx_v_c = (__pyx_v_path[0]);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":152
 *             return 0
 *         c = path[0]
 *         while c == c' ' or c == c'\t':             # <<<<<<<<<<<<<<
 *             path = path + 1
 *             c = path[0]
 */
  while (1) {
    __pyx_1 = (__pyx_v_c == ' ');
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_c == '\t');
    }
    if (!__pyx_1) break;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":153
 *         c = path[0]
 *         while c == c' ' or c == c'\t':
 *             path = path + 1             # <<<<<<<<<<<<<<
 *             c = path[0]
 *         return c == c'/'
 */
    __pyx_v_path = (__pyx_v_path + 1);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":154
 *         while c == c' ' or c == c'\t':
 *             path = path + 1
 *             c = path[0]             # <<<<<<<<<<<<<<
 *         return c == c'/'
 * 
 */
    __pyx_v_c = (__pyx_v_path[0]);
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":155
 *             path = path + 1
 *             c = path[0]
 *         return c == c'/'             # <<<<<<<<<<<<<<
 * 
 *     cdef int _lock(self) except -1:
 */
  __pyx_r = (__pyx_v_c == '/');
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":157
 *         return c == c'/'
 * 
 *     cdef int _lock(self) except -1:             # <<<<<<<<<<<<<<
 *         cdef int result
 *         if config.ENABLE_THREADING and self._eval_lock != NULL:
 */

static  int __pyx_f_4lxml_5etree_19_XPathEvaluatorBase__lock(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self) {
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":159
 *     cdef int _lock(self) except -1:
 *         cdef int result
 *         if config.ENABLE_THREADING and self._eval_lock != NULL:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 result = python.PyThread_acquire_lock(
 */
  __pyx_1 = ENABLE_THREADING;
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_eval_lock != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":160
 *         cdef int result
 *         if config.ENABLE_THREADING and self._eval_lock != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = python.PyThread_acquire_lock(
 *                     self._eval_lock, python.WAIT_LOCK)
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":162
 *             with nogil:
 *                 result = python.PyThread_acquire_lock(
 *                     self._eval_lock, python.WAIT_LOCK)             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 raise ParserError, u"parser locking failed"
 */
        __pyx_v_result = PyThread_acquire_lock(__pyx_v_self->_eval_lock, WAIT_LOCK);
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":163
 *                 result = python.PyThread_acquire_lock(
 *                     self._eval_lock, python.WAIT_LOCK)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 raise ParserError, u"parser locking failed"
 *         return 0
 */
    __pyx_1 = (__pyx_v_result == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":164
 *                     self._eval_lock, python.WAIT_LOCK)
 *             if result == 0:
 *                 raise ParserError, u"parser locking failed"             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ParserError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_557), 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[16]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":165
 *             if result == 0:
 *                 raise ParserError, u"parser locking failed"
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void _unlock(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase._lock");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":167
 *         return 0
 * 
 *     cdef void _unlock(self):             # <<<<<<<<<<<<<<
 *         if config.ENABLE_THREADING and self._eval_lock != NULL:
 *             python.PyThread_release_lock(self._eval_lock)
 */

static  void __pyx_f_4lxml_5etree_19_XPathEvaluatorBase__unlock(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":168
 * 
 *     cdef void _unlock(self):
 *         if config.ENABLE_THREADING and self._eval_lock != NULL:             # <<<<<<<<<<<<<<
 *             python.PyThread_release_lock(self._eval_lock)
 * 
 */
  __pyx_1 = ENABLE_THREADING;
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_eval_lock != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":169
 *     cdef void _unlock(self):
 *         if config.ENABLE_THREADING and self._eval_lock != NULL:
 *             python.PyThread_release_lock(self._eval_lock)             # <<<<<<<<<<<<<<
 * 
 *     cdef _raise_parse_error(self):
 */
    PyThread_release_lock(__pyx_v_self->_eval_lock);
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":171
 *             python.PyThread_release_lock(self._eval_lock)
 * 
 *     cdef _raise_parse_error(self):             # <<<<<<<<<<<<<<
 *         cdef _BaseErrorLog entries
 *         entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 */

static  PyObject *__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__raise_parse_error(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_entries;
  PyObject *__pyx_v_message;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  __pyx_v_entries = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)Py_None); Py_INCREF(Py_None);
  __pyx_v_message = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":173
 *     cdef _raise_parse_error(self):
 *         cdef _BaseErrorLog entries
 *         entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)             # <<<<<<<<<<<<<<
 *         if entries:
 *             message = entries._buildExceptionMessage(None)
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_error_log), __pyx_kp_filter_types); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__BaseErrorLog))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_entries));
  __pyx_v_entries = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_3);
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":174
 *         cdef _BaseErrorLog entries
 *         entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 *         if entries:             # <<<<<<<<<<<<<<
 *             message = entries._buildExceptionMessage(None)
 *             if message is not None:
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_entries)); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":175
 *         entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 *         if entries:
 *             message = entries._buildExceptionMessage(None)             # <<<<<<<<<<<<<<
 *             if message is not None:
 *                 raise XPathSyntaxError(message, self._error_log)
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog *)__pyx_v_entries->__pyx_vtab)->_buildExceptionMessage(__pyx_v_entries, Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":176
 *         if entries:
 *             message = entries._buildExceptionMessage(None)
 *             if message is not None:             # <<<<<<<<<<<<<<
 *                 raise XPathSyntaxError(message, self._error_log)
 *         raise XPathSyntaxError(self._error_log._buildExceptionMessage(
 */
    __pyx_4 = (__pyx_v_message != Py_None);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":177
 *             message = entries._buildExceptionMessage(None)
 *             if message is not None:
 *                 raise XPathSyntaxError(message, self._error_log)             # <<<<<<<<<<<<<<
 *         raise XPathSyntaxError(self._error_log._buildExceptionMessage(
 *                 u"Error in xpath expression"),
 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathSyntaxError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
      Py_INCREF(((PyObject *)__pyx_v_self->_error_log));
      PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_self->_error_log));
      __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      __Pyx_Raise(__pyx_1, 0, 0);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      {__pyx_filename = __pyx_f[16]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":178
 *             if message is not None:
 *                 raise XPathSyntaxError(message, self._error_log)
 *         raise XPathSyntaxError(self._error_log._buildExceptionMessage(             # <<<<<<<<<<<<<<
 *                 u"Error in xpath expression"),
 *                                self._error_log)
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathSyntaxError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":179
 *                 raise XPathSyntaxError(message, self._error_log)
 *         raise XPathSyntaxError(self._error_log._buildExceptionMessage(
 *                 u"Error in xpath expression"),             # <<<<<<<<<<<<<<
 *                                self._error_log)
 * 
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_self->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self->_error_log), ((PyObject *)__pyx_kp_558)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":180
 *         raise XPathSyntaxError(self._error_log._buildExceptionMessage(
 *                 u"Error in xpath expression"),
 *                                self._error_log)             # <<<<<<<<<<<<<<
 * 
 *     cdef _raise_eval_error(self):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  Py_INCREF(((PyObject *)__pyx_v_self->_error_log));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_self->_error_log));
  __pyx_3 = 0;
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __Pyx_Raise(__pyx_3, 0, 0);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  {__pyx_filename = __pyx_f[16]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase._raise_parse_error");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entries);
  Py_DECREF(__pyx_v_message);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":182
 *                                self._error_log)
 * 
 *     cdef _raise_eval_error(self):             # <<<<<<<<<<<<<<
 *         cdef _BaseErrorLog entries
 *         entries = self._error_log.filter_types(_XPATH_EVAL_ERRORS)
 */

static  PyObject *__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__raise_eval_error(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *__pyx_v_entries;
  PyObject *__pyx_v_message;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  __pyx_v_entries = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)Py_None); Py_INCREF(Py_None);
  __pyx_v_message = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":184
 *     cdef _raise_eval_error(self):
 *         cdef _BaseErrorLog entries
 *         entries = self._error_log.filter_types(_XPATH_EVAL_ERRORS)             # <<<<<<<<<<<<<<
 *         if not entries:
 *             entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_error_log), __pyx_kp_filter_types); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_4lxml_5etree__XPATH_EVAL_ERRORS);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_4lxml_5etree__XPATH_EVAL_ERRORS);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__BaseErrorLog))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_entries));
  __pyx_v_entries = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_3);
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":185
 *         cdef _BaseErrorLog entries
 *         entries = self._error_log.filter_types(_XPATH_EVAL_ERRORS)
 *         if not entries:             # <<<<<<<<<<<<<<
 *             entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 *         if entries:
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_entries)); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":186
 *         entries = self._error_log.filter_types(_XPATH_EVAL_ERRORS)
 *         if not entries:
 *             entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)             # <<<<<<<<<<<<<<
 *         if entries:
 *             message = entries._buildExceptionMessage(None)
 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_error_log), __pyx_kp_filter_types); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS);
    __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_4lxml_5etree__BaseErrorLog))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_entries));
    __pyx_v_entries = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_3);
    __pyx_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":187
 *         if not entries:
 *             entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 *         if entries:             # <<<<<<<<<<<<<<
 *             message = entries._buildExceptionMessage(None)
 *             if message is not None:
 */
  __pyx_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_entries)); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":188
 *             entries = self._error_log.filter_types(_XPATH_SYNTAX_ERRORS)
 *         if entries:
 *             message = entries._buildExceptionMessage(None)             # <<<<<<<<<<<<<<
 *             if message is not None:
 *                 raise XPathEvalError(message, self._error_log)
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog *)__pyx_v_entries->__pyx_vtab)->_buildExceptionMessage(__pyx_v_entries, Py_None); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_message);
    __pyx_v_message = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":189
 *         if entries:
 *             message = entries._buildExceptionMessage(None)
 *             if message is not None:             # <<<<<<<<<<<<<<
 *                 raise XPathEvalError(message, self._error_log)
 *         raise XPathEvalError(self._error_log._buildExceptionMessage(
 */
    __pyx_5 = (__pyx_v_message != Py_None);
    if (__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":190
 *             message = entries._buildExceptionMessage(None)
 *             if message is not None:
 *                 raise XPathEvalError(message, self._error_log)             # <<<<<<<<<<<<<<
 *         raise XPathEvalError(self._error_log._buildExceptionMessage(
 *                 u"Error in xpath expression"),
 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathEvalError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
      Py_INCREF(((PyObject *)__pyx_v_self->_error_log));
      PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_self->_error_log));
      __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      __Pyx_Raise(__pyx_1, 0, 0);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      {__pyx_filename = __pyx_f[16]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":191
 *             if message is not None:
 *                 raise XPathEvalError(message, self._error_log)
 *         raise XPathEvalError(self._error_log._buildExceptionMessage(             # <<<<<<<<<<<<<<
 *                 u"Error in xpath expression"),
 *                              self._error_log)
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathEvalError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":192
 *                 raise XPathEvalError(message, self._error_log)
 *         raise XPathEvalError(self._error_log._buildExceptionMessage(
 *                 u"Error in xpath expression"),             # <<<<<<<<<<<<<<
 *                              self._error_log)
 * 
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_self->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_v_self->_error_log), ((PyObject *)__pyx_kp_559)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":193
 *         raise XPathEvalError(self._error_log._buildExceptionMessage(
 *                 u"Error in xpath expression"),
 *                              self._error_log)             # <<<<<<<<<<<<<<
 * 
 *     cdef object _handle_result(self, xpath.xmlXPathObject* xpathObj, _Document doc):
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  Py_INCREF(((PyObject *)__pyx_v_self->_error_log));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_self->_error_log));
  __pyx_3 = 0;
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __Pyx_Raise(__pyx_3, 0, 0);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  {__pyx_filename = __pyx_f[16]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase._raise_eval_error");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entries);
  Py_DECREF(__pyx_v_message);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":195
 *                              self._error_log)
 * 
 *     cdef object _handle_result(self, xpath.xmlXPathObject* xpathObj, _Document doc):             # <<<<<<<<<<<<<<
 *         if self._context._exc._has_raised():
 *             if xpathObj is not NULL:
 */

static  PyObject *__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__handle_result(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *__pyx_v_self, xmlXPathObject *__pyx_v_xpathObj, struct LxmlDocument *__pyx_v_doc) {
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":196
 * 
 *     cdef object _handle_result(self, xpath.xmlXPathObject* xpathObj, _Document doc):
 *         if self._context._exc._has_raised():             # <<<<<<<<<<<<<<
 *             if xpathObj is not NULL:
 *                 _freeXPathObject(xpathObj)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_self->_context->__pyx_base._exc->__pyx_vtab)->_has_raised(__pyx_v_self->_context->__pyx_base._exc);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":197
 *     cdef object _handle_result(self, xpath.xmlXPathObject* xpathObj, _Document doc):
 *         if self._context._exc._has_raised():
 *             if xpathObj is not NULL:             # <<<<<<<<<<<<<<
 *                 _freeXPathObject(xpathObj)
 *                 xpathObj = NULL
 */
    __pyx_1 = (__pyx_v_xpathObj != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":198
 *         if self._context._exc._has_raised():
 *             if xpathObj is not NULL:
 *                 _freeXPathObject(xpathObj)             # <<<<<<<<<<<<<<
 *                 xpathObj = NULL
 *             self._context._release_temp_refs()
 */
      __pyx_f_4lxml_5etree__freeXPathObject(__pyx_v_xpathObj);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":199
 *             if xpathObj is not NULL:
 *                 _freeXPathObject(xpathObj)
 *                 xpathObj = NULL             # <<<<<<<<<<<<<<
 *             self._context._release_temp_refs()
 *             self._context._exc._raise_if_stored()
 */
      __pyx_v_xpathObj = NULL;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":200
 *                 _freeXPathObject(xpathObj)
 *                 xpathObj = NULL
 *             self._context._release_temp_refs()             # <<<<<<<<<<<<<<
 *             self._context._exc._raise_if_stored()
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->_context->__pyx_base.__pyx_vtab)->__pyx_base._release_temp_refs(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":201
 *                 xpathObj = NULL
 *             self._context._release_temp_refs()
 *             self._context._exc._raise_if_stored()             # <<<<<<<<<<<<<<
 * 
 *         if xpathObj is NULL:
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_self->_context->__pyx_base._exc->__pyx_vtab)->_raise_if_stored(__pyx_v_self->_context->__pyx_base._exc); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":203
 *             self._context._exc._raise_if_stored()
 * 
 *         if xpathObj is NULL:             # <<<<<<<<<<<<<<
 *             self._context._release_temp_refs()
 *             self._raise_eval_error()
 */
  __pyx_1 = (__pyx_v_xpathObj == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":204
 * 
 *         if xpathObj is NULL:
 *             self._context._release_temp_refs()             # <<<<<<<<<<<<<<
 *             self._raise_eval_error()
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->_context->__pyx_base.__pyx_vtab)->__pyx_base._release_temp_refs(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":205
 *         if xpathObj is NULL:
 *             self._context._release_temp_refs()
 *             self._raise_eval_error()             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self->__pyx_vtab)->_raise_eval_error(__pyx_v_self); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":207
 *             self._raise_eval_error()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             result = _unwrapXPathObject(xpathObj, doc,
 *                                         self._context._build_smart_strings)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":209
 *         try:
 *             result = _unwrapXPathObject(xpathObj, doc,
 *                                         self._context._build_smart_strings)             # <<<<<<<<<<<<<<
 *         finally:
 *             _freeXPathObject(xpathObj)
 */
    __pyx_2 = __pyx_f_4lxml_5etree__unwrapXPathObject(__pyx_v_xpathObj, __pyx_v_doc, __pyx_v_self->_context->__pyx_base._build_smart_strings); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_2;
    __pyx_2 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":211
 *                                         self._context._build_smart_strings)
 *         finally:
 *             _freeXPathObject(xpathObj)             # <<<<<<<<<<<<<<
 *             self._context._release_temp_refs()
 * 
 */
    __pyx_f_4lxml_5etree__freeXPathObject(__pyx_v_xpathObj);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":212
 *         finally:
 *             _freeXPathObject(xpathObj)
 *             self._context._release_temp_refs()             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)__pyx_v_self->_context->__pyx_base.__pyx_vtab)->__pyx_base._release_temp_refs(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L10;
    __pyx_L9_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L10:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":214
 *             self._context._release_temp_refs()
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._XPathEvaluatorBase._handle_result");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":231
 *     """
 *     cdef _Element _element
 *     def __init__(self, _Element element not None, *, namespaces=None,             # <<<<<<<<<<<<<<
 *                  extensions=None, regexp=True, smart_strings=True):
 *         cdef xpath.xmlXPathContext* xpathCtxt
 */

static int __pyx_pf_4lxml_5etree_21XPathElementEvaluator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_21XPathElementEvaluator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElement *__pyx_v_element = 0;
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_regexp = 0;
  PyObject *__pyx_v_smart_strings = 0;
  xmlXPathContext *__pyx_v_xpathCtxt;
  struct LxmlDocument *__pyx_v_doc;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_element,&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_regexp,&__pyx_kp_smart_strings,0};
  __pyx_v_namespaces = Py_None;
  __pyx_v_extensions = Py_None;
  __pyx_v_regexp = __pyx_k_167;
  __pyx_v_smart_strings = __pyx_k_168;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_element);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_element = ((struct LxmlElement *)values[0]);
    if (values[1]) {
      __pyx_v_namespaces = values[1];
    }
    if (values[2]) {
      __pyx_v_extensions = values[2];
    }
    if (values[3]) {
      __pyx_v_regexp = values[3];
    }
    if (values[4]) {
      __pyx_v_smart_strings = values[4];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_element = ((struct LxmlElement *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_element), __pyx_ptype_4lxml_5etree__Element, 0, "element", 0))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":236
 *         cdef int ns_register_status
 *         cdef _Document doc
 *         self._element = element             # <<<<<<<<<<<<<<
 *         doc = element._doc
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 */
  Py_INCREF(((PyObject *)__pyx_v_element));
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->_element));
  ((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->_element = __pyx_v_element;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":237
 *         cdef _Document doc
 *         self._element = element
 *         doc = element._doc             # <<<<<<<<<<<<<<
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 *                                      regexp, smart_strings)
 */
  Py_INCREF(((PyObject *)__pyx_v_element->_doc));
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = __pyx_v_element->_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":238
 *         self._element = element
 *         doc = element._doc
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,             # <<<<<<<<<<<<<<
 *                                      regexp, smart_strings)
 *         xpathCtxt = xpath.xmlXPathNewContext(doc._c_doc)
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XPathEvaluatorBase)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":239
 *         doc = element._doc
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 *                                      regexp, smart_strings)             # <<<<<<<<<<<<<<
 *         xpathCtxt = xpath.xmlXPathNewContext(doc._c_doc)
 *         if xpathCtxt is NULL:
 */
  __pyx_2 = PyTuple_New(5); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_namespaces);
  Py_INCREF(__pyx_v_extensions);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_extensions);
  Py_INCREF(__pyx_v_regexp);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_regexp);
  Py_INCREF(__pyx_v_smart_strings);
  PyTuple_SET_ITEM(__pyx_2, 4, __pyx_v_smart_strings);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":240
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 *                                      regexp, smart_strings)
 *         xpathCtxt = xpath.xmlXPathNewContext(doc._c_doc)             # <<<<<<<<<<<<<<
 *         if xpathCtxt is NULL:
 *             python.PyErr_NoMemory()
 */
  __pyx_v_xpathCtxt = xmlXPathNewContext(__pyx_v_doc->_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":241
 *                                      regexp, smart_strings)
 *         xpathCtxt = xpath.xmlXPathNewContext(doc._c_doc)
 *         if xpathCtxt is NULL:             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 *         self.set_context(xpathCtxt)
 */
  __pyx_4 = (__pyx_v_xpathCtxt == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":242
 *         xpathCtxt = xpath.xmlXPathNewContext(doc._c_doc)
 *         if xpathCtxt is NULL:
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         self.set_context(xpathCtxt)
 * 
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":243
 *         if xpathCtxt is NULL:
 *             python.PyErr_NoMemory()
 *         self.set_context(xpathCtxt)             # <<<<<<<<<<<<<<
 * 
 *     def register_namespace(self, prefix, uri):
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.set_context(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self), __pyx_v_xpathCtxt); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":245
 *         self.set_context(xpathCtxt)
 * 
 *     def register_namespace(self, prefix, uri):             # <<<<<<<<<<<<<<
 *         u"""Register a namespace with the XPath context.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_21XPathElementEvaluator_register_namespace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_21XPathElementEvaluator_register_namespace[] = "Register a namespace with the XPath context.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21XPathElementEvaluator_register_namespace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_prefix = 0;
  PyObject *__pyx_v_uri = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_prefix,&__pyx_kp_uri,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_prefix);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_uri);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("register_namespace", 1, 2, 2, 1); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "register_namespace") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_prefix = values[0];
    __pyx_v_uri = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_prefix = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_uri = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("register_namespace", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.register_namespace");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":248
 *         u"""Register a namespace with the XPath context.
 *         """
 *         self._context.addNamespace(prefix, uri)             # <<<<<<<<<<<<<<
 * 
 *     def register_namespaces(self, namespaces):
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->__pyx_base.addNamespace(((struct __pyx_obj_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context), __pyx_v_prefix, __pyx_v_uri); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.register_namespace");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":250
 *         self._context.addNamespace(prefix, uri)
 * 
 *     def register_namespaces(self, namespaces):             # <<<<<<<<<<<<<<
 *         u"""Register a prefix -> uri dict.
 *         """
 */

static PyObject *__pyx_pf_4lxml_5etree_21XPathElementEvaluator_register_namespaces(PyObject *__pyx_v_self, PyObject *__pyx_v_namespaces); /*proto*/
static char __pyx_doc_4lxml_5etree_21XPathElementEvaluator_register_namespaces[] = "Register a prefix -> uri dict.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21XPathElementEvaluator_register_namespaces(PyObject *__pyx_v_self, PyObject *__pyx_v_namespaces) {
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_v_uri;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);
  __pyx_v_uri = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":253
 *         u"""Register a prefix -> uri dict.
 *         """
 *         for prefix, uri in namespaces.items():             # <<<<<<<<<<<<<<
 *             self._context.addNamespace(prefix, uri)
 * 
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_namespaces, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) {
    __pyx_1 = 0; __pyx_2 = __pyx_3; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_uri);
      __pyx_v_uri = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_uri);
      __pyx_v_uri = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":254
 *         """
 *         for prefix, uri in namespaces.items():
 *             self._context.addNamespace(prefix, uri)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, _path, **_variables):
 */
    __pyx_5 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->__pyx_base.addNamespace(((struct __pyx_obj_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context), __pyx_v_prefix, __pyx_v_uri); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.register_namespaces");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_prefix);
  Py_DECREF(__pyx_v_uri);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":256
 *             self._context.addNamespace(prefix, uri)
 * 
 *     def __call__(self, _path, **_variables):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, _path, **_variables)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_21XPathElementEvaluator___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_21XPathElementEvaluator___call__[] = "__call__(self, _path, **_variables)\n\n        Evaluate an XPath expression on the document.\n\n        Variables may be provided as keyword arguments.  Note that namespaces\n        are currently not supported for variables.\n\n        Absolute XPath expressions (starting with '/') will be evaluated\n        against the ElementTree as returned by getroottree().\n        ";
static PyObject *__pyx_pf_4lxml_5etree_21XPathElementEvaluator___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__path = 0;
  PyObject *__pyx_v__variables = 0;
  xmlXPathObject *__pyx_v_xpathObj;
  struct LxmlDocument *__pyx_v_doc;
  char *__pyx_v_c_path;
  PyObject *__pyx_v_path;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__path,0};
  __pyx_v__variables = PyDict_New(); if (unlikely(!__pyx_v__variables)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__variables, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__path = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__path = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__variables);
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_path = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":270
 *         cdef _Document doc
 *         cdef char* c_path
 *         path = _utf8(_path)             # <<<<<<<<<<<<<<
 *         doc = self._element._doc
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v__path); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_path);
  __pyx_v_path = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":271
 *         cdef char* c_path
 *         path = _utf8(_path)
 *         doc = self._element._doc             # <<<<<<<<<<<<<<
 * 
 *         self._lock()
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->_element->_doc));
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->_element->_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":273
 *         doc = self._element._doc
 * 
 *         self._lock()             # <<<<<<<<<<<<<<
 *         self._error_log.connect()
 *         self._xpathCtxt.node = self._element._c_node
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._lock(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":274
 * 
 *         self._lock()
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         self._xpathCtxt.node = self._element._c_node
 *         try:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":275
 *         self._lock()
 *         self._error_log.connect()
 *         self._xpathCtxt.node = self._element._c_node             # <<<<<<<<<<<<<<
 *         try:
 *             self._context.register_context(doc)
 */
  ((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._xpathCtxt->node = ((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->_element->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":276
 *         self._error_log.connect()
 *         self._xpathCtxt.node = self._element._c_node
 *         try:             # <<<<<<<<<<<<<<
 *             self._context.register_context(doc)
 *             self._context.registerVariables(_variables)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":277
 *         self._xpathCtxt.node = self._element._c_node
 *         try:
 *             self._context.register_context(doc)             # <<<<<<<<<<<<<<
 *             self._context.registerVariables(_variables)
 *             c_path = _cstr(path)
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->register_context(((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context, __pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":278
 *         try:
 *             self._context.register_context(doc)
 *             self._context.registerVariables(_variables)             # <<<<<<<<<<<<<<
 *             c_path = _cstr(path)
 *             with nogil:
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->registerVariables(((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context, __pyx_v__variables); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":279
 *             self._context.register_context(doc)
 *             self._context.registerVariables(_variables)
 *             c_path = _cstr(path)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 xpathObj = xpath.xmlXPathEvalExpression(
 */
    __pyx_v_c_path = PyString_AS_STRING(__pyx_v_path);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":280
 *             self._context.registerVariables(_variables)
 *             c_path = _cstr(path)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 xpathObj = xpath.xmlXPathEvalExpression(
 *                     c_path, self._xpathCtxt)
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":282
 *             with nogil:
 *                 xpathObj = xpath.xmlXPathEvalExpression(
 *                     c_path, self._xpathCtxt)             # <<<<<<<<<<<<<<
 *             result = self._handle_result(xpathObj, doc)
 *         finally:
 */
        __pyx_v_xpathObj = xmlXPathEvalExpression(__pyx_v_c_path, ((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._xpathCtxt);
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":283
 *                 xpathObj = xpath.xmlXPathEvalExpression(
 *                     c_path, self._xpathCtxt)
 *             result = self._handle_result(xpathObj, doc)             # <<<<<<<<<<<<<<
 *         finally:
 *             self._error_log.disconnect()
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handle_result(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self), __pyx_v_xpathObj, __pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_1;
    __pyx_1 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":285
 *             result = self._handle_result(xpathObj, doc)
 *         finally:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             self._context.unregister_context()
 *             self._unlock()
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":286
 *         finally:
 *             self._error_log.disconnect()
 *             self._context.unregister_context()             # <<<<<<<<<<<<<<
 *             self._unlock()
 * 
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->unregister_context(((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base._context); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":287
 *             self._error_log.disconnect()
 *             self._context.unregister_context()
 *             self._unlock()             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    ((struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._unlock(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self));
    goto __pyx_L13;
    __pyx_L12_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L13:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":289
 *             self._unlock()
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XPathElementEvaluator.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__variables);
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_path);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":302
 *     you pass ``smart_strings=False``.
 *     """
 *     def __init__(self, _ElementTree etree not None, *, namespaces=None,             # <<<<<<<<<<<<<<
 *                  extensions=None, regexp=True, smart_strings=True):
 *         XPathElementEvaluator.__init__(
 */

static int __pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct LxmlElementTree *__pyx_v_etree = 0;
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_regexp = 0;
  PyObject *__pyx_v_smart_strings = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_regexp,&__pyx_kp_smart_strings,0};
  __pyx_v_namespaces = Py_None;
  __pyx_v_extensions = Py_None;
  __pyx_v_regexp = __pyx_k_169;
  __pyx_v_smart_strings = __pyx_k_170;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree = ((struct LxmlElementTree *)values[0]);
    if (values[1]) {
      __pyx_v_namespaces = values[1];
    }
    if (values[2]) {
      __pyx_v_extensions = values[2];
    }
    if (values[3]) {
      __pyx_v_regexp = values[3];
    }
    if (values[4]) {
      __pyx_v_smart_strings = values[4];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree = ((struct LxmlElementTree *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XPathDocumentEvaluator.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_etree), __pyx_ptype_4lxml_5etree__ElementTree, 0, "etree", 0))) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":304
 *     def __init__(self, _ElementTree etree not None, *, namespaces=None,
 *                  extensions=None, regexp=True, smart_strings=True):
 *         XPathElementEvaluator.__init__(             # <<<<<<<<<<<<<<
 *             self, etree._context_node, namespaces=namespaces,
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPathElementEvaluator)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":305
 *                  extensions=None, regexp=True, smart_strings=True):
 *         XPathElementEvaluator.__init__(
 *             self, etree._context_node, namespaces=namespaces,             # <<<<<<<<<<<<<<
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)
 * 
 */
  __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(((PyObject *)__pyx_v_etree->_context_node));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_etree->_context_node));
  __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_3, __pyx_kp_namespaces, __pyx_v_namespaces) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":306
 *         XPathElementEvaluator.__init__(
 *             self, etree._context_node, namespaces=namespaces,
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, _path, **_variables):
 */
  if (PyDict_SetItem(__pyx_3, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_3, __pyx_kp_regexp, __pyx_v_regexp) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_3, __pyx_kp_smart_strings, __pyx_v_smart_strings) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.XPathDocumentEvaluator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":308
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)
 * 
 *     def __call__(self, _path, **_variables):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, _path, **_variables)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_22XPathDocumentEvaluator___call__[] = "__call__(self, _path, **_variables)\n\n        Evaluate an XPath expression on the document.\n\n        Variables may be provided as keyword arguments.  Note that namespaces\n        are currently not supported for variables.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__path = 0;
  PyObject *__pyx_v__variables = 0;
  xmlXPathObject *__pyx_v_xpathObj;
  xmlDoc *__pyx_v_c_doc;
  struct LxmlDocument *__pyx_v_doc;
  char *__pyx_v_c_path;
  PyObject *__pyx_v_path;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  xmlDoc *__pyx_3;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__path,0};
  __pyx_v__variables = PyDict_New(); if (unlikely(!__pyx_v__variables)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__variables, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__path = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__path = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__variables);
  __Pyx_AddTraceback("lxml.etree.XPathDocumentEvaluator.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_path = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":320
 *         cdef _Document doc
 *         cdef char* c_path
 *         path = _utf8(_path)             # <<<<<<<<<<<<<<
 *         doc = self._element._doc
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v__path); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_path);
  __pyx_v_path = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":321
 *         cdef char* c_path
 *         path = _utf8(_path)
 *         doc = self._element._doc             # <<<<<<<<<<<<<<
 * 
 *         self._lock()
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base._element->_doc));
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base._element->_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":323
 *         doc = self._element._doc
 * 
 *         self._lock()             # <<<<<<<<<<<<<<
 *         self._error_log.connect()
 *         try:
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XPathDocumentEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._lock(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":324
 * 
 *         self._lock()
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         try:
 *             self._context.register_context(doc)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":325
 *         self._lock()
 *         self._error_log.connect()
 *         try:             # <<<<<<<<<<<<<<
 *             self._context.register_context(doc)
 *             c_doc = _fakeRootDoc(doc._c_doc, self._element._c_node)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":326
 *         self._error_log.connect()
 *         try:
 *             self._context.register_context(doc)             # <<<<<<<<<<<<<<
 *             c_doc = _fakeRootDoc(doc._c_doc, self._element._c_node)
 *             try:
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._context->__pyx_base.__pyx_vtab)->register_context(((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._context, __pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":327
 *         try:
 *             self._context.register_context(doc)
 *             c_doc = _fakeRootDoc(doc._c_doc, self._element._c_node)             # <<<<<<<<<<<<<<
 *             try:
 *                 self._context.registerVariables(_variables)
 */
    __pyx_3 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, ((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base._element->_c_node); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L7;}
    __pyx_v_c_doc = __pyx_3;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":328
 *             self._context.register_context(doc)
 *             c_doc = _fakeRootDoc(doc._c_doc, self._element._c_node)
 *             try:             # <<<<<<<<<<<<<<
 *                 self._context.registerVariables(_variables)
 *                 c_path = _cstr(path)
 */
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":329
 *             c_doc = _fakeRootDoc(doc._c_doc, self._element._c_node)
 *             try:
 *                 self._context.registerVariables(_variables)             # <<<<<<<<<<<<<<
 *                 c_path = _cstr(path)
 *                 with nogil:
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._context->__pyx_base.__pyx_vtab)->registerVariables(((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._context, __pyx_v__variables); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L10;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":330
 *             try:
 *                 self._context.registerVariables(_variables)
 *                 c_path = _cstr(path)             # <<<<<<<<<<<<<<
 *                 with nogil:
 *                     self._xpathCtxt.doc  = c_doc
 */
      __pyx_v_c_path = PyString_AS_STRING(__pyx_v_path);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":331
 *                 self._context.registerVariables(_variables)
 *                 c_path = _cstr(path)
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._xpathCtxt.doc  = c_doc
 *                     self._xpathCtxt.node = tree.xmlDocGetRootElement(c_doc)
 */
      /*with nogil:*/ {
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":332
 *                 c_path = _cstr(path)
 *                 with nogil:
 *                     self._xpathCtxt.doc  = c_doc             # <<<<<<<<<<<<<<
 *                     self._xpathCtxt.node = tree.xmlDocGetRootElement(c_doc)
 *                     xpathObj = xpath.xmlXPathEvalExpression(
 */
          ((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._xpathCtxt->doc = __pyx_v_c_doc;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":333
 *                 with nogil:
 *                     self._xpathCtxt.doc  = c_doc
 *                     self._xpathCtxt.node = tree.xmlDocGetRootElement(c_doc)             # <<<<<<<<<<<<<<
 *                     xpathObj = xpath.xmlXPathEvalExpression(
 *                         c_path, self._xpathCtxt)
 */
          ((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._xpathCtxt->node = xmlDocGetRootElement(__pyx_v_c_doc);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":335
 *                     self._xpathCtxt.node = tree.xmlDocGetRootElement(c_doc)
 *                     xpathObj = xpath.xmlXPathEvalExpression(
 *                         c_path, self._xpathCtxt)             # <<<<<<<<<<<<<<
 *                 result = self._handle_result(xpathObj, doc)
 *             finally:
 */
          __pyx_v_xpathObj = xmlXPathEvalExpression(__pyx_v_c_path, ((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._xpathCtxt);
        }
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":336
 *                     xpathObj = xpath.xmlXPathEvalExpression(
 *                         c_path, self._xpathCtxt)
 *                 result = self._handle_result(xpathObj, doc)             # <<<<<<<<<<<<<<
 *             finally:
 *                 _destroyFakeDoc(doc._c_doc, c_doc)
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_XPathDocumentEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._handle_result(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self), __pyx_v_xpathObj, __pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L10;}
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_1;
      __pyx_1 = 0;
    }
    /*finally:*/ {
      int __pyx_why;
      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
      int __pyx_exc_lineno;
      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
      __pyx_why = 0; goto __pyx_L11;
      __pyx_L10: {
        __pyx_why = 4;
        Py_XDECREF(__pyx_1); __pyx_1 = 0;
        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
        __pyx_exc_lineno = __pyx_lineno;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":338
 *                 result = self._handle_result(xpathObj, doc)
 *             finally:
 *                 _destroyFakeDoc(doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 *                 self._context.unregister_context()
 *         finally:
 */
      __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_c_doc);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":339
 *             finally:
 *                 _destroyFakeDoc(doc._c_doc, c_doc)
 *                 self._context.unregister_context()             # <<<<<<<<<<<<<<
 *         finally:
 *             self._error_log.disconnect()
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._context->__pyx_base.__pyx_vtab)->unregister_context(((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._context); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L15_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L16;
      __pyx_L15_error:;
      if (__pyx_why == 4) {
        Py_XDECREF(__pyx_exc_type);
        Py_XDECREF(__pyx_exc_value);
        Py_XDECREF(__pyx_exc_tb);
      }
      goto __pyx_L7;
      __pyx_L16:;
      switch (__pyx_why) {
        case 4: {
          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
          __pyx_lineno = __pyx_exc_lineno;
          __pyx_exc_type = 0;
          __pyx_exc_value = 0;
          __pyx_exc_tb = 0;
          goto __pyx_L7;
        }
      }
    }
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":341
 *                 self._context.unregister_context()
 *         finally:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             self._unlock()
 * 
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":342
 *         finally:
 *             self._error_log.disconnect()
 *             self._unlock()             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    ((struct __pyx_vtabstruct_4lxml_5etree_XPathDocumentEvaluator *)((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._unlock(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self));
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":344
 *             self._unlock()
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XPathDocumentEvaluator.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__variables);
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_path);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":347
 * 
 * 
 * def XPathEvaluator(etree_or_element, *, namespaces=None, extensions=None,             # <<<<<<<<<<<<<<
 *                    regexp=True, smart_strings=True):
 *     u"""XPathEvaluator(etree_or_element, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 */

static PyObject *__pyx_pf_4lxml_5etree_XPathEvaluator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_XPathEvaluator[] = "XPathEvaluator(etree_or_element, namespaces=None, extensions=None, regexp=True, smart_strings=True)\n\n    Creates an XPath evaluator for an ElementTree or an Element.\n\n    The resulting object can be called with an XPath expression as argument\n    and XPath variables provided as keyword arguments.\n\n    Additional namespace declarations can be passed with the\n    'namespace' keyword argument.  EXSLT regular expression support\n    can be disabled with the 'regexp' boolean keyword (defaults to\n    True).  Smart strings will be returned for string results unless\n    you pass ``smart_strings=False``.\n    ";
static PyObject *__pyx_pf_4lxml_5etree_XPathEvaluator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree_or_element = 0;
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_regexp = 0;
  PyObject *__pyx_v_smart_strings = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree_or_element,&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_regexp,&__pyx_kp_smart_strings,0};
  __pyx_self = __pyx_self;
  __pyx_v_namespaces = Py_None;
  __pyx_v_extensions = Py_None;
  __pyx_v_regexp = __pyx_k_171;
  __pyx_v_smart_strings = __pyx_k_172;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree_or_element);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "XPathEvaluator") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree_or_element = values[0];
    if (values[1]) {
      __pyx_v_namespaces = values[1];
    }
    if (values[2]) {
      __pyx_v_extensions = values[2];
    }
    if (values[3]) {
      __pyx_v_regexp = values[3];
    }
    if (values[4]) {
      __pyx_v_smart_strings = values[4];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree_or_element = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("XPathEvaluator", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XPathEvaluator");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":362
 *     you pass ``smart_strings=False``.
 *     """
 *     if isinstance(etree_or_element, _ElementTree):             # <<<<<<<<<<<<<<
 *         return XPathDocumentEvaluator(
 *             etree_or_element, namespaces=namespaces,
 */
  __pyx_1 = PyObject_TypeCheck(__pyx_v_etree_or_element, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree))); 
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":364
 *     if isinstance(etree_or_element, _ElementTree):
 *         return XPathDocumentEvaluator(
 *             etree_or_element, namespaces=namespaces,             # <<<<<<<<<<<<<<
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)
 *     else:
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_etree_or_element);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_etree_or_element);
    __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_namespaces, __pyx_v_namespaces) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":365
 *         return XPathDocumentEvaluator(
 *             etree_or_element, namespaces=namespaces,
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)             # <<<<<<<<<<<<<<
 *     else:
 *         return XPathElementEvaluator(
 */
    if (PyDict_SetItem(__pyx_3, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_regexp, __pyx_v_regexp) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_smart_strings, __pyx_v_smart_strings) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPathDocumentEvaluator)), ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":368
 *     else:
 *         return XPathElementEvaluator(
 *             etree_or_element, namespaces=namespaces,             # <<<<<<<<<<<<<<
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)
 * 
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_etree_or_element);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_etree_or_element);
    __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_namespaces, __pyx_v_namespaces) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":369
 *         return XPathElementEvaluator(
 *             etree_or_element, namespaces=namespaces,
 *             extensions=extensions, regexp=regexp, smart_strings=smart_strings)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    if (PyDict_SetItem(__pyx_3, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_regexp, __pyx_v_regexp) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_smart_strings, __pyx_v_smart_strings) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPathElementEvaluator)), ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.XPathEvaluator");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":387
 *     cdef readonly object path
 * 
 *     def __init__(self, path, *, namespaces=None, extensions=None,             # <<<<<<<<<<<<<<
 *                  regexp=True, smart_strings=True):
 *         cdef xpath.xmlXPathContext* xpathCtxt
 */

static int __pyx_pf_4lxml_5etree_5XPath___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_5XPath___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path = 0;
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_regexp = 0;
  PyObject *__pyx_v_smart_strings = 0;
  xmlXPathContext *__pyx_v_xpathCtxt;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_path,&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_regexp,&__pyx_kp_smart_strings,0};
  __pyx_v_namespaces = Py_None;
  __pyx_v_extensions = Py_None;
  __pyx_v_regexp = __pyx_k_173;
  __pyx_v_smart_strings = __pyx_k_174;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_path = values[0];
    if (values[1]) {
      __pyx_v_namespaces = values[1];
    }
    if (values[2]) {
      __pyx_v_extensions = values[2];
    }
    if (values[3]) {
      __pyx_v_regexp = values[3];
    }
    if (values[4]) {
      __pyx_v_smart_strings = values[4];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_path = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XPath.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_path);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":390
 *                  regexp=True, smart_strings=True):
 *         cdef xpath.xmlXPathContext* xpathCtxt
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,             # <<<<<<<<<<<<<<
 *                                      regexp, smart_strings)
 *         self.path = path
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XPathEvaluatorBase)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":391
 *         cdef xpath.xmlXPathContext* xpathCtxt
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 *                                      regexp, smart_strings)             # <<<<<<<<<<<<<<
 *         self.path = path
 *         path = _utf8(path)
 */
  __pyx_2 = PyTuple_New(5); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_namespaces);
  Py_INCREF(__pyx_v_extensions);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_extensions);
  Py_INCREF(__pyx_v_regexp);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_regexp);
  Py_INCREF(__pyx_v_smart_strings);
  PyTuple_SET_ITEM(__pyx_2, 4, __pyx_v_smart_strings);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":392
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 *                                      regexp, smart_strings)
 *         self.path = path             # <<<<<<<<<<<<<<
 *         path = _utf8(path)
 *         xpathCtxt = xpath.xmlXPathNewContext(NULL)
 */
  Py_INCREF(__pyx_v_path);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->path);
  ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->path = __pyx_v_path;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":393
 *                                      regexp, smart_strings)
 *         self.path = path
 *         path = _utf8(path)             # <<<<<<<<<<<<<<
 *         xpathCtxt = xpath.xmlXPathNewContext(NULL)
 *         if xpathCtxt is NULL:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_path); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_path);
  __pyx_v_path = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":394
 *         self.path = path
 *         path = _utf8(path)
 *         xpathCtxt = xpath.xmlXPathNewContext(NULL)             # <<<<<<<<<<<<<<
 *         if xpathCtxt is NULL:
 *             python.PyErr_NoMemory()
 */
  __pyx_v_xpathCtxt = xmlXPathNewContext(NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":395
 *         path = _utf8(path)
 *         xpathCtxt = xpath.xmlXPathNewContext(NULL)
 *         if xpathCtxt is NULL:             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 *         self.set_context(xpathCtxt)
 */
  __pyx_4 = (__pyx_v_xpathCtxt == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":396
 *         xpathCtxt = xpath.xmlXPathNewContext(NULL)
 *         if xpathCtxt is NULL:
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         self.set_context(xpathCtxt)
 *         self._error_log.connect()
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":397
 *         if xpathCtxt is NULL:
 *             python.PyErr_NoMemory()
 *         self.set_context(xpathCtxt)             # <<<<<<<<<<<<<<
 *         self._error_log.connect()
 *         self._xpath = xpath.xmlXPathCtxtCompile(xpathCtxt, _cstr(path))
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree_XPath *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.set_context(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self), __pyx_v_xpathCtxt); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":398
 *             python.PyErr_NoMemory()
 *         self.set_context(xpathCtxt)
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         self._xpath = xpath.xmlXPathCtxtCompile(xpathCtxt, _cstr(path))
 *         self._error_log.disconnect()
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":399
 *         self.set_context(xpathCtxt)
 *         self._error_log.connect()
 *         self._xpath = xpath.xmlXPathCtxtCompile(xpathCtxt, _cstr(path))             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 *         if self._xpath is NULL:
 */
  ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->_xpath = xmlXPathCtxtCompile(__pyx_v_xpathCtxt, PyString_AS_STRING(__pyx_v_path));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":400
 *         self._error_log.connect()
 *         self._xpath = xpath.xmlXPathCtxtCompile(xpathCtxt, _cstr(path))
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *         if self._xpath is NULL:
 *             self._raise_parse_error()
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":401
 *         self._xpath = xpath.xmlXPathCtxtCompile(xpathCtxt, _cstr(path))
 *         self._error_log.disconnect()
 *         if self._xpath is NULL:             # <<<<<<<<<<<<<<
 *             self._raise_parse_error()
 * 
 */
  __pyx_4 = (((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->_xpath == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":402
 *         self._error_log.disconnect()
 *         if self._xpath is NULL:
 *             self._raise_parse_error()             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, _etree_or_element, **_variables):
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_XPath *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._raise_parse_error(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.XPath.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":404
 *             self._raise_parse_error()
 * 
 *     def __call__(self, _etree_or_element, **_variables):             # <<<<<<<<<<<<<<
 *         u"__call__(self, _etree_or_element, **_variables)"
 *         cdef xpath.xmlXPathObject*  xpathObj
 */

static PyObject *__pyx_pf_4lxml_5etree_5XPath___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_5XPath___call__[] = "__call__(self, _etree_or_element, **_variables)";
static PyObject *__pyx_pf_4lxml_5etree_5XPath___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__etree_or_element = 0;
  PyObject *__pyx_v__variables = 0;
  xmlXPathObject *__pyx_v_xpathObj;
  struct LxmlDocument *__pyx_v_document;
  struct LxmlElement *__pyx_v_element;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__etree_or_element,0};
  __pyx_v__variables = PyDict_New(); if (unlikely(!__pyx_v__variables)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__etree_or_element);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v__variables, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__etree_or_element = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__etree_or_element = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v__variables);
  __Pyx_AddTraceback("lxml.etree.XPath.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_document = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":411
 *         cdef _XPathContext context
 * 
 *         document = _documentOrRaise(_etree_or_element)             # <<<<<<<<<<<<<<
 *         element  = _rootNodeOrRaise(_etree_or_element)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v__etree_or_element)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_document));
  __pyx_v_document = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":412
 * 
 *         document = _documentOrRaise(_etree_or_element)
 *         element  = _rootNodeOrRaise(_etree_or_element)             # <<<<<<<<<<<<<<
 * 
 *         self._lock()
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v__etree_or_element)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_element));
  __pyx_v_element = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":414
 *         element  = _rootNodeOrRaise(_etree_or_element)
 * 
 *         self._lock()             # <<<<<<<<<<<<<<
 *         self._error_log.connect()
 *         self._xpathCtxt.doc  = document._c_doc
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XPath *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._lock(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self)); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":415
 * 
 *         self._lock()
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         self._xpathCtxt.doc  = document._c_doc
 *         self._xpathCtxt.node = element._c_node
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":416
 *         self._lock()
 *         self._error_log.connect()
 *         self._xpathCtxt.doc  = document._c_doc             # <<<<<<<<<<<<<<
 *         self._xpathCtxt.node = element._c_node
 * 
 */
  ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._xpathCtxt->doc = __pyx_v_document->_c_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":417
 *         self._error_log.connect()
 *         self._xpathCtxt.doc  = document._c_doc
 *         self._xpathCtxt.node = element._c_node             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._xpathCtxt->node = __pyx_v_element->_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":419
 *         self._xpathCtxt.node = element._c_node
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self._context.register_context(document)
 *             self._context.registerVariables(_variables)
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":420
 * 
 *         try:
 *             self._context.register_context(document)             # <<<<<<<<<<<<<<
 *             self._context.registerVariables(_variables)
 *             with nogil:
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->register_context(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._context, __pyx_v_document); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":421
 *         try:
 *             self._context.register_context(document)
 *             self._context.registerVariables(_variables)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 xpathObj = xpath.xmlXPathCompiledEval(
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->registerVariables(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._context, __pyx_v__variables); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":422
 *             self._context.register_context(document)
 *             self._context.registerVariables(_variables)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 xpathObj = xpath.xmlXPathCompiledEval(
 *                     self._xpath, self._xpathCtxt)
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":424
 *             with nogil:
 *                 xpathObj = xpath.xmlXPathCompiledEval(
 *                     self._xpath, self._xpathCtxt)             # <<<<<<<<<<<<<<
 *             result = self._handle_result(xpathObj, document)
 *         finally:
 */
        __pyx_v_xpathObj = xmlXPathCompiledEval(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->_xpath, ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._xpathCtxt);
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":425
 *                 xpathObj = xpath.xmlXPathCompiledEval(
 *                     self._xpath, self._xpathCtxt)
 *             result = self._handle_result(xpathObj, document)             # <<<<<<<<<<<<<<
 *         finally:
 *             self._error_log.disconnect()
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_XPath *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._handle_result(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self), __pyx_v_xpathObj, __pyx_v_document); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L7;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_1;
    __pyx_1 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":427
 *             result = self._handle_result(xpathObj, document)
 *         finally:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             self._context.unregister_context()
 *             self._unlock()
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":428
 *         finally:
 *             self._error_log.disconnect()
 *             self._context.unregister_context()             # <<<<<<<<<<<<<<
 *             self._unlock()
 *         return result
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XPathContext *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._context->__pyx_base.__pyx_vtab)->unregister_context(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base._context); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":429
 *             self._error_log.disconnect()
 *             self._context.unregister_context()
 *             self._unlock()             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    ((struct __pyx_vtabstruct_4lxml_5etree_XPath *)((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base._unlock(((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)__pyx_v_self));
    goto __pyx_L13;
    __pyx_L12_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L13:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":430
 *             self._context.unregister_context()
 *             self._unlock()
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XPath.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v__variables);
  Py_DECREF(__pyx_v_document);
  Py_DECREF(__pyx_v_element);
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":432
 *         return result
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._xpath is not NULL:
 *             xpath.xmlXPathFreeCompExpr(self._xpath)
 */

static void __pyx_pf_4lxml_5etree_5XPath___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_5XPath___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":433
 * 
 *     def __dealloc__(self):
 *         if self._xpath is not NULL:             # <<<<<<<<<<<<<<
 *             xpath.xmlXPathFreeCompExpr(self._xpath)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->_xpath != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":434
 *     def __dealloc__(self):
 *         if self._xpath is not NULL:
 *             xpath.xmlXPathFreeCompExpr(self._xpath)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    xmlXPathFreeCompExpr(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->_xpath);
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":436
 *             xpath.xmlXPathFreeCompExpr(self._xpath)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.path
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_5XPath___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_5XPath___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":437
 * 
 *     def __repr__(self):
 *         return self.path             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->path);
  __pyx_r = ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_v_self)->path;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":454
 *     you pass ``smart_strings=False``.
 *     """
 *     def __init__(self, path, *, extensions=None, regexp=True, smart_strings=True):             # <<<<<<<<<<<<<<
 *         path, namespaces = self._nsextract_path(path)
 *         XPath.__init__(self, path, namespaces=namespaces,
 */

static int __pyx_pf_4lxml_5etree_7ETXPath___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_7ETXPath___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_regexp = 0;
  PyObject *__pyx_v_smart_strings = 0;
  PyObject *__pyx_v_namespaces;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_path,&__pyx_kp_extensions,&__pyx_kp_regexp,&__pyx_kp_smart_strings,0};
  __pyx_v_extensions = Py_None;
  __pyx_v_regexp = __pyx_k_177;
  __pyx_v_smart_strings = __pyx_k_178;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_path);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_path = values[0];
    if (values[1]) {
      __pyx_v_extensions = values[1];
    }
    if (values[2]) {
      __pyx_v_regexp = values[2];
    }
    if (values[3]) {
      __pyx_v_smart_strings = values[3];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_path = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[16]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.ETXPath.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_path);
  __pyx_v_namespaces = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":455
 *     """
 *     def __init__(self, path, *, extensions=None, regexp=True, smart_strings=True):
 *         path, namespaces = self._nsextract_path(path)             # <<<<<<<<<<<<<<
 *         XPath.__init__(self, path, namespaces=namespaces,
 *                        extensions=extensions, regexp=regexp,
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree_ETXPath *)((struct __pyx_obj_4lxml_5etree_ETXPath *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_nsextract_path(((struct __pyx_obj_4lxml_5etree_ETXPath *)__pyx_v_self), __pyx_v_path); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyTuple_CheckExact(__pyx_1) && PyTuple_GET_SIZE(__pyx_1) == 2) {
    PyObject* tuple = __pyx_1;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 0);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_path);
    __pyx_v_path = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyTuple_GET_ITEM(tuple, 1);
    Py_INCREF(__pyx_3);
    Py_DECREF(__pyx_v_namespaces);
    __pyx_v_namespaces = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  else {
    __pyx_2 = PyObject_GetIter(__pyx_1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_path);
    __pyx_v_path = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_namespaces);
    __pyx_v_namespaces = __pyx_3;
    __pyx_3 = 0;
    if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":456
 *     def __init__(self, path, *, extensions=None, regexp=True, smart_strings=True):
 *         path, namespaces = self._nsextract_path(path)
 *         XPath.__init__(self, path, namespaces=namespaces,             # <<<<<<<<<<<<<<
 *                        extensions=extensions, regexp=regexp,
 *                        smart_strings=smart_strings)
 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPath)), __pyx_kp___init__); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_path);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_namespaces, __pyx_v_namespaces) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":457
 *         path, namespaces = self._nsextract_path(path)
 *         XPath.__init__(self, path, namespaces=namespaces,
 *                        extensions=extensions, regexp=regexp,             # <<<<<<<<<<<<<<
 *                        smart_strings=smart_strings)
 * 
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_extensions, __pyx_v_extensions) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_regexp, __pyx_v_regexp) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":458
 *         XPath.__init__(self, path, namespaces=namespaces,
 *                        extensions=extensions, regexp=regexp,
 *                        smart_strings=smart_strings)             # <<<<<<<<<<<<<<
 * 
 *     cdef _nsextract_path(self, path):
 */
  if (PyDict_SetItem(__pyx_2, __pyx_kp_smart_strings, __pyx_v_smart_strings) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_3, ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.ETXPath.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_namespaces);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":460
 *                        smart_strings=smart_strings)
 * 
 *     cdef _nsextract_path(self, path):             # <<<<<<<<<<<<<<
 *         # replace {namespaces} by new prefixes
 *         cdef int i
 */

static  PyObject *__pyx_f_4lxml_5etree_7ETXPath__nsextract_path(struct __pyx_obj_4lxml_5etree_ETXPath *__pyx_v_self, PyObject *__pyx_v_path) {
  int __pyx_v_i;
  PyObject *__pyx_v_path_utf;
  PyObject *__pyx_v_stripped_path;
  PyObject *__pyx_v_namespaces;
  PyObject *__pyx_v_namespace_defs;
  PyObject *__pyx_v_namespace_def;
  PyObject *__pyx_v_prefix;
  PyObject *__pyx_v_namespace;
  PyObject *__pyx_v_prefix_str;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_t_1 = NULL;
  Py_INCREF(__pyx_v_path);
  __pyx_v_path_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_stripped_path = Py_None; Py_INCREF(Py_None);
  __pyx_v_namespaces = Py_None; Py_INCREF(Py_None);
  __pyx_v_namespace_defs = Py_None; Py_INCREF(Py_None);
  __pyx_v_namespace_def = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix = Py_None; Py_INCREF(Py_None);
  __pyx_v_namespace = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix_str = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":463
 *         # replace {namespaces} by new prefixes
 *         cdef int i
 *         path_utf = _utf8(path)             # <<<<<<<<<<<<<<
 *         stripped_path = _replace_strings('', path_utf) # remove string literals
 *         namespaces = {}
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_path); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_path_utf);
  __pyx_v_path_utf = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":464
 *         cdef int i
 *         path_utf = _utf8(path)
 *         stripped_path = _replace_strings('', path_utf) # remove string literals             # <<<<<<<<<<<<<<
 *         namespaces = {}
 *         namespace_defs = []
 */
  __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_560);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_kp_560);
  Py_INCREF(__pyx_v_path_utf);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_path_utf);
  __pyx_2 = PyObject_Call(__pyx_v_4lxml_5etree__replace_strings, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_v_stripped_path);
  __pyx_v_stripped_path = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":465
 *         path_utf = _utf8(path)
 *         stripped_path = _replace_strings('', path_utf) # remove string literals
 *         namespaces = {}             # <<<<<<<<<<<<<<
 *         namespace_defs = []
 *         i = 1
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_namespaces);
  __pyx_v_namespaces = ((PyObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":466
 *         stripped_path = _replace_strings('', path_utf) # remove string literals
 *         namespaces = {}
 *         namespace_defs = []             # <<<<<<<<<<<<<<
 *         i = 1
 *         for namespace_def in _find_namespaces(stripped_path):
 */
  __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_namespace_defs);
  __pyx_v_namespace_defs = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":467
 *         namespaces = {}
 *         namespace_defs = []
 *         i = 1             # <<<<<<<<<<<<<<
 *         for namespace_def in _find_namespaces(stripped_path):
 *             if namespace_def not in namespace_defs:
 */
  __pyx_v_i = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":468
 *         namespace_defs = []
 *         i = 1
 *         for namespace_def in _find_namespaces(stripped_path):             # <<<<<<<<<<<<<<
 *             if namespace_def not in namespace_defs:
 *                 prefix = python.PyString_FromFormat("__xpp%02d", i)
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_stripped_path);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_stripped_path);
  __pyx_2 = PyObject_Call(__pyx_v_4lxml_5etree__find_namespaces, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  if (PyList_CheckExact(__pyx_2) || PyTuple_CheckExact(__pyx_2)) {
    __pyx_3 = 0; __pyx_1 = __pyx_2; Py_INCREF(__pyx_1);
  } else {
    __pyx_3 = -1; __pyx_1 = PyObject_GetIter(__pyx_2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_1))) {
      if (__pyx_3 >= PyList_GET_SIZE(__pyx_1)) break;
      __pyx_2 = PyList_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_2); __pyx_3++;
    } else if (likely(PyTuple_CheckExact(__pyx_1))) {
      if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_1)) break;
      __pyx_2 = PyTuple_GET_ITEM(__pyx_1, __pyx_3); Py_INCREF(__pyx_2); __pyx_3++;
    } else {
      __pyx_2 = PyIter_Next(__pyx_1);
      if (!__pyx_2) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_namespace_def);
    __pyx_v_namespace_def = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":469
 *         i = 1
 *         for namespace_def in _find_namespaces(stripped_path):
 *             if namespace_def not in namespace_defs:             # <<<<<<<<<<<<<<
 *                 prefix = python.PyString_FromFormat("__xpp%02d", i)
 *                 i += 1
 */
    __pyx_4 = (!PySequence_Contains(__pyx_v_namespace_defs, __pyx_v_namespace_def)); if (unlikely(__pyx_4 < 0)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":470
 *         for namespace_def in _find_namespaces(stripped_path):
 *             if namespace_def not in namespace_defs:
 *                 prefix = python.PyString_FromFormat("__xpp%02d", i)             # <<<<<<<<<<<<<<
 *                 i += 1
 *                 python.PyList_Append(namespace_defs, namespace_def)
 */
      __pyx_2 = PyString_FromFormat(__pyx_k_561, __pyx_v_i); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":471
 *             if namespace_def not in namespace_defs:
 *                 prefix = python.PyString_FromFormat("__xpp%02d", i)
 *                 i += 1             # <<<<<<<<<<<<<<
 *                 python.PyList_Append(namespace_defs, namespace_def)
 *                 namespace = namespace_def[1:-1] # remove '{}'
 */
      __pyx_v_i += 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":472
 *                 prefix = python.PyString_FromFormat("__xpp%02d", i)
 *                 i += 1
 *                 python.PyList_Append(namespace_defs, namespace_def)             # <<<<<<<<<<<<<<
 *                 namespace = namespace_def[1:-1] # remove '{}'
 *                 namespace = python.PyUnicode_FromEncodedObject(
 */
      __pyx_5 = PyList_Append(__pyx_v_namespace_defs, __pyx_v_namespace_def); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":473
 *                 i += 1
 *                 python.PyList_Append(namespace_defs, namespace_def)
 *                 namespace = namespace_def[1:-1] # remove '{}'             # <<<<<<<<<<<<<<
 *                 namespace = python.PyUnicode_FromEncodedObject(
 *                     namespace, 'UTF-8', 'strict')
 */
      __pyx_2 = PySequence_GetSlice(__pyx_v_namespace_def, 1, -1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_namespace);
      __pyx_v_namespace = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":475
 *                 namespace = namespace_def[1:-1] # remove '{}'
 *                 namespace = python.PyUnicode_FromEncodedObject(
 *                     namespace, 'UTF-8', 'strict')             # <<<<<<<<<<<<<<
 *                 python.PyDict_SetItem(
 *                     namespaces,
 */
      __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_namespace, __pyx_k_562, __pyx_k_563); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_namespace);
      __pyx_v_namespace = __pyx_2;
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":478
 *                 python.PyDict_SetItem(
 *                     namespaces,
 *                     python.PyUnicode_FromEncodedObject(prefix, 'UTF-8', 'strict'),             # <<<<<<<<<<<<<<
 *                     namespace)
 *                 prefix_str = prefix + ':'
 */
      __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_prefix, __pyx_k_564, __pyx_k_565); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":479
 *                     namespaces,
 *                     python.PyUnicode_FromEncodedObject(prefix, 'UTF-8', 'strict'),
 *                     namespace)             # <<<<<<<<<<<<<<
 *                 prefix_str = prefix + ':'
 *                 # FIXME: this also replaces {namespaces} within strings!
 */
      __pyx_5 = PyDict_SetItem(__pyx_v_namespaces, __pyx_2, __pyx_v_namespace); if (unlikely(__pyx_5 == -1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":480
 *                     python.PyUnicode_FromEncodedObject(prefix, 'UTF-8', 'strict'),
 *                     namespace)
 *                 prefix_str = prefix + ':'             # <<<<<<<<<<<<<<
 *                 # FIXME: this also replaces {namespaces} within strings!
 *                 path_utf = path_utf.replace(namespace_def, prefix_str)
 */
      __pyx_t_1 = PyNumber_Add(__pyx_v_prefix, __pyx_kp_566); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_prefix_str);
      __pyx_v_prefix_str = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":482
 *                 prefix_str = prefix + ':'
 *                 # FIXME: this also replaces {namespaces} within strings!
 *                 path_utf = path_utf.replace(namespace_def, prefix_str)             # <<<<<<<<<<<<<<
 *         path = python.PyUnicode_FromEncodedObject(path_utf, 'UTF-8', 'strict')
 *         return path, namespaces
 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_path_utf, __pyx_kp_replace); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_INCREF(__pyx_v_namespace_def);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_namespace_def);
      Py_INCREF(__pyx_v_prefix_str);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_prefix_str);
      __pyx_7 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      Py_DECREF(__pyx_v_path_utf);
      __pyx_v_path_utf = __pyx_7;
      __pyx_7 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":483
 *                 # FIXME: this also replaces {namespaces} within strings!
 *                 path_utf = path_utf.replace(namespace_def, prefix_str)
 *         path = python.PyUnicode_FromEncodedObject(path_utf, 'UTF-8', 'strict')             # <<<<<<<<<<<<<<
 *         return path, namespaces
 */
  __pyx_2 = PyUnicode_FromEncodedObject(__pyx_v_path_utf, __pyx_k_567, __pyx_k_568); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_path);
  __pyx_v_path = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":484
 *                 path_utf = path_utf.replace(namespace_def, prefix_str)
 *         path = python.PyUnicode_FromEncodedObject(path_utf, 'UTF-8', 'strict')
 *         return path, namespaces             # <<<<<<<<<<<<<<
 */
  __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_path);
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_path);
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_namespaces);
  __pyx_r = ((PyObject *)__pyx_6);
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree.ETXPath._nsextract_path");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_path_utf);
  Py_DECREF(__pyx_v_stripped_path);
  Py_DECREF(__pyx_v_namespaces);
  Py_DECREF(__pyx_v_namespace_defs);
  Py_DECREF(__pyx_v_namespace_def);
  Py_DECREF(__pyx_v_prefix);
  Py_DECREF(__pyx_v_namespace);
  Py_DECREF(__pyx_v_prefix_str);
  Py_DECREF(__pyx_v_path);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":54
 *     cdef _BaseParser _parser
 * 
 *     cdef _XSLTResolverContext _copy(self):             # <<<<<<<<<<<<<<
 *         cdef _XSLTResolverContext context
 *         context = _XSLTResolverContext()
 */

static  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_f_4lxml_5etree_20_XSLTResolverContext__copy(struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":56
 *     cdef _XSLTResolverContext _copy(self):
 *         cdef _XSLTResolverContext context
 *         context = _XSLTResolverContext()             # <<<<<<<<<<<<<<
 *         _initXSLTResolverContext(context, self._parser)
 *         context._c_style_doc = self._c_style_doc
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XSLTResolverContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__XSLTResolverContext))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":57
 *         cdef _XSLTResolverContext context
 *         context = _XSLTResolverContext()
 *         _initXSLTResolverContext(context, self._parser)             # <<<<<<<<<<<<<<
 *         context._c_style_doc = self._c_style_doc
 *         return context
 */
  __pyx_1 = __pyx_f_4lxml_5etree__initXSLTResolverContext(__pyx_v_context, __pyx_v_self->_parser); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":58
 *         context = _XSLTResolverContext()
 *         _initXSLTResolverContext(context, self._parser)
 *         context._c_style_doc = self._c_style_doc             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  __pyx_v_context->_c_style_doc = __pyx_v_self->_c_style_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":59
 *         _initXSLTResolverContext(context, self._parser)
 *         context._c_style_doc = self._c_style_doc
 *         return context             # <<<<<<<<<<<<<<
 * 
 * cdef _initXSLTResolverContext(_XSLTResolverContext context,
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = __pyx_v_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XSLTResolverContext._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":61
 *         return context
 * 
 * cdef _initXSLTResolverContext(_XSLTResolverContext context,             # <<<<<<<<<<<<<<
 *                               _BaseParser parser):
 *     _initResolverContext(context, parser.resolvers)
 */

static  PyObject *__pyx_f_4lxml_5etree__initXSLTResolverContext(struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_v_context, struct __pyx_obj_4lxml_5etree__BaseParser *__pyx_v_parser) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":63
 * cdef _initXSLTResolverContext(_XSLTResolverContext context,
 *                               _BaseParser parser):
 *     _initResolverContext(context, parser.resolvers)             # <<<<<<<<<<<<<<
 *     context._parser = parser
 *     context._c_style_doc = NULL
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_parser), __pyx_kp_resolvers); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ResolverRegistry))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __pyx_f_4lxml_5etree__initResolverContext(((struct __pyx_obj_4lxml_5etree__ResolverContext *)__pyx_v_context), ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)__pyx_1)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":64
 *                               _BaseParser parser):
 *     _initResolverContext(context, parser.resolvers)
 *     context._parser = parser             # <<<<<<<<<<<<<<
 *     context._c_style_doc = NULL
 * 
 */
  Py_INCREF(((PyObject *)__pyx_v_parser));
  Py_DECREF(((PyObject *)__pyx_v_context->_parser));
  __pyx_v_context->_parser = __pyx_v_parser;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":65
 *     _initResolverContext(context, parser.resolvers)
 *     context._parser = parser
 *     context._c_style_doc = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _xslt_resolve_from_python(char* c_uri, void* c_context,
 */
  __pyx_v_context->_c_style_doc = NULL;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._initXSLTResolverContext");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":67
 *     context._c_style_doc = NULL
 * 
 * cdef xmlDoc* _xslt_resolve_from_python(char* c_uri, void* c_context,             # <<<<<<<<<<<<<<
 *                                        int parse_options, int* error) with gil:
 *     # call the Python document loaders
 */

static  xmlDoc *__pyx_f_4lxml_5etree__xslt_resolve_from_python(char *__pyx_v_c_uri, void *__pyx_v_c_context, int __pyx_v_parse_options, int *__pyx_v_error) {
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *__pyx_v_resolvers;
  struct __pyx_obj_4lxml_5etree__InputDocument *__pyx_v_doc_ref;
  xmlDoc *__pyx_v_c_doc;
  PyObject *__pyx_v_uri;
  xmlDoc *__pyx_r;
  int __pyx_1;
  xmlDoc *__pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  xmlDoc *__pyx_6;
  xmlDoc *__pyx_7;
  xmlDoc *__pyx_8;
  xmlDoc *__pyx_9;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);
  __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_uri = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":75
 *     cdef xmlDoc* c_doc
 * 
 *     error[0] = 0             # <<<<<<<<<<<<<<
 *     context = <_XSLTResolverContext>c_context
 * 
 */
  (__pyx_v_error[0]) = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":76
 * 
 *     error[0] = 0
 *     context = <_XSLTResolverContext>c_context             # <<<<<<<<<<<<<<
 * 
 *     # shortcut if we resolve the stylesheet itself
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_v_c_context)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_v_c_context);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":79
 * 
 *     # shortcut if we resolve the stylesheet itself
 *     c_doc = context._c_style_doc             # <<<<<<<<<<<<<<
 *     if c_doc is not NULL and c_doc.URL is not NULL:
 *         if cstd.strcmp(c_uri, c_doc.URL) == 0:
 */
  __pyx_v_c_doc = __pyx_v_context->_c_style_doc;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":80
 *     # shortcut if we resolve the stylesheet itself
 *     c_doc = context._c_style_doc
 *     if c_doc is not NULL and c_doc.URL is not NULL:             # <<<<<<<<<<<<<<
 *         if cstd.strcmp(c_uri, c_doc.URL) == 0:
 *             return _copyDoc(c_doc, 1)
 */
  __pyx_1 = (__pyx_v_c_doc != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_doc->URL != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":81
 *     c_doc = context._c_style_doc
 *     if c_doc is not NULL and c_doc.URL is not NULL:
 *         if cstd.strcmp(c_uri, c_doc.URL) == 0:             # <<<<<<<<<<<<<<
 *             return _copyDoc(c_doc, 1)
 * 
 */
    __pyx_1 = (strcmp(__pyx_v_c_uri, __pyx_v_c_doc->URL) == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":82
 *     if c_doc is not NULL and c_doc.URL is not NULL:
 *         if cstd.strcmp(c_uri, c_doc.URL) == 0:
 *             return _copyDoc(c_doc, 1)             # <<<<<<<<<<<<<<
 * 
 *     # delegate to the Python resolvers
 */
      __pyx_2 = __pyx_f_4lxml_5etree__copyDoc(__pyx_v_c_doc, 1); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = __pyx_2;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":85
 * 
 *     # delegate to the Python resolvers
 *     try:             # <<<<<<<<<<<<<<
 *         resolvers = context._resolvers
 *         if cstd.strncmp('string://', c_uri, 9) == 0:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":86
 *     # delegate to the Python resolvers
 *     try:
 *         resolvers = context._resolvers             # <<<<<<<<<<<<<<
 *         if cstd.strncmp('string://', c_uri, 9) == 0:
 *             uri = _decodeFilename(c_uri + 9)
 */
      Py_INCREF(((PyObject *)__pyx_v_context->__pyx_base._resolvers));
      Py_DECREF(((PyObject *)__pyx_v_resolvers));
      __pyx_v_resolvers = __pyx_v_context->__pyx_base._resolvers;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":87
 *     try:
 *         resolvers = context._resolvers
 *         if cstd.strncmp('string://', c_uri, 9) == 0:             # <<<<<<<<<<<<<<
 *             uri = _decodeFilename(c_uri + 9)
 *             if cstd.strncmp('string://', context._c_style_doc.URL, 9) != 0 and \
 */
      __pyx_1 = (strncmp(__pyx_k_569, __pyx_v_c_uri, 9) == 0);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":88
 *         resolvers = context._resolvers
 *         if cstd.strncmp('string://', c_uri, 9) == 0:
 *             uri = _decodeFilename(c_uri + 9)             # <<<<<<<<<<<<<<
 *             if cstd.strncmp('string://', context._c_style_doc.URL, 9) != 0 and \
 *                     cstd.strcmp('<string>', context._c_style_doc.URL) != 0:
 */
        __pyx_3 = __pyx_f_4lxml_5etree__decodeFilename((__pyx_v_c_uri + 9)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_uri);
        __pyx_v_uri = __pyx_3;
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":89
 *         if cstd.strncmp('string://', c_uri, 9) == 0:
 *             uri = _decodeFilename(c_uri + 9)
 *             if cstd.strncmp('string://', context._c_style_doc.URL, 9) != 0 and \             # <<<<<<<<<<<<<<
 *                     cstd.strcmp('<string>', context._c_style_doc.URL) != 0:
 *                 # stylesheet URL known => make the target URL absolute
 */
        __pyx_1 = (strncmp(__pyx_k_570, __pyx_v_context->_c_style_doc->URL, 9) != 0);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":90
 *             uri = _decodeFilename(c_uri + 9)
 *             if cstd.strncmp('string://', context._c_style_doc.URL, 9) != 0 and \
 *                     cstd.strcmp('<string>', context._c_style_doc.URL) != 0:             # <<<<<<<<<<<<<<
 *                 # stylesheet URL known => make the target URL absolute
 *                 uri = os_path_join(_decodeFilename(context._c_style_doc.URL), uri)
 */
          __pyx_1 = (strcmp(__pyx_k_571, __pyx_v_context->_c_style_doc->URL) != 0);
        }
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":92
 *                     cstd.strcmp('<string>', context._c_style_doc.URL) != 0:
 *                 # stylesheet URL known => make the target URL absolute
 *                 uri = os_path_join(_decodeFilename(context._c_style_doc.URL), uri)             # <<<<<<<<<<<<<<
 *         else:
 *             uri = _decodeFilename(c_uri)
 */
          __pyx_3 = __pyx_f_4lxml_5etree__decodeFilename(__pyx_v_context->_c_style_doc->URL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
          Py_INCREF(__pyx_v_uri);
          PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_uri);
          __pyx_3 = 0;
          __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree_os_path_join, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
          Py_DECREF(__pyx_v_uri);
          __pyx_v_uri = __pyx_3;
          __pyx_3 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":94
 *                 uri = os_path_join(_decodeFilename(context._c_style_doc.URL), uri)
 *         else:
 *             uri = _decodeFilename(c_uri)             # <<<<<<<<<<<<<<
 *         doc_ref = resolvers.resolve(uri, None, context)
 * 
 */
        __pyx_4 = __pyx_f_4lxml_5etree__decodeFilename(__pyx_v_c_uri); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_uri);
        __pyx_v_uri = __pyx_4;
        __pyx_4 = 0;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":95
 *         else:
 *             uri = _decodeFilename(c_uri)
 *         doc_ref = resolvers.resolve(uri, None, context)             # <<<<<<<<<<<<<<
 * 
 *         c_doc = NULL
 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_resolvers), __pyx_kp_resolve); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_INCREF(__pyx_v_uri);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_uri);
      Py_INCREF(Py_None);
      PyTuple_SET_ITEM(__pyx_4, 1, Py_None);
      Py_INCREF(((PyObject *)__pyx_v_context));
      PyTuple_SET_ITEM(__pyx_4, 2, ((PyObject *)__pyx_v_context));
      __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
      if (!(__Pyx_TypeTest(__pyx_5, __pyx_ptype_4lxml_5etree__InputDocument))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc_ref));
      __pyx_v_doc_ref = ((struct __pyx_obj_4lxml_5etree__InputDocument *)__pyx_5);
      __pyx_5 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":97
 *         doc_ref = resolvers.resolve(uri, None, context)
 * 
 *         c_doc = NULL             # <<<<<<<<<<<<<<
 *         if doc_ref is not None:
 *             if doc_ref._type == PARSER_DATA_STRING:
 */
      __pyx_v_c_doc = NULL;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":98
 * 
 *         c_doc = NULL
 *         if doc_ref is not None:             # <<<<<<<<<<<<<<
 *             if doc_ref._type == PARSER_DATA_STRING:
 *                 c_doc = _parseDoc(
 */
      __pyx_1 = (((PyObject *)__pyx_v_doc_ref) != Py_None);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":99
 *         c_doc = NULL
 *         if doc_ref is not None:
 *             if doc_ref._type == PARSER_DATA_STRING:             # <<<<<<<<<<<<<<
 *                 c_doc = _parseDoc(
 *                     doc_ref._data_bytes, doc_ref._filename, context._parser)
 */
        __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_STRING);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":101
 *             if doc_ref._type == PARSER_DATA_STRING:
 *                 c_doc = _parseDoc(
 *                     doc_ref._data_bytes, doc_ref._filename, context._parser)             # <<<<<<<<<<<<<<
 *             elif doc_ref._type == PARSER_DATA_FILENAME:
 *                 c_doc = _parseDocFromFile(doc_ref._filename, context._parser)
 */
          __pyx_6 = __pyx_f_4lxml_5etree__parseDoc(__pyx_v_doc_ref->_data_bytes, __pyx_v_doc_ref->_filename, __pyx_v_context->_parser); if (unlikely(__pyx_6 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_v_c_doc = __pyx_6;
          goto __pyx_L13;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":102
 *                 c_doc = _parseDoc(
 *                     doc_ref._data_bytes, doc_ref._filename, context._parser)
 *             elif doc_ref._type == PARSER_DATA_FILENAME:             # <<<<<<<<<<<<<<
 *                 c_doc = _parseDocFromFile(doc_ref._filename, context._parser)
 *             elif doc_ref._type == PARSER_DATA_FILE:
 */
        __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_FILENAME);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":103
 *                     doc_ref._data_bytes, doc_ref._filename, context._parser)
 *             elif doc_ref._type == PARSER_DATA_FILENAME:
 *                 c_doc = _parseDocFromFile(doc_ref._filename, context._parser)             # <<<<<<<<<<<<<<
 *             elif doc_ref._type == PARSER_DATA_FILE:
 *                 c_doc = _parseDocFromFilelike(
 */
          __pyx_7 = __pyx_f_4lxml_5etree__parseDocFromFile(__pyx_v_doc_ref->_filename, __pyx_v_context->_parser); if (unlikely(__pyx_7 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_v_c_doc = __pyx_7;
          goto __pyx_L13;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":104
 *             elif doc_ref._type == PARSER_DATA_FILENAME:
 *                 c_doc = _parseDocFromFile(doc_ref._filename, context._parser)
 *             elif doc_ref._type == PARSER_DATA_FILE:             # <<<<<<<<<<<<<<
 *                 c_doc = _parseDocFromFilelike(
 *                     doc_ref._file, doc_ref._filename, context._parser)
 */
        __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_FILE);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":106
 *             elif doc_ref._type == PARSER_DATA_FILE:
 *                 c_doc = _parseDocFromFilelike(
 *                     doc_ref._file, doc_ref._filename, context._parser)             # <<<<<<<<<<<<<<
 *             elif doc_ref._type == PARSER_DATA_EMPTY:
 *                 c_doc = _newXMLDoc()
 */
          __pyx_8 = __pyx_f_4lxml_5etree__parseDocFromFilelike(__pyx_v_doc_ref->_file, __pyx_v_doc_ref->_filename, __pyx_v_context->_parser); if (unlikely(__pyx_8 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_v_c_doc = __pyx_8;
          goto __pyx_L13;
        }

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":107
 *                 c_doc = _parseDocFromFilelike(
 *                     doc_ref._file, doc_ref._filename, context._parser)
 *             elif doc_ref._type == PARSER_DATA_EMPTY:             # <<<<<<<<<<<<<<
 *                 c_doc = _newXMLDoc()
 *             if c_doc is not NULL and c_doc.URL is NULL:
 */
        __pyx_1 = (__pyx_v_doc_ref->_type == __pyx_e_4lxml_5etree_PARSER_DATA_EMPTY);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":108
 *                     doc_ref._file, doc_ref._filename, context._parser)
 *             elif doc_ref._type == PARSER_DATA_EMPTY:
 *                 c_doc = _newXMLDoc()             # <<<<<<<<<<<<<<
 *             if c_doc is not NULL and c_doc.URL is NULL:
 *                 c_doc.URL = tree.xmlStrdup(c_uri)
 */
          __pyx_9 = __pyx_f_4lxml_5etree__newXMLDoc(); if (unlikely(__pyx_9 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __pyx_v_c_doc = __pyx_9;
          goto __pyx_L13;
        }
        __pyx_L13:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":109
 *             elif doc_ref._type == PARSER_DATA_EMPTY:
 *                 c_doc = _newXMLDoc()
 *             if c_doc is not NULL and c_doc.URL is NULL:             # <<<<<<<<<<<<<<
 *                 c_doc.URL = tree.xmlStrdup(c_uri)
 *         return c_doc
 */
        __pyx_1 = (__pyx_v_c_doc != NULL);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_c_doc->URL == NULL);
        }
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":110
 *                 c_doc = _newXMLDoc()
 *             if c_doc is not NULL and c_doc.URL is NULL:
 *                 c_doc.URL = tree.xmlStrdup(c_uri)             # <<<<<<<<<<<<<<
 *         return c_doc
 *     except:
 */
          __pyx_v_c_doc->URL = xmlStrdup(__pyx_v_c_uri);
          goto __pyx_L14;
        }
        __pyx_L14:;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":111
 *             if c_doc is not NULL and c_doc.URL is NULL:
 *                 c_doc.URL = tree.xmlStrdup(c_uri)
 *         return c_doc             # <<<<<<<<<<<<<<
 *     except:
 *         context._store_raised()
 */
      __pyx_r = __pyx_v_c_doc;
      goto __pyx_L0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":112
 *                 c_doc.URL = tree.xmlStrdup(c_uri)
 *         return c_doc
 *     except:             # <<<<<<<<<<<<<<
 *         context._store_raised()
 *         error[0] = 1
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._xslt_resolve_from_python");
      if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":113
 *         return c_doc
 *     except:
 *         context._store_raised()             # <<<<<<<<<<<<<<
 *         error[0] = 1
 *         return NULL
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)__pyx_v_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._store_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_context));

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":114
 *     except:
 *         context._store_raised()
 *         error[0] = 1             # <<<<<<<<<<<<<<
 *         return NULL
 * 
 */
      (__pyx_v_error[0]) = 1;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":115
 *         context._store_raised()
 *         error[0] = 1
 *         return NULL             # <<<<<<<<<<<<<<
 * 
 * cdef void _xslt_store_resolver_exception(char* c_uri, void* context,
 */
      __pyx_r = NULL;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L8_except_return;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L8_except_return:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L0;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("lxml.etree._xslt_resolve_from_python");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_resolvers);
  Py_DECREF(__pyx_v_doc_ref);
  Py_DECREF(__pyx_v_uri);
  PyGILState_Release(_save);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":117
 *         return NULL
 * 
 * cdef void _xslt_store_resolver_exception(char* c_uri, void* context,             # <<<<<<<<<<<<<<
 *                                          xslt.xsltLoadType c_type) with gil:
 *     try:
 */

static  void __pyx_f_4lxml_5etree__xslt_store_resolver_exception(char *__pyx_v_c_uri, void *__pyx_v_context, xsltLoadType __pyx_v_c_type) {
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_exception;
  PyObject *__pyx_v_e;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_t_1 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_message = Py_None; Py_INCREF(Py_None);
  __pyx_v_exception = Py_None; Py_INCREF(Py_None);
  __pyx_v_e = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":119
 * cdef void _xslt_store_resolver_exception(char* c_uri, void* context,
 *                                          xslt.xsltLoadType c_type) with gil:
 *     try:             # <<<<<<<<<<<<<<
 *         message = u"Cannot resolve URI %s" % _decodeFilename(c_uri)
 *         if c_type == xslt.XSLT_LOAD_DOCUMENT:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":120
 *                                          xslt.xsltLoadType c_type) with gil:
 *     try:
 *         message = u"Cannot resolve URI %s" % _decodeFilename(c_uri)             # <<<<<<<<<<<<<<
 *         if c_type == xslt.XSLT_LOAD_DOCUMENT:
 *             exception = XSLTApplyError(message)
 */
      __pyx_1 = __pyx_f_4lxml_5etree__decodeFilename(__pyx_v_c_uri); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_572), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":121
 *     try:
 *         message = u"Cannot resolve URI %s" % _decodeFilename(c_uri)
 *         if c_type == xslt.XSLT_LOAD_DOCUMENT:             # <<<<<<<<<<<<<<
 *             exception = XSLTApplyError(message)
 *         else:
 */
      __pyx_2 = (__pyx_v_c_type == XSLT_LOAD_DOCUMENT);
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":122
 *         message = u"Cannot resolve URI %s" % _decodeFilename(c_uri)
 *         if c_type == xslt.XSLT_LOAD_DOCUMENT:
 *             exception = XSLTApplyError(message)             # <<<<<<<<<<<<<<
 *         else:
 *             exception = XSLTParseError(message)
 */
        __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTApplyError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        Py_INCREF(__pyx_v_message);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
        __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
        Py_DECREF(__pyx_v_exception);
        __pyx_v_exception = __pyx_4;
        __pyx_4 = 0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":124
 *             exception = XSLTApplyError(message)
 *         else:
 *             exception = XSLTParseError(message)             # <<<<<<<<<<<<<<
 *         (<_XSLTResolverContext>context)._store_exception(exception)
 *     except Exception, e:
 */
        __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTParseError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        Py_INCREF(__pyx_v_message);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_message);
        __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
        Py_DECREF(__pyx_v_exception);
        __pyx_v_exception = __pyx_4;
        __pyx_4 = 0;
      }
      __pyx_L8:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":125
 *         else:
 *             exception = XSLTParseError(message)
 *         (<_XSLTResolverContext>context)._store_exception(exception)             # <<<<<<<<<<<<<<
 *     except Exception, e:
 *         (<_XSLTResolverContext>context)._store_exception(e)
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_v_context)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._store_exception(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_v_context)), __pyx_v_exception);
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L7_try;
    __pyx_L3_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":126
 *             exception = XSLTParseError(message)
 *         (<_XSLTResolverContext>context)._store_exception(exception)
 *     except Exception, e:             # <<<<<<<<<<<<<<
 *         (<_XSLTResolverContext>context)._store_exception(e)
 * 
 */
    __pyx_5 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_5) {
      __Pyx_AddTraceback("lxml.etree._xslt_store_resolver_exception");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      Py_INCREF(__pyx_3);
      Py_DECREF(__pyx_v_e);
      __pyx_v_e = __pyx_3;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":127
 *         (<_XSLTResolverContext>context)._store_exception(exception)
 *     except Exception, e:
 *         (<_XSLTResolverContext>context)._store_exception(e)             # <<<<<<<<<<<<<<
 * 
 * cdef xmlDoc* _xslt_doc_loader(char* c_uri, tree.xmlDict* c_dict,
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_v_context)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._store_exception(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_v_context)), __pyx_v_e);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L7_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("lxml.etree._xslt_store_resolver_exception");
  __pyx_L0:;
  Py_DECREF(__pyx_v_message);
  Py_DECREF(__pyx_v_exception);
  Py_DECREF(__pyx_v_e);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":129
 *         (<_XSLTResolverContext>context)._store_exception(e)
 * 
 * cdef xmlDoc* _xslt_doc_loader(char* c_uri, tree.xmlDict* c_dict,             # <<<<<<<<<<<<<<
 *                               int parse_options, void* c_ctxt,
 *                               xslt.xsltLoadType c_type) nogil:
 */

static  xmlDoc *__pyx_f_4lxml_5etree__xslt_doc_loader(char *__pyx_v_c_uri, xmlDict *__pyx_v_c_dict, int __pyx_v_parse_options, void *__pyx_v_c_ctxt, xsltLoadType __pyx_v_c_type) {
  xmlDoc *__pyx_v_c_doc;
  void *__pyx_v_c_pcontext;
  int __pyx_v_error;
  xmlDoc *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":139
 *     cdef int error
 *     # find resolver contexts of stylesheet and transformed doc
 *     if c_type == xslt.XSLT_LOAD_DOCUMENT:             # <<<<<<<<<<<<<<
 *         # transformation time
 *         c_pcontext = (<xslt.xsltTransformContext*>c_ctxt)._private
 */
  __pyx_1 = (__pyx_v_c_type == XSLT_LOAD_DOCUMENT);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":141
 *     if c_type == xslt.XSLT_LOAD_DOCUMENT:
 *         # transformation time
 *         c_pcontext = (<xslt.xsltTransformContext*>c_ctxt)._private             # <<<<<<<<<<<<<<
 *     elif c_type == xslt.XSLT_LOAD_STYLESHEET:
 *         # include/import resolution while parsing
 */
    __pyx_v_c_pcontext = ((xsltTransformContext *)__pyx_v_c_ctxt)->_private;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":142
 *         # transformation time
 *         c_pcontext = (<xslt.xsltTransformContext*>c_ctxt)._private
 *     elif c_type == xslt.XSLT_LOAD_STYLESHEET:             # <<<<<<<<<<<<<<
 *         # include/import resolution while parsing
 *         c_pcontext = (<xslt.xsltStylesheet*>c_ctxt).doc._private
 */
  __pyx_1 = (__pyx_v_c_type == XSLT_LOAD_STYLESHEET);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":144
 *     elif c_type == xslt.XSLT_LOAD_STYLESHEET:
 *         # include/import resolution while parsing
 *         c_pcontext = (<xslt.xsltStylesheet*>c_ctxt).doc._private             # <<<<<<<<<<<<<<
 *     else:
 *         c_pcontext = NULL
 */
    __pyx_v_c_pcontext = ((xsltStylesheet *)__pyx_v_c_ctxt)->doc->_private;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":146
 *         c_pcontext = (<xslt.xsltStylesheet*>c_ctxt).doc._private
 *     else:
 *         c_pcontext = NULL             # <<<<<<<<<<<<<<
 * 
 *     if c_pcontext is NULL:
 */
    __pyx_v_c_pcontext = NULL;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":148
 *         c_pcontext = NULL
 * 
 *     if c_pcontext is NULL:             # <<<<<<<<<<<<<<
 *         # can't call Python without context, fall back to default loader
 *         return XSLT_DOC_DEFAULT_LOADER(
 */
  __pyx_1 = (__pyx_v_c_pcontext == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":151
 *         # can't call Python without context, fall back to default loader
 *         return XSLT_DOC_DEFAULT_LOADER(
 *             c_uri, c_dict, parse_options, c_ctxt, c_type)             # <<<<<<<<<<<<<<
 * 
 *     c_doc = _xslt_resolve_from_python(c_uri, c_pcontext, parse_options, &error)
 */
    __pyx_r = __pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER(__pyx_v_c_uri, __pyx_v_c_dict, __pyx_v_parse_options, __pyx_v_c_ctxt, __pyx_v_c_type);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":153
 *             c_uri, c_dict, parse_options, c_ctxt, c_type)
 * 
 *     c_doc = _xslt_resolve_from_python(c_uri, c_pcontext, parse_options, &error)             # <<<<<<<<<<<<<<
 *     if c_doc is NULL and not error:
 *         c_doc = XSLT_DOC_DEFAULT_LOADER(
 */
  __pyx_v_c_doc = __pyx_f_4lxml_5etree__xslt_resolve_from_python(__pyx_v_c_uri, __pyx_v_c_pcontext, __pyx_v_parse_options, (&__pyx_v_error));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":154
 * 
 *     c_doc = _xslt_resolve_from_python(c_uri, c_pcontext, parse_options, &error)
 *     if c_doc is NULL and not error:             # <<<<<<<<<<<<<<
 *         c_doc = XSLT_DOC_DEFAULT_LOADER(
 *             c_uri, c_dict, parse_options, c_ctxt, c_type)
 */
  __pyx_1 = (__pyx_v_c_doc == NULL);
  if (__pyx_1) {
    __pyx_1 = (!__pyx_v_error);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":156
 *     if c_doc is NULL and not error:
 *         c_doc = XSLT_DOC_DEFAULT_LOADER(
 *             c_uri, c_dict, parse_options, c_ctxt, c_type)             # <<<<<<<<<<<<<<
 *         if c_doc is NULL:
 *             _xslt_store_resolver_exception(c_uri, c_pcontext, c_type)
 */
    __pyx_v_c_doc = __pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER(__pyx_v_c_uri, __pyx_v_c_dict, __pyx_v_parse_options, __pyx_v_c_ctxt, __pyx_v_c_type);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":157
 *         c_doc = XSLT_DOC_DEFAULT_LOADER(
 *             c_uri, c_dict, parse_options, c_ctxt, c_type)
 *         if c_doc is NULL:             # <<<<<<<<<<<<<<
 *             _xslt_store_resolver_exception(c_uri, c_pcontext, c_type)
 * 
 */
    __pyx_1 = (__pyx_v_c_doc == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":158
 *             c_uri, c_dict, parse_options, c_ctxt, c_type)
 *         if c_doc is NULL:
 *             _xslt_store_resolver_exception(c_uri, c_pcontext, c_type)             # <<<<<<<<<<<<<<
 * 
 *     if c_doc is not NULL and c_type == xslt.XSLT_LOAD_STYLESHEET:
 */
      __pyx_f_4lxml_5etree__xslt_store_resolver_exception(__pyx_v_c_uri, __pyx_v_c_pcontext, __pyx_v_c_type);
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":160
 *             _xslt_store_resolver_exception(c_uri, c_pcontext, c_type)
 * 
 *     if c_doc is not NULL and c_type == xslt.XSLT_LOAD_STYLESHEET:             # <<<<<<<<<<<<<<
 *         c_doc._private = c_pcontext
 *     return c_doc
 */
  __pyx_1 = (__pyx_v_c_doc != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_type == XSLT_LOAD_STYLESHEET);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":161
 * 
 *     if c_doc is not NULL and c_type == xslt.XSLT_LOAD_STYLESHEET:
 *         c_doc._private = c_pcontext             # <<<<<<<<<<<<<<
 *     return c_doc
 * 
 */
    __pyx_v_c_doc->_private = __pyx_v_c_pcontext;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":162
 *     if c_doc is not NULL and c_type == xslt.XSLT_LOAD_STYLESHEET:
 *         c_doc._private = c_pcontext
 *     return c_doc             # <<<<<<<<<<<<<<
 * 
 * cdef xslt.xsltDocLoaderFunc XSLT_DOC_DEFAULT_LOADER
 */
  __pyx_r = __pyx_v_c_doc;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":194
 *     """
 *     cdef xslt.xsltSecurityPrefs* _prefs
 *     def __init__(self, *, read_file=True, write_file=True, create_dir=True,             # <<<<<<<<<<<<<<
 *                  read_network=True, write_network=True):
 *         self._prefs = xslt.xsltNewSecurityPrefs()
 */

static int __pyx_pf_4lxml_5etree_17XSLTAccessControl___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_17XSLTAccessControl___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_read_file = 0;
  PyObject *__pyx_v_write_file = 0;
  PyObject *__pyx_v_create_dir = 0;
  PyObject *__pyx_v_read_network = 0;
  PyObject *__pyx_v_write_network = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_read_file,&__pyx_kp_write_file,&__pyx_kp_create_dir,&__pyx_kp_read_network,&__pyx_kp_write_network,0};
  __pyx_v_read_file = __pyx_k_185;
  __pyx_v_write_file = __pyx_k_186;
  __pyx_v_create_dir = __pyx_k_187;
  __pyx_v_read_network = __pyx_k_188;
  __pyx_v_write_network = __pyx_k_189;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[5] = {0,0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_read_file = values[0];
    }
    if (values[1]) {
      __pyx_v_write_file = values[1];
    }
    if (values[2]) {
      __pyx_v_create_dir = values[2];
    }
    if (values[3]) {
      __pyx_v_read_network = values[3];
    }
    if (values[4]) {
      __pyx_v_write_network = values[4];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
    goto __pyx_L5_argtuple_error;
  } else {
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XSLTAccessControl.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":196
 *     def __init__(self, *, read_file=True, write_file=True, create_dir=True,
 *                  read_network=True, write_network=True):
 *         self._prefs = xslt.xsltNewSecurityPrefs()             # <<<<<<<<<<<<<<
 *         if self._prefs is NULL:
 *             python.PyErr_NoMemory()
 */
  ((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->_prefs = xsltNewSecurityPrefs();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":197
 *                  read_network=True, write_network=True):
 *         self._prefs = xslt.xsltNewSecurityPrefs()
 *         if self._prefs is NULL:             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 *         self._setAccess(xslt.XSLT_SECPREF_READ_FILE, read_file)
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->_prefs == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":198
 *         self._prefs = xslt.xsltNewSecurityPrefs()
 *         if self._prefs is NULL:
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         self._setAccess(xslt.XSLT_SECPREF_READ_FILE, read_file)
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_FILE, write_file)
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":199
 *         if self._prefs is NULL:
 *             python.PyErr_NoMemory()
 *         self._setAccess(xslt.XSLT_SECPREF_READ_FILE, read_file)             # <<<<<<<<<<<<<<
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_FILE, write_file)
 *         self._setAccess(xslt.XSLT_SECPREF_CREATE_DIRECTORY, create_dir)
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_setAccess(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_READ_FILE, __pyx_v_read_file); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":200
 *             python.PyErr_NoMemory()
 *         self._setAccess(xslt.XSLT_SECPREF_READ_FILE, read_file)
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_FILE, write_file)             # <<<<<<<<<<<<<<
 *         self._setAccess(xslt.XSLT_SECPREF_CREATE_DIRECTORY, create_dir)
 *         self._setAccess(xslt.XSLT_SECPREF_READ_NETWORK, read_network)
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_setAccess(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_WRITE_FILE, __pyx_v_write_file); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":201
 *         self._setAccess(xslt.XSLT_SECPREF_READ_FILE, read_file)
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_FILE, write_file)
 *         self._setAccess(xslt.XSLT_SECPREF_CREATE_DIRECTORY, create_dir)             # <<<<<<<<<<<<<<
 *         self._setAccess(xslt.XSLT_SECPREF_READ_NETWORK, read_network)
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_NETWORK, write_network)
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_setAccess(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_CREATE_DIRECTORY, __pyx_v_create_dir); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":202
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_FILE, write_file)
 *         self._setAccess(xslt.XSLT_SECPREF_CREATE_DIRECTORY, create_dir)
 *         self._setAccess(xslt.XSLT_SECPREF_READ_NETWORK, read_network)             # <<<<<<<<<<<<<<
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_NETWORK, write_network)
 * 
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_setAccess(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_READ_NETWORK, __pyx_v_read_network); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":203
 *         self._setAccess(xslt.XSLT_SECPREF_CREATE_DIRECTORY, create_dir)
 *         self._setAccess(xslt.XSLT_SECPREF_READ_NETWORK, read_network)
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_NETWORK, write_network)             # <<<<<<<<<<<<<<
 * 
 *     DENY_ALL = XSLTAccessControl(
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_setAccess(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_WRITE_NETWORK, __pyx_v_write_network); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLTAccessControl.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":213
 *         read_network=True, write_network=False)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._prefs is not NULL:
 *             xslt.xsltFreeSecurityPrefs(self._prefs)
 */

static void __pyx_pf_4lxml_5etree_17XSLTAccessControl___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_17XSLTAccessControl___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":214
 * 
 *     def __dealloc__(self):
 *         if self._prefs is not NULL:             # <<<<<<<<<<<<<<
 *             xslt.xsltFreeSecurityPrefs(self._prefs)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->_prefs != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":215
 *     def __dealloc__(self):
 *         if self._prefs is not NULL:
 *             xslt.xsltFreeSecurityPrefs(self._prefs)             # <<<<<<<<<<<<<<
 * 
 *     cdef _setAccess(self, xslt.xsltSecurityOption option, allow):
 */
    xsltFreeSecurityPrefs(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->_prefs);
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":217
 *             xslt.xsltFreeSecurityPrefs(self._prefs)
 * 
 *     cdef _setAccess(self, xslt.xsltSecurityOption option, allow):             # <<<<<<<<<<<<<<
 *         cdef xslt.xsltSecurityCheck function
 *         if allow:
 */

static  PyObject *__pyx_f_4lxml_5etree_17XSLTAccessControl__setAccess(struct __pyx_obj_4lxml_5etree_XSLTAccessControl *__pyx_v_self, xsltSecurityOption __pyx_v_option, PyObject *__pyx_v_allow) {
  xsltSecurityCheck __pyx_v_function;
  PyObject *__pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":219
 *     cdef _setAccess(self, xslt.xsltSecurityOption option, allow):
 *         cdef xslt.xsltSecurityCheck function
 *         if allow:             # <<<<<<<<<<<<<<
 *             function = xslt.xsltSecurityAllow
 *         else:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_allow); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":220
 *         cdef xslt.xsltSecurityCheck function
 *         if allow:
 *             function = xslt.xsltSecurityAllow             # <<<<<<<<<<<<<<
 *         else:
 *             function = xslt.xsltSecurityForbid
 */
    __pyx_v_function = xsltSecurityAllow;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":222
 *             function = xslt.xsltSecurityAllow
 *         else:
 *             function = xslt.xsltSecurityForbid             # <<<<<<<<<<<<<<
 *         xslt.xsltSetSecurityPrefs(self._prefs, option, function)
 * 
 */
    __pyx_v_function = xsltSecurityForbid;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":223
 *         else:
 *             function = xslt.xsltSecurityForbid
 *         xslt.xsltSetSecurityPrefs(self._prefs, option, function)             # <<<<<<<<<<<<<<
 * 
 *     cdef void _register_in_context(self, xslt.xsltTransformContext* ctxt):
 */
  xsltSetSecurityPrefs(__pyx_v_self->_prefs, __pyx_v_option, __pyx_v_function);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.XSLTAccessControl._setAccess");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":225
 *         xslt.xsltSetSecurityPrefs(self._prefs, option, function)
 * 
 *     cdef void _register_in_context(self, xslt.xsltTransformContext* ctxt):             # <<<<<<<<<<<<<<
 *         xslt.xsltSetCtxtSecurityPrefs(self._prefs, ctxt)
 * 
 */

static  void __pyx_f_4lxml_5etree_17XSLTAccessControl__register_in_context(struct __pyx_obj_4lxml_5etree_XSLTAccessControl *__pyx_v_self, xsltTransformContext *__pyx_v_ctxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":226
 * 
 *     cdef void _register_in_context(self, xslt.xsltTransformContext* ctxt):
 *         xslt.xsltSetCtxtSecurityPrefs(self._prefs, ctxt)             # <<<<<<<<<<<<<<
 * 
 *     property options:
 */
  xsltSetCtxtSecurityPrefs(__pyx_v_self->_prefs, __pyx_v_ctxt);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":230
 *     property options:
 *         u"The access control configuration as a map of options."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return {
 *                 u'read_file': self._optval(xslt.XSLT_SECPREF_READ_FILE),
 */

static PyObject *__pyx_pf_4lxml_5etree_17XSLTAccessControl_7options___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_17XSLTAccessControl_7options___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":231
 *         u"The access control configuration as a map of options."
 *         def __get__(self):
 *             return {             # <<<<<<<<<<<<<<
 *                 u'read_file': self._optval(xslt.XSLT_SECPREF_READ_FILE),
 *                 u'write_file': self._optval(xslt.XSLT_SECPREF_WRITE_FILE),
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":232
 *         def __get__(self):
 *             return {
 *                 u'read_file': self._optval(xslt.XSLT_SECPREF_READ_FILE),             # <<<<<<<<<<<<<<
 *                 u'write_file': self._optval(xslt.XSLT_SECPREF_WRITE_FILE),
 *                 u'create_dir': self._optval(xslt.XSLT_SECPREF_CREATE_DIRECTORY),
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_optval(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_READ_FILE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_1, ((PyObject *)__pyx_kp_573), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":233
 *             return {
 *                 u'read_file': self._optval(xslt.XSLT_SECPREF_READ_FILE),
 *                 u'write_file': self._optval(xslt.XSLT_SECPREF_WRITE_FILE),             # <<<<<<<<<<<<<<
 *                 u'create_dir': self._optval(xslt.XSLT_SECPREF_CREATE_DIRECTORY),
 *                 u'read_network': self._optval(xslt.XSLT_SECPREF_READ_NETWORK),
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_optval(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_WRITE_FILE); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_1, ((PyObject *)__pyx_kp_574), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":234
 *                 u'read_file': self._optval(xslt.XSLT_SECPREF_READ_FILE),
 *                 u'write_file': self._optval(xslt.XSLT_SECPREF_WRITE_FILE),
 *                 u'create_dir': self._optval(xslt.XSLT_SECPREF_CREATE_DIRECTORY),             # <<<<<<<<<<<<<<
 *                 u'read_network': self._optval(xslt.XSLT_SECPREF_READ_NETWORK),
 *                 u'write_network': self._optval(xslt.XSLT_SECPREF_WRITE_NETWORK),
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_optval(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_CREATE_DIRECTORY); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_1, ((PyObject *)__pyx_kp_575), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":235
 *                 u'write_file': self._optval(xslt.XSLT_SECPREF_WRITE_FILE),
 *                 u'create_dir': self._optval(xslt.XSLT_SECPREF_CREATE_DIRECTORY),
 *                 u'read_network': self._optval(xslt.XSLT_SECPREF_READ_NETWORK),             # <<<<<<<<<<<<<<
 *                 u'write_network': self._optval(xslt.XSLT_SECPREF_WRITE_NETWORK),
 *                 }
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_optval(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_READ_NETWORK); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_1, ((PyObject *)__pyx_kp_576), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":236
 *                 u'create_dir': self._optval(xslt.XSLT_SECPREF_CREATE_DIRECTORY),
 *                 u'read_network': self._optval(xslt.XSLT_SECPREF_READ_NETWORK),
 *                 u'write_network': self._optval(xslt.XSLT_SECPREF_WRITE_NETWORK),             # <<<<<<<<<<<<<<
 *                 }
 * 
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self)->__pyx_vtab)->_optval(((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_self), XSLT_SECPREF_WRITE_NETWORK); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_1, ((PyObject *)__pyx_kp_577), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = ((PyObject *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLTAccessControl.options.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":239
 *                 }
 * 
 *     cdef _optval(self, xslt.xsltSecurityOption option):             # <<<<<<<<<<<<<<
 *         cdef xslt.xsltSecurityCheck function
 *         function = xslt.xsltGetSecurityPrefs(self._prefs, option)
 */

static  PyObject *__pyx_f_4lxml_5etree_17XSLTAccessControl__optval(struct __pyx_obj_4lxml_5etree_XSLTAccessControl *__pyx_v_self, xsltSecurityOption __pyx_v_option) {
  xsltSecurityCheck __pyx_v_function;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":241
 *     cdef _optval(self, xslt.xsltSecurityOption option):
 *         cdef xslt.xsltSecurityCheck function
 *         function = xslt.xsltGetSecurityPrefs(self._prefs, option)             # <<<<<<<<<<<<<<
 *         if function is <xslt.xsltSecurityCheck>xslt.xsltSecurityAllow:
 *             return True
 */
  __pyx_v_function = xsltGetSecurityPrefs(__pyx_v_self->_prefs, __pyx_v_option);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":242
 *         cdef xslt.xsltSecurityCheck function
 *         function = xslt.xsltGetSecurityPrefs(self._prefs, option)
 *         if function is <xslt.xsltSecurityCheck>xslt.xsltSecurityAllow:             # <<<<<<<<<<<<<<
 *             return True
 *         elif function is <xslt.xsltSecurityCheck>xslt.xsltSecurityForbid:
 */
  __pyx_1 = (__pyx_v_function == ((int (*)(xsltSecurityPrefs *, xsltTransformContext *, char *))xsltSecurityAllow));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":243
 *         function = xslt.xsltGetSecurityPrefs(self._prefs, option)
 *         if function is <xslt.xsltSecurityCheck>xslt.xsltSecurityAllow:
 *             return True             # <<<<<<<<<<<<<<
 *         elif function is <xslt.xsltSecurityCheck>xslt.xsltSecurityForbid:
 *             return False
 */
    __pyx_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":244
 *         if function is <xslt.xsltSecurityCheck>xslt.xsltSecurityAllow:
 *             return True
 *         elif function is <xslt.xsltSecurityCheck>xslt.xsltSecurityForbid:             # <<<<<<<<<<<<<<
 *             return False
 *         else:
 */
  __pyx_1 = (__pyx_v_function == ((int (*)(xsltSecurityPrefs *, xsltTransformContext *, char *))xsltSecurityForbid));
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":245
 *             return True
 *         elif function is <xslt.xsltSecurityCheck>xslt.xsltSecurityForbid:
 *             return False             # <<<<<<<<<<<<<<
 *         else:
 *             return None
 */
    __pyx_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":247
 *             return False
 *         else:
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLTAccessControl._optval");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":249
 *             return None
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         items = self.options.items()
 *         items.sort()
 */

static PyObject *__pyx_pf_4lxml_5etree_17XSLTAccessControl___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_17XSLTAccessControl___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_items;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  PyObject *__pyx_t_1 = NULL;
  __pyx_v_items = Py_None; Py_INCREF(Py_None);
  __pyx_v_item = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":250
 * 
 *     def __repr__(self):
 *         items = self.options.items()             # <<<<<<<<<<<<<<
 *         items.sort()
 *         return u"%s(%s)" % (
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_options); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_items);
  __pyx_v_items = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":251
 *     def __repr__(self):
 *         items = self.options.items()
 *         items.sort()             # <<<<<<<<<<<<<<
 *         return u"%s(%s)" % (
 *             funicode(python._fqtypename(self)).split(u'.')[-1],
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_items, __pyx_kp_sort); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":253
 *         items.sort()
 *         return u"%s(%s)" % (
 *             funicode(python._fqtypename(self)).split(u'.')[-1],             # <<<<<<<<<<<<<<
 *             u', '.join([u"%s=%r" % item for item in items]))
 * 
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(_fqtypename(__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_kp_split); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_579));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_579));
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_1 = __Pyx_GetItemInt(__pyx_3, -1, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":254
 *         return u"%s(%s)" % (
 *             funicode(python._fqtypename(self)).split(u'.')[-1],
 *             u', '.join([u"%s=%r" % item for item in items]))             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_580), __pyx_kp_join); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyList_CheckExact(__pyx_v_items) || PyTuple_CheckExact(__pyx_v_items)) {
    __pyx_4 = 0; __pyx_5 = __pyx_v_items; Py_INCREF(__pyx_5);
  } else {
    __pyx_4 = -1; __pyx_5 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_5))) {
      if (__pyx_4 >= PyList_GET_SIZE(__pyx_5)) break;
      __pyx_6 = PyList_GET_ITEM(__pyx_5, __pyx_4); Py_INCREF(__pyx_6); __pyx_4++;
    } else if (likely(PyTuple_CheckExact(__pyx_5))) {
      if (__pyx_4 >= PyTuple_GET_SIZE(__pyx_5)) break;
      __pyx_6 = PyTuple_GET_ITEM(__pyx_5, __pyx_4); Py_INCREF(__pyx_6); __pyx_4++;
    } else {
      __pyx_6 = PyIter_Next(__pyx_5);
      if (!__pyx_6) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_6;
    __pyx_6 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_581), __pyx_v_item); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_7 = PyList_Append(__pyx_3, (PyObject*)__pyx_t_1); if (unlikely(__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)__pyx_3));
  __pyx_3 = 0;
  __pyx_5 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_5);
  __pyx_1 = 0;
  __pyx_5 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_578), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("lxml.etree.XSLTAccessControl.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_items);
  Py_DECREF(__pyx_v_item);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":259
 * # XSLT
 * 
 * cdef int _register_xslt_function(void* ctxt, name_utf, ns_utf):             # <<<<<<<<<<<<<<
 *     if ns_utf is None:
 *         return 0
 */

static  int __pyx_f_4lxml_5etree__register_xslt_function(void *__pyx_v_ctxt, PyObject *__pyx_v_name_utf, PyObject *__pyx_v_ns_utf) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":260
 * 
 * cdef int _register_xslt_function(void* ctxt, name_utf, ns_utf):
 *     if ns_utf is None:             # <<<<<<<<<<<<<<
 *         return 0
 *     return xslt.xsltRegisterExtFunction(
 */
  __pyx_1 = (__pyx_v_ns_utf == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":261
 * cdef int _register_xslt_function(void* ctxt, name_utf, ns_utf):
 *     if ns_utf is None:
 *         return 0             # <<<<<<<<<<<<<<
 *     return xslt.xsltRegisterExtFunction(
 *         <xslt.xsltTransformContext*>ctxt, _cstr(name_utf), _cstr(ns_utf),
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":264
 *     return xslt.xsltRegisterExtFunction(
 *         <xslt.xsltTransformContext*>ctxt, _cstr(name_utf), _cstr(ns_utf),
 *         _xpath_function_call)             # <<<<<<<<<<<<<<
 * 
 * cdef int _unregister_xslt_function(void* ctxt, name_utf, ns_utf):
 */
  __pyx_r = xsltRegisterExtFunction(((xsltTransformContext *)__pyx_v_ctxt), PyString_AS_STRING(__pyx_v_name_utf), PyString_AS_STRING(__pyx_v_ns_utf), __pyx_f_4lxml_5etree__xpath_function_call);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":266
 *         _xpath_function_call)
 * 
 * cdef int _unregister_xslt_function(void* ctxt, name_utf, ns_utf):             # <<<<<<<<<<<<<<
 *     if ns_utf is None:
 *         return 0
 */

static  int __pyx_f_4lxml_5etree__unregister_xslt_function(void *__pyx_v_ctxt, PyObject *__pyx_v_name_utf, PyObject *__pyx_v_ns_utf) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":267
 * 
 * cdef int _unregister_xslt_function(void* ctxt, name_utf, ns_utf):
 *     if ns_utf is None:             # <<<<<<<<<<<<<<
 *         return 0
 *     return xslt.xsltRegisterExtFunction(
 */
  __pyx_1 = (__pyx_v_ns_utf == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":268
 * cdef int _unregister_xslt_function(void* ctxt, name_utf, ns_utf):
 *     if ns_utf is None:
 *         return 0             # <<<<<<<<<<<<<<
 *     return xslt.xsltRegisterExtFunction(
 *         <xslt.xsltTransformContext*>ctxt, _cstr(name_utf), _cstr(ns_utf),
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":271
 *     return xslt.xsltRegisterExtFunction(
 *         <xslt.xsltTransformContext*>ctxt, _cstr(name_utf), _cstr(ns_utf),
 *         NULL)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = xsltRegisterExtFunction(((xsltTransformContext *)__pyx_v_ctxt), PyString_AS_STRING(__pyx_v_name_utf), PyString_AS_STRING(__pyx_v_ns_utf), NULL);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":278
 *     cdef object _extension_elements
 *     cdef _ReadOnlyElementProxy _extension_element_proxy
 *     def __init__(self, namespaces, extensions, enable_regexp,             # <<<<<<<<<<<<<<
 *                  build_smart_strings):
 *         self._xsltCtxt = NULL
 */

static int __pyx_pf_4lxml_5etree_12_XSLTContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_12_XSLTContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_namespaces = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_enable_regexp = 0;
  PyObject *__pyx_v_build_smart_strings = 0;
  PyObject *__pyx_v_ns_name_tuple;
  PyObject *__pyx_v_extension;
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_name_utf;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  int __pyx_8;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_namespaces,&__pyx_kp_extensions,&__pyx_kp_enable_regexp,&__pyx_kp_build_smart_strings,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_namespaces);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_extensions);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_enable_regexp);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_build_smart_strings);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_namespaces = values[0];
    __pyx_v_extensions = values[1];
    __pyx_v_enable_regexp = values[2];
    __pyx_v_build_smart_strings = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_namespaces = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_extensions = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_enable_regexp = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_build_smart_strings = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._XSLTContext.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_extensions);
  __pyx_v_ns_name_tuple = Py_None; Py_INCREF(Py_None);
  __pyx_v_extension = Py_None; Py_INCREF(Py_None);
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":280
 *     def __init__(self, namespaces, extensions, enable_regexp,
 *                  build_smart_strings):
 *         self._xsltCtxt = NULL             # <<<<<<<<<<<<<<
 *         self._extension_elements = EMPTY_READ_ONLY_DICT
 *         if extensions is not None and extensions:
 */
  ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_xsltCtxt = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":281
 *                  build_smart_strings):
 *         self._xsltCtxt = NULL
 *         self._extension_elements = EMPTY_READ_ONLY_DICT             # <<<<<<<<<<<<<<
 *         if extensions is not None and extensions:
 *             for ns_name_tuple, extension in extensions.items():
 */
  Py_INCREF(__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
  Py_DECREF(((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_extension_elements);
  ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_extension_elements = __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":282
 *         self._xsltCtxt = NULL
 *         self._extension_elements = EMPTY_READ_ONLY_DICT
 *         if extensions is not None and extensions:             # <<<<<<<<<<<<<<
 *             for ns_name_tuple, extension in extensions.items():
 *                 if ns_name_tuple[0] is None:
 */
  __pyx_1 = (__pyx_v_extensions != Py_None);
  if (__pyx_1) {
    __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_v_extensions); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = __pyx_2;
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":283
 *         self._extension_elements = EMPTY_READ_ONLY_DICT
 *         if extensions is not None and extensions:
 *             for ns_name_tuple, extension in extensions.items():             # <<<<<<<<<<<<<<
 *                 if ns_name_tuple[0] is None:
 *                     raise XSLTExtensionError, \
 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_extensions, __pyx_kp_items); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_5 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (PyList_CheckExact(__pyx_5) || PyTuple_CheckExact(__pyx_5)) {
      __pyx_3 = 0; __pyx_4 = __pyx_5; Py_INCREF(__pyx_4);
    } else {
      __pyx_3 = -1; __pyx_4 = PyObject_GetIter(__pyx_5); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_4))) {
        if (__pyx_3 >= PyList_GET_SIZE(__pyx_4)) break;
        __pyx_5 = PyList_GET_ITEM(__pyx_4, __pyx_3); Py_INCREF(__pyx_5); __pyx_3++;
      } else if (likely(PyTuple_CheckExact(__pyx_4))) {
        if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_4)) break;
        __pyx_5 = PyTuple_GET_ITEM(__pyx_4, __pyx_3); Py_INCREF(__pyx_5); __pyx_3++;
      } else {
        __pyx_5 = PyIter_Next(__pyx_4);
        if (!__pyx_5) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
      }
      if (PyTuple_CheckExact(__pyx_5) && PyTuple_GET_SIZE(__pyx_5) == 2) {
        PyObject* tuple = __pyx_5;
        __pyx_7 = PyTuple_GET_ITEM(tuple, 0);
        Py_INCREF(__pyx_7);
        Py_DECREF(__pyx_v_ns_name_tuple);
        __pyx_v_ns_name_tuple = __pyx_7;
        __pyx_7 = 0;
        __pyx_7 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(__pyx_7);
        Py_DECREF(__pyx_v_extension);
        __pyx_v_extension = __pyx_7;
        __pyx_7 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }
      else {
        __pyx_6 = PyObject_GetIter(__pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_7 = __Pyx_UnpackItem(__pyx_6, 0); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_ns_name_tuple);
        __pyx_v_ns_name_tuple = __pyx_7;
        __pyx_7 = 0;
        __pyx_7 = __Pyx_UnpackItem(__pyx_6, 1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_v_extension);
        __pyx_v_extension = __pyx_7;
        __pyx_7 = 0;
        if (__Pyx_EndUnpack(__pyx_6) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":284
 *         if extensions is not None and extensions:
 *             for ns_name_tuple, extension in extensions.items():
 *                 if ns_name_tuple[0] is None:             # <<<<<<<<<<<<<<
 *                     raise XSLTExtensionError, \
 *                         u"extensions must not have empty namespaces"
 */
      __pyx_7 = __Pyx_GetItemInt(__pyx_v_ns_name_tuple, 0, 0); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_2 = (__pyx_7 == Py_None);
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      if (__pyx_2) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":285
 *             for ns_name_tuple, extension in extensions.items():
 *                 if ns_name_tuple[0] is None:
 *                     raise XSLTExtensionError, \             # <<<<<<<<<<<<<<
 *                         u"extensions must not have empty namespaces"
 *                 if isinstance(extension, XSLTExtension):
 */
        __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTExtensionError); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":286
 *                 if ns_name_tuple[0] is None:
 *                     raise XSLTExtensionError, \
 *                         u"extensions must not have empty namespaces"             # <<<<<<<<<<<<<<
 *                 if isinstance(extension, XSLTExtension):
 *                     if self._extension_elements is EMPTY_READ_ONLY_DICT:
 */
        __Pyx_Raise(__pyx_5, ((PyObject *)__pyx_kp_582), 0);
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        {__pyx_filename = __pyx_f[17]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":287
 *                     raise XSLTExtensionError, \
 *                         u"extensions must not have empty namespaces"
 *                 if isinstance(extension, XSLTExtension):             # <<<<<<<<<<<<<<
 *                     if self._extension_elements is EMPTY_READ_ONLY_DICT:
 *                         self._extension_elements = {}
 */
      __pyx_1 = PyObject_TypeCheck(__pyx_v_extension, ((PyTypeObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XSLTExtension))); 
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":288
 *                         u"extensions must not have empty namespaces"
 *                 if isinstance(extension, XSLTExtension):
 *                     if self._extension_elements is EMPTY_READ_ONLY_DICT:             # <<<<<<<<<<<<<<
 *                         self._extension_elements = {}
 *                         extensions = python.PyDict_Copy(extensions)
 */
        __pyx_2 = (((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_extension_elements == __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
        if (__pyx_2) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":289
 *                 if isinstance(extension, XSLTExtension):
 *                     if self._extension_elements is EMPTY_READ_ONLY_DICT:
 *                         self._extension_elements = {}             # <<<<<<<<<<<<<<
 *                         extensions = python.PyDict_Copy(extensions)
 *                     ns_utf   = _utf8(ns_name_tuple[0])
 */
          __pyx_6 = PyDict_New(); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_extension_elements);
          ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_extension_elements = ((PyObject *)__pyx_6);
          __pyx_6 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":290
 *                     if self._extension_elements is EMPTY_READ_ONLY_DICT:
 *                         self._extension_elements = {}
 *                         extensions = python.PyDict_Copy(extensions)             # <<<<<<<<<<<<<<
 *                     ns_utf   = _utf8(ns_name_tuple[0])
 *                     name_utf = _utf8(ns_name_tuple[1])
 */
          __pyx_7 = PyDict_Copy(__pyx_v_extensions); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          Py_DECREF(__pyx_v_extensions);
          __pyx_v_extensions = __pyx_7;
          __pyx_7 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":291
 *                         self._extension_elements = {}
 *                         extensions = python.PyDict_Copy(extensions)
 *                     ns_utf   = _utf8(ns_name_tuple[0])             # <<<<<<<<<<<<<<
 *                     name_utf = _utf8(ns_name_tuple[1])
 *                     python.PyDict_SetItem(
 */
        __pyx_5 = __Pyx_GetItemInt(__pyx_v_ns_name_tuple, 0, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_6 = __pyx_f_4lxml_5etree__utf8(__pyx_5); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_v_ns_utf);
        __pyx_v_ns_utf = __pyx_6;
        __pyx_6 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":292
 *                         extensions = python.PyDict_Copy(extensions)
 *                     ns_utf   = _utf8(ns_name_tuple[0])
 *                     name_utf = _utf8(ns_name_tuple[1])             # <<<<<<<<<<<<<<
 *                     python.PyDict_SetItem(
 *                         self._extension_elements, (ns_utf, name_utf),
 */
        __pyx_7 = __Pyx_GetItemInt(__pyx_v_ns_name_tuple, 1, 0); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_5 = __pyx_f_4lxml_5etree__utf8(__pyx_7); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(__pyx_v_name_utf);
        __pyx_v_name_utf = __pyx_5;
        __pyx_5 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":294
 *                     name_utf = _utf8(ns_name_tuple[1])
 *                     python.PyDict_SetItem(
 *                         self._extension_elements, (ns_utf, name_utf),             # <<<<<<<<<<<<<<
 *                         extension)
 *                     python.PyDict_DelItem(extensions, ns_name_tuple)
 */
        __pyx_6 = PyTuple_New(2); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_INCREF(__pyx_v_ns_utf);
        PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_ns_utf);
        Py_INCREF(__pyx_v_name_utf);
        PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_name_utf);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":295
 *                     python.PyDict_SetItem(
 *                         self._extension_elements, (ns_utf, name_utf),
 *                         extension)             # <<<<<<<<<<<<<<
 *                     python.PyDict_DelItem(extensions, ns_name_tuple)
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,
 */
        __pyx_8 = PyDict_SetItem(((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_self)->_extension_elements, ((PyObject *)__pyx_6), __pyx_v_extension); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":296
 *                         self._extension_elements, (ns_utf, name_utf),
 *                         extension)
 *                     python.PyDict_DelItem(extensions, ns_name_tuple)             # <<<<<<<<<<<<<<
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,
 *                               build_smart_strings)
 */
        __pyx_8 = PyDict_DelItem(__pyx_v_extensions, __pyx_v_ns_name_tuple); if (unlikely(__pyx_8 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":297
 *                         extension)
 *                     python.PyDict_DelItem(extensions, ns_name_tuple)
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,             # <<<<<<<<<<<<<<
 *                               build_smart_strings)
 * 
 */
  __pyx_7 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__BaseContext)), __pyx_kp___init__); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":298
 *                     python.PyDict_DelItem(extensions, ns_name_tuple)
 *         _BaseContext.__init__(self, namespaces, extensions, enable_regexp,
 *                               build_smart_strings)             # <<<<<<<<<<<<<<
 * 
 *     cdef _BaseContext _copy(self):
 */
  __pyx_5 = PyTuple_New(5); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_namespaces);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_namespaces);
  Py_INCREF(__pyx_v_extensions);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_v_extensions);
  Py_INCREF(__pyx_v_enable_regexp);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_v_enable_regexp);
  Py_INCREF(__pyx_v_build_smart_strings);
  PyTuple_SET_ITEM(__pyx_5, 4, __pyx_v_build_smart_strings);
  __pyx_6 = PyObject_Call(__pyx_7, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree._XSLTContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_name_tuple);
  Py_DECREF(__pyx_v_extension);
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_name_utf);
  Py_DECREF(__pyx_v_extensions);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":300
 *                               build_smart_strings)
 * 
 *     cdef _BaseContext _copy(self):             # <<<<<<<<<<<<<<
 *         cdef _XSLTContext context
 *         context = <_XSLTContext>_BaseContext._copy(self)
 */

static  struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":302
 *     cdef _BaseContext _copy(self):
 *         cdef _XSLTContext context
 *         context = <_XSLTContext>_BaseContext._copy(self)             # <<<<<<<<<<<<<<
 *         context._extension_elements = self._extension_elements
 *         return context
 */
  __pyx_1 = ((PyObject *)__pyx_vtabptr_4lxml_5etree__BaseContext->_copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_1)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":303
 *         cdef _XSLTContext context
 *         context = <_XSLTContext>_BaseContext._copy(self)
 *         context._extension_elements = self._extension_elements             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  Py_INCREF(__pyx_v_self->_extension_elements);
  Py_DECREF(__pyx_v_context->_extension_elements);
  __pyx_v_context->_extension_elements = __pyx_v_self->_extension_elements;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":304
 *         context = <_XSLTContext>_BaseContext._copy(self)
 *         context._extension_elements = self._extension_elements
 *         return context             # <<<<<<<<<<<<<<
 * 
 *     cdef register_context(self, xslt.xsltTransformContext* xsltCtxt,
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_context);
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__BaseContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XSLTContext._copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":306
 *         return context
 * 
 *     cdef register_context(self, xslt.xsltTransformContext* xsltCtxt,             # <<<<<<<<<<<<<<
 *                                _Document doc):
 *         self._xsltCtxt = xsltCtxt
 */

static  PyObject *__pyx_f_4lxml_5etree_12_XSLTContext_register_context(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self, xsltTransformContext *__pyx_v_xsltCtxt, struct LxmlDocument *__pyx_v_doc) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":308
 *     cdef register_context(self, xslt.xsltTransformContext* xsltCtxt,
 *                                _Document doc):
 *         self._xsltCtxt = xsltCtxt             # <<<<<<<<<<<<<<
 *         self._set_xpath_context(xsltCtxt.xpathCtxt)
 *         self._register_context(doc)
 */
  __pyx_v_self->_xsltCtxt = __pyx_v_xsltCtxt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":309
 *                                _Document doc):
 *         self._xsltCtxt = xsltCtxt
 *         self._set_xpath_context(xsltCtxt.xpathCtxt)             # <<<<<<<<<<<<<<
 *         self._register_context(doc)
 *         self.registerLocalFunctions(xsltCtxt, _register_xslt_function)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_xpath_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_xsltCtxt->xpathCtxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":310
 *         self._xsltCtxt = xsltCtxt
 *         self._set_xpath_context(xsltCtxt.xpathCtxt)
 *         self._register_context(doc)             # <<<<<<<<<<<<<<
 *         self.registerLocalFunctions(xsltCtxt, _register_xslt_function)
 *         self.registerGlobalFunctions(xsltCtxt, _register_xslt_function)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._register_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":311
 *         self._set_xpath_context(xsltCtxt.xpathCtxt)
 *         self._register_context(doc)
 *         self.registerLocalFunctions(xsltCtxt, _register_xslt_function)             # <<<<<<<<<<<<<<
 *         self.registerGlobalFunctions(xsltCtxt, _register_xslt_function)
 *         _registerXSLTExtensions(xsltCtxt, self._extension_elements)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.registerLocalFunctions(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_xsltCtxt, __pyx_f_4lxml_5etree__register_xslt_function);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":312
 *         self._register_context(doc)
 *         self.registerLocalFunctions(xsltCtxt, _register_xslt_function)
 *         self.registerGlobalFunctions(xsltCtxt, _register_xslt_function)             # <<<<<<<<<<<<<<
 *         _registerXSLTExtensions(xsltCtxt, self._extension_elements)
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.registerGlobalFunctions(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self), __pyx_v_xsltCtxt, __pyx_f_4lxml_5etree__register_xslt_function);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":313
 *         self.registerLocalFunctions(xsltCtxt, _register_xslt_function)
 *         self.registerGlobalFunctions(xsltCtxt, _register_xslt_function)
 *         _registerXSLTExtensions(xsltCtxt, self._extension_elements)             # <<<<<<<<<<<<<<
 * 
 *     cdef free_context(self):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__registerXSLTExtensions(__pyx_v_xsltCtxt, __pyx_v_self->_extension_elements); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XSLTContext.register_context");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":315
 *         _registerXSLTExtensions(xsltCtxt, self._extension_elements)
 * 
 *     cdef free_context(self):             # <<<<<<<<<<<<<<
 *         self._cleanup_context()
 *         self._release_context()
 */

static  PyObject *__pyx_f_4lxml_5etree_12_XSLTContext_free_context(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":316
 * 
 *     cdef free_context(self):
 *         self._cleanup_context()             # <<<<<<<<<<<<<<
 *         self._release_context()
 *         if self._xsltCtxt is not NULL:
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._cleanup_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":317
 *     cdef free_context(self):
 *         self._cleanup_context()
 *         self._release_context()             # <<<<<<<<<<<<<<
 *         if self._xsltCtxt is not NULL:
 *             xslt.xsltFreeTransformContext(self._xsltCtxt)
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._release_context(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":318
 *         self._cleanup_context()
 *         self._release_context()
 *         if self._xsltCtxt is not NULL:             # <<<<<<<<<<<<<<
 *             xslt.xsltFreeTransformContext(self._xsltCtxt)
 *             self._xsltCtxt = NULL
 */
  __pyx_2 = (__pyx_v_self->_xsltCtxt != NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":319
 *         self._release_context()
 *         if self._xsltCtxt is not NULL:
 *             xslt.xsltFreeTransformContext(self._xsltCtxt)             # <<<<<<<<<<<<<<
 *             self._xsltCtxt = NULL
 *         self._release_temp_refs()
 */
    xsltFreeTransformContext(__pyx_v_self->_xsltCtxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":320
 *         if self._xsltCtxt is not NULL:
 *             xslt.xsltFreeTransformContext(self._xsltCtxt)
 *             self._xsltCtxt = NULL             # <<<<<<<<<<<<<<
 *         self._release_temp_refs()
 * 
 */
    __pyx_v_self->_xsltCtxt = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":321
 *             xslt.xsltFreeTransformContext(self._xsltCtxt)
 *             self._xsltCtxt = NULL
 *         self._release_temp_refs()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._release_temp_refs(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XSLTContext.free_context");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":356
 *     cdef _ErrorLog _error_log
 * 
 *     def __init__(self, xslt_input, *, extensions=None, regexp=True,             # <<<<<<<<<<<<<<
 *                  access_control=None):
 *         cdef xslt.xsltStylesheet* c_style
 */

static int __pyx_pf_4lxml_5etree_4XSLT___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_4XSLT___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_xslt_input = 0;
  PyObject *__pyx_v_extensions = 0;
  PyObject *__pyx_v_regexp = 0;
  PyObject *__pyx_v_access_control = 0;
  xsltStylesheet *__pyx_v_c_style;
  xmlDoc *__pyx_v_c_doc;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  PyObject *__pyx_v_doc_url_utf;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  xmlDoc *__pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  xmlDoc *__pyx_5;
  int __pyx_6;
  int __pyx_7;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_xslt_input,&__pyx_kp_extensions,&__pyx_kp_regexp,&__pyx_kp_access_control,0};
  __pyx_v_extensions = Py_None;
  __pyx_v_regexp = __pyx_k_190;
  __pyx_v_access_control = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_xslt_input);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_xslt_input = values[0];
    if (values[1]) {
      __pyx_v_extensions = values[1];
    }
    if (values[2]) {
      __pyx_v_regexp = values[2];
    }
    if (values[3]) {
      __pyx_v_access_control = values[3];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_xslt_input = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XSLT.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_doc_url_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":363
 *         cdef _Element root_node
 * 
 *         doc = _documentOrRaise(xslt_input)             # <<<<<<<<<<<<<<
 *         root_node = _rootNodeOrRaise(xslt_input)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_xslt_input)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":364
 * 
 *         doc = _documentOrRaise(xslt_input)
 *         root_node = _rootNodeOrRaise(xslt_input)             # <<<<<<<<<<<<<<
 * 
 *         # set access control or raise TypeError
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_xslt_input)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root_node));
  __pyx_v_root_node = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":367
 * 
 *         # set access control or raise TypeError
 *         self._access_control = access_control             # <<<<<<<<<<<<<<
 * 
 *         # make a copy of the document as stylesheet parsing modifies it
 */
  if (!(__Pyx_TypeTest(__pyx_v_access_control, __pyx_ptype_4lxml_5etree_XSLTAccessControl))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_access_control);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_access_control));
  ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_access_control = ((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)__pyx_v_access_control);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":370
 * 
 *         # make a copy of the document as stylesheet parsing modifies it
 *         c_doc = _copyDocRoot(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 * 
 *         # make sure we always have a stylesheet URL
 */
  __pyx_2 = __pyx_f_4lxml_5etree__copyDocRoot(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":373
 * 
 *         # make sure we always have a stylesheet URL
 *         if c_doc.URL is NULL:             # <<<<<<<<<<<<<<
 *             doc_url_utf = python.PyUnicode_AsASCIIString(
 *                 u"string://__STRING__XSLT__%d" % id(self))
 */
  __pyx_3 = (__pyx_v_c_doc->URL == NULL);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":375
 *         if c_doc.URL is NULL:
 *             doc_url_utf = python.PyUnicode_AsASCIIString(
 *                 u"string://__STRING__XSLT__%d" % id(self))             # <<<<<<<<<<<<<<
 *             c_doc.URL = tree.xmlStrdup(_cstr(doc_url_utf))
 * 
 */
    __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
    __pyx_4 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_583), __pyx_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_1 = PyUnicode_AsASCIIString(__pyx_t_1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    Py_DECREF(__pyx_v_doc_url_utf);
    __pyx_v_doc_url_utf = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":376
 *             doc_url_utf = python.PyUnicode_AsASCIIString(
 *                 u"string://__STRING__XSLT__%d" % id(self))
 *             c_doc.URL = tree.xmlStrdup(_cstr(doc_url_utf))             # <<<<<<<<<<<<<<
 * 
 *         self._error_log = _ErrorLog()
 */
    __pyx_v_c_doc->URL = xmlStrdup(PyString_AS_STRING(__pyx_v_doc_url_utf));
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":378
 *             c_doc.URL = tree.xmlStrdup(_cstr(doc_url_utf))
 * 
 *         self._error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 *         self._xslt_resolver_context = _XSLTResolverContext()
 *         _initXSLTResolverContext(self._xslt_resolver_context, doc._parser)
 */
  __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
  ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_4);
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":379
 * 
 *         self._error_log = _ErrorLog()
 *         self._xslt_resolver_context = _XSLTResolverContext()             # <<<<<<<<<<<<<<
 *         _initXSLTResolverContext(self._xslt_resolver_context, doc._parser)
 *         # keep a copy in case we need to access the stylesheet via 'document()'
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XSLTResolverContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__XSLTResolverContext))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context));
  ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":380
 *         self._error_log = _ErrorLog()
 *         self._xslt_resolver_context = _XSLTResolverContext()
 *         _initXSLTResolverContext(self._xslt_resolver_context, doc._parser)             # <<<<<<<<<<<<<<
 *         # keep a copy in case we need to access the stylesheet via 'document()'
 *         self._xslt_resolver_context._c_style_doc = _copyDoc(c_doc, 1)
 */
  __pyx_4 = __pyx_f_4lxml_5etree__initXSLTResolverContext(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context, __pyx_v_doc->_parser); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":382
 *         _initXSLTResolverContext(self._xslt_resolver_context, doc._parser)
 *         # keep a copy in case we need to access the stylesheet via 'document()'
 *         self._xslt_resolver_context._c_style_doc = _copyDoc(c_doc, 1)             # <<<<<<<<<<<<<<
 *         c_doc._private = <python.PyObject*>self._xslt_resolver_context
 * 
 */
  __pyx_5 = __pyx_f_4lxml_5etree__copyDoc(__pyx_v_c_doc, 1); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context->_c_style_doc = __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":383
 *         # keep a copy in case we need to access the stylesheet via 'document()'
 *         self._xslt_resolver_context._c_style_doc = _copyDoc(c_doc, 1)
 *         c_doc._private = <python.PyObject*>self._xslt_resolver_context             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.connect()
 */
  __pyx_v_c_doc->_private = ((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":385
 *         c_doc._private = <python.PyObject*>self._xslt_resolver_context
 * 
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             c_style = xslt.xsltParseStylesheetDoc(c_doc)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":386
 * 
 *         self._error_log.connect()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             c_style = xslt.xsltParseStylesheetDoc(c_doc)
 *         self._error_log.disconnect()
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":387
 *         self._error_log.connect()
 *         with nogil:
 *             c_style = xslt.xsltParseStylesheetDoc(c_doc)             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 * 
 */
      __pyx_v_c_style = xsltParseStylesheetDoc(__pyx_v_c_doc);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":388
 *         with nogil:
 *             c_style = xslt.xsltParseStylesheetDoc(c_doc)
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         if c_style is NULL:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":390
 *         self._error_log.disconnect()
 * 
 *         if c_style is NULL:             # <<<<<<<<<<<<<<
 *             tree.xmlFreeDoc(c_doc)
 *             self._xslt_resolver_context._raise_if_stored()
 */
  __pyx_3 = (__pyx_v_c_style == NULL);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":391
 * 
 *         if c_style is NULL:
 *             tree.xmlFreeDoc(c_doc)             # <<<<<<<<<<<<<<
 *             self._xslt_resolver_context._raise_if_stored()
 *             # last error seems to be the most accurate here
 */
    xmlFreeDoc(__pyx_v_c_doc);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":392
 *         if c_style is NULL:
 *             tree.xmlFreeDoc(c_doc)
 *             self._xslt_resolver_context._raise_if_stored()             # <<<<<<<<<<<<<<
 *             # last error seems to be the most accurate here
 *             if self._error_log.last_error is not None and \
 */
    __pyx_6 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raise_if_stored(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context)); if (unlikely(__pyx_6 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":394
 *             self._xslt_resolver_context._raise_if_stored()
 *             # last error seems to be the most accurate here
 *             if self._error_log.last_error is not None and \             # <<<<<<<<<<<<<<
 *                     self._error_log.last_error.message:
 *                 raise XSLTParseError(self._error_log.last_error.message,
 */
    __pyx_3 = (((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.last_error != Py_None);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":395
 *             # last error seems to be the most accurate here
 *             if self._error_log.last_error is not None and \
 *                     self._error_log.last_error.message:             # <<<<<<<<<<<<<<
 *                 raise XSLTParseError(self._error_log.last_error.message,
 *                                      self._error_log)
 */
      __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.last_error, __pyx_kp_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":396
 *             if self._error_log.last_error is not None and \
 *                     self._error_log.last_error.message:
 *                 raise XSLTParseError(self._error_log.last_error.message,             # <<<<<<<<<<<<<<
 *                                      self._error_log)
 *             else:
 */
      __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTParseError); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.last_error, __pyx_kp_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":397
 *                     self._error_log.last_error.message:
 *                 raise XSLTParseError(self._error_log.last_error.message,
 *                                      self._error_log)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise XSLTParseError(
 */
      __pyx_8 = PyTuple_New(2); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_8, 0, __pyx_1);
      Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
      PyTuple_SET_ITEM(__pyx_8, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
      __pyx_1 = 0;
      __pyx_1 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_8), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(((PyObject *)__pyx_8)); __pyx_8 = 0;
      __Pyx_Raise(__pyx_1, 0, 0);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L11;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":399
 *                                      self._error_log)
 *             else:
 *                 raise XSLTParseError(             # <<<<<<<<<<<<<<
 *                     self._error_log._buildExceptionMessage(
 *                         u"Cannot parse stylesheet"),
 */
      __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTParseError); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":401
 *                 raise XSLTParseError(
 *                     self._error_log._buildExceptionMessage(
 *                         u"Cannot parse stylesheet"),             # <<<<<<<<<<<<<<
 *                     self._error_log)
 * 
 */
      __pyx_8 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log), ((PyObject *)__pyx_kp_584)); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":402
 *                     self._error_log._buildExceptionMessage(
 *                         u"Cannot parse stylesheet"),
 *                     self._error_log)             # <<<<<<<<<<<<<<
 * 
 *         c_doc._private = NULL # no longer used!
 */
      __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_8);
      Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
      PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
      __pyx_8 = 0;
      __pyx_8 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
      __Pyx_Raise(__pyx_8, 0, 0);
      Py_DECREF(__pyx_8); __pyx_8 = 0;
      {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L11:;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":404
 *                     self._error_log)
 * 
 *         c_doc._private = NULL # no longer used!             # <<<<<<<<<<<<<<
 *         self._c_style = c_style
 *         self._context = _XSLTContext(None, extensions, regexp, True)
 */
  __pyx_v_c_doc->_private = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":405
 * 
 *         c_doc._private = NULL # no longer used!
 *         self._c_style = c_style             # <<<<<<<<<<<<<<
 *         self._context = _XSLTContext(None, extensions, regexp, True)
 * 
 */
  ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_c_style = __pyx_v_c_style;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":406
 *         c_doc._private = NULL # no longer used!
 *         self._c_style = c_style
 *         self._context = _XSLTContext(None, extensions, regexp, True)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = PyTuple_New(4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_1, 0, Py_None);
  Py_INCREF(__pyx_v_extensions);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_extensions);
  Py_INCREF(__pyx_v_regexp);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_regexp);
  PyTuple_SET_ITEM(__pyx_1, 3, __pyx_4);
  __pyx_4 = 0;
  __pyx_8 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XSLTContext)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  if (!(__Pyx_TypeTest(__pyx_8, __pyx_ptype_4lxml_5etree__XSLTContext))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_context));
  ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_8);
  __pyx_8 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("lxml.etree.XSLT.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  Py_DECREF(__pyx_v_doc_url_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":408
 *         self._context = _XSLTContext(None, extensions, regexp, True)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._xslt_resolver_context is not None and \
 *                self._xslt_resolver_context._c_style_doc is not NULL:
 */

static void __pyx_pf_4lxml_5etree_4XSLT___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_4XSLT___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":409
 * 
 *     def __dealloc__(self):
 *         if self._xslt_resolver_context is not None and \             # <<<<<<<<<<<<<<
 *                self._xslt_resolver_context._c_style_doc is not NULL:
 *             tree.xmlFreeDoc(self._xslt_resolver_context._c_style_doc)
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":410
 *     def __dealloc__(self):
 *         if self._xslt_resolver_context is not None and \
 *                self._xslt_resolver_context._c_style_doc is not NULL:             # <<<<<<<<<<<<<<
 *             tree.xmlFreeDoc(self._xslt_resolver_context._c_style_doc)
 *         # this cleans up the doc copy as well
 */
    __pyx_1 = (((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context->_c_style_doc != NULL);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":411
 *         if self._xslt_resolver_context is not None and \
 *                self._xslt_resolver_context._c_style_doc is not NULL:
 *             tree.xmlFreeDoc(self._xslt_resolver_context._c_style_doc)             # <<<<<<<<<<<<<<
 *         # this cleans up the doc copy as well
 *         xslt.xsltFreeStylesheet(self._c_style)
 */
    xmlFreeDoc(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context->_c_style_doc);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":413
 *             tree.xmlFreeDoc(self._xslt_resolver_context._c_style_doc)
 *         # this cleans up the doc copy as well
 *         xslt.xsltFreeStylesheet(self._c_style)             # <<<<<<<<<<<<<<
 * 
 *     property error_log:
 */
  xsltFreeStylesheet(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_c_style);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":417
 *     property error_log:
 *         u"The log of errors and warnings of an XSLT execution."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._error_log.copy()
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_4XSLT_9error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_4XSLT_9error_log___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":418
 *         u"The log of errors and warnings of an XSLT execution."
 *         def __get__(self):
 *             return self._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 *     def apply(self, _input, *, profile_run=False, **kw):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLT.error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":420
 *             return self._error_log.copy()
 * 
 *     def apply(self, _input, *, profile_run=False, **kw):             # <<<<<<<<<<<<<<
 *         u"""apply(self, _input,  profile_run=False, **kw)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_4XSLT_apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_4XSLT_apply[] = "apply(self, _input,  profile_run=False, **kw)\n        \n        :deprecated: call the object, not this method.";
static PyObject *__pyx_pf_4lxml_5etree_4XSLT_apply(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__input = 0;
  PyObject *__pyx_v_profile_run = 0;
  PyObject *__pyx_v_kw = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__input,&__pyx_kp_profile_run,0};
  __pyx_v_profile_run = __pyx_k_191;
  __pyx_v_kw = PyDict_New(); if (unlikely(!__pyx_v_kw)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__input);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kw, values, PyTuple_GET_SIZE(__pyx_args), "apply") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__input = values[0];
    if (values[1]) {
      __pyx_v_profile_run = values[1];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__input = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("apply", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v_kw);
  __Pyx_AddTraceback("lxml.etree.XSLT.apply");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":424
 * 
 *         :deprecated: call the object, not this method."""
 *         return self(_input, profile_run=profile_run, **kw)             # <<<<<<<<<<<<<<
 * 
 *     def tostring(self, _ElementTree result_tree):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v__input);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v__input);
  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_2, __pyx_kp_profile_run, __pyx_v_profile_run) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_Update(((PyObject *)__pyx_2), __pyx_v_kw) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyEval_CallObjectWithKeywords(__pyx_v_self, ((PyObject *)__pyx_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.XSLT.apply");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_kw);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":426
 *         return self(_input, profile_run=profile_run, **kw)
 * 
 *     def tostring(self, _ElementTree result_tree):             # <<<<<<<<<<<<<<
 *         u"""tostring(self, result_tree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_4XSLT_tostring(PyObject *__pyx_v_self, PyObject *__pyx_v_result_tree); /*proto*/
static char __pyx_doc_4lxml_5etree_4XSLT_tostring[] = "tostring(self, result_tree)\n\n        Save result doc to string based on stylesheet output method.\n\n        :deprecated: use str(result_tree) instead.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_4XSLT_tostring(PyObject *__pyx_v_self, PyObject *__pyx_v_result_tree) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_result_tree), __pyx_ptype_4lxml_5etree__ElementTree, 1, "result_tree", 0))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":433
 *         :deprecated: use str(result_tree) instead.
 *         """
 *         return str(result_tree)             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self, memo):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_result_tree);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_result_tree);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLT.tostring");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":435
 *         return str(result_tree)
 * 
 *     def __deepcopy__(self, memo):             # <<<<<<<<<<<<<<
 *         return self.__copy__()
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_4XSLT___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_4XSLT___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":436
 * 
 *     def __deepcopy__(self, memo):
 *         return self.__copy__()             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___copy__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLT.__deepcopy__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":438
 *         return self.__copy__()
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return _copyXSLT(self)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_4XSLT___copy__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_4XSLT___copy__(PyObject *__pyx_v_self, PyObject *unused) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":439
 * 
 *     def __copy__(self):
 *         return _copyXSLT(self)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, _input, *, profile_run=False, **kw):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__copyXSLT(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XSLT.__copy__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":441
 *         return _copyXSLT(self)
 * 
 *     def __call__(self, _input, *, profile_run=False, **kw):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, _input, profile_run=False, **kw)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_4XSLT___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_4XSLT___call__[] = "__call__(self, _input, profile_run=False, **kw)\n\n        Execute the XSL transformation on a tree or Element.\n\n        Pass the ``profile_run`` option to get profile information\n        about the XSLT.  The result of the XSLT will have a property\n        xslt_profile that holds an XML tree with profiling data.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_4XSLT___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__input = 0;
  PyObject *__pyx_v_profile_run = 0;
  PyObject *__pyx_v_kw = 0;
  struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *__pyx_v_resolver_context;
  struct LxmlDocument *__pyx_v_input_doc;
  struct LxmlElement *__pyx_v_root_node;
  struct LxmlDocument *__pyx_v_result_doc;
  struct LxmlDocument *__pyx_v_profile_doc;
  xmlDoc *__pyx_v_c_profile_doc;
  xsltTransformContext *__pyx_v_transform_ctxt;
  xmlDoc *__pyx_v_c_result;
  xmlDoc *__pyx_v_c_doc;
  xmlDict *__pyx_v_c_dict;
  PyObject *__pyx_v_error;
  PyObject *__pyx_v_message;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  xmlDoc *__pyx_2;
  int __pyx_3;
  int __pyx_4;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp__input,&__pyx_kp_profile_run,0};
  __pyx_v_profile_run = __pyx_k_192;
  __pyx_v_kw = PyDict_New(); if (unlikely(!__pyx_v_kw)) return NULL;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp__input);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kw, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v__input = values[0];
    if (values[1]) {
      __pyx_v_profile_run = values[1];
    }
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v__input = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  Py_DECREF(__pyx_v_kw);
  __Pyx_AddTraceback("lxml.etree.XSLT.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_resolver_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_input_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_profile_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_error = Py_None; Py_INCREF(Py_None);
  __pyx_v_message = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":462
 *         cdef tree.xmlDict* c_dict
 * 
 *         input_doc = _documentOrRaise(_input)             # <<<<<<<<<<<<<<
 *         root_node = _rootNodeOrRaise(_input)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v__input)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_input_doc));
  __pyx_v_input_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":463
 * 
 *         input_doc = _documentOrRaise(_input)
 *         root_node = _rootNodeOrRaise(_input)             # <<<<<<<<<<<<<<
 * 
 *         c_doc = _fakeRootDoc(input_doc._c_doc, root_node._c_node)
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v__input)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root_node));
  __pyx_v_root_node = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":465
 *         root_node = _rootNodeOrRaise(_input)
 * 
 *         c_doc = _fakeRootDoc(input_doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 * 
 *         transform_ctxt = xslt.xsltNewTransformContext(self._c_style, c_doc)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_input_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":467
 *         c_doc = _fakeRootDoc(input_doc._c_doc, root_node._c_node)
 * 
 *         transform_ctxt = xslt.xsltNewTransformContext(self._c_style, c_doc)             # <<<<<<<<<<<<<<
 *         if transform_ctxt is NULL:
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)
 */
  __pyx_v_transform_ctxt = xsltNewTransformContext(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_c_style, __pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":468
 * 
 *         transform_ctxt = xslt.xsltNewTransformContext(self._c_style, c_doc)
 *         if transform_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)
 *             python.PyErr_NoMemory()
 */
  __pyx_3 = (__pyx_v_transform_ctxt == NULL);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":469
 *         transform_ctxt = xslt.xsltNewTransformContext(self._c_style, c_doc)
 *         if transform_ctxt is NULL:
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 * 
 */
    __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_input_doc->_c_doc, __pyx_v_c_doc);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":470
 *         if transform_ctxt is NULL:
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         initTransformDict(transform_ctxt)
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":472
 *             python.PyErr_NoMemory()
 * 
 *         initTransformDict(transform_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         if profile_run:
 */
  __pyx_f_4lxml_5etree_initTransformDict(__pyx_v_transform_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":474
 *         initTransformDict(transform_ctxt)
 * 
 *         if profile_run:             # <<<<<<<<<<<<<<
 *             transform_ctxt.profile = 1
 * 
 */
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_v_profile_run); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":475
 * 
 *         if profile_run:
 *             transform_ctxt.profile = 1             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __pyx_v_transform_ctxt->profile = 1;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":477
 *             transform_ctxt.profile = 1
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self._error_log.connect()
 *             context = self._context._copy()
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":478
 * 
 *         try:
 *             self._error_log.connect()             # <<<<<<<<<<<<<<
 *             context = self._context._copy()
 *             context.register_context(transform_ctxt, input_doc)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":479
 *         try:
 *             self._error_log.connect()
 *             context = self._context._copy()             # <<<<<<<<<<<<<<
 *             context.register_context(transform_ctxt, input_doc)
 * 
 */
    __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_context->__pyx_base.__pyx_vtab)->__pyx_base._copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_context))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L9;}
    if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__XSLTContext))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L9;}
    Py_DECREF(((PyObject *)__pyx_v_context));
    __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":480
 *             self._error_log.connect()
 *             context = self._context._copy()
 *             context.register_context(transform_ctxt, input_doc)             # <<<<<<<<<<<<<<
 * 
 *             resolver_context = self._xslt_resolver_context._copy()
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_context->__pyx_base.__pyx_vtab)->register_context(__pyx_v_context, __pyx_v_transform_ctxt, __pyx_v_input_doc); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L9;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":482
 *             context.register_context(transform_ctxt, input_doc)
 * 
 *             resolver_context = self._xslt_resolver_context._copy()             # <<<<<<<<<<<<<<
 *             transform_ctxt._private = <python.PyObject*>resolver_context
 * 
 */
    __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context->__pyx_base.__pyx_base.__pyx_vtab)->_copy(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_xslt_resolver_context)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L9;}
    Py_DECREF(((PyObject *)__pyx_v_resolver_context));
    __pyx_v_resolver_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":483
 * 
 *             resolver_context = self._xslt_resolver_context._copy()
 *             transform_ctxt._private = <python.PyObject*>resolver_context             # <<<<<<<<<<<<<<
 * 
 *             c_result = self._run_transform(
 */
    __pyx_v_transform_ctxt->_private = ((PyObject *)__pyx_v_resolver_context);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":486
 * 
 *             c_result = self._run_transform(
 *                 c_doc, kw, context, transform_ctxt)             # <<<<<<<<<<<<<<
 * 
 *             if transform_ctxt.state != xslt.XSLT_STATE_OK:
 */
    __pyx_v_c_result = ((struct __pyx_vtabstruct_4lxml_5etree_XSLT *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->__pyx_vtab)->_run_transform(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self), __pyx_v_c_doc, __pyx_v_kw, __pyx_v_context, __pyx_v_transform_ctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":488
 *                 c_doc, kw, context, transform_ctxt)
 * 
 *             if transform_ctxt.state != xslt.XSLT_STATE_OK:             # <<<<<<<<<<<<<<
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)
 */
    __pyx_3 = (__pyx_v_transform_ctxt->state != XSLT_STATE_OK);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":489
 * 
 *             if transform_ctxt.state != xslt.XSLT_STATE_OK:
 *                 if c_result is not NULL:             # <<<<<<<<<<<<<<
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL
 */
      __pyx_3 = (__pyx_v_c_result != NULL);
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":490
 *             if transform_ctxt.state != xslt.XSLT_STATE_OK:
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)             # <<<<<<<<<<<<<<
 *                     c_result = NULL
 * 
 */
        xmlFreeDoc(__pyx_v_c_result);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":491
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL             # <<<<<<<<<<<<<<
 * 
 *             if transform_ctxt.profile:
 */
        __pyx_v_c_result = NULL;
        goto __pyx_L12;
      }
      __pyx_L12:;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":493
 *                     c_result = NULL
 * 
 *             if transform_ctxt.profile:             # <<<<<<<<<<<<<<
 *                 c_profile_doc = xslt.xsltGetProfileInformation(transform_ctxt)
 *                 if c_profile_doc is not NULL:
 */
    __pyx_4 = __pyx_v_transform_ctxt->profile;
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":494
 * 
 *             if transform_ctxt.profile:
 *                 c_profile_doc = xslt.xsltGetProfileInformation(transform_ctxt)             # <<<<<<<<<<<<<<
 *                 if c_profile_doc is not NULL:
 *                     profile_doc = _documentFactory(
 */
      __pyx_v_c_profile_doc = xsltGetProfileInformation(__pyx_v_transform_ctxt);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":495
 *             if transform_ctxt.profile:
 *                 c_profile_doc = xslt.xsltGetProfileInformation(transform_ctxt)
 *                 if c_profile_doc is not NULL:             # <<<<<<<<<<<<<<
 *                     profile_doc = _documentFactory(
 *                         c_profile_doc, input_doc._parser)
 */
      __pyx_3 = (__pyx_v_c_profile_doc != NULL);
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":497
 *                 if c_profile_doc is not NULL:
 *                     profile_doc = _documentFactory(
 *                         c_profile_doc, input_doc._parser)             # <<<<<<<<<<<<<<
 *         finally:
 *             if context is not None:
 */
        __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_profile_doc, __pyx_v_input_doc->_parser)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L9;}
        Py_DECREF(((PyObject *)__pyx_v_profile_doc));
        __pyx_v_profile_doc = ((struct LxmlDocument *)__pyx_1);
        __pyx_1 = 0;
        goto __pyx_L14;
      }
      __pyx_L14:;
      goto __pyx_L13;
    }
    __pyx_L13:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L10;
    __pyx_L9: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":499
 *                         c_profile_doc, input_doc._parser)
 *         finally:
 *             if context is not None:             # <<<<<<<<<<<<<<
 *                 context.free_context()
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)
 */
    __pyx_3 = (((PyObject *)__pyx_v_context) != Py_None);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":500
 *         finally:
 *             if context is not None:
 *                 context.free_context()             # <<<<<<<<<<<<<<
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)
 *             self._error_log.disconnect()
 */
      __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_context->__pyx_base.__pyx_vtab)->free_context(__pyx_v_context); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L15_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":501
 *             if context is not None:
 *                 context.free_context()
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 * 
 */
    __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_input_doc->_c_doc, __pyx_v_c_doc);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":502
 *                 context.free_context()
 *             _destroyFakeDoc(input_doc._c_doc, c_doc)
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log);
    goto __pyx_L17;
    __pyx_L15_error:;
    if (__pyx_why == 4) {
      Py_XDECREF(__pyx_exc_type);
      Py_XDECREF(__pyx_exc_value);
      Py_XDECREF(__pyx_exc_tb);
    }
    goto __pyx_L1_error;
    __pyx_L17:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":504
 *             self._error_log.disconnect()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if resolver_context is not None and resolver_context._has_raised():
 *                 if c_result is not NULL:
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":505
 * 
 *         try:
 *             if resolver_context is not None and resolver_context._has_raised():             # <<<<<<<<<<<<<<
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)
 */
    __pyx_3 = (((PyObject *)__pyx_v_resolver_context) != Py_None);
    if (__pyx_3) {
      __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)__pyx_v_resolver_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._has_raised(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_resolver_context));
    }
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":506
 *         try:
 *             if resolver_context is not None and resolver_context._has_raised():
 *                 if c_result is not NULL:             # <<<<<<<<<<<<<<
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL
 */
      __pyx_3 = (__pyx_v_c_result != NULL);
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":507
 *             if resolver_context is not None and resolver_context._has_raised():
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)             # <<<<<<<<<<<<<<
 *                     c_result = NULL
 *                 resolver_context._raise_if_stored()
 */
        xmlFreeDoc(__pyx_v_c_result);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":508
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL             # <<<<<<<<<<<<<<
 *                 resolver_context._raise_if_stored()
 * 
 */
        __pyx_v_c_result = NULL;
        goto __pyx_L22;
      }
      __pyx_L22:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":509
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL
 *                 resolver_context._raise_if_stored()             # <<<<<<<<<<<<<<
 * 
 *             if context._exc._has_raised():
 */
      __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)__pyx_v_resolver_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raise_if_stored(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_resolver_context)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L19;}
      goto __pyx_L21;
    }
    __pyx_L21:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":511
 *                 resolver_context._raise_if_stored()
 * 
 *             if context._exc._has_raised():             # <<<<<<<<<<<<<<
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_context->__pyx_base._exc->__pyx_vtab)->_has_raised(__pyx_v_context->__pyx_base._exc);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":512
 * 
 *             if context._exc._has_raised():
 *                 if c_result is not NULL:             # <<<<<<<<<<<<<<
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL
 */
      __pyx_3 = (__pyx_v_c_result != NULL);
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":513
 *             if context._exc._has_raised():
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)             # <<<<<<<<<<<<<<
 *                     c_result = NULL
 *                 context._exc._raise_if_stored()
 */
        xmlFreeDoc(__pyx_v_c_result);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":514
 *                 if c_result is not NULL:
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL             # <<<<<<<<<<<<<<
 *                 context._exc._raise_if_stored()
 * 
 */
        __pyx_v_c_result = NULL;
        goto __pyx_L24;
      }
      __pyx_L24:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":515
 *                     tree.xmlFreeDoc(c_result)
 *                     c_result = NULL
 *                 context._exc._raise_if_stored()             # <<<<<<<<<<<<<<
 * 
 *             if c_result is NULL:
 */
      __pyx_4 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_context->__pyx_base._exc->__pyx_vtab)->_raise_if_stored(__pyx_v_context->__pyx_base._exc); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L19;}
      goto __pyx_L23;
    }
    __pyx_L23:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":517
 *                 context._exc._raise_if_stored()
 * 
 *             if c_result is NULL:             # <<<<<<<<<<<<<<
 *                 # last error seems to be the most accurate here
 *                 error = self._error_log.last_error
 */
    __pyx_3 = (__pyx_v_c_result == NULL);
    if (__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":519
 *             if c_result is NULL:
 *                 # last error seems to be the most accurate here
 *                 error = self._error_log.last_error             # <<<<<<<<<<<<<<
 *                 if error is not None and error.message:
 *                     if error.line > 0:
 */
      Py_INCREF(((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.last_error);
      Py_DECREF(__pyx_v_error);
      __pyx_v_error = ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.last_error;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":520
 *                 # last error seems to be the most accurate here
 *                 error = self._error_log.last_error
 *                 if error is not None and error.message:             # <<<<<<<<<<<<<<
 *                     if error.line > 0:
 *                         message = u"%s, line %d" % (error.message, error.line)
 */
      __pyx_3 = (__pyx_v_error != Py_None);
      if (__pyx_3) {
        __pyx_1 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L19;}
        __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L19;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
      }
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":521
 *                 error = self._error_log.last_error
 *                 if error is not None and error.message:
 *                     if error.line > 0:             # <<<<<<<<<<<<<<
 *                         message = u"%s, line %d" % (error.message, error.line)
 *                     else:
 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_line); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L19;}
        __pyx_6 = PyObject_RichCompare(__pyx_1, __pyx_int_0, Py_GT); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L19;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        __pyx_5 = __Pyx_PyObject_IsTrue(__pyx_6); if (unlikely(__pyx_5 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L19;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        if (__pyx_5) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":522
 *                 if error is not None and error.message:
 *                     if error.line > 0:
 *                         message = u"%s, line %d" % (error.message, error.line)             # <<<<<<<<<<<<<<
 *                     else:
 *                         message = error.message
 */
          __pyx_1 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L19;}
          __pyx_6 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_line); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L19;}
          __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L19;}
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
          PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
          __pyx_1 = 0;
          __pyx_6 = 0;
          __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_585), ((PyObject *)__pyx_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L19;}
          Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
          Py_DECREF(__pyx_v_message);
          __pyx_v_message = __pyx_t_1;
          __pyx_t_1 = 0;
          goto __pyx_L27;
        }
        /*else*/ {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":524
 *                         message = u"%s, line %d" % (error.message, error.line)
 *                     else:
 *                         message = error.message             # <<<<<<<<<<<<<<
 *                 elif error is not None and error.line > 0:
 *                     message = u"Error applying stylesheet, line %d" % error.line
 */
          __pyx_1 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L19;}
          Py_DECREF(__pyx_v_message);
          __pyx_v_message = __pyx_1;
          __pyx_1 = 0;
        }
        __pyx_L27:;
        goto __pyx_L26;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":525
 *                     else:
 *                         message = error.message
 *                 elif error is not None and error.line > 0:             # <<<<<<<<<<<<<<
 *                     message = u"Error applying stylesheet, line %d" % error.line
 *                 else:
 */
      __pyx_3 = (__pyx_v_error != Py_None);
      if (__pyx_3) {
        __pyx_6 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_line); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L19;}
        __pyx_7 = PyObject_RichCompare(__pyx_6, __pyx_int_0, Py_GT); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L19;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_7); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L19;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
      }
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":526
 *                         message = error.message
 *                 elif error is not None and error.line > 0:
 *                     message = u"Error applying stylesheet, line %d" % error.line             # <<<<<<<<<<<<<<
 *                 else:
 *                     message = u"Error applying stylesheet"
 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_error, __pyx_kp_line); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L19;}
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_586), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L19;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_v_message);
        __pyx_v_message = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L26;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":528
 *                     message = u"Error applying stylesheet, line %d" % error.line
 *                 else:
 *                     message = u"Error applying stylesheet"             # <<<<<<<<<<<<<<
 *                 raise XSLTApplyError(message, self._error_log)
 *         finally:
 */
        Py_INCREF(((PyObject *)__pyx_kp_587));
        Py_DECREF(__pyx_v_message);
        __pyx_v_message = ((PyObject *)__pyx_kp_587);
      }
      __pyx_L26:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":529
 *                 else:
 *                     message = u"Error applying stylesheet"
 *                 raise XSLTApplyError(message, self._error_log)             # <<<<<<<<<<<<<<
 *         finally:
 *             if resolver_context is not None:
 */
      __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTApplyError); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L19;}
      __pyx_7 = PyTuple_New(2); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L19;}
      Py_INCREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_message);
      Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
      PyTuple_SET_ITEM(__pyx_7, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_error_log));
      __pyx_1 = PyObject_Call(__pyx_6, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L19;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
      __Pyx_Raise(__pyx_1, 0, 0);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      {__pyx_filename = __pyx_f[17]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L19;}
      goto __pyx_L25;
    }
    __pyx_L25:;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L20;
    __pyx_L19: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_6); __pyx_6 = 0;
      Py_XDECREF(__pyx_7); __pyx_7 = 0;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L20;
    }
    __pyx_L20:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":531
 *                 raise XSLTApplyError(message, self._error_log)
 *         finally:
 *             if resolver_context is not None:             # <<<<<<<<<<<<<<
 *                 resolver_context.clear()
 * 
 */
    __pyx_5 = (((PyObject *)__pyx_v_resolver_context) != Py_None);
    if (__pyx_5) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":532
 *         finally:
 *             if resolver_context is not None:
 *                 resolver_context.clear()             # <<<<<<<<<<<<<<
 * 
 *         result_doc = _documentFactory(c_result, input_doc._parser)
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)__pyx_v_resolver_context->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.clear(((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_v_resolver_context));
      goto __pyx_L29;
    }
    __pyx_L29:;
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":534
 *                 resolver_context.clear()
 * 
 *         result_doc = _documentFactory(c_result, input_doc._parser)             # <<<<<<<<<<<<<<
 * 
 *         c_dict = c_result.dict
 */
  __pyx_6 = ((PyObject *)__pyx_f_4lxml_5etree__documentFactory(__pyx_v_c_result, __pyx_v_input_doc->_parser)); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_result_doc));
  __pyx_v_result_doc = ((struct LxmlDocument *)__pyx_6);
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":536
 *         result_doc = _documentFactory(c_result, input_doc._parser)
 * 
 *         c_dict = c_result.dict             # <<<<<<<<<<<<<<
 *         __GLOBAL_PARSER_CONTEXT.initThreadDictRef(&c_result.dict)
 *         if c_dict is not c_result.dict or \
 */
  __pyx_v_c_dict = __pyx_v_c_result->dict;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":537
 * 
 *         c_dict = c_result.dict
 *         __GLOBAL_PARSER_CONTEXT.initThreadDictRef(&c_result.dict)             # <<<<<<<<<<<<<<
 *         if c_dict is not c_result.dict or \
 *                 self._c_style.doc.dict is not c_result.dict or \
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initThreadDictRef(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, (&__pyx_v_c_result->dict));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":538
 *         c_dict = c_result.dict
 *         __GLOBAL_PARSER_CONTEXT.initThreadDictRef(&c_result.dict)
 *         if c_dict is not c_result.dict or \             # <<<<<<<<<<<<<<
 *                 self._c_style.doc.dict is not c_result.dict or \
 *                 input_doc._c_doc.dict is not c_result.dict:
 */
  __pyx_3 = (__pyx_v_c_dict != __pyx_v_c_result->dict);
  if (!__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":539
 *         __GLOBAL_PARSER_CONTEXT.initThreadDictRef(&c_result.dict)
 *         if c_dict is not c_result.dict or \
 *                 self._c_style.doc.dict is not c_result.dict or \             # <<<<<<<<<<<<<<
 *                 input_doc._c_doc.dict is not c_result.dict:
 *             with nogil:
 */
    __pyx_3 = (((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_c_style->doc->dict != __pyx_v_c_result->dict);
    if (!__pyx_3) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":540
 *         if c_dict is not c_result.dict or \
 *                 self._c_style.doc.dict is not c_result.dict or \
 *                 input_doc._c_doc.dict is not c_result.dict:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 if c_dict is not c_result.dict:
 */
      __pyx_3 = (__pyx_v_input_doc->_c_doc->dict != __pyx_v_c_result->dict);
    }
  }
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":541
 *                 self._c_style.doc.dict is not c_result.dict or \
 *                 input_doc._c_doc.dict is not c_result.dict:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 if c_dict is not c_result.dict:
 *                     fixThreadDictNames(<xmlNode*>c_result,
 */
    /*with nogil:*/ {
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":542
 *                 input_doc._c_doc.dict is not c_result.dict:
 *             with nogil:
 *                 if c_dict is not c_result.dict:             # <<<<<<<<<<<<<<
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        c_dict, c_result.dict)
 */
        __pyx_5 = (__pyx_v_c_dict != __pyx_v_c_result->dict);
        if (__pyx_5) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":544
 *                 if c_dict is not c_result.dict:
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        c_dict, c_result.dict)             # <<<<<<<<<<<<<<
 *                 if self._c_style.doc.dict is not c_result.dict:
 *                     fixThreadDictNames(<xmlNode*>c_result,
 */
          __pyx_f_4lxml_5etree_fixThreadDictNames(((xmlNode *)__pyx_v_c_result), __pyx_v_c_dict, __pyx_v_c_result->dict);
          goto __pyx_L34;
        }
        __pyx_L34:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":545
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        c_dict, c_result.dict)
 *                 if self._c_style.doc.dict is not c_result.dict:             # <<<<<<<<<<<<<<
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        self._c_style.doc.dict, c_result.dict)
 */
        __pyx_3 = (((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_c_style->doc->dict != __pyx_v_c_result->dict);
        if (__pyx_3) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":547
 *                 if self._c_style.doc.dict is not c_result.dict:
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        self._c_style.doc.dict, c_result.dict)             # <<<<<<<<<<<<<<
 *                 if input_doc._c_doc.dict is not c_result.dict:
 *                     fixThreadDictNames(<xmlNode*>c_result,
 */
          __pyx_f_4lxml_5etree_fixThreadDictNames(((xmlNode *)__pyx_v_c_result), ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self)->_c_style->doc->dict, __pyx_v_c_result->dict);
          goto __pyx_L35;
        }
        __pyx_L35:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":548
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        self._c_style.doc.dict, c_result.dict)
 *                 if input_doc._c_doc.dict is not c_result.dict:             # <<<<<<<<<<<<<<
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        input_doc._c_doc.dict, c_result.dict)
 */
        __pyx_5 = (__pyx_v_input_doc->_c_doc->dict != __pyx_v_c_result->dict);
        if (__pyx_5) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":550
 *                 if input_doc._c_doc.dict is not c_result.dict:
 *                     fixThreadDictNames(<xmlNode*>c_result,
 *                                        input_doc._c_doc.dict, c_result.dict)             # <<<<<<<<<<<<<<
 * 
 *         return _xsltResultTreeFactory(result_doc, self, profile_doc)
 */
          __pyx_f_4lxml_5etree_fixThreadDictNames(((xmlNode *)__pyx_v_c_result), __pyx_v_input_doc->_c_doc->dict, __pyx_v_c_result->dict);
          goto __pyx_L36;
        }
        __pyx_L36:;
      }
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
    }
    goto __pyx_L30;
  }
  __pyx_L30:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":552
 *                                        input_doc._c_doc.dict, c_result.dict)
 * 
 *         return _xsltResultTreeFactory(result_doc, self, profile_doc)             # <<<<<<<<<<<<<<
 * 
 *     cdef xmlDoc* _run_transform(self, xmlDoc* c_input_doc,
 */
  __pyx_7 = __pyx_f_4lxml_5etree__xsltResultTreeFactory(__pyx_v_result_doc, ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_v_self), __pyx_v_profile_doc); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_7;
  __pyx_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("lxml.etree.XSLT.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_kw);
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF((PyObject *)__pyx_v_resolver_context);
  Py_DECREF(__pyx_v_input_doc);
  Py_DECREF(__pyx_v_root_node);
  Py_DECREF(__pyx_v_result_doc);
  Py_DECREF(__pyx_v_profile_doc);
  Py_DECREF(__pyx_v_error);
  Py_DECREF(__pyx_v_message);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":554
 *         return _xsltResultTreeFactory(result_doc, self, profile_doc)
 * 
 *     cdef xmlDoc* _run_transform(self, xmlDoc* c_input_doc,             # <<<<<<<<<<<<<<
 *                                 parameters, _XSLTContext context,
 *                                 xslt.xsltTransformContext* transform_ctxt):
 */

static  xmlDoc *__pyx_f_4lxml_5etree_4XSLT__run_transform(struct __pyx_obj_4lxml_5etree_XSLT *__pyx_v_self, xmlDoc *__pyx_v_c_input_doc, PyObject *__pyx_v_parameters, struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_context, xsltTransformContext *__pyx_v_transform_ctxt) {
  xmlDoc *__pyx_v_c_result;
  char **__pyx_v_params;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_parameter_count;
  PyObject *__pyx_v_keep_ref;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_v_k;
  PyObject *__pyx_v_v;
  xmlDoc *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_ssize_t __pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  __pyx_v_keep_ref = Py_None; Py_INCREF(Py_None);
  __pyx_v_key = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);
  __pyx_v_k = Py_None; Py_INCREF(Py_None);
  __pyx_v_v = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":562
 * 
 *         xslt.xsltSetTransformErrorFunc(transform_ctxt, <void*>self._error_log,
 *                                        _receiveXSLTError)             # <<<<<<<<<<<<<<
 * 
 *         if self._access_control is not None:
 */
  xsltSetTransformErrorFunc(__pyx_v_transform_ctxt, ((void *)__pyx_v_self->_error_log), __pyx_f_4lxml_5etree__receiveXSLTError);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":564
 *                                        _receiveXSLTError)
 * 
 *         if self._access_control is not None:             # <<<<<<<<<<<<<<
 *             self._access_control._register_in_context(transform_ctxt)
 * 
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->_access_control) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":565
 * 
 *         if self._access_control is not None:
 *             self._access_control._register_in_context(transform_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         parameter_count = python.PyDict_Size(parameters)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl *)__pyx_v_self->_access_control->__pyx_vtab)->_register_in_context(__pyx_v_self->_access_control, __pyx_v_transform_ctxt);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":567
 *             self._access_control._register_in_context(transform_ctxt)
 * 
 *         parameter_count = python.PyDict_Size(parameters)             # <<<<<<<<<<<<<<
 *         if parameter_count > 0:
 *             # allocate space for parameters
 */
  __pyx_v_parameter_count = PyDict_Size(__pyx_v_parameters);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":568
 * 
 *         parameter_count = python.PyDict_Size(parameters)
 *         if parameter_count > 0:             # <<<<<<<<<<<<<<
 *             # allocate space for parameters
 *             # * 2 as we want an entry for both key and value,
 */
  __pyx_1 = (__pyx_v_parameter_count > 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":573
 *             # and + 1 as array is NULL terminated
 *             params = <char**>python.PyMem_Malloc(
 *                 sizeof(char*) * (parameter_count * 2 + 1))             # <<<<<<<<<<<<<<
 *             try:
 *                 i = 0
 */
    __pyx_v_params = ((char **)PyMem_Malloc(((sizeof(char *)) * ((__pyx_v_parameter_count * 2) + 1))));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":574
 *             params = <char**>python.PyMem_Malloc(
 *                 sizeof(char*) * (parameter_count * 2 + 1))
 *             try:             # <<<<<<<<<<<<<<
 *                 i = 0
 *                 keep_ref = []
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":575
 *                 sizeof(char*) * (parameter_count * 2 + 1))
 *             try:
 *                 i = 0             # <<<<<<<<<<<<<<
 *                 keep_ref = []
 *                 for key, value in parameters.items():
 */
        __pyx_v_i = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":576
 *             try:
 *                 i = 0
 *                 keep_ref = []             # <<<<<<<<<<<<<<
 *                 for key, value in parameters.items():
 *                     k = _utf8(key)
 */
        __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_v_keep_ref);
        __pyx_v_keep_ref = ((PyObject *)__pyx_2);
        __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":577
 *                 i = 0
 *                 keep_ref = []
 *                 for key, value in parameters.items():             # <<<<<<<<<<<<<<
 *                     k = _utf8(key)
 *                     python.PyList_Append(keep_ref, k)
 */
        __pyx_2 = PyObject_GetAttr(__pyx_v_parameters, __pyx_kp_items); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        if (PyList_CheckExact(__pyx_4) || PyTuple_CheckExact(__pyx_4)) {
          __pyx_3 = 0; __pyx_2 = __pyx_4; Py_INCREF(__pyx_2);
        } else {
          __pyx_3 = -1; __pyx_2 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        }
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        for (;;) {
          if (likely(PyList_CheckExact(__pyx_2))) {
            if (__pyx_3 >= PyList_GET_SIZE(__pyx_2)) break;
            __pyx_4 = PyList_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
          } else if (likely(PyTuple_CheckExact(__pyx_2))) {
            if (__pyx_3 >= PyTuple_GET_SIZE(__pyx_2)) break;
            __pyx_4 = PyTuple_GET_ITEM(__pyx_2, __pyx_3); Py_INCREF(__pyx_4); __pyx_3++;
          } else {
            __pyx_4 = PyIter_Next(__pyx_2);
            if (!__pyx_4) {
              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              break;
            }
          }
          if (PyTuple_CheckExact(__pyx_4) && PyTuple_GET_SIZE(__pyx_4) == 2) {
            PyObject* tuple = __pyx_4;
            __pyx_6 = PyTuple_GET_ITEM(tuple, 0);
            Py_INCREF(__pyx_6);
            Py_DECREF(__pyx_v_key);
            __pyx_v_key = __pyx_6;
            __pyx_6 = 0;
            __pyx_6 = PyTuple_GET_ITEM(tuple, 1);
            Py_INCREF(__pyx_6);
            Py_DECREF(__pyx_v_value);
            __pyx_v_value = __pyx_6;
            __pyx_6 = 0;
            Py_DECREF(__pyx_4); __pyx_4 = 0;
          }
          else {
            __pyx_5 = PyObject_GetIter(__pyx_4); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_4); __pyx_4 = 0;
            __pyx_6 = __Pyx_UnpackItem(__pyx_5, 0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_v_key);
            __pyx_v_key = __pyx_6;
            __pyx_6 = 0;
            __pyx_6 = __Pyx_UnpackItem(__pyx_5, 1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_v_value);
            __pyx_v_value = __pyx_6;
            __pyx_6 = 0;
            if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            Py_DECREF(__pyx_5); __pyx_5 = 0;
          }

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":578
 *                 keep_ref = []
 *                 for key, value in parameters.items():
 *                     k = _utf8(key)             # <<<<<<<<<<<<<<
 *                     python.PyList_Append(keep_ref, k)
 *                     v = _utf8(value)
 */
          __pyx_6 = __pyx_f_4lxml_5etree__utf8(__pyx_v_key); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          Py_DECREF(__pyx_v_k);
          __pyx_v_k = __pyx_6;
          __pyx_6 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":579
 *                 for key, value in parameters.items():
 *                     k = _utf8(key)
 *                     python.PyList_Append(keep_ref, k)             # <<<<<<<<<<<<<<
 *                     v = _utf8(value)
 *                     python.PyList_Append(keep_ref, v)
 */
          __pyx_7 = PyList_Append(__pyx_v_keep_ref, __pyx_v_k); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L5_error;}

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":580
 *                     k = _utf8(key)
 *                     python.PyList_Append(keep_ref, k)
 *                     v = _utf8(value)             # <<<<<<<<<<<<<<
 *                     python.PyList_Append(keep_ref, v)
 *                     params[i] = _cstr(k)
 */
          __pyx_4 = __pyx_f_4lxml_5etree__utf8(__pyx_v_value); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          Py_DECREF(__pyx_v_v);
          __pyx_v_v = __pyx_4;
          __pyx_4 = 0;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":581
 *                     python.PyList_Append(keep_ref, k)
 *                     v = _utf8(value)
 *                     python.PyList_Append(keep_ref, v)             # <<<<<<<<<<<<<<
 *                     params[i] = _cstr(k)
 *                     i += 1
 */
          __pyx_7 = PyList_Append(__pyx_v_keep_ref, __pyx_v_v); if (unlikely(__pyx_7 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L5_error;}

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":582
 *                     v = _utf8(value)
 *                     python.PyList_Append(keep_ref, v)
 *                     params[i] = _cstr(k)             # <<<<<<<<<<<<<<
 *                     i += 1
 *                     params[i] = _cstr(v)
 */
          (__pyx_v_params[__pyx_v_i]) = PyString_AS_STRING(__pyx_v_k);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":583
 *                     python.PyList_Append(keep_ref, v)
 *                     params[i] = _cstr(k)
 *                     i += 1             # <<<<<<<<<<<<<<
 *                     params[i] = _cstr(v)
 *                     i += 1
 */
          __pyx_v_i += 1;

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":584
 *                     params[i] = _cstr(k)
 *                     i += 1
 *                     params[i] = _cstr(v)             # <<<<<<<<<<<<<<
 *                     i += 1
 *             except:
 */
          (__pyx_v_params[__pyx_v_i]) = PyString_AS_STRING(__pyx_v_v);

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":585
 *                     i += 1
 *                     params[i] = _cstr(v)
 *                     i += 1             # <<<<<<<<<<<<<<
 *             except:
 *                 python.PyMem_Free(params)
 */
          __pyx_v_i += 1;
        }
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L9_try;
      __pyx_L5_error:;
      Py_XDECREF(__pyx_5); __pyx_5 = 0;
      Py_XDECREF(__pyx_6); __pyx_6 = 0;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":586
 *                     params[i] = _cstr(v)
 *                     i += 1
 *             except:             # <<<<<<<<<<<<<<
 *                 python.PyMem_Free(params)
 *                 raise
 */
      /*except:*/ {
        __Pyx_AddTraceback("lxml.etree._run_transform");
        if (__Pyx_GetException(&__pyx_5, &__pyx_6, &__pyx_4) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":587
 *                     i += 1
 *             except:
 *                 python.PyMem_Free(params)             # <<<<<<<<<<<<<<
 *                 raise
 *             params[i] = NULL
 */
        PyMem_Free(__pyx_v_params);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":588
 *             except:
 *                 python.PyMem_Free(params)
 *                 raise             # <<<<<<<<<<<<<<
 *             params[i] = NULL
 *         else:
 */
        __Pyx_Raise(__pyx_5, __pyx_6, __pyx_4);
        {__pyx_filename = __pyx_f[17]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        goto __pyx_L6_exception_handled;
      }
      __pyx_L7_except_error:;
      Py_XDECREF(__pyx_save_exc_type);
      Py_XDECREF(__pyx_save_exc_value);
      Py_XDECREF(__pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L6_exception_handled:;
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L9_try:;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":589
 *                 python.PyMem_Free(params)
 *                 raise
 *             params[i] = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             params = NULL
 */
    (__pyx_v_params[__pyx_v_i]) = NULL;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":591
 *             params[i] = NULL
 *         else:
 *             params = NULL             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_params = NULL;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":593
 *             params = NULL
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             c_result = xslt.xsltApplyStylesheetUser(
 *                 self._c_style, c_input_doc, params, NULL, NULL, transform_ctxt)
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":595
 *         with nogil:
 *             c_result = xslt.xsltApplyStylesheetUser(
 *                 self._c_style, c_input_doc, params, NULL, NULL, transform_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         if params is not NULL:
 */
      __pyx_v_c_result = xsltApplyStylesheetUser(__pyx_v_self->_c_style, __pyx_v_c_input_doc, __pyx_v_params, NULL, NULL, __pyx_v_transform_ctxt);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":597
 *                 self._c_style, c_input_doc, params, NULL, NULL, transform_ctxt)
 * 
 *         if params is not NULL:             # <<<<<<<<<<<<<<
 *             # deallocate space for parameters
 *             python.PyMem_Free(params)
 */
  __pyx_1 = (__pyx_v_params != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":599
 *         if params is not NULL:
 *             # deallocate space for parameters
 *             python.PyMem_Free(params)             # <<<<<<<<<<<<<<
 * 
 *         return c_result
 */
    PyMem_Free(__pyx_v_params);
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":601
 *             python.PyMem_Free(params)
 * 
 *         return c_result             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "etree_defs.h":
 */
  __pyx_r = __pyx_v_c_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("lxml.etree.XSLT._run_transform");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_keep_ref);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_k);
  Py_DECREF(__pyx_v_v);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":607
 *     cdef XSLT NEW_XSLT "PY_NEW" (object t)
 * 
 * cdef XSLT _copyXSLT(XSLT stylesheet):             # <<<<<<<<<<<<<<
 *     cdef XSLT new_xslt
 *     cdef xmlDoc* c_doc
 */

static  struct __pyx_obj_4lxml_5etree_XSLT *__pyx_f_4lxml_5etree__copyXSLT(struct __pyx_obj_4lxml_5etree_XSLT *__pyx_v_stylesheet) {
  struct __pyx_obj_4lxml_5etree_XSLT *__pyx_v_new_xslt;
  xmlDoc *__pyx_v_c_doc;
  struct __pyx_obj_4lxml_5etree_XSLT *__pyx_r;
  PyObject *__pyx_1 = 0;
  xmlDoc *__pyx_2;
  int __pyx_3;
  __pyx_v_new_xslt = ((struct __pyx_obj_4lxml_5etree_XSLT *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":610
 *     cdef XSLT new_xslt
 *     cdef xmlDoc* c_doc
 *     new_xslt = NEW_XSLT(XSLT) # without calling __init__()             # <<<<<<<<<<<<<<
 *     new_xslt._access_control = stylesheet._access_control
 *     new_xslt._error_log = _ErrorLog()
 */
  __pyx_1 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XSLT)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_new_xslt));
  __pyx_v_new_xslt = ((struct __pyx_obj_4lxml_5etree_XSLT *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":611
 *     cdef xmlDoc* c_doc
 *     new_xslt = NEW_XSLT(XSLT) # without calling __init__()
 *     new_xslt._access_control = stylesheet._access_control             # <<<<<<<<<<<<<<
 *     new_xslt._error_log = _ErrorLog()
 *     new_xslt._context = stylesheet._context._copy()
 */
  Py_INCREF(((PyObject *)__pyx_v_stylesheet->_access_control));
  Py_DECREF(((PyObject *)__pyx_v_new_xslt->_access_control));
  __pyx_v_new_xslt->_access_control = __pyx_v_stylesheet->_access_control;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":612
 *     new_xslt = NEW_XSLT(XSLT) # without calling __init__()
 *     new_xslt._access_control = stylesheet._access_control
 *     new_xslt._error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 *     new_xslt._context = stylesheet._context._copy()
 * 
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_new_xslt->_error_log));
  __pyx_v_new_xslt->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":613
 *     new_xslt._access_control = stylesheet._access_control
 *     new_xslt._error_log = _ErrorLog()
 *     new_xslt._context = stylesheet._context._copy()             # <<<<<<<<<<<<<<
 * 
 *     new_xslt._xslt_resolver_context = stylesheet._xslt_resolver_context._copy()
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__XSLTContext *)__pyx_v_stylesheet->_context->__pyx_base.__pyx_vtab)->__pyx_base._copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__XSLTContext))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_new_xslt->_context));
  __pyx_v_new_xslt->_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":615
 *     new_xslt._context = stylesheet._context._copy()
 * 
 *     new_xslt._xslt_resolver_context = stylesheet._xslt_resolver_context._copy()             # <<<<<<<<<<<<<<
 *     new_xslt._xslt_resolver_context._c_style_doc = _copyDoc(
 *         stylesheet._xslt_resolver_context._c_style_doc, 1)
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext *)__pyx_v_stylesheet->_xslt_resolver_context->__pyx_base.__pyx_base.__pyx_vtab)->_copy(__pyx_v_stylesheet->_xslt_resolver_context)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_new_xslt->_xslt_resolver_context));
  __pyx_v_new_xslt->_xslt_resolver_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":617
 *     new_xslt._xslt_resolver_context = stylesheet._xslt_resolver_context._copy()
 *     new_xslt._xslt_resolver_context._c_style_doc = _copyDoc(
 *         stylesheet._xslt_resolver_context._c_style_doc, 1)             # <<<<<<<<<<<<<<
 * 
 *     c_doc = _copyDoc(stylesheet._c_style.doc, 1)
 */
  __pyx_2 = __pyx_f_4lxml_5etree__copyDoc(__pyx_v_stylesheet->_xslt_resolver_context->_c_style_doc, 1); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":616
 * 
 *     new_xslt._xslt_resolver_context = stylesheet._xslt_resolver_context._copy()
 *     new_xslt._xslt_resolver_context._c_style_doc = _copyDoc(             # <<<<<<<<<<<<<<
 *         stylesheet._xslt_resolver_context._c_style_doc, 1)
 * 
 */
  __pyx_v_new_xslt->_xslt_resolver_context->_c_style_doc = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":619
 *         stylesheet._xslt_resolver_context._c_style_doc, 1)
 * 
 *     c_doc = _copyDoc(stylesheet._c_style.doc, 1)             # <<<<<<<<<<<<<<
 *     new_xslt._c_style = xslt.xsltParseStylesheetDoc(c_doc)
 *     if new_xslt._c_style is NULL:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__copyDoc(__pyx_v_stylesheet->_c_style->doc, 1); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":620
 * 
 *     c_doc = _copyDoc(stylesheet._c_style.doc, 1)
 *     new_xslt._c_style = xslt.xsltParseStylesheetDoc(c_doc)             # <<<<<<<<<<<<<<
 *     if new_xslt._c_style is NULL:
 *         tree.xmlFreeDoc(c_doc)
 */
  __pyx_v_new_xslt->_c_style = xsltParseStylesheetDoc(__pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":621
 *     c_doc = _copyDoc(stylesheet._c_style.doc, 1)
 *     new_xslt._c_style = xslt.xsltParseStylesheetDoc(c_doc)
 *     if new_xslt._c_style is NULL:             # <<<<<<<<<<<<<<
 *         tree.xmlFreeDoc(c_doc)
 *         python.PyErr_NoMemory()
 */
  __pyx_3 = (__pyx_v_new_xslt->_c_style == NULL);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":622
 *     new_xslt._c_style = xslt.xsltParseStylesheetDoc(c_doc)
 *     if new_xslt._c_style is NULL:
 *         tree.xmlFreeDoc(c_doc)             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 * 
 */
    xmlFreeDoc(__pyx_v_c_doc);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":623
 *     if new_xslt._c_style is NULL:
 *         tree.xmlFreeDoc(c_doc)
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *     return new_xslt
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":625
 *         python.PyErr_NoMemory()
 * 
 *     return new_xslt             # <<<<<<<<<<<<<<
 * 
 * cdef class _XSLTResultTree(_ElementTree):
 */
  Py_INCREF(((PyObject *)__pyx_v_new_xslt));
  __pyx_r = __pyx_v_new_xslt;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree_XSLT *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._copyXSLT");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_new_xslt);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":633
 *     cdef Py_ssize_t _buffer_len
 *     cdef Py_ssize_t _buffer_refcnt
 *     cdef _saveToStringAndSize(self, char** s, int* l):             # <<<<<<<<<<<<<<
 *         cdef _Document doc
 *         cdef int r
 */

static  PyObject *__pyx_f_4lxml_5etree_15_XSLTResultTree__saveToStringAndSize(struct __pyx_obj_4lxml_5etree__XSLTResultTree *__pyx_v_self, char **__pyx_v_s, int *__pyx_v_l) {
  struct LxmlDocument *__pyx_v_doc;
  int __pyx_v_r;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":636
 *         cdef _Document doc
 *         cdef int r
 *         if self._context_node is not None:             # <<<<<<<<<<<<<<
 *             doc = self._context_node._doc
 *         if doc is None:
 */
  __pyx_1 = (((PyObject *)__pyx_v_self->__pyx_base._context_node) != Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":637
 *         cdef int r
 *         if self._context_node is not None:
 *             doc = self._context_node._doc             # <<<<<<<<<<<<<<
 *         if doc is None:
 *             doc = self._doc
 */
    Py_INCREF(((PyObject *)__pyx_v_self->__pyx_base._context_node->_doc));
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = __pyx_v_self->__pyx_base._context_node->_doc;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":638
 *         if self._context_node is not None:
 *             doc = self._context_node._doc
 *         if doc is None:             # <<<<<<<<<<<<<<
 *             doc = self._doc
 *             if doc is None:
 */
  __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":639
 *             doc = self._context_node._doc
 *         if doc is None:
 *             doc = self._doc             # <<<<<<<<<<<<<<
 *             if doc is None:
 *                 s[0] = NULL
 */
    Py_INCREF(((PyObject *)__pyx_v_self->__pyx_base._doc));
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = __pyx_v_self->__pyx_base._doc;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":640
 *         if doc is None:
 *             doc = self._doc
 *             if doc is None:             # <<<<<<<<<<<<<<
 *                 s[0] = NULL
 *                 return
 */
    __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":641
 *             doc = self._doc
 *             if doc is None:
 *                 s[0] = NULL             # <<<<<<<<<<<<<<
 *                 return
 *         with nogil:
 */
      (__pyx_v_s[0]) = NULL;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":642
 *             if doc is None:
 *                 s[0] = NULL
 *                 return             # <<<<<<<<<<<<<<
 *         with nogil:
 *             r = xslt.xsltSaveResultToString(s, l, doc._c_doc,
 */
      __pyx_r = Py_None; Py_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":643
 *                 s[0] = NULL
 *                 return
 *         with nogil:             # <<<<<<<<<<<<<<
 *             r = xslt.xsltSaveResultToString(s, l, doc._c_doc,
 *                                             self._xslt._c_style)
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":645
 *         with nogil:
 *             r = xslt.xsltSaveResultToString(s, l, doc._c_doc,
 *                                             self._xslt._c_style)             # <<<<<<<<<<<<<<
 *         if r == -1:
 *             python.PyErr_NoMemory()
 */
      __pyx_v_r = xsltSaveResultToString(__pyx_v_s, __pyx_v_l, __pyx_v_doc->_c_doc, __pyx_v_self->_xslt->_c_style);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":646
 *             r = xslt.xsltSaveResultToString(s, l, doc._c_doc,
 *                                             self._xslt._c_style)
 *         if r == -1:             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 * 
 */
  __pyx_1 = (__pyx_v_r == -1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":647
 *                                             self._xslt._c_style)
 *         if r == -1:
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._XSLTResultTree._saveToStringAndSize");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":649
 *             python.PyErr_NoMemory()
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         cdef char* s
 *         cdef int l
 */

static PyObject *__pyx_pf_4lxml_5etree_15_XSLTResultTree___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_15_XSLTResultTree___str__(PyObject *__pyx_v_self) {
  char *__pyx_v_s;
  int __pyx_v_l;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":652
 *         cdef char* s
 *         cdef int l
 *         if python.IS_PYTHON3:             # <<<<<<<<<<<<<<
 *             return self.__unicode__()
 *         self._saveToStringAndSize(&s, &l)
 */
  __pyx_1 = IS_PYTHON3;
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":653
 *         cdef int l
 *         if python.IS_PYTHON3:
 *             return self.__unicode__()             # <<<<<<<<<<<<<<
 *         self._saveToStringAndSize(&s, &l)
 *         if s is NULL:
 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___unicode__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":654
 *         if python.IS_PYTHON3:
 *             return self.__unicode__()
 *         self._saveToStringAndSize(&s, &l)             # <<<<<<<<<<<<<<
 *         if s is NULL:
 *             return ''
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResultTree *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_saveToStringAndSize(((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self), (&__pyx_v_s), (&__pyx_v_l)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":655
 *             return self.__unicode__()
 *         self._saveToStringAndSize(&s, &l)
 *         if s is NULL:             # <<<<<<<<<<<<<<
 *             return ''
 *         # we must not use 'funicode' here as this is not always UTF-8
 */
  __pyx_1 = (__pyx_v_s == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":656
 *         self._saveToStringAndSize(&s, &l)
 *         if s is NULL:
 *             return ''             # <<<<<<<<<<<<<<
 *         # we must not use 'funicode' here as this is not always UTF-8
 *         try:
 */
    Py_INCREF(__pyx_kp_588);
    __pyx_r = __pyx_kp_588;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":658
 *             return ''
 *         # we must not use 'funicode' here as this is not always UTF-8
 *         try:             # <<<<<<<<<<<<<<
 *             result = python.PyString_FromStringAndSize(s, l)
 *         finally:
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":659
 *         # we must not use 'funicode' here as this is not always UTF-8
 *         try:
 *             result = python.PyString_FromStringAndSize(s, l)             # <<<<<<<<<<<<<<
 *         finally:
 *             tree.xmlFree(s)
 */
    __pyx_3 = PyString_FromStringAndSize(__pyx_v_s, __pyx_v_l); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L8;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_3;
    __pyx_3 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L9;
    __pyx_L8: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":661
 *             result = python.PyString_FromStringAndSize(s, l)
 *         finally:
 *             tree.xmlFree(s)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    xmlFree(__pyx_v_s);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":662
 *         finally:
 *             tree.xmlFree(s)
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def __unicode__(self):
 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._XSLTResultTree.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":664
 *         return result
 * 
 *     def __unicode__(self):             # <<<<<<<<<<<<<<
 *         cdef char* encoding
 *         cdef char* s
 */

static PyObject *__pyx_pf_4lxml_5etree_15_XSLTResultTree___unicode__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_15_XSLTResultTree___unicode__(PyObject *__pyx_v_self, PyObject *unused) {
  char *__pyx_v_encoding;
  char *__pyx_v_s;
  int __pyx_v_l;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":668
 *         cdef char* s
 *         cdef int l
 *         self._saveToStringAndSize(&s, &l)             # <<<<<<<<<<<<<<
 *         if s is NULL:
 *             return u''
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResultTree *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_saveToStringAndSize(((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self), (&__pyx_v_s), (&__pyx_v_l)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":669
 *         cdef int l
 *         self._saveToStringAndSize(&s, &l)
 *         if s is NULL:             # <<<<<<<<<<<<<<
 *             return u''
 *         encoding = self._xslt._c_style.encoding
 */
  __pyx_2 = (__pyx_v_s == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":670
 *         self._saveToStringAndSize(&s, &l)
 *         if s is NULL:
 *             return u''             # <<<<<<<<<<<<<<
 *         encoding = self._xslt._c_style.encoding
 *         if encoding is NULL:
 */
    Py_INCREF(((PyObject *)__pyx_kp_589));
    __pyx_r = ((PyObject *)__pyx_kp_589);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":671
 *         if s is NULL:
 *             return u''
 *         encoding = self._xslt._c_style.encoding             # <<<<<<<<<<<<<<
 *         if encoding is NULL:
 *             encoding = 'ascii'
 */
  __pyx_v_encoding = ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_xslt->_c_style->encoding;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":672
 *             return u''
 *         encoding = self._xslt._c_style.encoding
 *         if encoding is NULL:             # <<<<<<<<<<<<<<
 *             encoding = 'ascii'
 *         try:
 */
  __pyx_2 = (__pyx_v_encoding == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":673
 *         encoding = self._xslt._c_style.encoding
 *         if encoding is NULL:
 *             encoding = 'ascii'             # <<<<<<<<<<<<<<
 *         try:
 *             result = python.PyUnicode_Decode(s, l, encoding, 'strict')
 */
    __pyx_v_encoding = __pyx_k_590;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":674
 *         if encoding is NULL:
 *             encoding = 'ascii'
 *         try:             # <<<<<<<<<<<<<<
 *             result = python.PyUnicode_Decode(s, l, encoding, 'strict')
 *         finally:
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":675
 *             encoding = 'ascii'
 *         try:
 *             result = python.PyUnicode_Decode(s, l, encoding, 'strict')             # <<<<<<<<<<<<<<
 *         finally:
 *             tree.xmlFree(s)
 */
    __pyx_1 = PyUnicode_Decode(__pyx_v_s, __pyx_v_l, __pyx_v_encoding, __pyx_k_591); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L8;}
    Py_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_1;
    __pyx_1 = 0;
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L9;
    __pyx_L8: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":677
 *             result = python.PyUnicode_Decode(s, l, encoding, 'strict')
 *         finally:
 *             tree.xmlFree(s)             # <<<<<<<<<<<<<<
 *         return _stripEncodingDeclaration(result)
 * 
 */
    xmlFree(__pyx_v_s);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":678
 *         finally:
 *             tree.xmlFree(s)
 *         return _stripEncodingDeclaration(result)             # <<<<<<<<<<<<<<
 * 
 *     def __getbuffer__(self, Py_buffer* buffer, int flags):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__stripEncodingDeclaration(__pyx_v_result); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._XSLTResultTree.__unicode__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":680
 *         return _stripEncodingDeclaration(result)
 * 
 *     def __getbuffer__(self, Py_buffer* buffer, int flags):             # <<<<<<<<<<<<<<
 *         cdef int l
 *         if buffer is NULL:
 */

static int __pyx_pf_4lxml_5etree_15_XSLTResultTree___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer, int __pyx_v_flags); /*proto*/
static int __pyx_pf_4lxml_5etree_15_XSLTResultTree___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer, int __pyx_v_flags) {
  int __pyx_v_l;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  if (__pyx_v_buffer == NULL) return 0;
  __pyx_v_buffer->obj = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":682
 *     def __getbuffer__(self, Py_buffer* buffer, int flags):
 *         cdef int l
 *         if buffer is NULL:             # <<<<<<<<<<<<<<
 *             return # LOCK
 *         if self._buffer is NULL or flags & python.PyBUF_WRITABLE:
 */
  __pyx_1 = (__pyx_v_buffer == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":683
 *         cdef int l
 *         if buffer is NULL:
 *             return # LOCK             # <<<<<<<<<<<<<<
 *         if self._buffer is NULL or flags & python.PyBUF_WRITABLE:
 *             self._saveToStringAndSize(<char**>&buffer.buf, &l)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":684
 *         if buffer is NULL:
 *             return # LOCK
 *         if self._buffer is NULL or flags & python.PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
 *             self._saveToStringAndSize(<char**>&buffer.buf, &l)
 *             buffer.len = l
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer == NULL);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_flags & PyBUF_WRITABLE);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":685
 *             return # LOCK
 *         if self._buffer is NULL or flags & python.PyBUF_WRITABLE:
 *             self._saveToStringAndSize(<char**>&buffer.buf, &l)             # <<<<<<<<<<<<<<
 *             buffer.len = l
 *             if self._buffer is NULL and not flags & python.PyBUF_WRITABLE:
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__XSLTResultTree *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_saveToStringAndSize(((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self), ((char **)(&__pyx_v_buffer->buf)), (&__pyx_v_l)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":686
 *         if self._buffer is NULL or flags & python.PyBUF_WRITABLE:
 *             self._saveToStringAndSize(<char**>&buffer.buf, &l)
 *             buffer.len = l             # <<<<<<<<<<<<<<
 *             if self._buffer is NULL and not flags & python.PyBUF_WRITABLE:
 *                 self._buffer = <char*>buffer.buf
 */
    __pyx_v_buffer->len = __pyx_v_l;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":687
 *             self._saveToStringAndSize(<char**>&buffer.buf, &l)
 *             buffer.len = l
 *             if self._buffer is NULL and not flags & python.PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
 *                 self._buffer = <char*>buffer.buf
 *                 self._buffer_len = l
 */
    __pyx_1 = (((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer == NULL);
    if (__pyx_1) {
      __pyx_1 = (!(__pyx_v_flags & PyBUF_WRITABLE));
    }
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":688
 *             buffer.len = l
 *             if self._buffer is NULL and not flags & python.PyBUF_WRITABLE:
 *                 self._buffer = <char*>buffer.buf             # <<<<<<<<<<<<<<
 *                 self._buffer_len = l
 *                 self._buffer_refcnt = 1
 */
      ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer = ((char *)__pyx_v_buffer->buf);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":689
 *             if self._buffer is NULL and not flags & python.PyBUF_WRITABLE:
 *                 self._buffer = <char*>buffer.buf
 *                 self._buffer_len = l             # <<<<<<<<<<<<<<
 *                 self._buffer_refcnt = 1
 *         else:
 */
      ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer_len = __pyx_v_l;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":690
 *                 self._buffer = <char*>buffer.buf
 *                 self._buffer_len = l
 *                 self._buffer_refcnt = 1             # <<<<<<<<<<<<<<
 *         else:
 *             buffer.buf = <char*>self._buffer
 */
      ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer_refcnt = 1;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":692
 *                 self._buffer_refcnt = 1
 *         else:
 *             buffer.buf = <char*>self._buffer             # <<<<<<<<<<<<<<
 *             buffer.len = self._buffer_len
 *             self._buffer_refcnt += 1
 */
    __pyx_v_buffer->buf = ((char *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":693
 *         else:
 *             buffer.buf = <char*>self._buffer
 *             buffer.len = self._buffer_len             # <<<<<<<<<<<<<<
 *             self._buffer_refcnt += 1
 *         if flags & python.PyBUF_WRITABLE:
 */
    __pyx_v_buffer->len = ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer_len;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":694
 *             buffer.buf = <char*>self._buffer
 *             buffer.len = self._buffer_len
 *             self._buffer_refcnt += 1             # <<<<<<<<<<<<<<
 *         if flags & python.PyBUF_WRITABLE:
 *             buffer.readonly = 0
 */
    ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer_refcnt += 1;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":695
 *             buffer.len = self._buffer_len
 *             self._buffer_refcnt += 1
 *         if flags & python.PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
 *             buffer.readonly = 0
 *         else:
 */
  __pyx_3 = (__pyx_v_flags & PyBUF_WRITABLE);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":696
 *             self._buffer_refcnt += 1
 *         if flags & python.PyBUF_WRITABLE:
 *             buffer.readonly = 0             # <<<<<<<<<<<<<<
 *         else:
 *             buffer.readonly = 1
 */
    __pyx_v_buffer->readonly = 0;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":698
 *             buffer.readonly = 0
 *         else:
 *             buffer.readonly = 1             # <<<<<<<<<<<<<<
 *         if flags & python.PyBUF_FORMAT:
 *             buffer.format = "B"
 */
    __pyx_v_buffer->readonly = 1;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":699
 *         else:
 *             buffer.readonly = 1
 *         if flags & python.PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             buffer.format = "B"
 *         else:
 */
  __pyx_3 = (__pyx_v_flags & PyBUF_FORMAT);
  if (__pyx_3) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":700
 *             buffer.readonly = 1
 *         if flags & python.PyBUF_FORMAT:
 *             buffer.format = "B"             # <<<<<<<<<<<<<<
 *         else:
 *             buffer.format = NULL
 */
    __pyx_v_buffer->format = __pyx_k_592;
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":702
 *             buffer.format = "B"
 *         else:
 *             buffer.format = NULL             # <<<<<<<<<<<<<<
 *         buffer.ndim = 0
 *         buffer.shape = NULL
 */
    __pyx_v_buffer->format = NULL;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":703
 *         else:
 *             buffer.format = NULL
 *         buffer.ndim = 0             # <<<<<<<<<<<<<<
 *         buffer.shape = NULL
 *         buffer.strides = NULL
 */
  __pyx_v_buffer->ndim = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":704
 *             buffer.format = NULL
 *         buffer.ndim = 0
 *         buffer.shape = NULL             # <<<<<<<<<<<<<<
 *         buffer.strides = NULL
 *         buffer.suboffsets = NULL
 */
  __pyx_v_buffer->shape = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":705
 *         buffer.ndim = 0
 *         buffer.shape = NULL
 *         buffer.strides = NULL             # <<<<<<<<<<<<<<
 *         buffer.suboffsets = NULL
 *         buffer.itemsize = 1
 */
  __pyx_v_buffer->strides = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":706
 *         buffer.shape = NULL
 *         buffer.strides = NULL
 *         buffer.suboffsets = NULL             # <<<<<<<<<<<<<<
 *         buffer.itemsize = 1
 *         buffer.internal = NULL
 */
  __pyx_v_buffer->suboffsets = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":707
 *         buffer.strides = NULL
 *         buffer.suboffsets = NULL
 *         buffer.itemsize = 1             # <<<<<<<<<<<<<<
 *         buffer.internal = NULL
 * 
 */
  __pyx_v_buffer->itemsize = 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":708
 *         buffer.suboffsets = NULL
 *         buffer.itemsize = 1
 *         buffer.internal = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __releasebuffer__(self, Py_buffer* buffer):
 */
  __pyx_v_buffer->internal = NULL;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._XSLTResultTree.__getbuffer__");
  __pyx_r = -1;
  Py_DECREF(__pyx_v_buffer->obj); __pyx_v_buffer->obj = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_buffer->obj == Py_None) { Py_DECREF(Py_None); __pyx_v_buffer->obj = NULL; }
  __pyx_L2:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":710
 *         buffer.internal = NULL
 * 
 *     def __releasebuffer__(self, Py_buffer* buffer):             # <<<<<<<<<<<<<<
 *         if buffer is NULL:
 *             return # UNLOCK
 */

static void __pyx_pf_4lxml_5etree_15_XSLTResultTree___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer); /*proto*/
static void __pyx_pf_4lxml_5etree_15_XSLTResultTree___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_buffer) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":711
 * 
 *     def __releasebuffer__(self, Py_buffer* buffer):
 *         if buffer is NULL:             # <<<<<<<<<<<<<<
 *             return # UNLOCK
 *         if <char*>buffer.buf is self._buffer:
 */
  __pyx_1 = (__pyx_v_buffer == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":712
 *     def __releasebuffer__(self, Py_buffer* buffer):
 *         if buffer is NULL:
 *             return # UNLOCK             # <<<<<<<<<<<<<<
 *         if <char*>buffer.buf is self._buffer:
 *             self._buffer_refcnt -= 1
 */
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":713
 *         if buffer is NULL:
 *             return # UNLOCK
 *         if <char*>buffer.buf is self._buffer:             # <<<<<<<<<<<<<<
 *             self._buffer_refcnt -= 1
 *             if self._buffer_refcnt == 0:
 */
  __pyx_1 = (((char *)__pyx_v_buffer->buf) == ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":714
 *             return # UNLOCK
 *         if <char*>buffer.buf is self._buffer:
 *             self._buffer_refcnt -= 1             # <<<<<<<<<<<<<<
 *             if self._buffer_refcnt == 0:
 *                 tree.xmlFree(self._buffer)
 */
    ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer_refcnt -= 1;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":715
 *         if <char*>buffer.buf is self._buffer:
 *             self._buffer_refcnt -= 1
 *             if self._buffer_refcnt == 0:             # <<<<<<<<<<<<<<
 *                 tree.xmlFree(self._buffer)
 *                 self._buffer = NULL
 */
    __pyx_1 = (((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer_refcnt == 0);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":716
 *             self._buffer_refcnt -= 1
 *             if self._buffer_refcnt == 0:
 *                 tree.xmlFree(self._buffer)             # <<<<<<<<<<<<<<
 *                 self._buffer = NULL
 *         else:
 */
      xmlFree(((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":717
 *             if self._buffer_refcnt == 0:
 *                 tree.xmlFree(self._buffer)
 *                 self._buffer = NULL             # <<<<<<<<<<<<<<
 *         else:
 *             tree.xmlFree(<char*>buffer.buf)
 */
      ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_buffer = NULL;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":719
 *                 self._buffer = NULL
 *         else:
 *             tree.xmlFree(<char*>buffer.buf)             # <<<<<<<<<<<<<<
 *         buffer.buf = NULL
 * 
 */
    xmlFree(((char *)__pyx_v_buffer->buf));
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":720
 *         else:
 *             tree.xmlFree(<char*>buffer.buf)
 *         buffer.buf = NULL             # <<<<<<<<<<<<<<
 * 
 *     property xslt_profile:
 */
  __pyx_v_buffer->buf = NULL;

  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":725
 *         u"""Return an ElementTree with profiling data for the stylesheet run.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef object root
 *             if self._profile is None:
 */

static PyObject *__pyx_pf_4lxml_5etree_15_XSLTResultTree_12xslt_profile___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_15_XSLTResultTree_12xslt_profile___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_root;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_root = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":727
 *         def __get__(self):
 *             cdef object root
 *             if self._profile is None:             # <<<<<<<<<<<<<<
 *                 return None
 *             root = self._profile.getroot()
 */
  __pyx_1 = (((PyObject *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_profile) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":728
 *             cdef object root
 *             if self._profile is None:
 *                 return None             # <<<<<<<<<<<<<<
 *             root = self._profile.getroot()
 *             if root is None:
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":729
 *             if self._profile is None:
 *                 return None
 *             root = self._profile.getroot()             # <<<<<<<<<<<<<<
 *             if root is None:
 *                 return None
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_profile->__pyx_vtab)->getroot(((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_profile); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":730
 *                 return None
 *             root = self._profile.getroot()
 *             if root is None:             # <<<<<<<<<<<<<<
 *                 return None
 *             return ElementTree(root)
 */
  __pyx_1 = (__pyx_v_root == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":731
 *             root = self._profile.getroot()
 *             if root is None:
 *                 return None             # <<<<<<<<<<<<<<
 *             return ElementTree(root)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":732
 *             if root is None:
 *                 return None
 *             return ElementTree(root)             # <<<<<<<<<<<<<<
 * 
 *         def __del__(self):
 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_ElementTree); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_root);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_root);
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._XSLTResultTree.xslt_profile.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":734
 *             return ElementTree(root)
 * 
 *         def __del__(self):             # <<<<<<<<<<<<<<
 *             self._profile = None
 * 
 */

static int __pyx_pf_4lxml_5etree_15_XSLTResultTree_12xslt_profile___del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_4lxml_5etree_15_XSLTResultTree_12xslt_profile___del__(PyObject *__pyx_v_self) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":735
 * 
 *         def __del__(self):
 *             self._profile = None             # <<<<<<<<<<<<<<
 * 
 * cdef _xsltResultTreeFactory(_Document doc, XSLT xslt, _Document profile):
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_profile));
  ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_v_self)->_profile = ((struct LxmlDocument *)Py_None);

  __pyx_r = 0;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":737
 *             self._profile = None
 * 
 * cdef _xsltResultTreeFactory(_Document doc, XSLT xslt, _Document profile):             # <<<<<<<<<<<<<<
 *     cdef _XSLTResultTree result
 *     result = <_XSLTResultTree>_newElementTree(doc, None, _XSLTResultTree)
 */

static  PyObject *__pyx_f_4lxml_5etree__xsltResultTreeFactory(struct LxmlDocument *__pyx_v_doc, struct __pyx_obj_4lxml_5etree_XSLT *__pyx_v_xslt, struct LxmlDocument *__pyx_v_profile) {
  struct __pyx_obj_4lxml_5etree__XSLTResultTree *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_result = ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":739
 * cdef _xsltResultTreeFactory(_Document doc, XSLT xslt, _Document profile):
 *     cdef _XSLTResultTree result
 *     result = <_XSLTResultTree>_newElementTree(doc, None, _XSLTResultTree)             # <<<<<<<<<<<<<<
 *     result._xslt = xslt
 *     result._profile = profile
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__newElementTree(__pyx_v_doc, ((struct LxmlElement *)Py_None), ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__XSLTResultTree)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_1)));
  Py_DECREF(((PyObject *)__pyx_v_result));
  __pyx_v_result = ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)__pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":740
 *     cdef _XSLTResultTree result
 *     result = <_XSLTResultTree>_newElementTree(doc, None, _XSLTResultTree)
 *     result._xslt = xslt             # <<<<<<<<<<<<<<
 *     result._profile = profile
 *     result._buffer = NULL
 */
  Py_INCREF(((PyObject *)__pyx_v_xslt));
  Py_DECREF(((PyObject *)__pyx_v_result->_xslt));
  __pyx_v_result->_xslt = __pyx_v_xslt;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":741
 *     result = <_XSLTResultTree>_newElementTree(doc, None, _XSLTResultTree)
 *     result._xslt = xslt
 *     result._profile = profile             # <<<<<<<<<<<<<<
 *     result._buffer = NULL
 *     result._buffer_refcnt = 0
 */
  Py_INCREF(((PyObject *)__pyx_v_profile));
  Py_DECREF(((PyObject *)__pyx_v_result->_profile));
  __pyx_v_result->_profile = __pyx_v_profile;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":742
 *     result._xslt = xslt
 *     result._profile = profile
 *     result._buffer = NULL             # <<<<<<<<<<<<<<
 *     result._buffer_refcnt = 0
 *     result._buffer_len = 0
 */
  __pyx_v_result->_buffer = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":743
 *     result._profile = profile
 *     result._buffer = NULL
 *     result._buffer_refcnt = 0             # <<<<<<<<<<<<<<
 *     result._buffer_len = 0
 *     return result
 */
  __pyx_v_result->_buffer_refcnt = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":744
 *     result._buffer = NULL
 *     result._buffer_refcnt = 0
 *     result._buffer_len = 0             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_v_result->_buffer_len = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":745
 *     result._buffer_refcnt = 0
 *     result._buffer_len = 0
 *     return result             # <<<<<<<<<<<<<<
 * 
 * # functions like "output" and "write" are a potential security risk, but we
 */
  Py_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._xsltResultTreeFactory");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_result);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":754
 * xslt.exsltRegisterAll()
 * 
 * cdef void initTransformDict(xslt.xsltTransformContext* transform_ctxt):             # <<<<<<<<<<<<<<
 *     __GLOBAL_PARSER_CONTEXT.initThreadDictRef(&transform_ctxt.dict)
 * 
 */

static  void __pyx_f_4lxml_5etree_initTransformDict(xsltTransformContext *__pyx_v_transform_ctxt) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":755
 * 
 * cdef void initTransformDict(xslt.xsltTransformContext* transform_ctxt):
 *     __GLOBAL_PARSER_CONTEXT.initThreadDictRef(&transform_ctxt.dict)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initThreadDictRef(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, (&__pyx_v_transform_ctxt->dict));

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":776
 * __findStylesheetByID = None
 * 
 * cdef _findStylesheetByID(_Document doc, id):             # <<<<<<<<<<<<<<
 *     global __findStylesheetByID
 *     if __findStylesheetByID is None:
 */

static  PyObject *__pyx_f_4lxml_5etree__findStylesheetByID(struct LxmlDocument *__pyx_v_doc, PyObject *__pyx_v_id) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":778
 * cdef _findStylesheetByID(_Document doc, id):
 *     global __findStylesheetByID
 *     if __findStylesheetByID is None:             # <<<<<<<<<<<<<<
 *         __findStylesheetByID = XPath(
 *             u"//xsl:stylesheet[@xml:id = $id]",
 */
  __pyx_1 = (((PyObject *)__pyx_v_4lxml_5etree___findStylesheetByID) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":780
 *     if __findStylesheetByID is None:
 *         __findStylesheetByID = XPath(
 *             u"//xsl:stylesheet[@xml:id = $id]",             # <<<<<<<<<<<<<<
 *             namespaces={u"xsl" : u"http://www.w3.org/1999/XSL/Transform"})
 *     return __findStylesheetByID(doc, id=id)
 */
    __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_593));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_kp_593));
    __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":781
 *         __findStylesheetByID = XPath(
 *             u"//xsl:stylesheet[@xml:id = $id]",
 *             namespaces={u"xsl" : u"http://www.w3.org/1999/XSL/Transform"})             # <<<<<<<<<<<<<<
 *     return __findStylesheetByID(doc, id=id)
 * 
 */
    __pyx_4 = PyDict_New(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_4, ((PyObject *)__pyx_kp_594), ((PyObject *)__pyx_kp_595)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_3, __pyx_kp_namespaces, ((PyObject *)__pyx_4)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __pyx_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XPath)), ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_4lxml_5etree_XPath))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___findStylesheetByID));
    __pyx_v_4lxml_5etree___findStylesheetByID = ((struct __pyx_obj_4lxml_5etree_XPath *)__pyx_4);
    __pyx_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":782
 *             u"//xsl:stylesheet[@xml:id = $id]",
 *             namespaces={u"xsl" : u"http://www.w3.org/1999/XSL/Transform"})
 *     return __findStylesheetByID(doc, id=id)             # <<<<<<<<<<<<<<
 * 
 * cdef class _XSLTProcessingInstruction(PIBase):
 */
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_doc));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_doc));
  __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_3, __pyx_kp_id, __pyx_v_id) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyEval_CallObjectWithKeywords(((PyObject *)__pyx_v_4lxml_5etree___findStylesheetByID), ((PyObject *)__pyx_2), ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._findStylesheetByID");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":785
 * 
 * cdef class _XSLTProcessingInstruction(PIBase):
 *     def parseXSL(self, parser=None):             # <<<<<<<<<<<<<<
 *         u"""Try to parse the stylesheet referenced by this PI and return an
 *         ElementTree for it.  If the stylesheet is embedded in the same
 */

static PyObject *__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_parseXSL(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_26_XSLTProcessingInstruction_parseXSL[] = "Try to parse the stylesheet referenced by this PI and return an\n        ElementTree for it.  If the stylesheet is embedded in the same\n        document (referenced via xml:id), find and return an ElementTree for\n        the stylesheet Element.\n\n        The optional ``parser`` keyword argument can be passed to specify the\n        parser used to read from external stylesheet URLs.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_parseXSL(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parser = 0;
  struct LxmlDocument *__pyx_v_result_doc;
  struct LxmlElement *__pyx_v_result_node;
  char *__pyx_v_c_href;
  xmlAttr *__pyx_v_c_attr;
  PyObject *__pyx_v_hrefs_utf;
  PyObject *__pyx_v_href_utf;
  PyObject *__pyx_v_root;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_ssize_t __pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_parser,0};
  __pyx_v_parser = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "parseXSL") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_parser = values[0];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_parser = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("parseXSL", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._XSLTProcessingInstruction.parseXSL");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_result_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_hrefs_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_href_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_root = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":798
 *         cdef char* c_href
 *         cdef xmlAttr* c_attr
 *         if self._c_node.content is NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"PI lacks content"
 *         hrefs_utf = _FIND_PI_HREF(' ' + self._c_node.content)
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._c_node->content == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":799
 *         cdef xmlAttr* c_attr
 *         if self._c_node.content is NULL:
 *             raise ValueError, u"PI lacks content"             # <<<<<<<<<<<<<<
 *         hrefs_utf = _FIND_PI_HREF(' ' + self._c_node.content)
 *         if len(hrefs_utf) != 1:
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_596), 0);
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":800
 *         if self._c_node.content is NULL:
 *             raise ValueError, u"PI lacks content"
 *         hrefs_utf = _FIND_PI_HREF(' ' + self._c_node.content)             # <<<<<<<<<<<<<<
 *         if len(hrefs_utf) != 1:
 *             raise ValueError, u"malformed PI attributes"
 */
  __pyx_2 = __Pyx_PyBytes_FromString(((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._c_node->content); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Add(__pyx_kp_597, __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree__FIND_PI_HREF, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_v_hrefs_utf);
  __pyx_v_hrefs_utf = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":801
 *             raise ValueError, u"PI lacks content"
 *         hrefs_utf = _FIND_PI_HREF(' ' + self._c_node.content)
 *         if len(hrefs_utf) != 1:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"malformed PI attributes"
 *         href_utf = hrefs_utf[0]
 */
  __pyx_4 = PyObject_Length(__pyx_v_hrefs_utf); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (__pyx_4 != 1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":802
 *         hrefs_utf = _FIND_PI_HREF(' ' + self._c_node.content)
 *         if len(hrefs_utf) != 1:
 *             raise ValueError, u"malformed PI attributes"             # <<<<<<<<<<<<<<
 *         href_utf = hrefs_utf[0]
 *         c_href = _cstr(href_utf)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_598), 0);
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":803
 *         if len(hrefs_utf) != 1:
 *             raise ValueError, u"malformed PI attributes"
 *         href_utf = hrefs_utf[0]             # <<<<<<<<<<<<<<
 *         c_href = _cstr(href_utf)
 * 
 */
  __pyx_2 = __Pyx_GetItemInt(__pyx_v_hrefs_utf, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_href_utf);
  __pyx_v_href_utf = __pyx_2;
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":804
 *             raise ValueError, u"malformed PI attributes"
 *         href_utf = hrefs_utf[0]
 *         c_href = _cstr(href_utf)             # <<<<<<<<<<<<<<
 * 
 *         if c_href[0] != c'#':
 */
  __pyx_v_c_href = PyString_AS_STRING(__pyx_v_href_utf);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":806
 *         c_href = _cstr(href_utf)
 * 
 *         if c_href[0] != c'#':             # <<<<<<<<<<<<<<
 *             # normal URL, try to parse from it
 *             c_href = tree.xmlBuildURI(
 */
  __pyx_1 = ((__pyx_v_c_href[0]) != '#');
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":810
 *             c_href = tree.xmlBuildURI(
 *                 c_href,
 *                 tree.xmlNodeGetBase(self._c_node.doc, self._c_node))             # <<<<<<<<<<<<<<
 *             if c_href is not NULL:
 *                 href_utf = c_href
 */
    __pyx_v_c_href = xmlBuildURI(__pyx_v_c_href, xmlNodeGetBase(((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._c_node->doc, ((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._c_node));

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":811
 *                 c_href,
 *                 tree.xmlNodeGetBase(self._c_node.doc, self._c_node))
 *             if c_href is not NULL:             # <<<<<<<<<<<<<<
 *                 href_utf = c_href
 *                 tree.xmlFree(c_href)
 */
    __pyx_1 = (__pyx_v_c_href != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":812
 *                 tree.xmlNodeGetBase(self._c_node.doc, self._c_node))
 *             if c_href is not NULL:
 *                 href_utf = c_href             # <<<<<<<<<<<<<<
 *                 tree.xmlFree(c_href)
 *             result_doc = _parseDocumentFromURL(href_utf, parser)
 */
      __pyx_3 = __Pyx_PyBytes_FromString(__pyx_v_c_href); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_href_utf);
      __pyx_v_href_utf = __pyx_3;
      __pyx_3 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":813
 *             if c_href is not NULL:
 *                 href_utf = c_href
 *                 tree.xmlFree(c_href)             # <<<<<<<<<<<<<<
 *             result_doc = _parseDocumentFromURL(href_utf, parser)
 *             return _elementTreeFactory(result_doc, None)
 */
      xmlFree(__pyx_v_c_href);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":814
 *                 href_utf = c_href
 *                 tree.xmlFree(c_href)
 *             result_doc = _parseDocumentFromURL(href_utf, parser)             # <<<<<<<<<<<<<<
 *             return _elementTreeFactory(result_doc, None)
 * 
 */
    if (!(__Pyx_TypeTest(__pyx_v_parser, __pyx_ptype_4lxml_5etree__BaseParser))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocumentFromURL(__pyx_v_href_utf, ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_result_doc));
    __pyx_v_result_doc = ((struct LxmlDocument *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":815
 *                 tree.xmlFree(c_href)
 *             result_doc = _parseDocumentFromURL(href_utf, parser)
 *             return _elementTreeFactory(result_doc, None)             # <<<<<<<<<<<<<<
 * 
 *         # ID reference to embedded stylesheet
 */
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(__pyx_v_result_doc, ((struct LxmlElement *)Py_None))); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":819
 *         # ID reference to embedded stylesheet
 *         # try XML:ID lookup
 *         c_href += 1 # skip leading '#'             # <<<<<<<<<<<<<<
 *         c_attr = tree.xmlGetID(self._c_node.doc, c_href)
 *         if c_attr is not NULL and c_attr.doc is self._c_node.doc:
 */
  __pyx_v_c_href += 1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":820
 *         # try XML:ID lookup
 *         c_href += 1 # skip leading '#'
 *         c_attr = tree.xmlGetID(self._c_node.doc, c_href)             # <<<<<<<<<<<<<<
 *         if c_attr is not NULL and c_attr.doc is self._c_node.doc:
 *             result_node = _elementFactory(self._doc, c_attr.parent)
 */
  __pyx_v_c_attr = xmlGetID(((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._c_node->doc, __pyx_v_c_href);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":821
 *         c_href += 1 # skip leading '#'
 *         c_attr = tree.xmlGetID(self._c_node.doc, c_href)
 *         if c_attr is not NULL and c_attr.doc is self._c_node.doc:             # <<<<<<<<<<<<<<
 *             result_node = _elementFactory(self._doc, c_attr.parent)
 *             return _elementTreeFactory(result_node._doc, result_node)
 */
  __pyx_1 = (__pyx_v_c_attr != NULL);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_c_attr->doc == ((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._c_node->doc);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":822
 *         c_attr = tree.xmlGetID(self._c_node.doc, c_href)
 *         if c_attr is not NULL and c_attr.doc is self._c_node.doc:
 *             result_node = _elementFactory(self._doc, c_attr.parent)             # <<<<<<<<<<<<<<
 *             return _elementTreeFactory(result_node._doc, result_node)
 * 
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._doc, __pyx_v_c_attr->parent)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_result_node));
    __pyx_v_result_node = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":823
 *         if c_attr is not NULL and c_attr.doc is self._c_node.doc:
 *             result_node = _elementFactory(self._doc, c_attr.parent)
 *             return _elementTreeFactory(result_node._doc, result_node)             # <<<<<<<<<<<<<<
 * 
 *         # try XPath search
 */
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(__pyx_v_result_node->_doc, __pyx_v_result_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":826
 * 
 *         # try XPath search
 *         root = _findStylesheetByID(self._doc, funicode(c_href))             # <<<<<<<<<<<<<<
 *         if not root:
 *             raise ValueError, u"reference to non-existing embedded stylesheet"
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_href); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __pyx_f_4lxml_5etree__findStylesheetByID(((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base._doc, __pyx_2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_root);
  __pyx_v_root = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":827
 *         # try XPath search
 *         root = _findStylesheetByID(self._doc, funicode(c_href))
 *         if not root:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"reference to non-existing embedded stylesheet"
 *         elif len(root) > 1:
 */
  __pyx_1 = __Pyx_PyObject_IsTrue(__pyx_v_root); if (unlikely(__pyx_1 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = (!__pyx_1);
  if (__pyx_5) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":828
 *         root = _findStylesheetByID(self._doc, funicode(c_href))
 *         if not root:
 *             raise ValueError, u"reference to non-existing embedded stylesheet"             # <<<<<<<<<<<<<<
 *         elif len(root) > 1:
 *             raise ValueError, u"ambiguous reference to embedded stylesheet"
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_599), 0);
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":829
 *         if not root:
 *             raise ValueError, u"reference to non-existing embedded stylesheet"
 *         elif len(root) > 1:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"ambiguous reference to embedded stylesheet"
 *         result_node = root[0]
 */
  __pyx_4 = PyObject_Length(__pyx_v_root); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = (__pyx_4 > 1);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":830
 *             raise ValueError, u"reference to non-existing embedded stylesheet"
 *         elif len(root) > 1:
 *             raise ValueError, u"ambiguous reference to embedded stylesheet"             # <<<<<<<<<<<<<<
 *         result_node = root[0]
 *         return _elementTreeFactory(result_node._doc, result_node)
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_600), 0);
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":831
 *         elif len(root) > 1:
 *             raise ValueError, u"ambiguous reference to embedded stylesheet"
 *         result_node = root[0]             # <<<<<<<<<<<<<<
 *         return _elementTreeFactory(result_node._doc, result_node)
 * 
 */
  __pyx_2 = __Pyx_GetItemInt(__pyx_v_root, 0, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__Element))) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_result_node));
  __pyx_v_result_node = ((struct LxmlElement *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":832
 *             raise ValueError, u"ambiguous reference to embedded stylesheet"
 *         result_node = root[0]
 *         return _elementTreeFactory(result_node._doc, result_node)             # <<<<<<<<<<<<<<
 * 
 *     def set(self, key, value):
 */
  __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__elementTreeFactory(__pyx_v_result_node->_doc, __pyx_v_result_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._XSLTProcessingInstruction.parseXSL");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result_doc);
  Py_DECREF(__pyx_v_result_node);
  Py_DECREF(__pyx_v_hrefs_utf);
  Py_DECREF(__pyx_v_href_utf);
  Py_DECREF(__pyx_v_root);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":834
 *         return _elementTreeFactory(result_node._doc, result_node)
 * 
 *     def set(self, key, value):             # <<<<<<<<<<<<<<
 *         if key != u"href":
 *             raise AttributeError, \
 */

static PyObject *__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_attrib;
  PyObject *__pyx_v_text;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_value,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_value);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, 1); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    __pyx_v_value = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._XSLTProcessingInstruction.set");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_attrib = Py_None; Py_INCREF(Py_None);
  __pyx_v_text = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":835
 * 
 *     def set(self, key, value):
 *         if key != u"href":             # <<<<<<<<<<<<<<
 *             raise AttributeError, \
 *                 u"only setting the 'href' attribute is supported on XSLT-PIs"
 */
  __pyx_1 = PyObject_RichCompare(__pyx_v_key, ((PyObject *)__pyx_kp_601), Py_NE); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_1); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":837
 *         if key != u"href":
 *             raise AttributeError, \
 *                 u"only setting the 'href' attribute is supported on XSLT-PIs"             # <<<<<<<<<<<<<<
 *         if value is None:
 *             attrib = u""
 */
    __Pyx_Raise(__pyx_builtin_AttributeError, ((PyObject *)__pyx_kp_602), 0);
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":838
 *             raise AttributeError, \
 *                 u"only setting the 'href' attribute is supported on XSLT-PIs"
 *         if value is None:             # <<<<<<<<<<<<<<
 *             attrib = u""
 *         elif u'"' in value or u'>' in value:
 */
  __pyx_2 = (__pyx_v_value == Py_None);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":839
 *                 u"only setting the 'href' attribute is supported on XSLT-PIs"
 *         if value is None:
 *             attrib = u""             # <<<<<<<<<<<<<<
 *         elif u'"' in value or u'>' in value:
 *             raise ValueError, u"Invalid URL, must not contain '\"' or '>'"
 */
    Py_INCREF(((PyObject *)__pyx_kp_603));
    Py_DECREF(__pyx_v_attrib);
    __pyx_v_attrib = ((PyObject *)__pyx_kp_603);
    goto __pyx_L7;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":840
 *         if value is None:
 *             attrib = u""
 *         elif u'"' in value or u'>' in value:             # <<<<<<<<<<<<<<
 *             raise ValueError, u"Invalid URL, must not contain '\"' or '>'"
 *         else:
 */
  __pyx_2 = (PySequence_Contains(__pyx_v_value, ((PyObject *)__pyx_kp_604))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_2) {
    __pyx_2 = (PySequence_Contains(__pyx_v_value, ((PyObject *)__pyx_kp_605))); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":841
 *             attrib = u""
 *         elif u'"' in value or u'>' in value:
 *             raise ValueError, u"Invalid URL, must not contain '\"' or '>'"             # <<<<<<<<<<<<<<
 *         else:
 *             attrib = u' href="%s"' % value
 */
    __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_606), 0);
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":843
 *             raise ValueError, u"Invalid URL, must not contain '\"' or '>'"
 *         else:
 *             attrib = u' href="%s"' % value             # <<<<<<<<<<<<<<
 *         text = u' ' + self.text
 *         if _FIND_PI_HREF(text):
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_607), __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_attrib);
    __pyx_v_attrib = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":844
 *         else:
 *             attrib = u' href="%s"' % value
 *         text = u' ' + self.text             # <<<<<<<<<<<<<<
 *         if _FIND_PI_HREF(text):
 *             self.text = _REPLACE_PI_HREF(attrib, text)
 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_text); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_608), __pyx_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_text);
  __pyx_v_text = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":845
 *             attrib = u' href="%s"' % value
 *         text = u' ' + self.text
 *         if _FIND_PI_HREF(text):             # <<<<<<<<<<<<<<
 *             self.text = _REPLACE_PI_HREF(attrib, text)
 *         else:
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_text);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_text);
  __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree__FIND_PI_HREF, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_2 = __Pyx_PyObject_IsTrue(__pyx_3); if (unlikely(__pyx_2 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":846
 *         text = u' ' + self.text
 *         if _FIND_PI_HREF(text):
 *             self.text = _REPLACE_PI_HREF(attrib, text)             # <<<<<<<<<<<<<<
 *         else:
 *             self.text = text + attrib
 */
    __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(__pyx_v_attrib);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_attrib);
    Py_INCREF(__pyx_v_text);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_text);
    __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree__REPLACE_PI_HREF, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_text, __pyx_3) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":848
 *             self.text = _REPLACE_PI_HREF(attrib, text)
 *         else:
 *             self.text = text + attrib             # <<<<<<<<<<<<<<
 * 
 *     def get(self, key, default=None):
 */
    __pyx_t_1 = PyNumber_Add(__pyx_v_text, __pyx_v_attrib); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyObject_SetAttr(__pyx_v_self, __pyx_kp_text, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L8:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree._XSLTProcessingInstruction.set");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_attrib);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":850
 *             self.text = text + attrib
 * 
 *     def get(self, key, default=None):             # <<<<<<<<<<<<<<
 *         for attr, value in _FIND_PI_ATTRIBUTES(u' ' + self.text):
 *             if attr == key:
 */

static PyObject *__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_v_attr;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_key,&__pyx_kp_default,0};
  __pyx_v_default = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_key);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get") < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_key = values[0];
    if (values[1]) {
      __pyx_v_default = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_default = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[17]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree._XSLTProcessingInstruction.get");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_attr = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":851
 * 
 *     def get(self, key, default=None):
 *         for attr, value in _FIND_PI_ATTRIBUTES(u' ' + self.text):             # <<<<<<<<<<<<<<
 *             if attr == key:
 *                 return value
 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_kp_text); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_609), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_3 = PyObject_Call(__pyx_v_4lxml_5etree__FIND_PI_ATTRIBUTES, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  if (PyList_CheckExact(__pyx_3) || PyTuple_CheckExact(__pyx_3)) {
    __pyx_1 = 0; __pyx_2 = __pyx_3; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_attr);
      __pyx_v_attr = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_attr);
      __pyx_v_attr = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_value);
      __pyx_v_value = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":852
 *     def get(self, key, default=None):
 *         for attr, value in _FIND_PI_ATTRIBUTES(u' ' + self.text):
 *             if attr == key:             # <<<<<<<<<<<<<<
 *                 return value
 *         return default
 */
    __pyx_5 = PyObject_RichCompare(__pyx_v_attr, __pyx_v_key, Py_EQ); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_6 = __Pyx_PyObject_IsTrue(__pyx_5); if (unlikely(__pyx_6 < 0)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_6) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":853
 *         for attr, value in _FIND_PI_ATTRIBUTES(u' ' + self.text):
 *             if attr == key:
 *                 return value             # <<<<<<<<<<<<<<
 *         return default
 */
      Py_INCREF(__pyx_v_value);
      __pyx_r = __pyx_v_value;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":854
 *             if attr == key:
 *                 return value
 *         return default             # <<<<<<<<<<<<<<
 */
  Py_INCREF(__pyx_v_default);
  __pyx_r = __pyx_v_default;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._XSLTProcessingInstruction.get");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_attr);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":6
 *     u"""Base class of an XSLT extension element.
 *     """
 *     def execute(self, context, self_node, input_node, output_parent):             # <<<<<<<<<<<<<<
 *         u"""execute(self, context, self_node, input_node, output_parent)
 *         Execute this extension element.
 */

static PyObject *__pyx_pf_4lxml_5etree_13XSLTExtension_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_13XSLTExtension_execute[] = "execute(self, context, self_node, input_node, output_parent)\n        Execute this extension element.\n\n        Subclasses must override this method.  They may append\n        elements to the `output_parent` element here, or set its text\n        content.  To this end, the `input_node` provides read-only\n        access to the current node in the input document, and the\n        `self_node` points to the extension element in the stylesheet.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13XSLTExtension_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_v_self_node = 0;
  PyObject *__pyx_v_input_node = 0;
  PyObject *__pyx_v_output_parent = 0;
  PyObject *__pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_context,&__pyx_kp_self_node,&__pyx_kp_input_node,&__pyx_kp_output_parent,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[4] = {0,0,0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_self_node);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("execute", 1, 4, 4, 1); {__pyx_filename = __pyx_f[18]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_input_node);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("execute", 1, 4, 4, 2); {__pyx_filename = __pyx_f[18]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_kp_output_parent);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("execute", 1, 4, 4, 3); {__pyx_filename = __pyx_f[18]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "execute") < 0)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_context = values[0];
    __pyx_v_self_node = values[1];
    __pyx_v_input_node = values[2];
    __pyx_v_output_parent = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_self_node = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_input_node = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_output_parent = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execute", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[18]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XSLTExtension.execute");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":18
 *         pass
 * 
 *     def apply_templates(self, _XSLTContext context not None, node):             # <<<<<<<<<<<<<<
 *         u"""apply_templates(self, context, node)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_13XSLTExtension_apply_templates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_13XSLTExtension_apply_templates[] = "apply_templates(self, context, node)\n\n        Call this method to retrieve the result of applying templates\n        to an element.\n\n        The return value is a list of elements or text strings that\n        were generated by the XSLT processor.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_13XSLTExtension_apply_templates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_context = 0;
  PyObject *__pyx_v_node = 0;
  xmlNode *__pyx_v_c_parent;
  xmlNode *__pyx_v_c_node;
  xmlNode *__pyx_v_c_next;
  xmlNode *__pyx_v_c_context_node;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_proxy;
  PyObject *__pyx_v_results;
  PyObject *__pyx_r;
  xmlNode *__pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_context,&__pyx_kp_node,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_context);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_node);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("apply_templates", 1, 2, 2, 1); {__pyx_filename = __pyx_f[18]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "apply_templates") < 0)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)values[0]);
    __pyx_v_node = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_node = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("apply_templates", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[18]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XSLTExtension.apply_templates");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  __pyx_v_results = Py_None; Py_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_context), __pyx_ptype_4lxml_5etree__XSLTContext, 0, "context", 0))) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":32
 *         cdef xmlNode* c_context_node
 *         cdef _ReadOnlyElementProxy proxy
 *         c_context_node = _roNodeOf(node)             # <<<<<<<<<<<<<<
 *         #assert c_context_node.doc is context._xsltContext.node.doc, \
 *         #    "switching input documents during transformation is not currently supported"
 */
  __pyx_1 = __pyx_f_4lxml_5etree__roNodeOf(__pyx_v_node); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_context_node = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":37
 * 
 *         c_parent = tree.xmlNewDocNode(
 *             context._xsltCtxt.output, NULL, "fake-parent", NULL)             # <<<<<<<<<<<<<<
 * 
 *         c_node = context._xsltCtxt.insert
 */
  __pyx_v_c_parent = xmlNewDocNode(__pyx_v_context->_xsltCtxt->output, NULL, __pyx_k_610, NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":39
 *             context._xsltCtxt.output, NULL, "fake-parent", NULL)
 * 
 *         c_node = context._xsltCtxt.insert             # <<<<<<<<<<<<<<
 *         context._xsltCtxt.insert = c_parent
 *         xslt.xsltProcessOneNode(
 */
  __pyx_v_c_node = __pyx_v_context->_xsltCtxt->insert;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":40
 * 
 *         c_node = context._xsltCtxt.insert
 *         context._xsltCtxt.insert = c_parent             # <<<<<<<<<<<<<<
 *         xslt.xsltProcessOneNode(
 *             context._xsltCtxt, c_context_node, NULL)
 */
  __pyx_v_context->_xsltCtxt->insert = __pyx_v_c_parent;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":42
 *         context._xsltCtxt.insert = c_parent
 *         xslt.xsltProcessOneNode(
 *             context._xsltCtxt, c_context_node, NULL)             # <<<<<<<<<<<<<<
 *         context._xsltCtxt.insert = c_node
 * 
 */
  xsltProcessOneNode(__pyx_v_context->_xsltCtxt, __pyx_v_c_context_node, NULL);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":43
 *         xslt.xsltProcessOneNode(
 *             context._xsltCtxt, c_context_node, NULL)
 *         context._xsltCtxt.insert = c_node             # <<<<<<<<<<<<<<
 * 
 *         results = [] # or maybe _collectAttributes(c_parent, 2) ?
 */
  __pyx_v_context->_xsltCtxt->insert = __pyx_v_c_node;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":45
 *         context._xsltCtxt.insert = c_node
 * 
 *         results = [] # or maybe _collectAttributes(c_parent, 2) ?             # <<<<<<<<<<<<<<
 *         c_node = c_parent.children
 *         try:
 */
  __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_results);
  __pyx_v_results = ((PyObject *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":46
 * 
 *         results = [] # or maybe _collectAttributes(c_parent, 2) ?
 *         c_node = c_parent.children             # <<<<<<<<<<<<<<
 *         try:
 *             while c_node is not NULL:
 */
  __pyx_v_c_node = __pyx_v_c_parent->children;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":47
 *         results = [] # or maybe _collectAttributes(c_parent, 2) ?
 *         c_node = c_parent.children
 *         try:             # <<<<<<<<<<<<<<
 *             while c_node is not NULL:
 *                 c_next = c_node.next
 */
  /*try:*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":48
 *         c_node = c_parent.children
 *         try:
 *             while c_node is not NULL:             # <<<<<<<<<<<<<<
 *                 c_next = c_node.next
 *                 if c_node.type == tree.XML_TEXT_NODE:
 */
    while (1) {
      __pyx_3 = (__pyx_v_c_node != NULL);
      if (!__pyx_3) break;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":49
 *         try:
 *             while c_node is not NULL:
 *                 c_next = c_node.next             # <<<<<<<<<<<<<<
 *                 if c_node.type == tree.XML_TEXT_NODE:
 *                     python.PyList_Append(
 */
      __pyx_v_c_next = __pyx_v_c_node->next;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":50
 *             while c_node is not NULL:
 *                 c_next = c_node.next
 *                 if c_node.type == tree.XML_TEXT_NODE:             # <<<<<<<<<<<<<<
 *                     python.PyList_Append(
 *                         results, funicode(c_node.content))
 */
      __pyx_3 = (__pyx_v_c_node->type == XML_TEXT_NODE);
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":52
 *                 if c_node.type == tree.XML_TEXT_NODE:
 *                     python.PyList_Append(
 *                         results, funicode(c_node.content))             # <<<<<<<<<<<<<<
 *                 elif c_node.type == tree.XML_ELEMENT_NODE:
 *                     proxy = _newReadOnlyProxy(
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_node->content); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __pyx_4 = PyList_Append(__pyx_v_results, __pyx_2); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L7;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        goto __pyx_L11;
      }

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":53
 *                     python.PyList_Append(
 *                         results, funicode(c_node.content))
 *                 elif c_node.type == tree.XML_ELEMENT_NODE:             # <<<<<<<<<<<<<<
 *                     proxy = _newReadOnlyProxy(
 *                         context._extension_element_proxy, c_node)
 */
      __pyx_3 = (__pyx_v_c_node->type == XML_ELEMENT_NODE);
      if (__pyx_3) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":55
 *                 elif c_node.type == tree.XML_ELEMENT_NODE:
 *                     proxy = _newReadOnlyProxy(
 *                         context._extension_element_proxy, c_node)             # <<<<<<<<<<<<<<
 *                     python.PyList_Append(results, proxy)
 *                     # unlink node and make sure it will be freed later on
 */
        __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(__pyx_v_context->_extension_element_proxy, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L7;}
        Py_DECREF(((PyObject *)__pyx_v_proxy));
        __pyx_v_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_2);
        __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":56
 *                     proxy = _newReadOnlyProxy(
 *                         context._extension_element_proxy, c_node)
 *                     python.PyList_Append(results, proxy)             # <<<<<<<<<<<<<<
 *                     # unlink node and make sure it will be freed later on
 *                     tree.xmlUnlinkNode(c_node)
 */
        __pyx_4 = PyList_Append(__pyx_v_results, ((PyObject *)__pyx_v_proxy)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L7;}

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":58
 *                     python.PyList_Append(results, proxy)
 *                     # unlink node and make sure it will be freed later on
 *                     tree.xmlUnlinkNode(c_node)             # <<<<<<<<<<<<<<
 *                     proxy.free_after_use()
 *                 else:
 */
        xmlUnlinkNode(__pyx_v_c_node);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":59
 *                     # unlink node and make sure it will be freed later on
 *                     tree.xmlUnlinkNode(c_node)
 *                     proxy.free_after_use()             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise TypeError, \
 */
        ((struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy *)__pyx_v_proxy->__pyx_vtab)->free_after_use(__pyx_v_proxy);
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":62
 *                 else:
 *                     raise TypeError, \
 *                         u"unsupported XSLT result type: %d" % c_node.type             # <<<<<<<<<<<<<<
 *                 c_node = c_next
 *         finally:
 */
        __pyx_2 = PyInt_FromLong(__pyx_v_c_node->type); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L7;}
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_611), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L7;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __Pyx_Raise(__pyx_builtin_TypeError, __pyx_t_1, 0);
        Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        {__pyx_filename = __pyx_f[18]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L7;}
      }
      __pyx_L11:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":63
 *                     raise TypeError, \
 *                         u"unsupported XSLT result type: %d" % c_node.type
 *                 c_node = c_next             # <<<<<<<<<<<<<<
 *         finally:
 *             # free all intermediate nodes that will not be freed by proxies
 */
      __pyx_v_c_node = __pyx_v_c_next;
    }
  }
  /*finally:*/ {
    int __pyx_why;
    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
    int __pyx_exc_lineno;
    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 0; goto __pyx_L8;
    __pyx_L7: {
      __pyx_why = 4;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":66
 *         finally:
 *             # free all intermediate nodes that will not be freed by proxies
 *             tree.xmlFreeNode(c_parent)             # <<<<<<<<<<<<<<
 *         return results
 * 
 */
    xmlFreeNode(__pyx_v_c_parent);
    switch (__pyx_why) {
      case 4: {
        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
        __pyx_lineno = __pyx_exc_lineno;
        __pyx_exc_type = 0;
        __pyx_exc_value = 0;
        __pyx_exc_tb = 0;
        goto __pyx_L1_error;
      }
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":67
 *             # free all intermediate nodes that will not be freed by proxies
 *             tree.xmlFreeNode(c_parent)
 *         return results             # <<<<<<<<<<<<<<
 * 
 * 
 */
  Py_INCREF(__pyx_v_results);
  __pyx_r = __pyx_v_results;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.XSLTExtension.apply_templates");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_proxy);
  Py_DECREF(__pyx_v_results);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":70
 * 
 * 
 * cdef _registerXSLTExtensions(xslt.xsltTransformContext* c_ctxt,             # <<<<<<<<<<<<<<
 *                              extension_dict):
 *     for ns_utf, name_utf in extension_dict:
 */

static  PyObject *__pyx_f_4lxml_5etree__registerXSLTExtensions(xsltTransformContext *__pyx_v_c_ctxt, PyObject *__pyx_v_extension_dict) {
  PyObject *__pyx_v_ns_utf;
  PyObject *__pyx_v_name_utf;
  PyObject *__pyx_r;
  Py_ssize_t __pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_v_ns_utf = Py_None; Py_INCREF(Py_None);
  __pyx_v_name_utf = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":72
 * cdef _registerXSLTExtensions(xslt.xsltTransformContext* c_ctxt,
 *                              extension_dict):
 *     for ns_utf, name_utf in extension_dict:             # <<<<<<<<<<<<<<
 *         xslt.xsltRegisterExtElement(
 *             c_ctxt, _cstr(name_utf), _cstr(ns_utf), _callExtensionElement)
 */
  if (PyList_CheckExact(__pyx_v_extension_dict) || PyTuple_CheckExact(__pyx_v_extension_dict)) {
    __pyx_1 = 0; __pyx_2 = __pyx_v_extension_dict; Py_INCREF(__pyx_2);
  } else {
    __pyx_1 = -1; __pyx_2 = PyObject_GetIter(__pyx_v_extension_dict); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyList_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyList_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_2))) {
      if (__pyx_1 >= PyTuple_GET_SIZE(__pyx_2)) break;
      __pyx_3 = PyTuple_GET_ITEM(__pyx_2, __pyx_1); Py_INCREF(__pyx_3); __pyx_1++;
    } else {
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
    }
    if (PyTuple_CheckExact(__pyx_3) && PyTuple_GET_SIZE(__pyx_3) == 2) {
      PyObject* tuple = __pyx_3;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 0);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = PyTuple_GET_ITEM(tuple, 1);
      Py_INCREF(__pyx_5);
      Py_DECREF(__pyx_v_name_utf);
      __pyx_v_name_utf = __pyx_5;
      __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    else {
      __pyx_4 = PyObject_GetIter(__pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_ns_utf);
      __pyx_v_ns_utf = __pyx_5;
      __pyx_5 = 0;
      __pyx_5 = __Pyx_UnpackItem(__pyx_4, 1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_name_utf);
      __pyx_v_name_utf = __pyx_5;
      __pyx_5 = 0;
      if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":74
 *     for ns_utf, name_utf in extension_dict:
 *         xslt.xsltRegisterExtElement(
 *             c_ctxt, _cstr(name_utf), _cstr(ns_utf), _callExtensionElement)             # <<<<<<<<<<<<<<
 * 
 * cdef void _callExtensionElement(xslt.xsltTransformContext* c_ctxt,
 */
    xsltRegisterExtElement(__pyx_v_c_ctxt, PyString_AS_STRING(__pyx_v_name_utf), PyString_AS_STRING(__pyx_v_ns_utf), __pyx_f_4lxml_5etree__callExtensionElement);
  }
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._registerXSLTExtensions");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ns_utf);
  Py_DECREF(__pyx_v_name_utf);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":76
 *             c_ctxt, _cstr(name_utf), _cstr(ns_utf), _callExtensionElement)
 * 
 * cdef void _callExtensionElement(xslt.xsltTransformContext* c_ctxt,             # <<<<<<<<<<<<<<
 *                                 xmlNode* c_context_node,
 *                                 xmlNode* c_inst_node,
 */

static  void __pyx_f_4lxml_5etree__callExtensionElement(xsltTransformContext *__pyx_v_c_ctxt, xmlNode *__pyx_v_c_context_node, xmlNode *__pyx_v_c_inst_node, void *__pyx_v_dummy) {
  struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree_XSLTExtension *__pyx_v_extension;
  PyObject *__pyx_v_dict_result;
  char *__pyx_v_c_uri;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_context_node;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_self_node;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *__pyx_v_output_parent;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_message;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  char *__pyx_9;
  PyObject *__pyx_t_1 = NULL;
  PyGILState_STATE _save = PyGILState_Ensure();
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_extension = ((struct __pyx_obj_4lxml_5etree_XSLTExtension *)Py_None); Py_INCREF(Py_None);
  __pyx_v_context_node = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  __pyx_v_self_node = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  __pyx_v_output_parent = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  __pyx_v_e = Py_None; Py_INCREF(Py_None);
  __pyx_v_message = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":85
 *     cdef char* c_uri
 *     cdef _ReadOnlyElementProxy context_node, self_node, output_parent
 *     c_uri = _getNs(c_inst_node)             # <<<<<<<<<<<<<<
 *     if c_uri is NULL:
 *         # not allowed, and should never happen
 */
  __pyx_v_c_uri = _getNs(__pyx_v_c_inst_node);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":86
 *     cdef _ReadOnlyElementProxy context_node, self_node, output_parent
 *     c_uri = _getNs(c_inst_node)
 *     if c_uri is NULL:             # <<<<<<<<<<<<<<
 *         # not allowed, and should never happen
 *         return
 */
  __pyx_1 = (__pyx_v_c_uri == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":88
 *     if c_uri is NULL:
 *         # not allowed, and should never happen
 *         return             # <<<<<<<<<<<<<<
 *     if c_ctxt.xpathCtxt.userData is NULL:
 *         # just for safety, should never happen
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":89
 *         # not allowed, and should never happen
 *         return
 *     if c_ctxt.xpathCtxt.userData is NULL:             # <<<<<<<<<<<<<<
 *         # just for safety, should never happen
 *         return
 */
  __pyx_1 = (__pyx_v_c_ctxt->xpathCtxt->userData == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":91
 *     if c_ctxt.xpathCtxt.userData is NULL:
 *         # just for safety, should never happen
 *         return             # <<<<<<<<<<<<<<
 *     context = <_XSLTContext>c_ctxt.xpathCtxt.userData
 *     try:
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":92
 *         # just for safety, should never happen
 *         return
 *     context = <_XSLTContext>c_ctxt.xpathCtxt.userData             # <<<<<<<<<<<<<<
 *     try:
 *         dict_result = python.PyDict_GetItem(
 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_c_ctxt->xpathCtxt->userData)));
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)__pyx_v_c_ctxt->xpathCtxt->userData);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":93
 *         return
 *     context = <_XSLTContext>c_ctxt.xpathCtxt.userData
 *     try:             # <<<<<<<<<<<<<<
 *         dict_result = python.PyDict_GetItem(
 *             context._extension_elements, (c_uri, c_inst_node.name))
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":95
 *     try:
 *         dict_result = python.PyDict_GetItem(
 *             context._extension_elements, (c_uri, c_inst_node.name))             # <<<<<<<<<<<<<<
 *         if dict_result is NULL:
 *             raise KeyError, \
 */
      __pyx_2 = __Pyx_PyBytes_FromString(__pyx_v_c_uri); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_3 = __Pyx_PyBytes_FromString(__pyx_v_c_inst_node->name); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
      __pyx_2 = 0;
      __pyx_3 = 0;
      __pyx_v_dict_result = PyDict_GetItem(__pyx_v_context->_extension_elements, ((PyObject *)__pyx_4));
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":96
 *         dict_result = python.PyDict_GetItem(
 *             context._extension_elements, (c_uri, c_inst_node.name))
 *         if dict_result is NULL:             # <<<<<<<<<<<<<<
 *             raise KeyError, \
 *                 u"extension element %s not found" % funicode(c_inst_node.name)
 */
      __pyx_1 = (__pyx_v_dict_result == NULL);
      if (__pyx_1) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":98
 *         if dict_result is NULL:
 *             raise KeyError, \
 *                 u"extension element %s not found" % funicode(c_inst_node.name)             # <<<<<<<<<<<<<<
 *         extension = <object>dict_result
 * 
 */
        __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_c_inst_node->name); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_612), __pyx_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __Pyx_Raise(__pyx_builtin_KeyError, __pyx_t_1, 0);
        Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        {__pyx_filename = __pyx_f[18]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":99
 *             raise KeyError, \
 *                 u"extension element %s not found" % funicode(c_inst_node.name)
 *         extension = <object>dict_result             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      if (!(__Pyx_TypeTest(((PyObject *)__pyx_v_dict_result), __pyx_ptype_4lxml_5etree_XSLTExtension))) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      Py_INCREF(((PyObject *)__pyx_v_dict_result));
      Py_DECREF(((PyObject *)__pyx_v_extension));
      __pyx_v_extension = ((struct __pyx_obj_4lxml_5etree_XSLTExtension *)((PyObject *)__pyx_v_dict_result));

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":101
 *         extension = <object>dict_result
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             self_node     = _newReadOnlyProxy(None, c_inst_node)
 *             context_node  = _newReadOnlyProxy(self_node, c_context_node)
 */
      /*try:*/ {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":102
 * 
 *         try:
 *             self_node     = _newReadOnlyProxy(None, c_inst_node)             # <<<<<<<<<<<<<<
 *             context_node  = _newReadOnlyProxy(self_node, c_context_node)
 *             output_parent = _newAppendOnlyProxy(self_node, c_ctxt.insert)
 */
        __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None), __pyx_v_c_inst_node)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L12;}
        Py_DECREF(((PyObject *)__pyx_v_self_node));
        __pyx_v_self_node = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_3);
        __pyx_3 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":103
 *         try:
 *             self_node     = _newReadOnlyProxy(None, c_inst_node)
 *             context_node  = _newReadOnlyProxy(self_node, c_context_node)             # <<<<<<<<<<<<<<
 *             output_parent = _newAppendOnlyProxy(self_node, c_ctxt.insert)
 * 
 */
        __pyx_4 = ((PyObject *)__pyx_f_4lxml_5etree__newReadOnlyProxy(__pyx_v_self_node, __pyx_v_c_context_node)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L12;}
        Py_DECREF(((PyObject *)__pyx_v_context_node));
        __pyx_v_context_node = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_4);
        __pyx_4 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":104
 *             self_node     = _newReadOnlyProxy(None, c_inst_node)
 *             context_node  = _newReadOnlyProxy(self_node, c_context_node)
 *             output_parent = _newAppendOnlyProxy(self_node, c_ctxt.insert)             # <<<<<<<<<<<<<<
 * 
 *             context._extension_element_proxy = self_node
 */
        __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__newAppendOnlyProxy(__pyx_v_self_node, __pyx_v_c_ctxt->insert)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L12;}
        Py_DECREF(((PyObject *)__pyx_v_output_parent));
        __pyx_v_output_parent = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)__pyx_2);
        __pyx_2 = 0;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":106
 *             output_parent = _newAppendOnlyProxy(self_node, c_ctxt.insert)
 * 
 *             context._extension_element_proxy = self_node             # <<<<<<<<<<<<<<
 *             extension.execute(context, self_node, context_node, output_parent)
 *         finally:
 */
        Py_INCREF(((PyObject *)__pyx_v_self_node));
        Py_DECREF(((PyObject *)__pyx_v_context->_extension_element_proxy));
        __pyx_v_context->_extension_element_proxy = __pyx_v_self_node;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":107
 * 
 *             context._extension_element_proxy = self_node
 *             extension.execute(context, self_node, context_node, output_parent)             # <<<<<<<<<<<<<<
 *         finally:
 *             context._extension_element_proxy = None
 */
        __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_extension), __pyx_kp_execute); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L12;}
        __pyx_4 = PyTuple_New(4); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L12;}
        Py_INCREF(((PyObject *)__pyx_v_context));
        PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_context));
        Py_INCREF(((PyObject *)__pyx_v_self_node));
        PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_v_self_node));
        Py_INCREF(((PyObject *)__pyx_v_context_node));
        PyTuple_SET_ITEM(__pyx_4, 2, ((PyObject *)__pyx_v_context_node));
        Py_INCREF(((PyObject *)__pyx_v_output_parent));
        PyTuple_SET_ITEM(__pyx_4, 3, ((PyObject *)__pyx_v_output_parent));
        __pyx_2 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L12;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      /*finally:*/ {
        int __pyx_why;
        PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
        int __pyx_exc_lineno;
        __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
        __pyx_why = 0; goto __pyx_L13;
        __pyx_L12: {
          __pyx_why = 4;
          Py_XDECREF(__pyx_3); __pyx_3 = 0;
          Py_XDECREF(__pyx_4); __pyx_4 = 0;
          Py_XDECREF(__pyx_2); __pyx_2 = 0;
          __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
          __pyx_exc_lineno = __pyx_lineno;
          goto __pyx_L13;
        }
        __pyx_L13:;

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":109
 *             extension.execute(context, self_node, context_node, output_parent)
 *         finally:
 *             context._extension_element_proxy = None             # <<<<<<<<<<<<<<
 *             if self_node is not None:
 *                 _freeReadOnlyProxies(self_node)
 */
        Py_INCREF(Py_None);
        Py_DECREF(((PyObject *)__pyx_v_context->_extension_element_proxy));
        __pyx_v_context->_extension_element_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None);

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":110
 *         finally:
 *             context._extension_element_proxy = None
 *             if self_node is not None:             # <<<<<<<<<<<<<<
 *                 _freeReadOnlyProxies(self_node)
 *     except Exception, e:
 */
        __pyx_1 = (((PyObject *)__pyx_v_self_node) != Py_None);
        if (__pyx_1) {

          /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":111
 *             context._extension_element_proxy = None
 *             if self_node is not None:
 *                 _freeReadOnlyProxies(self_node)             # <<<<<<<<<<<<<<
 *     except Exception, e:
 *         e = unicode(e).encode(u"UTF-8")
 */
          __pyx_3 = __pyx_f_4lxml_5etree__freeReadOnlyProxies(__pyx_v_self_node); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          goto __pyx_L15;
        }
        __pyx_L15:;
        goto __pyx_L16;
        __pyx_L14_error:;
        if (__pyx_why == 4) {
          Py_XDECREF(__pyx_exc_type);
          Py_XDECREF(__pyx_exc_value);
          Py_XDECREF(__pyx_exc_tb);
        }
        goto __pyx_L5_error;
        __pyx_L16:;
        switch (__pyx_why) {
          case 4: {
            __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
            __pyx_lineno = __pyx_exc_lineno;
            __pyx_exc_type = 0;
            __pyx_exc_value = 0;
            __pyx_exc_tb = 0;
            goto __pyx_L5_error;
          }
        }
      }
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L9_try;
    __pyx_L5_error:;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":112
 *             if self_node is not None:
 *                 _freeReadOnlyProxies(self_node)
 *     except Exception, e:             # <<<<<<<<<<<<<<
 *         e = unicode(e).encode(u"UTF-8")
 *         message = python.PyString_FromFormat(
 */
    __pyx_5 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_5) {
      __Pyx_AddTraceback("lxml.etree._callExtensionElement");
      if (__Pyx_GetException(&__pyx_4, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_INCREF(__pyx_2);
      Py_DECREF(__pyx_v_e);
      __pyx_v_e = __pyx_2;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":113
 *                 _freeReadOnlyProxies(self_node)
 *     except Exception, e:
 *         e = unicode(e).encode(u"UTF-8")             # <<<<<<<<<<<<<<
 *         message = python.PyString_FromFormat(
 *             "Error executing extension element '%s': %s",
 */
      __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_INCREF(__pyx_v_e);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_e);
      __pyx_7 = PyObject_Call(((PyObject *)((PyObject*)&PyUnicode_Type)), ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      __pyx_6 = PyObject_GetAttr(__pyx_7, __pyx_kp_encode); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      __pyx_7 = PyTuple_New(1); if (unlikely(!__pyx_7)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_INCREF(((PyObject *)__pyx_kp_613));
      PyTuple_SET_ITEM(__pyx_7, 0, ((PyObject *)__pyx_kp_613));
      __pyx_8 = PyObject_Call(__pyx_6, ((PyObject *)__pyx_7), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(((PyObject *)__pyx_7)); __pyx_7 = 0;
      Py_DECREF(__pyx_v_e);
      __pyx_v_e = __pyx_8;
      __pyx_8 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":116
 *         message = python.PyString_FromFormat(
 *             "Error executing extension element '%s': %s",
 *             c_inst_node.name, _cstr(e))             # <<<<<<<<<<<<<<
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)
 *         context._exc._store_raised()
 */
      __pyx_6 = PyString_FromFormat(__pyx_k_614, __pyx_v_c_inst_node->name, PyString_AS_STRING(__pyx_v_e)); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_6;
      __pyx_6 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":117
 *             "Error executing extension element '%s': %s",
 *             c_inst_node.name, _cstr(e))
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)             # <<<<<<<<<<<<<<
 *         context._exc._store_raised()
 *     except:
 */
      __pyx_9 = __Pyx_PyBytes_AsString(__pyx_v_message); if (unlikely((!__pyx_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      xsltTransformError(__pyx_v_c_ctxt, NULL, __pyx_v_c_inst_node, __pyx_9);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":118
 *             c_inst_node.name, _cstr(e))
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)
 *         context._exc._store_raised()             # <<<<<<<<<<<<<<
 *     except:
 *         # just in case
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_context->__pyx_base._exc->__pyx_vtab)->_store_raised(__pyx_v_context->__pyx_base._exc);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L6_exception_handled;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":119
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)
 *         context._exc._store_raised()
 *     except:             # <<<<<<<<<<<<<<
 *         # just in case
 *         message = python.PyString_FromFormat(
 */
    /*except:*/ {
      __Pyx_AddTraceback("lxml.etree._callExtensionElement");
      if (__Pyx_GetException(&__pyx_7, &__pyx_8, &__pyx_6) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":122
 *         # just in case
 *         message = python.PyString_FromFormat(
 *             "Error executing extension element '%s'", c_inst_node.name)             # <<<<<<<<<<<<<<
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)
 *         context._exc._store_raised()
 */
      __pyx_4 = PyString_FromFormat(__pyx_k_615, __pyx_v_c_inst_node->name); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      Py_DECREF(__pyx_v_message);
      __pyx_v_message = __pyx_4;
      __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":123
 *         message = python.PyString_FromFormat(
 *             "Error executing extension element '%s'", c_inst_node.name)
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)             # <<<<<<<<<<<<<<
 *         context._exc._store_raised()
 */
      __pyx_9 = __Pyx_PyBytes_AsString(__pyx_v_message); if (unlikely((!__pyx_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      xsltTransformError(__pyx_v_c_ctxt, NULL, __pyx_v_c_inst_node, __pyx_9);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xsltext.pxi":124
 *             "Error executing extension element '%s'", c_inst_node.name)
 *         xslt.xsltTransformError(c_ctxt, NULL, c_inst_node, message)
 *         context._exc._store_raised()             # <<<<<<<<<<<<<<
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_context->__pyx_base._exc->__pyx_vtab)->_store_raised(__pyx_v_context->__pyx_base._exc);
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_8); __pyx_8 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L9_try:;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_WriteUnraisable("lxml.etree._callExtensionElement");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_context);
  Py_DECREF(__pyx_v_extension);
  Py_DECREF(__pyx_v_context_node);
  Py_DECREF(__pyx_v_self_node);
  Py_DECREF(__pyx_v_output_parent);
  Py_DECREF(__pyx_v_e);
  Py_DECREF(__pyx_v_message);
  PyGILState_Release(_save);
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2640
 *     u"Base class for XML validators."
 *     cdef _ErrorLog _error_log
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         u"__init__(self)"
 *         self._error_log = _ErrorLog()
 */

static int __pyx_pf_4lxml_5etree_10_Validator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_10_Validator___init__[] = "__init__(self)";
static int __pyx_pf_4lxml_5etree_10_Validator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2642
 *     def __init__(self):
 *         u"__init__(self)"
 *         self._error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 * 
 *     def validate(self, etree):
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log));
  ((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_1);
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._Validator.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2644
 *         self._error_log = _ErrorLog()
 * 
 *     def validate(self, etree):             # <<<<<<<<<<<<<<
 *         u"""validate(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_10_Validator_validate(PyObject *__pyx_v_self, PyObject *__pyx_v_etree); /*proto*/
static char __pyx_doc_4lxml_5etree_10_Validator_validate[] = "validate(self, etree)\n\n        Validate the document using this schema.\n\n        Returns true if document is valid, false if not.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_10_Validator_validate(PyObject *__pyx_v_self, PyObject *__pyx_v_etree) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2651
 *         Returns true if document is valid, false if not.
 *         """
 *         return self(etree)             # <<<<<<<<<<<<<<
 * 
 *     def assertValid(self, etree):
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_etree);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_etree);
  __pyx_2 = PyObject_Call(__pyx_v_self, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Validator.validate");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2653
 *         return self(etree)
 * 
 *     def assertValid(self, etree):             # <<<<<<<<<<<<<<
 *         u"""assertValid(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_10_Validator_assertValid(PyObject *__pyx_v_self, PyObject *__pyx_v_etree); /*proto*/
static char __pyx_doc_4lxml_5etree_10_Validator_assertValid[] = "assertValid(self, etree)\n\n        Raises `DocumentInvalid` if the document does not comply with the schema.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_10_Validator_assertValid(PyObject *__pyx_v_self, PyObject *__pyx_v_etree) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2658
 *         Raises `DocumentInvalid` if the document does not comply with the schema.
 *         """
 *         if not self(etree):             # <<<<<<<<<<<<<<
 *             raise DocumentInvalid(self._error_log._buildExceptionMessage(
 *                     u"Document does not comply with schema"),
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_etree);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_etree);
  __pyx_2 = PyObject_Call(__pyx_v_self, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = (!__pyx_3);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2659
 *         """
 *         if not self(etree):
 *             raise DocumentInvalid(self._error_log._buildExceptionMessage(             # <<<<<<<<<<<<<<
 *                     u"Document does not comply with schema"),
 *                                   self._error_log)
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_DocumentInvalid); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2660
 *         if not self(etree):
 *             raise DocumentInvalid(self._error_log._buildExceptionMessage(
 *                     u"Document does not comply with schema"),             # <<<<<<<<<<<<<<
 *                                   self._error_log)
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log), ((PyObject *)__pyx_kp_616)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2661
 *             raise DocumentInvalid(self._error_log._buildExceptionMessage(
 *                     u"Document does not comply with schema"),
 *                                   self._error_log)             # <<<<<<<<<<<<<<
 * 
 *     def assert_(self, etree):
 */
    __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log));
    PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log));
    __pyx_2 = 0;
    __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._Validator.assertValid");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2663
 *                                   self._error_log)
 * 
 *     def assert_(self, etree):             # <<<<<<<<<<<<<<
 *         u"""assert_(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_10_Validator_assert_(PyObject *__pyx_v_self, PyObject *__pyx_v_etree); /*proto*/
static char __pyx_doc_4lxml_5etree_10_Validator_assert_[] = "assert_(self, etree)\n\n        Raises `AssertionError` if the document does not comply with the schema.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_10_Validator_assert_(PyObject *__pyx_v_self, PyObject *__pyx_v_etree) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2668
 *         Raises `AssertionError` if the document does not comply with the schema.
 *         """
 *         if not self(etree):             # <<<<<<<<<<<<<<
 *             raise AssertionError, self._error_log._buildExceptionMessage(
 *                 u"Document does not comply with schema")
 */
  __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_etree);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_etree);
  __pyx_2 = PyObject_Call(__pyx_v_self, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  __pyx_3 = __Pyx_PyObject_IsTrue(__pyx_2); if (unlikely(__pyx_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = (!__pyx_3);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2670
 *         if not self(etree):
 *             raise AssertionError, self._error_log._buildExceptionMessage(
 *                 u"Document does not comply with schema")             # <<<<<<<<<<<<<<
 * 
 *     property error_log:
 */
    __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log), ((PyObject *)__pyx_kp_617)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_builtin_AssertionError, __pyx_1, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Validator.assert_");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2674
 *     property error_log:
 *         u"The log of validation errors and warnings."
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._error_log.copy()
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_10_Validator_9error_log___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4lxml_5etree_10_Validator_9error_log___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2675
 *         u"The log of validation errors and warnings."
 *         def __get__(self):
 *             return self._error_log.copy()             # <<<<<<<<<<<<<<
 * 
 * include "dtd.pxi"        # DTD
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_4lxml_5etree__Validator *)__pyx_v_self)->_error_log), __pyx_kp_copy); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._Validator.error_log.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":31
 *     """
 *     cdef tree.xmlDtd* _c_dtd
 *     def __init__(self, file=None, *, external_id=None):             # <<<<<<<<<<<<<<
 *         self._c_dtd = NULL
 *         _Validator.__init__(self)
 */

static int __pyx_pf_4lxml_5etree_3DTD___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_3DTD___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_file = 0;
  PyObject *__pyx_v_external_id = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  xmlDtd *__pyx_5;
  char *__pyx_6;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_file,&__pyx_kp_external_id,0};
  __pyx_v_file = Py_None;
  __pyx_v_external_id = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_file = values[0];
    }
    if (values[1]) {
      __pyx_v_external_id = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_file = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[19]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.DTD.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  Py_INCREF(__pyx_v_file);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":32
 *     cdef tree.xmlDtd* _c_dtd
 *     def __init__(self, file=None, *, external_id=None):
 *         self._c_dtd = NULL             # <<<<<<<<<<<<<<
 *         _Validator.__init__(self)
 *         if file is not None:
 */
  ((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":33
 *     def __init__(self, file=None, *, external_id=None):
 *         self._c_dtd = NULL
 *         _Validator.__init__(self)             # <<<<<<<<<<<<<<
 *         if file is not None:
 *             if _isString(file):
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Validator)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":34
 *         self._c_dtd = NULL
 *         _Validator.__init__(self)
 *         if file is not None:             # <<<<<<<<<<<<<<
 *             if _isString(file):
 *                 file = _encodeFilename(file)
 */
  __pyx_4 = (__pyx_v_file != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":35
 *         _Validator.__init__(self)
 *         if file is not None:
 *             if _isString(file):             # <<<<<<<<<<<<<<
 *                 file = _encodeFilename(file)
 *                 self._error_log.connect()
 */
    __pyx_4 = _isString(__pyx_v_file);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":36
 *         if file is not None:
 *             if _isString(file):
 *                 file = _encodeFilename(file)             # <<<<<<<<<<<<<<
 *                 self._error_log.connect()
 *                 self._c_dtd = xmlparser.xmlParseDTD(NULL, _cstr(file))
 */
      __pyx_1 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_file); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_file);
      __pyx_v_file = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":37
 *             if _isString(file):
 *                 file = _encodeFilename(file)
 *                 self._error_log.connect()             # <<<<<<<<<<<<<<
 *                 self._c_dtd = xmlparser.xmlParseDTD(NULL, _cstr(file))
 *                 self._error_log.disconnect()
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":38
 *                 file = _encodeFilename(file)
 *                 self._error_log.connect()
 *                 self._c_dtd = xmlparser.xmlParseDTD(NULL, _cstr(file))             # <<<<<<<<<<<<<<
 *                 self._error_log.disconnect()
 *             elif hasattr(file, u'read'):
 */
      ((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd = xmlParseDTD(NULL, PyString_AS_STRING(__pyx_v_file));

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":39
 *                 self._error_log.connect()
 *                 self._c_dtd = xmlparser.xmlParseDTD(NULL, _cstr(file))
 *                 self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             elif hasattr(file, u'read'):
 *                 self._c_dtd = _parseDtdFromFilelike(file)
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);
      goto __pyx_L7;
    }

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":40
 *                 self._c_dtd = xmlparser.xmlParseDTD(NULL, _cstr(file))
 *                 self._error_log.disconnect()
 *             elif hasattr(file, u'read'):             # <<<<<<<<<<<<<<
 *                 self._c_dtd = _parseDtdFromFilelike(file)
 *             else:
 */
    __pyx_4 = PyObject_HasAttr(__pyx_v_file, ((PyObject *)__pyx_kp_618)); if (unlikely(__pyx_4 == -1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":41
 *                 self._error_log.disconnect()
 *             elif hasattr(file, u'read'):
 *                 self._c_dtd = _parseDtdFromFilelike(file)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise DTDParseError, u"file must be a filename or file-like object"
 */
      __pyx_5 = __pyx_f_4lxml_5etree__parseDtdFromFilelike(__pyx_v_file); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      ((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd = __pyx_5;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":43
 *                 self._c_dtd = _parseDtdFromFilelike(file)
 *             else:
 *                 raise DTDParseError, u"file must be a filename or file-like object"             # <<<<<<<<<<<<<<
 *         elif external_id is not None:
 *             self._error_log.connect()
 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDParseError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_2, ((PyObject *)__pyx_kp_619), 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[19]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":44
 *             else:
 *                 raise DTDParseError, u"file must be a filename or file-like object"
 *         elif external_id is not None:             # <<<<<<<<<<<<<<
 *             self._error_log.connect()
 *             self._c_dtd = xmlparser.xmlParseDTD(external_id, NULL)
 */
  __pyx_4 = (__pyx_v_external_id != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":45
 *                 raise DTDParseError, u"file must be a filename or file-like object"
 *         elif external_id is not None:
 *             self._error_log.connect()             # <<<<<<<<<<<<<<
 *             self._c_dtd = xmlparser.xmlParseDTD(external_id, NULL)
 *             self._error_log.disconnect()
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":46
 *         elif external_id is not None:
 *             self._error_log.connect()
 *             self._c_dtd = xmlparser.xmlParseDTD(external_id, NULL)             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 *         else:
 */
    __pyx_6 = __Pyx_PyBytes_AsString(__pyx_v_external_id); if (unlikely((!__pyx_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd = xmlParseDTD(__pyx_6, NULL);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":47
 *             self._error_log.connect()
 *             self._c_dtd = xmlparser.xmlParseDTD(external_id, NULL)
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *         else:
 *             raise DTDParseError, u"either filename or external ID required"
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":49
 *             self._error_log.disconnect()
 *         else:
 *             raise DTDParseError, u"either filename or external ID required"             # <<<<<<<<<<<<<<
 * 
 *         if self._c_dtd is NULL:
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDParseError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_620), 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[19]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":51
 *             raise DTDParseError, u"either filename or external ID required"
 * 
 *         if self._c_dtd is NULL:             # <<<<<<<<<<<<<<
 *             raise DTDParseError(
 *                 self._error_log._buildExceptionMessage(u"error parsing DTD"),
 */
  __pyx_4 = (((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":52
 * 
 *         if self._c_dtd is NULL:
 *             raise DTDParseError(             # <<<<<<<<<<<<<<
 *                 self._error_log._buildExceptionMessage(u"error parsing DTD"),
 *                 self._error_log)
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDParseError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":53
 *         if self._c_dtd is NULL:
 *             raise DTDParseError(
 *                 self._error_log._buildExceptionMessage(u"error parsing DTD"),             # <<<<<<<<<<<<<<
 *                 self._error_log)
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log), ((PyObject *)__pyx_kp_621)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":54
 *             raise DTDParseError(
 *                 self._error_log._buildExceptionMessage(u"error parsing DTD"),
 *                 self._error_log)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_2 = 0;
    __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[19]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.DTD.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_file);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":56
 *                 self._error_log)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         tree.xmlFreeDtd(self._c_dtd)
 * 
 */

static void __pyx_pf_4lxml_5etree_3DTD___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_3DTD___dealloc__(PyObject *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":57
 * 
 *     def __dealloc__(self):
 *         tree.xmlFreeDtd(self._c_dtd)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, etree):
 */
  xmlFreeDtd(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":59
 *         tree.xmlFreeDtd(self._c_dtd)
 * 
 *     def __call__(self, etree):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_3DTD___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_3DTD___call__[] = "__call__(self, etree)\n\n        Validate doc using the DTD.\n\n        Returns true if the document is valid, false if not.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_3DTD___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlDoc *__pyx_v_c_doc;
  xmlValidCtxt *__pyx_v_valid_ctxt;
  int __pyx_v_ret;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  xmlDoc *__pyx_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[19]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.DTD.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":72
 *         cdef int ret
 * 
 *         doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *         root_node = _rootNodeOrRaise(etree)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":73
 * 
 *         doc = _documentOrRaise(etree)
 *         root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.connect()
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root_node));
  __pyx_v_root_node = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":75
 *         root_node = _rootNodeOrRaise(etree)
 * 
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         valid_ctxt = dtdvalid.xmlNewValidCtxt()
 *         if valid_ctxt is NULL:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":76
 * 
 *         self._error_log.connect()
 *         valid_ctxt = dtdvalid.xmlNewValidCtxt()             # <<<<<<<<<<<<<<
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()
 */
  __pyx_v_valid_ctxt = xmlNewValidCtxt();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":77
 *         self._error_log.connect()
 *         valid_ctxt = dtdvalid.xmlNewValidCtxt()
 *         if valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 *             raise DTDError(u"Failed to create validation context",
 */
  __pyx_2 = (__pyx_v_valid_ctxt == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":78
 *         valid_ctxt = dtdvalid.xmlNewValidCtxt()
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             raise DTDError(u"Failed to create validation context",
 *                            self._error_log)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":79
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()
 *             raise DTDError(u"Failed to create validation context",             # <<<<<<<<<<<<<<
 *                            self._error_log)
 * 
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":80
 *             self._error_log.disconnect()
 *             raise DTDError(u"Failed to create validation context",
 *                            self._error_log)             # <<<<<<<<<<<<<<
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_622));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_622));
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[19]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":82
 *                            self._error_log)
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             ret = dtdvalid.xmlValidateDtd(valid_ctxt, c_doc, self._c_dtd)
 */
  __pyx_5 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_5;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":83
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = dtdvalid.xmlValidateDtd(valid_ctxt, c_doc, self._c_dtd)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":84
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:
 *             ret = dtdvalid.xmlValidateDtd(valid_ctxt, c_doc, self._c_dtd)             # <<<<<<<<<<<<<<
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 * 
 */
      __pyx_v_ret = xmlValidateDtd(__pyx_v_valid_ctxt, __pyx_v_c_doc, ((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->_c_dtd);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":85
 *         with nogil:
 *             ret = dtdvalid.xmlValidateDtd(valid_ctxt, c_doc, self._c_dtd)
 *         _destroyFakeDoc(doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 * 
 *         dtdvalid.xmlFreeValidCtxt(valid_ctxt)
 */
  __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":87
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 * 
 *         dtdvalid.xmlFreeValidCtxt(valid_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.disconnect()
 */
  xmlFreeValidCtxt(__pyx_v_valid_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":89
 *         dtdvalid.xmlFreeValidCtxt(valid_ctxt)
 * 
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *         if ret == -1:
 *             raise DTDValidateError(u"Internal error in DTD validation",
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":90
 * 
 *         self._error_log.disconnect()
 *         if ret == -1:             # <<<<<<<<<<<<<<
 *             raise DTDValidateError(u"Internal error in DTD validation",
 *                                    self._error_log)
 */
  __pyx_2 = (__pyx_v_ret == -1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":91
 *         self._error_log.disconnect()
 *         if ret == -1:
 *             raise DTDValidateError(u"Internal error in DTD validation",             # <<<<<<<<<<<<<<
 *                                    self._error_log)
 *         if ret == 1:
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDValidateError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":92
 *         if ret == -1:
 *             raise DTDValidateError(u"Internal error in DTD validation",
 *                                    self._error_log)             # <<<<<<<<<<<<<<
 *         if ret == 1:
 *             return True
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_623));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_623));
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_4 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[19]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":93
 *             raise DTDValidateError(u"Internal error in DTD validation",
 *                                    self._error_log)
 *         if ret == 1:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_2 = (__pyx_v_ret == 1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":94
 *                                    self._error_log)
 *         if ret == 1:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":96
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L11:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree.DTD.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":99
 * 
 * 
 * cdef tree.xmlDtd* _parseDtdFromFilelike(file) except NULL:             # <<<<<<<<<<<<<<
 *     cdef _ExceptionContext exc_context
 *     cdef _FileReaderContext dtd_parser
 */

static  xmlDtd *__pyx_f_4lxml_5etree__parseDtdFromFilelike(PyObject *__pyx_v_file) {
  struct __pyx_obj_4lxml_5etree__ExceptionContext *__pyx_v_exc_context;
  struct __pyx_obj_4lxml_5etree__FileReaderContext *__pyx_v_dtd_parser;
  struct __pyx_obj_4lxml_5etree__ErrorLog *__pyx_v_error_log;
  xmlDtd *__pyx_v_c_dtd;
  xmlDtd *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  __pyx_v_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_dtd_parser = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":104
 *     cdef _ErrorLog error_log
 *     cdef tree.xmlDtd* c_dtd
 *     exc_context = _ExceptionContext()             # <<<<<<<<<<<<<<
 *     dtd_parser = _FileReaderContext(file, exc_context, None, None)
 *     error_log = _ErrorLog()
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ExceptionContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ExceptionContext))) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_exc_context));
  __pyx_v_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":105
 *     cdef tree.xmlDtd* c_dtd
 *     exc_context = _ExceptionContext()
 *     dtd_parser = _FileReaderContext(file, exc_context, None, None)             # <<<<<<<<<<<<<<
 *     error_log = _ErrorLog()
 * 
 */
  __pyx_1 = PyTuple_New(4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_file);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_file);
  Py_INCREF(((PyObject *)__pyx_v_exc_context));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_exc_context));
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_1, 2, Py_None);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_1, 3, Py_None);
  __pyx_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__FileReaderContext)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_4lxml_5etree__FileReaderContext))) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_dtd_parser));
  __pyx_v_dtd_parser = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":106
 *     exc_context = _ExceptionContext()
 *     dtd_parser = _FileReaderContext(file, exc_context, None, None)
 *     error_log = _ErrorLog()             # <<<<<<<<<<<<<<
 * 
 *     error_log.connect()
 */
  __pyx_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ErrorLog)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_1, __pyx_ptype_4lxml_5etree__ErrorLog))) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_error_log));
  __pyx_v_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":108
 *     error_log = _ErrorLog()
 * 
 *     error_log.connect()             # <<<<<<<<<<<<<<
 *     c_dtd = dtd_parser._readDtd()
 *     error_log.disconnect()
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(__pyx_v_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":109
 * 
 *     error_log.connect()
 *     c_dtd = dtd_parser._readDtd()             # <<<<<<<<<<<<<<
 *     error_log.disconnect()
 * 
 */
  __pyx_v_c_dtd = ((struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext *)__pyx_v_dtd_parser->__pyx_vtab)->_readDtd(__pyx_v_dtd_parser);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":110
 *     error_log.connect()
 *     c_dtd = dtd_parser._readDtd()
 *     error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *     exc_context._raise_if_stored()
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)__pyx_v_error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(__pyx_v_error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":112
 *     error_log.disconnect()
 * 
 *     exc_context._raise_if_stored()             # <<<<<<<<<<<<<<
 *     if c_dtd is NULL:
 *         raise DTDParseError(u"error parsing DTD", error_log)
 */
  __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext *)__pyx_v_exc_context->__pyx_vtab)->_raise_if_stored(__pyx_v_exc_context); if (unlikely(__pyx_3 == -1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":113
 * 
 *     exc_context._raise_if_stored()
 *     if c_dtd is NULL:             # <<<<<<<<<<<<<<
 *         raise DTDParseError(u"error parsing DTD", error_log)
 *     return c_dtd
 */
  __pyx_4 = (__pyx_v_c_dtd == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":114
 *     exc_context._raise_if_stored()
 *     if c_dtd is NULL:
 *         raise DTDParseError(u"error parsing DTD", error_log)             # <<<<<<<<<<<<<<
 *     return c_dtd
 * 
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDParseError); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = PyTuple_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_624));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_kp_624));
    Py_INCREF(((PyObject *)__pyx_v_error_log));
    PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_error_log));
    __pyx_5 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[19]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":115
 *     if c_dtd is NULL:
 *         raise DTDParseError(u"error parsing DTD", error_log)
 *     return c_dtd             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "etree_defs.h":
 */
  __pyx_r = __pyx_v_c_dtd;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree._parseDtdFromFilelike");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_exc_context);
  Py_DECREF(__pyx_v_dtd_parser);
  Py_DECREF((PyObject *)__pyx_v_error_log);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":121
 *     cdef DTD NEW_DTD "PY_NEW" (object t)
 * 
 * cdef DTD _dtdFactory(tree.xmlDtd* c_dtd):             # <<<<<<<<<<<<<<
 *     # do not run through DTD.__init__()!
 *     cdef DTD dtd
 */

static  struct __pyx_obj_4lxml_5etree_DTD *__pyx_f_4lxml_5etree__dtdFactory(xmlDtd *__pyx_v_c_dtd) {
  struct __pyx_obj_4lxml_5etree_DTD *__pyx_v_dtd;
  struct __pyx_obj_4lxml_5etree_DTD *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_dtd = ((struct __pyx_obj_4lxml_5etree_DTD *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":124
 *     # do not run through DTD.__init__()!
 *     cdef DTD dtd
 *     if c_dtd is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     dtd = NEW_DTD(DTD)
 */
  __pyx_1 = (__pyx_v_c_dtd == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":125
 *     cdef DTD dtd
 *     if c_dtd is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     dtd = NEW_DTD(DTD)
 *     dtd._c_dtd = tree.xmlCopyDtd(c_dtd)
 */
    Py_INCREF(Py_None);
    __pyx_r = ((struct __pyx_obj_4lxml_5etree_DTD *)Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":126
 *     if c_dtd is NULL:
 *         return None
 *     dtd = NEW_DTD(DTD)             # <<<<<<<<<<<<<<
 *     dtd._c_dtd = tree.xmlCopyDtd(c_dtd)
 *     if dtd._c_dtd is NULL:
 */
  __pyx_2 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_DTD)))); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_dtd));
  __pyx_v_dtd = ((struct __pyx_obj_4lxml_5etree_DTD *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":127
 *         return None
 *     dtd = NEW_DTD(DTD)
 *     dtd._c_dtd = tree.xmlCopyDtd(c_dtd)             # <<<<<<<<<<<<<<
 *     if dtd._c_dtd is NULL:
 *         python.PyErr_NoMemory()
 */
  __pyx_v_dtd->_c_dtd = xmlCopyDtd(__pyx_v_c_dtd);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":128
 *     dtd = NEW_DTD(DTD)
 *     dtd._c_dtd = tree.xmlCopyDtd(c_dtd)
 *     if dtd._c_dtd is NULL:             # <<<<<<<<<<<<<<
 *         python.PyErr_NoMemory()
 *     _Validator.__init__(dtd)
 */
  __pyx_1 = (__pyx_v_dtd->_c_dtd == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":129
 *     dtd._c_dtd = tree.xmlCopyDtd(c_dtd)
 *     if dtd._c_dtd is NULL:
 *         python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *     _Validator.__init__(dtd)
 *     return dtd
 */
    __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":130
 *     if dtd._c_dtd is NULL:
 *         python.PyErr_NoMemory()
 *     _Validator.__init__(dtd)             # <<<<<<<<<<<<<<
 *     return dtd
 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Validator)), __pyx_kp___init__); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_dtd));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_dtd));
  __pyx_4 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":131
 *         python.PyErr_NoMemory()
 *     _Validator.__init__(dtd)
 *     return dtd             # <<<<<<<<<<<<<<
 */
  Py_INCREF(((PyObject *)__pyx_v_dtd));
  __pyx_r = __pyx_v_dtd;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree_DTD *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("lxml.etree._dtdFactory");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_dtd);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":30
 *     """
 *     cdef relaxng.xmlRelaxNG* _c_schema
 *     def __init__(self, etree=None, *, file=None):             # <<<<<<<<<<<<<<
 *         cdef _Document doc
 *         cdef _Element root_node
 */

static int __pyx_pf_4lxml_5etree_7RelaxNG___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_7RelaxNG___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  PyObject *__pyx_v_file = 0;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlNode *__pyx_v_c_node;
  xmlDoc *__pyx_v_fake_c_doc;
  char *__pyx_v_c_href;
  xmlRelaxNGParserCtxt *__pyx_v_parser_ctxt;
  PyObject *__pyx_v_filename;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  xmlDoc *__pyx_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,&__pyx_kp_file,0};
  __pyx_v_etree = Py_None;
  __pyx_v_file = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_etree = values[0];
    }
    if (values[1]) {
      __pyx_v_file = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[20]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.RelaxNG.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filename = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":37
 *         cdef char* c_href
 *         cdef relaxng.xmlRelaxNGParserCtxt* parser_ctxt
 *         _Validator.__init__(self)             # <<<<<<<<<<<<<<
 *         self._c_schema = NULL
 *         fake_c_doc = NULL
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Validator)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":38
 *         cdef relaxng.xmlRelaxNGParserCtxt* parser_ctxt
 *         _Validator.__init__(self)
 *         self._c_schema = NULL             # <<<<<<<<<<<<<<
 *         fake_c_doc = NULL
 *         if etree is not None:
 */
  ((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->_c_schema = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":39
 *         _Validator.__init__(self)
 *         self._c_schema = NULL
 *         fake_c_doc = NULL             # <<<<<<<<<<<<<<
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)
 */
  __pyx_v_fake_c_doc = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":40
 *         self._c_schema = NULL
 *         fake_c_doc = NULL
 *         if etree is not None:             # <<<<<<<<<<<<<<
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)
 */
  __pyx_4 = (__pyx_v_etree != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":41
 *         fake_c_doc = NULL
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *             root_node = _rootNodeOrRaise(etree)
 *             c_node = root_node._c_node
 */
    __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":42
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 *             c_node = root_node._c_node
 *             # work around for libxml2 crash bug if document is not RNG at all
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_root_node));
    __pyx_v_root_node = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":43
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)
 *             c_node = root_node._c_node             # <<<<<<<<<<<<<<
 *             # work around for libxml2 crash bug if document is not RNG at all
 *             if _LIBXML_VERSION_INT < 20624:
 */
    __pyx_v_c_node = __pyx_v_root_node->_c_node;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":45
 *             c_node = root_node._c_node
 *             # work around for libxml2 crash bug if document is not RNG at all
 *             if _LIBXML_VERSION_INT < 20624:             # <<<<<<<<<<<<<<
 *                 c_href = _getNs(c_node)
 *                 if c_href is NULL or \
 */
    __pyx_4 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT < 20624);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":46
 *             # work around for libxml2 crash bug if document is not RNG at all
 *             if _LIBXML_VERSION_INT < 20624:
 *                 c_href = _getNs(c_node)             # <<<<<<<<<<<<<<
 *                 if c_href is NULL or \
 *                        cstd.strcmp(c_href,
 */
      __pyx_v_c_href = _getNs(__pyx_v_c_node);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":47
 *             if _LIBXML_VERSION_INT < 20624:
 *                 c_href = _getNs(c_node)
 *                 if c_href is NULL or \             # <<<<<<<<<<<<<<
 *                        cstd.strcmp(c_href,
 *                                    'http://relaxng.org/ns/structure/1.0') != 0:
 */
      __pyx_4 = (__pyx_v_c_href == NULL);
      if (!__pyx_4) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":49
 *                 if c_href is NULL or \
 *                        cstd.strcmp(c_href,
 *                                    'http://relaxng.org/ns/structure/1.0') != 0:             # <<<<<<<<<<<<<<
 *                     raise RelaxNGParseError, u"Document is not Relax NG"
 *             self._error_log.connect()
 */
        __pyx_4 = (strcmp(__pyx_v_c_href, __pyx_k_625) != 0);
      }
      if (__pyx_4) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":50
 *                        cstd.strcmp(c_href,
 *                                    'http://relaxng.org/ns/structure/1.0') != 0:
 *                     raise RelaxNGParseError, u"Document is not Relax NG"             # <<<<<<<<<<<<<<
 *             self._error_log.connect()
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 */
        __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGParseError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_626), 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[20]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":51
 *                                    'http://relaxng.org/ns/structure/1.0') != 0:
 *                     raise RelaxNGParseError, u"Document is not Relax NG"
 *             self._error_log.connect()             # <<<<<<<<<<<<<<
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *             parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(fake_c_doc)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":52
 *                     raise RelaxNGParseError, u"Document is not Relax NG"
 *             self._error_log.connect()
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *             parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(fake_c_doc)
 *         elif file is not None:
 */
    __pyx_5 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_fake_c_doc = __pyx_5;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":53
 *             self._error_log.connect()
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *             parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(fake_c_doc)             # <<<<<<<<<<<<<<
 *         elif file is not None:
 *             if _isString(file):
 */
    __pyx_v_parser_ctxt = xmlRelaxNGNewDocParserCtxt(__pyx_v_fake_c_doc);
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":54
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *             parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(fake_c_doc)
 *         elif file is not None:             # <<<<<<<<<<<<<<
 *             if _isString(file):
 *                 filename = _encodeFilename(file)
 */
  __pyx_4 = (__pyx_v_file != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":55
 *             parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(fake_c_doc)
 *         elif file is not None:
 *             if _isString(file):             # <<<<<<<<<<<<<<
 *                 filename = _encodeFilename(file)
 *                 self._error_log.connect()
 */
    __pyx_4 = _isString(__pyx_v_file);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":56
 *         elif file is not None:
 *             if _isString(file):
 *                 filename = _encodeFilename(file)             # <<<<<<<<<<<<<<
 *                 self._error_log.connect()
 *                 parser_ctxt = relaxng.xmlRelaxNGNewParserCtxt(_cstr(filename))
 */
      __pyx_1 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_file); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_filename);
      __pyx_v_filename = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":57
 *             if _isString(file):
 *                 filename = _encodeFilename(file)
 *                 self._error_log.connect()             # <<<<<<<<<<<<<<
 *                 parser_ctxt = relaxng.xmlRelaxNGNewParserCtxt(_cstr(filename))
 *             else:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":58
 *                 filename = _encodeFilename(file)
 *                 self._error_log.connect()
 *                 parser_ctxt = relaxng.xmlRelaxNGNewParserCtxt(_cstr(filename))             # <<<<<<<<<<<<<<
 *             else:
 *                 doc = _parseDocument(file, None, None)
 */
      __pyx_v_parser_ctxt = xmlRelaxNGNewParserCtxt(PyString_AS_STRING(__pyx_v_filename));
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":60
 *                 parser_ctxt = relaxng.xmlRelaxNGNewParserCtxt(_cstr(filename))
 *             else:
 *                 doc = _parseDocument(file, None, None)             # <<<<<<<<<<<<<<
 *                 self._error_log.connect()
 *                 parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc)
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocument(__pyx_v_file, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None), Py_None)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":61
 *             else:
 *                 doc = _parseDocument(file, None, None)
 *                 self._error_log.connect()             # <<<<<<<<<<<<<<
 *                 parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc)
 *         else:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":62
 *                 doc = _parseDocument(file, None, None)
 *                 self._error_log.connect()
 *                 parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc)             # <<<<<<<<<<<<<<
 *         else:
 *             raise RelaxNGParseError, u"No tree or file given"
 */
      __pyx_v_parser_ctxt = xmlRelaxNGNewDocParserCtxt(__pyx_v_doc->_c_doc);
    }
    __pyx_L9:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":64
 *                 parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc)
 *         else:
 *             raise RelaxNGParseError, u"No tree or file given"             # <<<<<<<<<<<<<<
 * 
 *         if parser_ctxt is NULL:
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGParseError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_627), 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[20]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":66
 *             raise RelaxNGParseError, u"No tree or file given"
 * 
 *         if parser_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 *             if fake_c_doc is not NULL:
 */
  __pyx_4 = (__pyx_v_parser_ctxt == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":67
 * 
 *         if parser_ctxt is NULL:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             if fake_c_doc is not NULL:
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":68
 *         if parser_ctxt is NULL:
 *             self._error_log.disconnect()
 *             if fake_c_doc is not NULL:             # <<<<<<<<<<<<<<
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)
 *             raise RelaxNGParseError(
 */
    __pyx_4 = (__pyx_v_fake_c_doc != NULL);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":69
 *             self._error_log.disconnect()
 *             if fake_c_doc is not NULL:
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)             # <<<<<<<<<<<<<<
 *             raise RelaxNGParseError(
 *                 self._error_log._buildExceptionMessage(
 */
      __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_fake_c_doc);
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":70
 *             if fake_c_doc is not NULL:
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)
 *             raise RelaxNGParseError(             # <<<<<<<<<<<<<<
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not parsable as Relax NG"),
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGParseError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":72
 *             raise RelaxNGParseError(
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not parsable as Relax NG"),             # <<<<<<<<<<<<<<
 *                 self._error_log)
 *         self._c_schema = relaxng.xmlRelaxNGParse(parser_ctxt)
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log), ((PyObject *)__pyx_kp_628)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":73
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not parsable as Relax NG"),
 *                 self._error_log)             # <<<<<<<<<<<<<<
 *         self._c_schema = relaxng.xmlRelaxNGParse(parser_ctxt)
 *         self._error_log.disconnect()
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_2 = 0;
    __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[20]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":74
 *                     u"Document is not parsable as Relax NG"),
 *                 self._error_log)
 *         self._c_schema = relaxng.xmlRelaxNGParse(parser_ctxt)             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 * 
 */
  ((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->_c_schema = xmlRelaxNGParse(__pyx_v_parser_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":75
 *                 self._error_log)
 *         self._c_schema = relaxng.xmlRelaxNGParse(parser_ctxt)
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         if _LIBXML_VERSION_INT >= 20624:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":77
 *         self._error_log.disconnect()
 * 
 *         if _LIBXML_VERSION_INT >= 20624:             # <<<<<<<<<<<<<<
 *             relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 *         if self._c_schema is NULL:
 */
  __pyx_4 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT >= 20624);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":78
 * 
 *         if _LIBXML_VERSION_INT >= 20624:
 *             relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)             # <<<<<<<<<<<<<<
 *         if self._c_schema is NULL:
 *             if fake_c_doc is not NULL:
 */
    xmlRelaxNGFreeParserCtxt(__pyx_v_parser_ctxt);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":79
 *         if _LIBXML_VERSION_INT >= 20624:
 *             relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 *         if self._c_schema is NULL:             # <<<<<<<<<<<<<<
 *             if fake_c_doc is not NULL:
 *                 if _LIBXML_VERSION_INT < 20624:
 */
  __pyx_4 = (((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->_c_schema == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":80
 *             relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 *         if self._c_schema is NULL:
 *             if fake_c_doc is not NULL:             # <<<<<<<<<<<<<<
 *                 if _LIBXML_VERSION_INT < 20624:
 *                     relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 */
    __pyx_4 = (__pyx_v_fake_c_doc != NULL);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":81
 *         if self._c_schema is NULL:
 *             if fake_c_doc is not NULL:
 *                 if _LIBXML_VERSION_INT < 20624:             # <<<<<<<<<<<<<<
 *                     relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)
 */
      __pyx_4 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT < 20624);
      if (__pyx_4) {

        /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":82
 *             if fake_c_doc is not NULL:
 *                 if _LIBXML_VERSION_INT < 20624:
 *                     relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)             # <<<<<<<<<<<<<<
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)
 *             raise RelaxNGParseError(
 */
        xmlRelaxNGFreeParserCtxt(__pyx_v_parser_ctxt);
        goto __pyx_L15;
      }
      __pyx_L15:;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":83
 *                 if _LIBXML_VERSION_INT < 20624:
 *                     relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)             # <<<<<<<<<<<<<<
 *             raise RelaxNGParseError(
 *                 self._error_log._buildExceptionMessage(
 */
      __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_fake_c_doc);
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":84
 *                     relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt)
 *                 _destroyFakeDoc(doc._c_doc, fake_c_doc)
 *             raise RelaxNGParseError(             # <<<<<<<<<<<<<<
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not valid Relax NG"),
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGParseError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":86
 *             raise RelaxNGParseError(
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not valid Relax NG"),             # <<<<<<<<<<<<<<
 *                 self._error_log)
 *         if fake_c_doc is not NULL:
 */
    __pyx_3 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log), ((PyObject *)__pyx_kp_629)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":87
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not valid Relax NG"),
 *                 self._error_log)             # <<<<<<<<<<<<<<
 *         if fake_c_doc is not NULL:
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)
 */
    __pyx_2 = PyTuple_New(2); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_3 = 0;
    __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[20]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":88
 *                     u"Document is not valid Relax NG"),
 *                 self._error_log)
 *         if fake_c_doc is not NULL:             # <<<<<<<<<<<<<<
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)
 * 
 */
  __pyx_4 = (__pyx_v_fake_c_doc != NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":89
 *                 self._error_log)
 *         if fake_c_doc is not NULL:
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_fake_c_doc);
    goto __pyx_L16;
  }
  __pyx_L16:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.RelaxNG.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":91
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         relaxng.xmlRelaxNGFree(self._c_schema)
 * 
 */

static void __pyx_pf_4lxml_5etree_7RelaxNG___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_7RelaxNG___dealloc__(PyObject *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":92
 * 
 *     def __dealloc__(self):
 *         relaxng.xmlRelaxNGFree(self._c_schema)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, etree):
 */
  xmlRelaxNGFree(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->_c_schema);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":94
 *         relaxng.xmlRelaxNGFree(self._c_schema)
 * 
 *     def __call__(self, etree):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_7RelaxNG___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_7RelaxNG___call__[] = "__call__(self, etree)\n\n        Validate doc using Relax NG.\n\n        Returns true if document is valid, false if not.";
static PyObject *__pyx_pf_4lxml_5etree_7RelaxNG___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlDoc *__pyx_v_c_doc;
  xmlRelaxNGValidCtxt *__pyx_v_valid_ctxt;
  int __pyx_v_ret;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  xmlDoc *__pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[20]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.RelaxNG.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":106
 *         cdef int ret
 * 
 *         doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *         root_node = _rootNodeOrRaise(etree)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":107
 * 
 *         doc = _documentOrRaise(etree)
 *         root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.connect()
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root_node));
  __pyx_v_root_node = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":109
 *         root_node = _rootNodeOrRaise(etree)
 * 
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         valid_ctxt = relaxng.xmlRelaxNGNewValidCtxt(self._c_schema)
 *         if valid_ctxt is NULL:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":110
 * 
 *         self._error_log.connect()
 *         valid_ctxt = relaxng.xmlRelaxNGNewValidCtxt(self._c_schema)             # <<<<<<<<<<<<<<
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()
 */
  __pyx_v_valid_ctxt = xmlRelaxNGNewValidCtxt(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->_c_schema);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":111
 *         self._error_log.connect()
 *         valid_ctxt = relaxng.xmlRelaxNGNewValidCtxt(self._c_schema)
 *         if valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 *             python.PyErr_NoMemory()
 */
  __pyx_2 = (__pyx_v_valid_ctxt == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":112
 *         valid_ctxt = relaxng.xmlRelaxNGNewValidCtxt(self._c_schema)
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 * 
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":113
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":115
 *             python.PyErr_NoMemory()
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             ret = relaxng.xmlRelaxNGValidateDoc(valid_ctxt, c_doc)
 */
  __pyx_3 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":116
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = relaxng.xmlRelaxNGValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":117
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:
 *             ret = relaxng.xmlRelaxNGValidateDoc(valid_ctxt, c_doc)             # <<<<<<<<<<<<<<
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 * 
 */
      __pyx_v_ret = xmlRelaxNGValidateDoc(__pyx_v_valid_ctxt, __pyx_v_c_doc);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":118
 *         with nogil:
 *             ret = relaxng.xmlRelaxNGValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 * 
 *         relaxng.xmlRelaxNGFreeValidCtxt(valid_ctxt)
 */
  __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":120
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 * 
 *         relaxng.xmlRelaxNGFreeValidCtxt(valid_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.disconnect()
 */
  xmlRelaxNGFreeValidCtxt(__pyx_v_valid_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":122
 *         relaxng.xmlRelaxNGFreeValidCtxt(valid_ctxt)
 * 
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *         if ret == -1:
 *             raise RelaxNGValidateError(
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":123
 * 
 *         self._error_log.disconnect()
 *         if ret == -1:             # <<<<<<<<<<<<<<
 *             raise RelaxNGValidateError(
 *                 u"Internal error in Relax NG validation",
 */
  __pyx_2 = (__pyx_v_ret == -1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":124
 *         self._error_log.disconnect()
 *         if ret == -1:
 *             raise RelaxNGValidateError(             # <<<<<<<<<<<<<<
 *                 u"Internal error in Relax NG validation",
 *                 self._error_log)
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_201); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":126
 *             raise RelaxNGValidateError(
 *                 u"Internal error in Relax NG validation",
 *                 self._error_log)             # <<<<<<<<<<<<<<
 *         if ret == 0:
 *             return True
 */
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_630));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_kp_630));
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_RelaxNG *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_5 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[20]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":127
 *                 u"Internal error in Relax NG validation",
 *                 self._error_log)
 *         if ret == 0:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_2 = (__pyx_v_ret == 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":128
 *                 self._error_log)
 *         if ret == 0:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":130
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 */
    __pyx_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L11:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.RelaxNG.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":30
 *     """
 *     cdef xmlschema.xmlSchema* _c_schema
 *     def __init__(self, etree=None, *, file=None):             # <<<<<<<<<<<<<<
 *         cdef _Document doc
 *         cdef _Element root_node
 */

static int __pyx_pf_4lxml_5etree_9XMLSchema___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_9XMLSchema___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  PyObject *__pyx_v_file = 0;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlDoc *__pyx_v_fake_c_doc;
  xmlNode *__pyx_v_c_node;
  char *__pyx_v_c_href;
  xmlSchemaParserCtxt *__pyx_v_parser_ctxt;
  PyObject *__pyx_v_filename;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  xmlDoc *__pyx_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,&__pyx_kp_file,0};
  __pyx_v_etree = Py_None;
  __pyx_v_file = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_etree = values[0];
    }
    if (values[1]) {
      __pyx_v_file = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[21]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XMLSchema.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filename = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":37
 *         cdef char* c_href
 *         cdef xmlschema.xmlSchemaParserCtxt* parser_ctxt
 *         _Validator.__init__(self)             # <<<<<<<<<<<<<<
 *         self._c_schema = NULL
 *         fake_c_doc = NULL
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Validator)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":38
 *         cdef xmlschema.xmlSchemaParserCtxt* parser_ctxt
 *         _Validator.__init__(self)
 *         self._c_schema = NULL             # <<<<<<<<<<<<<<
 *         fake_c_doc = NULL
 *         if etree is not None:
 */
  ((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->_c_schema = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":39
 *         _Validator.__init__(self)
 *         self._c_schema = NULL
 *         fake_c_doc = NULL             # <<<<<<<<<<<<<<
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)
 */
  __pyx_v_fake_c_doc = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":40
 *         self._c_schema = NULL
 *         fake_c_doc = NULL
 *         if etree is not None:             # <<<<<<<<<<<<<<
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)
 */
  __pyx_4 = (__pyx_v_etree != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":41
 *         fake_c_doc = NULL
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *             root_node = _rootNodeOrRaise(etree)
 * 
 */
    __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":42
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 * 
 *             # work around for libxml2 bug if document is not XML schema at all
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_root_node));
    __pyx_v_root_node = ((struct LxmlElement *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":46
 *             # work around for libxml2 bug if document is not XML schema at all
 *             #if _LIBXML_VERSION_INT < 20624:
 *             c_node = root_node._c_node             # <<<<<<<<<<<<<<
 *             c_href = _getNs(c_node)
 *             if c_href is NULL or \
 */
    __pyx_v_c_node = __pyx_v_root_node->_c_node;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":47
 *             #if _LIBXML_VERSION_INT < 20624:
 *             c_node = root_node._c_node
 *             c_href = _getNs(c_node)             # <<<<<<<<<<<<<<
 *             if c_href is NULL or \
 *                    cstd.strcmp(c_href, 'http://www.w3.org/2001/XMLSchema') != 0:
 */
    __pyx_v_c_href = _getNs(__pyx_v_c_node);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":48
 *             c_node = root_node._c_node
 *             c_href = _getNs(c_node)
 *             if c_href is NULL or \             # <<<<<<<<<<<<<<
 *                    cstd.strcmp(c_href, 'http://www.w3.org/2001/XMLSchema') != 0:
 *                 raise XMLSchemaParseError, u"Document is not XML Schema"
 */
    __pyx_4 = (__pyx_v_c_href == NULL);
    if (!__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":49
 *             c_href = _getNs(c_node)
 *             if c_href is NULL or \
 *                    cstd.strcmp(c_href, 'http://www.w3.org/2001/XMLSchema') != 0:             # <<<<<<<<<<<<<<
 *                 raise XMLSchemaParseError, u"Document is not XML Schema"
 * 
 */
      __pyx_4 = (strcmp(__pyx_v_c_href, __pyx_k_631) != 0);
    }
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":50
 *             if c_href is NULL or \
 *                    cstd.strcmp(c_href, 'http://www.w3.org/2001/XMLSchema') != 0:
 *                 raise XMLSchemaParseError, u"Document is not XML Schema"             # <<<<<<<<<<<<<<
 * 
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 */
      __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSchemaParseError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_632), 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[21]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":52
 *                 raise XMLSchemaParseError, u"Document is not XML Schema"
 * 
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *             self._error_log.connect()
 *             parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(fake_c_doc)
 */
    __pyx_5 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_fake_c_doc = __pyx_5;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":53
 * 
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *             self._error_log.connect()             # <<<<<<<<<<<<<<
 *             parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(fake_c_doc)
 *         elif file is not None:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":54
 *             fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *             self._error_log.connect()
 *             parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(fake_c_doc)             # <<<<<<<<<<<<<<
 *         elif file is not None:
 *             if _isString(file):
 */
    __pyx_v_parser_ctxt = xmlSchemaNewDocParserCtxt(__pyx_v_fake_c_doc);
    goto __pyx_L6;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":55
 *             self._error_log.connect()
 *             parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(fake_c_doc)
 *         elif file is not None:             # <<<<<<<<<<<<<<
 *             if _isString(file):
 *                 filename = _encodeFilename(file)
 */
  __pyx_4 = (__pyx_v_file != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":56
 *             parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(fake_c_doc)
 *         elif file is not None:
 *             if _isString(file):             # <<<<<<<<<<<<<<
 *                 filename = _encodeFilename(file)
 *                 self._error_log.connect()
 */
    __pyx_4 = _isString(__pyx_v_file);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":57
 *         elif file is not None:
 *             if _isString(file):
 *                 filename = _encodeFilename(file)             # <<<<<<<<<<<<<<
 *                 self._error_log.connect()
 *                 parser_ctxt = xmlschema.xmlSchemaNewParserCtxt(_cstr(filename))
 */
      __pyx_1 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_file); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_v_filename);
      __pyx_v_filename = __pyx_1;
      __pyx_1 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":58
 *             if _isString(file):
 *                 filename = _encodeFilename(file)
 *                 self._error_log.connect()             # <<<<<<<<<<<<<<
 *                 parser_ctxt = xmlschema.xmlSchemaNewParserCtxt(_cstr(filename))
 *             else:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":59
 *                 filename = _encodeFilename(file)
 *                 self._error_log.connect()
 *                 parser_ctxt = xmlschema.xmlSchemaNewParserCtxt(_cstr(filename))             # <<<<<<<<<<<<<<
 *             else:
 *                 doc = _parseDocument(file, None, None)
 */
      __pyx_v_parser_ctxt = xmlSchemaNewParserCtxt(PyString_AS_STRING(__pyx_v_filename));
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":61
 *                 parser_ctxt = xmlschema.xmlSchemaNewParserCtxt(_cstr(filename))
 *             else:
 *                 doc = _parseDocument(file, None, None)             # <<<<<<<<<<<<<<
 *                 self._error_log.connect()
 *                 parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(doc._c_doc)
 */
      __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__parseDocument(__pyx_v_file, ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None), Py_None)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(((PyObject *)__pyx_v_doc));
      __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
      __pyx_2 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":62
 *             else:
 *                 doc = _parseDocument(file, None, None)
 *                 self._error_log.connect()             # <<<<<<<<<<<<<<
 *                 parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(doc._c_doc)
 *         else:
 */
      ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":63
 *                 doc = _parseDocument(file, None, None)
 *                 self._error_log.connect()
 *                 parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(doc._c_doc)             # <<<<<<<<<<<<<<
 *         else:
 *             raise XMLSchemaParseError, u"No tree or file given"
 */
      __pyx_v_parser_ctxt = xmlSchemaNewDocParserCtxt(__pyx_v_doc->_c_doc);
    }
    __pyx_L8:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":65
 *                 parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(doc._c_doc)
 *         else:
 *             raise XMLSchemaParseError, u"No tree or file given"             # <<<<<<<<<<<<<<
 * 
 *         if parser_ctxt is not NULL:
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSchemaParseError); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_633), 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[21]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":67
 *             raise XMLSchemaParseError, u"No tree or file given"
 * 
 *         if parser_ctxt is not NULL:             # <<<<<<<<<<<<<<
 *             # calling xmlSchemaParse on a schema with imports or
 *             # includes will cause libxml2 to create an internal
 */
  __pyx_4 = (__pyx_v_parser_ctxt != NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":72
 *             # context for parsing, so push an implied context to route
 *             # resolve requests to the document's parser
 *             __GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(doc._parser)             # <<<<<<<<<<<<<<
 *             self._c_schema = xmlschema.xmlSchemaParse(parser_ctxt)
 *             __GLOBAL_PARSER_CONTEXT.popImpliedContext()
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->pushImpliedContextFromParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, __pyx_v_doc->_parser);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":73
 *             # resolve requests to the document's parser
 *             __GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(doc._parser)
 *             self._c_schema = xmlschema.xmlSchemaParse(parser_ctxt)             # <<<<<<<<<<<<<<
 *             __GLOBAL_PARSER_CONTEXT.popImpliedContext()
 * 
 */
    ((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->_c_schema = xmlSchemaParse(__pyx_v_parser_ctxt);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":74
 *             __GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(doc._parser)
 *             self._c_schema = xmlschema.xmlSchemaParse(parser_ctxt)
 *             __GLOBAL_PARSER_CONTEXT.popImpliedContext()             # <<<<<<<<<<<<<<
 * 
 *             if _LIBXML_VERSION_INT >= 20624:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->popImpliedContext(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":76
 *             __GLOBAL_PARSER_CONTEXT.popImpliedContext()
 * 
 *             if _LIBXML_VERSION_INT >= 20624:             # <<<<<<<<<<<<<<
 *                 xmlschema.xmlSchemaFreeParserCtxt(parser_ctxt)
 * 
 */
    __pyx_4 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT >= 20624);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":77
 * 
 *             if _LIBXML_VERSION_INT >= 20624:
 *                 xmlschema.xmlSchemaFreeParserCtxt(parser_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.disconnect()
 */
      xmlSchemaFreeParserCtxt(__pyx_v_parser_ctxt);
      goto __pyx_L10;
    }
    __pyx_L10:;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":79
 *                 xmlschema.xmlSchemaFreeParserCtxt(parser_ctxt)
 * 
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         if fake_c_doc is not NULL:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":81
 *         self._error_log.disconnect()
 * 
 *         if fake_c_doc is not NULL:             # <<<<<<<<<<<<<<
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)
 * 
 */
  __pyx_4 = (__pyx_v_fake_c_doc != NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":82
 * 
 *         if fake_c_doc is not NULL:
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)             # <<<<<<<<<<<<<<
 * 
 *         if self._c_schema is NULL:
 */
    __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_fake_c_doc);
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":84
 *             _destroyFakeDoc(doc._c_doc, fake_c_doc)
 * 
 *         if self._c_schema is NULL:             # <<<<<<<<<<<<<<
 *             raise XMLSchemaParseError(
 *                 self._error_log._buildExceptionMessage(
 */
  __pyx_4 = (((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->_c_schema == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":85
 * 
 *         if self._c_schema is NULL:
 *             raise XMLSchemaParseError(             # <<<<<<<<<<<<<<
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not valid XML Schema"),
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSchemaParseError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":87
 *             raise XMLSchemaParseError(
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not valid XML Schema"),             # <<<<<<<<<<<<<<
 *                 self._error_log)
 * 
 */
    __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._buildExceptionMessage(((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log), ((PyObject *)__pyx_kp_634)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":88
 *                 self._error_log._buildExceptionMessage(
 *                     u"Document is not valid XML Schema"),
 *                 self._error_log)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_2 = 0;
    __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[21]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L12;
  }
  __pyx_L12:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.XMLSchema.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":90
 *                 self._error_log)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         xmlschema.xmlSchemaFree(self._c_schema)
 * 
 */

static void __pyx_pf_4lxml_5etree_9XMLSchema___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_9XMLSchema___dealloc__(PyObject *__pyx_v_self) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":91
 * 
 *     def __dealloc__(self):
 *         xmlschema.xmlSchemaFree(self._c_schema)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, etree):
 */
  xmlSchemaFree(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->_c_schema);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":93
 *         xmlschema.xmlSchemaFree(self._c_schema)
 * 
 *     def __call__(self, etree):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_9XMLSchema___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_9XMLSchema___call__[] = "__call__(self, etree)\n\n        Validate doc using XML Schema.\n\n        Returns true if document is valid, false if not.\n        ";
static PyObject *__pyx_pf_4lxml_5etree_9XMLSchema___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  xmlSchemaValidCtxt *__pyx_v_valid_ctxt;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlDoc *__pyx_v_c_doc;
  int __pyx_v_ret;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  xmlDoc *__pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[21]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.XMLSchema.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":106
 *         cdef int ret
 * 
 *         doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *         root_node = _rootNodeOrRaise(etree)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":107
 * 
 *         doc = _documentOrRaise(etree)
 *         root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.connect()
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root_node));
  __pyx_v_root_node = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":109
 *         root_node = _rootNodeOrRaise(etree)
 * 
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(self._c_schema)
 *         if valid_ctxt is NULL:
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":110
 * 
 *         self._error_log.connect()
 *         valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(self._c_schema)             # <<<<<<<<<<<<<<
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()
 */
  __pyx_v_valid_ctxt = xmlSchemaNewValidCtxt(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->_c_schema);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":111
 *         self._error_log.connect()
 *         valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(self._c_schema)
 *         if valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 *             return python.PyErr_NoMemory()
 */
  __pyx_2 = (__pyx_v_valid_ctxt == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":112
 *         valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(self._c_schema)
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             return python.PyErr_NoMemory()
 * 
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":113
 *         if valid_ctxt is NULL:
 *             self._error_log.disconnect()
 *             return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":115
 *             return python.PyErr_NoMemory()
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             ret = xmlschema.xmlSchemaValidateDoc(valid_ctxt, c_doc)
 */
  __pyx_3 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":116
 * 
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = xmlschema.xmlSchemaValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":117
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:
 *             ret = xmlschema.xmlSchemaValidateDoc(valid_ctxt, c_doc)             # <<<<<<<<<<<<<<
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 * 
 */
      __pyx_v_ret = xmlSchemaValidateDoc(__pyx_v_valid_ctxt, __pyx_v_c_doc);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":118
 *         with nogil:
 *             ret = xmlschema.xmlSchemaValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 * 
 *         xmlschema.xmlSchemaFreeValidCtxt(valid_ctxt)
 */
  __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":120
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 * 
 *         xmlschema.xmlSchemaFreeValidCtxt(valid_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.disconnect()
 */
  xmlSchemaFreeValidCtxt(__pyx_v_valid_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":122
 *         xmlschema.xmlSchemaFreeValidCtxt(valid_ctxt)
 * 
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *         if ret == -1:
 *             raise XMLSchemaValidateError(
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":123
 * 
 *         self._error_log.disconnect()
 *         if ret == -1:             # <<<<<<<<<<<<<<
 *             raise XMLSchemaValidateError(
 *                 u"Internal error in XML Schema validation.",
 */
  __pyx_2 = (__pyx_v_ret == -1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":124
 *         self._error_log.disconnect()
 *         if ret == -1:
 *             raise XMLSchemaValidateError(             # <<<<<<<<<<<<<<
 *                 u"Internal error in XML Schema validation.",
 *                 self._error_log)
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_205); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":126
 *             raise XMLSchemaValidateError(
 *                 u"Internal error in XML Schema validation.",
 *                 self._error_log)             # <<<<<<<<<<<<<<
 *         if ret == 0:
 *             return True
 */
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_635));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_kp_635));
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_XMLSchema *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_5 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[21]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":127
 *                 u"Internal error in XML Schema validation.",
 *                 self._error_log)
 *         if ret == 0:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_2 = (__pyx_v_ret == 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":128
 *                 self._error_log)
 *         if ret == 0:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":130
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserSchemaValidationContext _newSaxValidator(self):
 */
    __pyx_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L11:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.XMLSchema.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":132
 *             return False
 * 
 *     cdef _ParserSchemaValidationContext _newSaxValidator(self):             # <<<<<<<<<<<<<<
 *         cdef _ParserSchemaValidationContext context
 *         context = NEW_SCHEMA_CONTEXT(_ParserSchemaValidationContext)
 */

static  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_f_4lxml_5etree_9XMLSchema__newSaxValidator(struct __pyx_obj_4lxml_5etree_XMLSchema *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_v_context;
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":134
 *     cdef _ParserSchemaValidationContext _newSaxValidator(self):
 *         cdef _ParserSchemaValidationContext context
 *         context = NEW_SCHEMA_CONTEXT(_ParserSchemaValidationContext)             # <<<<<<<<<<<<<<
 *         context._schema = self
 *         context._valid_ctxt = NULL
 */
  __pyx_1 = ((PyObject *)PY_NEW(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ParserSchemaValidationContext)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":135
 *         cdef _ParserSchemaValidationContext context
 *         context = NEW_SCHEMA_CONTEXT(_ParserSchemaValidationContext)
 *         context._schema = self             # <<<<<<<<<<<<<<
 *         context._valid_ctxt = NULL
 *         context._sax_plug = NULL
 */
  Py_INCREF(((PyObject *)__pyx_v_self));
  Py_DECREF(((PyObject *)__pyx_v_context->_schema));
  __pyx_v_context->_schema = __pyx_v_self;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":136
 *         context = NEW_SCHEMA_CONTEXT(_ParserSchemaValidationContext)
 *         context._schema = self
 *         context._valid_ctxt = NULL             # <<<<<<<<<<<<<<
 *         context._sax_plug = NULL
 *         return context
 */
  __pyx_v_context->_valid_ctxt = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":137
 *         context._schema = self
 *         context._valid_ctxt = NULL
 *         context._sax_plug = NULL             # <<<<<<<<<<<<<<
 *         return context
 * 
 */
  __pyx_v_context->_sax_plug = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":138
 *         context._valid_ctxt = NULL
 *         context._sax_plug = NULL
 *         return context             # <<<<<<<<<<<<<<
 * 
 * cdef class _ParserSchemaValidationContext:
 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = __pyx_v_context;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.XMLSchema._newSaxValidator");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":145
 *     cdef xmlschema.xmlSchemaSAXPlugStruct* _sax_plug
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self.disconnect()
 *         if self._valid_ctxt:
 */

static void __pyx_pf_4lxml_5etree_30_ParserSchemaValidationContext___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_30_ParserSchemaValidationContext___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":146
 * 
 *     def __dealloc__(self):
 *         self.disconnect()             # <<<<<<<<<<<<<<
 *         if self._valid_ctxt:
 *             xmlschema.xmlSchemaFreeValidCtxt(self._valid_ctxt)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext *)((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self)->__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":147
 *     def __dealloc__(self):
 *         self.disconnect()
 *         if self._valid_ctxt:             # <<<<<<<<<<<<<<
 *             xmlschema.xmlSchemaFreeValidCtxt(self._valid_ctxt)
 * 
 */
  __pyx_1 = (((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self)->_valid_ctxt != 0);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":148
 *         self.disconnect()
 *         if self._valid_ctxt:
 *             xmlschema.xmlSchemaFreeValidCtxt(self._valid_ctxt)             # <<<<<<<<<<<<<<
 * 
 *     cdef _ParserSchemaValidationContext copy(self):
 */
    xmlSchemaFreeValidCtxt(((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_v_self)->_valid_ctxt);
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":150
 *             xmlschema.xmlSchemaFreeValidCtxt(self._valid_ctxt)
 * 
 *     cdef _ParserSchemaValidationContext copy(self):             # <<<<<<<<<<<<<<
 *         return self._schema._newSaxValidator()
 * 
 */

static  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_copy(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_v_self) {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":151
 * 
 *     cdef _ParserSchemaValidationContext copy(self):
 *         return self._schema._newSaxValidator()             # <<<<<<<<<<<<<<
 * 
 *     cdef int connect(self, xmlparser.xmlParserCtxt* c_ctxt) except -1:
 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_4lxml_5etree_XMLSchema *)__pyx_v_self->_schema->__pyx_vtab)->_newSaxValidator(__pyx_v_self->_schema)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree._ParserSchemaValidationContext.copy");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":153
 *         return self._schema._newSaxValidator()
 * 
 *     cdef int connect(self, xmlparser.xmlParserCtxt* c_ctxt) except -1:             # <<<<<<<<<<<<<<
 *         if self._valid_ctxt is NULL:
 *             self._valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(
 */

static  int __pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_connect(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_v_self, xmlParserCtxt *__pyx_v_c_ctxt) {
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":154
 * 
 *     cdef int connect(self, xmlparser.xmlParserCtxt* c_ctxt) except -1:
 *         if self._valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             self._valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(
 *                 self._schema._c_schema)
 */
  __pyx_1 = (__pyx_v_self->_valid_ctxt == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":155
 *     cdef int connect(self, xmlparser.xmlParserCtxt* c_ctxt) except -1:
 *         if self._valid_ctxt is NULL:
 *             self._valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(             # <<<<<<<<<<<<<<
 *                 self._schema._c_schema)
 *             if self._valid_ctxt is NULL:
 */
    __pyx_v_self->_valid_ctxt = xmlSchemaNewValidCtxt(__pyx_v_self->_schema->_c_schema);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":157
 *             self._valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(
 *                 self._schema._c_schema)
 *             if self._valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *                 return python.PyErr_NoMemory()
 *         self._sax_plug = xmlschema.xmlSchemaSAXPlug(
 */
    __pyx_1 = (__pyx_v_self->_valid_ctxt == NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":158
 *                 self._schema._c_schema)
 *             if self._valid_ctxt is NULL:
 *                 return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *         self._sax_plug = xmlschema.xmlSchemaSAXPlug(
 *             self._valid_ctxt, &c_ctxt.sax, &c_ctxt.userData)
 */
      __pyx_2 = PyErr_NoMemory(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_3 = __pyx_PyInt_int(__pyx_2); if (unlikely((__pyx_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_r = __pyx_3;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":159
 *             if self._valid_ctxt is NULL:
 *                 return python.PyErr_NoMemory()
 *         self._sax_plug = xmlschema.xmlSchemaSAXPlug(             # <<<<<<<<<<<<<<
 *             self._valid_ctxt, &c_ctxt.sax, &c_ctxt.userData)
 * 
 */
  __pyx_v_self->_sax_plug = xmlSchemaSAXPlug(__pyx_v_self->_valid_ctxt, (&__pyx_v_c_ctxt->sax), (&__pyx_v_c_ctxt->userData));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree._ParserSchemaValidationContext.connect");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":162
 *             self._valid_ctxt, &c_ctxt.sax, &c_ctxt.userData)
 * 
 *     cdef void disconnect(self):             # <<<<<<<<<<<<<<
 *         if self._sax_plug is not NULL:
 *             xmlschema.xmlSchemaSAXUnplug(self._sax_plug)
 */

static  void __pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_disconnect(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":163
 * 
 *     cdef void disconnect(self):
 *         if self._sax_plug is not NULL:             # <<<<<<<<<<<<<<
 *             xmlschema.xmlSchemaSAXUnplug(self._sax_plug)
 *             self._sax_plug = NULL
 */
  __pyx_1 = (__pyx_v_self->_sax_plug != NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":164
 *     cdef void disconnect(self):
 *         if self._sax_plug is not NULL:
 *             xmlschema.xmlSchemaSAXUnplug(self._sax_plug)             # <<<<<<<<<<<<<<
 *             self._sax_plug = NULL
 * 
 */
    xmlSchemaSAXUnplug(__pyx_v_self->_sax_plug);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":165
 *         if self._sax_plug is not NULL:
 *             xmlschema.xmlSchemaSAXUnplug(self._sax_plug)
 *             self._sax_plug = NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef bint isvalid(self):
 */
    __pyx_v_self->_sax_plug = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":167
 *             self._sax_plug = NULL
 * 
 *     cdef bint isvalid(self):             # <<<<<<<<<<<<<<
 *         if self._valid_ctxt is NULL:
 *             return 1 # valid
 */

static  int __pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_isvalid(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *__pyx_v_self) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":168
 * 
 *     cdef bint isvalid(self):
 *         if self._valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             return 1 # valid
 *         return xmlschema.xmlSchemaIsValid(self._valid_ctxt)
 */
  __pyx_1 = (__pyx_v_self->_valid_ctxt == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":169
 *     cdef bint isvalid(self):
 *         if self._valid_ctxt is NULL:
 *             return 1 # valid             # <<<<<<<<<<<<<<
 *         return xmlschema.xmlSchemaIsValid(self._valid_ctxt)
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":170
 *         if self._valid_ctxt is NULL:
 *             return 1 # valid
 *         return xmlschema.xmlSchemaIsValid(self._valid_ctxt)             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "etree_defs.h":
 */
  __pyx_r = xmlSchemaIsValid(__pyx_v_self->_valid_ctxt);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":73
 *     cdef schematron.xmlSchematron* _c_schema
 *     cdef xmlDoc* _c_schema_doc
 *     def __init__(self, etree=None, *, file=None):             # <<<<<<<<<<<<<<
 *         cdef _Document doc
 *         cdef _Element root_node
 */

static int __pyx_pf_4lxml_5etree_10Schematron___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4lxml_5etree_10Schematron___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  PyObject *__pyx_v_file = 0;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlSchematronParserCtxt *__pyx_v_parser_ctxt;
  PyObject *__pyx_v_filename;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  xmlDoc *__pyx_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,&__pyx_kp_file,0};
  __pyx_v_etree = Py_None;
  __pyx_v_file = Py_None;
  if (unlikely(__pyx_kwds)) {
    PyObject* values[2] = {0,0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_etree = values[0];
    }
    if (values[1]) {
      __pyx_v_file = values[1];
    }
  } else {
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[22]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Schematron.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  __pyx_v_filename = Py_None; Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":79
 *         cdef char* c_href
 *         cdef schematron.xmlSchematronParserCtxt* parser_ctxt
 *         self._c_schema = NULL             # <<<<<<<<<<<<<<
 *         self._c_schema_doc = NULL
 *         _Validator.__init__(self)
 */
  ((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":80
 *         cdef schematron.xmlSchematronParserCtxt* parser_ctxt
 *         self._c_schema = NULL
 *         self._c_schema_doc = NULL             # <<<<<<<<<<<<<<
 *         _Validator.__init__(self)
 *         if not config.ENABLE_SCHEMATRON:
 */
  ((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":81
 *         self._c_schema = NULL
 *         self._c_schema_doc = NULL
 *         _Validator.__init__(self)             # <<<<<<<<<<<<<<
 *         if not config.ENABLE_SCHEMATRON:
 *             raise SchematronError, \
 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__Validator)), __pyx_kp___init__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":82
 *         self._c_schema_doc = NULL
 *         _Validator.__init__(self)
 *         if not config.ENABLE_SCHEMATRON:             # <<<<<<<<<<<<<<
 *             raise SchematronError, \
 *                 u"lxml.etree was compiled without Schematron support."
 */
  __pyx_4 = (!ENABLE_SCHEMATRON);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":83
 *         _Validator.__init__(self)
 *         if not config.ENABLE_SCHEMATRON:
 *             raise SchematronError, \             # <<<<<<<<<<<<<<
 *                 u"lxml.etree was compiled without Schematron support."
 *         if etree is not None:
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_SchematronError); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":84
 *         if not config.ENABLE_SCHEMATRON:
 *             raise SchematronError, \
 *                 u"lxml.etree was compiled without Schematron support."             # <<<<<<<<<<<<<<
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)
 */
    __Pyx_Raise(__pyx_1, ((PyObject *)__pyx_kp_636), 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[22]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":85
 *             raise SchematronError, \
 *                 u"lxml.etree was compiled without Schematron support."
 *         if etree is not None:             # <<<<<<<<<<<<<<
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)
 */
  __pyx_4 = (__pyx_v_etree != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":86
 *                 u"lxml.etree was compiled without Schematron support."
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *             root_node = _rootNodeOrRaise(etree)
 *             self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
 */
    __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_doc));
    __pyx_v_doc = ((struct LxmlDocument *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":87
 *         if etree is not None:
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 *             self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
 *             self._error_log.connect()
 */
    __pyx_3 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(((PyObject *)__pyx_v_root_node));
    __pyx_v_root_node = ((struct LxmlElement *)__pyx_3);
    __pyx_3 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":88
 *             doc = _documentOrRaise(etree)
 *             root_node = _rootNodeOrRaise(etree)
 *             self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *             self._error_log.connect()
 *             parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(
 */
    __pyx_5 = __pyx_f_4lxml_5etree__copyDocRoot(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_5 == NULL)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc = __pyx_5;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":89
 *             root_node = _rootNodeOrRaise(etree)
 *             self._c_schema_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
 *             self._error_log.connect()             # <<<<<<<<<<<<<<
 *             parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(
 *                 self._c_schema_doc)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":91
 *             self._error_log.connect()
 *             parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(
 *                 self._c_schema_doc)             # <<<<<<<<<<<<<<
 *         elif file is not None:
 *             filename = _getFilenameForFile(file)
 */
    __pyx_v_parser_ctxt = xmlSchematronNewDocParserCtxt(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc);
    goto __pyx_L7;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":92
 *             parser_ctxt = schematron.xmlSchematronNewDocParserCtxt(
 *                 self._c_schema_doc)
 *         elif file is not None:             # <<<<<<<<<<<<<<
 *             filename = _getFilenameForFile(file)
 *             if filename is None:
 */
  __pyx_4 = (__pyx_v_file != Py_None);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":93
 *                 self._c_schema_doc)
 *         elif file is not None:
 *             filename = _getFilenameForFile(file)             # <<<<<<<<<<<<<<
 *             if filename is None:
 *                 # XXX assume a string object
 */
    __pyx_1 = __pyx_f_4lxml_5etree__getFilenameForFile(__pyx_v_file); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_filename);
    __pyx_v_filename = __pyx_1;
    __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":94
 *         elif file is not None:
 *             filename = _getFilenameForFile(file)
 *             if filename is None:             # <<<<<<<<<<<<<<
 *                 # XXX assume a string object
 *                 filename = file
 */
    __pyx_4 = (__pyx_v_filename == Py_None);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":96
 *             if filename is None:
 *                 # XXX assume a string object
 *                 filename = file             # <<<<<<<<<<<<<<
 *             filename = _encodeFilename(filename)
 *             self._error_log.connect()
 */
      Py_INCREF(__pyx_v_file);
      Py_DECREF(__pyx_v_filename);
      __pyx_v_filename = __pyx_v_file;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":97
 *                 # XXX assume a string object
 *                 filename = file
 *             filename = _encodeFilename(filename)             # <<<<<<<<<<<<<<
 *             self._error_log.connect()
 *             parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))
 */
    __pyx_2 = __pyx_f_4lxml_5etree__encodeFilename(__pyx_v_filename); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_v_filename);
    __pyx_v_filename = __pyx_2;
    __pyx_2 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":98
 *                 filename = file
 *             filename = _encodeFilename(filename)
 *             self._error_log.connect()             # <<<<<<<<<<<<<<
 *             parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))
 *         else:
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":99
 *             filename = _encodeFilename(filename)
 *             self._error_log.connect()
 *             parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))             # <<<<<<<<<<<<<<
 *         else:
 *             raise SchematronParseError, u"No tree or file given"
 */
    __pyx_v_parser_ctxt = xmlSchematronNewParserCtxt(PyString_AS_STRING(__pyx_v_filename));
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":101
 *             parser_ctxt = schematron.xmlSchematronNewParserCtxt(_cstr(filename))
 *         else:
 *             raise SchematronParseError, u"No tree or file given"             # <<<<<<<<<<<<<<
 * 
 *         if parser_ctxt is NULL:
 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_208); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_Raise(__pyx_3, ((PyObject *)__pyx_kp_637), 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[22]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":103
 *             raise SchematronParseError, u"No tree or file given"
 * 
 *         if parser_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             self._error_log.disconnect()
 *             if self._c_schema_doc is not NULL:
 */
  __pyx_4 = (__pyx_v_parser_ctxt == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":104
 * 
 *         if parser_ctxt is NULL:
 *             self._error_log.disconnect()             # <<<<<<<<<<<<<<
 *             if self._c_schema_doc is not NULL:
 *                 tree.xmlFreeDoc(self._c_schema_doc)
 */
    ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log);

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":105
 *         if parser_ctxt is NULL:
 *             self._error_log.disconnect()
 *             if self._c_schema_doc is not NULL:             # <<<<<<<<<<<<<<
 *                 tree.xmlFreeDoc(self._c_schema_doc)
 *                 self._c_schema_doc = NULL
 */
    __pyx_4 = (((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc != NULL);
    if (__pyx_4) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":106
 *             self._error_log.disconnect()
 *             if self._c_schema_doc is not NULL:
 *                 tree.xmlFreeDoc(self._c_schema_doc)             # <<<<<<<<<<<<<<
 *                 self._c_schema_doc = NULL
 *             python.PyErr_NoMemory()
 */
      xmlFreeDoc(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc);

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":107
 *             if self._c_schema_doc is not NULL:
 *                 tree.xmlFreeDoc(self._c_schema_doc)
 *                 self._c_schema_doc = NULL             # <<<<<<<<<<<<<<
 *             python.PyErr_NoMemory()
 *             return
 */
      ((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc = NULL;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":108
 *                 tree.xmlFreeDoc(self._c_schema_doc)
 *                 self._c_schema_doc = NULL
 *             python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":109
 *                 self._c_schema_doc = NULL
 *             python.PyErr_NoMemory()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self._c_schema = schematron.xmlSchematronParse(parser_ctxt)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":111
 *             return
 * 
 *         self._c_schema = schematron.xmlSchematronParse(parser_ctxt)             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 * 
 */
  ((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema = xmlSchematronParse(__pyx_v_parser_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":112
 * 
 *         self._c_schema = schematron.xmlSchematronParse(parser_ctxt)
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         schematron.xmlSchematronFreeParserCtxt(parser_ctxt)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":114
 *         self._error_log.disconnect()
 * 
 *         schematron.xmlSchematronFreeParserCtxt(parser_ctxt)             # <<<<<<<<<<<<<<
 *         if self._c_schema is NULL:
 *             raise SchematronParseError(
 */
  xmlSchematronFreeParserCtxt(__pyx_v_parser_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":115
 * 
 *         schematron.xmlSchematronFreeParserCtxt(parser_ctxt)
 *         if self._c_schema is NULL:             # <<<<<<<<<<<<<<
 *             raise SchematronParseError(
 *                 u"Document is not a valid Schematron schema",
 */
  __pyx_4 = (((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema == NULL);
  if (__pyx_4) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":116
 *         schematron.xmlSchematronFreeParserCtxt(parser_ctxt)
 *         if self._c_schema is NULL:
 *             raise SchematronParseError(             # <<<<<<<<<<<<<<
 *                 u"Document is not a valid Schematron schema",
 *                 self._error_log)
 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_kp_208); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":118
 *             raise SchematronParseError(
 *                 u"Document is not a valid Schematron schema",
 *                 self._error_log)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
    __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_638));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_638));
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_1 = PyObject_Call(__pyx_2, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[22]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("lxml.etree.Schematron.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":120
 *                 self._error_log)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         schematron.xmlSchematronFree(self._c_schema)
 *         if _LIBXML_VERSION_INT >= 20631:
 */

static void __pyx_pf_4lxml_5etree_10Schematron___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4lxml_5etree_10Schematron___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":121
 * 
 *     def __dealloc__(self):
 *         schematron.xmlSchematronFree(self._c_schema)             # <<<<<<<<<<<<<<
 *         if _LIBXML_VERSION_INT >= 20631:
 *             # earlier libxml2 versions may have freed the document in
 */
  xmlSchematronFree(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":122
 *     def __dealloc__(self):
 *         schematron.xmlSchematronFree(self._c_schema)
 *         if _LIBXML_VERSION_INT >= 20631:             # <<<<<<<<<<<<<<
 *             # earlier libxml2 versions may have freed the document in
 *             # xmlSchematronFree() already, we don't know ...
 */
  __pyx_1 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT >= 20631);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":125
 *             # earlier libxml2 versions may have freed the document in
 *             # xmlSchematronFree() already, we don't know ...
 *             if self._c_schema_doc is not NULL:             # <<<<<<<<<<<<<<
 *                 tree.xmlFreeDoc(self._c_schema_doc)
 * 
 */
    __pyx_1 = (((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc != NULL);
    if (__pyx_1) {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":126
 *             # xmlSchematronFree() already, we don't know ...
 *             if self._c_schema_doc is not NULL:
 *                 tree.xmlFreeDoc(self._c_schema_doc)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, etree):
 */
      xmlFreeDoc(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema_doc);
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":128
 *                 tree.xmlFreeDoc(self._c_schema_doc)
 * 
 *     def __call__(self, etree):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, etree)
 * 
 */

static PyObject *__pyx_pf_4lxml_5etree_10Schematron___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4lxml_5etree_10Schematron___call__[] = "__call__(self, etree)\n\n        Validate doc using Schematron.\n\n        Returns true if document is valid, false if not.";
static PyObject *__pyx_pf_4lxml_5etree_10Schematron___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_etree = 0;
  struct LxmlDocument *__pyx_v_doc;
  struct LxmlElement *__pyx_v_root_node;
  xmlDoc *__pyx_v_c_doc;
  xmlSchematronValidCtxt *__pyx_v_valid_ctxt;
  int __pyx_v_ret;
  int __pyx_v_options;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  xmlDoc *__pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_etree,0};
  if (unlikely(__pyx_kwds)) {
    PyObject* values[1] = {0};
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_etree);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_etree = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_etree = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[22]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("lxml.etree.Schematron.__call__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  __pyx_v_root_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":141
 *         cdef int options
 * 
 *         doc = _documentOrRaise(etree)             # <<<<<<<<<<<<<<
 *         root_node = _rootNodeOrRaise(etree)
 * 
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_doc));
  __pyx_v_doc = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":142
 * 
 *         doc = _documentOrRaise(etree)
 *         root_node = _rootNodeOrRaise(etree)             # <<<<<<<<<<<<<<
 * 
 *         if _LIBXML_VERSION_INT >= 20632 and \
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_etree)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_root_node));
  __pyx_v_root_node = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":144
 *         root_node = _rootNodeOrRaise(etree)
 * 
 *         if _LIBXML_VERSION_INT >= 20632 and \             # <<<<<<<<<<<<<<
 *                 schematron.XML_SCHEMATRON_OUT_ERROR != 0:
 *             options = schematron.XML_SCHEMATRON_OUT_ERROR
 */
  __pyx_2 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT >= 20632);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":145
 * 
 *         if _LIBXML_VERSION_INT >= 20632 and \
 *                 schematron.XML_SCHEMATRON_OUT_ERROR != 0:             # <<<<<<<<<<<<<<
 *             options = schematron.XML_SCHEMATRON_OUT_ERROR
 *         else:
 */
    __pyx_2 = (XML_SCHEMATRON_OUT_ERROR != 0);
  }
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":146
 *         if _LIBXML_VERSION_INT >= 20632 and \
 *                 schematron.XML_SCHEMATRON_OUT_ERROR != 0:
 *             options = schematron.XML_SCHEMATRON_OUT_ERROR             # <<<<<<<<<<<<<<
 *         else:
 *             options = schematron.XML_SCHEMATRON_OUT_QUIET
 */
    __pyx_v_options = XML_SCHEMATRON_OUT_ERROR;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":148
 *             options = schematron.XML_SCHEMATRON_OUT_ERROR
 *         else:
 *             options = schematron.XML_SCHEMATRON_OUT_QUIET             # <<<<<<<<<<<<<<
 *             # hack to switch off stderr output
 *             options = options | schematron.XML_SCHEMATRON_OUT_XML
 */
    __pyx_v_options = XML_SCHEMATRON_OUT_QUIET;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":150
 *             options = schematron.XML_SCHEMATRON_OUT_QUIET
 *             # hack to switch off stderr output
 *             options = options | schematron.XML_SCHEMATRON_OUT_XML             # <<<<<<<<<<<<<<
 * 
 *         valid_ctxt = schematron.xmlSchematronNewValidCtxt(
 */
    __pyx_v_options = (__pyx_v_options | XML_SCHEMATRON_OUT_XML);
  }
  __pyx_L6:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":153
 * 
 *         valid_ctxt = schematron.xmlSchematronNewValidCtxt(
 *             self._c_schema, options)             # <<<<<<<<<<<<<<
 *         if valid_ctxt is NULL:
 *             return python.PyErr_NoMemory()
 */
  __pyx_v_valid_ctxt = xmlSchematronNewValidCtxt(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->_c_schema, __pyx_v_options);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":154
 *         valid_ctxt = schematron.xmlSchematronNewValidCtxt(
 *             self._c_schema, options)
 *         if valid_ctxt is NULL:             # <<<<<<<<<<<<<<
 *             return python.PyErr_NoMemory()
 * 
 */
  __pyx_2 = (__pyx_v_valid_ctxt == NULL);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":155
 *             self._c_schema, options)
 *         if valid_ctxt is NULL:
 *             return python.PyErr_NoMemory()             # <<<<<<<<<<<<<<
 * 
 *         self._error_log.connect()
 */
    __pyx_1 = PyErr_NoMemory(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":157
 *             return python.PyErr_NoMemory()
 * 
 *         self._error_log.connect()             # <<<<<<<<<<<<<<
 *         if _LIBXML_VERSION_INT >= 20632:
 *             schematron.xmlSchematronSetValidStructuredErrors(
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->connect(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":158
 * 
 *         self._error_log.connect()
 *         if _LIBXML_VERSION_INT >= 20632:             # <<<<<<<<<<<<<<
 *             schematron.xmlSchematronSetValidStructuredErrors(
 *                 valid_ctxt, _receiveError, <void*>self._error_log)
 */
  __pyx_2 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT >= 20632);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":160
 *         if _LIBXML_VERSION_INT >= 20632:
 *             schematron.xmlSchematronSetValidStructuredErrors(
 *                 valid_ctxt, _receiveError, <void*>self._error_log)             # <<<<<<<<<<<<<<
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:
 */
    xmlSchematronSetValidStructuredErrors(__pyx_v_valid_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log));
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":161
 *             schematron.xmlSchematronSetValidStructuredErrors(
 *                 valid_ctxt, _receiveError, <void*>self._error_log)
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
 */
  __pyx_3 = __pyx_f_4lxml_5etree__fakeRootDoc(__pyx_v_doc->_c_doc, __pyx_v_root_node->_c_node); if (unlikely(__pyx_3 == NULL)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_doc = __pyx_3;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":162
 *                 valid_ctxt, _receiveError, <void*>self._error_log)
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 */
  /*with nogil:*/ {
    PyThreadState *_save;
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":163
 *         c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
 *         with nogil:
 *             ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)             # <<<<<<<<<<<<<<
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 *         self._error_log.disconnect()
 */
      __pyx_v_ret = xmlSchematronValidateDoc(__pyx_v_valid_ctxt, __pyx_v_c_doc);
    }
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":164
 *         with nogil:
 *             ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)             # <<<<<<<<<<<<<<
 *         self._error_log.disconnect()
 * 
 */
  __pyx_f_4lxml_5etree__destroyFakeDoc(__pyx_v_doc->_c_doc, __pyx_v_c_doc);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":165
 *             ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
 *         _destroyFakeDoc(doc._c_doc, c_doc)
 *         self._error_log.disconnect()             # <<<<<<<<<<<<<<
 * 
 *         schematron.xmlSchematronFreeValidCtxt(valid_ctxt)
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ErrorLog *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log->__pyx_base.__pyx_base.__pyx_vtab)->disconnect(((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":167
 *         self._error_log.disconnect()
 * 
 *         schematron.xmlSchematronFreeValidCtxt(valid_ctxt)             # <<<<<<<<<<<<<<
 * 
 *         if ret == -1:
 */
  xmlSchematronFreeValidCtxt(__pyx_v_valid_ctxt);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":169
 *         schematron.xmlSchematronFreeValidCtxt(valid_ctxt)
 * 
 *         if ret == -1:             # <<<<<<<<<<<<<<
 *             raise SchematronValidateError(
 *                 u"Internal error in Schematron validation",
 */
  __pyx_2 = (__pyx_v_ret == -1);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":170
 * 
 *         if ret == -1:
 *             raise SchematronValidateError(             # <<<<<<<<<<<<<<
 *                 u"Internal error in Schematron validation",
 *                 self._error_log)
 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_210); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":172
 *             raise SchematronValidateError(
 *                 u"Internal error in Schematron validation",
 *                 self._error_log)             # <<<<<<<<<<<<<<
 *         if ret == 0:
 *             return True
 */
    __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_639));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_kp_639));
    Py_INCREF(((PyObject *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)((struct __pyx_obj_4lxml_5etree_Schematron *)__pyx_v_self)->__pyx_base._error_log));
    __pyx_5 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[22]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":173
 *                 u"Internal error in Schematron validation",
 *                 self._error_log)
 *         if ret == 0:             # <<<<<<<<<<<<<<
 *             return True
 *         else:
 */
  __pyx_2 = (__pyx_v_ret == 0);
  if (__pyx_2) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":174
 *                 self._error_log)
 *         if ret == 0:
 *             return True             # <<<<<<<<<<<<<<
 *         else:
 *             return False
 */
    __pyx_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L13;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":176
 *             return True
 *         else:
 *             return False             # <<<<<<<<<<<<<<
 */
    __pyx_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L13:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("lxml.etree.Schematron.__call__");
  __pyx_r = NULL;
  __pyx_L0:;
  Py_DECREF(__pyx_v_doc);
  Py_DECREF(__pyx_v_root_node);
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":3
 * # Public C API for lxml.etree
 * 
 * cdef public api _Element deepcopyNodeToDocument(_Document doc, xmlNode* c_root):             # <<<<<<<<<<<<<<
 *     u"Recursively copy the element into the document. doc is not modified."
 *     cdef xmlNode* c_node
 */

 DL_EXPORT(struct LxmlElement) *deepcopyNodeToDocument(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_root) {
  xmlNode *__pyx_v_c_node;
  struct LxmlElement *__pyx_r;
  xmlNode *__pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":6
 *     u"Recursively copy the element into the document. doc is not modified."
 *     cdef xmlNode* c_node
 *     c_node = _copyNodeToDoc(c_root, doc._c_doc)             # <<<<<<<<<<<<<<
 *     return _elementFactory(doc, c_node)
 * 
 */
  __pyx_1 = __pyx_f_4lxml_5etree__copyNodeToDoc(__pyx_v_c_root, __pyx_v_doc->_c_doc); if (unlikely(__pyx_1 == NULL)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_node = __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":7
 *     cdef xmlNode* c_node
 *     c_node = _copyNodeToDoc(c_root, doc._c_doc)
 *     return _elementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _ElementTree elementTreeFactory(_Element context_node):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.deepcopyNodeToDocument");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":9
 *     return _elementFactory(doc, c_node)
 * 
 * cdef public api _ElementTree elementTreeFactory(_Element context_node):             # <<<<<<<<<<<<<<
 *     return newElementTree(context_node, _ElementTree)
 * 
 */

 DL_EXPORT(struct LxmlElementTree) *elementTreeFactory(struct LxmlElement *__pyx_v_context_node) {
  struct LxmlElementTree *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":10
 * 
 * cdef public api _ElementTree elementTreeFactory(_Element context_node):
 *     return newElementTree(context_node, _ElementTree)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _ElementTree newElementTree(_Element context_node,
 */
  __pyx_1 = ((PyObject *)newElementTree(__pyx_v_context_node, ((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ElementTree)))); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElementTree *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElementTree *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.elementTreeFactory");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":12
 *     return newElementTree(context_node, _ElementTree)
 * 
 * cdef public api _ElementTree newElementTree(_Element context_node,             # <<<<<<<<<<<<<<
 *                                         object subclass):
 *     if <void*>context_node is NULL or context_node is None:
 */

 DL_EXPORT(struct LxmlElementTree) *newElementTree(struct LxmlElement *__pyx_v_context_node, PyObject *__pyx_v_subclass) {
  struct LxmlElementTree *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":14
 * cdef public api _ElementTree newElementTree(_Element context_node,
 *                                         object subclass):
 *     if <void*>context_node is NULL or context_node is None:             # <<<<<<<<<<<<<<
 *         raise TypeError
 * 
 */
  __pyx_1 = (((void *)__pyx_v_context_node) == NULL);
  if (!__pyx_1) {
    __pyx_1 = (((PyObject *)__pyx_v_context_node) == Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":15
 *                                         object subclass):
 *     if <void*>context_node is NULL or context_node is None:
 *         raise TypeError             # <<<<<<<<<<<<<<
 * 
 *     return _newElementTree(context_node._doc, context_node, subclass)
 */
    __Pyx_Raise(__pyx_builtin_TypeError, 0, 0);
    {__pyx_filename = __pyx_f[23]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":17
 *         raise TypeError
 * 
 *     return _newElementTree(context_node._doc, context_node, subclass)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _Element elementFactory(_Document doc, xmlNode* c_node):
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__newElementTree(__pyx_v_context_node->_doc, __pyx_v_context_node, __pyx_v_subclass)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElementTree *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElementTree *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.newElementTree");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":19
 *     return _newElementTree(context_node._doc, context_node, subclass)
 * 
 * cdef public api _Element elementFactory(_Document doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     if c_node is NULL or doc is None:
 *         raise TypeError
 */

 DL_EXPORT(struct LxmlElement) *elementFactory(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  struct LxmlElement *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":20
 * 
 * cdef public api _Element elementFactory(_Document doc, xmlNode* c_node):
 *     if c_node is NULL or doc is None:             # <<<<<<<<<<<<<<
 *         raise TypeError
 *     return _elementFactory(doc, c_node)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (!__pyx_1) {
    __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
  }
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":21
 * cdef public api _Element elementFactory(_Document doc, xmlNode* c_node):
 *     if c_node is NULL or doc is None:
 *         raise TypeError             # <<<<<<<<<<<<<<
 *     return _elementFactory(doc, c_node)
 * 
 */
    __Pyx_Raise(__pyx_builtin_TypeError, 0, 0);
    {__pyx_filename = __pyx_f[23]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":22
 *     if c_node is NULL or doc is None:
 *         raise TypeError
 *     return _elementFactory(doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _Element makeElement(tag, _Document doc, parser,
 */
  __pyx_2 = ((PyObject *)__pyx_f_4lxml_5etree__elementFactory(__pyx_v_doc, __pyx_v_c_node)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_2);
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.elementFactory");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":24
 *     return _elementFactory(doc, c_node)
 * 
 * cdef public api _Element makeElement(tag, _Document doc, parser,             # <<<<<<<<<<<<<<
 *                                  text, tail, attrib, nsmap):
 *     return _makeElement(tag, NULL, doc, parser, text, tail, attrib, nsmap, None)
 */

 DL_EXPORT(struct LxmlElement) *makeElement(PyObject *__pyx_v_tag, struct LxmlDocument *__pyx_v_doc, PyObject *__pyx_v_parser, PyObject *__pyx_v_text, PyObject *__pyx_v_tail, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap) {
  struct LxmlElement *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":26
 * cdef public api _Element makeElement(tag, _Document doc, parser,
 *                                  text, tail, attrib, nsmap):
 *     return _makeElement(tag, NULL, doc, parser, text, tail, attrib, nsmap, None)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _Element makeSubElement(_Element parent, tag, text, tail,
 */
  if (!(__Pyx_TypeTest(__pyx_v_parser, __pyx_ptype_4lxml_5etree__BaseParser))) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__makeElement(__pyx_v_tag, NULL, __pyx_v_doc, ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_parser), __pyx_v_text, __pyx_v_tail, __pyx_v_attrib, __pyx_v_nsmap, Py_None)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.makeElement");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":28
 *     return _makeElement(tag, NULL, doc, parser, text, tail, attrib, nsmap, None)
 * 
 * cdef public api _Element makeSubElement(_Element parent, tag, text, tail,             # <<<<<<<<<<<<<<
 *                                     attrib, nsmap):
 *     return _makeSubElement(parent, tag, text, tail, attrib, nsmap, None)
 */

 DL_EXPORT(struct LxmlElement) *makeSubElement(struct LxmlElement *__pyx_v_parent, PyObject *__pyx_v_tag, PyObject *__pyx_v_text, PyObject *__pyx_v_tail, PyObject *__pyx_v_attrib, PyObject *__pyx_v_nsmap) {
  struct LxmlElement *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":30
 * cdef public api _Element makeSubElement(_Element parent, tag, text, tail,
 *                                     attrib, nsmap):
 *     return _makeSubElement(parent, tag, text, tail, attrib, nsmap, None)             # <<<<<<<<<<<<<<
 * 
 * cdef public api void setElementClassLookupFunction(
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__makeSubElement(__pyx_v_parent, __pyx_v_tag, __pyx_v_text, __pyx_v_tail, __pyx_v_attrib, __pyx_v_nsmap, Py_None)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.makeSubElement");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":32
 *     return _makeSubElement(parent, tag, text, tail, attrib, nsmap, None)
 * 
 * cdef public api void setElementClassLookupFunction(             # <<<<<<<<<<<<<<
 *     _element_class_lookup_function function, state):
 *     _setElementClassLookupFunction(function, state)
 */

 DL_EXPORT(void) setElementClassLookupFunction(_element_class_lookup_function __pyx_v_function, PyObject *__pyx_v_state) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":34
 * cdef public api void setElementClassLookupFunction(
 *     _element_class_lookup_function function, state):
 *     _setElementClassLookupFunction(function, state)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object lookupDefaultElementClass(state, doc, xmlNode* c_node):
 */
  __pyx_f_4lxml_5etree__setElementClassLookupFunction(__pyx_v_function, __pyx_v_state);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":36
 *     _setElementClassLookupFunction(function, state)
 * 
 * cdef public api object lookupDefaultElementClass(state, doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _lookupDefaultElementClass(state, doc, c_node)
 * 
 */

 DL_EXPORT(PyObject) *lookupDefaultElementClass(PyObject *__pyx_v_state, PyObject *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":37
 * 
 * cdef public api object lookupDefaultElementClass(state, doc, xmlNode* c_node):
 *     return _lookupDefaultElementClass(state, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object lookupNamespaceElementClass(state, doc, xmlNode* c_node):
 */
  if (!(__Pyx_TypeTest(__pyx_v_doc, __pyx_ptype_4lxml_5etree__Document))) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __pyx_f_4lxml_5etree__lookupDefaultElementClass(__pyx_v_state, ((struct LxmlDocument *)__pyx_v_doc), __pyx_v_c_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.lookupDefaultElementClass");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":39
 *     return _lookupDefaultElementClass(state, doc, c_node)
 * 
 * cdef public api object lookupNamespaceElementClass(state, doc, xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _find_nselement_class(state, doc, c_node)
 * 
 */

 DL_EXPORT(PyObject) *lookupNamespaceElementClass(PyObject *__pyx_v_state, PyObject *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":40
 * 
 * cdef public api object lookupNamespaceElementClass(state, doc, xmlNode* c_node):
 *     return _find_nselement_class(state, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object callLookupFallback(FallbackElementClassLookup lookup,
 */
  if (!(__Pyx_TypeTest(__pyx_v_doc, __pyx_ptype_4lxml_5etree__Document))) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __pyx_f_4lxml_5etree__find_nselement_class(__pyx_v_state, ((struct LxmlDocument *)__pyx_v_doc), __pyx_v_c_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.lookupNamespaceElementClass");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":42
 *     return _find_nselement_class(state, doc, c_node)
 * 
 * cdef public api object callLookupFallback(FallbackElementClassLookup lookup,             # <<<<<<<<<<<<<<
 *                                       _Document doc, xmlNode* c_node):
 *     return _callLookupFallback(lookup, doc, c_node)
 */

 DL_EXPORT(PyObject) *callLookupFallback(struct LxmlFallbackElementClassLookup *__pyx_v_lookup, struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":44
 * cdef public api object callLookupFallback(FallbackElementClassLookup lookup,
 *                                       _Document doc, xmlNode* c_node):
 *     return _callLookupFallback(lookup, doc, c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api int tagMatches(xmlNode* c_node, char* c_href, char* c_name):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__callLookupFallback(__pyx_v_lookup, __pyx_v_doc, __pyx_v_c_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.callLookupFallback");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":46
 *     return _callLookupFallback(lookup, doc, c_node)
 * 
 * cdef public api int tagMatches(xmlNode* c_node, char* c_href, char* c_name):             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         return -1
 */

 DL_EXPORT(int) tagMatches(xmlNode *__pyx_v_c_node, char *__pyx_v_c_href, char *__pyx_v_c_name) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":47
 * 
 * cdef public api int tagMatches(xmlNode* c_node, char* c_href, char* c_name):
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return -1
 *     return _tagMatches(c_node, c_href, c_name)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":48
 * cdef public api int tagMatches(xmlNode* c_node, char* c_href, char* c_name):
 *     if c_node is NULL:
 *         return -1             # <<<<<<<<<<<<<<
 *     return _tagMatches(c_node, c_href, c_name)
 * 
 */
    __pyx_r = -1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":49
 *     if c_node is NULL:
 *         return -1
 *     return _tagMatches(c_node, c_href, c_name)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _Document documentOrRaise(object input):
 */
  __pyx_r = __pyx_f_4lxml_5etree__tagMatches(__pyx_v_c_node, __pyx_v_c_href, __pyx_v_c_name);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":51
 *     return _tagMatches(c_node, c_href, c_name)
 * 
 * cdef public api _Document documentOrRaise(object input):             # <<<<<<<<<<<<<<
 *     return _documentOrRaise(input)
 * 
 */

 DL_EXPORT(struct LxmlDocument) *documentOrRaise(PyObject *__pyx_v_input) {
  struct LxmlDocument *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":52
 * 
 * cdef public api _Document documentOrRaise(object input):
 *     return _documentOrRaise(input)             # <<<<<<<<<<<<<<
 * 
 * cdef public api _Element rootNodeOrRaise(object input):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__documentOrRaise(__pyx_v_input)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlDocument *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.documentOrRaise");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":54
 *     return _documentOrRaise(input)
 * 
 * cdef public api _Element rootNodeOrRaise(object input):             # <<<<<<<<<<<<<<
 *     return _rootNodeOrRaise(input)
 * 
 */

 DL_EXPORT(struct LxmlElement) *rootNodeOrRaise(PyObject *__pyx_v_input) {
  struct LxmlElement *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":55
 * 
 * cdef public api _Element rootNodeOrRaise(object input):
 *     return _rootNodeOrRaise(input)             # <<<<<<<<<<<<<<
 * 
 * cdef public api bint hasText(xmlNode* c_node):
 */
  __pyx_1 = ((PyObject *)__pyx_f_4lxml_5etree__rootNodeOrRaise(__pyx_v_input)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct LxmlElement *)__pyx_1);
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.rootNodeOrRaise");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":57
 *     return _rootNodeOrRaise(input)
 * 
 * cdef public api bint hasText(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _hasText(c_node)
 * 
 */

 DL_EXPORT(int) hasText(xmlNode *__pyx_v_c_node) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":58
 * 
 * cdef public api bint hasText(xmlNode* c_node):
 *     return _hasText(c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api bint hasTail(xmlNode* c_node):
 */
  __pyx_r = __pyx_f_4lxml_5etree__hasText(__pyx_v_c_node);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":60
 *     return _hasText(c_node)
 * 
 * cdef public api bint hasTail(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _hasTail(c_node)
 * 
 */

 DL_EXPORT(int) hasTail(xmlNode *__pyx_v_c_node) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":61
 * 
 * cdef public api bint hasTail(xmlNode* c_node):
 *     return _hasTail(c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object textOf(xmlNode* c_node):
 */
  __pyx_r = __pyx_f_4lxml_5etree__hasTail(__pyx_v_c_node);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":63
 *     return _hasTail(c_node)
 * 
 * cdef public api object textOf(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         return None
 */

 DL_EXPORT(PyObject) *textOf(xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":64
 * 
 * cdef public api object textOf(xmlNode* c_node):
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return _collectText(c_node.children)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":65
 * cdef public api object textOf(xmlNode* c_node):
 *     if c_node is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     return _collectText(c_node.children)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":66
 *     if c_node is NULL:
 *         return None
 *     return _collectText(c_node.children)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object tailOf(xmlNode* c_node):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectText(__pyx_v_c_node->children); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.textOf");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":68
 *     return _collectText(c_node.children)
 * 
 * cdef public api object tailOf(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         return None
 */

 DL_EXPORT(PyObject) *tailOf(xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":69
 * 
 * cdef public api object tailOf(xmlNode* c_node):
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return _collectText(c_node.next)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":70
 * cdef public api object tailOf(xmlNode* c_node):
 *     if c_node is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     return _collectText(c_node.next)
 * 
 */
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":71
 *     if c_node is NULL:
 *         return None
 *     return _collectText(c_node.next)             # <<<<<<<<<<<<<<
 * 
 * cdef public api int setNodeText(xmlNode* c_node, text) except -1:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__collectText(__pyx_v_c_node->next); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.tailOf");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":73
 *     return _collectText(c_node.next)
 * 
 * cdef public api int setNodeText(xmlNode* c_node, text) except -1:             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         raise ValueError
 */

 DL_EXPORT(int) setNodeText(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_text) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":74
 * 
 * cdef public api int setNodeText(xmlNode* c_node, text) except -1:
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError
 *     return _setNodeText(c_node, text)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":75
 * cdef public api int setNodeText(xmlNode* c_node, text) except -1:
 *     if c_node is NULL:
 *         raise ValueError             # <<<<<<<<<<<<<<
 *     return _setNodeText(c_node, text)
 * 
 */
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0);
    {__pyx_filename = __pyx_f[23]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":76
 *     if c_node is NULL:
 *         raise ValueError
 *     return _setNodeText(c_node, text)             # <<<<<<<<<<<<<<
 * 
 * cdef public api int setTailText(xmlNode* c_node, text) except -1:
 */
  __pyx_2 = __pyx_f_4lxml_5etree__setNodeText(__pyx_v_c_node, __pyx_v_text); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.setNodeText");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":78
 *     return _setNodeText(c_node, text)
 * 
 * cdef public api int setTailText(xmlNode* c_node, text) except -1:             # <<<<<<<<<<<<<<
 *     if c_node is NULL:
 *         raise ValueError
 */

 DL_EXPORT(int) setTailText(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_text) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":79
 * 
 * cdef public api int setTailText(xmlNode* c_node, text) except -1:
 *     if c_node is NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError
 *     return _setTailText(c_node, text)
 */
  __pyx_1 = (__pyx_v_c_node == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":80
 * cdef public api int setTailText(xmlNode* c_node, text) except -1:
 *     if c_node is NULL:
 *         raise ValueError             # <<<<<<<<<<<<<<
 *     return _setTailText(c_node, text)
 * 
 */
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0);
    {__pyx_filename = __pyx_f[23]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":81
 *     if c_node is NULL:
 *         raise ValueError
 *     return _setTailText(c_node, text)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):
 */
  __pyx_2 = __pyx_f_4lxml_5etree__setTailText(__pyx_v_c_node, __pyx_v_text); if (unlikely(__pyx_2 == -1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.setTailText");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":83
 *     return _setTailText(c_node, text)
 * 
 * cdef public api object attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):             # <<<<<<<<<<<<<<
 *     return _attributeValue(c_element, c_attrib_node)
 * 
 */

 DL_EXPORT(PyObject) *attributeValue(xmlNode *__pyx_v_c_element, xmlAttr *__pyx_v_c_attrib_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":84
 * 
 * cdef public api object attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):
 *     return _attributeValue(c_element, c_attrib_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object attributeValueFromNsName(xmlNode* c_element,
 */
  __pyx_1 = __pyx_f_4lxml_5etree__attributeValue(__pyx_v_c_element, __pyx_v_c_attrib_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.attributeValue");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":86
 *     return _attributeValue(c_element, c_attrib_node)
 * 
 * cdef public api object attributeValueFromNsName(xmlNode* c_element,             # <<<<<<<<<<<<<<
 *                                             char* ns, char* name):
 *     return _attributeValueFromNsName(c_element, ns, name)
 */

 DL_EXPORT(PyObject) *attributeValueFromNsName(xmlNode *__pyx_v_c_element, char *__pyx_v_ns, char *__pyx_v_name) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":88
 * cdef public api object attributeValueFromNsName(xmlNode* c_element,
 *                                             char* ns, char* name):
 *     return _attributeValueFromNsName(c_element, ns, name)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object getAttributeValue(_Element element, key, default):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__attributeValueFromNsName(__pyx_v_c_element, __pyx_v_ns, __pyx_v_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.attributeValueFromNsName");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":90
 *     return _attributeValueFromNsName(c_element, ns, name)
 * 
 * cdef public api object getAttributeValue(_Element element, key, default):             # <<<<<<<<<<<<<<
 *     return _getAttributeValue(element, key, default)
 * 
 */

 DL_EXPORT(PyObject) *getAttributeValue(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_key, PyObject *__pyx_v_default) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":91
 * 
 * cdef public api object getAttributeValue(_Element element, key, default):
 *     return _getAttributeValue(element, key, default)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object iterattributes(_Element element, int keysvalues):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getAttributeValue(__pyx_v_element, __pyx_v_key, __pyx_v_default); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.getAttributeValue");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":93
 *     return _getAttributeValue(element, key, default)
 * 
 * cdef public api object iterattributes(_Element element, int keysvalues):             # <<<<<<<<<<<<<<
 *     return _attributeIteratorFactory(element, keysvalues)
 * 
 */

 DL_EXPORT(PyObject) *iterattributes(struct LxmlElement *__pyx_v_element, int __pyx_v_keysvalues) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":94
 * 
 * cdef public api object iterattributes(_Element element, int keysvalues):
 *     return _attributeIteratorFactory(element, keysvalues)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object collectAttributes(xmlNode* c_element, int keysvalues):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__attributeIteratorFactory(__pyx_v_element, __pyx_v_keysvalues); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.iterattributes");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":96
 *     return _attributeIteratorFactory(element, keysvalues)
 * 
 * cdef public api object collectAttributes(xmlNode* c_element, int keysvalues):             # <<<<<<<<<<<<<<
 *     return _collectAttributes(c_element, keysvalues)
 * 
 */

 DL_EXPORT(PyObject) *collectAttributes(xmlNode *__pyx_v_c_element, int __pyx_v_keysvalues) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":97
 * 
 * cdef public api object collectAttributes(xmlNode* c_element, int keysvalues):
 *     return _collectAttributes(c_element, keysvalues)             # <<<<<<<<<<<<<<
 * 
 * cdef public api int setAttributeValue(_Element element, key, value) except -1:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__collectAttributes(__pyx_v_c_element, __pyx_v_keysvalues); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.collectAttributes");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":99
 *     return _collectAttributes(c_element, keysvalues)
 * 
 * cdef public api int setAttributeValue(_Element element, key, value) except -1:             # <<<<<<<<<<<<<<
 *     return _setAttributeValue(element, key, value)
 * 
 */

 DL_EXPORT(int) setAttributeValue(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":100
 * 
 * cdef public api int setAttributeValue(_Element element, key, value) except -1:
 *     return _setAttributeValue(element, key, value)             # <<<<<<<<<<<<<<
 * 
 * cdef public api int delAttribute(_Element element, key) except -1:
 */
  __pyx_1 = __pyx_f_4lxml_5etree__setAttributeValue(__pyx_v_element, __pyx_v_key, __pyx_v_value); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.setAttributeValue");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":102
 *     return _setAttributeValue(element, key, value)
 * 
 * cdef public api int delAttribute(_Element element, key) except -1:             # <<<<<<<<<<<<<<
 *     return _delAttribute(element, key)
 * 
 */

 DL_EXPORT(int) delAttribute(struct LxmlElement *__pyx_v_element, PyObject *__pyx_v_key) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":103
 * 
 * cdef public api int delAttribute(_Element element, key) except -1:
 *     return _delAttribute(element, key)             # <<<<<<<<<<<<<<
 * 
 * cdef public api int delAttributeFromNsName(tree.xmlNode* c_element,
 */
  __pyx_1 = __pyx_f_4lxml_5etree__delAttribute(__pyx_v_element, __pyx_v_key); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.delAttribute");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":105
 *     return _delAttribute(element, key)
 * 
 * cdef public api int delAttributeFromNsName(tree.xmlNode* c_element,             # <<<<<<<<<<<<<<
 *                                        char* c_href, char* c_name):
 *     return _delAttributeFromNsName(c_element, c_href, c_name)
 */

 DL_EXPORT(int) delAttributeFromNsName(xmlNode *__pyx_v_c_element, char *__pyx_v_c_href, char *__pyx_v_c_name) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":107
 * cdef public api int delAttributeFromNsName(tree.xmlNode* c_element,
 *                                        char* c_href, char* c_name):
 *     return _delAttributeFromNsName(c_element, c_href, c_name)             # <<<<<<<<<<<<<<
 * 
 * cdef public api bint hasChild(xmlNode* c_node):
 */
  __pyx_r = __pyx_f_4lxml_5etree__delAttributeFromNsName(__pyx_v_c_element, __pyx_v_c_href, __pyx_v_c_name);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":109
 *     return _delAttributeFromNsName(c_element, c_href, c_name)
 * 
 * cdef public api bint hasChild(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _hasChild(c_node)
 * 
 */

 DL_EXPORT(int) hasChild(xmlNode *__pyx_v_c_node) {
  int __pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":110
 * 
 * cdef public api bint hasChild(xmlNode* c_node):
 *     return _hasChild(c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api xmlNode* findChild(xmlNode* c_node, Py_ssize_t index):
 */
  __pyx_r = __pyx_f_4lxml_5etree__hasChild(__pyx_v_c_node);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":112
 *     return _hasChild(c_node)
 * 
 * cdef public api xmlNode* findChild(xmlNode* c_node, Py_ssize_t index):             # <<<<<<<<<<<<<<
 *     return _findChild(c_node, index)
 * 
 */

 DL_EXPORT(xmlNode) *findChild(xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_index) {
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":113
 * 
 * cdef public api xmlNode* findChild(xmlNode* c_node, Py_ssize_t index):
 *     return _findChild(c_node, index)             # <<<<<<<<<<<<<<
 * 
 * cdef public api xmlNode* findChildForwards(xmlNode* c_node, Py_ssize_t index):
 */
  __pyx_r = __pyx_f_4lxml_5etree__findChild(__pyx_v_c_node, __pyx_v_index);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":115
 *     return _findChild(c_node, index)
 * 
 * cdef public api xmlNode* findChildForwards(xmlNode* c_node, Py_ssize_t index):             # <<<<<<<<<<<<<<
 *     return _findChildForwards(c_node, index)
 * 
 */

 DL_EXPORT(xmlNode) *findChildForwards(xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_index) {
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":116
 * 
 * cdef public api xmlNode* findChildForwards(xmlNode* c_node, Py_ssize_t index):
 *     return _findChildForwards(c_node, index)             # <<<<<<<<<<<<<<
 * 
 * cdef public api xmlNode* findChildBackwards(xmlNode* c_node, Py_ssize_t index):
 */
  __pyx_r = __pyx_f_4lxml_5etree__findChildForwards(__pyx_v_c_node, __pyx_v_index);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":118
 *     return _findChildForwards(c_node, index)
 * 
 * cdef public api xmlNode* findChildBackwards(xmlNode* c_node, Py_ssize_t index):             # <<<<<<<<<<<<<<
 *     return _findChildBackwards(c_node, index)
 * 
 */

 DL_EXPORT(xmlNode) *findChildBackwards(xmlNode *__pyx_v_c_node, Py_ssize_t __pyx_v_index) {
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":119
 * 
 * cdef public api xmlNode* findChildBackwards(xmlNode* c_node, Py_ssize_t index):
 *     return _findChildBackwards(c_node, index)             # <<<<<<<<<<<<<<
 * 
 * cdef public api xmlNode* nextElement(xmlNode* c_node):
 */
  __pyx_r = __pyx_f_4lxml_5etree__findChildBackwards(__pyx_v_c_node, __pyx_v_index);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":121
 *     return _findChildBackwards(c_node, index)
 * 
 * cdef public api xmlNode* nextElement(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _nextElement(c_node)
 * 
 */

 DL_EXPORT(xmlNode) *nextElement(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":122
 * 
 * cdef public api xmlNode* nextElement(xmlNode* c_node):
 *     return _nextElement(c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api xmlNode* previousElement(xmlNode* c_node):
 */
  __pyx_r = __pyx_f_4lxml_5etree__nextElement(__pyx_v_c_node);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":124
 *     return _nextElement(c_node)
 * 
 * cdef public api xmlNode* previousElement(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _previousElement(c_node)
 * 
 */

 DL_EXPORT(xmlNode) *previousElement(xmlNode *__pyx_v_c_node) {
  xmlNode *__pyx_r;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":125
 * 
 * cdef public api xmlNode* previousElement(xmlNode* c_node):
 *     return _previousElement(c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api void appendChild(_Element parent, _Element child):
 */
  __pyx_r = __pyx_f_4lxml_5etree__previousElement(__pyx_v_c_node);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":127
 *     return _previousElement(c_node)
 * 
 * cdef public api void appendChild(_Element parent, _Element child):             # <<<<<<<<<<<<<<
 *     _appendChild(parent, child)
 * 
 */

 DL_EXPORT(void) appendChild(struct LxmlElement *__pyx_v_parent, struct LxmlElement *__pyx_v_child) {
  int __pyx_1;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":128
 * 
 * cdef public api void appendChild(_Element parent, _Element child):
 *     _appendChild(parent, child)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object pyunicode(char* s):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__appendChild(__pyx_v_parent, __pyx_v_child); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("lxml.etree.appendChild");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":130
 *     _appendChild(parent, child)
 * 
 * cdef public api object pyunicode(char* s):             # <<<<<<<<<<<<<<
 *     if s is NULL:
 *         raise TypeError
 */

 DL_EXPORT(PyObject) *pyunicode(char *__pyx_v_s) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":131
 * 
 * cdef public api object pyunicode(char* s):
 *     if s is NULL:             # <<<<<<<<<<<<<<
 *         raise TypeError
 *     return funicode(s)
 */
  __pyx_1 = (__pyx_v_s == NULL);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":132
 * cdef public api object pyunicode(char* s):
 *     if s is NULL:
 *         raise TypeError             # <<<<<<<<<<<<<<
 *     return funicode(s)
 * 
 */
    __Pyx_Raise(__pyx_builtin_TypeError, 0, 0);
    {__pyx_filename = __pyx_f[23]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":133
 *     if s is NULL:
 *         raise TypeError
 *     return funicode(s)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object utf8(object s):
 */
  __pyx_2 = __pyx_f_4lxml_5etree_funicode(__pyx_v_s); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("lxml.etree.pyunicode");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":135
 *     return funicode(s)
 * 
 * cdef public api object utf8(object s):             # <<<<<<<<<<<<<<
 *     return _utf8(s)
 * 
 */

 DL_EXPORT(PyObject) *utf8(PyObject *__pyx_v_s) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":136
 * 
 * cdef public api object utf8(object s):
 *     return _utf8(s)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object getNsTag(object tag):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__utf8(__pyx_v_s); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.utf8");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":138
 *     return _utf8(s)
 * 
 * cdef public api object getNsTag(object tag):             # <<<<<<<<<<<<<<
 *     return _getNsTag(tag)
 * 
 */

 DL_EXPORT(PyObject) *getNsTag(PyObject *__pyx_v_tag) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":139
 * 
 * cdef public api object getNsTag(object tag):
 *     return _getNsTag(tag)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object namespacedName(xmlNode* c_node):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__getNsTag(__pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.getNsTag");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":141
 *     return _getNsTag(tag)
 * 
 * cdef public api object namespacedName(xmlNode* c_node):             # <<<<<<<<<<<<<<
 *     return _namespacedName(c_node)
 * 
 */

 DL_EXPORT(PyObject) *namespacedName(xmlNode *__pyx_v_c_node) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":142
 * 
 * cdef public api object namespacedName(xmlNode* c_node):
 *     return _namespacedName(c_node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api object namespacedNameFromNsName(char* href, char* name):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__namespacedName(__pyx_v_c_node); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.namespacedName");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":144
 *     return _namespacedName(c_node)
 * 
 * cdef public api object namespacedNameFromNsName(char* href, char* name):             # <<<<<<<<<<<<<<
 *     return _namespacedNameFromNsName(href, name)
 * 
 */

 DL_EXPORT(PyObject) *namespacedNameFromNsName(char *__pyx_v_href, char *__pyx_v_name) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":145
 * 
 * cdef public api object namespacedNameFromNsName(char* href, char* name):
 *     return _namespacedNameFromNsName(href, name)             # <<<<<<<<<<<<<<
 * 
 * cdef public api void iteratorStoreNext(_ElementIterator iterator, _Element node):
 */
  __pyx_1 = __pyx_f_4lxml_5etree__namespacedNameFromNsName(__pyx_v_href, __pyx_v_name); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("lxml.etree.namespacedNameFromNsName");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":147
 *     return _namespacedNameFromNsName(href, name)
 * 
 * cdef public api void iteratorStoreNext(_ElementIterator iterator, _Element node):             # <<<<<<<<<<<<<<
 *     iterator._storeNext(node)
 * 
 */

 DL_EXPORT(void) iteratorStoreNext(struct LxmlElementIterator *__pyx_v_iterator, struct LxmlElement *__pyx_v_node) {

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":148
 * 
 * cdef public api void iteratorStoreNext(_ElementIterator iterator, _Element node):
 *     iterator._storeNext(node)             # <<<<<<<<<<<<<<
 * 
 * cdef public api void initTagMatch(_ElementTagMatcher matcher, tag):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ElementIterator *)__pyx_v_iterator->__pyx_base.__pyx_vtab)->_storeNext(__pyx_v_iterator, __pyx_v_node);

}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":150
 *     iterator._storeNext(node)
 * 
 * cdef public api void initTagMatch(_ElementTagMatcher matcher, tag):             # <<<<<<<<<<<<<<
 *     matcher._initTagMatch(tag)
 * 
 */

 DL_EXPORT(void) initTagMatch(struct LxmlElementTagMatcher *__pyx_v_matcher, PyObject *__pyx_v_tag) {
  PyObject *__pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":151
 * 
 * cdef public api void initTagMatch(_ElementTagMatcher matcher, tag):
 *     matcher._initTagMatch(tag)             # <<<<<<<<<<<<<<
 * 
 * cdef public api tree.xmlNs* findOrBuildNodeNsPrefix(
 */
  __pyx_1 = ((struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher *)__pyx_v_matcher->__pyx_vtab)->_initTagMatch(__pyx_v_matcher, __pyx_v_tag); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("lxml.etree.initTagMatch");
  __pyx_L0:;
}

/* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":153
 *     matcher._initTagMatch(tag)
 * 
 * cdef public api tree.xmlNs* findOrBuildNodeNsPrefix(             # <<<<<<<<<<<<<<
 *     _Document doc, xmlNode* c_node, char* href, char* prefix) except NULL:
 *     if doc is None:
 */

 DL_EXPORT(xmlNs) *findOrBuildNodeNsPrefix(struct LxmlDocument *__pyx_v_doc, xmlNode *__pyx_v_c_node, char *__pyx_v_href, char *__pyx_v_prefix) {
  xmlNs *__pyx_r;
  int __pyx_1;
  xmlNs *__pyx_2;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":155
 * cdef public api tree.xmlNs* findOrBuildNodeNsPrefix(
 *     _Document doc, xmlNode* c_node, char* href, char* prefix) except NULL:
 *     if doc is None:             # <<<<<<<<<<<<<<
 *         raise TypeError
 *     return doc._findOrBuildNodeNs(c_node, href, prefix)
 */
  __pyx_1 = (((PyObject *)__pyx_v_doc) == Py_None);
  if (__pyx_1) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":156
 *     _Document doc, xmlNode* c_node, char* href, char* prefix) except NULL:
 *     if doc is None:
 *         raise TypeError             # <<<<<<<<<<<<<<
 *     return doc._findOrBuildNodeNs(c_node, href, prefix)
 */
    __Pyx_Raise(__pyx_builtin_TypeError, 0, 0);
    {__pyx_filename = __pyx_f[23]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/public-api.pxi":157
 *     if doc is None:
 *         raise TypeError
 *     return doc._findOrBuildNodeNs(c_node, href, prefix)             # <<<<<<<<<<<<<<
 */
  __pyx_2 = ((struct __pyx_vtabstruct_4lxml_5etree__Document *)__pyx_v_doc->__pyx_vtab)->_findOrBuildNodeNs(__pyx_v_doc, __pyx_v_c_node, __pyx_v_href, __pyx_v_prefix); if (unlikely(__pyx_2 == NULL)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("lxml.etree.findOrBuildNodeNsPrefix");
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}
static struct __pyx_vtabstruct_4lxml_5etree__TempStore __pyx_vtable_4lxml_5etree__TempStore;

static PyObject *__pyx_tp_new_4lxml_5etree__TempStore(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__TempStore *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__TempStore *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__TempStore;
  p->_storage = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__TempStore(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__TempStore *p = (struct __pyx_obj_4lxml_5etree__TempStore *)o;
  Py_XDECREF(p->_storage);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__TempStore(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__TempStore *p = (struct __pyx_obj_4lxml_5etree__TempStore *)o;
  if (p->_storage) {
    e = (*v)(p->_storage, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__TempStore(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__TempStore *p = (struct __pyx_obj_4lxml_5etree__TempStore *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_storage);
  p->_storage = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__TempStore[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__TempStore = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__TempStore = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__TempStore = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__TempStore = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__TempStore = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._TempStore", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__TempStore), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__TempStore, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__TempStore, /*tp_as_number*/
  &__pyx_tp_as_sequence__TempStore, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__TempStore, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__TempStore, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__TempStore, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__TempStore, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__TempStore, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_10_TempStore___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__TempStore, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext __pyx_vtable_4lxml_5etree__ExceptionContext;

static PyObject *__pyx_tp_new_4lxml_5etree__ExceptionContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ExceptionContext *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ExceptionContext;
  p->_exc_info = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ExceptionContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ExceptionContext *p = (struct __pyx_obj_4lxml_5etree__ExceptionContext *)o;
  Py_XDECREF(p->_exc_info);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ExceptionContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ExceptionContext *p = (struct __pyx_obj_4lxml_5etree__ExceptionContext *)o;
  if (p->_exc_info) {
    e = (*v)(p->_exc_info, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ExceptionContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ExceptionContext *p = (struct __pyx_obj_4lxml_5etree__ExceptionContext *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_exc_info);
  p->_exc_info = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ExceptionContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ExceptionContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ExceptionContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ExceptionContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ExceptionContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ExceptionContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ExceptionContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ExceptionContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ExceptionContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ExceptionContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__ExceptionContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ExceptionContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ExceptionContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ExceptionContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ExceptionContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ExceptionContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ExceptionContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_QName(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_QName *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_QName *)o);
  p->text = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_QName(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_QName *p = (struct __pyx_obj_4lxml_5etree_QName *)o;
  Py_XDECREF(p->text);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_QName(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_QName *p = (struct __pyx_obj_4lxml_5etree_QName *)o;
  if (p->text) {
    e = (*v)(p->text, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_QName(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_QName *p = (struct __pyx_obj_4lxml_5etree_QName *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->text);
  p->text = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_QName[] = {
  {"__str__", (PyCFunction)__pyx_pf_4lxml_5etree_5QName___str__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree_QName[] = {
  {"text", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_QName, text), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_QName = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_QName = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_QName = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_QName = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_QName = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.QName", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_QName), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_QName, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_QName, /*tp_as_number*/
  &__pyx_tp_as_sequence_QName, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_QName, /*tp_as_mapping*/
  __pyx_pf_4lxml_5etree_5QName___hash__, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_4lxml_5etree_5QName___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_QName, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "QName(text_or_uri, tag=None)\n\n    QName wrapper.\n\n    Pass a tag name by itself or a namespace URI and a tag name to\n    create a qualified name.  The ``text`` property holds the\n    qualified name in ``{namespace}tagname`` notation.\n\n    You can pass QName objects wherever a tag name is expected.  Also,\n    setting Element text from a QName will resolve the namespace\n    prefix and set a qualified text value.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_QName, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_QName, /*tp_clear*/
  __pyx_pf_4lxml_5etree_5QName___richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_QName, /*tp_methods*/
  __pyx_members_4lxml_5etree_QName, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_5QName___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_QName, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__BaseParser __pyx_vtable_4lxml_5etree__BaseParser;

static PyObject *__pyx_tp_new_4lxml_5etree__BaseParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__BaseParser *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__BaseParser *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__BaseParser;
  p->_class_lookup = ((struct LxmlElementClassLookup *)Py_None); Py_INCREF(Py_None);
  p->_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);
  p->_parser_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  p->_push_parser_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  p->_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None); Py_INCREF(Py_None);
  p->_filename = Py_None; Py_INCREF(Py_None);
  p->_target = Py_None; Py_INCREF(Py_None);
  p->_default_encoding = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__BaseParser(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__BaseParser *p = (struct __pyx_obj_4lxml_5etree__BaseParser *)o;
  Py_XDECREF(((PyObject *)p->_class_lookup));
  Py_XDECREF(((PyObject *)p->_resolvers));
  Py_XDECREF(((PyObject *)p->_parser_context));
  Py_XDECREF(((PyObject *)p->_push_parser_context));
  Py_XDECREF(((PyObject *)p->_schema));
  Py_XDECREF(p->_filename);
  Py_XDECREF(p->_target);
  Py_XDECREF(p->_default_encoding);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__BaseParser(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__BaseParser *p = (struct __pyx_obj_4lxml_5etree__BaseParser *)o;
  if (p->_class_lookup) {
    e = (*v)(((PyObject*)p->_class_lookup), a); if (e) return e;
  }
  if (p->_resolvers) {
    e = (*v)(((PyObject*)p->_resolvers), a); if (e) return e;
  }
  if (p->_parser_context) {
    e = (*v)(((PyObject*)p->_parser_context), a); if (e) return e;
  }
  if (p->_push_parser_context) {
    e = (*v)(((PyObject*)p->_push_parser_context), a); if (e) return e;
  }
  if (p->_schema) {
    e = (*v)(((PyObject*)p->_schema), a); if (e) return e;
  }
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  if (p->_target) {
    e = (*v)(p->_target, a); if (e) return e;
  }
  if (p->_default_encoding) {
    e = (*v)(p->_default_encoding, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__BaseParser(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__BaseParser *p = (struct __pyx_obj_4lxml_5etree__BaseParser *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_class_lookup);
  p->_class_lookup = ((struct LxmlElementClassLookup *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_resolvers);
  p->_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_parser_context);
  p->_parser_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_push_parser_context);
  p->_push_parser_context = ((struct __pyx_obj_4lxml_5etree__ParserContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_schema);
  p->_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_filename);
  p->_filename = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_target);
  p->_target = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_default_encoding);
  p->_default_encoding = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_11_BaseParser_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_11_BaseParser_9error_log___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_11_BaseParser_resolvers(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_11_BaseParser_9resolvers___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_11_BaseParser_version(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_11_BaseParser_7version___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__BaseParser[] = {
  {"setElementClassLookup", (PyCFunction)__pyx_pf_4lxml_5etree_11_BaseParser_setElementClassLookup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_11_BaseParser_setElementClassLookup},
  {"set_element_class_lookup", (PyCFunction)__pyx_pf_4lxml_5etree_11_BaseParser_set_element_class_lookup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_11_BaseParser_set_element_class_lookup},
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_11_BaseParser_copy, METH_NOARGS, __pyx_doc_4lxml_5etree_11_BaseParser_copy},
  {"makeelement", (PyCFunction)__pyx_pf_4lxml_5etree_11_BaseParser_makeelement, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_11_BaseParser_makeelement},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__BaseParser[] = {
  {"error_log", __pyx_getprop_4lxml_5etree_11_BaseParser_error_log, 0, __pyx_k_24, 0},
  {"resolvers", __pyx_getprop_4lxml_5etree_11_BaseParser_resolvers, 0, __pyx_k_25, 0},
  {"version", __pyx_getprop_4lxml_5etree_11_BaseParser_version, 0, __pyx_k_26, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__BaseParser = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__BaseParser = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__BaseParser = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__BaseParser = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__BaseParser = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._BaseParser", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__BaseParser), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseParser, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__BaseParser, /*tp_as_number*/
  &__pyx_tp_as_sequence__BaseParser, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__BaseParser, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__BaseParser, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseParser, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseParser, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__BaseParser, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__BaseParser, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_11_BaseParser___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__BaseParser, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__Document __pyx_vtable_4lxml_5etree__Document;

static PyObject *__pyx_tp_new_4lxml_5etree__Document(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct LxmlDocument *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct LxmlDocument *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__Document;
  p->_prefix_tail = Py_None; Py_INCREF(Py_None);
  p->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__Document(PyObject *o) {
  struct LxmlDocument *p = (struct LxmlDocument *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_9_Document___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_prefix_tail);
  Py_XDECREF(((PyObject *)p->_parser));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__Document(PyObject *o, visitproc v, void *a) {
  int e;
  struct LxmlDocument *p = (struct LxmlDocument *)o;
  if (p->_prefix_tail) {
    e = (*v)(p->_prefix_tail, a); if (e) return e;
  }
  if (p->_parser) {
    e = (*v)(((PyObject*)p->_parser), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__Document(PyObject *o) {
  struct LxmlDocument *p = (struct LxmlDocument *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_prefix_tail);
  p->_prefix_tail = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_parser);
  p->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__Document[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Document = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__Document = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Document = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Document = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlDocumentType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._Document", /*tp_name*/
  sizeof(struct LxmlDocument), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Document, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Document, /*tp_as_number*/
  &__pyx_tp_as_sequence__Document, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Document, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Document, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Internal base class to reference a libxml document.\n\n    When instances of this class are garbage collected, the libxml\n    document is cleaned up.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Document, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Document, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__Document, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__Document, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_DocInfo(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_DocInfo *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_DocInfo *)o);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_DocInfo(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_DocInfo *p = (struct __pyx_obj_4lxml_5etree_DocInfo *)o;
  Py_XDECREF(((PyObject *)p->_doc));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_DocInfo(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_DocInfo *p = (struct __pyx_obj_4lxml_5etree_DocInfo *)o;
  if (p->_doc) {
    e = (*v)(((PyObject*)p->_doc), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_DocInfo(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_DocInfo *p = (struct __pyx_obj_4lxml_5etree_DocInfo *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_doc);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_root_name(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_9root_name___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_public_id(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_9public_id___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_system_url(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_10system_url___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_xml_version(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_11xml_version___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_encoding(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_8encoding___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_URL(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_3URL___get__(o);
}

static int __pyx_setprop_4lxml_5etree_7DocInfo_URL(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_7DocInfo_3URL___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_doctype(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_7doctype___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_internalDTD(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_11internalDTD___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7DocInfo_externalDTD(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7DocInfo_11externalDTD___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_DocInfo[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree_DocInfo[] = {
  {"root_name", __pyx_getprop_4lxml_5etree_7DocInfo_root_name, 0, __pyx_k_1, 0},
  {"public_id", __pyx_getprop_4lxml_5etree_7DocInfo_public_id, 0, __pyx_k_2, 0},
  {"system_url", __pyx_getprop_4lxml_5etree_7DocInfo_system_url, 0, __pyx_k_3, 0},
  {"xml_version", __pyx_getprop_4lxml_5etree_7DocInfo_xml_version, 0, __pyx_k_4, 0},
  {"encoding", __pyx_getprop_4lxml_5etree_7DocInfo_encoding, 0, __pyx_k_5, 0},
  {"URL", __pyx_getprop_4lxml_5etree_7DocInfo_URL, __pyx_setprop_4lxml_5etree_7DocInfo_URL, __pyx_k_6, 0},
  {"doctype", __pyx_getprop_4lxml_5etree_7DocInfo_doctype, 0, __pyx_k_7, 0},
  {"internalDTD", __pyx_getprop_4lxml_5etree_7DocInfo_internalDTD, 0, __pyx_k_8, 0},
  {"externalDTD", __pyx_getprop_4lxml_5etree_7DocInfo_externalDTD, 0, __pyx_k_9, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_DocInfo = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_DocInfo = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_DocInfo = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_DocInfo = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_DocInfo = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.DocInfo", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_DocInfo), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_DocInfo, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_DocInfo, /*tp_as_number*/
  &__pyx_tp_as_sequence_DocInfo, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_DocInfo, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_DocInfo, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Document information provided by parser and DTD.", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_DocInfo, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_DocInfo, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_DocInfo, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree_DocInfo, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_7DocInfo___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_DocInfo, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree__Element(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct LxmlElement *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct LxmlElement *)o);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  p->_tag = Py_None; Py_INCREF(Py_None);
  p->_attrib = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__Element(PyObject *o) {
  struct LxmlElement *p = (struct LxmlElement *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_8_Element___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_doc));
  Py_XDECREF(p->_tag);
  Py_XDECREF(p->_attrib);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__Element(PyObject *o, visitproc v, void *a) {
  int e;
  struct LxmlElement *p = (struct LxmlElement *)o;
  if (p->_doc) {
    e = (*v)(((PyObject*)p->_doc), a); if (e) return e;
  }
  if (p->_tag) {
    e = (*v)(p->_tag, a); if (e) return e;
  }
  if (p->_attrib) {
    e = (*v)(p->_attrib, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__Element(PyObject *o) {
  struct LxmlElement *p = (struct LxmlElement *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_doc);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_tag);
  p->_tag = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_attrib);
  p->_attrib = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4lxml_5etree__Element(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_4lxml_5etree__Element(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_4lxml_5etree_8_Element___setitem__(o, i, v);
  }
  else {
    return __pyx_pf_4lxml_5etree_8_Element___delitem__(o, i);
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_tag(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_3tag___get__(o);
}

static int __pyx_setprop_4lxml_5etree_8_Element_tag(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_8_Element_3tag___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_attrib(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_6attrib___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_text(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_4text___get__(o);
}

static int __pyx_setprop_4lxml_5etree_8_Element_text(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_8_Element_4text___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_tail(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_4tail___get__(o);
}

static int __pyx_setprop_4lxml_5etree_8_Element_tail(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_8_Element_4tail___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_prefix(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_6prefix___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_sourceline(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_10sourceline___get__(o);
}

static int __pyx_setprop_4lxml_5etree_8_Element_sourceline(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_8_Element_10sourceline___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_nsmap(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_5nsmap___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Element_base(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Element_4base___get__(o);
}

static int __pyx_setprop_4lxml_5etree_8_Element_base(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_8_Element_4base___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__Element[] = {
  {"_init", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element__init, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element__init},
  {"__deepcopy__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element___deepcopy__, METH_O, __pyx_doc_4lxml_5etree_8_Element___deepcopy__},
  {"__copy__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element___copy__, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element___copy__},
  {"set", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_set},
  {"append", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_append, METH_O, __pyx_doc_4lxml_5etree_8_Element_append},
  {"addnext", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_addnext, METH_O, __pyx_doc_4lxml_5etree_8_Element_addnext},
  {"addprevious", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_addprevious, METH_O, __pyx_doc_4lxml_5etree_8_Element_addprevious},
  {"extend", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_extend, METH_O, __pyx_doc_4lxml_5etree_8_Element_extend},
  {"clear", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_clear, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_clear},
  {"insert", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_insert, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_insert},
  {"remove", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_remove, METH_O, __pyx_doc_4lxml_5etree_8_Element_remove},
  {"replace", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_replace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_replace},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element___repr__, METH_NOARGS|METH_COEXIST, __pyx_doc_4lxml_5etree_8_Element___repr__},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element___getitem__, METH_O|METH_COEXIST, __pyx_doc_4lxml_5etree_8_Element___getitem__},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element___iter__, METH_NOARGS|METH_COEXIST, __pyx_doc_4lxml_5etree_8_Element___iter__},
  {"__reversed__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element___reversed__, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element___reversed__},
  {"index", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_index},
  {"get", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_get},
  {"keys", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_keys, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_keys},
  {"values", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_values, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_values},
  {"items", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_items, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_items},
  {"getchildren", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_getchildren, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_getchildren},
  {"getparent", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_getparent, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_getparent},
  {"getnext", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_getnext, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_getnext},
  {"getprevious", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_getprevious, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_getprevious},
  {"itersiblings", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_itersiblings, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_itersiblings},
  {"iterancestors", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_iterancestors, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_iterancestors},
  {"iterdescendants", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_iterdescendants, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_iterdescendants},
  {"iterchildren", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_iterchildren, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_iterchildren},
  {"getroottree", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_getroottree, METH_NOARGS, __pyx_doc_4lxml_5etree_8_Element_getroottree},
  {"getiterator", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_getiterator, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_getiterator},
  {"iter", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_iter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_iter},
  {"itertext", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_itertext, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_itertext},
  {"makeelement", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_makeelement, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_makeelement},
  {"find", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_find, METH_O, __pyx_doc_4lxml_5etree_8_Element_find},
  {"findtext", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_findtext, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_findtext},
  {"findall", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_findall, METH_O, __pyx_doc_4lxml_5etree_8_Element_findall},
  {"iterfind", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_iterfind, METH_O, __pyx_doc_4lxml_5etree_8_Element_iterfind},
  {"xpath", (PyCFunction)__pyx_pf_4lxml_5etree_8_Element_xpath, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8_Element_xpath},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__Element[] = {
  {"tag", __pyx_getprop_4lxml_5etree_8_Element_tag, __pyx_setprop_4lxml_5etree_8_Element_tag, __pyx_k_10, 0},
  {"attrib", __pyx_getprop_4lxml_5etree_8_Element_attrib, 0, __pyx_k_11, 0},
  {"text", __pyx_getprop_4lxml_5etree_8_Element_text, __pyx_setprop_4lxml_5etree_8_Element_text, __pyx_k_12, 0},
  {"tail", __pyx_getprop_4lxml_5etree_8_Element_tail, __pyx_setprop_4lxml_5etree_8_Element_tail, __pyx_k_13, 0},
  {"prefix", __pyx_getprop_4lxml_5etree_8_Element_prefix, 0, __pyx_k_14, 0},
  {"sourceline", __pyx_getprop_4lxml_5etree_8_Element_sourceline, __pyx_setprop_4lxml_5etree_8_Element_sourceline, __pyx_k_15, 0},
  {"nsmap", __pyx_getprop_4lxml_5etree_8_Element_nsmap, 0, __pyx_k_16, 0},
  {"base", __pyx_getprop_4lxml_5etree_8_Element_base, __pyx_setprop_4lxml_5etree_8_Element_base, __pyx_k_17, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Element = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pf_4lxml_5etree_8_Element___nonzero__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__Element = {
  __pyx_pf_4lxml_5etree_8_Element___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree__Element, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pf_4lxml_5etree_8_Element___contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Element = {
  __pyx_pf_4lxml_5etree_8_Element___len__, /*mp_length*/
  __pyx_pf_4lxml_5etree_8_Element___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lxml_5etree__Element, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Element = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlElementType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._Element", /*tp_name*/
  sizeof(struct LxmlElement), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_8_Element___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Element, /*tp_as_number*/
  &__pyx_tp_as_sequence__Element, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Element, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Element, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Element class.\n\n    References a document object and a libxml node.\n\n    By pointing to a Document instance, a reference is kept to\n    _Document as long as there is some pointer to a node in it.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_8_Element___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__Element, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__Element, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__Element, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement __pyx_vtable_4lxml_5etree___ContentOnlyElement;

static PyObject *__pyx_tp_new_4lxml_5etree___ContentOnlyElement(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree___ContentOnlyElement *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree___ContentOnlyElement *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree___ContentOnlyElement;
  return o;
}
static PyObject *__pyx_sq_item_4lxml_5etree___ContentOnlyElement(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_4lxml_5etree___ContentOnlyElement(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_4lxml_5etree_20__ContentOnlyElement___setitem__(o, i, v);
  }
  else {
    if (__pyx_ptype_4lxml_5etree__Element->tp_as_mapping && __pyx_ptype_4lxml_5etree__Element->tp_as_mapping->mp_ass_subscript)
      return __pyx_ptype_4lxml_5etree__Element->tp_as_mapping->mp_ass_subscript(o, i, v);
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_20__ContentOnlyElement_attrib(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_20__ContentOnlyElement_6attrib___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_20__ContentOnlyElement_text(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_20__ContentOnlyElement_4text___get__(o);
}

static int __pyx_setprop_4lxml_5etree_20__ContentOnlyElement_text(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_20__ContentOnlyElement_4text___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree___ContentOnlyElement[] = {
  {"set", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_set},
  {"append", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_append, METH_O, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_append},
  {"insert", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_insert, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_insert},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement___getitem__, METH_O|METH_COEXIST, __pyx_doc_4lxml_5etree_20__ContentOnlyElement___getitem__},
  {"get", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_get},
  {"keys", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_keys, METH_NOARGS, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_keys},
  {"items", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_items, METH_NOARGS, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_items},
  {"values", (PyCFunction)__pyx_pf_4lxml_5etree_20__ContentOnlyElement_values, METH_NOARGS, __pyx_doc_4lxml_5etree_20__ContentOnlyElement_values},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree___ContentOnlyElement[] = {
  {"attrib", __pyx_getprop_4lxml_5etree_20__ContentOnlyElement_attrib, 0, 0, 0},
  {"text", __pyx_getprop_4lxml_5etree_20__ContentOnlyElement_text, __pyx_setprop_4lxml_5etree_20__ContentOnlyElement_text, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number___ContentOnlyElement = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence___ContentOnlyElement = {
  __pyx_pf_4lxml_5etree_20__ContentOnlyElement___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree___ContentOnlyElement, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping___ContentOnlyElement = {
  __pyx_pf_4lxml_5etree_20__ContentOnlyElement___len__, /*mp_length*/
  __pyx_pf_4lxml_5etree_20__ContentOnlyElement___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lxml_5etree___ContentOnlyElement, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer___ContentOnlyElement = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree___ContentOnlyElement = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.__ContentOnlyElement", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree___ContentOnlyElement), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number___ContentOnlyElement, /*tp_as_number*/
  &__pyx_tp_as_sequence___ContentOnlyElement, /*tp_as_sequence*/
  &__pyx_tp_as_mapping___ContentOnlyElement, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer___ContentOnlyElement, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree___ContentOnlyElement, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree___ContentOnlyElement, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree___ContentOnlyElement, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__Comment __pyx_vtable_4lxml_5etree__Comment;

static PyObject *__pyx_tp_new_4lxml_5etree__Comment(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__Comment *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__Comment *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree__Comment;
  return o;
}

static PyObject *__pyx_getprop_4lxml_5etree_8_Comment_tag(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8_Comment_3tag___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__Comment[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_8_Comment___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__Comment[] = {
  {"tag", __pyx_getprop_4lxml_5etree_8_Comment_tag, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Comment = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__Comment = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Comment = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Comment = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__Comment = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._Comment", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__Comment), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_8_Comment___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Comment, /*tp_as_number*/
  &__pyx_tp_as_sequence__Comment, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Comment, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Comment, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__Comment, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__Comment, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__Comment, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ProcessingInstruction __pyx_vtable_4lxml_5etree__ProcessingInstruction;

static PyObject *__pyx_tp_new_4lxml_5etree__ProcessingInstruction(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ProcessingInstruction *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ProcessingInstruction *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree__ProcessingInstruction;
  return o;
}

static PyObject *__pyx_getprop_4lxml_5etree_22_ProcessingInstruction_tag(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_22_ProcessingInstruction_3tag___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_22_ProcessingInstruction_target(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_22_ProcessingInstruction_6target___get__(o);
}

static int __pyx_setprop_4lxml_5etree_22_ProcessingInstruction_target(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_22_ProcessingInstruction_6target___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ProcessingInstruction[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_22_ProcessingInstruction___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__ProcessingInstruction[] = {
  {"tag", __pyx_getprop_4lxml_5etree_22_ProcessingInstruction_tag, 0, 0, 0},
  {"target", __pyx_getprop_4lxml_5etree_22_ProcessingInstruction_target, __pyx_setprop_4lxml_5etree_22_ProcessingInstruction_target, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ProcessingInstruction = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ProcessingInstruction = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ProcessingInstruction = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ProcessingInstruction = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ProcessingInstruction = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ProcessingInstruction", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ProcessingInstruction), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_22_ProcessingInstruction___repr__, /*tp_repr*/
  &__pyx_tp_as_number__ProcessingInstruction, /*tp_as_number*/
  &__pyx_tp_as_sequence__ProcessingInstruction, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ProcessingInstruction, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ProcessingInstruction, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ProcessingInstruction, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__ProcessingInstruction, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ProcessingInstruction, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__Entity __pyx_vtable_4lxml_5etree__Entity;

static PyObject *__pyx_tp_new_4lxml_5etree__Entity(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__Entity *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__Entity *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree__Entity;
  return o;
}

static PyObject *__pyx_getprop_4lxml_5etree_7_Entity_tag(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7_Entity_3tag___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_7_Entity_name(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7_Entity_4name___get__(o);
}

static int __pyx_setprop_4lxml_5etree_7_Entity_name(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_7_Entity_4name___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4lxml_5etree_7_Entity_text(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_7_Entity_4text___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__Entity[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_7_Entity___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__Entity[] = {
  {"tag", __pyx_getprop_4lxml_5etree_7_Entity_tag, 0, 0, 0},
  {"name", __pyx_getprop_4lxml_5etree_7_Entity_name, __pyx_setprop_4lxml_5etree_7_Entity_name, 0, 0},
  {"text", __pyx_getprop_4lxml_5etree_7_Entity_text, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Entity = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__Entity = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Entity = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Entity = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__Entity = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._Entity", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__Entity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_7_Entity___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Entity, /*tp_as_number*/
  &__pyx_tp_as_sequence__Entity, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Entity, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Entity, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__Entity, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__Entity, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__Entity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ElementTree __pyx_vtable_4lxml_5etree__ElementTree;

static PyObject *__pyx_tp_new_4lxml_5etree__ElementTree(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct LxmlElementTree *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct LxmlElementTree *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ElementTree;
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  p->_context_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ElementTree(PyObject *o) {
  struct LxmlElementTree *p = (struct LxmlElementTree *)o;
  Py_XDECREF(((PyObject *)p->_doc));
  Py_XDECREF(((PyObject *)p->_context_node));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ElementTree(PyObject *o, visitproc v, void *a) {
  int e;
  struct LxmlElementTree *p = (struct LxmlElementTree *)o;
  if (p->_doc) {
    e = (*v)(((PyObject*)p->_doc), a); if (e) return e;
  }
  if (p->_context_node) {
    e = (*v)(((PyObject*)p->_context_node), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ElementTree(PyObject *o) {
  struct LxmlElementTree *p = (struct LxmlElementTree *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_doc);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_context_node);
  p->_context_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_12_ElementTree_docinfo(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_12_ElementTree_7docinfo___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_12_ElementTree_parser(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_12_ElementTree_6parser___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ElementTree[] = {
  {"parse", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_parse, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_parse},
  {"_setroot", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree__setroot, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree__setroot},
  {"getroot", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_getroot, METH_NOARGS, __pyx_doc_4lxml_5etree_12_ElementTree_getroot},
  {"__copy__", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree___copy__, METH_NOARGS, 0},
  {"__deepcopy__", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree___deepcopy__, METH_O, 0},
  {"write", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_write, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_write},
  {"getpath", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_getpath, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_getpath},
  {"getiterator", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_getiterator, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_getiterator},
  {"iter", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_iter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_iter},
  {"find", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_find, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_find},
  {"findtext", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_findtext, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_findtext},
  {"findall", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_findall, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_findall},
  {"iterfind", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_iterfind, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_iterfind},
  {"xpath", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_xpath, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_xpath},
  {"xslt", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_xslt, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_12_ElementTree_xslt},
  {"relaxng", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_relaxng, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_relaxng},
  {"xmlschema", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_xmlschema, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_xmlschema},
  {"xinclude", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_xinclude, METH_NOARGS, __pyx_doc_4lxml_5etree_12_ElementTree_xinclude},
  {"write_c14n", (PyCFunction)__pyx_pf_4lxml_5etree_12_ElementTree_write_c14n, METH_O, __pyx_doc_4lxml_5etree_12_ElementTree_write_c14n},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__ElementTree[] = {
  {"docinfo", __pyx_getprop_4lxml_5etree_12_ElementTree_docinfo, 0, __pyx_k_18, 0},
  {"parser", __pyx_getprop_4lxml_5etree_12_ElementTree_parser, 0, __pyx_k_19, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ElementTree = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ElementTree = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ElementTree = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ElementTree = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlElementTreeType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ElementTree", /*tp_name*/
  sizeof(struct LxmlElementTree), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementTree, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ElementTree, /*tp_as_number*/
  &__pyx_tp_as_sequence__ElementTree, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ElementTree, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ElementTree, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementTree, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementTree, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ElementTree, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__ElementTree, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ElementTree, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree__Attrib(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__Attrib *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__Attrib *)o);
  p->_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__Attrib(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__Attrib *p = (struct __pyx_obj_4lxml_5etree__Attrib *)o;
  Py_XDECREF(((PyObject *)p->_element));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__Attrib(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__Attrib *p = (struct __pyx_obj_4lxml_5etree__Attrib *)o;
  if (p->_element) {
    e = (*v)(((PyObject*)p->_element), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__Attrib(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__Attrib *p = (struct __pyx_obj_4lxml_5etree__Attrib *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_element);
  p->_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4lxml_5etree__Attrib(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_4lxml_5etree__Attrib(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_4lxml_5etree_7_Attrib___setitem__(o, i, v);
  }
  else {
    return __pyx_pf_4lxml_5etree_7_Attrib___delitem__(o, i);
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__Attrib[] = {
  {"update", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_update, METH_O, 0},
  {"pop", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_pop, METH_VARARGS|METH_KEYWORDS, 0},
  {"clear", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_clear, METH_NOARGS, 0},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib___repr__, METH_NOARGS|METH_COEXIST, 0},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib___getitem__, METH_O|METH_COEXIST, 0},
  {"get", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_get, METH_VARARGS|METH_KEYWORDS, 0},
  {"keys", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_keys, METH_NOARGS, 0},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"iterkeys", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_iterkeys, METH_NOARGS, 0},
  {"values", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_values, METH_NOARGS, 0},
  {"itervalues", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_itervalues, METH_NOARGS, 0},
  {"items", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_items, METH_NOARGS, 0},
  {"iteritems", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_iteritems, METH_NOARGS, 0},
  {"has_key", (PyCFunction)__pyx_pf_4lxml_5etree_7_Attrib_has_key, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Attrib = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pf_4lxml_5etree_7_Attrib___nonzero__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__Attrib = {
  __pyx_pf_4lxml_5etree_7_Attrib___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree__Attrib, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pf_4lxml_5etree_7_Attrib___contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Attrib = {
  __pyx_pf_4lxml_5etree_7_Attrib___len__, /*mp_length*/
  __pyx_pf_4lxml_5etree_7_Attrib___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lxml_5etree__Attrib, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Attrib = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__Attrib = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._Attrib", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__Attrib), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Attrib, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_7_Attrib___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Attrib, /*tp_as_number*/
  &__pyx_tp_as_sequence__Attrib, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Attrib, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Attrib, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A dict-like proxy for the ``Element.attrib`` property.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Attrib, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Attrib, /*tp_clear*/
  __pyx_pf_4lxml_5etree_7_Attrib___richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_7_Attrib___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__Attrib, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_7_Attrib___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__Attrib, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree__AttribIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__AttribIterator *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__AttribIterator *)o);
  p->_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__AttribIterator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__AttribIterator *p = (struct __pyx_obj_4lxml_5etree__AttribIterator *)o;
  Py_XDECREF(((PyObject *)p->_node));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__AttribIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__AttribIterator *p = (struct __pyx_obj_4lxml_5etree__AttribIterator *)o;
  if (p->_node) {
    e = (*v)(((PyObject*)p->_node), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__AttribIterator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__AttribIterator *p = (struct __pyx_obj_4lxml_5etree__AttribIterator *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_node);
  p->_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__AttribIterator[] = {
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_15_AttribIterator___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__next__", (PyCFunction)__pyx_pf_4lxml_5etree_15_AttribIterator___next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__AttribIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__AttribIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__AttribIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__AttribIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__AttribIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._AttribIterator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__AttribIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__AttribIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__AttribIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence__AttribIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__AttribIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__AttribIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Attribute iterator - for internal use only!\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__AttribIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__AttribIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_15_AttribIterator___iter__, /*tp_iter*/
  __pyx_pf_4lxml_5etree_15_AttribIterator___next__, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__AttribIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__AttribIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher __pyx_vtable_4lxml_5etree__ElementTagMatcher;

static PyObject *__pyx_tp_new_4lxml_5etree__ElementTagMatcher(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct LxmlElementTagMatcher *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct LxmlElementTagMatcher *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ElementTagMatcher;
  p->_pystrings = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ElementTagMatcher(PyObject *o) {
  struct LxmlElementTagMatcher *p = (struct LxmlElementTagMatcher *)o;
  Py_XDECREF(p->_pystrings);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ElementTagMatcher(PyObject *o, visitproc v, void *a) {
  int e;
  struct LxmlElementTagMatcher *p = (struct LxmlElementTagMatcher *)o;
  if (p->_pystrings) {
    e = (*v)(p->_pystrings, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ElementTagMatcher(PyObject *o) {
  struct LxmlElementTagMatcher *p = (struct LxmlElementTagMatcher *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_pystrings);
  p->_pystrings = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ElementTagMatcher[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ElementTagMatcher = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ElementTagMatcher = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ElementTagMatcher = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ElementTagMatcher = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlElementTagMatcherType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ElementTagMatcher", /*tp_name*/
  sizeof(struct LxmlElementTagMatcher), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementTagMatcher, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ElementTagMatcher, /*tp_as_number*/
  &__pyx_tp_as_sequence__ElementTagMatcher, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ElementTagMatcher, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ElementTagMatcher, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementTagMatcher, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementTagMatcher, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ElementTagMatcher, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ElementTagMatcher, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ElementIterator __pyx_vtable_4lxml_5etree__ElementIterator;

static PyObject *__pyx_tp_new_4lxml_5etree__ElementIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct LxmlElementIterator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ElementTagMatcher(t, a, k);
  if (!o) return 0;
  p = ((struct LxmlElementIterator *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher*)__pyx_vtabptr_4lxml_5etree__ElementIterator;
  p->_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ElementIterator(PyObject *o) {
  struct LxmlElementIterator *p = (struct LxmlElementIterator *)o;
  Py_XDECREF(((PyObject *)p->_node));
  __pyx_tp_dealloc_4lxml_5etree__ElementTagMatcher(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ElementIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct LxmlElementIterator *p = (struct LxmlElementIterator *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ElementTagMatcher(o, v, a); if (e) return e;
  if (p->_node) {
    e = (*v)(((PyObject*)p->_node), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ElementIterator(PyObject *o) {
  struct LxmlElementIterator *p = (struct LxmlElementIterator *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ElementTagMatcher(o);
  tmp = ((PyObject*)p->_node);
  p->_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ElementIterator[] = {
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_16_ElementIterator___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__next__", (PyCFunction)__pyx_pf_4lxml_5etree_16_ElementIterator___next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ElementIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ElementIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ElementIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ElementIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlElementIteratorType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ElementIterator", /*tp_name*/
  sizeof(struct LxmlElementIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ElementIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence__ElementIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ElementIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ElementIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_16_ElementIterator___iter__, /*tp_iter*/
  __pyx_pf_4lxml_5etree_16_ElementIterator___next__, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ElementIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ElementIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_ElementChildIterator __pyx_vtable_4lxml_5etree_ElementChildIterator;

static PyObject *__pyx_tp_new_4lxml_5etree_ElementChildIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ElementChildIterator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ElementIterator(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ElementChildIterator *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher*)__pyx_vtabptr_4lxml_5etree_ElementChildIterator;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementChildIterator[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementChildIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementChildIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementChildIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementChildIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ElementChildIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementChildIterator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ElementChildIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementChildIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementChildIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementChildIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementChildIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ElementChildIterator(self, node, tag=None, reversed=False)\n    Iterates over the children of an element.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementChildIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_20ElementChildIterator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementChildIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_SiblingsIterator __pyx_vtable_4lxml_5etree_SiblingsIterator;

static PyObject *__pyx_tp_new_4lxml_5etree_SiblingsIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_SiblingsIterator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ElementIterator(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_SiblingsIterator *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher*)__pyx_vtabptr_4lxml_5etree_SiblingsIterator;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_SiblingsIterator[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SiblingsIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_SiblingsIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SiblingsIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SiblingsIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_SiblingsIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.SiblingsIterator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_SiblingsIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_SiblingsIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_SiblingsIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SiblingsIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SiblingsIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "SiblingsIterator(self, node, tag=None, preceding=False)\n    Iterates over the siblings of an element.\n\n    You can pass the boolean keyword ``preceding`` to specify the direction.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_SiblingsIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_16SiblingsIterator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_SiblingsIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_AncestorsIterator __pyx_vtable_4lxml_5etree_AncestorsIterator;

static PyObject *__pyx_tp_new_4lxml_5etree_AncestorsIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_AncestorsIterator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ElementIterator(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_AncestorsIterator *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher*)__pyx_vtabptr_4lxml_5etree_AncestorsIterator;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_AncestorsIterator[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_AncestorsIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_AncestorsIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_AncestorsIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_AncestorsIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_AncestorsIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.AncestorsIterator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_AncestorsIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_AncestorsIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_AncestorsIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_AncestorsIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_AncestorsIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "AncestorsIterator(self, node, tag=None)\n    Iterates over the ancestors of an element (from parent to parent).\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_AncestorsIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_17AncestorsIterator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_AncestorsIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_ElementDepthFirstIterator __pyx_vtable_4lxml_5etree_ElementDepthFirstIterator;

static PyObject *__pyx_tp_new_4lxml_5etree_ElementDepthFirstIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ElementTagMatcher(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher*)__pyx_vtabptr_4lxml_5etree_ElementDepthFirstIterator;
  p->_next_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  p->_top_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_ElementDepthFirstIterator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *p = (struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)o;
  Py_XDECREF(((PyObject *)p->_next_node));
  Py_XDECREF(((PyObject *)p->_top_node));
  __pyx_tp_dealloc_4lxml_5etree__ElementTagMatcher(o);
}

static int __pyx_tp_traverse_4lxml_5etree_ElementDepthFirstIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *p = (struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ElementTagMatcher(o, v, a); if (e) return e;
  if (p->_next_node) {
    e = (*v)(((PyObject*)p->_next_node), a); if (e) return e;
  }
  if (p->_top_node) {
    e = (*v)(((PyObject*)p->_top_node), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_ElementDepthFirstIterator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *p = (struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ElementTagMatcher(o);
  tmp = ((PyObject*)p->_next_node);
  p->_next_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_top_node);
  p->_top_node = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementDepthFirstIterator[] = {
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__next__", (PyCFunction)__pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementDepthFirstIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementDepthFirstIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementDepthFirstIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementDepthFirstIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ElementDepthFirstIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementDepthFirstIterator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ElementDepthFirstIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_ElementDepthFirstIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementDepthFirstIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementDepthFirstIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementDepthFirstIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementDepthFirstIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ElementDepthFirstIterator(self, node, tag=None, inclusive=True)\n    Iterates over an element and its sub-elements in document order (depth\n    first pre-order).\n\n    Note that this also includes comments, entities and processing\n    instructions.  To filter them out, check if the ``tag`` property\n    of the returned element is a string (i.e. not None and not a\n    factory function), or pass the ``Element`` factory for the ``tag``\n    keyword.\n\n    If the optional ``tag`` argument is not None, the iterator returns only\n    the elements that match the respective name and namespace.\n\n    The optional boolean argument 'inclusive' defaults to True and can be set\n    to False to exclude the start element itself.\n\n    Note that the behaviour of this iterator is completely undefined if the\n    tree it traverses is modified during iteration.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_ElementDepthFirstIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_ElementDepthFirstIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___iter__, /*tp_iter*/
  __pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___next__, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementDepthFirstIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_25ElementDepthFirstIterator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementDepthFirstIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_ElementTextIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ElementTextIterator *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ElementTextIterator *)o);
  p->_nextEvent = Py_None; Py_INCREF(Py_None);
  p->_start_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_ElementTextIterator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementTextIterator *p = (struct __pyx_obj_4lxml_5etree_ElementTextIterator *)o;
  Py_XDECREF(p->_nextEvent);
  Py_XDECREF(((PyObject *)p->_start_element));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_ElementTextIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_ElementTextIterator *p = (struct __pyx_obj_4lxml_5etree_ElementTextIterator *)o;
  if (p->_nextEvent) {
    e = (*v)(p->_nextEvent, a); if (e) return e;
  }
  if (p->_start_element) {
    e = (*v)(((PyObject*)p->_start_element), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_ElementTextIterator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementTextIterator *p = (struct __pyx_obj_4lxml_5etree_ElementTextIterator *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_nextEvent);
  p->_nextEvent = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_start_element);
  p->_start_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementTextIterator[] = {
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_19ElementTextIterator___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__next__", (PyCFunction)__pyx_pf_4lxml_5etree_19ElementTextIterator___next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementTextIterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementTextIterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementTextIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementTextIterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ElementTextIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementTextIterator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ElementTextIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_ElementTextIterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementTextIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementTextIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementTextIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementTextIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ElementTextIterator(self, element, tag=None, with_tail=True)\n    Iterates over the text content of a subtree.\n\n    You can pass the ``tag`` keyword argument to restrict text content to a\n    specific tag name.\n\n    You can set the ``with_tail`` keyword argument to ``False`` to skip over\n    tail text.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_ElementTextIterator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_ElementTextIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_19ElementTextIterator___iter__, /*tp_iter*/
  __pyx_pf_4lxml_5etree_19ElementTextIterator___next__, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementTextIterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_19ElementTextIterator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementTextIterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_CDATA(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_CDATA *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_CDATA *)o);
  p->_utf8_data = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_CDATA(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_CDATA *p = (struct __pyx_obj_4lxml_5etree_CDATA *)o;
  Py_XDECREF(p->_utf8_data);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_CDATA(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_CDATA *p = (struct __pyx_obj_4lxml_5etree_CDATA *)o;
  if (p->_utf8_data) {
    e = (*v)(p->_utf8_data, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_CDATA(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_CDATA *p = (struct __pyx_obj_4lxml_5etree_CDATA *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_utf8_data);
  p->_utf8_data = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_CDATA[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CDATA = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CDATA = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CDATA = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CDATA = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_CDATA = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.CDATA", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_CDATA), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_CDATA, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_CDATA, /*tp_as_number*/
  &__pyx_tp_as_sequence_CDATA, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CDATA, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CDATA, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CDATA(data)\n\n    CDATA factory.  This factory creates an opaque data object that\n    can be used to set Element text.  The usual way to use it is::\n\n        >>> from lxml import etree\n        >>> el = etree.Element('content')\n        >>> el.text = etree.CDATA('a string')\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_CDATA, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_CDATA, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_CDATA, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_5CDATA___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_CDATA, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__LogEntry __pyx_vtable_4lxml_5etree__LogEntry;

static PyObject *__pyx_tp_new_4lxml_5etree__LogEntry(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__LogEntry *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__LogEntry *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__LogEntry;
  p->domain = Py_None; Py_INCREF(Py_None);
  p->type = Py_None; Py_INCREF(Py_None);
  p->level = Py_None; Py_INCREF(Py_None);
  p->line = Py_None; Py_INCREF(Py_None);
  p->column = Py_None; Py_INCREF(Py_None);
  p->message = Py_None; Py_INCREF(Py_None);
  p->filename = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__LogEntry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__LogEntry *p = (struct __pyx_obj_4lxml_5etree__LogEntry *)o;
  Py_XDECREF(p->domain);
  Py_XDECREF(p->type);
  Py_XDECREF(p->level);
  Py_XDECREF(p->line);
  Py_XDECREF(p->column);
  Py_XDECREF(p->message);
  Py_XDECREF(p->filename);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__LogEntry(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__LogEntry *p = (struct __pyx_obj_4lxml_5etree__LogEntry *)o;
  if (p->domain) {
    e = (*v)(p->domain, a); if (e) return e;
  }
  if (p->type) {
    e = (*v)(p->type, a); if (e) return e;
  }
  if (p->level) {
    e = (*v)(p->level, a); if (e) return e;
  }
  if (p->line) {
    e = (*v)(p->line, a); if (e) return e;
  }
  if (p->column) {
    e = (*v)(p->column, a); if (e) return e;
  }
  if (p->message) {
    e = (*v)(p->message, a); if (e) return e;
  }
  if (p->filename) {
    e = (*v)(p->filename, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__LogEntry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__LogEntry *p = (struct __pyx_obj_4lxml_5etree__LogEntry *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->domain);
  p->domain = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->type);
  p->type = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->level);
  p->level = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->line);
  p->line = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->column);
  p->column = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->message);
  p->message = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->filename);
  p->filename = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_9_LogEntry_domain_name(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_9_LogEntry_11domain_name___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_9_LogEntry_type_name(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_9_LogEntry_9type_name___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_9_LogEntry_level_name(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_9_LogEntry_10level_name___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__LogEntry[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_9_LogEntry___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree__LogEntry[] = {
  {"domain", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, domain), READONLY, 0},
  {"type", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, type), READONLY, 0},
  {"level", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, level), READONLY, 0},
  {"line", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, line), READONLY, 0},
  {"column", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, column), READONLY, 0},
  {"message", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, message), READONLY, 0},
  {"filename", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__LogEntry, filename), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__LogEntry[] = {
  {"domain_name", __pyx_getprop_4lxml_5etree_9_LogEntry_domain_name, 0, 0, 0},
  {"type_name", __pyx_getprop_4lxml_5etree_9_LogEntry_type_name, 0, 0, 0},
  {"level_name", __pyx_getprop_4lxml_5etree_9_LogEntry_level_name, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__LogEntry = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__LogEntry = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__LogEntry = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__LogEntry = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__LogEntry = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._LogEntry", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__LogEntry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__LogEntry, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_9_LogEntry___repr__, /*tp_repr*/
  &__pyx_tp_as_number__LogEntry, /*tp_as_number*/
  &__pyx_tp_as_sequence__LogEntry, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__LogEntry, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__LogEntry, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__LogEntry, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__LogEntry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__LogEntry, /*tp_methods*/
  __pyx_members_4lxml_5etree__LogEntry, /*tp_members*/
  __pyx_getsets_4lxml_5etree__LogEntry, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__LogEntry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog __pyx_vtable_4lxml_5etree__BaseErrorLog;

static PyObject *__pyx_tp_new_4lxml_5etree__BaseErrorLog(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__BaseErrorLog;
  p->_first_error = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);
  p->last_error = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__BaseErrorLog(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *p = (struct __pyx_obj_4lxml_5etree__BaseErrorLog *)o;
  Py_XDECREF(((PyObject *)p->_first_error));
  Py_XDECREF(p->last_error);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__BaseErrorLog(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *p = (struct __pyx_obj_4lxml_5etree__BaseErrorLog *)o;
  if (p->_first_error) {
    e = (*v)(((PyObject*)p->_first_error), a); if (e) return e;
  }
  if (p->last_error) {
    e = (*v)(p->last_error, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__BaseErrorLog(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__BaseErrorLog *p = (struct __pyx_obj_4lxml_5etree__BaseErrorLog *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_first_error);
  p->_first_error = ((struct __pyx_obj_4lxml_5etree__LogEntry *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->last_error);
  p->last_error = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__BaseErrorLog[] = {
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_13_BaseErrorLog_copy, METH_NOARGS, 0},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_13_BaseErrorLog___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree__BaseErrorLog[] = {
  {"last_error", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__BaseErrorLog, last_error), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__BaseErrorLog = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__BaseErrorLog = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__BaseErrorLog = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__BaseErrorLog = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__BaseErrorLog = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._BaseErrorLog", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__BaseErrorLog), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseErrorLog, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_13_BaseErrorLog___repr__, /*tp_repr*/
  &__pyx_tp_as_number__BaseErrorLog, /*tp_as_number*/
  &__pyx_tp_as_sequence__BaseErrorLog, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__BaseErrorLog, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__BaseErrorLog, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseErrorLog, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseErrorLog, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__BaseErrorLog, /*tp_methods*/
  __pyx_members_4lxml_5etree__BaseErrorLog, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_13_BaseErrorLog___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__BaseErrorLog, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ListErrorLog __pyx_vtable_4lxml_5etree__ListErrorLog;

static PyObject *__pyx_tp_new_4lxml_5etree__ListErrorLog(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ListErrorLog *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseErrorLog(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ListErrorLog *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog*)__pyx_vtabptr_4lxml_5etree__ListErrorLog;
  p->_entries = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ListErrorLog(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ListErrorLog *p = (struct __pyx_obj_4lxml_5etree__ListErrorLog *)o;
  Py_XDECREF(p->_entries);
  __pyx_tp_dealloc_4lxml_5etree__BaseErrorLog(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ListErrorLog(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ListErrorLog *p = (struct __pyx_obj_4lxml_5etree__ListErrorLog *)o;
  e = __pyx_tp_traverse_4lxml_5etree__BaseErrorLog(o, v, a); if (e) return e;
  if (p->_entries) {
    e = (*v)(p->_entries, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ListErrorLog(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ListErrorLog *p = (struct __pyx_obj_4lxml_5etree__ListErrorLog *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__BaseErrorLog(o);
  tmp = ((PyObject*)p->_entries);
  p->_entries = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4lxml_5etree__ListErrorLog(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ListErrorLog[] = {
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_copy, METH_NOARGS, __pyx_doc_4lxml_5etree_13_ListErrorLog_copy},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog___repr__, METH_NOARGS|METH_COEXIST, 0},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog___getitem__, METH_O|METH_COEXIST, 0},
  {"filter_domains", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_domains, METH_O, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_domains},
  {"filter_types", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_types, METH_O, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_types},
  {"filter_levels", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_levels, METH_O, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_levels},
  {"filter_from_level", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_level, METH_O, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_level},
  {"filter_from_fatals", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_fatals, METH_NOARGS, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_fatals},
  {"filter_from_errors", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_errors, METH_NOARGS, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_errors},
  {"filter_from_warnings", (PyCFunction)__pyx_pf_4lxml_5etree_13_ListErrorLog_filter_from_warnings, METH_NOARGS, __pyx_doc_4lxml_5etree_13_ListErrorLog_filter_from_warnings},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ListErrorLog = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pf_4lxml_5etree_13_ListErrorLog___nonzero__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ListErrorLog = {
  __pyx_pf_4lxml_5etree_13_ListErrorLog___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree__ListErrorLog, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pf_4lxml_5etree_13_ListErrorLog___contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ListErrorLog = {
  __pyx_pf_4lxml_5etree_13_ListErrorLog___len__, /*mp_length*/
  __pyx_pf_4lxml_5etree_13_ListErrorLog___getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ListErrorLog = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ListErrorLog = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ListErrorLog", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ListErrorLog), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ListErrorLog, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_13_ListErrorLog___repr__, /*tp_repr*/
  &__pyx_tp_as_number__ListErrorLog, /*tp_as_number*/
  &__pyx_tp_as_sequence__ListErrorLog, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ListErrorLog, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ListErrorLog, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Immutable base version of a list based error log.", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ListErrorLog, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ListErrorLog, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_13_ListErrorLog___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ListErrorLog, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_13_ListErrorLog___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ListErrorLog, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ErrorLog __pyx_vtable_4lxml_5etree__ErrorLog;

static PyObject *__pyx_tp_new_4lxml_5etree__ErrorLog(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ErrorLog *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ListErrorLog(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog*)__pyx_vtabptr_4lxml_5etree__ErrorLog;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ErrorLog[] = {
  {"clear", (PyCFunction)__pyx_pf_4lxml_5etree_9_ErrorLog_clear, METH_NOARGS, 0},
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_9_ErrorLog_copy, METH_NOARGS, __pyx_doc_4lxml_5etree_9_ErrorLog_copy},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_9_ErrorLog___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"receive", (PyCFunction)__pyx_pf_4lxml_5etree_9_ErrorLog_receive, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ErrorLog = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ErrorLog = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ErrorLog = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ErrorLog = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ErrorLog = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ErrorLog", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ErrorLog), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ListErrorLog, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ErrorLog, /*tp_as_number*/
  &__pyx_tp_as_sequence__ErrorLog, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ErrorLog, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ErrorLog, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ListErrorLog, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ListErrorLog, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_9_ErrorLog___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ErrorLog, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_9_ErrorLog___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ErrorLog, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__DomainErrorLog __pyx_vtable_4lxml_5etree__DomainErrorLog;

static PyObject *__pyx_tp_new_4lxml_5etree__DomainErrorLog(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__DomainErrorLog *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ListErrorLog(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__DomainErrorLog *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog*)__pyx_vtabptr_4lxml_5etree__DomainErrorLog;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__DomainErrorLog[] = {
  {"receive", (PyCFunction)__pyx_pf_4lxml_5etree_15_DomainErrorLog_receive, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__DomainErrorLog = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__DomainErrorLog = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__DomainErrorLog = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__DomainErrorLog = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__DomainErrorLog = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._DomainErrorLog", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__DomainErrorLog), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ListErrorLog, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__DomainErrorLog, /*tp_as_number*/
  &__pyx_tp_as_sequence__DomainErrorLog, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__DomainErrorLog, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__DomainErrorLog, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ListErrorLog, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ListErrorLog, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__DomainErrorLog, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_15_DomainErrorLog___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__DomainErrorLog, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__RotatingErrorLog __pyx_vtable_4lxml_5etree__RotatingErrorLog;

static PyObject *__pyx_tp_new_4lxml_5etree__RotatingErrorLog(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__RotatingErrorLog *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ListErrorLog(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__RotatingErrorLog *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog*)__pyx_vtabptr_4lxml_5etree__RotatingErrorLog;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__RotatingErrorLog[] = {
  {"receive", (PyCFunction)__pyx_pf_4lxml_5etree_17_RotatingErrorLog_receive, METH_O, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__RotatingErrorLog = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__RotatingErrorLog = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__RotatingErrorLog = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__RotatingErrorLog = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__RotatingErrorLog = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._RotatingErrorLog", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__RotatingErrorLog), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ListErrorLog, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__RotatingErrorLog, /*tp_as_number*/
  &__pyx_tp_as_sequence__RotatingErrorLog, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__RotatingErrorLog, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__RotatingErrorLog, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ListErrorLog, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ListErrorLog, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__RotatingErrorLog, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_17_RotatingErrorLog___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__RotatingErrorLog, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_PyErrorLog __pyx_vtable_4lxml_5etree_PyErrorLog;

static PyObject *__pyx_tp_new_4lxml_5etree_PyErrorLog(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_PyErrorLog *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseErrorLog(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_PyErrorLog *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseErrorLog*)__pyx_vtabptr_4lxml_5etree_PyErrorLog;
  p->level_map = Py_None; Py_INCREF(Py_None);
  p->_map_level = Py_None; Py_INCREF(Py_None);
  p->_log = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_PyErrorLog(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_PyErrorLog *p = (struct __pyx_obj_4lxml_5etree_PyErrorLog *)o;
  Py_XDECREF(p->level_map);
  Py_XDECREF(p->_map_level);
  Py_XDECREF(p->_log);
  __pyx_tp_dealloc_4lxml_5etree__BaseErrorLog(o);
}

static int __pyx_tp_traverse_4lxml_5etree_PyErrorLog(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_PyErrorLog *p = (struct __pyx_obj_4lxml_5etree_PyErrorLog *)o;
  e = __pyx_tp_traverse_4lxml_5etree__BaseErrorLog(o, v, a); if (e) return e;
  if (p->level_map) {
    e = (*v)(p->level_map, a); if (e) return e;
  }
  if (p->_map_level) {
    e = (*v)(p->_map_level, a); if (e) return e;
  }
  if (p->_log) {
    e = (*v)(p->_log, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_PyErrorLog(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_PyErrorLog *p = (struct __pyx_obj_4lxml_5etree_PyErrorLog *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__BaseErrorLog(o);
  tmp = ((PyObject*)p->level_map);
  p->level_map = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_map_level);
  p->_map_level = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_log);
  p->_log = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_PyErrorLog[] = {
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_10PyErrorLog_copy, METH_NOARGS, __pyx_doc_4lxml_5etree_10PyErrorLog_copy},
  {"log", (PyCFunction)__pyx_pf_4lxml_5etree_10PyErrorLog_log, METH_VARARGS|METH_KEYWORDS, 0},
  {"receive", (PyCFunction)__pyx_pf_4lxml_5etree_10PyErrorLog_receive, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree_PyErrorLog[] = {
  {"level_map", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_PyErrorLog, level_map), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PyErrorLog = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_PyErrorLog = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_PyErrorLog = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PyErrorLog = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_PyErrorLog = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.PyErrorLog", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_PyErrorLog), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_PyErrorLog, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_PyErrorLog, /*tp_as_number*/
  &__pyx_tp_as_sequence_PyErrorLog, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PyErrorLog, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PyErrorLog, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "PyErrorLog(self, logger_name=None)\n    A global error log that connects to the Python stdlib logging package.\n\n    The constructor accepts an optional logger name.\n\n    If you want to change the mapping between libxml2's ErrorLevels and Python\n    logging levels, you can modify the level_map dictionary from a subclass.\n\n    The default mapping is::\n\n            ErrorLevels.WARNING = logging.WARNING\n            ErrorLevels.ERROR   = logging.ERROR\n            ErrorLevels.FATAL   = logging.CRITICAL\n\n    You can also override the method ``receive()`` that takes a LogEntry\n    object and calls ``self.log(log_entry, format_string, arg1, arg2, ...)``\n    with appropriate data.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_PyErrorLog, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_PyErrorLog, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_PyErrorLog, /*tp_methods*/
  __pyx_members_4lxml_5etree_PyErrorLog, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_10PyErrorLog___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_PyErrorLog, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy __pyx_vtable_4lxml_5etree__ReadOnlyElementProxy;

static PyObject *__pyx_tp_new_4lxml_5etree__ReadOnlyElementProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ReadOnlyElementProxy;
  p->_source_proxy = Py_None; Py_INCREF(Py_None);
  p->_dependent_proxies = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ReadOnlyElementProxy(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *p = (struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)o;
  Py_XDECREF(p->_source_proxy);
  Py_XDECREF(p->_dependent_proxies);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ReadOnlyElementProxy(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *p = (struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)o;
  if (p->_source_proxy) {
    e = (*v)(p->_source_proxy, a); if (e) return e;
  }
  if (p->_dependent_proxies) {
    e = (*v)(p->_dependent_proxies, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ReadOnlyElementProxy(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *p = (struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_source_proxy);
  p->_source_proxy = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_dependent_proxies);
  p->_dependent_proxies = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4lxml_5etree__ReadOnlyElementProxy(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_tag(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_3tag___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_text(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_4text___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_tail(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_4tail___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_attrib(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_6attrib___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_prefix(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_6prefix___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_sourceline(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_10sourceline___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ReadOnlyElementProxy[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___repr__, METH_NOARGS|METH_COEXIST, 0},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___getitem__, METH_O|METH_COEXIST, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___getitem__},
  {"__deepcopy__", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___deepcopy__, METH_O, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___deepcopy__},
  {"__copy__", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___copy__, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy___copy__},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"iterchildren", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_iterchildren, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_iterchildren},
  {"get", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_get},
  {"keys", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_keys, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_keys},
  {"values", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_values, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_values},
  {"items", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_items, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_items},
  {"getchildren", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getchildren, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getchildren},
  {"getparent", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getparent, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getparent},
  {"getnext", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getnext, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getnext},
  {"getprevious", (PyCFunction)__pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy_getprevious, METH_NOARGS, __pyx_doc_4lxml_5etree_21_ReadOnlyElementProxy_getprevious},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__ReadOnlyElementProxy[] = {
  {"tag", __pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_tag, 0, __pyx_k_10, 0},
  {"text", __pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_text, 0, __pyx_k_12, 0},
  {"tail", __pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_tail, 0, __pyx_k_13, 0},
  {"attrib", __pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_attrib, 0, 0, 0},
  {"prefix", __pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_prefix, 0, __pyx_k_14, 0},
  {"sourceline", __pyx_getprop_4lxml_5etree_21_ReadOnlyElementProxy_sourceline, 0, __pyx_k_15, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ReadOnlyElementProxy = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___nonzero__, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ReadOnlyElementProxy = {
  __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree__ReadOnlyElementProxy, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ReadOnlyElementProxy = {
  __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___len__, /*mp_length*/
  __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ReadOnlyElementProxy = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ReadOnlyElementProxy = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ReadOnlyElementProxy", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ReadOnlyElementProxy, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___repr__, /*tp_repr*/
  &__pyx_tp_as_number__ReadOnlyElementProxy, /*tp_as_number*/
  &__pyx_tp_as_sequence__ReadOnlyElementProxy, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ReadOnlyElementProxy, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ReadOnlyElementProxy, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "The main read-only Element proxy class (for internal use only!).", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ReadOnlyElementProxy, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ReadOnlyElementProxy, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_21_ReadOnlyElementProxy___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ReadOnlyElementProxy, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__ReadOnlyElementProxy, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ReadOnlyElementProxy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__AppendOnlyElementProxy __pyx_vtable_4lxml_5etree__AppendOnlyElementProxy;

static PyObject *__pyx_tp_new_4lxml_5etree__AppendOnlyElementProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ReadOnlyElementProxy(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ReadOnlyElementProxy*)__pyx_vtabptr_4lxml_5etree__AppendOnlyElementProxy;
  return o;
}

static PyObject *__pyx_getprop_4lxml_5etree_23_AppendOnlyElementProxy_text(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_4text___get__(o);
}

static int __pyx_setprop_4lxml_5etree_23_AppendOnlyElementProxy_text(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_4text___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__AppendOnlyElementProxy[] = {
  {"append", (PyCFunction)__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_append, METH_O, __pyx_doc_4lxml_5etree_23_AppendOnlyElementProxy_append},
  {"extend", (PyCFunction)__pyx_pf_4lxml_5etree_23_AppendOnlyElementProxy_extend, METH_O, __pyx_doc_4lxml_5etree_23_AppendOnlyElementProxy_extend},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__AppendOnlyElementProxy[] = {
  {"text", __pyx_getprop_4lxml_5etree_23_AppendOnlyElementProxy_text, __pyx_setprop_4lxml_5etree_23_AppendOnlyElementProxy_text, __pyx_k_22, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__AppendOnlyElementProxy = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__AppendOnlyElementProxy = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__AppendOnlyElementProxy = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__AppendOnlyElementProxy = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__AppendOnlyElementProxy = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._AppendOnlyElementProxy", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__AppendOnlyElementProxy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ReadOnlyElementProxy, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__AppendOnlyElementProxy, /*tp_as_number*/
  &__pyx_tp_as_sequence__AppendOnlyElementProxy, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__AppendOnlyElementProxy, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__AppendOnlyElementProxy, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A read-only element that allows adding children and changing the\n    text content (i.e. everything that adds to the subtree).\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ReadOnlyElementProxy, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ReadOnlyElementProxy, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__AppendOnlyElementProxy, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__AppendOnlyElementProxy, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__AppendOnlyElementProxy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_ElementBase(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementBase[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementBase = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementBase = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementBase = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlElementBaseType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementBase", /*tp_name*/
  sizeof(struct LxmlElementBase), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementBase, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementBase, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementBase, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementBase, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "All custom Element classes must inherit from this one.\n\n    Note that you cannot (and must not) instantiate this class or its\n    subclasses.\n\n    Subclasses *must not* override __init__ or __new__ as it is\n    absolutely undefined when these objects will be created or\n    destroyed.  All persistent state of Elements must be stored in the\n    underlying XML.  If you really need to initialize the object after\n    creation, you can implement an ``_init(self)`` method that will be\n    called after object creation.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementBase, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementBase, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_CommentBase __pyx_vtable_4lxml_5etree_CommentBase;

static PyObject *__pyx_tp_new_4lxml_5etree_CommentBase(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_CommentBase *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_CommentBase *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree_CommentBase;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_CommentBase[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CommentBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CommentBase = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CommentBase = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CommentBase = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_CommentBase = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.CommentBase", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_CommentBase), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_CommentBase, /*tp_as_number*/
  &__pyx_tp_as_sequence_CommentBase, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CommentBase, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CommentBase, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "All custom Comment classes must inherit from this one.\n\n    Note that you cannot (and must not) instantiate this class or its\n    subclasses.\n\n    Subclasses *must not* override __init__ or __new__ as it is\n    absolutely undefined when these objects will be created or\n    destroyed.  All persistent state of Comments must be stored in the\n    underlying XML.  If you really need to initialize the object after\n    creation, you can implement an ``_init(self)`` method that will be\n    called after object creation.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_CommentBase, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_CommentBase, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_PIBase __pyx_vtable_4lxml_5etree_PIBase;

static PyObject *__pyx_tp_new_4lxml_5etree_PIBase(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_PIBase *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_PIBase *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree_PIBase;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_PIBase[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PIBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_PIBase = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_PIBase = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PIBase = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_PIBase = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.PIBase", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_PIBase), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_PIBase, /*tp_as_number*/
  &__pyx_tp_as_sequence_PIBase, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PIBase, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PIBase, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "All custom Processing Instruction classes must inherit from this one.\n\n    Note that you cannot (and must not) instantiate this class or its\n    subclasses.\n\n    Subclasses *must not* override __init__ or __new__ as it is\n    absolutely undefined when these objects will be created or\n    destroyed.  All persistent state of PIs must be stored in the\n    underlying XML.  If you really need to initialize the object after\n    creation, you can implement an ``_init(self)`` method that will be\n    called after object creation.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_PIBase, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_PIBase, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_EntityBase __pyx_vtable_4lxml_5etree_EntityBase;

static PyObject *__pyx_tp_new_4lxml_5etree_EntityBase(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_EntityBase *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_EntityBase *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree_EntityBase;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_EntityBase[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_EntityBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_EntityBase = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_EntityBase = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_EntityBase = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_EntityBase = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.EntityBase", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_EntityBase), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_EntityBase, /*tp_as_number*/
  &__pyx_tp_as_sequence_EntityBase, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_EntityBase, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_EntityBase, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "All custom Entity classes must inherit from this one.\n\n    Note that you cannot (and must not) instantiate this class or its\n    subclasses.\n\n    Subclasses *must not* override __init__ or __new__ as it is\n    absolutely undefined when these objects will be created or\n    destroyed.  All persistent state of Entities must be stored in the\n    underlying XML.  If you really need to initialize the object after\n    creation, you can implement an ``_init(self)`` method that will be\n    called after object creation.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_EntityBase, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_EntityBase, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_ElementClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  if (__pyx_pf_4lxml_5etree_18ElementClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_ElementClassLookup(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementClassLookup[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlElementClassLookupType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementClassLookup", /*tp_name*/
  sizeof(struct LxmlElementClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_ElementClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  "ElementClassLookup(self)\n    Superclass of Element class lookups.\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementClassLookup, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup __pyx_vtable_4lxml_5etree_FallbackElementClassLookup;

static PyObject *__pyx_tp_new_4lxml_5etree_FallbackElementClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct LxmlFallbackElementClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_ElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct LxmlFallbackElementClassLookup *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;
  p->fallback = ((struct LxmlElementClassLookup *)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_4lxml_5etree_26FallbackElementClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup(PyObject *o) {
  struct LxmlFallbackElementClassLookup *p = (struct LxmlFallbackElementClassLookup *)o;
  Py_XDECREF(((PyObject *)p->fallback));
  __pyx_tp_dealloc_4lxml_5etree_ElementClassLookup(o);
}

static int __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup(PyObject *o, visitproc v, void *a) {
  int e;
  struct LxmlFallbackElementClassLookup *p = (struct LxmlFallbackElementClassLookup *)o;
  if (__pyx_ptype_4lxml_5etree_ElementClassLookup->tp_traverse) {
    e = __pyx_ptype_4lxml_5etree_ElementClassLookup->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->fallback) {
    e = (*v)(((PyObject*)p->fallback), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup(PyObject *o) {
  struct LxmlFallbackElementClassLookup *p = (struct LxmlFallbackElementClassLookup *)o;
  PyObject* tmp;
  if (__pyx_ptype_4lxml_5etree_ElementClassLookup->tp_clear) {
    __pyx_ptype_4lxml_5etree_ElementClassLookup->tp_clear(o);
  }
  tmp = ((PyObject*)p->fallback);
  p->fallback = ((struct LxmlElementClassLookup *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_FallbackElementClassLookup[] = {
  {"set_fallback", (PyCFunction)__pyx_pf_4lxml_5etree_26FallbackElementClassLookup_set_fallback, METH_O, __pyx_doc_4lxml_5etree_26FallbackElementClassLookup_set_fallback},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree_FallbackElementClassLookup[] = {
  {"fallback", T_OBJECT, offsetof(struct LxmlFallbackElementClassLookup, fallback), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_FallbackElementClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_FallbackElementClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_FallbackElementClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_FallbackElementClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

DL_EXPORT(PyTypeObject) LxmlFallbackElementClassLookupType = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.FallbackElementClassLookup", /*tp_name*/
  sizeof(struct LxmlFallbackElementClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_FallbackElementClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_FallbackElementClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_FallbackElementClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_FallbackElementClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "FallbackElementClassLookup(self, fallback=None)\n\n    Superclass of Element class lookups with additional fallback.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_FallbackElementClassLookup, /*tp_methods*/
  __pyx_members_4lxml_5etree_FallbackElementClassLookup, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_26FallbackElementClassLookup___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_FallbackElementClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_ElementDefaultClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_ElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)o);
  p->element_class = Py_None; Py_INCREF(Py_None);
  p->comment_class = Py_None; Py_INCREF(Py_None);
  p->pi_class = Py_None; Py_INCREF(Py_None);
  p->entity_class = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_4lxml_5etree_25ElementDefaultClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_ElementDefaultClassLookup(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *p = (struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)o;
  Py_XDECREF(p->element_class);
  Py_XDECREF(p->comment_class);
  Py_XDECREF(p->pi_class);
  Py_XDECREF(p->entity_class);
  __pyx_tp_dealloc_4lxml_5etree_ElementClassLookup(o);
}

static int __pyx_tp_traverse_4lxml_5etree_ElementDefaultClassLookup(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *p = (struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)o;
  if (__pyx_ptype_4lxml_5etree_ElementClassLookup->tp_traverse) {
    e = __pyx_ptype_4lxml_5etree_ElementClassLookup->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->element_class) {
    e = (*v)(p->element_class, a); if (e) return e;
  }
  if (p->comment_class) {
    e = (*v)(p->comment_class, a); if (e) return e;
  }
  if (p->pi_class) {
    e = (*v)(p->pi_class, a); if (e) return e;
  }
  if (p->entity_class) {
    e = (*v)(p->entity_class, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_ElementDefaultClassLookup(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *p = (struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup *)o;
  PyObject* tmp;
  if (__pyx_ptype_4lxml_5etree_ElementClassLookup->tp_clear) {
    __pyx_ptype_4lxml_5etree_ElementClassLookup->tp_clear(o);
  }
  tmp = ((PyObject*)p->element_class);
  p->element_class = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->comment_class);
  p->comment_class = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pi_class);
  p->pi_class = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->entity_class);
  p->entity_class = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementDefaultClassLookup[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree_ElementDefaultClassLookup[] = {
  {"element_class", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup, element_class), READONLY, 0},
  {"comment_class", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup, comment_class), READONLY, 0},
  {"pi_class", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup, pi_class), READONLY, 0},
  {"entity_class", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup, entity_class), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementDefaultClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementDefaultClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementDefaultClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementDefaultClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ElementDefaultClassLookup = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementDefaultClassLookup", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ElementDefaultClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_ElementDefaultClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementDefaultClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementDefaultClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementDefaultClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementDefaultClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ElementDefaultClassLookup(self, element=None, comment=None, pi=None, entity=None)\n    Element class lookup scheme that always returns the default Element\n    class.\n\n    The keyword arguments ``element``, ``comment``, ``pi`` and ``entity``\n    accept the respective Element classes.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_ElementDefaultClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_ElementDefaultClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementDefaultClassLookup, /*tp_methods*/
  __pyx_members_4lxml_5etree_ElementDefaultClassLookup, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_25ElementDefaultClassLookup___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementDefaultClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_AttributeBasedElementClassLookup __pyx_vtable_4lxml_5etree_AttributeBasedElementClassLookup;

static PyObject *__pyx_tp_new_4lxml_5etree_AttributeBasedElementClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_FallbackElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup*)__pyx_vtabptr_4lxml_5etree_AttributeBasedElementClassLookup;
  p->_class_mapping = Py_None; Py_INCREF(Py_None);
  p->_pytag = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_4lxml_5etree_32AttributeBasedElementClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_AttributeBasedElementClassLookup(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *p = (struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)o;
  Py_XDECREF(p->_class_mapping);
  Py_XDECREF(p->_pytag);
  __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup(o);
}

static int __pyx_tp_traverse_4lxml_5etree_AttributeBasedElementClassLookup(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *p = (struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)o;
  e = __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup(o, v, a); if (e) return e;
  if (p->_class_mapping) {
    e = (*v)(p->_class_mapping, a); if (e) return e;
  }
  if (p->_pytag) {
    e = (*v)(p->_pytag, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_AttributeBasedElementClassLookup(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *p = (struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup(o);
  tmp = ((PyObject*)p->_class_mapping);
  p->_class_mapping = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pytag);
  p->_pytag = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_AttributeBasedElementClassLookup[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_AttributeBasedElementClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_AttributeBasedElementClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_AttributeBasedElementClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_AttributeBasedElementClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_AttributeBasedElementClassLookup = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.AttributeBasedElementClassLookup", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_AttributeBasedElementClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_AttributeBasedElementClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_AttributeBasedElementClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_AttributeBasedElementClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_AttributeBasedElementClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_AttributeBasedElementClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "AttributeBasedElementClassLookup(self, attribute_name, class_mapping, fallback=None)\n    Checks an attribute of an Element and looks up the value in a\n    class dictionary.\n\n    Arguments:\n      - attribute name - '{ns}name' style string\n      - class mapping  - Python dict mapping attribute values to Element classes\n      - fallback       - optional fallback lookup mechanism\n\n    A None key in the class mapping will be checked if the attribute is\n    missing.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_AttributeBasedElementClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_AttributeBasedElementClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_AttributeBasedElementClassLookup, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_32AttributeBasedElementClassLookup___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_AttributeBasedElementClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_ParserBasedElementClassLookup __pyx_vtable_4lxml_5etree_ParserBasedElementClassLookup;

static PyObject *__pyx_tp_new_4lxml_5etree_ParserBasedElementClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_FallbackElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup*)__pyx_vtabptr_4lxml_5etree_ParserBasedElementClassLookup;
  if (__pyx_pf_4lxml_5etree_29ParserBasedElementClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ParserBasedElementClassLookup[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ParserBasedElementClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ParserBasedElementClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ParserBasedElementClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ParserBasedElementClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ParserBasedElementClassLookup = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ParserBasedElementClassLookup", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ParserBasedElementClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_ParserBasedElementClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ParserBasedElementClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ParserBasedElementClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ParserBasedElementClassLookup(self, fallback=None)\n    Element class lookup based on the XML parser.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ParserBasedElementClassLookup, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ParserBasedElementClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_CustomElementClassLookup __pyx_vtable_4lxml_5etree_CustomElementClassLookup;

static PyObject *__pyx_tp_new_4lxml_5etree_CustomElementClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_FallbackElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_CustomElementClassLookup *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup*)__pyx_vtabptr_4lxml_5etree_CustomElementClassLookup;
  if (__pyx_pf_4lxml_5etree_24CustomElementClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_CustomElementClassLookup[] = {
  {"lookup", (PyCFunction)__pyx_pf_4lxml_5etree_24CustomElementClassLookup_lookup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_24CustomElementClassLookup_lookup},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CustomElementClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_CustomElementClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CustomElementClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CustomElementClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_CustomElementClassLookup = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.CustomElementClassLookup", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_CustomElementClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_CustomElementClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_CustomElementClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CustomElementClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CustomElementClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CustomElementClassLookup(self, fallback=None)\n    Element class lookup based on a subclass method.\n\n    You can inherit from this class and override the method::\n\n        lookup(self, type, doc, namespace, name)\n\n    to lookup the element class for a node. Arguments of the method:\n    * type:      one of 'element', 'comment', 'PI', 'entity'\n    * doc:       document that the node is in\n    * namespace: namespace URI of the node (or None for comments/PIs/entities)\n    * name:      name of the element/entity, None for comments, target for PIs\n\n    If you return None from this method, the fallback will be called.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_CustomElementClassLookup, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_CustomElementClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_PythonElementClassLookup __pyx_vtable_4lxml_5etree_PythonElementClassLookup;

static PyObject *__pyx_tp_new_4lxml_5etree_PythonElementClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_FallbackElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_PythonElementClassLookup *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup*)__pyx_vtabptr_4lxml_5etree_PythonElementClassLookup;
  if (__pyx_pf_4lxml_5etree_24PythonElementClassLookup___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_PythonElementClassLookup[] = {
  {"lookup", (PyCFunction)__pyx_pf_4lxml_5etree_24PythonElementClassLookup_lookup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_24PythonElementClassLookup_lookup},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PythonElementClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_PythonElementClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_PythonElementClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PythonElementClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_PythonElementClassLookup = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.PythonElementClassLookup", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_PythonElementClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_PythonElementClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_PythonElementClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PythonElementClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PythonElementClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "PythonElementClassLookup(self, fallback=None)\n    Element class lookup based on a subclass method.\n\n    This class lookup scheme allows access to the entire XML tree in\n    read-only mode.  To use it, re-implement the ``lookup(self, doc,\n    root)`` method in a subclass::\n\n        >>> from lxml import etree, pyclasslookup\n        >>>\n        >>> class MyElementClass(etree.ElementBase):\n        ...     honkey = True\n        ...\n        >>> class MyLookup(pyclasslookup.PythonElementClassLookup):\n        ...     def lookup(self, doc, root):\n        ...         if root.tag == \"sometag\":\n        ...             return MyElementClass\n        ...         else:\n        ...             for child in root:\n        ...                 if child.tag == \"someothertag\":\n        ...                     return MyElementClass\n        ...         # delegate to default\n        ...         return None\n\n    If you return None from this method, the fallback will be called.\n\n    The first argument is the opaque document instance that contains\n    the Element.  The second argument is a lightweight Element proxy\n    implementation that is only valid during the lookup.  Do not try\n    to keep a reference to it.  Once the lookup is done, the proxy\n    will be invalid.\n\n    Also, you cannot wrap such a read-only Element in an ElementTree,\n    and you must take care not to keep a reference to them outside of\n    the `lookup()` method.\n\n    Note that the API of the Element objects is not complete.  It is\n    purely read-only and does not support all features of the normal\n    `lxml.etree` API (such as XPath, extended slicing or some\n    iteration methods).\n\n    See http://codespeak.net/lxml/element_classes.html\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_PythonElementClassLookup, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_PythonElementClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry __pyx_vtable_4lxml_5etree__NamespaceRegistry;

static PyObject *__pyx_tp_new_4lxml_5etree__NamespaceRegistry(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__NamespaceRegistry;
  p->_ns_uri = Py_None; Py_INCREF(Py_None);
  p->_ns_uri_utf = Py_None; Py_INCREF(Py_None);
  p->_entries = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__NamespaceRegistry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry *p = (struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)o;
  Py_XDECREF(p->_ns_uri);
  Py_XDECREF(p->_ns_uri_utf);
  Py_XDECREF(p->_entries);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__NamespaceRegistry(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry *p = (struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)o;
  if (p->_ns_uri) {
    e = (*v)(p->_ns_uri, a); if (e) return e;
  }
  if (p->_ns_uri_utf) {
    e = (*v)(p->_ns_uri_utf, a); if (e) return e;
  }
  if (p->_entries) {
    e = (*v)(p->_entries, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__NamespaceRegistry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__NamespaceRegistry *p = (struct __pyx_obj_4lxml_5etree__NamespaceRegistry *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_ns_uri);
  p->_ns_uri = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_ns_uri_utf);
  p->_ns_uri_utf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_entries);
  p->_entries = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4lxml_5etree__NamespaceRegistry(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_4lxml_5etree__NamespaceRegistry(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript assignment not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
  else {
    return __pyx_pf_4lxml_5etree_18_NamespaceRegistry___delitem__(o, i);
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__NamespaceRegistry[] = {
  {"update", (PyCFunction)__pyx_pf_4lxml_5etree_18_NamespaceRegistry_update, METH_O, __pyx_doc_4lxml_5etree_18_NamespaceRegistry_update},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_18_NamespaceRegistry___getitem__, METH_O|METH_COEXIST, 0},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_18_NamespaceRegistry___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"items", (PyCFunction)__pyx_pf_4lxml_5etree_18_NamespaceRegistry_items, METH_NOARGS, 0},
  {"iteritems", (PyCFunction)__pyx_pf_4lxml_5etree_18_NamespaceRegistry_iteritems, METH_NOARGS, 0},
  {"clear", (PyCFunction)__pyx_pf_4lxml_5etree_18_NamespaceRegistry_clear, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__NamespaceRegistry = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__NamespaceRegistry = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree__NamespaceRegistry, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__NamespaceRegistry = {
  0, /*mp_length*/
  __pyx_pf_4lxml_5etree_18_NamespaceRegistry___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lxml_5etree__NamespaceRegistry, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__NamespaceRegistry = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__NamespaceRegistry = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._NamespaceRegistry", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__NamespaceRegistry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__NamespaceRegistry, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__NamespaceRegistry, /*tp_as_number*/
  &__pyx_tp_as_sequence__NamespaceRegistry, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__NamespaceRegistry, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__NamespaceRegistry, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Dictionary-like namespace registry", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__NamespaceRegistry, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__NamespaceRegistry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_18_NamespaceRegistry___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__NamespaceRegistry, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_18_NamespaceRegistry___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__NamespaceRegistry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ClassNamespaceRegistry __pyx_vtable_4lxml_5etree__ClassNamespaceRegistry;

static PyObject *__pyx_tp_new_4lxml_5etree__ClassNamespaceRegistry(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ClassNamespaceRegistry *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__NamespaceRegistry(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ClassNamespaceRegistry *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry*)__pyx_vtabptr_4lxml_5etree__ClassNamespaceRegistry;
  return o;
}

static int __pyx_mp_ass_subscript_4lxml_5etree__ClassNamespaceRegistry(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___setitem__(o, i, v);
  }
  else {
    if (__pyx_ptype_4lxml_5etree__NamespaceRegistry->tp_as_mapping && __pyx_ptype_4lxml_5etree__NamespaceRegistry->tp_as_mapping->mp_ass_subscript)
      return __pyx_ptype_4lxml_5etree__NamespaceRegistry->tp_as_mapping->mp_ass_subscript(o, i, v);
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ClassNamespaceRegistry[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ClassNamespaceRegistry = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ClassNamespaceRegistry = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ClassNamespaceRegistry = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lxml_5etree__ClassNamespaceRegistry, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ClassNamespaceRegistry = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ClassNamespaceRegistry = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ClassNamespaceRegistry", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ClassNamespaceRegistry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__NamespaceRegistry, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_23_ClassNamespaceRegistry___repr__, /*tp_repr*/
  &__pyx_tp_as_number__ClassNamespaceRegistry, /*tp_as_number*/
  &__pyx_tp_as_sequence__ClassNamespaceRegistry, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ClassNamespaceRegistry, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ClassNamespaceRegistry, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Dictionary-like registry for namespace implementation classes", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__NamespaceRegistry, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__NamespaceRegistry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ClassNamespaceRegistry, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ClassNamespaceRegistry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_ElementNamespaceClassLookup __pyx_vtable_4lxml_5etree_ElementNamespaceClassLookup;

static PyObject *__pyx_tp_new_4lxml_5etree_ElementNamespaceClassLookup(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_FallbackElementClassLookup(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup*)__pyx_vtabptr_4lxml_5etree_ElementNamespaceClassLookup;
  p->_namespace_registries = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_ElementNamespaceClassLookup(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *p = (struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)o;
  Py_XDECREF(p->_namespace_registries);
  __pyx_tp_dealloc_4lxml_5etree_FallbackElementClassLookup(o);
}

static int __pyx_tp_traverse_4lxml_5etree_ElementNamespaceClassLookup(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *p = (struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)o;
  e = __pyx_tp_traverse_4lxml_5etree_FallbackElementClassLookup(o, v, a); if (e) return e;
  if (p->_namespace_registries) {
    e = (*v)(p->_namespace_registries, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_ElementNamespaceClassLookup(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *p = (struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree_FallbackElementClassLookup(o);
  tmp = ((PyObject*)p->_namespace_registries);
  p->_namespace_registries = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ElementNamespaceClassLookup[] = {
  {"get_namespace", (PyCFunction)__pyx_pf_4lxml_5etree_27ElementNamespaceClassLookup_get_namespace, METH_O, __pyx_doc_4lxml_5etree_27ElementNamespaceClassLookup_get_namespace},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ElementNamespaceClassLookup = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ElementNamespaceClassLookup = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ElementNamespaceClassLookup = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ElementNamespaceClassLookup = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ElementNamespaceClassLookup = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ElementNamespaceClassLookup", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ElementNamespaceClassLookup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_ElementNamespaceClassLookup, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ElementNamespaceClassLookup, /*tp_as_number*/
  &__pyx_tp_as_sequence_ElementNamespaceClassLookup, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ElementNamespaceClassLookup, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ElementNamespaceClassLookup, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ElementNamespaceClassLookup(self, fallback=None)\n\n    Element class lookup scheme that searches the Element class in the\n    Namespace registry.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_ElementNamespaceClassLookup, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_ElementNamespaceClassLookup, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ElementNamespaceClassLookup, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_27ElementNamespaceClassLookup___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ElementNamespaceClassLookup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__FunctionNamespaceRegistry __pyx_vtable_4lxml_5etree__FunctionNamespaceRegistry;

static PyObject *__pyx_tp_new_4lxml_5etree__FunctionNamespaceRegistry(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__NamespaceRegistry(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry*)__pyx_vtabptr_4lxml_5etree__FunctionNamespaceRegistry;
  return o;
}

static int __pyx_mp_ass_subscript_4lxml_5etree__FunctionNamespaceRegistry(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___setitem__(o, i, v);
  }
  else {
    if (__pyx_ptype_4lxml_5etree__NamespaceRegistry->tp_as_mapping && __pyx_ptype_4lxml_5etree__NamespaceRegistry->tp_as_mapping->mp_ass_subscript)
      return __pyx_ptype_4lxml_5etree__NamespaceRegistry->tp_as_mapping->mp_ass_subscript(o, i, v);
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__FunctionNamespaceRegistry[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__FunctionNamespaceRegistry = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__FunctionNamespaceRegistry = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__FunctionNamespaceRegistry = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  __pyx_mp_ass_subscript_4lxml_5etree__FunctionNamespaceRegistry, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__FunctionNamespaceRegistry = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__FunctionNamespaceRegistry = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._FunctionNamespaceRegistry", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__FunctionNamespaceRegistry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__NamespaceRegistry, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_26_FunctionNamespaceRegistry___repr__, /*tp_repr*/
  &__pyx_tp_as_number__FunctionNamespaceRegistry, /*tp_as_number*/
  &__pyx_tp_as_sequence__FunctionNamespaceRegistry, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__FunctionNamespaceRegistry, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__FunctionNamespaceRegistry, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__NamespaceRegistry, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__NamespaceRegistry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__FunctionNamespaceRegistry, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__FunctionNamespaceRegistry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XPathFunctionNamespaceRegistry __pyx_vtable_4lxml_5etree__XPathFunctionNamespaceRegistry;

static PyObject *__pyx_tp_new_4lxml_5etree__XPathFunctionNamespaceRegistry(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__NamespaceRegistry(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__NamespaceRegistry*)__pyx_vtabptr_4lxml_5etree__XPathFunctionNamespaceRegistry;
  p->_prefix = Py_None; Py_INCREF(Py_None);
  p->_prefix_utf = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__XPathFunctionNamespaceRegistry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *p = (struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)o;
  Py_XDECREF(p->_prefix);
  Py_XDECREF(p->_prefix_utf);
  __pyx_tp_dealloc_4lxml_5etree__NamespaceRegistry(o);
}

static int __pyx_tp_traverse_4lxml_5etree__XPathFunctionNamespaceRegistry(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *p = (struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)o;
  e = __pyx_tp_traverse_4lxml_5etree__NamespaceRegistry(o, v, a); if (e) return e;
  if (p->_prefix) {
    e = (*v)(p->_prefix, a); if (e) return e;
  }
  if (p->_prefix_utf) {
    e = (*v)(p->_prefix_utf, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__XPathFunctionNamespaceRegistry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *p = (struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__NamespaceRegistry(o);
  tmp = ((PyObject*)p->_prefix);
  p->_prefix = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_prefix_utf);
  p->_prefix_utf = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_31_XPathFunctionNamespaceRegistry_prefix(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___get__(o);
}

static int __pyx_setprop_4lxml_5etree_31_XPathFunctionNamespaceRegistry_prefix(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___set__(o, v);
  }
  else {
    return __pyx_pf_4lxml_5etree_31_XPathFunctionNamespaceRegistry_6prefix___del__(o);
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XPathFunctionNamespaceRegistry[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__XPathFunctionNamespaceRegistry[] = {
  {"prefix", __pyx_getprop_4lxml_5etree_31_XPathFunctionNamespaceRegistry_prefix, __pyx_setprop_4lxml_5etree_31_XPathFunctionNamespaceRegistry_prefix, __pyx_k_23, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XPathFunctionNamespaceRegistry = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XPathFunctionNamespaceRegistry = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XPathFunctionNamespaceRegistry = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XPathFunctionNamespaceRegistry = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XPathFunctionNamespaceRegistry = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XPathFunctionNamespaceRegistry", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XPathFunctionNamespaceRegistry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__XPathFunctionNamespaceRegistry, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XPathFunctionNamespaceRegistry, /*tp_as_number*/
  &__pyx_tp_as_sequence__XPathFunctionNamespaceRegistry, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XPathFunctionNamespaceRegistry, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XPathFunctionNamespaceRegistry, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__XPathFunctionNamespaceRegistry, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__XPathFunctionNamespaceRegistry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XPathFunctionNamespaceRegistry, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__XPathFunctionNamespaceRegistry, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XPathFunctionNamespaceRegistry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree__InputDocument(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__InputDocument *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__InputDocument *)o);
  p->_data_bytes = Py_None; Py_INCREF(Py_None);
  p->_filename = Py_None; Py_INCREF(Py_None);
  p->_file = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__InputDocument(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__InputDocument *p = (struct __pyx_obj_4lxml_5etree__InputDocument *)o;
  Py_XDECREF(p->_data_bytes);
  Py_XDECREF(p->_filename);
  Py_XDECREF(p->_file);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__InputDocument(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__InputDocument *p = (struct __pyx_obj_4lxml_5etree__InputDocument *)o;
  if (p->_data_bytes) {
    e = (*v)(p->_data_bytes, a); if (e) return e;
  }
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  if (p->_file) {
    e = (*v)(p->_file, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__InputDocument(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__InputDocument *p = (struct __pyx_obj_4lxml_5etree__InputDocument *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_data_bytes);
  p->_data_bytes = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_filename);
  p->_filename = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_file);
  p->_file = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__InputDocument[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__InputDocument = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__InputDocument = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__InputDocument = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__InputDocument = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__InputDocument = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._InputDocument", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__InputDocument), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__InputDocument, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__InputDocument, /*tp_as_number*/
  &__pyx_tp_as_sequence__InputDocument, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__InputDocument, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__InputDocument, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__InputDocument, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__InputDocument, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__InputDocument, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__InputDocument, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_Resolver(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_Resolver(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_Resolver[] = {
  {"resolve", (PyCFunction)__pyx_pf_4lxml_5etree_8Resolver_resolve, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8Resolver_resolve},
  {"resolve_empty", (PyCFunction)__pyx_pf_4lxml_5etree_8Resolver_resolve_empty, METH_O, __pyx_doc_4lxml_5etree_8Resolver_resolve_empty},
  {"resolve_string", (PyCFunction)__pyx_pf_4lxml_5etree_8Resolver_resolve_string, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8Resolver_resolve_string},
  {"resolve_filename", (PyCFunction)__pyx_pf_4lxml_5etree_8Resolver_resolve_filename, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8Resolver_resolve_filename},
  {"resolve_file", (PyCFunction)__pyx_pf_4lxml_5etree_8Resolver_resolve_file, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_8Resolver_resolve_file},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Resolver = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Resolver = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Resolver = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Resolver = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_Resolver = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.Resolver", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_Resolver), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_Resolver, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Resolver, /*tp_as_number*/
  &__pyx_tp_as_sequence_Resolver, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Resolver, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Resolver, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  "This is the base class of all resolvers.", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_Resolver, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_Resolver, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ResolverRegistry __pyx_vtable_4lxml_5etree__ResolverRegistry;

static PyObject *__pyx_tp_new_4lxml_5etree__ResolverRegistry(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ResolverRegistry;
  p->_resolvers = Py_None; Py_INCREF(Py_None);
  p->_default_resolver = ((struct __pyx_obj_4lxml_5etree_Resolver *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ResolverRegistry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *p = (struct __pyx_obj_4lxml_5etree__ResolverRegistry *)o;
  Py_XDECREF(p->_resolvers);
  Py_XDECREF(((PyObject *)p->_default_resolver));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ResolverRegistry(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *p = (struct __pyx_obj_4lxml_5etree__ResolverRegistry *)o;
  if (p->_resolvers) {
    e = (*v)(p->_resolvers, a); if (e) return e;
  }
  if (p->_default_resolver) {
    e = (*v)(((PyObject*)p->_default_resolver), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ResolverRegistry(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ResolverRegistry *p = (struct __pyx_obj_4lxml_5etree__ResolverRegistry *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_resolvers);
  p->_resolvers = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_default_resolver);
  p->_default_resolver = ((struct __pyx_obj_4lxml_5etree_Resolver *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ResolverRegistry[] = {
  {"add", (PyCFunction)__pyx_pf_4lxml_5etree_17_ResolverRegistry_add, METH_O, __pyx_doc_4lxml_5etree_17_ResolverRegistry_add},
  {"remove", (PyCFunction)__pyx_pf_4lxml_5etree_17_ResolverRegistry_remove, METH_O, __pyx_doc_4lxml_5etree_17_ResolverRegistry_remove},
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_17_ResolverRegistry_copy, METH_NOARGS, __pyx_doc_4lxml_5etree_17_ResolverRegistry_copy},
  {"resolve", (PyCFunction)__pyx_pf_4lxml_5etree_17_ResolverRegistry_resolve, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_17_ResolverRegistry_resolve},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_17_ResolverRegistry___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ResolverRegistry = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ResolverRegistry = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ResolverRegistry = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ResolverRegistry = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ResolverRegistry = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ResolverRegistry", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ResolverRegistry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ResolverRegistry, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_17_ResolverRegistry___repr__, /*tp_repr*/
  &__pyx_tp_as_number__ResolverRegistry, /*tp_as_number*/
  &__pyx_tp_as_sequence__ResolverRegistry, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ResolverRegistry, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ResolverRegistry, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ResolverRegistry, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ResolverRegistry, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ResolverRegistry, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_17_ResolverRegistry___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ResolverRegistry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ResolverContext __pyx_vtable_4lxml_5etree__ResolverContext;

static PyObject *__pyx_tp_new_4lxml_5etree__ResolverContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ResolverContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ExceptionContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ResolverContext *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext*)__pyx_vtabptr_4lxml_5etree__ResolverContext;
  p->_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);
  p->_storage = ((struct __pyx_obj_4lxml_5etree__TempStore *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ResolverContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ResolverContext *p = (struct __pyx_obj_4lxml_5etree__ResolverContext *)o;
  Py_XDECREF(((PyObject *)p->_resolvers));
  Py_XDECREF(((PyObject *)p->_storage));
  __pyx_tp_dealloc_4lxml_5etree__ExceptionContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ResolverContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ResolverContext *p = (struct __pyx_obj_4lxml_5etree__ResolverContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ExceptionContext(o, v, a); if (e) return e;
  if (p->_resolvers) {
    e = (*v)(((PyObject*)p->_resolvers), a); if (e) return e;
  }
  if (p->_storage) {
    e = (*v)(((PyObject*)p->_storage), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ResolverContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ResolverContext *p = (struct __pyx_obj_4lxml_5etree__ResolverContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ExceptionContext(o);
  tmp = ((PyObject*)p->_resolvers);
  p->_resolvers = ((struct __pyx_obj_4lxml_5etree__ResolverRegistry *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_storage);
  p->_storage = ((struct __pyx_obj_4lxml_5etree__TempStore *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ResolverContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ResolverContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ResolverContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ResolverContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ResolverContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ResolverContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ResolverContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ResolverContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ResolverContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ResolverContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__ResolverContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ResolverContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ResolverContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ResolverContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ResolverContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ResolverContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ResolverContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ParserContext __pyx_vtable_4lxml_5etree__ParserContext;

static PyObject *__pyx_tp_new_4lxml_5etree__ParserContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ParserContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ResolverContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ParserContext *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext*)__pyx_vtabptr_4lxml_5etree__ParserContext;
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  p->_validator = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ParserContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ParserContext *p = (struct __pyx_obj_4lxml_5etree__ParserContext *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_14_ParserContext___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_error_log));
  Py_XDECREF(((PyObject *)p->_validator));
  __pyx_tp_dealloc_4lxml_5etree__ResolverContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ParserContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ParserContext *p = (struct __pyx_obj_4lxml_5etree__ParserContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ResolverContext(o, v, a); if (e) return e;
  if (p->_error_log) {
    e = (*v)(((PyObject*)p->_error_log), a); if (e) return e;
  }
  if (p->_validator) {
    e = (*v)(((PyObject*)p->_validator), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ParserContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ParserContext *p = (struct __pyx_obj_4lxml_5etree__ParserContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ResolverContext(o);
  tmp = ((PyObject*)p->_error_log);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_validator);
  p->_validator = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ParserContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ParserContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ParserContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ParserContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ParserContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ParserContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ParserContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ParserContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ParserContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ParserContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__ParserContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ParserContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ParserContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ParserContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ParserContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ParserContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ParserContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__SaxParserContext __pyx_vtable_4lxml_5etree__SaxParserContext;

static PyObject *__pyx_tp_new_4lxml_5etree__SaxParserContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ParserContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__SaxParserContext *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext*)__pyx_vtabptr_4lxml_5etree__SaxParserContext;
  p->_target = ((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__SaxParserContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *p = (struct __pyx_obj_4lxml_5etree__SaxParserContext *)o;
  Py_XDECREF(((PyObject *)p->_target));
  __pyx_tp_dealloc_4lxml_5etree__ParserContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__SaxParserContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__SaxParserContext *p = (struct __pyx_obj_4lxml_5etree__SaxParserContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ParserContext(o, v, a); if (e) return e;
  if (p->_target) {
    e = (*v)(((PyObject*)p->_target), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__SaxParserContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__SaxParserContext *p = (struct __pyx_obj_4lxml_5etree__SaxParserContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ParserContext(o);
  tmp = ((PyObject*)p->_target);
  p->_target = ((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__SaxParserContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SaxParserContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__SaxParserContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__SaxParserContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SaxParserContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__SaxParserContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._SaxParserContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__SaxParserContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__SaxParserContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SaxParserContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__SaxParserContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SaxParserContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SaxParserContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "This class maps SAX2 events to method calls.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__SaxParserContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__SaxParserContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__SaxParserContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__SaxParserContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__TargetParserContext __pyx_vtable_4lxml_5etree__TargetParserContext;

static PyObject *__pyx_tp_new_4lxml_5etree__TargetParserContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__TargetParserContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__SaxParserContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__TargetParserContext *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext*)__pyx_vtabptr_4lxml_5etree__TargetParserContext;
  p->_python_target = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__TargetParserContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__TargetParserContext *p = (struct __pyx_obj_4lxml_5etree__TargetParserContext *)o;
  Py_XDECREF(p->_python_target);
  __pyx_tp_dealloc_4lxml_5etree__SaxParserContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__TargetParserContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__TargetParserContext *p = (struct __pyx_obj_4lxml_5etree__TargetParserContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__SaxParserContext(o, v, a); if (e) return e;
  if (p->_python_target) {
    e = (*v)(p->_python_target, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__TargetParserContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__TargetParserContext *p = (struct __pyx_obj_4lxml_5etree__TargetParserContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__SaxParserContext(o);
  tmp = ((PyObject*)p->_python_target);
  p->_python_target = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__TargetParserContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__TargetParserContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__TargetParserContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__TargetParserContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__TargetParserContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__TargetParserContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._TargetParserContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__TargetParserContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__TargetParserContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__TargetParserContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__TargetParserContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__TargetParserContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__TargetParserContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "This class maps SAX2 events to the ET parser target interface.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__TargetParserContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__TargetParserContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__TargetParserContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__TargetParserContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ParserSchemaValidationContext __pyx_vtable_4lxml_5etree__ParserSchemaValidationContext;

static PyObject *__pyx_tp_new_4lxml_5etree__ParserSchemaValidationContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ParserSchemaValidationContext;
  p->_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ParserSchemaValidationContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *p = (struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_30_ParserSchemaValidationContext___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_schema));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ParserSchemaValidationContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *p = (struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)o;
  if (p->_schema) {
    e = (*v)(((PyObject*)p->_schema), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ParserSchemaValidationContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *p = (struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_schema);
  p->_schema = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ParserSchemaValidationContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ParserSchemaValidationContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ParserSchemaValidationContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ParserSchemaValidationContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ParserSchemaValidationContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ParserSchemaValidationContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ParserSchemaValidationContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ParserSchemaValidationContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ParserSchemaValidationContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ParserSchemaValidationContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__ParserSchemaValidationContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ParserSchemaValidationContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ParserSchemaValidationContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ParserSchemaValidationContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ParserSchemaValidationContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ParserSchemaValidationContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ParserSchemaValidationContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree__Validator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__Validator *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__Validator *)o);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__Validator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__Validator *p = (struct __pyx_obj_4lxml_5etree__Validator *)o;
  Py_XDECREF(((PyObject *)p->_error_log));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__Validator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__Validator *p = (struct __pyx_obj_4lxml_5etree__Validator *)o;
  if (p->_error_log) {
    e = (*v)(((PyObject*)p->_error_log), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__Validator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__Validator *p = (struct __pyx_obj_4lxml_5etree__Validator *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_error_log);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_10_Validator_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_10_Validator_9error_log___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__Validator[] = {
  {"validate", (PyCFunction)__pyx_pf_4lxml_5etree_10_Validator_validate, METH_O, __pyx_doc_4lxml_5etree_10_Validator_validate},
  {"assertValid", (PyCFunction)__pyx_pf_4lxml_5etree_10_Validator_assertValid, METH_O, __pyx_doc_4lxml_5etree_10_Validator_assertValid},
  {"assert_", (PyCFunction)__pyx_pf_4lxml_5etree_10_Validator_assert_, METH_O, __pyx_doc_4lxml_5etree_10_Validator_assert_},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__Validator[] = {
  {"error_log", __pyx_getprop_4lxml_5etree_10_Validator_error_log, 0, __pyx_k_34, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Validator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__Validator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Validator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Validator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__Validator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._Validator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__Validator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Validator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Validator, /*tp_as_number*/
  &__pyx_tp_as_sequence__Validator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Validator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Validator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Base class for XML validators.", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Validator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Validator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__Validator, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__Validator, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_10_Validator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__Validator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XMLSchema __pyx_vtable_4lxml_5etree_XMLSchema;

static PyObject *__pyx_tp_new_4lxml_5etree_XMLSchema(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XMLSchema *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Validator(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XMLSchema *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree_XMLSchema;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XMLSchema(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_9XMLSchema___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  __pyx_tp_dealloc_4lxml_5etree__Validator(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XMLSchema[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_9XMLSchema___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_9XMLSchema___call__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XMLSchema = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XMLSchema = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XMLSchema = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XMLSchema = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XMLSchema = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XMLSchema", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XMLSchema), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XMLSchema, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XMLSchema, /*tp_as_number*/
  &__pyx_tp_as_sequence_XMLSchema, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XMLSchema, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_9XMLSchema___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XMLSchema, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XMLSchema(self, etree=None, file=None)\n    Turn a document into an XML Schema validator.\n\n    Either pass a schema as Element or ElementTree, or pass a file or\n    filename through the ``file`` keyword argument.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Validator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Validator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XMLSchema, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_9XMLSchema___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XMLSchema, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext __pyx_vtable_4lxml_5etree__ParserDictionaryContext;

static PyObject *__pyx_tp_new_4lxml_5etree__ParserDictionaryContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ParserDictionaryContext;
  p->_default_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  p->_implied_parser_contexts = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ParserDictionaryContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *p = (struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_24_ParserDictionaryContext___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_default_parser));
  Py_XDECREF(p->_implied_parser_contexts);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ParserDictionaryContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *p = (struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)o;
  if (p->_default_parser) {
    e = (*v)(((PyObject*)p->_default_parser), a); if (e) return e;
  }
  if (p->_implied_parser_contexts) {
    e = (*v)(p->_implied_parser_contexts, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ParserDictionaryContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *p = (struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_default_parser);
  p->_default_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_implied_parser_contexts);
  p->_implied_parser_contexts = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ParserDictionaryContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ParserDictionaryContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ParserDictionaryContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ParserDictionaryContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ParserDictionaryContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ParserDictionaryContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ParserDictionaryContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ParserDictionaryContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ParserDictionaryContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ParserDictionaryContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__ParserDictionaryContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ParserDictionaryContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ParserDictionaryContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ParserDictionaryContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ParserDictionaryContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ParserDictionaryContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_24_ParserDictionaryContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ParserDictionaryContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__FileReaderContext __pyx_vtable_4lxml_5etree__FileReaderContext;

static PyObject *__pyx_tp_new_4lxml_5etree__FileReaderContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__FileReaderContext *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__FileReaderContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__FileReaderContext;
  p->_filelike = Py_None; Py_INCREF(Py_None);
  p->_encoding = Py_None; Py_INCREF(Py_None);
  p->_url = Py_None; Py_INCREF(Py_None);
  p->_bytes = Py_None; Py_INCREF(Py_None);
  p->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__FileReaderContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__FileReaderContext *p = (struct __pyx_obj_4lxml_5etree__FileReaderContext *)o;
  Py_XDECREF(p->_filelike);
  Py_XDECREF(p->_encoding);
  Py_XDECREF(p->_url);
  Py_XDECREF(p->_bytes);
  Py_XDECREF(((PyObject *)p->_exc_context));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__FileReaderContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__FileReaderContext *p = (struct __pyx_obj_4lxml_5etree__FileReaderContext *)o;
  if (p->_filelike) {
    e = (*v)(p->_filelike, a); if (e) return e;
  }
  if (p->_encoding) {
    e = (*v)(p->_encoding, a); if (e) return e;
  }
  if (p->_url) {
    e = (*v)(p->_url, a); if (e) return e;
  }
  if (p->_bytes) {
    e = (*v)(p->_bytes, a); if (e) return e;
  }
  if (p->_exc_context) {
    e = (*v)(((PyObject*)p->_exc_context), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__FileReaderContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__FileReaderContext *p = (struct __pyx_obj_4lxml_5etree__FileReaderContext *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_filelike);
  p->_filelike = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_encoding);
  p->_encoding = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_url);
  p->_url = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_bytes);
  p->_bytes = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_exc_context);
  p->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__FileReaderContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__FileReaderContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__FileReaderContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__FileReaderContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__FileReaderContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__FileReaderContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._FileReaderContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__FileReaderContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__FileReaderContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__FileReaderContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__FileReaderContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__FileReaderContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__FileReaderContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__FileReaderContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__FileReaderContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__FileReaderContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_18_FileReaderContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__FileReaderContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__FeedParser __pyx_vtable_4lxml_5etree__FeedParser;

static PyObject *__pyx_tp_new_4lxml_5etree__FeedParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__FeedParser *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseParser(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__FeedParser *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseParser*)__pyx_vtabptr_4lxml_5etree__FeedParser;
  return o;
}

static PyObject *__pyx_getprop_4lxml_5etree_11_FeedParser_feed_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_11_FeedParser_14feed_error_log___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__FeedParser[] = {
  {"feed", (PyCFunction)__pyx_pf_4lxml_5etree_11_FeedParser_feed, METH_O, __pyx_doc_4lxml_5etree_11_FeedParser_feed},
  {"close", (PyCFunction)__pyx_pf_4lxml_5etree_11_FeedParser_close, METH_NOARGS, __pyx_doc_4lxml_5etree_11_FeedParser_close},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__FeedParser[] = {
  {"feed_error_log", __pyx_getprop_4lxml_5etree_11_FeedParser_feed_error_log, 0, __pyx_k_29, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__FeedParser = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__FeedParser = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__FeedParser = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__FeedParser = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__FeedParser = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._FeedParser", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__FeedParser), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseParser, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__FeedParser, /*tp_as_number*/
  &__pyx_tp_as_sequence__FeedParser, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__FeedParser, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__FeedParser, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseParser, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseParser, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__FeedParser, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__FeedParser, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__FeedParser, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XMLParser __pyx_vtable_4lxml_5etree_XMLParser;

static PyObject *__pyx_tp_new_4lxml_5etree_XMLParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XMLParser *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseParser(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XMLParser *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseParser*)__pyx_vtabptr_4lxml_5etree_XMLParser;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XMLParser[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XMLParser = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XMLParser = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XMLParser = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XMLParser = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XMLParser = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XMLParser", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XMLParser), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseParser, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XMLParser, /*tp_as_number*/
  &__pyx_tp_as_sequence_XMLParser, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XMLParser, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XMLParser, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XMLParser(self, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, remove_blank_text=False, compact=True, resolve_entities=True, remove_comments=False, remove_pis=False, target=None, encoding=None, schema=None)\n    The XML parser.\n\n    Parsers can be supplied as additional argument to various parse\n    functions of the lxml API.  A default parser is always available\n    and can be replaced by a call to the global function\n    'set_default_parser'.  New parsers can be created at any time\n    without a major run-time overhead.\n\n    The keyword arguments in the constructor are mainly based on the libxml2\n    parser configuration.  A DTD will also be loaded if validation or\n    attribute default values are requested.\n\n    Available boolean keyword arguments:\n\n    - attribute_defaults - read default attributes from DTD\n    - dtd_validation     - validate (if DTD is available)\n    - load_dtd           - use DTD for parsing\n    - no_network         - prevent network access for related files (default: True)\n    - ns_clean           - clean up redundant namespace declarations\n    - recover            - try hard to parse through broken XML\n    - remove_blank_text  - discard blank text nodes\n    - remove_comments    - discard comments\n    - remove_pis         - discard processing instructions\n    - strip_cdata        - replace CDATA sections by normal text content (default: True)\n    - compact            - safe memory for short text content (default: True)\n    - resolve_entities   - replace entities by their text value (default: True)\n\n    Other keyword arguments:\n\n    - encoding - override the document encoding\n    - target   - a parser target object that will receive the parse events\n    - schema   - an XMLSchema to validate against\n\n    Note that you should avoid sharing parsers between threads.  While this is\n    not harmful, it is more efficient to use separate parsers.  This does not\n    apply to the default parser.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseParser, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseParser, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XMLParser, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_9XMLParser___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XMLParser, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_ETCompatXMLParser __pyx_vtable_4lxml_5etree_ETCompatXMLParser;

static PyObject *__pyx_tp_new_4lxml_5etree_ETCompatXMLParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ETCompatXMLParser *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseParser(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ETCompatXMLParser *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseParser*)__pyx_vtabptr_4lxml_5etree_ETCompatXMLParser;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ETCompatXMLParser[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ETCompatXMLParser = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ETCompatXMLParser = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ETCompatXMLParser = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ETCompatXMLParser = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ETCompatXMLParser = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ETCompatXMLParser", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ETCompatXMLParser), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseParser, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ETCompatXMLParser, /*tp_as_number*/
  &__pyx_tp_as_sequence_ETCompatXMLParser, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ETCompatXMLParser, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ETCompatXMLParser, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ETCompatXMLParser(self, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, ns_clean=False, recover=False, remove_blank_text=False, compact=True, resolve_entities=True, remove_comments=True, remove_pis=True, target=None, encoding=None, schema=None)\n    An XML parser with an ElementTree compatible default setup.\n\n    See the XMLParser class for details.\n\n    This parser has ``remove_comments`` and ``remove_pis`` enabled by default\n    and thus ignores comments and processing instructions.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseParser, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseParser, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ETCompatXMLParser, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_17ETCompatXMLParser___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ETCompatXMLParser, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_HTMLParser __pyx_vtable_4lxml_5etree_HTMLParser;

static PyObject *__pyx_tp_new_4lxml_5etree_HTMLParser(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_HTMLParser *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseParser(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_HTMLParser *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseParser*)__pyx_vtabptr_4lxml_5etree_HTMLParser;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_HTMLParser[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_HTMLParser = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_HTMLParser = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_HTMLParser = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_HTMLParser = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_HTMLParser = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.HTMLParser", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_HTMLParser), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseParser, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_HTMLParser, /*tp_as_number*/
  &__pyx_tp_as_sequence_HTMLParser, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_HTMLParser, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_HTMLParser, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "HTMLParser(self, recover=True, no_network=True, remove_blank_text=False, compact=True, remove_comments=False, remove_pis=False, target=None, encoding=None, schema=None)\n    The HTML parser.\n\n    This parser allows reading HTML into a normal XML tree.  By\n    default, it can read broken (non well-formed) HTML, depending on\n    the capabilities of libxml2.  Use the 'recover' option to switch\n    this off.\n\n    Available boolean keyword arguments:\n\n    - recover            - try hard to parse through broken HTML (default: True)\n    - no_network         - prevent network access for related files (default: True)\n    - remove_blank_text  - discard empty text nodes\n    - remove_comments    - discard comments\n    - remove_pis         - discard processing instructions\n    - strip_cdata        - replace CDATA sections by normal text content (default: True)\n    - compact            - safe memory for short text content (default: True)\n\n    Other keyword arguments:\n\n    - encoding - override the document encoding\n    - target   - a parser target object that will receive the parse events\n    - schema   - an XMLSchema to validate against\n\n    Note that you should avoid sharing parsers between threads for performance\n    reasons.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseParser, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseParser, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_HTMLParser, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_10HTMLParser___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_HTMLParser, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget __pyx_vtable_4lxml_5etree__SaxParserTarget;

static PyObject *__pyx_tp_new_4lxml_5etree__SaxParserTarget(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__SaxParserTarget *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__SaxParserTarget *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__SaxParserTarget;
  if (__pyx_pf_4lxml_5etree_16_SaxParserTarget___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__SaxParserTarget(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__SaxParserTarget[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SaxParserTarget = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__SaxParserTarget = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__SaxParserTarget = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SaxParserTarget = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__SaxParserTarget = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._SaxParserTarget", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__SaxParserTarget), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__SaxParserTarget, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SaxParserTarget, /*tp_as_number*/
  &__pyx_tp_as_sequence__SaxParserTarget, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SaxParserTarget, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SaxParserTarget, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__SaxParserTarget, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__SaxParserTarget, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_TreeBuilder __pyx_vtable_4lxml_5etree_TreeBuilder;

static PyObject *__pyx_tp_new_4lxml_5etree_TreeBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_TreeBuilder *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__SaxParserTarget(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_TreeBuilder *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget*)__pyx_vtabptr_4lxml_5etree_TreeBuilder;
  p->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  p->_factory = Py_None; Py_INCREF(Py_None);
  p->_data = Py_None; Py_INCREF(Py_None);
  p->_element_stack = Py_None; Py_INCREF(Py_None);
  p->_element_stack_pop = Py_None; Py_INCREF(Py_None);
  p->_last = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_TreeBuilder(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_TreeBuilder *p = (struct __pyx_obj_4lxml_5etree_TreeBuilder *)o;
  Py_XDECREF(((PyObject *)p->_parser));
  Py_XDECREF(p->_factory);
  Py_XDECREF(p->_data);
  Py_XDECREF(p->_element_stack);
  Py_XDECREF(p->_element_stack_pop);
  Py_XDECREF(((PyObject *)p->_last));
  __pyx_tp_dealloc_4lxml_5etree__SaxParserTarget(o);
}

static int __pyx_tp_traverse_4lxml_5etree_TreeBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_TreeBuilder *p = (struct __pyx_obj_4lxml_5etree_TreeBuilder *)o;
  if (__pyx_ptype_4lxml_5etree__SaxParserTarget->tp_traverse) {
    e = __pyx_ptype_4lxml_5etree__SaxParserTarget->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->_parser) {
    e = (*v)(((PyObject*)p->_parser), a); if (e) return e;
  }
  if (p->_factory) {
    e = (*v)(p->_factory, a); if (e) return e;
  }
  if (p->_data) {
    e = (*v)(p->_data, a); if (e) return e;
  }
  if (p->_element_stack) {
    e = (*v)(p->_element_stack, a); if (e) return e;
  }
  if (p->_element_stack_pop) {
    e = (*v)(p->_element_stack_pop, a); if (e) return e;
  }
  if (p->_last) {
    e = (*v)(((PyObject*)p->_last), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_TreeBuilder(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_TreeBuilder *p = (struct __pyx_obj_4lxml_5etree_TreeBuilder *)o;
  PyObject* tmp;
  if (__pyx_ptype_4lxml_5etree__SaxParserTarget->tp_clear) {
    __pyx_ptype_4lxml_5etree__SaxParserTarget->tp_clear(o);
  }
  tmp = ((PyObject*)p->_parser);
  p->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_factory);
  p->_factory = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_data);
  p->_data = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_element_stack);
  p->_element_stack = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_element_stack_pop);
  p->_element_stack_pop = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_last);
  p->_last = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_TreeBuilder[] = {
  {"close", (PyCFunction)__pyx_pf_4lxml_5etree_11TreeBuilder_close, METH_NOARGS, __pyx_doc_4lxml_5etree_11TreeBuilder_close},
  {"data", (PyCFunction)__pyx_pf_4lxml_5etree_11TreeBuilder_data, METH_O, __pyx_doc_4lxml_5etree_11TreeBuilder_data},
  {"start", (PyCFunction)__pyx_pf_4lxml_5etree_11TreeBuilder_start, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_11TreeBuilder_start},
  {"end", (PyCFunction)__pyx_pf_4lxml_5etree_11TreeBuilder_end, METH_O, __pyx_doc_4lxml_5etree_11TreeBuilder_end},
  {"pi", (PyCFunction)__pyx_pf_4lxml_5etree_11TreeBuilder_pi, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_11TreeBuilder_pi},
  {"comment", (PyCFunction)__pyx_pf_4lxml_5etree_11TreeBuilder_comment, METH_O, __pyx_doc_4lxml_5etree_11TreeBuilder_comment},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_TreeBuilder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_TreeBuilder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_TreeBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_TreeBuilder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_TreeBuilder = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.TreeBuilder", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_TreeBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_TreeBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_TreeBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_TreeBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_TreeBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_TreeBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "TreeBuilder(self, element_factory=None, parser=None)\n    Parser target that builds a tree.\n\n    The final tree is returned by the ``close()`` method.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_TreeBuilder, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_TreeBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_TreeBuilder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_11TreeBuilder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_TreeBuilder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__PythonSaxParserTarget __pyx_vtable_4lxml_5etree__PythonSaxParserTarget;

static PyObject *__pyx_tp_new_4lxml_5etree__PythonSaxParserTarget(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__SaxParserTarget(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__SaxParserTarget*)__pyx_vtabptr_4lxml_5etree__PythonSaxParserTarget;
  p->_target_start = Py_None; Py_INCREF(Py_None);
  p->_target_end = Py_None; Py_INCREF(Py_None);
  p->_target_data = Py_None; Py_INCREF(Py_None);
  p->_target_doctype = Py_None; Py_INCREF(Py_None);
  p->_target_pi = Py_None; Py_INCREF(Py_None);
  p->_target_comment = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__PythonSaxParserTarget(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *p = (struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)o;
  Py_XDECREF(p->_target_start);
  Py_XDECREF(p->_target_end);
  Py_XDECREF(p->_target_data);
  Py_XDECREF(p->_target_doctype);
  Py_XDECREF(p->_target_pi);
  Py_XDECREF(p->_target_comment);
  __pyx_tp_dealloc_4lxml_5etree__SaxParserTarget(o);
}

static int __pyx_tp_traverse_4lxml_5etree__PythonSaxParserTarget(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *p = (struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)o;
  if (__pyx_ptype_4lxml_5etree__SaxParserTarget->tp_traverse) {
    e = __pyx_ptype_4lxml_5etree__SaxParserTarget->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->_target_start) {
    e = (*v)(p->_target_start, a); if (e) return e;
  }
  if (p->_target_end) {
    e = (*v)(p->_target_end, a); if (e) return e;
  }
  if (p->_target_data) {
    e = (*v)(p->_target_data, a); if (e) return e;
  }
  if (p->_target_doctype) {
    e = (*v)(p->_target_doctype, a); if (e) return e;
  }
  if (p->_target_pi) {
    e = (*v)(p->_target_pi, a); if (e) return e;
  }
  if (p->_target_comment) {
    e = (*v)(p->_target_comment, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__PythonSaxParserTarget(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *p = (struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget *)o;
  PyObject* tmp;
  if (__pyx_ptype_4lxml_5etree__SaxParserTarget->tp_clear) {
    __pyx_ptype_4lxml_5etree__SaxParserTarget->tp_clear(o);
  }
  tmp = ((PyObject*)p->_target_start);
  p->_target_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_target_end);
  p->_target_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_target_data);
  p->_target_data = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_target_doctype);
  p->_target_doctype = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_target_pi);
  p->_target_pi = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_target_comment);
  p->_target_comment = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__PythonSaxParserTarget[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__PythonSaxParserTarget = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__PythonSaxParserTarget = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__PythonSaxParserTarget = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__PythonSaxParserTarget = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__PythonSaxParserTarget = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._PythonSaxParserTarget", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__PythonSaxParserTarget), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__PythonSaxParserTarget, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__PythonSaxParserTarget, /*tp_as_number*/
  &__pyx_tp_as_sequence__PythonSaxParserTarget, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__PythonSaxParserTarget, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__PythonSaxParserTarget, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__PythonSaxParserTarget, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__PythonSaxParserTarget, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__PythonSaxParserTarget, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_22_PythonSaxParserTarget___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__PythonSaxParserTarget, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__FilelikeWriter __pyx_vtable_4lxml_5etree__FilelikeWriter;

static PyObject *__pyx_tp_new_4lxml_5etree__FilelikeWriter(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__FilelikeWriter *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__FilelikeWriter *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__FilelikeWriter;
  p->_filelike = Py_None; Py_INCREF(Py_None);
  p->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  p->error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__FilelikeWriter(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__FilelikeWriter *p = (struct __pyx_obj_4lxml_5etree__FilelikeWriter *)o;
  Py_XDECREF(p->_filelike);
  Py_XDECREF(((PyObject *)p->_exc_context));
  Py_XDECREF(((PyObject *)p->error_log));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__FilelikeWriter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__FilelikeWriter *p = (struct __pyx_obj_4lxml_5etree__FilelikeWriter *)o;
  if (p->_filelike) {
    e = (*v)(p->_filelike, a); if (e) return e;
  }
  if (p->_exc_context) {
    e = (*v)(((PyObject*)p->_exc_context), a); if (e) return e;
  }
  if (p->error_log) {
    e = (*v)(((PyObject*)p->error_log), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__FilelikeWriter(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__FilelikeWriter *p = (struct __pyx_obj_4lxml_5etree__FilelikeWriter *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_filelike);
  p->_filelike = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_exc_context);
  p->_exc_context = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->error_log);
  p->error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__FilelikeWriter[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__FilelikeWriter = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__FilelikeWriter = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__FilelikeWriter = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__FilelikeWriter = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__FilelikeWriter = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._FilelikeWriter", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__FilelikeWriter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__FilelikeWriter, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__FilelikeWriter, /*tp_as_number*/
  &__pyx_tp_as_sequence__FilelikeWriter, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__FilelikeWriter, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__FilelikeWriter, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__FilelikeWriter, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__FilelikeWriter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__FilelikeWriter, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_15_FilelikeWriter___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__FilelikeWriter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__IterparseContext __pyx_vtable_4lxml_5etree__IterparseContext;

static PyObject *__pyx_tp_new_4lxml_5etree__IterparseContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__IterparseContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ParserContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__IterparseContext *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext*)__pyx_vtabptr_4lxml_5etree__IterparseContext;
  p->_root = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  p->_events = Py_None; Py_INCREF(Py_None);
  p->_ns_stack = Py_None; Py_INCREF(Py_None);
  p->_pop_ns = Py_None; Py_INCREF(Py_None);
  p->_node_stack = Py_None; Py_INCREF(Py_None);
  p->_pop_node = Py_None; Py_INCREF(Py_None);
  p->_tag_tuple = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__IterparseContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__IterparseContext *p = (struct __pyx_obj_4lxml_5etree__IterparseContext *)o;
  Py_XDECREF(((PyObject *)p->_root));
  Py_XDECREF(((PyObject *)p->_doc));
  Py_XDECREF(p->_events);
  Py_XDECREF(p->_ns_stack);
  Py_XDECREF(p->_pop_ns);
  Py_XDECREF(p->_node_stack);
  Py_XDECREF(p->_pop_node);
  Py_XDECREF(p->_tag_tuple);
  __pyx_tp_dealloc_4lxml_5etree__ParserContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__IterparseContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__IterparseContext *p = (struct __pyx_obj_4lxml_5etree__IterparseContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ParserContext(o, v, a); if (e) return e;
  if (p->_root) {
    e = (*v)(((PyObject*)p->_root), a); if (e) return e;
  }
  if (p->_doc) {
    e = (*v)(((PyObject*)p->_doc), a); if (e) return e;
  }
  if (p->_events) {
    e = (*v)(p->_events, a); if (e) return e;
  }
  if (p->_ns_stack) {
    e = (*v)(p->_ns_stack, a); if (e) return e;
  }
  if (p->_pop_ns) {
    e = (*v)(p->_pop_ns, a); if (e) return e;
  }
  if (p->_node_stack) {
    e = (*v)(p->_node_stack, a); if (e) return e;
  }
  if (p->_pop_node) {
    e = (*v)(p->_pop_node, a); if (e) return e;
  }
  if (p->_tag_tuple) {
    e = (*v)(p->_tag_tuple, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__IterparseContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__IterparseContext *p = (struct __pyx_obj_4lxml_5etree__IterparseContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ParserContext(o);
  tmp = ((PyObject*)p->_root);
  p->_root = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_doc);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_events);
  p->_events = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_ns_stack);
  p->_ns_stack = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pop_ns);
  p->_pop_ns = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_node_stack);
  p->_node_stack = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pop_node);
  p->_pop_node = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_tag_tuple);
  p->_tag_tuple = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__IterparseContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__IterparseContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__IterparseContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__IterparseContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__IterparseContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__IterparseContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._IterparseContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__IterparseContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__IterparseContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__IterparseContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__IterparseContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__IterparseContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__IterparseContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__IterparseContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__IterparseContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__IterparseContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_17_IterparseContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__IterparseContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_iterparse __pyx_vtable_4lxml_5etree_iterparse;

static PyObject *__pyx_tp_new_4lxml_5etree_iterparse(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_iterparse *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseParser(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_iterparse *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseParser*)__pyx_vtabptr_4lxml_5etree_iterparse;
  p->_tag = Py_None; Py_INCREF(Py_None);
  p->_events = Py_None; Py_INCREF(Py_None);
  p->root = Py_None; Py_INCREF(Py_None);
  p->_source = Py_None; Py_INCREF(Py_None);
  p->_buffer = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_iterparse(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_iterparse *p = (struct __pyx_obj_4lxml_5etree_iterparse *)o;
  Py_XDECREF(p->_tag);
  Py_XDECREF(p->_events);
  Py_XDECREF(p->root);
  Py_XDECREF(p->_source);
  Py_XDECREF(p->_buffer);
  __pyx_tp_dealloc_4lxml_5etree__BaseParser(o);
}

static int __pyx_tp_traverse_4lxml_5etree_iterparse(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_iterparse *p = (struct __pyx_obj_4lxml_5etree_iterparse *)o;
  e = __pyx_tp_traverse_4lxml_5etree__BaseParser(o, v, a); if (e) return e;
  if (p->_tag) {
    e = (*v)(p->_tag, a); if (e) return e;
  }
  if (p->_events) {
    e = (*v)(p->_events, a); if (e) return e;
  }
  if (p->root) {
    e = (*v)(p->root, a); if (e) return e;
  }
  if (p->_source) {
    e = (*v)(p->_source, a); if (e) return e;
  }
  if (p->_buffer) {
    e = (*v)(p->_buffer, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_iterparse(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_iterparse *p = (struct __pyx_obj_4lxml_5etree_iterparse *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__BaseParser(o);
  tmp = ((PyObject*)p->_tag);
  p->_tag = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_events);
  p->_events = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->root);
  p->root = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_source);
  p->_source = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_buffer);
  p->_buffer = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_9iterparse_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_9iterparse_9error_log___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_iterparse[] = {
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_9iterparse_copy, METH_NOARGS, 0},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_9iterparse___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__next__", (PyCFunction)__pyx_pf_4lxml_5etree_9iterparse___next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree_iterparse[] = {
  {"root", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_iterparse, root), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree_iterparse[] = {
  {"error_log", __pyx_getprop_4lxml_5etree_9iterparse_error_log, 0, __pyx_k_30, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_iterparse = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_iterparse = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_iterparse = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_iterparse = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_iterparse = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.iterparse", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_iterparse), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_iterparse, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_iterparse, /*tp_as_number*/
  &__pyx_tp_as_sequence_iterparse, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_iterparse, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_iterparse, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "iterparse(self, source, events=(\"end\",), tag=None, attribute_defaults=False, dtd_validation=False, load_dtd=False, no_network=True, remove_blank_text=False, remove_comments=False, remove_pis=False, encoding=None, html=False, schema=None)\n\nIncremental parser.\n\nParses XML into a tree and generates tuples (event, element) in a\nSAX-like fashion. ``event`` is any of 'start', 'end', 'start-ns',\n'end-ns'.\n\nFor 'start' and 'end', ``element`` is the Element that the parser just\nfound opening or closing.  For 'start-ns', it is a tuple (prefix, URI) of\na new namespace declaration.  For 'end-ns', it is simply None.  Note that\nall start and end events are guaranteed to be properly nested.\n\nThe keyword argument ``events`` specifies a sequence of event type names\nthat should be generated.  By default, only 'end' events will be\ngenerated.\n\nThe additional ``tag`` argument restricts the 'start' and 'end' events to\nthose elements that match the given tag.  By default, events are generated\nfor all elements.  Note that the 'start-ns' and 'end-ns' events are not\nimpacted by this restriction.\n\nThe other keyword arguments in the constructor are mainly based on the\nlibxml2 parser configuration.  A DTD will also be loaded if validation or\nattribute default values are requested.\n\nAvailable boolean keyword arguments:\n - attribute_defaults: read default attributes from DTD\n - dtd_validation: validate (if DTD is available)\n - load_dtd: use DTD for parsing\n - no_network: prevent network access for related files\n - remove_blank_text: discard blank text nodes\n - remove_comments: discard comments\n - remove_pis: discard processing instructions\n - strip_cdata: replace CDATA sections by normal text content (default: True)\n - compact: safe memory for short text content (default: True)\n - resolve_entities: replace entities by their text value (default: True)\n\nOther keyword arguments:\n - encoding: override the document encoding\n - schema: an XMLSchema to validate against\n", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_iterparse, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_iterparse, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_9iterparse___iter__, /*tp_iter*/
  __pyx_pf_4lxml_5etree_9iterparse___next__, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_iterparse, /*tp_methods*/
  __pyx_members_4lxml_5etree_iterparse, /*tp_members*/
  __pyx_getsets_4lxml_5etree_iterparse, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_9iterparse___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_iterparse, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_iterwalk __pyx_vtable_4lxml_5etree_iterwalk;

static PyObject *__pyx_tp_new_4lxml_5etree_iterwalk(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_iterwalk *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_iterwalk *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree_iterwalk;
  p->_node_stack = Py_None; Py_INCREF(Py_None);
  p->_pop_node = Py_None; Py_INCREF(Py_None);
  p->_events = Py_None; Py_INCREF(Py_None);
  p->_pop_event = Py_None; Py_INCREF(Py_None);
  p->_tag_tuple = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_iterwalk(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_iterwalk *p = (struct __pyx_obj_4lxml_5etree_iterwalk *)o;
  Py_XDECREF(p->_node_stack);
  Py_XDECREF(p->_pop_node);
  Py_XDECREF(p->_events);
  Py_XDECREF(p->_pop_event);
  Py_XDECREF(p->_tag_tuple);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_iterwalk(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_iterwalk *p = (struct __pyx_obj_4lxml_5etree_iterwalk *)o;
  if (p->_node_stack) {
    e = (*v)(p->_node_stack, a); if (e) return e;
  }
  if (p->_pop_node) {
    e = (*v)(p->_pop_node, a); if (e) return e;
  }
  if (p->_events) {
    e = (*v)(p->_events, a); if (e) return e;
  }
  if (p->_pop_event) {
    e = (*v)(p->_pop_event, a); if (e) return e;
  }
  if (p->_tag_tuple) {
    e = (*v)(p->_tag_tuple, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_iterwalk(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_iterwalk *p = (struct __pyx_obj_4lxml_5etree_iterwalk *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_node_stack);
  p->_node_stack = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pop_node);
  p->_pop_node = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_events);
  p->_events = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pop_event);
  p->_pop_event = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_tag_tuple);
  p->_tag_tuple = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_iterwalk[] = {
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_8iterwalk___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"__next__", (PyCFunction)__pyx_pf_4lxml_5etree_8iterwalk___next__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_iterwalk = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_iterwalk = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_iterwalk = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_iterwalk = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_iterwalk = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.iterwalk", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_iterwalk), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_iterwalk, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_iterwalk, /*tp_as_number*/
  &__pyx_tp_as_sequence_iterwalk, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_iterwalk, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_iterwalk, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "iterwalk(self, element_or_tree, events=(\"end\",), tag=None)\n\n    A tree walker that generates events from an existing tree as if it\n    was parsing XML data with ``iterparse()``.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_iterwalk, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_iterwalk, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_8iterwalk___iter__, /*tp_iter*/
  __pyx_pf_4lxml_5etree_8iterwalk___next__, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_iterwalk, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_8iterwalk___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_iterwalk, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__IDDict __pyx_vtable_4lxml_5etree__IDDict;

static PyObject *__pyx_tp_new_4lxml_5etree__IDDict(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__IDDict *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__IDDict *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__IDDict;
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  p->_keys = Py_None; Py_INCREF(Py_None);
  p->_items = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__IDDict(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__IDDict *p = (struct __pyx_obj_4lxml_5etree__IDDict *)o;
  Py_XDECREF(((PyObject *)p->_doc));
  Py_XDECREF(p->_keys);
  Py_XDECREF(p->_items);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__IDDict(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__IDDict *p = (struct __pyx_obj_4lxml_5etree__IDDict *)o;
  if (p->_doc) {
    e = (*v)(((PyObject*)p->_doc), a); if (e) return e;
  }
  if (p->_keys) {
    e = (*v)(p->_keys, a); if (e) return e;
  }
  if (p->_items) {
    e = (*v)(p->_items, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__IDDict(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__IDDict *p = (struct __pyx_obj_4lxml_5etree__IDDict *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_doc);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_keys);
  p->_keys = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_items);
  p->_items = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_4lxml_5etree__IDDict(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__IDDict[] = {
  {"copy", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_copy, METH_NOARGS, 0},
  {"__getitem__", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict___getitem__, METH_O|METH_COEXIST, 0},
  {"get", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_get, METH_O, 0},
  {"has_key", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_has_key, METH_O, 0},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict___repr__, METH_NOARGS|METH_COEXIST, 0},
  {"keys", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_keys, METH_NOARGS, 0},
  {"__iter__", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict___iter__, METH_NOARGS|METH_COEXIST, 0},
  {"iterkeys", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_iterkeys, METH_NOARGS, 0},
  {"items", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_items, METH_NOARGS, 0},
  {"iteritems", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_iteritems, METH_NOARGS, 0},
  {"values", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_values, METH_NOARGS, 0},
  {"itervalues", (PyCFunction)__pyx_pf_4lxml_5etree_7_IDDict_itervalues, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__IDDict = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__IDDict = {
  __pyx_pf_4lxml_5etree_7_IDDict___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_4lxml_5etree__IDDict, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pf_4lxml_5etree_7_IDDict___contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__IDDict = {
  __pyx_pf_4lxml_5etree_7_IDDict___len__, /*mp_length*/
  __pyx_pf_4lxml_5etree_7_IDDict___getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__IDDict = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__IDDict = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._IDDict", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__IDDict), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__IDDict, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  __pyx_pf_4lxml_5etree_7_IDDict___cmp__, /*tp_compare*/
  __pyx_pf_4lxml_5etree_7_IDDict___repr__, /*tp_repr*/
  &__pyx_tp_as_number__IDDict, /*tp_as_number*/
  &__pyx_tp_as_sequence__IDDict, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__IDDict, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__IDDict, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "IDDict(self, etree)\n    A dictionary-like proxy class that mapps ID attributes to elements.\n\n    The dictionary must be instantiated with the root element of a parsed XML\n    document, otherwise the behaviour is undefined.  Elements and XML trees\n    that were created or modified 'by hand' are not supported.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__IDDict, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__IDDict, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_4lxml_5etree_7_IDDict___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__IDDict, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_7_IDDict___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__IDDict, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_XInclude(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XInclude *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XInclude *)o);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XInclude(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XInclude *p = (struct __pyx_obj_4lxml_5etree_XInclude *)o;
  Py_XDECREF(((PyObject *)p->_error_log));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_XInclude(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_XInclude *p = (struct __pyx_obj_4lxml_5etree_XInclude *)o;
  if (p->_error_log) {
    e = (*v)(((PyObject*)p->_error_log), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_XInclude(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XInclude *p = (struct __pyx_obj_4lxml_5etree_XInclude *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_error_log);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_8XInclude_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_8XInclude_9error_log___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XInclude[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_8XInclude___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_8XInclude___call__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree_XInclude[] = {
  {"error_log", __pyx_getprop_4lxml_5etree_8XInclude_error_log, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XInclude = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XInclude = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XInclude = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XInclude = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XInclude = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XInclude", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XInclude), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XInclude, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XInclude, /*tp_as_number*/
  &__pyx_tp_as_sequence_XInclude, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XInclude, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_8XInclude___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XInclude, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XInclude(self)\n    XInclude processor.\n\n    Create an instance and call it on an Element to run XInclude\n    processing.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_XInclude, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_XInclude, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XInclude, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree_XInclude, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_8XInclude___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XInclude, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__ExsltRegExp __pyx_vtable_4lxml_5etree__ExsltRegExp;

static PyObject *__pyx_tp_new_4lxml_5etree__ExsltRegExp(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ExsltRegExp *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ExsltRegExp *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__ExsltRegExp;
  p->_compile_map = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ExsltRegExp(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ExsltRegExp *p = (struct __pyx_obj_4lxml_5etree__ExsltRegExp *)o;
  Py_XDECREF(p->_compile_map);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ExsltRegExp(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ExsltRegExp *p = (struct __pyx_obj_4lxml_5etree__ExsltRegExp *)o;
  if (p->_compile_map) {
    e = (*v)(p->_compile_map, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ExsltRegExp(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ExsltRegExp *p = (struct __pyx_obj_4lxml_5etree__ExsltRegExp *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_compile_map);
  p->_compile_map = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ExsltRegExp[] = {
  {"test", (PyCFunction)__pyx_pf_4lxml_5etree_12_ExsltRegExp_test, METH_VARARGS|METH_KEYWORDS, 0},
  {"match", (PyCFunction)__pyx_pf_4lxml_5etree_12_ExsltRegExp_match, METH_VARARGS|METH_KEYWORDS, 0},
  {"replace", (PyCFunction)__pyx_pf_4lxml_5etree_12_ExsltRegExp_replace, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ExsltRegExp = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ExsltRegExp = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ExsltRegExp = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ExsltRegExp = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ExsltRegExp = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ExsltRegExp", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ExsltRegExp), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ExsltRegExp, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ExsltRegExp, /*tp_as_number*/
  &__pyx_tp_as_sequence__ExsltRegExp, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ExsltRegExp, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ExsltRegExp, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ExsltRegExp, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ExsltRegExp, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ExsltRegExp, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_12_ExsltRegExp___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ExsltRegExp, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__BaseContext __pyx_vtable_4lxml_5etree__BaseContext;

static PyObject *__pyx_tp_new_4lxml_5etree__BaseContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__BaseContext *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__BaseContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__BaseContext;
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  p->_extensions = Py_None; Py_INCREF(Py_None);
  p->_namespaces = Py_None; Py_INCREF(Py_None);
  p->_global_namespaces = Py_None; Py_INCREF(Py_None);
  p->_utf_refs = Py_None; Py_INCREF(Py_None);
  p->_function_cache = Py_None; Py_INCREF(Py_None);
  p->_eval_context_dict = Py_None; Py_INCREF(Py_None);
  p->_temp_refs = ((struct __pyx_obj_4lxml_5etree__TempStore *)Py_None); Py_INCREF(Py_None);
  p->_exc = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__BaseContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__BaseContext *p = (struct __pyx_obj_4lxml_5etree__BaseContext *)o;
  Py_XDECREF(((PyObject *)p->_doc));
  Py_XDECREF(p->_extensions);
  Py_XDECREF(p->_namespaces);
  Py_XDECREF(p->_global_namespaces);
  Py_XDECREF(p->_utf_refs);
  Py_XDECREF(p->_function_cache);
  Py_XDECREF(p->_eval_context_dict);
  Py_XDECREF(((PyObject *)p->_temp_refs));
  Py_XDECREF(((PyObject *)p->_exc));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__BaseContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__BaseContext *p = (struct __pyx_obj_4lxml_5etree__BaseContext *)o;
  if (p->_doc) {
    e = (*v)(((PyObject*)p->_doc), a); if (e) return e;
  }
  if (p->_extensions) {
    e = (*v)(p->_extensions, a); if (e) return e;
  }
  if (p->_namespaces) {
    e = (*v)(p->_namespaces, a); if (e) return e;
  }
  if (p->_global_namespaces) {
    e = (*v)(p->_global_namespaces, a); if (e) return e;
  }
  if (p->_utf_refs) {
    e = (*v)(p->_utf_refs, a); if (e) return e;
  }
  if (p->_function_cache) {
    e = (*v)(p->_function_cache, a); if (e) return e;
  }
  if (p->_eval_context_dict) {
    e = (*v)(p->_eval_context_dict, a); if (e) return e;
  }
  if (p->_temp_refs) {
    e = (*v)(((PyObject*)p->_temp_refs), a); if (e) return e;
  }
  if (p->_exc) {
    e = (*v)(((PyObject*)p->_exc), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__BaseContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__BaseContext *p = (struct __pyx_obj_4lxml_5etree__BaseContext *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_doc);
  p->_doc = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_extensions);
  p->_extensions = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_namespaces);
  p->_namespaces = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_global_namespaces);
  p->_global_namespaces = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_utf_refs);
  p->_utf_refs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_function_cache);
  p->_function_cache = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_eval_context_dict);
  p->_eval_context_dict = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_temp_refs);
  p->_temp_refs = ((struct __pyx_obj_4lxml_5etree__TempStore *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_exc);
  p->_exc = ((struct __pyx_obj_4lxml_5etree__ExceptionContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_12_BaseContext_context_node(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_12_BaseContext_12context_node___get__(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_12_BaseContext_eval_context(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_12_BaseContext_12eval_context___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__BaseContext[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__BaseContext[] = {
  {"context_node", __pyx_getprop_4lxml_5etree_12_BaseContext_context_node, 0, 0, 0},
  {"eval_context", __pyx_getprop_4lxml_5etree_12_BaseContext_eval_context, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__BaseContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__BaseContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__BaseContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__BaseContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__BaseContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._BaseContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__BaseContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__BaseContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__BaseContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__BaseContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__BaseContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__BaseContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__BaseContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__BaseContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__BaseContext, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__BaseContext, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_12_BaseContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__BaseContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree__ElementUnicodeResult(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *p;
  PyObject *o = __pyx_ptype_4lxml_6python_unicode->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)o);
  p->_parent = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  p->is_tail = Py_None; Py_INCREF(Py_None);
  p->is_text = Py_None; Py_INCREF(Py_None);
  p->is_attribute = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__ElementUnicodeResult(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *p = (struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)o;
  Py_XDECREF(((PyObject *)p->_parent));
  Py_XDECREF(p->is_tail);
  Py_XDECREF(p->is_text);
  Py_XDECREF(p->is_attribute);
  __pyx_ptype_4lxml_6python_unicode->tp_dealloc(o);
}

static int __pyx_tp_traverse_4lxml_5etree__ElementUnicodeResult(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *p = (struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)o;
  if (__pyx_ptype_4lxml_6python_unicode->tp_traverse) {
    e = __pyx_ptype_4lxml_6python_unicode->tp_traverse(o, v, a); if (e) return e;
  }
  if (p->_parent) {
    e = (*v)(((PyObject*)p->_parent), a); if (e) return e;
  }
  if (p->is_tail) {
    e = (*v)(p->is_tail, a); if (e) return e;
  }
  if (p->is_text) {
    e = (*v)(p->is_text, a); if (e) return e;
  }
  if (p->is_attribute) {
    e = (*v)(p->is_attribute, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__ElementUnicodeResult(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *p = (struct __pyx_obj_4lxml_5etree__ElementUnicodeResult *)o;
  PyObject* tmp;
  if (__pyx_ptype_4lxml_6python_unicode->tp_clear) {
    __pyx_ptype_4lxml_6python_unicode->tp_clear(o);
  }
  tmp = ((PyObject*)p->_parent);
  p->_parent = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->is_tail);
  p->is_tail = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->is_text);
  p->is_text = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->is_attribute);
  p->is_attribute = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__ElementUnicodeResult[] = {
  {"getparent", (PyCFunction)__pyx_pf_4lxml_5etree_21_ElementUnicodeResult_getparent, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree__ElementUnicodeResult[] = {
  {"is_tail", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__ElementUnicodeResult, is_tail), READONLY, 0},
  {"is_text", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__ElementUnicodeResult, is_text), READONLY, 0},
  {"is_attribute", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree__ElementUnicodeResult, is_attribute), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ElementUnicodeResult = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__ElementUnicodeResult = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ElementUnicodeResult = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ElementUnicodeResult = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__ElementUnicodeResult = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._ElementUnicodeResult", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__ElementUnicodeResult), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__ElementUnicodeResult, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ElementUnicodeResult, /*tp_as_number*/
  &__pyx_tp_as_sequence__ElementUnicodeResult, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ElementUnicodeResult, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ElementUnicodeResult, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__ElementUnicodeResult, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__ElementUnicodeResult, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__ElementUnicodeResult, /*tp_methods*/
  __pyx_members_4lxml_5etree__ElementUnicodeResult, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__ElementUnicodeResult, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XPathContext __pyx_vtable_4lxml_5etree__XPathContext;

static PyObject *__pyx_tp_new_4lxml_5etree__XPathContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XPathContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XPathContext *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseContext*)__pyx_vtabptr_4lxml_5etree__XPathContext;
  p->_variables = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__XPathContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XPathContext *p = (struct __pyx_obj_4lxml_5etree__XPathContext *)o;
  Py_XDECREF(p->_variables);
  __pyx_tp_dealloc_4lxml_5etree__BaseContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__XPathContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__XPathContext *p = (struct __pyx_obj_4lxml_5etree__XPathContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__BaseContext(o, v, a); if (e) return e;
  if (p->_variables) {
    e = (*v)(p->_variables, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__XPathContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XPathContext *p = (struct __pyx_obj_4lxml_5etree__XPathContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__BaseContext(o);
  tmp = ((PyObject*)p->_variables);
  p->_variables = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XPathContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XPathContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XPathContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XPathContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XPathContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XPathContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XPathContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XPathContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__XPathContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XPathContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__XPathContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XPathContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XPathContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__XPathContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__XPathContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XPathContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_13_XPathContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XPathContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase __pyx_vtable_4lxml_5etree__XPathEvaluatorBase;

static PyObject *__pyx_tp_new_4lxml_5etree__XPathEvaluatorBase(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree__XPathEvaluatorBase;
  p->_context = ((struct __pyx_obj_4lxml_5etree__XPathContext *)Py_None); Py_INCREF(Py_None);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__XPathEvaluatorBase(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *p = (struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_context));
  Py_XDECREF(((PyObject *)p->_error_log));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree__XPathEvaluatorBase(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *p = (struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)o;
  if (p->_context) {
    e = (*v)(((PyObject*)p->_context), a); if (e) return e;
  }
  if (p->_error_log) {
    e = (*v)(((PyObject*)p->_error_log), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__XPathEvaluatorBase(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *p = (struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_context);
  p->_context = ((struct __pyx_obj_4lxml_5etree__XPathContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_error_log);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_19_XPathEvaluatorBase_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase_9error_log___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XPathEvaluatorBase[] = {
  {"evaluate", (PyCFunction)__pyx_pf_4lxml_5etree_19_XPathEvaluatorBase_evaluate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_19_XPathEvaluatorBase_evaluate},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__XPathEvaluatorBase[] = {
  {"error_log", __pyx_getprop_4lxml_5etree_19_XPathEvaluatorBase_error_log, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XPathEvaluatorBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XPathEvaluatorBase = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XPathEvaluatorBase = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XPathEvaluatorBase = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XPathEvaluatorBase = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XPathEvaluatorBase", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XPathEvaluatorBase), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__XPathEvaluatorBase, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XPathEvaluatorBase, /*tp_as_number*/
  &__pyx_tp_as_sequence__XPathEvaluatorBase, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XPathEvaluatorBase, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XPathEvaluatorBase, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__XPathEvaluatorBase, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__XPathEvaluatorBase, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XPathEvaluatorBase, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__XPathEvaluatorBase, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_19_XPathEvaluatorBase___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XPathEvaluatorBase, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XPathElementEvaluator __pyx_vtable_4lxml_5etree_XPathElementEvaluator;

static PyObject *__pyx_tp_new_4lxml_5etree_XPathElementEvaluator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__XPathEvaluatorBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase*)__pyx_vtabptr_4lxml_5etree_XPathElementEvaluator;
  p->_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XPathElementEvaluator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *p = (struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)o;
  Py_XDECREF(((PyObject *)p->_element));
  __pyx_tp_dealloc_4lxml_5etree__XPathEvaluatorBase(o);
}

static int __pyx_tp_traverse_4lxml_5etree_XPathElementEvaluator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *p = (struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)o;
  e = __pyx_tp_traverse_4lxml_5etree__XPathEvaluatorBase(o, v, a); if (e) return e;
  if (p->_element) {
    e = (*v)(((PyObject*)p->_element), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_XPathElementEvaluator(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *p = (struct __pyx_obj_4lxml_5etree_XPathElementEvaluator *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__XPathEvaluatorBase(o);
  tmp = ((PyObject*)p->_element);
  p->_element = ((struct LxmlElement *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XPathElementEvaluator[] = {
  {"register_namespace", (PyCFunction)__pyx_pf_4lxml_5etree_21XPathElementEvaluator_register_namespace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_21XPathElementEvaluator_register_namespace},
  {"register_namespaces", (PyCFunction)__pyx_pf_4lxml_5etree_21XPathElementEvaluator_register_namespaces, METH_O, __pyx_doc_4lxml_5etree_21XPathElementEvaluator_register_namespaces},
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_21XPathElementEvaluator___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_21XPathElementEvaluator___call__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XPathElementEvaluator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XPathElementEvaluator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XPathElementEvaluator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XPathElementEvaluator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XPathElementEvaluator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XPathElementEvaluator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XPathElementEvaluator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XPathElementEvaluator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XPathElementEvaluator, /*tp_as_number*/
  &__pyx_tp_as_sequence_XPathElementEvaluator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XPathElementEvaluator, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_21XPathElementEvaluator___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XPathElementEvaluator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XPathElementEvaluator(self, element, namespaces=None, extensions=None, regexp=True, smart_strings=True)\n    Create an XPath evaluator for an element.\n\n    Absolute XPath expressions (starting with '/') will be evaluated against\n    the ElementTree as returned by getroottree().\n\n    Additional namespace declarations can be passed with the\n    'namespace' keyword argument.  EXSLT regular expression support\n    can be disabled with the 'regexp' boolean keyword (defaults to\n    True).  Smart strings will be returned for string results unless\n    you pass ``smart_strings=False``.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_XPathElementEvaluator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_XPathElementEvaluator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XPathElementEvaluator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_21XPathElementEvaluator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XPathElementEvaluator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XPathDocumentEvaluator __pyx_vtable_4lxml_5etree_XPathDocumentEvaluator;

static PyObject *__pyx_tp_new_4lxml_5etree_XPathDocumentEvaluator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_XPathElementEvaluator(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase*)__pyx_vtabptr_4lxml_5etree_XPathDocumentEvaluator;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XPathDocumentEvaluator[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_22XPathDocumentEvaluator___call__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XPathDocumentEvaluator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XPathDocumentEvaluator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XPathDocumentEvaluator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XPathDocumentEvaluator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XPathDocumentEvaluator = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XPathDocumentEvaluator", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XPathDocumentEvaluator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XPathElementEvaluator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XPathDocumentEvaluator, /*tp_as_number*/
  &__pyx_tp_as_sequence_XPathDocumentEvaluator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XPathDocumentEvaluator, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XPathDocumentEvaluator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XPathDocumentEvaluator(self, etree, namespaces=None, extensions=None, regexp=True, smart_strings=True)\n    Create an XPath evaluator for an ElementTree.\n\n    Additional namespace declarations can be passed with the\n    'namespace' keyword argument.  EXSLT regular expression support\n    can be disabled with the 'regexp' boolean keyword (defaults to\n    True).  Smart strings will be returned for string results unless\n    you pass ``smart_strings=False``.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_XPathElementEvaluator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_XPathElementEvaluator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XPathDocumentEvaluator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_22XPathDocumentEvaluator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XPathDocumentEvaluator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XPath __pyx_vtable_4lxml_5etree_XPath;

static PyObject *__pyx_tp_new_4lxml_5etree_XPath(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XPath *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__XPathEvaluatorBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XPath *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase*)__pyx_vtabptr_4lxml_5etree_XPath;
  p->path = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XPath(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XPath *p = (struct __pyx_obj_4lxml_5etree_XPath *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_5XPath___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->path);
  __pyx_tp_dealloc_4lxml_5etree__XPathEvaluatorBase(o);
}

static int __pyx_tp_traverse_4lxml_5etree_XPath(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_XPath *p = (struct __pyx_obj_4lxml_5etree_XPath *)o;
  e = __pyx_tp_traverse_4lxml_5etree__XPathEvaluatorBase(o, v, a); if (e) return e;
  if (p->path) {
    e = (*v)(p->path, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_XPath(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XPath *p = (struct __pyx_obj_4lxml_5etree_XPath *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__XPathEvaluatorBase(o);
  tmp = ((PyObject*)p->path);
  p->path = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XPath[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_5XPath___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_5XPath___call__},
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_5XPath___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_4lxml_5etree_XPath[] = {
  {"path", T_OBJECT, offsetof(struct __pyx_obj_4lxml_5etree_XPath, path), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XPath = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XPath = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XPath = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XPath = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XPath = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XPath", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XPath), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XPath, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_5XPath___repr__, /*tp_repr*/
  &__pyx_tp_as_number_XPath, /*tp_as_number*/
  &__pyx_tp_as_sequence_XPath, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XPath, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_5XPath___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XPath, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XPath(self, path, namespaces=None, extensions=None, regexp=True, smart_strings=True)\n    A compiled XPath expression that can be called on Elements and ElementTrees.\n\n    Besides the XPath expression, you can pass prefix-namespace\n    mappings and extension functions to the constructor through the\n    keyword arguments ``namespaces`` and ``extensions``.  EXSLT\n    regular expression support can be disabled with the 'regexp'\n    boolean keyword (defaults to True).  Smart strings will be\n    returned for string results unless you pass\n    ``smart_strings=False``.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_XPath, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_XPath, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XPath, /*tp_methods*/
  __pyx_members_4lxml_5etree_XPath, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_5XPath___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XPath, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_ETXPath __pyx_vtable_4lxml_5etree_ETXPath;

static PyObject *__pyx_tp_new_4lxml_5etree_ETXPath(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_ETXPath *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree_XPath(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_ETXPath *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__XPathEvaluatorBase*)__pyx_vtabptr_4lxml_5etree_ETXPath;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_ETXPath[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ETXPath = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ETXPath = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ETXPath = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ETXPath = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_ETXPath = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.ETXPath", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_ETXPath), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XPath, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ETXPath, /*tp_as_number*/
  &__pyx_tp_as_sequence_ETXPath, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ETXPath, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ETXPath, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ETXPath(self, path, extensions=None, regexp=True)\n    Special XPath class that supports the ElementTree {uri} notation for namespaces.\n\n    Note that this class does not accept the ``namespace`` keyword\n    argument. All namespaces must be passed as part of the path\n    string.  Smart strings will be returned for string results unless\n    you pass ``smart_strings=False``.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_XPath, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_XPath, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_ETXPath, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_7ETXPath___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_ETXPath, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTResolverContext __pyx_vtable_4lxml_5etree__XSLTResolverContext;

static PyObject *__pyx_tp_new_4lxml_5etree__XSLTResolverContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ResolverContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ExceptionContext*)__pyx_vtabptr_4lxml_5etree__XSLTResolverContext;
  p->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__XSLTResolverContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *p = (struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)o;
  Py_XDECREF(((PyObject *)p->_parser));
  __pyx_tp_dealloc_4lxml_5etree__ResolverContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__XSLTResolverContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *p = (struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ResolverContext(o, v, a); if (e) return e;
  if (p->_parser) {
    e = (*v)(((PyObject*)p->_parser), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__XSLTResolverContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XSLTResolverContext *p = (struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ResolverContext(o);
  tmp = ((PyObject*)p->_parser);
  p->_parser = ((struct __pyx_obj_4lxml_5etree__BaseParser *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XSLTResolverContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XSLTResolverContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XSLTResolverContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XSLTResolverContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XSLTResolverContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XSLTResolverContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XSLTResolverContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XSLTResolverContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__XSLTResolverContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XSLTResolverContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__XSLTResolverContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XSLTResolverContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XSLTResolverContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__XSLTResolverContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__XSLTResolverContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XSLTResolverContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XSLTResolverContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XSLTAccessControl __pyx_vtable_4lxml_5etree_XSLTAccessControl;

static PyObject *__pyx_tp_new_4lxml_5etree_XSLTAccessControl(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XSLTAccessControl *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree_XSLTAccessControl;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XSLTAccessControl(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_17XSLTAccessControl___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_4lxml_5etree_17XSLTAccessControl_options(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_17XSLTAccessControl_7options___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XSLTAccessControl[] = {
  {"__repr__", (PyCFunction)__pyx_pf_4lxml_5etree_17XSLTAccessControl___repr__, METH_NOARGS|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree_XSLTAccessControl[] = {
  {"options", __pyx_getprop_4lxml_5etree_17XSLTAccessControl_options, 0, __pyx_k_31, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XSLTAccessControl = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XSLTAccessControl = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XSLTAccessControl = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XSLTAccessControl = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XSLTAccessControl = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XSLTAccessControl", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XSLTAccessControl), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XSLTAccessControl, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_pf_4lxml_5etree_17XSLTAccessControl___repr__, /*tp_repr*/
  &__pyx_tp_as_number_XSLTAccessControl, /*tp_as_number*/
  &__pyx_tp_as_sequence_XSLTAccessControl, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XSLTAccessControl, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XSLTAccessControl, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  "XSLTAccessControl(self, read_file=True, write_file=True, create_dir=True, read_network=True, write_network=True)\n\n    Access control for XSLT: reading/writing files, directories and\n    network I/O.  Access to a type of resource is granted or denied by\n    passing any of the following boolean keyword arguments.  All of\n    them default to True to allow access.\n\n    - read_file\n    - write_file\n    - create_dir\n    - read_network\n    - write_network\n\n    For convenience, there is also a class member `DENY_ALL` that\n    provides an XSLTAccessControl instance that is readily configured\n    to deny everything, and a `DENY_WRITE` member that denies all\n    write access but allows read access.\n\n    See `XSLT`.\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XSLTAccessControl, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree_XSLTAccessControl, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_17XSLTAccessControl___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XSLTAccessControl, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTContext __pyx_vtable_4lxml_5etree__XSLTContext;

static PyObject *__pyx_tp_new_4lxml_5etree__XSLTContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XSLTContext *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__BaseContext(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__BaseContext*)__pyx_vtabptr_4lxml_5etree__XSLTContext;
  p->_extension_elements = Py_None; Py_INCREF(Py_None);
  p->_extension_element_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__XSLTContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XSLTContext *p = (struct __pyx_obj_4lxml_5etree__XSLTContext *)o;
  Py_XDECREF(p->_extension_elements);
  Py_XDECREF(((PyObject *)p->_extension_element_proxy));
  __pyx_tp_dealloc_4lxml_5etree__BaseContext(o);
}

static int __pyx_tp_traverse_4lxml_5etree__XSLTContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__XSLTContext *p = (struct __pyx_obj_4lxml_5etree__XSLTContext *)o;
  e = __pyx_tp_traverse_4lxml_5etree__BaseContext(o, v, a); if (e) return e;
  if (p->_extension_elements) {
    e = (*v)(p->_extension_elements, a); if (e) return e;
  }
  if (p->_extension_element_proxy) {
    e = (*v)(((PyObject*)p->_extension_element_proxy), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__XSLTContext(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XSLTContext *p = (struct __pyx_obj_4lxml_5etree__XSLTContext *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__BaseContext(o);
  tmp = ((PyObject*)p->_extension_elements);
  p->_extension_elements = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_extension_element_proxy);
  p->_extension_element_proxy = ((struct __pyx_obj_4lxml_5etree__ReadOnlyElementProxy *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XSLTContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XSLTContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XSLTContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XSLTContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XSLTContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XSLTContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XSLTContext", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XSLTContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__XSLTContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XSLTContext, /*tp_as_number*/
  &__pyx_tp_as_sequence__XSLTContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XSLTContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XSLTContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__XSLTContext, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__XSLTContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XSLTContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_12_XSLTContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XSLTContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree_XSLT __pyx_vtable_4lxml_5etree_XSLT;

static PyObject *__pyx_tp_new_4lxml_5etree_XSLT(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree_XSLT *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree_XSLT *)o);
  p->__pyx_vtab = __pyx_vtabptr_4lxml_5etree_XSLT;
  p->_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)Py_None); Py_INCREF(Py_None);
  p->_xslt_resolver_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)Py_None); Py_INCREF(Py_None);
  p->_access_control = ((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)Py_None); Py_INCREF(Py_None);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XSLT(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XSLT *p = (struct __pyx_obj_4lxml_5etree_XSLT *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_4XSLT___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_context));
  Py_XDECREF(((PyObject *)p->_xslt_resolver_context));
  Py_XDECREF(((PyObject *)p->_access_control));
  Py_XDECREF(((PyObject *)p->_error_log));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4lxml_5etree_XSLT(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree_XSLT *p = (struct __pyx_obj_4lxml_5etree_XSLT *)o;
  if (p->_context) {
    e = (*v)(((PyObject*)p->_context), a); if (e) return e;
  }
  if (p->_xslt_resolver_context) {
    e = (*v)(((PyObject*)p->_xslt_resolver_context), a); if (e) return e;
  }
  if (p->_access_control) {
    e = (*v)(((PyObject*)p->_access_control), a); if (e) return e;
  }
  if (p->_error_log) {
    e = (*v)(((PyObject*)p->_error_log), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree_XSLT(PyObject *o) {
  struct __pyx_obj_4lxml_5etree_XSLT *p = (struct __pyx_obj_4lxml_5etree_XSLT *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_context);
  p->_context = ((struct __pyx_obj_4lxml_5etree__XSLTContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_xslt_resolver_context);
  p->_xslt_resolver_context = ((struct __pyx_obj_4lxml_5etree__XSLTResolverContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_access_control);
  p->_access_control = ((struct __pyx_obj_4lxml_5etree_XSLTAccessControl *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_error_log);
  p->_error_log = ((struct __pyx_obj_4lxml_5etree__ErrorLog *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_4XSLT_error_log(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_4XSLT_9error_log___get__(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XSLT[] = {
  {"apply", (PyCFunction)__pyx_pf_4lxml_5etree_4XSLT_apply, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_4XSLT_apply},
  {"tostring", (PyCFunction)__pyx_pf_4lxml_5etree_4XSLT_tostring, METH_O, __pyx_doc_4lxml_5etree_4XSLT_tostring},
  {"__deepcopy__", (PyCFunction)__pyx_pf_4lxml_5etree_4XSLT___deepcopy__, METH_O, 0},
  {"__copy__", (PyCFunction)__pyx_pf_4lxml_5etree_4XSLT___copy__, METH_NOARGS, 0},
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_4XSLT___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_4XSLT___call__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree_XSLT[] = {
  {"error_log", __pyx_getprop_4lxml_5etree_4XSLT_error_log, 0, __pyx_k_32, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XSLT = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XSLT = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XSLT = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XSLT = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XSLT = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XSLT", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XSLT), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XSLT, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XSLT, /*tp_as_number*/
  &__pyx_tp_as_sequence_XSLT, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XSLT, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_4XSLT___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XSLT, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "XSLT(self, xslt_input, extensions=None, regexp=True, access_control=None)\n\n    Turn an XSL document into an XSLT object.\n\n    Calling this object on a tree or Element will execute the XSLT::\n\n      >>> transform = etree.XSLT(xsl_tree)\n      >>> result = transform(xml_tree)\n\n    Keyword arguments of the constructor:\n\n    - extensions: a dict mapping ``(namespace, name)`` pairs to\n      extension functions or extension elements\n    - regexp: enable exslt regular expression support in XPath\n      (default: True)\n    - access_control: access restrictions for network or file\n      system (see `XSLTAccessControl`)\n\n    Keyword arguments of the XSLT call:\n\n    - profile_run: enable XSLT profiling (default: False)\n\n    Other keyword arguments of the call are passed to the stylesheet\n    as parameters.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree_XSLT, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree_XSLT, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XSLT, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree_XSLT, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_4XSLT___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XSLT, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTResultTree __pyx_vtable_4lxml_5etree__XSLTResultTree;

static PyObject *__pyx_tp_new_4lxml_5etree__XSLTResultTree(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XSLTResultTree *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__ElementTree(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XSLTResultTree *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree__ElementTree*)__pyx_vtabptr_4lxml_5etree__XSLTResultTree;
  p->_xslt = ((struct __pyx_obj_4lxml_5etree_XSLT *)Py_None); Py_INCREF(Py_None);
  p->_profile = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree__XSLTResultTree(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XSLTResultTree *p = (struct __pyx_obj_4lxml_5etree__XSLTResultTree *)o;
  Py_XDECREF(((PyObject *)p->_xslt));
  Py_XDECREF(((PyObject *)p->_profile));
  __pyx_tp_dealloc_4lxml_5etree__ElementTree(o);
}

static int __pyx_tp_traverse_4lxml_5etree__XSLTResultTree(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4lxml_5etree__XSLTResultTree *p = (struct __pyx_obj_4lxml_5etree__XSLTResultTree *)o;
  e = __pyx_tp_traverse_4lxml_5etree__ElementTree(o, v, a); if (e) return e;
  if (p->_xslt) {
    e = (*v)(((PyObject*)p->_xslt), a); if (e) return e;
  }
  if (p->_profile) {
    e = (*v)(((PyObject*)p->_profile), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4lxml_5etree__XSLTResultTree(PyObject *o) {
  struct __pyx_obj_4lxml_5etree__XSLTResultTree *p = (struct __pyx_obj_4lxml_5etree__XSLTResultTree *)o;
  PyObject* tmp;
  __pyx_tp_clear_4lxml_5etree__ElementTree(o);
  tmp = ((PyObject*)p->_xslt);
  p->_xslt = ((struct __pyx_obj_4lxml_5etree_XSLT *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_profile);
  p->_profile = ((struct LxmlDocument *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4lxml_5etree_15_XSLTResultTree_xslt_profile(PyObject *o, void *x) {
  return __pyx_pf_4lxml_5etree_15_XSLTResultTree_12xslt_profile___get__(o);
}

static int __pyx_setprop_4lxml_5etree_15_XSLTResultTree_xslt_profile(PyObject *o, PyObject *v, void *x) {
  if (v) {
    PyErr_SetString(PyExc_NotImplementedError, "__set__");
    return -1;
  }
  else {
    return __pyx_pf_4lxml_5etree_15_XSLTResultTree_12xslt_profile___del__(o);
  }
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XSLTResultTree[] = {
  {"__str__", (PyCFunction)__pyx_pf_4lxml_5etree_15_XSLTResultTree___str__, METH_NOARGS|METH_COEXIST, 0},
  {"__unicode__", (PyCFunction)__pyx_pf_4lxml_5etree_15_XSLTResultTree___unicode__, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4lxml_5etree__XSLTResultTree[] = {
  {"xslt_profile", __pyx_getprop_4lxml_5etree_15_XSLTResultTree_xslt_profile, __pyx_setprop_4lxml_5etree_15_XSLTResultTree_xslt_profile, __pyx_k_33, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XSLTResultTree = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XSLTResultTree = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XSLTResultTree = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XSLTResultTree = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  __pyx_pf_4lxml_5etree_15_XSLTResultTree___getbuffer__, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  __pyx_pf_4lxml_5etree_15_XSLTResultTree___releasebuffer__, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XSLTResultTree = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XSLTResultTree", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XSLTResultTree), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__XSLTResultTree, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XSLTResultTree, /*tp_as_number*/
  &__pyx_tp_as_sequence__XSLTResultTree, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XSLTResultTree, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_4lxml_5etree_15_XSLTResultTree___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XSLTResultTree, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__XSLTResultTree, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__XSLTResultTree, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XSLTResultTree, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4lxml_5etree__XSLTResultTree, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XSLTResultTree, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_4lxml_5etree__XSLTProcessingInstruction __pyx_vtable_4lxml_5etree__XSLTProcessingInstruction;

static PyObject *__pyx_tp_new_4lxml_5etree__XSLTProcessingInstruction(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *p;
  PyObject *o = __pyx_tp_new_4lxml_5etree__Element(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction *)o);
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4lxml_5etree___ContentOnlyElement*)__pyx_vtabptr_4lxml_5etree__XSLTProcessingInstruction;
  return o;
}

static struct PyMethodDef __pyx_methods_4lxml_5etree__XSLTProcessingInstruction[] = {
  {"parseXSL", (PyCFunction)__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_parseXSL, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_26_XSLTProcessingInstruction_parseXSL},
  {"set", (PyCFunction)__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_set, METH_VARARGS|METH_KEYWORDS, 0},
  {"get", (PyCFunction)__pyx_pf_4lxml_5etree_26_XSLTProcessingInstruction_get, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__XSLTProcessingInstruction = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence__XSLTProcessingInstruction = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__XSLTProcessingInstruction = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__XSLTProcessingInstruction = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree__XSLTProcessingInstruction = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree._XSLTProcessingInstruction", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree__XSLTProcessingInstruction), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree__Element, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__XSLTProcessingInstruction, /*tp_as_number*/
  &__pyx_tp_as_sequence__XSLTProcessingInstruction, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__XSLTProcessingInstruction, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__XSLTProcessingInstruction, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Element, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Element, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree__XSLTProcessingInstruction, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree__XSLTProcessingInstruction, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_XSLTExtension(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_XSLTExtension(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_XSLTExtension[] = {
  {"execute", (PyCFunction)__pyx_pf_4lxml_5etree_13XSLTExtension_execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_13XSLTExtension_execute},
  {"apply_templates", (PyCFunction)__pyx_pf_4lxml_5etree_13XSLTExtension_apply_templates, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_13XSLTExtension_apply_templates},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_XSLTExtension = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_XSLTExtension = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_XSLTExtension = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_XSLTExtension = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_XSLTExtension = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.XSLTExtension", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_XSLTExtension), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_XSLTExtension, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_XSLTExtension, /*tp_as_number*/
  &__pyx_tp_as_sequence_XSLTExtension, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_XSLTExtension, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_XSLTExtension, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  "Base class of an XSLT extension element.\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_XSLTExtension, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_XSLTExtension, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_DTD(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_4lxml_5etree__Validator(t, a, k);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_DTD(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_3DTD___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  __pyx_tp_dealloc_4lxml_5etree__Validator(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_DTD[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_3DTD___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_3DTD___call__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_DTD = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_DTD = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_DTD = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_DTD = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_DTD = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.DTD", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_DTD), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_DTD, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_DTD, /*tp_as_number*/
  &__pyx_tp_as_sequence_DTD, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_DTD, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_3DTD___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_DTD, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "DTD(self, file=None, external_id=None)\n    A DTD validator.\n\n    Can load from filesystem directly given a filename or file-like object.\n    Alternatively, pass the keyword parameter ``external_id`` to load from a\n    catalog.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Validator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Validator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_DTD, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_3DTD___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_DTD, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_RelaxNG(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_4lxml_5etree__Validator(t, a, k);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_RelaxNG(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_7RelaxNG___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  __pyx_tp_dealloc_4lxml_5etree__Validator(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_RelaxNG[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_7RelaxNG___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_7RelaxNG___call__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RelaxNG = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RelaxNG = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RelaxNG = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RelaxNG = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_RelaxNG = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.RelaxNG", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_RelaxNG), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_RelaxNG, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_RelaxNG, /*tp_as_number*/
  &__pyx_tp_as_sequence_RelaxNG, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RelaxNG, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_7RelaxNG___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RelaxNG, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "RelaxNG(self, etree=None, file=None)\n    Turn a document into a Relax NG validator.\n\n    Either pass a schema as Element or ElementTree, or pass a file or\n    filename through the ``file`` keyword argument.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Validator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Validator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_RelaxNG, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_7RelaxNG___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_RelaxNG, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_4lxml_5etree_Schematron(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_4lxml_5etree__Validator(t, a, k);
  if (!o) return 0;
  return o;
}

static void __pyx_tp_dealloc_4lxml_5etree_Schematron(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4lxml_5etree_10Schematron___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  __pyx_tp_dealloc_4lxml_5etree__Validator(o);
}

static struct PyMethodDef __pyx_methods_4lxml_5etree_Schematron[] = {
  {"__call__", (PyCFunction)__pyx_pf_4lxml_5etree_10Schematron___call__, METH_VARARGS|METH_KEYWORDS|METH_COEXIST, __pyx_doc_4lxml_5etree_10Schematron___call__},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Schematron = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Schematron = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Schematron = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Schematron = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4lxml_5etree_Schematron = {
  PyVarObject_HEAD_INIT(0, 0)
  "lxml.etree.Schematron", /*tp_name*/
  sizeof(struct __pyx_obj_4lxml_5etree_Schematron), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4lxml_5etree_Schematron, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Schematron, /*tp_as_number*/
  &__pyx_tp_as_sequence_Schematron, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Schematron, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pf_4lxml_5etree_10Schematron___call__, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Schematron, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Schematron(self, etree=None, file=None)\n    A Schematron validator.\n\n    Pass a root Element or an ElementTree to turn it into a validator.\n    Alternatively, pass a filename as keyword argument 'file' to parse from\n    the file system.\n\n    Schematron is a less well known, but very powerful schema language.  The main\n    idea is to use the capabilities of XPath to put restrictions on the structure\n    and the content of XML documents.  Here is a simple example::\n\n      >>> schematron = etree.Schematron(etree.XML('''\n      ... <schema xmlns=\"http://www.ascc.net/xml/schematron\" >\n      ...   <pattern name=\"id is the only permited attribute name\">\n      ...     <rule context=\"*\">\n      ...       <report test=\"@*[not(name()='id')]\">Attribute\n      ...         <name path=\"@*[not(name()='id')]\"/> is forbidden<name/>\n      ...       </report>\n      ...     </rule>\n      ...   </pattern>\n      ... </schema>\n      ... '''))\n\n      >>> xml = etree.XML('''\n      ... <AAA name=\"aaa\">\n      ...   <BBB id=\"bbb\"/>\n      ...   <CCC color=\"ccc\"/>\n      ... </AAA>\n      ... ''')\n\n      >>> schematron.validate(xml)\n      0\n\n      >>> xml = etree.XML('''\n      ... <AAA id=\"aaa\">\n      ...   <BBB id=\"bbb\"/>\n      ...   <CCC/>\n      ... </AAA>\n      ... ''')\n\n      >>> schematron.validate(xml)\n      1\n\n    Schematron was added to libxml2 in version 2.6.21.  Before version 2.6.32,\n    however, Schematron lacked support for error reporting other than to stderr.\n    This version is therefore required to retrieve validation warnings and\n    errors in lxml.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4lxml_5etree__Validator, /*tp_traverse*/
  __pyx_tp_clear_4lxml_5etree__Validator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4lxml_5etree_Schematron, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4lxml_5etree_10Schematron___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4lxml_5etree_Schematron, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"Element", (PyCFunction)__pyx_pf_4lxml_5etree_Element, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_Element},
  {"Comment", (PyCFunction)__pyx_pf_4lxml_5etree_Comment, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_Comment},
  {"ProcessingInstruction", (PyCFunction)__pyx_pf_4lxml_5etree_ProcessingInstruction, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_ProcessingInstruction},
  {"Entity", (PyCFunction)__pyx_pf_4lxml_5etree_Entity, METH_O, __pyx_doc_4lxml_5etree_Entity},
  {"SubElement", (PyCFunction)__pyx_pf_4lxml_5etree_SubElement, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_SubElement},
  {"ElementTree", (PyCFunction)__pyx_pf_4lxml_5etree_ElementTree, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_ElementTree},
  {"HTML", (PyCFunction)__pyx_pf_4lxml_5etree_HTML, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_HTML},
  {"XML", (PyCFunction)__pyx_pf_4lxml_5etree_XML, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_XML},
  {"fromstring", (PyCFunction)__pyx_pf_4lxml_5etree_fromstring, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_fromstring},
  {"fromstringlist", (PyCFunction)__pyx_pf_4lxml_5etree_fromstringlist, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_fromstringlist},
  {"iselement", (PyCFunction)__pyx_pf_4lxml_5etree_iselement, METH_O, __pyx_doc_4lxml_5etree_iselement},
  {"dump", (PyCFunction)__pyx_pf_4lxml_5etree_dump, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_dump},
  {"tostring", (PyCFunction)__pyx_pf_4lxml_5etree_tostring, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_tostring},
  {"tostringlist", (PyCFunction)__pyx_pf_4lxml_5etree_tostringlist, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_tostringlist},
  {"tounicode", (PyCFunction)__pyx_pf_4lxml_5etree_tounicode, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_tounicode},
  {"parse", (PyCFunction)__pyx_pf_4lxml_5etree_parse, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_parse},
  {"cleanup_namespaces", (PyCFunction)__pyx_pf_4lxml_5etree_cleanup_namespaces, METH_O, __pyx_doc_4lxml_5etree_cleanup_namespaces},
  {"clear_error_log", (PyCFunction)__pyx_pf_4lxml_5etree_clear_error_log, METH_NOARGS, __pyx_doc_4lxml_5etree_clear_error_log},
  {"use_global_python_log", (PyCFunction)__pyx_pf_4lxml_5etree_use_global_python_log, METH_O, __pyx_doc_4lxml_5etree_use_global_python_log},
  {"set_element_class_lookup", (PyCFunction)__pyx_pf_4lxml_5etree_set_element_class_lookup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_set_element_class_lookup},
  {"FunctionNamespace", (PyCFunction)__pyx_pf_4lxml_5etree_FunctionNamespace, METH_O, __pyx_doc_4lxml_5etree_FunctionNamespace},
  {"set_default_parser", (PyCFunction)__pyx_pf_4lxml_5etree_set_default_parser, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_set_default_parser},
  {"get_default_parser", (PyCFunction)__pyx_pf_4lxml_5etree_get_default_parser, METH_NOARGS, __pyx_doc_4lxml_5etree_get_default_parser},
  {"XMLID", (PyCFunction)__pyx_pf_4lxml_5etree_XMLID, METH_O, __pyx_doc_4lxml_5etree_XMLID},
  {"XMLDTDID", (PyCFunction)__pyx_pf_4lxml_5etree_XMLDTDID, METH_O, __pyx_doc_4lxml_5etree_XMLDTDID},
  {"parseid", (PyCFunction)__pyx_pf_4lxml_5etree_parseid, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_parseid},
  {"Extension", (PyCFunction)__pyx_pf_4lxml_5etree_Extension, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_Extension},
  {"XPathEvaluator", (PyCFunction)__pyx_pf_4lxml_5etree_XPathEvaluator, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4lxml_5etree_XPathEvaluator},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "etree",
    __pyx_mdoc, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1},
  {&__pyx_kp___str__, __pyx_k___str__, sizeof(__pyx_k___str__), 1, 1, 1},
  {&__pyx_kp___hash__, __pyx_k___hash__, sizeof(__pyx_k___hash__), 1, 1, 1},
  {&__pyx_kp___richcmp__, __pyx_k___richcmp__, sizeof(__pyx_k___richcmp__), 1, 1, 1},
  {&__pyx_kp___dealloc__, __pyx_k___dealloc__, sizeof(__pyx_k___dealloc__), 1, 1, 1},
  {&__pyx_kp__init, __pyx_k__init, sizeof(__pyx_k__init), 1, 1, 1},
  {&__pyx_kp___setitem__, __pyx_k___setitem__, sizeof(__pyx_k___setitem__), 1, 1, 1},
  {&__pyx_kp___delitem__, __pyx_k___delitem__, sizeof(__pyx_k___delitem__), 1, 1, 1},
  {&__pyx_kp___deepcopy__, __pyx_k___deepcopy__, sizeof(__pyx_k___deepcopy__), 1, 1, 1},
  {&__pyx_kp___copy__, __pyx_k___copy__, sizeof(__pyx_k___copy__), 1, 1, 1},
  {&__pyx_kp_set, __pyx_k_set, sizeof(__pyx_k_set), 1, 1, 1},
  {&__pyx_kp_append, __pyx_k_append, sizeof(__pyx_k_append), 1, 1, 1},
  {&__pyx_kp_addnext, __pyx_k_addnext, sizeof(__pyx_k_addnext), 1, 1, 1},
  {&__pyx_kp_addprevious, __pyx_k_addprevious, sizeof(__pyx_k_addprevious), 1, 1, 1},
  {&__pyx_kp_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 1, 1, 1},
  {&__pyx_kp_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 1, 1, 1},
  {&__pyx_kp_insert, __pyx_k_insert, sizeof(__pyx_k_insert), 1, 1, 1},
  {&__pyx_kp_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 1, 1, 1},
  {&__pyx_kp_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 1, 1, 1},
  {&__pyx_kp___repr__, __pyx_k___repr__, sizeof(__pyx_k___repr__), 1, 1, 1},
  {&__pyx_kp___getitem__, __pyx_k___getitem__, sizeof(__pyx_k___getitem__), 1, 1, 1},
  {&__pyx_kp___len__, __pyx_k___len__, sizeof(__pyx_k___len__), 1, 1, 1},
  {&__pyx_kp___nonzero__, __pyx_k___nonzero__, sizeof(__pyx_k___nonzero__), 1, 1, 1},
  {&__pyx_kp___contains__, __pyx_k___contains__, sizeof(__pyx_k___contains__), 1, 1, 1},
  {&__pyx_kp___iter__, __pyx_k___iter__, sizeof(__pyx_k___iter__), 1, 1, 1},
  {&__pyx_kp___reversed__, __pyx_k___reversed__, sizeof(__pyx_k___reversed__), 1, 1, 1},
  {&__pyx_kp_index, __pyx_k_index, sizeof(__pyx_k_index), 1, 1, 1},
  {&__pyx_kp_get, __pyx_k_get, sizeof(__pyx_k_get), 1, 1, 1},
  {&__pyx_kp_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 1, 1, 1},
  {&__pyx_kp_values, __pyx_k_values, sizeof(__pyx_k_values), 1, 1, 1},
  {&__pyx_kp_items, __pyx_k_items, sizeof(__pyx_k_items), 1, 1, 1},
  {&__pyx_kp_getchildren, __pyx_k_getchildren, sizeof(__pyx_k_getchildren), 1, 1, 1},
  {&__pyx_kp_getparent, __pyx_k_getparent, sizeof(__pyx_k_getparent), 1, 1, 1},
  {&__pyx_kp_getnext, __pyx_k_getnext, sizeof(__pyx_k_getnext), 1, 1, 1},
  {&__pyx_kp_getprevious, __pyx_k_getprevious, sizeof(__pyx_k_getprevious), 1, 1, 1},
  {&__pyx_kp_itersiblings, __pyx_k_itersiblings, sizeof(__pyx_k_itersiblings), 1, 1, 1},
  {&__pyx_kp_iterancestors, __pyx_k_iterancestors, sizeof(__pyx_k_iterancestors), 1, 1, 1},
  {&__pyx_kp_iterdescendants, __pyx_k_iterdescendants, sizeof(__pyx_k_iterdescendants), 1, 1, 1},
  {&__pyx_kp_iterchildren, __pyx_k_iterchildren, sizeof(__pyx_k_iterchildren), 1, 1, 1},
  {&__pyx_kp_getroottree, __pyx_k_getroottree, sizeof(__pyx_k_getroottree), 1, 1, 1},
  {&__pyx_kp_getiterator, __pyx_k_getiterator, sizeof(__pyx_k_getiterator), 1, 1, 1},
  {&__pyx_kp_iter, __pyx_k_iter, sizeof(__pyx_k_iter), 1, 1, 1},
  {&__pyx_kp_itertext, __pyx_k_itertext, sizeof(__pyx_k_itertext), 1, 1, 1},
  {&__pyx_kp_makeelement, __pyx_k_makeelement, sizeof(__pyx_k_makeelement), 1, 1, 1},
  {&__pyx_kp_find, __pyx_k_find, sizeof(__pyx_k_find), 1, 1, 1},
  {&__pyx_kp_findtext, __pyx_k_findtext, sizeof(__pyx_k_findtext), 1, 1, 1},
  {&__pyx_kp_findall, __pyx_k_findall, sizeof(__pyx_k_findall), 1, 1, 1},
  {&__pyx_kp_iterfind, __pyx_k_iterfind, sizeof(__pyx_k_iterfind), 1, 1, 1},
  {&__pyx_kp_xpath, __pyx_k_xpath, sizeof(__pyx_k_xpath), 1, 1, 1},
  {&__pyx_kp_parse, __pyx_k_parse, sizeof(__pyx_k_parse), 1, 1, 1},
  {&__pyx_kp__setroot, __pyx_k__setroot, sizeof(__pyx_k__setroot), 1, 1, 1},
  {&__pyx_kp_getroot, __pyx_k_getroot, sizeof(__pyx_k_getroot), 1, 1, 1},
  {&__pyx_kp_write, __pyx_k_write, sizeof(__pyx_k_write), 1, 1, 1},
  {&__pyx_kp_getpath, __pyx_k_getpath, sizeof(__pyx_k_getpath), 1, 1, 1},
  {&__pyx_kp_xslt, __pyx_k_xslt, sizeof(__pyx_k_xslt), 1, 1, 1},
  {&__pyx_kp_relaxng, __pyx_k_relaxng, sizeof(__pyx_k_relaxng), 1, 1, 1},
  {&__pyx_kp_xmlschema, __pyx_k_xmlschema, sizeof(__pyx_k_xmlschema), 1, 1, 1},
  {&__pyx_kp_xinclude, __pyx_k_xinclude, sizeof(__pyx_k_xinclude), 1, 1, 1},
  {&__pyx_kp_20, __pyx_k_20, sizeof(__pyx_k_20), 1, 1, 1},
  {&__pyx_kp_update, __pyx_k_update, sizeof(__pyx_k_update), 1, 1, 1},
  {&__pyx_kp_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 1, 1, 1},
  {&__pyx_kp_iterkeys, __pyx_k_iterkeys, sizeof(__pyx_k_iterkeys), 1, 1, 1},
  {&__pyx_kp_itervalues, __pyx_k_itervalues, sizeof(__pyx_k_itervalues), 1, 1, 1},
  {&__pyx_kp_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 1, 1, 1},
  {&__pyx_kp_has_key, __pyx_k_has_key, sizeof(__pyx_k_has_key), 1, 1, 1},
  {&__pyx_kp___next__, __pyx_k___next__, sizeof(__pyx_k___next__), 1, 1, 1},
  {&__pyx_kp_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 1, 1, 1},
  {&__pyx_kp_filter_domains, __pyx_k_filter_domains, sizeof(__pyx_k_filter_domains), 1, 1, 1},
  {&__pyx_kp_filter_types, __pyx_k_filter_types, sizeof(__pyx_k_filter_types), 1, 1, 1},
  {&__pyx_kp_filter_levels, __pyx_k_filter_levels, sizeof(__pyx_k_filter_levels), 1, 1, 1},
  {&__pyx_kp_filter_from_level, __pyx_k_filter_from_level, sizeof(__pyx_k_filter_from_level), 1, 1, 1},
  {&__pyx_kp_filter_from_fatals, __pyx_k_filter_from_fatals, sizeof(__pyx_k_filter_from_fatals), 1, 1, 1},
  {&__pyx_kp_filter_from_errors, __pyx_k_filter_from_errors, sizeof(__pyx_k_filter_from_errors), 1, 1, 1},
  {&__pyx_kp_21, __pyx_k_21, sizeof(__pyx_k_21), 1, 1, 1},
  {&__pyx_kp_receive, __pyx_k_receive, sizeof(__pyx_k_receive), 1, 1, 1},
  {&__pyx_kp_log, __pyx_k_log, sizeof(__pyx_k_log), 1, 1, 1},
  {&__pyx_kp___cinit__, __pyx_k___cinit__, sizeof(__pyx_k___cinit__), 1, 1, 1},
  {&__pyx_kp_set_fallback, __pyx_k_set_fallback, sizeof(__pyx_k_set_fallback), 1, 1, 1},
  {&__pyx_kp_lookup, __pyx_k_lookup, sizeof(__pyx_k_lookup), 1, 1, 1},
  {&__pyx_kp_get_namespace, __pyx_k_get_namespace, sizeof(__pyx_k_get_namespace), 1, 1, 1},
  {&__pyx_kp_resolve, __pyx_k_resolve, sizeof(__pyx_k_resolve), 1, 1, 1},
  {&__pyx_kp_resolve_empty, __pyx_k_resolve_empty, sizeof(__pyx_k_resolve_empty), 1, 1, 1},
  {&__pyx_kp_resolve_string, __pyx_k_resolve_string, sizeof(__pyx_k_resolve_string), 1, 1, 1},
  {&__pyx_kp_resolve_filename, __pyx_k_resolve_filename, sizeof(__pyx_k_resolve_filename), 1, 1, 1},
  {&__pyx_kp_resolve_file, __pyx_k_resolve_file, sizeof(__pyx_k_resolve_file), 1, 1, 1},
  {&__pyx_kp_add, __pyx_k_add, sizeof(__pyx_k_add), 1, 1, 1},
  {&__pyx_kp_27, __pyx_k_27, sizeof(__pyx_k_27), 1, 1, 1},
  {&__pyx_kp_28, __pyx_k_28, sizeof(__pyx_k_28), 1, 1, 1},
  {&__pyx_kp_feed, __pyx_k_feed, sizeof(__pyx_k_feed), 1, 1, 1},
  {&__pyx_kp_close, __pyx_k_close, sizeof(__pyx_k_close), 1, 1, 1},
  {&__pyx_kp_data, __pyx_k_data, sizeof(__pyx_k_data), 1, 1, 1},
  {&__pyx_kp_start, __pyx_k_start, sizeof(__pyx_k_start), 1, 1, 1},
  {&__pyx_kp_end, __pyx_k_end, sizeof(__pyx_k_end), 1, 1, 1},
  {&__pyx_kp_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 1, 1, 1},
  {&__pyx_kp_comment, __pyx_k_comment, sizeof(__pyx_k_comment), 1, 1, 1},
  {&__pyx_kp___cmp__, __pyx_k___cmp__, sizeof(__pyx_k___cmp__), 1, 1, 1},
  {&__pyx_kp___call__, __pyx_k___call__, sizeof(__pyx_k___call__), 1, 1, 1},
  {&__pyx_kp_test, __pyx_k_test, sizeof(__pyx_k_test), 1, 1, 1},
  {&__pyx_kp_match, __pyx_k_match, sizeof(__pyx_k_match), 1, 1, 1},
  {&__pyx_kp_evaluate, __pyx_k_evaluate, sizeof(__pyx_k_evaluate), 1, 1, 1},
  {&__pyx_kp_register_namespace, __pyx_k_register_namespace, sizeof(__pyx_k_register_namespace), 1, 1, 1},
  {&__pyx_kp_register_namespaces, __pyx_k_register_namespaces, sizeof(__pyx_k_register_namespaces), 1, 1, 1},
  {&__pyx_kp_DENY_ALL, __pyx_k_DENY_ALL, sizeof(__pyx_k_DENY_ALL), 1, 1, 1},
  {&__pyx_kp_DENY_WRITE, __pyx_k_DENY_WRITE, sizeof(__pyx_k_DENY_WRITE), 1, 1, 1},
  {&__pyx_kp_apply, __pyx_k_apply, sizeof(__pyx_k_apply), 1, 1, 1},
  {&__pyx_kp_tostring, __pyx_k_tostring, sizeof(__pyx_k_tostring), 1, 1, 1},
  {&__pyx_kp___unicode__, __pyx_k___unicode__, sizeof(__pyx_k___unicode__), 1, 1, 1},
  {&__pyx_kp___getbuffer__, __pyx_k___getbuffer__, sizeof(__pyx_k___getbuffer__), 1, 1, 1},
  {&__pyx_kp___releasebuffer__, __pyx_k___releasebuffer__, sizeof(__pyx_k___releasebuffer__), 1, 1, 1},
  {&__pyx_kp_parseXSL, __pyx_k_parseXSL, sizeof(__pyx_k_parseXSL), 1, 1, 1},
  {&__pyx_kp_execute, __pyx_k_execute, sizeof(__pyx_k_execute), 1, 1, 1},
  {&__pyx_kp_apply_templates, __pyx_k_apply_templates, sizeof(__pyx_k_apply_templates), 1, 1, 1},
  {&__pyx_kp_validate, __pyx_k_validate, sizeof(__pyx_k_validate), 1, 1, 1},
  {&__pyx_kp_assertValid, __pyx_k_assertValid, sizeof(__pyx_k_assertValid), 1, 1, 1},
  {&__pyx_kp_assert_, __pyx_k_assert_, sizeof(__pyx_k_assert_), 1, 1, 1},
  {&__pyx_kp_self, __pyx_k_self, sizeof(__pyx_k_self), 1, 1, 1},
  {&__pyx_kp_message, __pyx_k_message, sizeof(__pyx_k_message), 1, 1, 1},
  {&__pyx_kp_error_log, __pyx_k_error_log, sizeof(__pyx_k_error_log), 1, 1, 1},
  {&__pyx_kp_text_or_uri, __pyx_k_text_or_uri, sizeof(__pyx_k_text_or_uri), 1, 1, 1},
  {&__pyx_kp_tag, __pyx_k_tag, sizeof(__pyx_k_tag), 1, 1, 1},
  {&__pyx_kp_one, __pyx_k_one, sizeof(__pyx_k_one), 1, 1, 1},
  {&__pyx_kp_other, __pyx_k_other, sizeof(__pyx_k_other), 1, 1, 1},
  {&__pyx_kp_op, __pyx_k_op, sizeof(__pyx_k_op), 1, 1, 1},
  {&__pyx_kp_tree, __pyx_k_tree, sizeof(__pyx_k_tree), 1, 1, 1},
  {&__pyx_kp_url, __pyx_k_url, sizeof(__pyx_k_url), 1, 1, 1},
  {&__pyx_kp_x, __pyx_k_x, sizeof(__pyx_k_x), 1, 1, 1},
  {&__pyx_kp_value, __pyx_k_value, sizeof(__pyx_k_value), 1, 1, 1},
  {&__pyx_kp_memo, __pyx_k_memo, sizeof(__pyx_k_memo), 1, 1, 1},
  {&__pyx_kp_key, __pyx_k_key, sizeof(__pyx_k_key), 1, 1, 1},
  {&__pyx_kp_element, __pyx_k_element, sizeof(__pyx_k_element), 1, 1, 1},
  {&__pyx_kp_elements, __pyx_k_elements, sizeof(__pyx_k_elements), 1, 1, 1},
  {&__pyx_kp_old_element, __pyx_k_old_element, sizeof(__pyx_k_old_element), 1, 1, 1},
  {&__pyx_kp_new_element, __pyx_k_new_element, sizeof(__pyx_k_new_element), 1, 1, 1},
  {&__pyx_kp_line, __pyx_k_line, sizeof(__pyx_k_line), 1, 1, 1},
  {&__pyx_kp_child, __pyx_k_child, sizeof(__pyx_k_child), 1, 1, 1},
  {&__pyx_kp_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 1, 1, 1},
  {&__pyx_kp_default, __pyx_k_default, sizeof(__pyx_k_default), 1, 1, 1},
  {&__pyx_kp_preceding, __pyx_k_preceding, sizeof(__pyx_k_preceding), 1, 1, 1},
  {&__pyx_kp_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 1, 1, 1},
  {&__pyx_kp_with_tail, __pyx_k_with_tail, sizeof(__pyx_k_with_tail), 1, 1, 1},
  {&__pyx_kp__tag, __pyx_k__tag, sizeof(__pyx_k__tag), 1, 1, 1},
  {&__pyx_kp_attrib, __pyx_k_attrib, sizeof(__pyx_k_attrib), 1, 1, 1},
  {&__pyx_kp_nsmap, __pyx_k_nsmap, sizeof(__pyx_k_nsmap), 1, 1, 1},
  {&__pyx_kp_path, __pyx_k_path, sizeof(__pyx_k_path), 1, 1, 1},
  {&__pyx_kp__path, __pyx_k__path, sizeof(__pyx_k__path), 1, 1, 1},
  {&__pyx_kp_namespaces, __pyx_k_namespaces, sizeof(__pyx_k_namespaces), 1, 1, 1},
  {&__pyx_kp_extensions, __pyx_k_extensions, sizeof(__pyx_k_extensions), 1, 1, 1},
  {&__pyx_kp_smart_strings, __pyx_k_smart_strings, sizeof(__pyx_k_smart_strings), 1, 1, 1},
  {&__pyx_kp_source, __pyx_k_source, sizeof(__pyx_k_source), 1, 1, 1},
  {&__pyx_kp_parser, __pyx_k_parser, sizeof(__pyx_k_parser), 1, 1, 1},
  {&__pyx_kp_base_url, __pyx_k_base_url, sizeof(__pyx_k_base_url), 1, 1, 1},
  {&__pyx_kp_root, __pyx_k_root, sizeof(__pyx_k_root), 1, 1, 1},
  {&__pyx_kp_file, __pyx_k_file, sizeof(__pyx_k_file), 1, 1, 1},
  {&__pyx_kp_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 1, 1, 1},
  {&__pyx_kp_method, __pyx_k_method, sizeof(__pyx_k_method), 1, 1, 1},
  {&__pyx_kp_pretty_print, __pyx_k_pretty_print, sizeof(__pyx_k_pretty_print), 1, 1, 1},
  {&__pyx_kp_xml_declaration, __pyx_k_xml_declaration, sizeof(__pyx_k_xml_declaration), 1, 1, 1},
  {&__pyx_kp__xslt, __pyx_k__xslt, sizeof(__pyx_k__xslt), 1, 1, 1},
  {&__pyx_kp_access_control, __pyx_k_access_control, sizeof(__pyx_k_access_control), 1, 1, 1},
  {&__pyx_kp_sequence_or_dict, __pyx_k_sequence_or_dict, sizeof(__pyx_k_sequence_or_dict), 1, 1, 1},
  {&__pyx_kp_node, __pyx_k_node, sizeof(__pyx_k_node), 1, 1, 1},
  {&__pyx_kp_inclusive, __pyx_k_inclusive, sizeof(__pyx_k_inclusive), 1, 1, 1},
  {&__pyx_kp_text, __pyx_k_text, sizeof(__pyx_k_text), 1, 1, 1},
  {&__pyx_kp_target, __pyx_k_target, sizeof(__pyx_k_target), 1, 1, 1},
  {&__pyx_kp_name, __pyx_k_name, sizeof(__pyx_k_name), 1, 1, 1},
  {&__pyx_kp__parent, __pyx_k__parent, sizeof(__pyx_k__parent), 1, 1, 1},
  {&__pyx_kp_strings, __pyx_k_strings, sizeof(__pyx_k_strings), 1, 1, 1},
  {&__pyx_kp_elem, __pyx_k_elem, sizeof(__pyx_k_elem), 1, 1, 1},
  {&__pyx_kp_element_or_tree, __pyx_k_element_or_tree, sizeof(__pyx_k_element_or_tree), 1, 1, 1},
  {&__pyx_kp_tree_or_element, __pyx_k_tree_or_element, sizeof(__pyx_k_tree_or_element), 1, 1, 1},
  {&__pyx_kp_first_error, __pyx_k_first_error, sizeof(__pyx_k_first_error), 1, 1, 1},
  {&__pyx_kp_last_error, __pyx_k_last_error, sizeof(__pyx_k_last_error), 1, 1, 1},
  {&__pyx_kp_entries, __pyx_k_entries, sizeof(__pyx_k_entries), 1, 1, 1},
  {&__pyx_kp_error_type, __pyx_k_error_type, sizeof(__pyx_k_error_type), 1, 1, 1},
  {&__pyx_kp_domains, __pyx_k_domains, sizeof(__pyx_k_domains), 1, 1, 1},
  {&__pyx_kp_types, __pyx_k_types, sizeof(__pyx_k_types), 1, 1, 1},
  {&__pyx_kp_levels, __pyx_k_levels, sizeof(__pyx_k_levels), 1, 1, 1},
  {&__pyx_kp_level, __pyx_k_level, sizeof(__pyx_k_level), 1, 1, 1},
  {&__pyx_kp_entry, __pyx_k_entry, sizeof(__pyx_k_entry), 1, 1, 1},
  {&__pyx_kp_max_len, __pyx_k_max_len, sizeof(__pyx_k_max_len), 1, 1, 1},
  {&__pyx_kp_logger_name, __pyx_k_logger_name, sizeof(__pyx_k_logger_name), 1, 1, 1},
  {&__pyx_kp_35, __pyx_k_35, sizeof(__pyx_k_35), 1, 1, 1},
  {&__pyx_kp_other_element, __pyx_k_other_element, sizeof(__pyx_k_other_element), 0, 1, 1},
  {&__pyx_kp_fallback, __pyx_k_fallback, sizeof(__pyx_k_fallback), 1, 1, 1},
  {&__pyx_kp_entity, __pyx_k_entity, sizeof(__pyx_k_entity), 1, 1, 1},
  {&__pyx_kp_attribute_name, __pyx_k_attribute_name, sizeof(__pyx_k_attribute_name), 1, 1, 1},
  {&__pyx_kp_class_mapping, __pyx_k_class_mapping, sizeof(__pyx_k_class_mapping), 1, 1, 1},
  {&__pyx_kp_type, __pyx_k_type, sizeof(__pyx_k_type), 1, 1, 1},
  {&__pyx_kp_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 1, 1, 1},
  {&__pyx_kp_namespace, __pyx_k_namespace, sizeof(__pyx_k_namespace), 1, 1, 1},
  {&__pyx_kp_ns_uri, __pyx_k_ns_uri, sizeof(__pyx_k_ns_uri), 1, 1, 1},
  {&__pyx_kp_class_dict_iterable, __pyx_k_class_dict_iterable, sizeof(__pyx_k_class_dict_iterable), 1, 1, 1},
  {&__pyx_kp_item, __pyx_k_item, sizeof(__pyx_k_item), 1, 1, 1},
  {&__pyx_kp_prefix, __pyx_k_prefix, sizeof(__pyx_k_prefix), 1, 1, 1},
  {&__pyx_kp_system_url, __pyx_k_system_url, sizeof(__pyx_k_system_url), 1, 1, 1},
  {&__pyx_kp_public_id, __pyx_k_public_id, sizeof(__pyx_k_public_id), 1, 1, 1},
  {&__pyx_kp_context, __pyx_k_context, sizeof(__pyx_k_context), 1, 1, 1},
  {&__pyx_kp_string, __pyx_k_string, sizeof(__pyx_k_string), 1, 1, 1},
  {&__pyx_kp_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 1, 1, 1},
  {&__pyx_kp_f, __pyx_k_f, sizeof(__pyx_k_f), 1, 1, 1},
  {&__pyx_kp_default_resolver, __pyx_k_default_resolver, sizeof(__pyx_k_default_resolver), 1, 1, 1},
  {&__pyx_kp_resolver, __pyx_k_resolver, sizeof(__pyx_k_resolver), 1, 1, 1},
  {&__pyx_kp_code, __pyx_k_code, sizeof(__pyx_k_code), 1, 1, 1},
  {&__pyx_kp_column, __pyx_k_column, sizeof(__pyx_k_column), 1, 1, 1},
  {&__pyx_kp_filelike, __pyx_k_filelike, sizeof(__pyx_k_filelike), 1, 1, 1},
  {&__pyx_kp_exc_context, __pyx_k_exc_context, sizeof(__pyx_k_exc_context), 1, 1, 1},
  {&__pyx_kp_parse_options, __pyx_k_parse_options, sizeof(__pyx_k_parse_options), 1, 1, 1},
  {&__pyx_kp_for_html, __pyx_k_for_html, sizeof(__pyx_k_for_html), 1, 1, 1},
  {&__pyx_kp_schema, __pyx_k_schema, sizeof(__pyx_k_schema), 1, 1, 1},
  {&__pyx_kp_remove_comments, __pyx_k_remove_comments, sizeof(__pyx_k_remove_comments), 1, 1, 1},
  {&__pyx_kp_remove_pis, __pyx_k_remove_pis, sizeof(__pyx_k_remove_pis), 1, 1, 1},
  {&__pyx_kp_strip_cdata, __pyx_k_strip_cdata, sizeof(__pyx_k_strip_cdata), 1, 1, 1},
  {&__pyx_kp_attribute_defaults, __pyx_k_attribute_defaults, sizeof(__pyx_k_attribute_defaults), 1, 1, 1},
  {&__pyx_kp_dtd_validation, __pyx_k_dtd_validation, sizeof(__pyx_k_dtd_validation), 1, 1, 1},
  {&__pyx_kp_load_dtd, __pyx_k_load_dtd, sizeof(__pyx_k_load_dtd), 1, 1, 1},
  {&__pyx_kp_no_network, __pyx_k_no_network, sizeof(__pyx_k_no_network), 1, 1, 1},
  {&__pyx_kp_ns_clean, __pyx_k_ns_clean, sizeof(__pyx_k_ns_clean), 1, 1, 1},
  {&__pyx_kp_recover, __pyx_k_recover, sizeof(__pyx_k_recover), 1, 1, 1},
  {&__pyx_kp_remove_blank_text, __pyx_k_remove_blank_text, sizeof(__pyx_k_remove_blank_text), 1, 1, 1},
  {&__pyx_kp_compact, __pyx_k_compact, sizeof(__pyx_k_compact), 1, 1, 1},
  {&__pyx_kp_resolve_entities, __pyx_k_resolve_entities, sizeof(__pyx_k_resolve_entities), 1, 1, 1},
  {&__pyx_kp_element_factory, __pyx_k_element_factory, sizeof(__pyx_k_element_factory), 1, 1, 1},
  {&__pyx_kp_attrs, __pyx_k_attrs, sizeof(__pyx_k_attrs), 1, 1, 1},
  {&__pyx_kp_result, __pyx_k_result, sizeof(__pyx_k_result), 1, 1, 1},
  {&__pyx_kp_events, __pyx_k_events, sizeof(__pyx_k_events), 1, 1, 1},
  {&__pyx_kp_html, __pyx_k_html, sizeof(__pyx_k_html), 1, 1, 1},
  {&__pyx_kp_etree, __pyx_k_etree, sizeof(__pyx_k_etree), 1, 1, 1},
  {&__pyx_kp_id_name, __pyx_k_id_name, sizeof(__pyx_k_id_name), 1, 1, 1},
  {&__pyx_kp_enable_regexp, __pyx_k_enable_regexp, sizeof(__pyx_k_enable_regexp), 1, 1, 1},
  {&__pyx_kp_build_smart_strings, __pyx_k_build_smart_strings, sizeof(__pyx_k_build_smart_strings), 1, 1, 1},
  {&__pyx_kp_module, __pyx_k_module, sizeof(__pyx_k_module), 1, 1, 1},
  {&__pyx_kp_function_mapping, __pyx_k_function_mapping, sizeof(__pyx_k_function_mapping), 1, 1, 1},
  {&__pyx_kp_ns, __pyx_k_ns, sizeof(__pyx_k_ns), 1, 1, 1},
  {&__pyx_kp_ctxt, __pyx_k_ctxt, sizeof(__pyx_k_ctxt), 1, 1, 1},
  {&__pyx_kp_s, __pyx_k_s, sizeof(__pyx_k_s), 1, 1, 1},
  {&__pyx_kp_rexp, __pyx_k_rexp, sizeof(__pyx_k_rexp), 1, 1, 1},
  {&__pyx_kp_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 1, 1, 1},
  {&__pyx_kp_replacement, __pyx_k_replacement, sizeof(__pyx_k_replacement), 1, 1, 1},
  {&__pyx_kp_variables, __pyx_k_variables, sizeof(__pyx_k_variables), 1, 1, 1},
  {&__pyx_kp__eval_arg, __pyx_k__eval_arg, sizeof(__pyx_k__eval_arg), 1, 1, 1},
  {&__pyx_kp_regexp, __pyx_k_regexp, sizeof(__pyx_k_regexp), 1, 1, 1},
  {&__pyx_kp_uri, __pyx_k_uri, sizeof(__pyx_k_uri), 1, 1, 1},
  {&__pyx_kp_etree_or_element, __pyx_k_etree_or_element, sizeof(__pyx_k_etree_or_element), 1, 1, 1},
  {&__pyx_kp__etree_or_element, __pyx_k__etree_or_element, sizeof(__pyx_k__etree_or_element), 1, 1, 1},
  {&__pyx_kp_read_file, __pyx_k_read_file, sizeof(__pyx_k_read_file), 1, 1, 1},
  {&__pyx_kp_write_file, __pyx_k_write_file, sizeof(__pyx_k_write_file), 1, 1, 1},
  {&__pyx_kp_create_dir, __pyx_k_create_dir, sizeof(__pyx_k_create_dir), 1, 1, 1},
  {&__pyx_kp_read_network, __pyx_k_read_network, sizeof(__pyx_k_read_network), 1, 1, 1},
  {&__pyx_kp_write_network, __pyx_k_write_network, sizeof(__pyx_k_write_network), 1, 1, 1},
  {&__pyx_kp_xslt_input, __pyx_k_xslt_input, sizeof(__pyx_k_xslt_input), 1, 1, 1},
  {&__pyx_kp__input, __pyx_k__input, sizeof(__pyx_k__input), 1, 1, 1},
  {&__pyx_kp_profile_run, __pyx_k_profile_run, sizeof(__pyx_k_profile_run), 1, 1, 1},
  {&__pyx_kp_result_tree, __pyx_k_result_tree, sizeof(__pyx_k_result_tree), 1, 1, 1},
  {&__pyx_kp_buffer, __pyx_k_buffer, sizeof(__pyx_k_buffer), 1, 1, 1},
  {&__pyx_kp_self_node, __pyx_k_self_node, sizeof(__pyx_k_self_node), 1, 1, 1},
  {&__pyx_kp_input_node, __pyx_k_input_node, sizeof(__pyx_k_input_node), 1, 1, 1},
  {&__pyx_kp_output_parent, __pyx_k_output_parent, sizeof(__pyx_k_output_parent), 1, 1, 1},
  {&__pyx_kp_external_id, __pyx_k_external_id, sizeof(__pyx_k_external_id), 1, 1, 1},
  {&__pyx_kp___docformat__, __pyx_k___docformat__, sizeof(__pyx_k___docformat__), 1, 1, 1},
  {&__pyx_kp___builtin__, __pyx_k___builtin__, sizeof(__pyx_k___builtin__), 1, 1, 1},
  {&__pyx_kp_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 1, 1, 1},
  {&__pyx_kp_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 1, 1, 1},
  {&__pyx_kp_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 1, 1, 1},
  {&__pyx_kp_sets, __pyx_k_sets, sizeof(__pyx_k_sets), 1, 1, 1},
  {&__pyx_kp_Set, __pyx_k_Set, sizeof(__pyx_k_Set), 1, 1, 1},
  {&__pyx_kp_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 1, 1, 1},
  {&__pyx_kp_str, __pyx_k_str, sizeof(__pyx_k_str), 1, 1, 1},
  {&__pyx_kp_37, __pyx_k_37, sizeof(__pyx_k_37), 1, 1, 1},
  {&__pyx_kp_abspath, __pyx_k_abspath, sizeof(__pyx_k_abspath), 1, 1, 1},
  {&__pyx_kp_join, __pyx_k_join, sizeof(__pyx_k_join), 1, 1, 1},
  {&__pyx_kp_io, __pyx_k_io, sizeof(__pyx_k_io), 1, 1, 1},
  {&__pyx_kp_BytesIO, __pyx_k_BytesIO, sizeof(__pyx_k_BytesIO), 1, 1, 1},
  {&__pyx_kp_StringIO, __pyx_k_StringIO, sizeof(__pyx_k_StringIO), 1, 1, 1},
  {&__pyx_kp__elementpath, __pyx_k__elementpath, sizeof(__pyx_k__elementpath), 1, 1, 1},
  {&__pyx_kp_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 1, 1, 1},
  {&__pyx_kp_re, __pyx_k_re, sizeof(__pyx_k_re), 1, 1, 1},
  {&__pyx_kp_DEBUG, __pyx_k_DEBUG, sizeof(__pyx_k_DEBUG), 1, 1, 1},
  {&__pyx_kp_38, __pyx_k_38, sizeof(__pyx_k_38), 1, 1, 1},
  {&__pyx_kp_getdefaultencoding, __pyx_k_getdefaultencoding, sizeof(__pyx_k_getdefaultencoding), 1, 1, 1},
  {&__pyx_kp_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 1, 0},
  {&__pyx_kp_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 1, 1, 1},
  {&__pyx_kp_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 1, 0},
  {&__pyx_kp_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 1, 0},
  {&__pyx_kp_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 1, 0},
  {&__pyx_kp_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 1, 0},
  {&__pyx_kp_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 1, 0},
  {&__pyx_kp_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 1, 0},
  {&__pyx_kp_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 1, 0},
  {&__pyx_kp_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 1, 0},
  {&__pyx_kp_Error, __pyx_k_Error, sizeof(__pyx_k_Error), 0, 1, 1},
  {&__pyx_kp_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 1, 1, 1},
  {&__pyx_kp_LxmlError, __pyx_k_LxmlError, sizeof(__pyx_k_LxmlError), 0, 1, 1},
  {&__pyx_kp_LxmlSyntaxError, __pyx_k_LxmlSyntaxError, sizeof(__pyx_k_LxmlSyntaxError), 0, 1, 1},
  {&__pyx_kp_SyntaxError, __pyx_k_SyntaxError, sizeof(__pyx_k_SyntaxError), 1, 1, 1},
  {&__pyx_kp_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 1, 1},
  {&__pyx_kp_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 1, 1, 1},
  {&__pyx_kp_62, __pyx_k_62, sizeof(__pyx_k_62), 1, 1, 0},
  {&__pyx_kp_group, __pyx_k_group, sizeof(__pyx_k_group), 1, 1, 1},
  {&__pyx_kp_64, __pyx_k_64, sizeof(__pyx_k_64), 1, 1, 0},
  {&__pyx_kp_LIBXML_VERSION, __pyx_k_LIBXML_VERSION, sizeof(__pyx_k_LIBXML_VERSION), 1, 1, 1},
  {&__pyx_kp_65, __pyx_k_65, sizeof(__pyx_k_65), 1, 1, 1},
  {&__pyx_kp_LXML_VERSION, __pyx_k_LXML_VERSION, sizeof(__pyx_k_LXML_VERSION), 1, 1, 1},
  {&__pyx_kp_66, __pyx_k_66, sizeof(__pyx_k_66), 1, 1, 0},
  {&__pyx_kp___version__, __pyx_k___version__, sizeof(__pyx_k___version__), 1, 1, 1},
  {&__pyx_kp_71, __pyx_k_71, sizeof(__pyx_k_71), 1, 1, 0},
  {&__pyx_kp_79, __pyx_k_79, sizeof(__pyx_k_79), 1, 1, 1},
  {&__pyx_kp_PI, __pyx_k_PI, sizeof(__pyx_k_PI), 1, 1, 1},
  {&__pyx_kp_82, __pyx_k_82, sizeof(__pyx_k_82), 1, 1, 0},
  {&__pyx_kp_85, __pyx_k_85, sizeof(__pyx_k_85), 1, 1, 0},
  {&__pyx_kp_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 1, 1, 1},
  {&__pyx_kp_U, __pyx_k_U, sizeof(__pyx_k_U), 1, 1, 1},
  {&__pyx_kp_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 1, 1, 1},
  {&__pyx_kp_ErrorLevels, __pyx_k_ErrorLevels, sizeof(__pyx_k_ErrorLevels), 0, 1, 1},
  {&__pyx_kp_ErrorDomains, __pyx_k_ErrorDomains, sizeof(__pyx_k_ErrorDomains), 0, 1, 1},
  {&__pyx_kp_ErrorTypes, __pyx_k_ErrorTypes, sizeof(__pyx_k_ErrorTypes), 0, 1, 1},
  {&__pyx_kp_RelaxNGErrorTypes, __pyx_k_RelaxNGErrorTypes, sizeof(__pyx_k_RelaxNGErrorTypes), 0, 1, 1},
  {&__pyx_kp_LxmlRegistryError, __pyx_k_LxmlRegistryError, sizeof(__pyx_k_LxmlRegistryError), 0, 1, 1},
  {&__pyx_kp_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 1, 1},
  {&__pyx_kp_ParseError, __pyx_k_ParseError, sizeof(__pyx_k_ParseError), 0, 1, 1},
  {&__pyx_kp_XMLSyntaxError, __pyx_k_XMLSyntaxError, sizeof(__pyx_k_XMLSyntaxError), 0, 1, 1},
  {&__pyx_kp_ParserError, __pyx_k_ParserError, sizeof(__pyx_k_ParserError), 0, 1, 1},
  {&__pyx_kp_inspect, __pyx_k_inspect, sizeof(__pyx_k_inspect), 1, 1, 1},
  {&__pyx_kp_getargspec, __pyx_k_getargspec, sizeof(__pyx_k_getargspec), 1, 1, 1},
  {&__pyx_kp__TargetParserResult, __pyx_k__TargetParserResult, sizeof(__pyx_k__TargetParserResult), 0, 1, 1},
  {&__pyx_kp_144, __pyx_k_144, sizeof(__pyx_k_144), 1, 1, 0},
  {&__pyx_kp_157, __pyx_k_157, sizeof(__pyx_k_157), 1, 1, 0},
  {&__pyx_kp_XIncludeError, __pyx_k_XIncludeError, sizeof(__pyx_k_XIncludeError), 0, 1, 1},
  {&__pyx_kp_XPathError, __pyx_k_XPathError, sizeof(__pyx_k_XPathError), 0, 1, 1},
  {&__pyx_kp_XPathEvalError, __pyx_k_XPathEvalError, sizeof(__pyx_k_XPathEvalError), 0, 1, 1},
  {&__pyx_kp_XPathFunctionError, __pyx_k_XPathFunctionError, sizeof(__pyx_k_XPathFunctionError), 0, 1, 1},
  {&__pyx_kp_XPathResultError, __pyx_k_XPathResultError, sizeof(__pyx_k_XPathResultError), 0, 1, 1},
  {&__pyx_kp_166, __pyx_k_166, sizeof(__pyx_k_166), 0, 1, 1},
  {&__pyx_kp_XPathSyntaxError, __pyx_k_XPathSyntaxError, sizeof(__pyx_k_XPathSyntaxError), 0, 1, 1},
  {&__pyx_kp_XSLTError, __pyx_k_XSLTError, sizeof(__pyx_k_XSLTError), 0, 1, 1},
  {&__pyx_kp_XSLTParseError, __pyx_k_XSLTParseError, sizeof(__pyx_k_XSLTParseError), 0, 1, 1},
  {&__pyx_kp_XSLTApplyError, __pyx_k_XSLTApplyError, sizeof(__pyx_k_XSLTApplyError), 0, 1, 1},
  {&__pyx_kp_XSLTSaveError, __pyx_k_XSLTSaveError, sizeof(__pyx_k_XSLTSaveError), 0, 1, 1},
  {&__pyx_kp_XSLTExtensionError, __pyx_k_XSLTExtensionError, sizeof(__pyx_k_XSLTExtensionError), 0, 1, 1},
  {&__pyx_kp_184, __pyx_k_184, sizeof(__pyx_k_184), 1, 1, 1},
  {&__pyx_kp_LIBXSLT_VERSION, __pyx_k_LIBXSLT_VERSION, sizeof(__pyx_k_LIBXSLT_VERSION), 1, 1, 1},
  {&__pyx_kp_DocumentInvalid, __pyx_k_DocumentInvalid, sizeof(__pyx_k_DocumentInvalid), 0, 1, 1},
  {&__pyx_kp_DTDError, __pyx_k_DTDError, sizeof(__pyx_k_DTDError), 0, 1, 1},
  {&__pyx_kp_DTDParseError, __pyx_k_DTDParseError, sizeof(__pyx_k_DTDParseError), 0, 1, 1},
  {&__pyx_kp_DTDValidateError, __pyx_k_DTDValidateError, sizeof(__pyx_k_DTDValidateError), 0, 1, 1},
  {&__pyx_kp_RelaxNGError, __pyx_k_RelaxNGError, sizeof(__pyx_k_RelaxNGError), 0, 1, 1},
  {&__pyx_kp_RelaxNGParseError, __pyx_k_RelaxNGParseError, sizeof(__pyx_k_RelaxNGParseError), 0, 1, 1},
  {&__pyx_kp_201, __pyx_k_201, sizeof(__pyx_k_201), 0, 1, 1},
  {&__pyx_kp_XMLSchemaError, __pyx_k_XMLSchemaError, sizeof(__pyx_k_XMLSchemaError), 0, 1, 1},
  {&__pyx_kp_XMLSchemaParseError, __pyx_k_XMLSchemaParseError, sizeof(__pyx_k_XMLSchemaParseError), 0, 1, 1},
  {&__pyx_kp_205, __pyx_k_205, sizeof(__pyx_k_205), 0, 1, 1},
  {&__pyx_kp_SchematronError, __pyx_k_SchematronError, sizeof(__pyx_k_SchematronError), 0, 1, 1},
  {&__pyx_kp_208, __pyx_k_208, sizeof(__pyx_k_208), 0, 1, 1},
  {&__pyx_kp_210, __pyx_k_210, sizeof(__pyx_k_210), 0, 1, 1},
  {&__pyx_kp_super, __pyx_k_super, sizeof(__pyx_k_super), 1, 1, 1},
  {&__pyx_kp_212, __pyx_k_212, sizeof(__pyx_k_212), 1, 1, 0},
  {&__pyx_kp_split, __pyx_k_split, sizeof(__pyx_k_split), 1, 1, 1},
  {&__pyx_kp_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 1, 1, 1},
  {&__pyx_kp_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 1, 1, 1},
  {&__pyx_kp_216, __pyx_k_216, sizeof(__pyx_k_216), 1, 1, 0},
  {&__pyx_kp_217, __pyx_k_217, sizeof(__pyx_k_217), 1, 1, 0},
  {&__pyx_kp_218, __pyx_k_218, sizeof(__pyx_k_218), 1, 1, 0},
  {&__pyx_kp_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 1, 1, 1},
  {&__pyx_kp_221, __pyx_k_221, sizeof(__pyx_k_221), 0, 1, 0},
  {&__pyx_kp_222, __pyx_k_222, sizeof(__pyx_k_222), 0, 1, 0},
  {&__pyx_kp_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 1, 1, 1},
  {&__pyx_kp_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 1, 1, 1},
  {&__pyx_kp_tail, __pyx_k_tail, sizeof(__pyx_k_tail), 1, 1, 1},
  {&__pyx_kp_id, __pyx_k_id, sizeof(__pyx_k_id), 1, 1, 1},
  {&__pyx_kp_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 1, 1, 1},
  {&__pyx_kp_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 1, 1, 1},
  {&__pyx_kp_FutureWarning, __pyx_k_FutureWarning, sizeof(__pyx_k_FutureWarning), 1, 1, 1},
  {&__pyx_kp_Comment, __pyx_k_Comment, sizeof(__pyx_k_Comment), 1, 1, 1},
  {&__pyx_kp_Entity, __pyx_k_Entity, sizeof(__pyx_k_Entity), 1, 1, 1},
  {&__pyx_kp_262, __pyx_k_262, sizeof(__pyx_k_262), 1, 1, 0},
  {&__pyx_kp_263, __pyx_k_263, sizeof(__pyx_k_263), 1, 1, 0},
  {&__pyx_kp_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 1, 1, 1},
  {&__pyx_kp_265, __pyx_k_265, sizeof(__pyx_k_265), 1, 1, 0},
  {&__pyx_kp_266, __pyx_k_266, sizeof(__pyx_k_266), 1, 1, 0},
  {&__pyx_kp_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 1, 1, 1},
  {&__pyx_kp_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 1, 1, 1},
  {&__pyx_kp_Element, __pyx_k_Element, sizeof(__pyx_k_Element), 1, 1, 1},
  {&__pyx_kp_286, __pyx_k_286, sizeof(__pyx_k_286), 1, 1, 0},
  {&__pyx_kp_287, __pyx_k_287, sizeof(__pyx_k_287), 1, 1, 0},
  {&__pyx_kp_288, __pyx_k_288, sizeof(__pyx_k_288), 1, 1, 0},
  {&__pyx_kp_289, __pyx_k_289, sizeof(__pyx_k_289), 1, 1, 0},
  {&__pyx_kp_stdout, __pyx_k_stdout, sizeof(__pyx_k_stdout), 1, 1, 1},
  {&__pyx_kp_295, __pyx_k_295, sizeof(__pyx_k_295), 1, 1, 0},
  {&__pyx_kp_297, __pyx_k_297, sizeof(__pyx_k_297), 1, 1, 0},
  {&__pyx_kp_299, __pyx_k_299, sizeof(__pyx_k_299), 1, 1, 0},
  {&__pyx_kp_309, __pyx_k_309, sizeof(__pyx_k_309), 1, 1, 0},
  {&__pyx_kp_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 1, 1, 1},
  {&__pyx_kp_UnicodeEncodeError, __pyx_k_UnicodeEncodeError, sizeof(__pyx_k_UnicodeEncodeError), 1, 1, 1},
  {&__pyx_kp_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 1, 1, 1},
  {&__pyx_kp_347, __pyx_k_347, sizeof(__pyx_k_347), 1, 1, 0},
  {&__pyx_kp_348, __pyx_k_348, sizeof(__pyx_k_348), 1, 1, 0},
  {&__pyx_kp_349, __pyx_k_349, sizeof(__pyx_k_349), 1, 1, 0},
  {&__pyx_kp_level_name, __pyx_k_level_name, sizeof(__pyx_k_level_name), 1, 1, 1},
  {&__pyx_kp_domain_name, __pyx_k_domain_name, sizeof(__pyx_k_domain_name), 1, 1, 1},
  {&__pyx_kp_type_name, __pyx_k_type_name, sizeof(__pyx_k_type_name), 1, 1, 1},
  {&__pyx_kp__getName, __pyx_k__getName, sizeof(__pyx_k__getName), 1, 1, 1},
  {&__pyx_kp_352, __pyx_k_352, sizeof(__pyx_k_352), 1, 1, 0},
  {&__pyx_kp_RELAXNGV, __pyx_k_RELAXNGV, sizeof(__pyx_k_RELAXNGV), 1, 1, 1},
  {&__pyx_kp_353, __pyx_k_353, sizeof(__pyx_k_353), 1, 1, 0},
  {&__pyx_kp_354, __pyx_k_354, sizeof(__pyx_k_354), 1, 1, 0},
  {&__pyx_kp_FATAL, __pyx_k_FATAL, sizeof(__pyx_k_FATAL), 1, 1, 1},
  {&__pyx_kp_ERROR, __pyx_k_ERROR, sizeof(__pyx_k_ERROR), 1, 1, 1},
  {&__pyx_kp_WARNING, __pyx_k_WARNING, sizeof(__pyx_k_WARNING), 1, 1, 1},
  {&__pyx_kp__accepted_domains, __pyx_k__accepted_domains, sizeof(__pyx_k__accepted_domains), 1, 1, 1},
  {&__pyx_kp_domain, __pyx_k_domain, sizeof(__pyx_k_domain), 1, 1, 1},
  {&__pyx_kp_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 1, 1, 1},
  {&__pyx_kp_CRITICAL, __pyx_k_CRITICAL, sizeof(__pyx_k_CRITICAL), 1, 1, 1},
  {&__pyx_kp_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 1, 1, 1},
  {&__pyx_kp__names, __pyx_k__names, sizeof(__pyx_k__names), 1, 1, 1},
  {&__pyx_kp__doc, __pyx_k__doc, sizeof(__pyx_k__doc), 1, 1, 1},
  {&__pyx_kp_385, __pyx_k_385, sizeof(__pyx_k_385), 1, 1, 0},
  {&__pyx_kp_386, __pyx_k_386, sizeof(__pyx_k_386), 1, 1, 0},
  {&__pyx_kp_387, __pyx_k_387, sizeof(__pyx_k_387), 1, 1, 0},
  {&__pyx_kp_388, __pyx_k_388, sizeof(__pyx_k_388), 1, 1, 0},
  {&__pyx_kp_389, __pyx_k_389, sizeof(__pyx_k_389), 1, 1, 0},
  {&__pyx_kp_390, __pyx_k_390, sizeof(__pyx_k_390), 1, 1, 0},
  {&__pyx_kp_391, __pyx_k_391, sizeof(__pyx_k_391), 1, 1, 0},
  {&__pyx_kp_read, __pyx_k_read, sizeof(__pyx_k_read), 1, 1, 1},
  {&__pyx_kp_discard, __pyx_k_discard, sizeof(__pyx_k_discard), 1, 1, 1},
  {&__pyx_kp_position, __pyx_k_position, sizeof(__pyx_k_position), 1, 1, 1},
  {&__pyx_kp_403, __pyx_k_403, sizeof(__pyx_k_403), 1, 1, 0},
  {&__pyx_kp_404, __pyx_k_404, sizeof(__pyx_k_404), 1, 1, 0},
  {&__pyx_kp_405, __pyx_k_405, sizeof(__pyx_k_405), 1, 1, 0},
  {&__pyx_kp___class__, __pyx_k___class__, sizeof(__pyx_k___class__), 1, 1, 1},
  {&__pyx_kp_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 1, 1, 1},
  {&__pyx_kp_420, __pyx_k_420, sizeof(__pyx_k_420), 1, 1, 1},
  {&__pyx_kp_421, __pyx_k_421, sizeof(__pyx_k_421), 1, 1, 1},
  {&__pyx_kp_LookupError, __pyx_k_LookupError, sizeof(__pyx_k_LookupError), 1, 1, 1},
  {&__pyx_kp_432, __pyx_k_432, sizeof(__pyx_k_432), 1, 1, 0},
  {&__pyx_kp_433, __pyx_k_433, sizeof(__pyx_k_433), 1, 1, 0},
  {&__pyx_kp_tell, __pyx_k_tell, sizeof(__pyx_k_tell), 1, 1, 1},
  {&__pyx_kp_getvalue, __pyx_k_getvalue, sizeof(__pyx_k_getvalue), 1, 1, 1},
  {&__pyx_kp_434, __pyx_k_434, sizeof(__pyx_k_434), 1, 1, 0},
  {&__pyx_kp_doctype, __pyx_k_doctype, sizeof(__pyx_k_doctype), 1, 1, 1},
  {&__pyx_kp_449, __pyx_k_449, sizeof(__pyx_k_449), 1, 1, 0},
  {&__pyx_kp_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 1, 1, 1},
  {&__pyx_kp_450, __pyx_k_450, sizeof(__pyx_k_450), 1, 1, 0},
  {&__pyx_kp_451, __pyx_k_451, sizeof(__pyx_k_451), 1, 1, 0},
  {&__pyx_kp_452, __pyx_k_452, sizeof(__pyx_k_452), 1, 1, 0},
  {&__pyx_kp_455, __pyx_k_455, sizeof(__pyx_k_455), 1, 1, 0},
  {&__pyx_kp_open, __pyx_k_open, sizeof(__pyx_k_open), 1, 1, 1},
  {&__pyx_kp_478, __pyx_k_478, sizeof(__pyx_k_478), 1, 1, 0},
  {&__pyx_kp_481, __pyx_k_481, sizeof(__pyx_k_481), 1, 1, 0},
  {&__pyx_kp_483, __pyx_k_483, sizeof(__pyx_k_483), 1, 1, 0},
  {&__pyx_kp_488, __pyx_k_488, sizeof(__pyx_k_488), 1, 1, 0},
  {&__pyx_kp_489, __pyx_k_489, sizeof(__pyx_k_489), 1, 1, 0},
  {&__pyx_kp_492, __pyx_k_492, sizeof(__pyx_k_492), 1, 1, 0},
  {&__pyx_kp_493, __pyx_k_493, sizeof(__pyx_k_493), 1, 1, 0},
  {&__pyx_kp_501, __pyx_k_501, sizeof(__pyx_k_501), 1, 1, 0},
  {&__pyx_kp_502, __pyx_k_502, sizeof(__pyx_k_502), 1, 1, 0},
  {&__pyx_kp_504, __pyx_k_504, sizeof(__pyx_k_504), 1, 1, 0},
  {&__pyx_kp_505, __pyx_k_505, sizeof(__pyx_k_505), 1, 1, 0},
  {&__pyx_kp_506, __pyx_k_506, sizeof(__pyx_k_506), 1, 1, 0},
  {&__pyx_kp_507, __pyx_k_507, sizeof(__pyx_k_507), 1, 1, 0},
  {&__pyx_kp_515, __pyx_k_515, sizeof(__pyx_k_515), 1, 1, 0},
  {&__pyx_kp_516, __pyx_k_516, sizeof(__pyx_k_516), 1, 1, 0},
  {&__pyx_kp_XML, __pyx_k_XML, sizeof(__pyx_k_XML), 1, 1, 1},
  {&__pyx_kp_519, __pyx_k_519, sizeof(__pyx_k_519), 1, 1, 0},
  {&__pyx_kp_cmp, __pyx_k_cmp, sizeof(__pyx_k_cmp), 1, 1, 1},
  {&__pyx_kp_533, __pyx_k_533, sizeof(__pyx_k_533), 1, 1, 0},
  {&__pyx_kp_UNICODE, __pyx_k_UNICODE, sizeof(__pyx_k_UNICODE), 1, 1, 1},
  {&__pyx_kp_IGNORECASE, __pyx_k_IGNORECASE, sizeof(__pyx_k_IGNORECASE), 1, 1, 1},
  {&__pyx_kp_535, __pyx_k_535, sizeof(__pyx_k_535), 1, 1, 0},
  {&__pyx_kp_search, __pyx_k_search, sizeof(__pyx_k_search), 1, 1, 1},
  {&__pyx_kp_536, __pyx_k_536, sizeof(__pyx_k_536), 1, 1, 0},
  {&__pyx_kp_537, __pyx_k_537, sizeof(__pyx_k_537), 1, 1, 0},
  {&__pyx_kp_groups, __pyx_k_groups, sizeof(__pyx_k_groups), 1, 1, 1},
  {&__pyx_kp_539, __pyx_k_539, sizeof(__pyx_k_539), 1, 1, 0},
  {&__pyx_kp_SubElement, __pyx_k_SubElement, sizeof(__pyx_k_SubElement), 1, 1, 1},
  {&__pyx_kp_541, __pyx_k_541, sizeof(__pyx_k_541), 1, 1, 0},
  {&__pyx_kp_542, __pyx_k_542, sizeof(__pyx_k_542), 1, 1, 0},
  {&__pyx_kp_543, __pyx_k_543, sizeof(__pyx_k_543), 1, 1, 0},
  {&__pyx_kp_545, __pyx_k_545, sizeof(__pyx_k_545), 0, 1, 0},
  {&__pyx_kp_546, __pyx_k_546, sizeof(__pyx_k_546), 0, 1, 0},
  {&__pyx_kp_547, __pyx_k_547, sizeof(__pyx_k_547), 0, 1, 0},
  {&__pyx_kp_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 1, 1, 1},
  {&__pyx_kp_is_attribute, __pyx_k_is_attribute, sizeof(__pyx_k_is_attribute), 1, 1, 1},
  {&__pyx_kp_is_tail, __pyx_k_is_tail, sizeof(__pyx_k_is_tail), 1, 1, 1},
  {&__pyx_kp_is_text, __pyx_k_is_text, sizeof(__pyx_k_is_text), 1, 1, 1},
  {&__pyx_kp_resolvers, __pyx_k_resolvers, sizeof(__pyx_k_resolvers), 1, 1, 1},
  {&__pyx_kp_573, __pyx_k_573, sizeof(__pyx_k_573), 1, 1, 0},
  {&__pyx_kp_574, __pyx_k_574, sizeof(__pyx_k_574), 1, 1, 0},
  {&__pyx_kp_575, __pyx_k_575, sizeof(__pyx_k_575), 1, 1, 0},
  {&__pyx_kp_576, __pyx_k_576, sizeof(__pyx_k_576), 1, 1, 0},
  {&__pyx_kp_577, __pyx_k_577, sizeof(__pyx_k_577), 1, 1, 0},
  {&__pyx_kp_options, __pyx_k_options, sizeof(__pyx_k_options), 1, 1, 1},
  {&__pyx_kp_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 1, 1, 1},
  {&__pyx_kp_ElementTree, __pyx_k_ElementTree, sizeof(__pyx_k_ElementTree), 1, 1, 1},
  {&__pyx_kp_594, __pyx_k_594, sizeof(__pyx_k_594), 1, 1, 0},
  {&__pyx_kp_601, __pyx_k_601, sizeof(__pyx_k_601), 1, 1, 0},
  {&__pyx_kp_AssertionError, __pyx_k_AssertionError, sizeof(__pyx_k_AssertionError), 1, 1, 1},
  {&__pyx_kp_618, __pyx_k_618, sizeof(__pyx_k_618), 1, 1, 0},
  {&__pyx_kp_36, __pyx_k_36, sizeof(__pyx_k_36), 1, 0, 0},
  {&__pyx_kp_40, __pyx_k_40, sizeof(__pyx_k_40), 1, 0, 0},
  {&__pyx_kp_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 0},
  {&__pyx_kp_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 0},
  {&__pyx_kp_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 0},
  {&__pyx_kp_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 0},
  {&__pyx_kp_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 0},
  {&__pyx_kp_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 0},
  {&__pyx_kp_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 0},
  {&__pyx_kp_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 0},
  {&__pyx_kp_57, __pyx_k_57, sizeof(__pyx_k_57), 1, 0, 0},
  {&__pyx_kp_58, __pyx_k_58, sizeof(__pyx_k_58), 1, 0, 0},
  {&__pyx_kp_60, __pyx_k_60, sizeof(__pyx_k_60), 1, 0, 0},
  {&__pyx_kp_61, __pyx_k_61, sizeof(__pyx_k_61), 1, 0, 0},
  {&__pyx_kp_63, __pyx_k_63, sizeof(__pyx_k_63), 1, 0, 0},
  {&__pyx_kp_88, __pyx_k_88, sizeof(__pyx_k_88), 1, 0, 0},
  {&__pyx_kp_89, __pyx_k_89, sizeof(__pyx_k_89), 1, 0, 0},
  {&__pyx_kp_90, __pyx_k_90, sizeof(__pyx_k_90), 1, 0, 0},
  {&__pyx_kp_91, __pyx_k_91, sizeof(__pyx_k_91), 1, 0, 0},
  {&__pyx_kp_92, __pyx_k_92, sizeof(__pyx_k_92), 1, 0, 0},
  {&__pyx_kp_93, __pyx_k_93, sizeof(__pyx_k_93), 1, 0, 0},
  {&__pyx_kp_94, __pyx_k_94, sizeof(__pyx_k_94), 1, 0, 0},
  {&__pyx_kp_95, __pyx_k_95, sizeof(__pyx_k_95), 1, 0, 0},
  {&__pyx_kp_96, __pyx_k_96, sizeof(__pyx_k_96), 1, 0, 0},
  {&__pyx_kp_97, __pyx_k_97, sizeof(__pyx_k_97), 1, 0, 0},
  {&__pyx_kp_98, __pyx_k_98, sizeof(__pyx_k_98), 1, 0, 0},
  {&__pyx_kp_99, __pyx_k_99, sizeof(__pyx_k_99), 1, 0, 0},
  {&__pyx_kp_100, __pyx_k_100, sizeof(__pyx_k_100), 1, 0, 0},
  {&__pyx_kp_101, __pyx_k_101, sizeof(__pyx_k_101), 1, 0, 0},
  {&__pyx_kp_102, __pyx_k_102, sizeof(__pyx_k_102), 1, 0, 0},
  {&__pyx_kp_103, __pyx_k_103, sizeof(__pyx_k_103), 1, 0, 0},
  {&__pyx_kp_104, __pyx_k_104, sizeof(__pyx_k_104), 1, 0, 0},
  {&__pyx_kp_105, __pyx_k_105, sizeof(__pyx_k_105), 1, 0, 0},
  {&__pyx_kp_107, __pyx_k_107, sizeof(__pyx_k_107), 1, 0, 0},
  {&__pyx_kp_109, __pyx_k_109, sizeof(__pyx_k_109), 1, 0, 0},
  {&__pyx_kp_110, __pyx_k_110, sizeof(__pyx_k_110), 1, 0, 0},
  {&__pyx_kp_111, __pyx_k_111, sizeof(__pyx_k_111), 1, 0, 0},
  {&__pyx_kp_112, __pyx_k_112, sizeof(__pyx_k_112), 1, 0, 0},
  {&__pyx_kp_159, __pyx_k_159, sizeof(__pyx_k_159), 1, 0, 0},
  {&__pyx_kp_160, __pyx_k_160, sizeof(__pyx_k_160), 1, 0, 0},
  {&__pyx_kp_161, __pyx_k_161, sizeof(__pyx_k_161), 1, 0, 0},
  {&__pyx_kp_162, __pyx_k_162, sizeof(__pyx_k_162), 1, 0, 0},
  {&__pyx_kp_163, __pyx_k_163, sizeof(__pyx_k_163), 1, 0, 0},
  {&__pyx_kp_175, __pyx_k_175, sizeof(__pyx_k_175), 0, 0, 0},
  {&__pyx_kp_176, __pyx_k_176, sizeof(__pyx_k_176), 0, 0, 0},
  {&__pyx_kp_179, __pyx_k_179, sizeof(__pyx_k_179), 1, 0, 0},
  {&__pyx_kp_180, __pyx_k_180, sizeof(__pyx_k_180), 1, 0, 0},
  {&__pyx_kp_181, __pyx_k_181, sizeof(__pyx_k_181), 1, 0, 0},
  {&__pyx_kp_182, __pyx_k_182, sizeof(__pyx_k_182), 1, 0, 0},
  {&__pyx_kp_183, __pyx_k_183, sizeof(__pyx_k_183), 1, 0, 0},
  {&__pyx_kp_193, __pyx_k_193, sizeof(__pyx_k_193), 1, 0, 0},
  {&__pyx_kp_194, __pyx_k_194, sizeof(__pyx_k_194), 1, 0, 0},
  {&__pyx_kp_195, __pyx_k_195, sizeof(__pyx_k_195), 1, 0, 0},
  {&__pyx_kp_196, __pyx_k_196, sizeof(__pyx_k_196), 1, 0, 0},
  {&__pyx_kp_197, __pyx_k_197, sizeof(__pyx_k_197), 1, 0, 0},
  {&__pyx_kp_198, __pyx_k_198, sizeof(__pyx_k_198), 1, 0, 0},
  {&__pyx_kp_199, __pyx_k_199, sizeof(__pyx_k_199), 1, 0, 0},
  {&__pyx_kp_200, __pyx_k_200, sizeof(__pyx_k_200), 1, 0, 0},
  {&__pyx_kp_202, __pyx_k_202, sizeof(__pyx_k_202), 1, 0, 0},
  {&__pyx_kp_203, __pyx_k_203, sizeof(__pyx_k_203), 1, 0, 0},
  {&__pyx_kp_204, __pyx_k_204, sizeof(__pyx_k_204), 1, 0, 0},
  {&__pyx_kp_206, __pyx_k_206, sizeof(__pyx_k_206), 1, 0, 0},
  {&__pyx_kp_207, __pyx_k_207, sizeof(__pyx_k_207), 1, 0, 0},
  {&__pyx_kp_209, __pyx_k_209, sizeof(__pyx_k_209), 1, 0, 0},
  {&__pyx_kp_211, __pyx_k_211, sizeof(__pyx_k_211), 1, 0, 0},
  {&__pyx_kp_213, __pyx_k_213, sizeof(__pyx_k_213), 1, 0, 0},
  {&__pyx_kp_214, __pyx_k_214, sizeof(__pyx_k_214), 1, 0, 0},
  {&__pyx_kp_215, __pyx_k_215, sizeof(__pyx_k_215), 1, 0, 0},
  {&__pyx_kp_219, __pyx_k_219, sizeof(__pyx_k_219), 1, 0, 0},
  {&__pyx_kp_223, __pyx_k_223, sizeof(__pyx_k_223), 1, 0, 0},
  {&__pyx_kp_225, __pyx_k_225, sizeof(__pyx_k_225), 1, 0, 0},
  {&__pyx_kp_226, __pyx_k_226, sizeof(__pyx_k_226), 1, 0, 0},
  {&__pyx_kp_227, __pyx_k_227, sizeof(__pyx_k_227), 1, 0, 0},
  {&__pyx_kp_228, __pyx_k_228, sizeof(__pyx_k_228), 1, 0, 0},
  {&__pyx_kp_229, __pyx_k_229, sizeof(__pyx_k_229), 1, 0, 0},
  {&__pyx_kp_230, __pyx_k_230, sizeof(__pyx_k_230), 1, 0, 0},
  {&__pyx_kp_231, __pyx_k_231, sizeof(__pyx_k_231), 1, 0, 0},
  {&__pyx_kp_232, __pyx_k_232, sizeof(__pyx_k_232), 1, 0, 0},
  {&__pyx_kp_233, __pyx_k_233, sizeof(__pyx_k_233), 1, 0, 0},
  {&__pyx_kp_234, __pyx_k_234, sizeof(__pyx_k_234), 1, 0, 0},
  {&__pyx_kp_235, __pyx_k_235, sizeof(__pyx_k_235), 1, 0, 0},
  {&__pyx_kp_236, __pyx_k_236, sizeof(__pyx_k_236), 1, 0, 0},
  {&__pyx_kp_237, __pyx_k_237, sizeof(__pyx_k_237), 1, 0, 0},
  {&__pyx_kp_240, __pyx_k_240, sizeof(__pyx_k_240), 1, 0, 0},
  {&__pyx_kp_241, __pyx_k_241, sizeof(__pyx_k_241), 1, 0, 0},
  {&__pyx_kp_242, __pyx_k_242, sizeof(__pyx_k_242), 1, 0, 0},
  {&__pyx_kp_243, __pyx_k_243, sizeof(__pyx_k_243), 1, 0, 0},
  {&__pyx_kp_244, __pyx_k_244, sizeof(__pyx_k_244), 1, 0, 0},
  {&__pyx_kp_245, __pyx_k_245, sizeof(__pyx_k_245), 1, 0, 0},
  {&__pyx_kp_246, __pyx_k_246, sizeof(__pyx_k_246), 1, 0, 0},
  {&__pyx_kp_247, __pyx_k_247, sizeof(__pyx_k_247), 1, 0, 0},
  {&__pyx_kp_248, __pyx_k_248, sizeof(__pyx_k_248), 1, 0, 0},
  {&__pyx_kp_249, __pyx_k_249, sizeof(__pyx_k_249), 1, 0, 0},
  {&__pyx_kp_250, __pyx_k_250, sizeof(__pyx_k_250), 0, 0, 0},
  {&__pyx_kp_251, __pyx_k_251, sizeof(__pyx_k_251), 1, 0, 0},
  {&__pyx_kp_252, __pyx_k_252, sizeof(__pyx_k_252), 1, 0, 0},
  {&__pyx_kp_253, __pyx_k_253, sizeof(__pyx_k_253), 1, 0, 0},
  {&__pyx_kp_254, __pyx_k_254, sizeof(__pyx_k_254), 1, 0, 0},
  {&__pyx_kp_255, __pyx_k_255, sizeof(__pyx_k_255), 1, 0, 0},
  {&__pyx_kp_256, __pyx_k_256, sizeof(__pyx_k_256), 1, 0, 0},
  {&__pyx_kp_257, __pyx_k_257, sizeof(__pyx_k_257), 1, 0, 0},
  {&__pyx_kp_258, __pyx_k_258, sizeof(__pyx_k_258), 1, 0, 0},
  {&__pyx_kp_259, __pyx_k_259, sizeof(__pyx_k_259), 1, 0, 0},
  {&__pyx_kp_260, __pyx_k_260, sizeof(__pyx_k_260), 1, 0, 0},
  {&__pyx_kp_261, __pyx_k_261, sizeof(__pyx_k_261), 1, 0, 0},
  {&__pyx_kp_264, __pyx_k_264, sizeof(__pyx_k_264), 1, 0, 0},
  {&__pyx_kp_267, __pyx_k_267, sizeof(__pyx_k_267), 1, 0, 0},
  {&__pyx_kp_268, __pyx_k_268, sizeof(__pyx_k_268), 1, 0, 0},
  {&__pyx_kp_269, __pyx_k_269, sizeof(__pyx_k_269), 1, 0, 0},
  {&__pyx_kp_270, __pyx_k_270, sizeof(__pyx_k_270), 1, 0, 0},
  {&__pyx_kp_271, __pyx_k_271, sizeof(__pyx_k_271), 0, 0, 0},
  {&__pyx_kp_272, __pyx_k_272, sizeof(__pyx_k_272), 0, 0, 0},
  {&__pyx_kp_273, __pyx_k_273, sizeof(__pyx_k_273), 1, 0, 0},
  {&__pyx_kp_274, __pyx_k_274, sizeof(__pyx_k_274), 1, 0, 0},
  {&__pyx_kp_275, __pyx_k_275, sizeof(__pyx_k_275), 0, 0, 0},
  {&__pyx_kp_276, __pyx_k_276, sizeof(__pyx_k_276), 0, 0, 0},
  {&__pyx_kp_277, __pyx_k_277, sizeof(__pyx_k_277), 1, 0, 0},
  {&__pyx_kp_278, __pyx_k_278, sizeof(__pyx_k_278), 1, 0, 0},
  {&__pyx_kp_279, __pyx_k_279, sizeof(__pyx_k_279), 0, 0, 0},
  {&__pyx_kp_280, __pyx_k_280, sizeof(__pyx_k_280), 0, 0, 0},
  {&__pyx_kp_281, __pyx_k_281, sizeof(__pyx_k_281), 1, 0, 0},
  {&__pyx_kp_282, __pyx_k_282, sizeof(__pyx_k_282), 1, 0, 0},
  {&__pyx_kp_283, __pyx_k_283, sizeof(__pyx_k_283), 0, 0, 0},
  {&__pyx_kp_284, __pyx_k_284, sizeof(__pyx_k_284), 0, 0, 0},
  {&__pyx_kp_285, __pyx_k_285, sizeof(__pyx_k_285), 1, 0, 0},
  {&__pyx_kp_290, __pyx_k_290, sizeof(__pyx_k_290), 0, 0, 0},
  {&__pyx_kp_291, __pyx_k_291, sizeof(__pyx_k_291), 0, 0, 0},
  {&__pyx_kp_292, __pyx_k_292, sizeof(__pyx_k_292), 1, 0, 0},
  {&__pyx_kp_293, __pyx_k_293, sizeof(__pyx_k_293), 1, 0, 0},
  {&__pyx_kp_294, __pyx_k_294, sizeof(__pyx_k_294), 1, 0, 0},
  {&__pyx_kp_296, __pyx_k_296, sizeof(__pyx_k_296), 1, 0, 0},
  {&__pyx_kp_298, __pyx_k_298, sizeof(__pyx_k_298), 1, 0, 0},
  {&__pyx_kp_300, __pyx_k_300, sizeof(__pyx_k_300), 1, 0, 0},
  {&__pyx_kp_301, __pyx_k_301, sizeof(__pyx_k_301), 1, 0, 0},
  {&__pyx_kp_302, __pyx_k_302, sizeof(__pyx_k_302), 1, 0, 0},
  {&__pyx_kp_303, __pyx_k_303, sizeof(__pyx_k_303), 1, 0, 0},
  {&__pyx_kp_304, __pyx_k_304, sizeof(__pyx_k_304), 1, 0, 0},
  {&__pyx_kp_305, __pyx_k_305, sizeof(__pyx_k_305), 1, 0, 0},
  {&__pyx_kp_306, __pyx_k_306, sizeof(__pyx_k_306), 1, 0, 0},
  {&__pyx_kp_307, __pyx_k_307, sizeof(__pyx_k_307), 1, 0, 0},
  {&__pyx_kp_308, __pyx_k_308, sizeof(__pyx_k_308), 1, 0, 0},
  {&__pyx_kp_310, __pyx_k_310, sizeof(__pyx_k_310), 1, 0, 0},
  {&__pyx_kp_311, __pyx_k_311, sizeof(__pyx_k_311), 1, 0, 0},
  {&__pyx_kp_312, __pyx_k_312, sizeof(__pyx_k_312), 0, 0, 0},
  {&__pyx_kp_313, __pyx_k_313, sizeof(__pyx_k_313), 0, 0, 0},
  {&__pyx_kp_314, __pyx_k_314, sizeof(__pyx_k_314), 0, 0, 0},
  {&__pyx_kp_315, __pyx_k_315, sizeof(__pyx_k_315), 1, 0, 0},
  {&__pyx_kp_316, __pyx_k_316, sizeof(__pyx_k_316), 0, 0, 0},
  {&__pyx_kp_317, __pyx_k_317, sizeof(__pyx_k_317), 0, 0, 0},
  {&__pyx_kp_319, __pyx_k_319, sizeof(__pyx_k_319), 1, 0, 0},
  {&__pyx_kp_320, __pyx_k_320, sizeof(__pyx_k_320), 1, 0, 0},
  {&__pyx_kp_321, __pyx_k_321, sizeof(__pyx_k_321), 1, 0, 0},
  {&__pyx_kp_322, __pyx_k_322, sizeof(__pyx_k_322), 1, 0, 0},
  {&__pyx_kp_323, __pyx_k_323, sizeof(__pyx_k_323), 1, 0, 0},
  {&__pyx_kp_324, __pyx_k_324, sizeof(__pyx_k_324), 1, 0, 0},
  {&__pyx_kp_325, __pyx_k_325, sizeof(__pyx_k_325), 1, 0, 0},
  {&__pyx_kp_326, __pyx_k_326, sizeof(__pyx_k_326), 1, 0, 0},
  {&__pyx_kp_327, __pyx_k_327, sizeof(__pyx_k_327), 1, 0, 0},
  {&__pyx_kp_328, __pyx_k_328, sizeof(__pyx_k_328), 1, 0, 0},
  {&__pyx_kp_330, __pyx_k_330, sizeof(__pyx_k_330), 1, 0, 0},
  {&__pyx_kp_332, __pyx_k_332, sizeof(__pyx_k_332), 1, 0, 0},
  {&__pyx_kp_333, __pyx_k_333, sizeof(__pyx_k_333), 1, 0, 0},
  {&__pyx_kp_334, __pyx_k_334, sizeof(__pyx_k_334), 1, 0, 0},
  {&__pyx_kp_335, __pyx_k_335, sizeof(__pyx_k_335), 1, 0, 0},
  {&__pyx_kp_336, __pyx_k_336, sizeof(__pyx_k_336), 1, 0, 0},
  {&__pyx_kp_338, __pyx_k_338, sizeof(__pyx_k_338), 1, 0, 0},
  {&__pyx_kp_340, __pyx_k_340, sizeof(__pyx_k_340), 1, 0, 0},
  {&__pyx_kp_342, __pyx_k_342, sizeof(__pyx_k_342), 1, 0, 0},
  {&__pyx_kp_350, __pyx_k_350, sizeof(__pyx_k_350), 1, 0, 0},
  {&__pyx_kp_351, __pyx_k_351, sizeof(__pyx_k_351), 1, 0, 0},
  {&__pyx_kp_355, __pyx_k_355, sizeof(__pyx_k_355), 1, 0, 0},
  {&__pyx_kp_356, __pyx_k_356, sizeof(__pyx_k_356), 1, 0, 0},
  {&__pyx_kp_357, __pyx_k_357, sizeof(__pyx_k_357), 1, 0, 0},
  {&__pyx_kp_358, __pyx_k_358, sizeof(__pyx_k_358), 1, 0, 0},
  {&__pyx_kp_359, __pyx_k_359, sizeof(__pyx_k_359), 1, 0, 0},
  {&__pyx_kp_360, __pyx_k_360, sizeof(__pyx_k_360), 1, 0, 0},
  {&__pyx_kp_368, __pyx_k_368, sizeof(__pyx_k_368), 1, 0, 0},
  {&__pyx_kp_369, __pyx_k_369, sizeof(__pyx_k_369), 1, 0, 0},
  {&__pyx_kp_370, __pyx_k_370, sizeof(__pyx_k_370), 1, 0, 0},
  {&__pyx_kp_371, __pyx_k_371, sizeof(__pyx_k_371), 1, 0, 0},
  {&__pyx_kp_372, __pyx_k_372, sizeof(__pyx_k_372), 0, 0, 0},
  {&__pyx_kp_375, __pyx_k_375, sizeof(__pyx_k_375), 1, 0, 0},
  {&__pyx_kp_376, __pyx_k_376, sizeof(__pyx_k_376), 1, 0, 0},
  {&__pyx_kp_377, __pyx_k_377, sizeof(__pyx_k_377), 1, 0, 0},
  {&__pyx_kp_378, __pyx_k_378, sizeof(__pyx_k_378), 1, 0, 0},
  {&__pyx_kp_379, __pyx_k_379, sizeof(__pyx_k_379), 1, 0, 0},
  {&__pyx_kp_380, __pyx_k_380, sizeof(__pyx_k_380), 1, 0, 0},
  {&__pyx_kp_384, __pyx_k_384, sizeof(__pyx_k_384), 1, 0, 0},
  {&__pyx_kp_392, __pyx_k_392, sizeof(__pyx_k_392), 1, 0, 0},
  {&__pyx_kp_393, __pyx_k_393, sizeof(__pyx_k_393), 1, 0, 0},
  {&__pyx_kp_394, __pyx_k_394, sizeof(__pyx_k_394), 1, 0, 0},
  {&__pyx_kp_395, __pyx_k_395, sizeof(__pyx_k_395), 1, 0, 0},
  {&__pyx_kp_396, __pyx_k_396, sizeof(__pyx_k_396), 1, 0, 0},
  {&__pyx_kp_397, __pyx_k_397, sizeof(__pyx_k_397), 1, 0, 0},
  {&__pyx_kp_398, __pyx_k_398, sizeof(__pyx_k_398), 1, 0, 0},
  {&__pyx_kp_399, __pyx_k_399, sizeof(__pyx_k_399), 0, 0, 0},
  {&__pyx_kp_400, __pyx_k_400, sizeof(__pyx_k_400), 0, 0, 0},
  {&__pyx_kp_401, __pyx_k_401, sizeof(__pyx_k_401), 0, 0, 0},
  {&__pyx_kp_402, __pyx_k_402, sizeof(__pyx_k_402), 1, 0, 0},
  {&__pyx_kp_413, __pyx_k_413, sizeof(__pyx_k_413), 0, 0, 0},
  {&__pyx_kp_414, __pyx_k_414, sizeof(__pyx_k_414), 1, 0, 0},
  {&__pyx_kp_415, __pyx_k_415, sizeof(__pyx_k_415), 1, 0, 0},
  {&__pyx_kp_416, __pyx_k_416, sizeof(__pyx_k_416), 1, 0, 0},
  {&__pyx_kp_417, __pyx_k_417, sizeof(__pyx_k_417), 1, 0, 0},
  {&__pyx_kp_418, __pyx_k_418, sizeof(__pyx_k_418), 1, 0, 0},
  {&__pyx_kp_419, __pyx_k_419, sizeof(__pyx_k_419), 1, 0, 0},
  {&__pyx_kp_423, __pyx_k_423, sizeof(__pyx_k_423), 1, 0, 0},
  {&__pyx_kp_424, __pyx_k_424, sizeof(__pyx_k_424), 1, 0, 0},
  {&__pyx_kp_426, __pyx_k_426, sizeof(__pyx_k_426), 1, 0, 0},
  {&__pyx_kp_427, __pyx_k_427, sizeof(__pyx_k_427), 1, 0, 0},
  {&__pyx_kp_428, __pyx_k_428, sizeof(__pyx_k_428), 1, 0, 0},
  {&__pyx_kp_429, __pyx_k_429, sizeof(__pyx_k_429), 1, 0, 0},
  {&__pyx_kp_430, __pyx_k_430, sizeof(__pyx_k_430), 1, 0, 0},
  {&__pyx_kp_435, __pyx_k_435, sizeof(__pyx_k_435), 1, 0, 0},
  {&__pyx_kp_436, __pyx_k_436, sizeof(__pyx_k_436), 1, 0, 0},
  {&__pyx_kp_437, __pyx_k_437, sizeof(__pyx_k_437), 1, 0, 0},
  {&__pyx_kp_438, __pyx_k_438, sizeof(__pyx_k_438), 1, 0, 0},
  {&__pyx_kp_439, __pyx_k_439, sizeof(__pyx_k_439), 0, 0, 0},
  {&__pyx_kp_441, __pyx_k_441, sizeof(__pyx_k_441), 1, 0, 0},
  {&__pyx_kp_442, __pyx_k_442, sizeof(__pyx_k_442), 0, 0, 0},
  {&__pyx_kp_443, __pyx_k_443, sizeof(__pyx_k_443), 1, 0, 0},
  {&__pyx_kp_444, __pyx_k_444, sizeof(__pyx_k_444), 1, 0, 0},
  {&__pyx_kp_445, __pyx_k_445, sizeof(__pyx_k_445), 1, 0, 0},
  {&__pyx_kp_446, __pyx_k_446, sizeof(__pyx_k_446), 1, 0, 0},
  {&__pyx_kp_447, __pyx_k_447, sizeof(__pyx_k_447), 1, 0, 0},
  {&__pyx_kp_448, __pyx_k_448, sizeof(__pyx_k_448), 1, 0, 0},
  {&__pyx_kp_453, __pyx_k_453, sizeof(__pyx_k_453), 1, 0, 0},
  {&__pyx_kp_454, __pyx_k_454, sizeof(__pyx_k_454), 1, 0, 0},
  {&__pyx_kp_458, __pyx_k_458, sizeof(__pyx_k_458), 1, 0, 0},
  {&__pyx_kp_459, __pyx_k_459, sizeof(__pyx_k_459), 1, 0, 0},
  {&__pyx_kp_476, __pyx_k_476, sizeof(__pyx_k_476), 1, 0, 0},
  {&__pyx_kp_477, __pyx_k_477, sizeof(__pyx_k_477), 1, 0, 0},
  {&__pyx_kp_479, __pyx_k_479, sizeof(__pyx_k_479), 1, 0, 0},
  {&__pyx_kp_480, __pyx_k_480, sizeof(__pyx_k_480), 1, 0, 0},
  {&__pyx_kp_482, __pyx_k_482, sizeof(__pyx_k_482), 1, 0, 0},
  {&__pyx_kp_484, __pyx_k_484, sizeof(__pyx_k_484), 1, 0, 0},
  {&__pyx_kp_485, __pyx_k_485, sizeof(__pyx_k_485), 1, 0, 0},
  {&__pyx_kp_486, __pyx_k_486, sizeof(__pyx_k_486), 1, 0, 0},
  {&__pyx_kp_490, __pyx_k_490, sizeof(__pyx_k_490), 1, 0, 0},
  {&__pyx_kp_491, __pyx_k_491, sizeof(__pyx_k_491), 1, 0, 0},
  {&__pyx_kp_494, __pyx_k_494, sizeof(__pyx_k_494), 1, 0, 0},
  {&__pyx_kp_495, __pyx_k_495, sizeof(__pyx_k_495), 1, 0, 0},
  {&__pyx_kp_496, __pyx_k_496, sizeof(__pyx_k_496), 0, 0, 0},
  {&__pyx_kp_497, __pyx_k_497, sizeof(__pyx_k_497), 1, 0, 0},
  {&__pyx_kp_498, __pyx_k_498, sizeof(__pyx_k_498), 1, 0, 0},
  {&__pyx_kp_499, __pyx_k_499, sizeof(__pyx_k_499), 0, 0, 0},
  {&__pyx_kp_500, __pyx_k_500, sizeof(__pyx_k_500), 0, 0, 0},
  {&__pyx_kp_503, __pyx_k_503, sizeof(__pyx_k_503), 1, 0, 0},
  {&__pyx_kp_508, __pyx_k_508, sizeof(__pyx_k_508), 1, 0, 0},
  {&__pyx_kp_509, __pyx_k_509, sizeof(__pyx_k_509), 1, 0, 0},
  {&__pyx_kp_510, __pyx_k_510, sizeof(__pyx_k_510), 1, 0, 0},
  {&__pyx_kp_511, __pyx_k_511, sizeof(__pyx_k_511), 1, 0, 0},
  {&__pyx_kp_512, __pyx_k_512, sizeof(__pyx_k_512), 1, 0, 0},
  {&__pyx_kp_513, __pyx_k_513, sizeof(__pyx_k_513), 1, 0, 0},
  {&__pyx_kp_514, __pyx_k_514, sizeof(__pyx_k_514), 1, 0, 0},
  {&__pyx_kp_517, __pyx_k_517, sizeof(__pyx_k_517), 1, 0, 0},
  {&__pyx_kp_518, __pyx_k_518, sizeof(__pyx_k_518), 1, 0, 0},
  {&__pyx_kp_520, __pyx_k_520, sizeof(__pyx_k_520), 1, 0, 0},
  {&__pyx_kp_521, __pyx_k_521, sizeof(__pyx_k_521), 1, 0, 0},
  {&__pyx_kp_522, __pyx_k_522, sizeof(__pyx_k_522), 1, 0, 0},
  {&__pyx_kp_523, __pyx_k_523, sizeof(__pyx_k_523), 1, 0, 0},
  {&__pyx_kp_164, __pyx_k_164, sizeof(__pyx_k_164), 1, 0, 0},
  {&__pyx_kp_165, __pyx_k_165, sizeof(__pyx_k_165), 1, 0, 0},
  {&__pyx_kp_524, __pyx_k_524, sizeof(__pyx_k_524), 1, 0, 0},
  {&__pyx_kp_525, __pyx_k_525, sizeof(__pyx_k_525), 1, 0, 0},
  {&__pyx_kp_526, __pyx_k_526, sizeof(__pyx_k_526), 1, 0, 0},
  {&__pyx_kp_527, __pyx_k_527, sizeof(__pyx_k_527), 1, 0, 0},
  {&__pyx_kp_528, __pyx_k_528, sizeof(__pyx_k_528), 1, 0, 0},
  {&__pyx_kp_529, __pyx_k_529, sizeof(__pyx_k_529), 1, 0, 0},
  {&__pyx_kp_530, __pyx_k_530, sizeof(__pyx_k_530), 1, 0, 0},
  {&__pyx_kp_531, __pyx_k_531, sizeof(__pyx_k_531), 1, 0, 0},
  {&__pyx_kp_532, __pyx_k_532, sizeof(__pyx_k_532), 1, 0, 0},
  {&__pyx_kp_534, __pyx_k_534, sizeof(__pyx_k_534), 1, 0, 0},
  {&__pyx_kp_538, __pyx_k_538, sizeof(__pyx_k_538), 1, 0, 0},
  {&__pyx_kp_540, __pyx_k_540, sizeof(__pyx_k_540), 1, 0, 0},
  {&__pyx_kp_544, __pyx_k_544, sizeof(__pyx_k_544), 0, 0, 0},
  {&__pyx_kp_548, __pyx_k_548, sizeof(__pyx_k_548), 1, 0, 0},
  {&__pyx_kp_549, __pyx_k_549, sizeof(__pyx_k_549), 1, 0, 0},
  {&__pyx_kp_550, __pyx_k_550, sizeof(__pyx_k_550), 1, 0, 0},
  {&__pyx_kp_551, __pyx_k_551, sizeof(__pyx_k_551), 1, 0, 0},
  {&__pyx_kp_552, __pyx_k_552, sizeof(__pyx_k_552), 1, 0, 0},
  {&__pyx_kp_553, __pyx_k_553, sizeof(__pyx_k_553), 1, 0, 0},
  {&__pyx_kp_554, __pyx_k_554, sizeof(__pyx_k_554), 1, 0, 0},
  {&__pyx_kp_555, __pyx_k_555, sizeof(__pyx_k_555), 1, 0, 0},
  {&__pyx_kp_556, __pyx_k_556, sizeof(__pyx_k_556), 1, 0, 0},
  {&__pyx_kp_557, __pyx_k_557, sizeof(__pyx_k_557), 1, 0, 0},
  {&__pyx_kp_558, __pyx_k_558, sizeof(__pyx_k_558), 1, 0, 0},
  {&__pyx_kp_559, __pyx_k_559, sizeof(__pyx_k_559), 1, 0, 0},
  {&__pyx_kp_560, __pyx_k_560, sizeof(__pyx_k_560), 0, 0, 0},
  {&__pyx_kp_566, __pyx_k_566, sizeof(__pyx_k_566), 0, 0, 0},
  {&__pyx_kp_572, __pyx_k_572, sizeof(__pyx_k_572), 1, 0, 0},
  {&__pyx_kp_578, __pyx_k_578, sizeof(__pyx_k_578), 1, 0, 0},
  {&__pyx_kp_579, __pyx_k_579, sizeof(__pyx_k_579), 1, 0, 0},
  {&__pyx_kp_580, __pyx_k_580, sizeof(__pyx_k_580), 1, 0, 0},
  {&__pyx_kp_581, __pyx_k_581, sizeof(__pyx_k_581), 1, 0, 0},
  {&__pyx_kp_582, __pyx_k_582, sizeof(__pyx_k_582), 1, 0, 0},
  {&__pyx_kp_583, __pyx_k_583, sizeof(__pyx_k_583), 1, 0, 0},
  {&__pyx_kp_584, __pyx_k_584, sizeof(__pyx_k_584), 1, 0, 0},
  {&__pyx_kp_585, __pyx_k_585, sizeof(__pyx_k_585), 1, 0, 0},
  {&__pyx_kp_586, __pyx_k_586, sizeof(__pyx_k_586), 1, 0, 0},
  {&__pyx_kp_587, __pyx_k_587, sizeof(__pyx_k_587), 1, 0, 0},
  {&__pyx_kp_588, __pyx_k_588, sizeof(__pyx_k_588), 0, 0, 0},
  {&__pyx_kp_589, __pyx_k_589, sizeof(__pyx_k_589), 1, 0, 0},
  {&__pyx_kp_593, __pyx_k_593, sizeof(__pyx_k_593), 1, 0, 0},
  {&__pyx_kp_595, __pyx_k_595, sizeof(__pyx_k_595), 1, 0, 0},
  {&__pyx_kp_596, __pyx_k_596, sizeof(__pyx_k_596), 1, 0, 0},
  {&__pyx_kp_597, __pyx_k_597, sizeof(__pyx_k_597), 0, 0, 0},
  {&__pyx_kp_598, __pyx_k_598, sizeof(__pyx_k_598), 1, 0, 0},
  {&__pyx_kp_599, __pyx_k_599, sizeof(__pyx_k_599), 1, 0, 0},
  {&__pyx_kp_600, __pyx_k_600, sizeof(__pyx_k_600), 1, 0, 0},
  {&__pyx_kp_602, __pyx_k_602, sizeof(__pyx_k_602), 1, 0, 0},
  {&__pyx_kp_603, __pyx_k_603, sizeof(__pyx_k_603), 1, 0, 0},
  {&__pyx_kp_604, __pyx_k_604, sizeof(__pyx_k_604), 1, 0, 0},
  {&__pyx_kp_605, __pyx_k_605, sizeof(__pyx_k_605), 1, 0, 0},
  {&__pyx_kp_606, __pyx_k_606, sizeof(__pyx_k_606), 1, 0, 0},
  {&__pyx_kp_607, __pyx_k_607, sizeof(__pyx_k_607), 1, 0, 0},
  {&__pyx_kp_608, __pyx_k_608, sizeof(__pyx_k_608), 1, 0, 0},
  {&__pyx_kp_609, __pyx_k_609, sizeof(__pyx_k_609), 1, 0, 0},
  {&__pyx_kp_611, __pyx_k_611, sizeof(__pyx_k_611), 1, 0, 0},
  {&__pyx_kp_612, __pyx_k_612, sizeof(__pyx_k_612), 1, 0, 0},
  {&__pyx_kp_613, __pyx_k_613, sizeof(__pyx_k_613), 1, 0, 0},
  {&__pyx_kp_616, __pyx_k_616, sizeof(__pyx_k_616), 1, 0, 0},
  {&__pyx_kp_617, __pyx_k_617, sizeof(__pyx_k_617), 1, 0, 0},
  {&__pyx_kp_619, __pyx_k_619, sizeof(__pyx_k_619), 1, 0, 0},
  {&__pyx_kp_620, __pyx_k_620, sizeof(__pyx_k_620), 1, 0, 0},
  {&__pyx_kp_621, __pyx_k_621, sizeof(__pyx_k_621), 1, 0, 0},
  {&__pyx_kp_622, __pyx_k_622, sizeof(__pyx_k_622), 1, 0, 0},
  {&__pyx_kp_623, __pyx_k_623, sizeof(__pyx_k_623), 1, 0, 0},
  {&__pyx_kp_624, __pyx_k_624, sizeof(__pyx_k_624), 1, 0, 0},
  {&__pyx_kp_626, __pyx_k_626, sizeof(__pyx_k_626), 1, 0, 0},
  {&__pyx_kp_627, __pyx_k_627, sizeof(__pyx_k_627), 1, 0, 0},
  {&__pyx_kp_628, __pyx_k_628, sizeof(__pyx_k_628), 1, 0, 0},
  {&__pyx_kp_629, __pyx_k_629, sizeof(__pyx_k_629), 1, 0, 0},
  {&__pyx_kp_630, __pyx_k_630, sizeof(__pyx_k_630), 1, 0, 0},
  {&__pyx_kp_632, __pyx_k_632, sizeof(__pyx_k_632), 1, 0, 0},
  {&__pyx_kp_633, __pyx_k_633, sizeof(__pyx_k_633), 1, 0, 0},
  {&__pyx_kp_634, __pyx_k_634, sizeof(__pyx_k_634), 1, 0, 0},
  {&__pyx_kp_635, __pyx_k_635, sizeof(__pyx_k_635), 1, 0, 0},
  {&__pyx_kp_636, __pyx_k_636, sizeof(__pyx_k_636), 1, 0, 0},
  {&__pyx_kp_637, __pyx_k_637, sizeof(__pyx_k_637), 1, 0, 0},
  {&__pyx_kp_638, __pyx_k_638, sizeof(__pyx_k_638), 1, 0, 0},
  {&__pyx_kp_639, __pyx_k_639, sizeof(__pyx_k_639), 1, 0, 0},
  {0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetName(__pyx_b, __pyx_kp_ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_kp_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_kp_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_SyntaxError = __Pyx_GetName(__pyx_b, __pyx_kp_SyntaxError); if (!__pyx_builtin_SyntaxError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_kp_super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_kp_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_kp_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_kp_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetName(__pyx_b, __pyx_kp_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_FutureWarning = __Pyx_GetName(__pyx_b, __pyx_kp_FutureWarning); if (!__pyx_builtin_FutureWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_kp_KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_kp_StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_UnicodeEncodeError = __Pyx_GetName(__pyx_b, __pyx_kp_UnicodeEncodeError); if (!__pyx_builtin_UnicodeEncodeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_UnicodeDecodeError = __Pyx_GetName(__pyx_b, __pyx_kp_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_kp_IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_LookupError = __Pyx_GetName(__pyx_b, __pyx_kp_LookupError); if (!__pyx_builtin_LookupError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_kp_open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_kp_cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_kp_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AssertionError = __Pyx_GetName(__pyx_b, __pyx_kp_AssertionError); if (!__pyx_builtin_AssertionError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_300 = PyInt_FromLong(-300); if (unlikely(!__pyx_int_neg_300)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_200 = PyInt_FromLong(-200); if (unlikely(!__pyx_int_neg_200)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_100 = PyInt_FromLong(-100); if (unlikely(!__pyx_int_neg_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_32768 = PyInt_FromLong(32768); if (unlikely(!__pyx_int_32768)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initetree(void); /*proto*/
PyMODINIT_FUNC initetree(void)
#else
PyMODINIT_FUNC PyInit_etree(void); /*proto*/
PyMODINIT_FUNC PyInit_etree(void)
#endif
{
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  PyObject *__pyx_12 = 0;
  PyObject *__pyx_13 = 0;
  PyObject *__pyx_14 = 0;
  PyObject *__pyx_15 = 0;
  PyObject *__pyx_16 = 0;
  PyObject *__pyx_17 = 0;
  PyObject *__pyx_18 = 0;
  PyObject *__pyx_19 = 0;
  PyObject *__pyx_20 = 0;
  PyObject *__pyx_21 = 0;
  PyObject *__pyx_22 = 0;
  PyObject *__pyx_23 = 0;
  PyObject *__pyx_24 = 0;
  PyObject *__pyx_25 = 0;
  PyObject *__pyx_26 = 0;
  PyObject *__pyx_27 = 0;
  PyObject *__pyx_28 = 0;
  PyObject *__pyx_29 = 0;
  PyObject *__pyx_30 = 0;
  PyObject *__pyx_31 = 0;
  PyObject *__pyx_32 = 0;
  PyObject *__pyx_33 = 0;
  PyObject *__pyx_34 = 0;
  PyObject *__pyx_35 = 0;
  PyObject *__pyx_36 = 0;
  PyObject *__pyx_37 = 0;
  PyObject *__pyx_38 = 0;
  PyObject *__pyx_39 = 0;
  PyObject *__pyx_40 = 0;
  PyObject *__pyx_41 = 0;
  PyObject *__pyx_42 = 0;
  PyObject *__pyx_43 = 0;
  PyObject *__pyx_44 = 0;
  PyObject *__pyx_45 = 0;
  PyObject *__pyx_46 = 0;
  PyObject *__pyx_47 = 0;
  PyObject *__pyx_48 = 0;
  PyObject *__pyx_49 = 0;
  PyObject *__pyx_50 = 0;
  PyObject *__pyx_51 = 0;
  PyObject *__pyx_52 = 0;
  PyObject *__pyx_53 = 0;
  PyObject *__pyx_54 = 0;
  PyObject *__pyx_55 = 0;
  PyObject *__pyx_56 = 0;
  PyObject *__pyx_57 = 0;
  PyObject *__pyx_58 = 0;
  PyObject *__pyx_59 = 0;
  PyObject *__pyx_60 = 0;
  PyObject *__pyx_61 = 0;
  PyObject *__pyx_62 = 0;
  PyObject *__pyx_63 = 0;
  PyObject *__pyx_64 = 0;
  PyObject *__pyx_65 = 0;
  PyObject *__pyx_66 = 0;
  PyObject *__pyx_67 = 0;
  PyObject *__pyx_68 = 0;
  PyObject *__pyx_69 = 0;
  PyObject *__pyx_70 = 0;
  PyObject *__pyx_71 = 0;
  PyObject *__pyx_72 = 0;
  PyObject *__pyx_73 = 0;
  PyObject *__pyx_74 = 0;
  PyObject *__pyx_75 = 0;
  PyObject *__pyx_76 = 0;
  PyObject *__pyx_77 = 0;
  PyObject *__pyx_78 = 0;
  PyObject *__pyx_79 = 0;
  PyObject *__pyx_80 = 0;
  PyObject *__pyx_81 = 0;
  PyObject *__pyx_82 = 0;
  PyObject *__pyx_83 = 0;
  PyObject *__pyx_84 = 0;
  PyObject *__pyx_85 = 0;
  PyObject *__pyx_t_1 = NULL;
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Library function declarations ---*/
  __pyx_init_filenames();
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("etree", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME);
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_skip_dispatch = 0;
  /*--- Global init code ---*/
  __pyx_v_4lxml_5etree_set = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__unicode = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_os_path_abspath = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_os_path_join = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_BytesIO = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_StringIO = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__elementpath = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_sys = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_re = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_ITER_EMPTY = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__FILENAME_ENCODING = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__DEFAULT_NAMESPACE_PREFIXES = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__LxmlError = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_error_super_init = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__PREFIX_CACHE = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___RE_XML_ENCODING = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___REPLACE_XML_ENCODING = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___HAS_XML_ENCODING = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)Py_None); Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___ERROR_LEVELS = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___ERROR_DOMAINS = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___PARSER_ERROR_TYPES = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___RELAXNG_ERROR_TYPES = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_ELEMENT_CLASS_LOOKUP_STATE = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP = ((struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup *)Py_None); Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__XMLSyntaxError = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)Py_None); Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___DEFAULT_XML_PARSER = ((struct __pyx_obj_4lxml_5etree_XMLParser *)Py_None); Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___DEFAULT_HTML_PARSER = ((struct __pyx_obj_4lxml_5etree_HTMLParser *)Py_None); Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree_inspect_getargspec = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__find_id_attributes = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__XPATH_EVAL_ERRORS = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__replace_strings = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__find_namespaces = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__FIND_PI_ATTRIBUTES = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__RE_PI_HREF = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__FIND_PI_HREF = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree__REPLACE_PI_HREF = Py_None; Py_INCREF(Py_None);
  __pyx_v_4lxml_5etree___findStylesheetByID = ((struct __pyx_obj_4lxml_5etree_XPath *)Py_None); Py_INCREF(Py_None);
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("deepcopyNodeToDocument", (void*)deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("elementTreeFactory", (void*)elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("newElementTree", (void*)newElementTree, "struct LxmlElementTree *(struct LxmlElement *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("elementFactory", (void*)elementFactory, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("makeElement", (void*)makeElement, "struct LxmlElement *(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("makeSubElement", (void*)makeSubElement, "struct LxmlElement *(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("setElementClassLookupFunction", (void*)setElementClassLookupFunction, "void (_element_class_lookup_function, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("lookupDefaultElementClass", (void*)lookupDefaultElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("lookupNamespaceElementClass", (void*)lookupNamespaceElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("callLookupFallback", (void*)callLookupFallback, "PyObject *(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("tagMatches", (void*)tagMatches, "int (xmlNode *, char *, char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("documentOrRaise", (void*)documentOrRaise, "struct LxmlDocument *(PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("rootNodeOrRaise", (void*)rootNodeOrRaise, "struct LxmlElement *(PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("hasText", (void*)hasText, "int (xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("hasTail", (void*)hasTail, "int (xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("textOf", (void*)textOf, "PyObject *(xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("tailOf", (void*)tailOf, "PyObject *(xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("setNodeText", (void*)setNodeText, "int (xmlNode *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("setTailText", (void*)setTailText, "int (xmlNode *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("attributeValue", (void*)attributeValue, "PyObject *(xmlNode *, xmlAttr *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("attributeValueFromNsName", (void*)attributeValueFromNsName, "PyObject *(xmlNode *, char *, char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("getAttributeValue", (void*)getAttributeValue, "PyObject *(struct LxmlElement *, PyObject *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("iterattributes", (void*)iterattributes, "PyObject *(struct LxmlElement *, int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("collectAttributes", (void*)collectAttributes, "PyObject *(xmlNode *, int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("setAttributeValue", (void*)setAttributeValue, "int (struct LxmlElement *, PyObject *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("delAttribute", (void*)delAttribute, "int (struct LxmlElement *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("delAttributeFromNsName", (void*)delAttributeFromNsName, "int (xmlNode *, char *, char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("hasChild", (void*)hasChild, "int (xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("findChild", (void*)findChild, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("findChildForwards", (void*)findChildForwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("findChildBackwards", (void*)findChildBackwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("nextElement", (void*)nextElement, "xmlNode *(xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("previousElement", (void*)previousElement, "xmlNode *(xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("appendChild", (void*)appendChild, "void (struct LxmlElement *, struct LxmlElement *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("pyunicode", (void*)pyunicode, "PyObject *(char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("utf8", (void*)utf8, "PyObject *(PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("getNsTag", (void*)getNsTag, "PyObject *(PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("namespacedName", (void*)namespacedName, "PyObject *(xmlNode *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("namespacedNameFromNsName", (void*)namespacedNameFromNsName, "PyObject *(char *, char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("iteratorStoreNext", (void*)iteratorStoreNext, "void (struct LxmlElementIterator *, struct LxmlElement *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("initTagMatch", (void*)initTagMatch, "void (struct LxmlElementTagMatcher *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("findOrBuildNodeNsPrefix", (void*)findOrBuildNodeNsPrefix, "xmlNs *(struct LxmlDocument *, xmlNode *, char *, char *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Type init code ---*/
  __pyx_vtabptr_4lxml_5etree__TempStore = &__pyx_vtable_4lxml_5etree__TempStore;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__TempStore.add = (void(*)(void))__pyx_f_4lxml_5etree_10_TempStore_add;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__TempStore.clear = (void(*)(void))__pyx_f_4lxml_5etree_10_TempStore_clear;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__TempStore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__TempStore.tp_dict, __pyx_vtabptr_4lxml_5etree__TempStore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_TempStore", (PyObject *)&__pyx_type_4lxml_5etree__TempStore) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__TempStore = &__pyx_type_4lxml_5etree__TempStore;
  __pyx_vtabptr_4lxml_5etree__ExceptionContext = &__pyx_vtable_4lxml_5etree__ExceptionContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExceptionContext.clear = (void(*)(void))__pyx_f_4lxml_5etree_17_ExceptionContext_clear;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExceptionContext._store_raised = (void(*)(void))__pyx_f_4lxml_5etree_17_ExceptionContext__store_raised;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExceptionContext._store_exception = (void(*)(void))__pyx_f_4lxml_5etree_17_ExceptionContext__store_exception;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExceptionContext._has_raised = (void(*)(void))__pyx_f_4lxml_5etree_17_ExceptionContext__has_raised;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExceptionContext._raise_if_stored = (void(*)(void))__pyx_f_4lxml_5etree_17_ExceptionContext__raise_if_stored;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ExceptionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ExceptionContext.tp_dict, __pyx_vtabptr_4lxml_5etree__ExceptionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ExceptionContext", (PyObject *)&__pyx_type_4lxml_5etree__ExceptionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ExceptionContext = &__pyx_type_4lxml_5etree__ExceptionContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_QName) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "QName", (PyObject *)&__pyx_type_4lxml_5etree_QName) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_QName = &__pyx_type_4lxml_5etree_QName;
  __pyx_vtabptr_4lxml_5etree__BaseParser = &__pyx_vtable_4lxml_5etree__BaseParser;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._getParserContext = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__getParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._getPushParserContext = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__getPushParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._createContext = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__createContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._newParserCtxt = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__newParserCtxt;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._newPushParserCtxt = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__newPushParserCtxt;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._copy = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__copy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._parseUnicodeDoc = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__parseUnicodeDoc;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._parseDoc = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__parseDoc;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._parseDocFromFile = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFile;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseParser._parseDocFromFilelike = (void(*)(void))__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFilelike;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__BaseParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__BaseParser.tp_dict, __pyx_vtabptr_4lxml_5etree__BaseParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_BaseParser", (PyObject *)&__pyx_type_4lxml_5etree__BaseParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__BaseParser = &__pyx_type_4lxml_5etree__BaseParser;
  __pyx_vtabptr_4lxml_5etree__Document = &__pyx_vtable_4lxml_5etree__Document;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document.getroot = (void(*)(void))__pyx_f_4lxml_5etree_9_Document_getroot;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document.hasdoctype = (void(*)(void))__pyx_f_4lxml_5etree_9_Document_hasdoctype;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document.getdoctype = (void(*)(void))__pyx_f_4lxml_5etree_9_Document_getdoctype;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document.getxmlinfo = (void(*)(void))__pyx_f_4lxml_5etree_9_Document_getxmlinfo;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document.buildNewPrefix = (void(*)(void))__pyx_f_4lxml_5etree_9_Document_buildNewPrefix;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document._findOrBuildNodeNs = (void(*)(void))__pyx_f_4lxml_5etree_9_Document__findOrBuildNodeNs;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__Document._setNodeNs = (void(*)(void))__pyx_f_4lxml_5etree_9_Document__setNodeNs;
  if (PyType_Ready(&LxmlDocumentType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(LxmlDocumentType.tp_dict, __pyx_vtabptr_4lxml_5etree__Document) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_Document", (PyObject *)&LxmlDocumentType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__Document = &LxmlDocumentType;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_DocInfo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "DocInfo", (PyObject *)&__pyx_type_4lxml_5etree_DocInfo) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_DocInfo = &__pyx_type_4lxml_5etree_DocInfo;
  if (PyType_Ready(&LxmlElementType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_Element", (PyObject *)&LxmlElementType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__Element = &LxmlElementType;
  __pyx_vtabptr_4lxml_5etree___ContentOnlyElement = &__pyx_vtable_4lxml_5etree___ContentOnlyElement;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree___ContentOnlyElement._raiseImmutable = (void(*)(void))__pyx_f_4lxml_5etree_20__ContentOnlyElement__raiseImmutable;
  __pyx_type_4lxml_5etree___ContentOnlyElement.tp_base = __pyx_ptype_4lxml_5etree__Element;
  if (PyType_Ready(&__pyx_type_4lxml_5etree___ContentOnlyElement) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree___ContentOnlyElement.tp_dict, __pyx_vtabptr_4lxml_5etree___ContentOnlyElement) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "__ContentOnlyElement", (PyObject *)&__pyx_type_4lxml_5etree___ContentOnlyElement) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree___ContentOnlyElement = &__pyx_type_4lxml_5etree___ContentOnlyElement;
  __pyx_vtabptr_4lxml_5etree__Comment = &__pyx_vtable_4lxml_5etree__Comment;
  __pyx_vtable_4lxml_5etree__Comment.__pyx_base = *__pyx_vtabptr_4lxml_5etree___ContentOnlyElement;
  __pyx_type_4lxml_5etree__Comment.tp_base = __pyx_ptype_4lxml_5etree___ContentOnlyElement;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__Comment) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__Comment.tp_dict, __pyx_vtabptr_4lxml_5etree__Comment) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_Comment", (PyObject *)&__pyx_type_4lxml_5etree__Comment) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__Comment = &__pyx_type_4lxml_5etree__Comment;
  __pyx_vtabptr_4lxml_5etree__ProcessingInstruction = &__pyx_vtable_4lxml_5etree__ProcessingInstruction;
  __pyx_vtable_4lxml_5etree__ProcessingInstruction.__pyx_base = *__pyx_vtabptr_4lxml_5etree___ContentOnlyElement;
  __pyx_type_4lxml_5etree__ProcessingInstruction.tp_base = __pyx_ptype_4lxml_5etree___ContentOnlyElement;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ProcessingInstruction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ProcessingInstruction.tp_dict, __pyx_vtabptr_4lxml_5etree__ProcessingInstruction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ProcessingInstruction", (PyObject *)&__pyx_type_4lxml_5etree__ProcessingInstruction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ProcessingInstruction = &__pyx_type_4lxml_5etree__ProcessingInstruction;
  __pyx_vtabptr_4lxml_5etree__Entity = &__pyx_vtable_4lxml_5etree__Entity;
  __pyx_vtable_4lxml_5etree__Entity.__pyx_base = *__pyx_vtabptr_4lxml_5etree___ContentOnlyElement;
  __pyx_type_4lxml_5etree__Entity.tp_base = __pyx_ptype_4lxml_5etree___ContentOnlyElement;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__Entity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__Entity.tp_dict, __pyx_vtabptr_4lxml_5etree__Entity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_Entity", (PyObject *)&__pyx_type_4lxml_5etree__Entity) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__Entity = &__pyx_type_4lxml_5etree__Entity;
  __pyx_vtabptr_4lxml_5etree__ElementTree = &__pyx_vtable_4lxml_5etree__ElementTree;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ElementTree._assertHasRoot = (void(*)(void))__pyx_f_4lxml_5etree_12_ElementTree__assertHasRoot;
  if (PyType_Ready(&LxmlElementTreeType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(LxmlElementTreeType.tp_dict, __pyx_vtabptr_4lxml_5etree__ElementTree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ElementTree", (PyObject *)&LxmlElementTreeType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ElementTree = &LxmlElementTreeType;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__Attrib) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_Attrib", (PyObject *)&__pyx_type_4lxml_5etree__Attrib) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__Attrib = &__pyx_type_4lxml_5etree__Attrib;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__AttribIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_AttribIterator", (PyObject *)&__pyx_type_4lxml_5etree__AttribIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__AttribIterator = &__pyx_type_4lxml_5etree__AttribIterator;
  __pyx_vtabptr_4lxml_5etree__ElementTagMatcher = &__pyx_vtable_4lxml_5etree__ElementTagMatcher;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ElementTagMatcher._initTagMatch = (void(*)(void))__pyx_f_4lxml_5etree_18_ElementTagMatcher__initTagMatch;
  if (PyType_Ready(&LxmlElementTagMatcherType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(LxmlElementTagMatcherType.tp_dict, __pyx_vtabptr_4lxml_5etree__ElementTagMatcher) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ElementTagMatcher", (PyObject *)&LxmlElementTagMatcherType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ElementTagMatcher = &LxmlElementTagMatcherType;
  __pyx_vtabptr_4lxml_5etree__ElementIterator = &__pyx_vtable_4lxml_5etree__ElementIterator;
  __pyx_vtable_4lxml_5etree__ElementIterator.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ElementTagMatcher;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ElementIterator._storeNext = (void(*)(void))__pyx_f_4lxml_5etree_16_ElementIterator__storeNext;
  LxmlElementIteratorType.tp_base = __pyx_ptype_4lxml_5etree__ElementTagMatcher;
  if (PyType_Ready(&LxmlElementIteratorType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(LxmlElementIteratorType.tp_dict, __pyx_vtabptr_4lxml_5etree__ElementIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ElementIterator", (PyObject *)&LxmlElementIteratorType) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ElementIterator = &LxmlElementIteratorType;
  __pyx_vtabptr_4lxml_5etree_ElementChildIterator = &__pyx_vtable_4lxml_5etree_ElementChildIterator;
  __pyx_vtable_4lxml_5etree_ElementChildIterator.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ElementIterator;
  __pyx_type_4lxml_5etree_ElementChildIterator.tp_base = __pyx_ptype_4lxml_5etree__ElementIterator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ElementChildIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_ElementChildIterator.tp_dict, __pyx_vtabptr_4lxml_5etree_ElementChildIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementChildIterator", (PyObject *)&__pyx_type_4lxml_5etree_ElementChildIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementChildIterator = &__pyx_type_4lxml_5etree_ElementChildIterator;
  __pyx_vtabptr_4lxml_5etree_SiblingsIterator = &__pyx_vtable_4lxml_5etree_SiblingsIterator;
  __pyx_vtable_4lxml_5etree_SiblingsIterator.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ElementIterator;
  __pyx_type_4lxml_5etree_SiblingsIterator.tp_base = __pyx_ptype_4lxml_5etree__ElementIterator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_SiblingsIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_SiblingsIterator.tp_dict, __pyx_vtabptr_4lxml_5etree_SiblingsIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SiblingsIterator", (PyObject *)&__pyx_type_4lxml_5etree_SiblingsIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_SiblingsIterator = &__pyx_type_4lxml_5etree_SiblingsIterator;
  __pyx_vtabptr_4lxml_5etree_AncestorsIterator = &__pyx_vtable_4lxml_5etree_AncestorsIterator;
  __pyx_vtable_4lxml_5etree_AncestorsIterator.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ElementIterator;
  __pyx_type_4lxml_5etree_AncestorsIterator.tp_base = __pyx_ptype_4lxml_5etree__ElementIterator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_AncestorsIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_AncestorsIterator.tp_dict, __pyx_vtabptr_4lxml_5etree_AncestorsIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "AncestorsIterator", (PyObject *)&__pyx_type_4lxml_5etree_AncestorsIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_AncestorsIterator = &__pyx_type_4lxml_5etree_AncestorsIterator;
  __pyx_vtabptr_4lxml_5etree_ElementDepthFirstIterator = &__pyx_vtable_4lxml_5etree_ElementDepthFirstIterator;
  __pyx_vtable_4lxml_5etree_ElementDepthFirstIterator.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ElementTagMatcher;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_ElementDepthFirstIterator._nextNodeAnyTag = (void(*)(void))__pyx_f_4lxml_5etree_25ElementDepthFirstIterator__nextNodeAnyTag;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_ElementDepthFirstIterator._nextNodeMatchTag = (void(*)(void))__pyx_f_4lxml_5etree_25ElementDepthFirstIterator__nextNodeMatchTag;
  __pyx_type_4lxml_5etree_ElementDepthFirstIterator.tp_base = __pyx_ptype_4lxml_5etree__ElementTagMatcher;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ElementDepthFirstIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_ElementDepthFirstIterator.tp_dict, __pyx_vtabptr_4lxml_5etree_ElementDepthFirstIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementDepthFirstIterator", (PyObject *)&__pyx_type_4lxml_5etree_ElementDepthFirstIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementDepthFirstIterator = &__pyx_type_4lxml_5etree_ElementDepthFirstIterator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ElementTextIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementTextIterator", (PyObject *)&__pyx_type_4lxml_5etree_ElementTextIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementTextIterator = &__pyx_type_4lxml_5etree_ElementTextIterator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_CDATA) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "CDATA", (PyObject *)&__pyx_type_4lxml_5etree_CDATA) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_CDATA = &__pyx_type_4lxml_5etree_CDATA;
  __pyx_vtabptr_4lxml_5etree__LogEntry = &__pyx_vtable_4lxml_5etree__LogEntry;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__LogEntry._setError = (void(*)(void))__pyx_f_4lxml_5etree_9_LogEntry__setError;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__LogEntry._setGeneric = (void(*)(void))__pyx_f_4lxml_5etree_9_LogEntry__setGeneric;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__LogEntry) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__LogEntry.tp_dict, __pyx_vtabptr_4lxml_5etree__LogEntry) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_LogEntry", (PyObject *)&__pyx_type_4lxml_5etree__LogEntry) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__LogEntry = &__pyx_type_4lxml_5etree__LogEntry;
  __pyx_vtabptr_4lxml_5etree__BaseErrorLog = &__pyx_vtable_4lxml_5etree__BaseErrorLog;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseErrorLog._receive = (void(*)(void))__pyx_f_4lxml_5etree_13_BaseErrorLog__receive;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseErrorLog._receiveGeneric = (void(*)(void))__pyx_f_4lxml_5etree_13_BaseErrorLog__receiveGeneric;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseErrorLog._buildParseException = (void(*)(void))__pyx_f_4lxml_5etree_13_BaseErrorLog__buildParseException;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseErrorLog._buildExceptionMessage = (void(*)(void))__pyx_f_4lxml_5etree_13_BaseErrorLog__buildExceptionMessage;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__BaseErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__BaseErrorLog.tp_dict, __pyx_vtabptr_4lxml_5etree__BaseErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_BaseErrorLog", (PyObject *)&__pyx_type_4lxml_5etree__BaseErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__BaseErrorLog = &__pyx_type_4lxml_5etree__BaseErrorLog;
  __pyx_vtabptr_4lxml_5etree__ListErrorLog = &__pyx_vtable_4lxml_5etree__ListErrorLog;
  __pyx_vtable_4lxml_5etree__ListErrorLog.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseErrorLog;
  __pyx_type_4lxml_5etree__ListErrorLog.tp_base = __pyx_ptype_4lxml_5etree__BaseErrorLog;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ListErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ListErrorLog.tp_dict, __pyx_vtabptr_4lxml_5etree__ListErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ListErrorLog", (PyObject *)&__pyx_type_4lxml_5etree__ListErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ListErrorLog = &__pyx_type_4lxml_5etree__ListErrorLog;
  __pyx_vtabptr_4lxml_5etree__ErrorLog = &__pyx_vtable_4lxml_5etree__ErrorLog;
  __pyx_vtable_4lxml_5etree__ErrorLog.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ListErrorLog;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ErrorLog.connect = (void(*)(void))__pyx_f_4lxml_5etree_9_ErrorLog_connect;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ErrorLog.disconnect = (void(*)(void))__pyx_f_4lxml_5etree_9_ErrorLog_disconnect;
  __pyx_type_4lxml_5etree__ErrorLog.tp_base = __pyx_ptype_4lxml_5etree__ListErrorLog;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ErrorLog.tp_dict, __pyx_vtabptr_4lxml_5etree__ErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ErrorLog", (PyObject *)&__pyx_type_4lxml_5etree__ErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ErrorLog = &__pyx_type_4lxml_5etree__ErrorLog;
  __pyx_vtabptr_4lxml_5etree__DomainErrorLog = &__pyx_vtable_4lxml_5etree__DomainErrorLog;
  __pyx_vtable_4lxml_5etree__DomainErrorLog.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ErrorLog;
  __pyx_type_4lxml_5etree__DomainErrorLog.tp_base = __pyx_ptype_4lxml_5etree__ErrorLog;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__DomainErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__DomainErrorLog.tp_dict, __pyx_vtabptr_4lxml_5etree__DomainErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_DomainErrorLog", (PyObject *)&__pyx_type_4lxml_5etree__DomainErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__DomainErrorLog = &__pyx_type_4lxml_5etree__DomainErrorLog;
  __pyx_vtabptr_4lxml_5etree__RotatingErrorLog = &__pyx_vtable_4lxml_5etree__RotatingErrorLog;
  __pyx_vtable_4lxml_5etree__RotatingErrorLog.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ErrorLog;
  __pyx_type_4lxml_5etree__RotatingErrorLog.tp_base = __pyx_ptype_4lxml_5etree__ErrorLog;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__RotatingErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__RotatingErrorLog.tp_dict, __pyx_vtabptr_4lxml_5etree__RotatingErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_RotatingErrorLog", (PyObject *)&__pyx_type_4lxml_5etree__RotatingErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__RotatingErrorLog = &__pyx_type_4lxml_5etree__RotatingErrorLog;
  __pyx_vtabptr_4lxml_5etree_PyErrorLog = &__pyx_vtable_4lxml_5etree_PyErrorLog;
  __pyx_vtable_4lxml_5etree_PyErrorLog.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseErrorLog;
  __pyx_type_4lxml_5etree_PyErrorLog.tp_base = __pyx_ptype_4lxml_5etree__BaseErrorLog;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_PyErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_PyErrorLog.tp_dict, __pyx_vtabptr_4lxml_5etree_PyErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "PyErrorLog", (PyObject *)&__pyx_type_4lxml_5etree_PyErrorLog) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_PyErrorLog = &__pyx_type_4lxml_5etree_PyErrorLog;
  __pyx_vtabptr_4lxml_5etree__ReadOnlyElementProxy = &__pyx_vtable_4lxml_5etree__ReadOnlyElementProxy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ReadOnlyElementProxy._assertNode = (void(*)(void))__pyx_f_4lxml_5etree_21_ReadOnlyElementProxy__assertNode;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ReadOnlyElementProxy.free_after_use = (void(*)(void))__pyx_f_4lxml_5etree_21_ReadOnlyElementProxy_free_after_use;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ReadOnlyElementProxy.getchildren = (void(*)(void))__pyx_f_4lxml_5etree_21_ReadOnlyElementProxy_getchildren;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ReadOnlyElementProxy) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ReadOnlyElementProxy.tp_dict, __pyx_vtabptr_4lxml_5etree__ReadOnlyElementProxy) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ReadOnlyElementProxy", (PyObject *)&__pyx_type_4lxml_5etree__ReadOnlyElementProxy) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy = &__pyx_type_4lxml_5etree__ReadOnlyElementProxy;
  __pyx_vtabptr_4lxml_5etree__AppendOnlyElementProxy = &__pyx_vtable_4lxml_5etree__AppendOnlyElementProxy;
  __pyx_vtable_4lxml_5etree__AppendOnlyElementProxy.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ReadOnlyElementProxy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__AppendOnlyElementProxy.append = (void(*)(void))__pyx_f_4lxml_5etree_23_AppendOnlyElementProxy_append;
  __pyx_type_4lxml_5etree__AppendOnlyElementProxy.tp_base = __pyx_ptype_4lxml_5etree__ReadOnlyElementProxy;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__AppendOnlyElementProxy) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__AppendOnlyElementProxy.tp_dict, __pyx_vtabptr_4lxml_5etree__AppendOnlyElementProxy) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_AppendOnlyElementProxy", (PyObject *)&__pyx_type_4lxml_5etree__AppendOnlyElementProxy) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__AppendOnlyElementProxy = &__pyx_type_4lxml_5etree__AppendOnlyElementProxy;
  LxmlElementBaseType.tp_base = __pyx_ptype_4lxml_5etree__Element;
  if (PyType_Ready(&LxmlElementBaseType) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementBase", (PyObject *)&LxmlElementBaseType) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementBase = &LxmlElementBaseType;
  __pyx_vtabptr_4lxml_5etree_CommentBase = &__pyx_vtable_4lxml_5etree_CommentBase;
  __pyx_vtable_4lxml_5etree_CommentBase.__pyx_base = *__pyx_vtabptr_4lxml_5etree__Comment;
  __pyx_type_4lxml_5etree_CommentBase.tp_base = __pyx_ptype_4lxml_5etree__Comment;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_CommentBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_CommentBase.tp_dict, __pyx_vtabptr_4lxml_5etree_CommentBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "CommentBase", (PyObject *)&__pyx_type_4lxml_5etree_CommentBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_CommentBase = &__pyx_type_4lxml_5etree_CommentBase;
  __pyx_vtabptr_4lxml_5etree_PIBase = &__pyx_vtable_4lxml_5etree_PIBase;
  __pyx_vtable_4lxml_5etree_PIBase.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ProcessingInstruction;
  __pyx_type_4lxml_5etree_PIBase.tp_base = __pyx_ptype_4lxml_5etree__ProcessingInstruction;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_PIBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_PIBase.tp_dict, __pyx_vtabptr_4lxml_5etree_PIBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "PIBase", (PyObject *)&__pyx_type_4lxml_5etree_PIBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_PIBase = &__pyx_type_4lxml_5etree_PIBase;
  __pyx_vtabptr_4lxml_5etree_EntityBase = &__pyx_vtable_4lxml_5etree_EntityBase;
  __pyx_vtable_4lxml_5etree_EntityBase.__pyx_base = *__pyx_vtabptr_4lxml_5etree__Entity;
  __pyx_type_4lxml_5etree_EntityBase.tp_base = __pyx_ptype_4lxml_5etree__Entity;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_EntityBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_EntityBase.tp_dict, __pyx_vtabptr_4lxml_5etree_EntityBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "EntityBase", (PyObject *)&__pyx_type_4lxml_5etree_EntityBase) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_EntityBase = &__pyx_type_4lxml_5etree_EntityBase;
  if (PyType_Ready(&LxmlElementClassLookupType) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementClassLookup", (PyObject *)&LxmlElementClassLookupType) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementClassLookup = &LxmlElementClassLookupType;
  __pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup = &__pyx_vtable_4lxml_5etree_FallbackElementClassLookup;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_FallbackElementClassLookup._setFallback = (void(*)(void))__pyx_f_4lxml_5etree_26FallbackElementClassLookup__setFallback;
  LxmlFallbackElementClassLookupType.tp_base = __pyx_ptype_4lxml_5etree_ElementClassLookup;
  if (PyType_Ready(&LxmlFallbackElementClassLookupType) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(LxmlFallbackElementClassLookupType.tp_dict, __pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "FallbackElementClassLookup", (PyObject *)&LxmlFallbackElementClassLookupType) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_FallbackElementClassLookup = &LxmlFallbackElementClassLookupType;
  __pyx_type_4lxml_5etree_ElementDefaultClassLookup.tp_base = __pyx_ptype_4lxml_5etree_ElementClassLookup;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ElementDefaultClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementDefaultClassLookup", (PyObject *)&__pyx_type_4lxml_5etree_ElementDefaultClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementDefaultClassLookup = &__pyx_type_4lxml_5etree_ElementDefaultClassLookup;
  __pyx_vtabptr_4lxml_5etree_AttributeBasedElementClassLookup = &__pyx_vtable_4lxml_5etree_AttributeBasedElementClassLookup;
  __pyx_vtable_4lxml_5etree_AttributeBasedElementClassLookup.__pyx_base = *__pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;
  __pyx_type_4lxml_5etree_AttributeBasedElementClassLookup.tp_base = __pyx_ptype_4lxml_5etree_FallbackElementClassLookup;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_AttributeBasedElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_AttributeBasedElementClassLookup.tp_dict, __pyx_vtabptr_4lxml_5etree_AttributeBasedElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "AttributeBasedElementClassLookup", (PyObject *)&__pyx_type_4lxml_5etree_AttributeBasedElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_AttributeBasedElementClassLookup = &__pyx_type_4lxml_5etree_AttributeBasedElementClassLookup;
  __pyx_vtabptr_4lxml_5etree_ParserBasedElementClassLookup = &__pyx_vtable_4lxml_5etree_ParserBasedElementClassLookup;
  __pyx_vtable_4lxml_5etree_ParserBasedElementClassLookup.__pyx_base = *__pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;
  __pyx_type_4lxml_5etree_ParserBasedElementClassLookup.tp_base = __pyx_ptype_4lxml_5etree_FallbackElementClassLookup;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ParserBasedElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_ParserBasedElementClassLookup.tp_dict, __pyx_vtabptr_4lxml_5etree_ParserBasedElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ParserBasedElementClassLookup", (PyObject *)&__pyx_type_4lxml_5etree_ParserBasedElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ParserBasedElementClassLookup = &__pyx_type_4lxml_5etree_ParserBasedElementClassLookup;
  __pyx_vtabptr_4lxml_5etree_CustomElementClassLookup = &__pyx_vtable_4lxml_5etree_CustomElementClassLookup;
  __pyx_vtable_4lxml_5etree_CustomElementClassLookup.__pyx_base = *__pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;
  __pyx_type_4lxml_5etree_CustomElementClassLookup.tp_base = __pyx_ptype_4lxml_5etree_FallbackElementClassLookup;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_CustomElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_CustomElementClassLookup.tp_dict, __pyx_vtabptr_4lxml_5etree_CustomElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "CustomElementClassLookup", (PyObject *)&__pyx_type_4lxml_5etree_CustomElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_CustomElementClassLookup = &__pyx_type_4lxml_5etree_CustomElementClassLookup;
  __pyx_vtabptr_4lxml_5etree_PythonElementClassLookup = &__pyx_vtable_4lxml_5etree_PythonElementClassLookup;
  __pyx_vtable_4lxml_5etree_PythonElementClassLookup.__pyx_base = *__pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;
  __pyx_type_4lxml_5etree_PythonElementClassLookup.tp_base = __pyx_ptype_4lxml_5etree_FallbackElementClassLookup;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_PythonElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_PythonElementClassLookup.tp_dict, __pyx_vtabptr_4lxml_5etree_PythonElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "PythonElementClassLookup", (PyObject *)&__pyx_type_4lxml_5etree_PythonElementClassLookup) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_PythonElementClassLookup = &__pyx_type_4lxml_5etree_PythonElementClassLookup;
  __pyx_vtabptr_4lxml_5etree__NamespaceRegistry = &__pyx_vtable_4lxml_5etree__NamespaceRegistry;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__NamespaceRegistry._get = (void(*)(void))__pyx_f_4lxml_5etree_18_NamespaceRegistry__get;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__NamespaceRegistry._getForString = (void(*)(void))__pyx_f_4lxml_5etree_18_NamespaceRegistry__getForString;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__NamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__NamespaceRegistry.tp_dict, __pyx_vtabptr_4lxml_5etree__NamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_NamespaceRegistry", (PyObject *)&__pyx_type_4lxml_5etree__NamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__NamespaceRegistry = &__pyx_type_4lxml_5etree__NamespaceRegistry;
  __pyx_vtabptr_4lxml_5etree__ClassNamespaceRegistry = &__pyx_vtable_4lxml_5etree__ClassNamespaceRegistry;
  __pyx_vtable_4lxml_5etree__ClassNamespaceRegistry.__pyx_base = *__pyx_vtabptr_4lxml_5etree__NamespaceRegistry;
  __pyx_type_4lxml_5etree__ClassNamespaceRegistry.tp_base = __pyx_ptype_4lxml_5etree__NamespaceRegistry;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ClassNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ClassNamespaceRegistry.tp_dict, __pyx_vtabptr_4lxml_5etree__ClassNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ClassNamespaceRegistry", (PyObject *)&__pyx_type_4lxml_5etree__ClassNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ClassNamespaceRegistry = &__pyx_type_4lxml_5etree__ClassNamespaceRegistry;
  __pyx_vtabptr_4lxml_5etree_ElementNamespaceClassLookup = &__pyx_vtable_4lxml_5etree_ElementNamespaceClassLookup;
  __pyx_vtable_4lxml_5etree_ElementNamespaceClassLookup.__pyx_base = *__pyx_vtabptr_4lxml_5etree_FallbackElementClassLookup;
  __pyx_type_4lxml_5etree_ElementNamespaceClassLookup.tp_base = __pyx_ptype_4lxml_5etree_FallbackElementClassLookup;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ElementNamespaceClassLookup) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_ElementNamespaceClassLookup.tp_dict, __pyx_vtabptr_4lxml_5etree_ElementNamespaceClassLookup) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ElementNamespaceClassLookup", (PyObject *)&__pyx_type_4lxml_5etree_ElementNamespaceClassLookup) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ElementNamespaceClassLookup = &__pyx_type_4lxml_5etree_ElementNamespaceClassLookup;
  __pyx_vtabptr_4lxml_5etree__FunctionNamespaceRegistry = &__pyx_vtable_4lxml_5etree__FunctionNamespaceRegistry;
  __pyx_vtable_4lxml_5etree__FunctionNamespaceRegistry.__pyx_base = *__pyx_vtabptr_4lxml_5etree__NamespaceRegistry;
  __pyx_type_4lxml_5etree__FunctionNamespaceRegistry.tp_base = __pyx_ptype_4lxml_5etree__NamespaceRegistry;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__FunctionNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__FunctionNamespaceRegistry.tp_dict, __pyx_vtabptr_4lxml_5etree__FunctionNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_FunctionNamespaceRegistry", (PyObject *)&__pyx_type_4lxml_5etree__FunctionNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__FunctionNamespaceRegistry = &__pyx_type_4lxml_5etree__FunctionNamespaceRegistry;
  __pyx_vtabptr_4lxml_5etree__XPathFunctionNamespaceRegistry = &__pyx_vtable_4lxml_5etree__XPathFunctionNamespaceRegistry;
  __pyx_vtable_4lxml_5etree__XPathFunctionNamespaceRegistry.__pyx_base = *__pyx_vtabptr_4lxml_5etree__FunctionNamespaceRegistry;
  __pyx_type_4lxml_5etree__XPathFunctionNamespaceRegistry.tp_base = __pyx_ptype_4lxml_5etree__FunctionNamespaceRegistry;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XPathFunctionNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XPathFunctionNamespaceRegistry.tp_dict, __pyx_vtabptr_4lxml_5etree__XPathFunctionNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XPathFunctionNamespaceRegistry", (PyObject *)&__pyx_type_4lxml_5etree__XPathFunctionNamespaceRegistry) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XPathFunctionNamespaceRegistry = &__pyx_type_4lxml_5etree__XPathFunctionNamespaceRegistry;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__InputDocument) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_InputDocument", (PyObject *)&__pyx_type_4lxml_5etree__InputDocument) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__InputDocument = &__pyx_type_4lxml_5etree__InputDocument;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_Resolver) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "Resolver", (PyObject *)&__pyx_type_4lxml_5etree_Resolver) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_Resolver = &__pyx_type_4lxml_5etree_Resolver;
  __pyx_vtabptr_4lxml_5etree__ResolverRegistry = &__pyx_vtable_4lxml_5etree__ResolverRegistry;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ResolverRegistry._copy = (void(*)(void))__pyx_f_4lxml_5etree_17_ResolverRegistry__copy;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ResolverRegistry) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ResolverRegistry.tp_dict, __pyx_vtabptr_4lxml_5etree__ResolverRegistry) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ResolverRegistry", (PyObject *)&__pyx_type_4lxml_5etree__ResolverRegistry) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ResolverRegistry = &__pyx_type_4lxml_5etree__ResolverRegistry;
  __pyx_vtabptr_4lxml_5etree__ResolverContext = &__pyx_vtable_4lxml_5etree__ResolverContext;
  __pyx_vtable_4lxml_5etree__ResolverContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ExceptionContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ResolverContext.__pyx_base.clear = (void(*)(void))__pyx_f_4lxml_5etree_16_ResolverContext_clear;
  __pyx_type_4lxml_5etree__ResolverContext.tp_base = __pyx_ptype_4lxml_5etree__ExceptionContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ResolverContext) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ResolverContext.tp_dict, __pyx_vtabptr_4lxml_5etree__ResolverContext) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ResolverContext", (PyObject *)&__pyx_type_4lxml_5etree__ResolverContext) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ResolverContext = &__pyx_type_4lxml_5etree__ResolverContext;
  __pyx_vtabptr_4lxml_5etree__ParserContext = &__pyx_vtable_4lxml_5etree__ParserContext;
  __pyx_vtable_4lxml_5etree__ParserContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ResolverContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext._copy = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext__copy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext._initParserContext = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext__initParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext._resetParserContext = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext__resetParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext.prepare = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext_prepare;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext.cleanup = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext_cleanup;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext._handleParseResult = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext__handleParseResult;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserContext._handleParseResultDoc = (void(*)(void))__pyx_f_4lxml_5etree_14_ParserContext__handleParseResultDoc;
  __pyx_type_4lxml_5etree__ParserContext.tp_base = __pyx_ptype_4lxml_5etree__ResolverContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ParserContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ParserContext.tp_dict, __pyx_vtabptr_4lxml_5etree__ParserContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ParserContext", (PyObject *)&__pyx_type_4lxml_5etree__ParserContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ParserContext = &__pyx_type_4lxml_5etree__ParserContext;
  __pyx_vtabptr_4lxml_5etree__SaxParserContext = &__pyx_vtable_4lxml_5etree__SaxParserContext;
  __pyx_vtable_4lxml_5etree__SaxParserContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserContext.__pyx_base._initParserContext = (void(*)(void))__pyx_f_4lxml_5etree_17_SaxParserContext__initParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserContext._setSaxParserTarget = (void(*)(void))__pyx_f_4lxml_5etree_17_SaxParserContext__setSaxParserTarget;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserContext._handleSaxException = (void(*)(void))__pyx_f_4lxml_5etree_17_SaxParserContext__handleSaxException;
  __pyx_type_4lxml_5etree__SaxParserContext.tp_base = __pyx_ptype_4lxml_5etree__ParserContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__SaxParserContext) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__SaxParserContext.tp_dict, __pyx_vtabptr_4lxml_5etree__SaxParserContext) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_SaxParserContext", (PyObject *)&__pyx_type_4lxml_5etree__SaxParserContext) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__SaxParserContext = &__pyx_type_4lxml_5etree__SaxParserContext;
  __pyx_vtabptr_4lxml_5etree__TargetParserContext = &__pyx_vtable_4lxml_5etree__TargetParserContext;
  __pyx_vtable_4lxml_5etree__TargetParserContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__SaxParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__TargetParserContext.__pyx_base.__pyx_base._copy = (void(*)(void))__pyx_f_4lxml_5etree_20_TargetParserContext__copy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__TargetParserContext.__pyx_base.__pyx_base._handleParseResult = (void(*)(void))__pyx_f_4lxml_5etree_20_TargetParserContext__handleParseResult;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__TargetParserContext.__pyx_base.__pyx_base._handleParseResultDoc = (void(*)(void))__pyx_f_4lxml_5etree_20_TargetParserContext__handleParseResultDoc;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__TargetParserContext._setTarget = (void(*)(void))__pyx_f_4lxml_5etree_20_TargetParserContext__setTarget;
  __pyx_type_4lxml_5etree__TargetParserContext.tp_base = __pyx_ptype_4lxml_5etree__SaxParserContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__TargetParserContext) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__TargetParserContext.tp_dict, __pyx_vtabptr_4lxml_5etree__TargetParserContext) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_TargetParserContext", (PyObject *)&__pyx_type_4lxml_5etree__TargetParserContext) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__TargetParserContext = &__pyx_type_4lxml_5etree__TargetParserContext;
  __pyx_vtabptr_4lxml_5etree__ParserSchemaValidationContext = &__pyx_vtable_4lxml_5etree__ParserSchemaValidationContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserSchemaValidationContext.copy = (void(*)(void))__pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_copy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserSchemaValidationContext.connect = (void(*)(void))__pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_connect;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserSchemaValidationContext.disconnect = (void(*)(void))__pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_disconnect;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserSchemaValidationContext.isvalid = (void(*)(void))__pyx_f_4lxml_5etree_30_ParserSchemaValidationContext_isvalid;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ParserSchemaValidationContext) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ParserSchemaValidationContext.tp_dict, __pyx_vtabptr_4lxml_5etree__ParserSchemaValidationContext) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ParserSchemaValidationContext", (PyObject *)&__pyx_type_4lxml_5etree__ParserSchemaValidationContext) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ParserSchemaValidationContext = &__pyx_type_4lxml_5etree__ParserSchemaValidationContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__Validator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_Validator", (PyObject *)&__pyx_type_4lxml_5etree__Validator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__Validator = &__pyx_type_4lxml_5etree__Validator;
  __pyx_vtabptr_4lxml_5etree_XMLSchema = &__pyx_vtable_4lxml_5etree_XMLSchema;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_XMLSchema._newSaxValidator = (void(*)(void))__pyx_f_4lxml_5etree_9XMLSchema__newSaxValidator;
  __pyx_type_4lxml_5etree_XMLSchema.tp_base = __pyx_ptype_4lxml_5etree__Validator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XMLSchema) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XMLSchema.tp_dict, __pyx_vtabptr_4lxml_5etree_XMLSchema) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XMLSchema", (PyObject *)&__pyx_type_4lxml_5etree_XMLSchema) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XMLSchema = &__pyx_type_4lxml_5etree_XMLSchema;
  __pyx_vtabptr_4lxml_5etree__ParserDictionaryContext = &__pyx_vtable_4lxml_5etree__ParserDictionaryContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.initMainParserContext = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_initMainParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext._findThreadParserContext = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext__findThreadParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.setDefaultParser = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_setDefaultParser;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.getDefaultParser = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_getDefaultParser;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext._getThreadDict = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext__getThreadDict;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.initThreadDictRef = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_initThreadDictRef;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.initParserDict = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_initParserDict;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.initXPathParserDict = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_initXPathParserDict;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.initDocDict = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_initDocDict;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.findImpliedContext = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_findImpliedContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.pushImpliedContextFromParser = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_pushImpliedContextFromParser;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.pushImpliedContext = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_pushImpliedContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ParserDictionaryContext.popImpliedContext = (void(*)(void))__pyx_f_4lxml_5etree_24_ParserDictionaryContext_popImpliedContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ParserDictionaryContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ParserDictionaryContext.tp_dict, __pyx_vtabptr_4lxml_5etree__ParserDictionaryContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ParserDictionaryContext", (PyObject *)&__pyx_type_4lxml_5etree__ParserDictionaryContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ParserDictionaryContext = &__pyx_type_4lxml_5etree__ParserDictionaryContext;
  __pyx_vtabptr_4lxml_5etree__FileReaderContext = &__pyx_vtable_4lxml_5etree__FileReaderContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FileReaderContext._createParserInputBuffer = (void(*)(void))__pyx_f_4lxml_5etree_18_FileReaderContext__createParserInputBuffer;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FileReaderContext._createParserInput = (void(*)(void))__pyx_f_4lxml_5etree_18_FileReaderContext__createParserInput;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FileReaderContext._readDtd = (void(*)(void))__pyx_f_4lxml_5etree_18_FileReaderContext__readDtd;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FileReaderContext._readDoc = (void(*)(void))__pyx_f_4lxml_5etree_18_FileReaderContext__readDoc;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FileReaderContext.copyToBuffer = (void(*)(void))__pyx_f_4lxml_5etree_18_FileReaderContext_copyToBuffer;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__FileReaderContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__FileReaderContext.tp_dict, __pyx_vtabptr_4lxml_5etree__FileReaderContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_FileReaderContext", (PyObject *)&__pyx_type_4lxml_5etree__FileReaderContext) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__FileReaderContext = &__pyx_type_4lxml_5etree__FileReaderContext;
  __pyx_vtabptr_4lxml_5etree__FeedParser = &__pyx_vtable_4lxml_5etree__FeedParser;
  __pyx_vtable_4lxml_5etree__FeedParser.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseParser;
  __pyx_type_4lxml_5etree__FeedParser.tp_base = __pyx_ptype_4lxml_5etree__BaseParser;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__FeedParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__FeedParser.tp_dict, __pyx_vtabptr_4lxml_5etree__FeedParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_FeedParser", (PyObject *)&__pyx_type_4lxml_5etree__FeedParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__FeedParser = &__pyx_type_4lxml_5etree__FeedParser;
  __pyx_vtabptr_4lxml_5etree_XMLParser = &__pyx_vtable_4lxml_5etree_XMLParser;
  __pyx_vtable_4lxml_5etree_XMLParser.__pyx_base = *__pyx_vtabptr_4lxml_5etree__FeedParser;
  __pyx_type_4lxml_5etree_XMLParser.tp_base = __pyx_ptype_4lxml_5etree__FeedParser;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XMLParser.tp_dict, __pyx_vtabptr_4lxml_5etree_XMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XMLParser", (PyObject *)&__pyx_type_4lxml_5etree_XMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XMLParser = &__pyx_type_4lxml_5etree_XMLParser;
  __pyx_vtabptr_4lxml_5etree_ETCompatXMLParser = &__pyx_vtable_4lxml_5etree_ETCompatXMLParser;
  __pyx_vtable_4lxml_5etree_ETCompatXMLParser.__pyx_base = *__pyx_vtabptr_4lxml_5etree_XMLParser;
  __pyx_type_4lxml_5etree_ETCompatXMLParser.tp_base = __pyx_ptype_4lxml_5etree_XMLParser;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ETCompatXMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_ETCompatXMLParser.tp_dict, __pyx_vtabptr_4lxml_5etree_ETCompatXMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ETCompatXMLParser", (PyObject *)&__pyx_type_4lxml_5etree_ETCompatXMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ETCompatXMLParser = &__pyx_type_4lxml_5etree_ETCompatXMLParser;
  __pyx_vtabptr_4lxml_5etree_HTMLParser = &__pyx_vtable_4lxml_5etree_HTMLParser;
  __pyx_vtable_4lxml_5etree_HTMLParser.__pyx_base = *__pyx_vtabptr_4lxml_5etree__FeedParser;
  __pyx_type_4lxml_5etree_HTMLParser.tp_base = __pyx_ptype_4lxml_5etree__FeedParser;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_HTMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_HTMLParser.tp_dict, __pyx_vtabptr_4lxml_5etree_HTMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "HTMLParser", (PyObject *)&__pyx_type_4lxml_5etree_HTMLParser) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_HTMLParser = &__pyx_type_4lxml_5etree_HTMLParser;
  __pyx_vtabptr_4lxml_5etree__SaxParserTarget = &__pyx_vtable_4lxml_5etree__SaxParserTarget;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserTarget._handleSaxStart = (void(*)(void))__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxStart;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserTarget._handleSaxEnd = (void(*)(void))__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxEnd;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserTarget._handleSaxData = (void(*)(void))__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxData;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserTarget._handleSaxDoctype = (void(*)(void))__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxDoctype;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserTarget._handleSaxPi = (void(*)(void))__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxPi;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__SaxParserTarget._handleSaxComment = (void(*)(void))__pyx_f_4lxml_5etree_16_SaxParserTarget__handleSaxComment;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__SaxParserTarget) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__SaxParserTarget.tp_dict, __pyx_vtabptr_4lxml_5etree__SaxParserTarget) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_SaxParserTarget", (PyObject *)&__pyx_type_4lxml_5etree__SaxParserTarget) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__SaxParserTarget = &__pyx_type_4lxml_5etree__SaxParserTarget;
  __pyx_vtabptr_4lxml_5etree_TreeBuilder = &__pyx_vtable_4lxml_5etree_TreeBuilder;
  __pyx_vtable_4lxml_5etree_TreeBuilder.__pyx_base = *__pyx_vtabptr_4lxml_5etree__SaxParserTarget;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_TreeBuilder.__pyx_base._handleSaxStart = (void(*)(void))__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxStart;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_TreeBuilder.__pyx_base._handleSaxEnd = (void(*)(void))__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxEnd;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_TreeBuilder.__pyx_base._handleSaxData = (void(*)(void))__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxData;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_TreeBuilder.__pyx_base._handleSaxPi = (void(*)(void))__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxPi;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_TreeBuilder.__pyx_base._handleSaxComment = (void(*)(void))__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxComment;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_TreeBuilder._flush = (void(*)(void))__pyx_f_4lxml_5etree_11TreeBuilder__flush;
  __pyx_type_4lxml_5etree_TreeBuilder.tp_base = __pyx_ptype_4lxml_5etree__SaxParserTarget;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_TreeBuilder) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_TreeBuilder.tp_dict, __pyx_vtabptr_4lxml_5etree_TreeBuilder) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "TreeBuilder", (PyObject *)&__pyx_type_4lxml_5etree_TreeBuilder) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_TreeBuilder = &__pyx_type_4lxml_5etree_TreeBuilder;
  __pyx_vtabptr_4lxml_5etree__PythonSaxParserTarget = &__pyx_vtable_4lxml_5etree__PythonSaxParserTarget;
  __pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base = *__pyx_vtabptr_4lxml_5etree__SaxParserTarget;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base._handleSaxStart = (void(*)(void))__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxStart;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base._handleSaxEnd = (void(*)(void))__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxEnd;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base._handleSaxData = (void(*)(void))__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxData;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base._handleSaxDoctype = (void(*)(void))__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxDoctype;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base._handleSaxPi = (void(*)(void))__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxPi;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__PythonSaxParserTarget.__pyx_base._handleSaxComment = (void(*)(void))__pyx_f_4lxml_5etree_22_PythonSaxParserTarget__handleSaxComment;
  __pyx_type_4lxml_5etree__PythonSaxParserTarget.tp_base = __pyx_ptype_4lxml_5etree__SaxParserTarget;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__PythonSaxParserTarget) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__PythonSaxParserTarget.tp_dict, __pyx_vtabptr_4lxml_5etree__PythonSaxParserTarget) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_PythonSaxParserTarget", (PyObject *)&__pyx_type_4lxml_5etree__PythonSaxParserTarget) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__PythonSaxParserTarget = &__pyx_type_4lxml_5etree__PythonSaxParserTarget;
  __pyx_vtabptr_4lxml_5etree__FilelikeWriter = &__pyx_vtable_4lxml_5etree__FilelikeWriter;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FilelikeWriter._createOutputBuffer = (void(*)(void))__pyx_f_4lxml_5etree_15_FilelikeWriter__createOutputBuffer;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FilelikeWriter.write = (void(*)(void))__pyx_f_4lxml_5etree_15_FilelikeWriter_write;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__FilelikeWriter.close = (void(*)(void))__pyx_f_4lxml_5etree_15_FilelikeWriter_close;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__FilelikeWriter) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__FilelikeWriter.tp_dict, __pyx_vtabptr_4lxml_5etree__FilelikeWriter) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_FilelikeWriter", (PyObject *)&__pyx_type_4lxml_5etree__FilelikeWriter) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__FilelikeWriter = &__pyx_type_4lxml_5etree__FilelikeWriter;
  __pyx_vtabptr_4lxml_5etree__IterparseContext = &__pyx_vtable_4lxml_5etree__IterparseContext;
  __pyx_vtable_4lxml_5etree__IterparseContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IterparseContext.__pyx_base._initParserContext = (void(*)(void))__pyx_f_4lxml_5etree_17_IterparseContext__initParserContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IterparseContext._setEventFilter = (void(*)(void))__pyx_f_4lxml_5etree_17_IterparseContext__setEventFilter;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IterparseContext.startNode = (void(*)(void))__pyx_f_4lxml_5etree_17_IterparseContext_startNode;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IterparseContext.endNode = (void(*)(void))__pyx_f_4lxml_5etree_17_IterparseContext_endNode;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IterparseContext.pushEvent = (void(*)(void))__pyx_f_4lxml_5etree_17_IterparseContext_pushEvent;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IterparseContext._assureDocGetsFreed = (void(*)(void))__pyx_f_4lxml_5etree_17_IterparseContext__assureDocGetsFreed;
  __pyx_type_4lxml_5etree__IterparseContext.tp_base = __pyx_ptype_4lxml_5etree__ParserContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__IterparseContext) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__IterparseContext.tp_dict, __pyx_vtabptr_4lxml_5etree__IterparseContext) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_IterparseContext", (PyObject *)&__pyx_type_4lxml_5etree__IterparseContext) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__IterparseContext = &__pyx_type_4lxml_5etree__IterparseContext;
  __pyx_vtabptr_4lxml_5etree_iterparse = &__pyx_vtable_4lxml_5etree_iterparse;
  __pyx_vtable_4lxml_5etree_iterparse.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseParser;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_iterparse.__pyx_base._createContext = (void(*)(void))__pyx_f_4lxml_5etree_9iterparse__createContext;
  __pyx_type_4lxml_5etree_iterparse.tp_base = __pyx_ptype_4lxml_5etree__BaseParser;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_iterparse) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_iterparse.tp_dict, __pyx_vtabptr_4lxml_5etree_iterparse) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "iterparse", (PyObject *)&__pyx_type_4lxml_5etree_iterparse) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_iterparse = &__pyx_type_4lxml_5etree_iterparse;
  __pyx_vtabptr_4lxml_5etree_iterwalk = &__pyx_vtable_4lxml_5etree_iterwalk;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_iterwalk._setTagFilter = (void(*)(void))__pyx_f_4lxml_5etree_8iterwalk__setTagFilter;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_iterwalk._start_node = (void(*)(void))__pyx_f_4lxml_5etree_8iterwalk__start_node;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_iterwalk._end_node = (void(*)(void))__pyx_f_4lxml_5etree_8iterwalk__end_node;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_iterwalk) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_iterwalk.tp_dict, __pyx_vtabptr_4lxml_5etree_iterwalk) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "iterwalk", (PyObject *)&__pyx_type_4lxml_5etree_iterwalk) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_iterwalk = &__pyx_type_4lxml_5etree_iterwalk;
  __pyx_vtabptr_4lxml_5etree__IDDict = &__pyx_vtable_4lxml_5etree__IDDict;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IDDict._build_keys = (void(*)(void))__pyx_f_4lxml_5etree_7_IDDict__build_keys;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__IDDict._build_items = (void(*)(void))__pyx_f_4lxml_5etree_7_IDDict__build_items;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__IDDict) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__IDDict.tp_dict, __pyx_vtabptr_4lxml_5etree__IDDict) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_IDDict", (PyObject *)&__pyx_type_4lxml_5etree__IDDict) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__IDDict = &__pyx_type_4lxml_5etree__IDDict;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XInclude) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XInclude", (PyObject *)&__pyx_type_4lxml_5etree_XInclude) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XInclude = &__pyx_type_4lxml_5etree_XInclude;
  __pyx_vtabptr_4lxml_5etree__ExsltRegExp = &__pyx_vtable_4lxml_5etree__ExsltRegExp;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExsltRegExp._make_string = (void(*)(void))__pyx_f_4lxml_5etree_12_ExsltRegExp__make_string;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExsltRegExp._compile = (void(*)(void))__pyx_f_4lxml_5etree_12_ExsltRegExp__compile;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__ExsltRegExp._register_in_context = (void(*)(void))__pyx_f_4lxml_5etree_12_ExsltRegExp__register_in_context;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ExsltRegExp) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__ExsltRegExp.tp_dict, __pyx_vtabptr_4lxml_5etree__ExsltRegExp) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ExsltRegExp", (PyObject *)&__pyx_type_4lxml_5etree__ExsltRegExp) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ExsltRegExp = &__pyx_type_4lxml_5etree__ExsltRegExp;
  __pyx_vtabptr_4lxml_5etree__BaseContext = &__pyx_vtable_4lxml_5etree__BaseContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._copy = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__copy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._to_utf = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__to_utf;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._set_xpath_context = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__set_xpath_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._register_context = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__register_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._cleanup_context = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__cleanup_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._release_context = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__release_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.addNamespace = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_addNamespace;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.registerNamespace = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_registerNamespace;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.registerLocalNamespaces = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_registerLocalNamespaces;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.registerGlobalNamespaces = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_registerGlobalNamespaces;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.unregisterGlobalNamespaces = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_unregisterGlobalNamespaces;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._unregisterNamespace = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__unregisterNamespace;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._addLocalExtensionFunction = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__addLocalExtensionFunction;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.registerGlobalFunctions = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_registerGlobalFunctions;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.registerLocalFunctions = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_registerLocalFunctions;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.unregisterAllFunctions = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_unregisterAllFunctions;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext.unregisterGlobalFunctions = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext_unregisterGlobalFunctions;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._find_cached_function = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__find_cached_function;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._release_temp_refs = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__release_temp_refs;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__BaseContext._hold = (void(*)(void))__pyx_f_4lxml_5etree_12_BaseContext__hold;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__BaseContext) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__BaseContext.tp_dict, __pyx_vtabptr_4lxml_5etree__BaseContext) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_BaseContext", (PyObject *)&__pyx_type_4lxml_5etree__BaseContext) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__BaseContext = &__pyx_type_4lxml_5etree__BaseContext;
  #if PY_MAJOR_VERSION >= 3
  __pyx_ptype_4lxml_6python_unicode = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "str", sizeof(PyUnicodeObject)); if (unlikely(!__pyx_ptype_4lxml_6python_unicode)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_ptype_4lxml_6python_unicode = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "unicode", sizeof(PyUnicodeObject)); if (unlikely(!__pyx_ptype_4lxml_6python_unicode)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  __pyx_type_4lxml_5etree__ElementUnicodeResult.tp_base = __pyx_ptype_4lxml_6python_unicode;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__ElementUnicodeResult) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_ElementUnicodeResult", (PyObject *)&__pyx_type_4lxml_5etree__ElementUnicodeResult) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__ElementUnicodeResult = &__pyx_type_4lxml_5etree__ElementUnicodeResult;
  __pyx_vtabptr_4lxml_5etree__XPathContext = &__pyx_vtable_4lxml_5etree__XPathContext;
  __pyx_vtable_4lxml_5etree__XPathContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext.set_context = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext_set_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext.register_context = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext_register_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext.unregister_context = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext_unregister_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext.registerVariables = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext_registerVariables;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext.registerVariable = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext_registerVariable;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext._registerVariable = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext__registerVariable;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathContext._setupDict = (void(*)(void))__pyx_f_4lxml_5etree_13_XPathContext__setupDict;
  __pyx_type_4lxml_5etree__XPathContext.tp_base = __pyx_ptype_4lxml_5etree__BaseContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XPathContext) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XPathContext.tp_dict, __pyx_vtabptr_4lxml_5etree__XPathContext) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XPathContext", (PyObject *)&__pyx_type_4lxml_5etree__XPathContext) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XPathContext = &__pyx_type_4lxml_5etree__XPathContext;
  __pyx_vtabptr_4lxml_5etree__XPathEvaluatorBase = &__pyx_vtable_4lxml_5etree__XPathEvaluatorBase;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase.set_context = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase_set_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase._checkAbsolutePath = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__checkAbsolutePath;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase._lock = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__lock;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase._unlock = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__unlock;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase._raise_parse_error = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__raise_parse_error;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase._raise_eval_error = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__raise_eval_error;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XPathEvaluatorBase._handle_result = (void(*)(void))__pyx_f_4lxml_5etree_19_XPathEvaluatorBase__handle_result;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XPathEvaluatorBase) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XPathEvaluatorBase.tp_dict, __pyx_vtabptr_4lxml_5etree__XPathEvaluatorBase) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XPathEvaluatorBase", (PyObject *)&__pyx_type_4lxml_5etree__XPathEvaluatorBase) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XPathEvaluatorBase = &__pyx_type_4lxml_5etree__XPathEvaluatorBase;
  __pyx_vtabptr_4lxml_5etree_XPathElementEvaluator = &__pyx_vtable_4lxml_5etree_XPathElementEvaluator;
  __pyx_vtable_4lxml_5etree_XPathElementEvaluator.__pyx_base = *__pyx_vtabptr_4lxml_5etree__XPathEvaluatorBase;
  __pyx_type_4lxml_5etree_XPathElementEvaluator.tp_base = __pyx_ptype_4lxml_5etree__XPathEvaluatorBase;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XPathElementEvaluator) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XPathElementEvaluator.tp_dict, __pyx_vtabptr_4lxml_5etree_XPathElementEvaluator) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XPathElementEvaluator", (PyObject *)&__pyx_type_4lxml_5etree_XPathElementEvaluator) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XPathElementEvaluator = &__pyx_type_4lxml_5etree_XPathElementEvaluator;
  __pyx_vtabptr_4lxml_5etree_XPathDocumentEvaluator = &__pyx_vtable_4lxml_5etree_XPathDocumentEvaluator;
  __pyx_vtable_4lxml_5etree_XPathDocumentEvaluator.__pyx_base = *__pyx_vtabptr_4lxml_5etree_XPathElementEvaluator;
  __pyx_type_4lxml_5etree_XPathDocumentEvaluator.tp_base = __pyx_ptype_4lxml_5etree_XPathElementEvaluator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XPathDocumentEvaluator) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XPathDocumentEvaluator.tp_dict, __pyx_vtabptr_4lxml_5etree_XPathDocumentEvaluator) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XPathDocumentEvaluator", (PyObject *)&__pyx_type_4lxml_5etree_XPathDocumentEvaluator) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XPathDocumentEvaluator = &__pyx_type_4lxml_5etree_XPathDocumentEvaluator;
  __pyx_vtabptr_4lxml_5etree_XPath = &__pyx_vtable_4lxml_5etree_XPath;
  __pyx_vtable_4lxml_5etree_XPath.__pyx_base = *__pyx_vtabptr_4lxml_5etree__XPathEvaluatorBase;
  __pyx_type_4lxml_5etree_XPath.tp_base = __pyx_ptype_4lxml_5etree__XPathEvaluatorBase;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XPath) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XPath.tp_dict, __pyx_vtabptr_4lxml_5etree_XPath) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XPath", (PyObject *)&__pyx_type_4lxml_5etree_XPath) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XPath = &__pyx_type_4lxml_5etree_XPath;
  __pyx_vtabptr_4lxml_5etree_ETXPath = &__pyx_vtable_4lxml_5etree_ETXPath;
  __pyx_vtable_4lxml_5etree_ETXPath.__pyx_base = *__pyx_vtabptr_4lxml_5etree_XPath;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_ETXPath._nsextract_path = (void(*)(void))__pyx_f_4lxml_5etree_7ETXPath__nsextract_path;
  __pyx_type_4lxml_5etree_ETXPath.tp_base = __pyx_ptype_4lxml_5etree_XPath;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_ETXPath) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_ETXPath.tp_dict, __pyx_vtabptr_4lxml_5etree_ETXPath) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ETXPath", (PyObject *)&__pyx_type_4lxml_5etree_ETXPath) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_ETXPath = &__pyx_type_4lxml_5etree_ETXPath;
  __pyx_vtabptr_4lxml_5etree__XSLTResolverContext = &__pyx_vtable_4lxml_5etree__XSLTResolverContext;
  __pyx_vtable_4lxml_5etree__XSLTResolverContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ResolverContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XSLTResolverContext._copy = (void(*)(void))__pyx_f_4lxml_5etree_20_XSLTResolverContext__copy;
  __pyx_type_4lxml_5etree__XSLTResolverContext.tp_base = __pyx_ptype_4lxml_5etree__ResolverContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XSLTResolverContext) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XSLTResolverContext.tp_dict, __pyx_vtabptr_4lxml_5etree__XSLTResolverContext) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XSLTResolverContext", (PyObject *)&__pyx_type_4lxml_5etree__XSLTResolverContext) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XSLTResolverContext = &__pyx_type_4lxml_5etree__XSLTResolverContext;
  __pyx_vtabptr_4lxml_5etree_XSLTAccessControl = &__pyx_vtable_4lxml_5etree_XSLTAccessControl;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_XSLTAccessControl._setAccess = (void(*)(void))__pyx_f_4lxml_5etree_17XSLTAccessControl__setAccess;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_XSLTAccessControl._register_in_context = (void(*)(void))__pyx_f_4lxml_5etree_17XSLTAccessControl__register_in_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_XSLTAccessControl._optval = (void(*)(void))__pyx_f_4lxml_5etree_17XSLTAccessControl__optval;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XSLTAccessControl) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XSLTAccessControl.tp_dict, __pyx_vtabptr_4lxml_5etree_XSLTAccessControl) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XSLTAccessControl", (PyObject *)&__pyx_type_4lxml_5etree_XSLTAccessControl) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XSLTAccessControl = &__pyx_type_4lxml_5etree_XSLTAccessControl;
  __pyx_vtabptr_4lxml_5etree__XSLTContext = &__pyx_vtable_4lxml_5etree__XSLTContext;
  __pyx_vtable_4lxml_5etree__XSLTContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseContext;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XSLTContext.__pyx_base._copy = (void(*)(void))__pyx_f_4lxml_5etree_12_XSLTContext__copy;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XSLTContext.register_context = (void(*)(void))__pyx_f_4lxml_5etree_12_XSLTContext_register_context;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XSLTContext.free_context = (void(*)(void))__pyx_f_4lxml_5etree_12_XSLTContext_free_context;
  __pyx_type_4lxml_5etree__XSLTContext.tp_base = __pyx_ptype_4lxml_5etree__BaseContext;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XSLTContext) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XSLTContext.tp_dict, __pyx_vtabptr_4lxml_5etree__XSLTContext) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XSLTContext", (PyObject *)&__pyx_type_4lxml_5etree__XSLTContext) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XSLTContext = &__pyx_type_4lxml_5etree__XSLTContext;
  __pyx_vtabptr_4lxml_5etree_XSLT = &__pyx_vtable_4lxml_5etree_XSLT;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree_XSLT._run_transform = (void(*)(void))__pyx_f_4lxml_5etree_4XSLT__run_transform;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XSLT) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree_XSLT.tp_dict, __pyx_vtabptr_4lxml_5etree_XSLT) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XSLT", (PyObject *)&__pyx_type_4lxml_5etree_XSLT) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XSLT = &__pyx_type_4lxml_5etree_XSLT;
  __pyx_vtabptr_4lxml_5etree__XSLTResultTree = &__pyx_vtable_4lxml_5etree__XSLTResultTree;
  __pyx_vtable_4lxml_5etree__XSLTResultTree.__pyx_base = *__pyx_vtabptr_4lxml_5etree__ElementTree;
  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XSLTResultTree._saveToStringAndSize = (void(*)(void))__pyx_f_4lxml_5etree_15_XSLTResultTree__saveToStringAndSize;
  __pyx_type_4lxml_5etree__XSLTResultTree.tp_base = __pyx_ptype_4lxml_5etree__ElementTree;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XSLTResultTree) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XSLTResultTree.tp_dict, __pyx_vtabptr_4lxml_5etree__XSLTResultTree) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XSLTResultTree", (PyObject *)&__pyx_type_4lxml_5etree__XSLTResultTree) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XSLTResultTree = &__pyx_type_4lxml_5etree__XSLTResultTree;
  __pyx_vtabptr_4lxml_5etree__XSLTProcessingInstruction = &__pyx_vtable_4lxml_5etree__XSLTProcessingInstruction;
  __pyx_vtable_4lxml_5etree__XSLTProcessingInstruction.__pyx_base = *__pyx_vtabptr_4lxml_5etree_PIBase;
  __pyx_type_4lxml_5etree__XSLTProcessingInstruction.tp_base = __pyx_ptype_4lxml_5etree_PIBase;
  if (PyType_Ready(&__pyx_type_4lxml_5etree__XSLTProcessingInstruction) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4lxml_5etree__XSLTProcessingInstruction.tp_dict, __pyx_vtabptr_4lxml_5etree__XSLTProcessingInstruction) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "_XSLTProcessingInstruction", (PyObject *)&__pyx_type_4lxml_5etree__XSLTProcessingInstruction) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree__XSLTProcessingInstruction = &__pyx_type_4lxml_5etree__XSLTProcessingInstruction;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_XSLTExtension) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "XSLTExtension", (PyObject *)&__pyx_type_4lxml_5etree_XSLTExtension) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_XSLTExtension = &__pyx_type_4lxml_5etree_XSLTExtension;
  __pyx_type_4lxml_5etree_DTD.tp_base = __pyx_ptype_4lxml_5etree__Validator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_DTD) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "DTD", (PyObject *)&__pyx_type_4lxml_5etree_DTD) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_DTD = &__pyx_type_4lxml_5etree_DTD;
  __pyx_type_4lxml_5etree_RelaxNG.tp_base = __pyx_ptype_4lxml_5etree__Validator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_RelaxNG) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "RelaxNG", (PyObject *)&__pyx_type_4lxml_5etree_RelaxNG) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_RelaxNG = &__pyx_type_4lxml_5etree_RelaxNG;
  __pyx_type_4lxml_5etree_Schematron.tp_base = __pyx_ptype_4lxml_5etree__Validator;
  if (PyType_Ready(&__pyx_type_4lxml_5etree_Schematron) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "Schematron", (PyObject *)&__pyx_type_4lxml_5etree_Schematron) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4lxml_5etree_Schematron = &__pyx_type_4lxml_5etree_Schematron;
  /*--- Type import code ---*/
  __pyx_ptype_4lxml_6python_slice = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "slice", sizeof(PySliceObject)); if (unlikely(!__pyx_ptype_4lxml_6python_slice)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":5
 * """
 * 
 * __docformat__ = u"restructuredtext en"             # <<<<<<<<<<<<<<
 * 
 * cimport tree, python, config
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___docformat__, ((PyObject *)__pyx_kp_36)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":14
 * cimport cstd
 * 
 * try:             # <<<<<<<<<<<<<<
 *     import __builtin__
 * except ImportError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":15
 * 
 * try:
 *     import __builtin__             # <<<<<<<<<<<<<<
 * except ImportError:
 *     # Python 3
 */
      __pyx_1 = __Pyx_Import(__pyx_kp___builtin__, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      if (PyObject_SetAttr(__pyx_m, __pyx_kp___builtin__, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L6_try;
    __pyx_L2_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":16
 * try:
 *     import __builtin__
 * except ImportError:             # <<<<<<<<<<<<<<
 *     # Python 3
 *     import builtins as __builtin__
 */
    __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree");
      if (__Pyx_GetException(&__pyx_1, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":18
 * except ImportError:
 *     # Python 3
 *     import builtins as __builtin__             # <<<<<<<<<<<<<<
 * 
 * cdef object set
 */
      __pyx_5 = __Pyx_Import(__pyx_kp_builtins, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      if (PyObject_SetAttr(__pyx_m, __pyx_kp___builtin__, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L3_exception_handled;
    }
    __pyx_L4_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L6_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":21
 * 
 * cdef object set
 * try:             # <<<<<<<<<<<<<<
 *     set = __builtin__.set
 * except AttributeError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":22
 * cdef object set
 * try:
 *     set = __builtin__.set             # <<<<<<<<<<<<<<
 * except AttributeError:
 *     from sets import Set as set
 */
      __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp___builtin__); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
      __pyx_1 = PyObject_GetAttr(__pyx_5, __pyx_kp_set); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_v_4lxml_5etree_set);
      __pyx_v_4lxml_5etree_set = __pyx_1;
      __pyx_1 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L11_try;
    __pyx_L7_error:;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":23
 * try:
 *     set = __builtin__.set
 * except AttributeError:             # <<<<<<<<<<<<<<
 *     from sets import Set as set
 * 
 */
    __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree");
      if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":24
 *     set = __builtin__.set
 * except AttributeError:
 *     from sets import Set as set             # <<<<<<<<<<<<<<
 * 
 * cdef object _unicode
 */
      __pyx_1 = PyList_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
      Py_INCREF(__pyx_kp_Set);
      PyList_SET_ITEM(__pyx_1, 0, __pyx_kp_Set);
      __pyx_6 = __Pyx_Import(__pyx_kp_sets, ((PyObject *)__pyx_1)); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
      __pyx_1 = PyObject_GetAttr(__pyx_6, __pyx_kp_Set); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
      Py_DECREF(__pyx_v_4lxml_5etree_set);
      __pyx_v_4lxml_5etree_set = __pyx_1;
      __pyx_1 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L8_exception_handled;
    }
    __pyx_L9_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L8_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L11_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":27
 * 
 * cdef object _unicode
 * try:             # <<<<<<<<<<<<<<
 *     _unicode = __builtin__.unicode
 * except AttributeError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":28
 * cdef object _unicode
 * try:
 *     _unicode = __builtin__.unicode             # <<<<<<<<<<<<<<
 * except AttributeError:
 *     # Python 3
 */
      __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp___builtin__); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
      __pyx_1 = PyObject_GetAttr(__pyx_6, __pyx_kp_unicode); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_v_4lxml_5etree__unicode);
      __pyx_v_4lxml_5etree__unicode = __pyx_1;
      __pyx_1 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L16_try;
    __pyx_L12_error:;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_6); __pyx_6 = 0;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":29
 * try:
 *     _unicode = __builtin__.unicode
 * except AttributeError:             # <<<<<<<<<<<<<<
 *     # Python 3
 *     _unicode = __builtin__.str
 */
    __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree");
      if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":31
 * except AttributeError:
 *     # Python 3
 *     _unicode = __builtin__.str             # <<<<<<<<<<<<<<
 * 
 * del __builtin__
 */
      __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp___builtin__); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;}
      __pyx_1 = PyObject_GetAttr(__pyx_6, __pyx_kp_str); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L14_except_error;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_v_4lxml_5etree__unicode);
      __pyx_v_4lxml_5etree__unicode = __pyx_1;
      __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L13_exception_handled;
    }
    __pyx_L14_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L13_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L16_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":33
 *     _unicode = __builtin__.str
 * 
 * del __builtin__             # <<<<<<<<<<<<<<
 * 
 * cdef object os_path_abspath
 */
  if (PyObject_DelAttrString(__pyx_m, "__builtin__") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":36
 * 
 * cdef object os_path_abspath
 * from os.path import abspath as os_path_abspath             # <<<<<<<<<<<<<<
 * cdef object os_path_join
 * from os.path import join as os_path_join
 */
  __pyx_6 = PyList_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_abspath);
  PyList_SET_ITEM(__pyx_6, 0, __pyx_kp_abspath);
  __pyx_1 = __Pyx_Import(__pyx_kp_37, ((PyObject *)__pyx_6)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_kp_abspath); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree_os_path_abspath);
  __pyx_v_4lxml_5etree_os_path_abspath = __pyx_3;
  __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":38
 * from os.path import abspath as os_path_abspath
 * cdef object os_path_join
 * from os.path import join as os_path_join             # <<<<<<<<<<<<<<
 * 
 * cdef object BytesIO, StringIO
 */
  __pyx_4 = PyList_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_join);
  PyList_SET_ITEM(__pyx_4, 0, __pyx_kp_join);
  __pyx_5 = __Pyx_Import(__pyx_kp_37, ((PyObject *)__pyx_4)); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_kp_join); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree_os_path_join);
  __pyx_v_4lxml_5etree_os_path_join = __pyx_6;
  __pyx_6 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":41
 * 
 * cdef object BytesIO, StringIO
 * try:             # <<<<<<<<<<<<<<
 *     from io import BytesIO, StringIO
 * except ImportError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":42
 * cdef object BytesIO, StringIO
 * try:
 *     from io import BytesIO, StringIO             # <<<<<<<<<<<<<<
 * except ImportError:
 *     from StringIO import StringIO, StringIO as BytesIO
 */
      __pyx_1 = PyList_New(2); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      Py_INCREF(__pyx_kp_BytesIO);
      PyList_SET_ITEM(__pyx_1, 0, __pyx_kp_BytesIO);
      Py_INCREF(__pyx_kp_StringIO);
      PyList_SET_ITEM(__pyx_1, 1, __pyx_kp_StringIO);
      __pyx_3 = __Pyx_Import(__pyx_kp_io, ((PyObject *)__pyx_1)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
      __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_kp_BytesIO); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      Py_DECREF(__pyx_v_4lxml_5etree_BytesIO);
      __pyx_v_4lxml_5etree_BytesIO = __pyx_4;
      __pyx_4 = 0;
      __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_kp_StringIO); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
      Py_DECREF(__pyx_v_4lxml_5etree_StringIO);
      __pyx_v_4lxml_5etree_StringIO = __pyx_4;
      __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L21_try;
    __pyx_L17_error:;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_6); __pyx_6 = 0;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":43
 * try:
 *     from io import BytesIO, StringIO
 * except ImportError:             # <<<<<<<<<<<<<<
 *     from StringIO import StringIO, StringIO as BytesIO
 * 
 */
    __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree");
      if (__Pyx_GetException(&__pyx_5, &__pyx_6, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":44
 *     from io import BytesIO, StringIO
 * except ImportError:
 *     from StringIO import StringIO, StringIO as BytesIO             # <<<<<<<<<<<<<<
 * 
 * cdef object _elementpath
 */
      __pyx_3 = PyList_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
      Py_INCREF(__pyx_kp_StringIO);
      PyList_SET_ITEM(__pyx_3, 0, __pyx_kp_StringIO);
      Py_INCREF(__pyx_kp_StringIO);
      PyList_SET_ITEM(__pyx_3, 1, __pyx_kp_StringIO);
      __pyx_4 = __Pyx_Import(__pyx_kp_StringIO, ((PyObject *)__pyx_3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
      Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
      __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_kp_StringIO); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
      Py_DECREF(__pyx_v_4lxml_5etree_StringIO);
      __pyx_v_4lxml_5etree_StringIO = __pyx_3;
      __pyx_3 = 0;
      __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_kp_StringIO); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
      Py_DECREF(__pyx_v_4lxml_5etree_BytesIO);
      __pyx_v_4lxml_5etree_BytesIO = __pyx_3;
      __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L18_exception_handled;
    }
    __pyx_L19_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L18_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L21_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":47
 * 
 * cdef object _elementpath
 * import _elementpath             # <<<<<<<<<<<<<<
 * 
 * cdef object sys
 */
  __pyx_4 = __Pyx_Import(__pyx_kp__elementpath, 0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__elementpath);
  __pyx_v_4lxml_5etree__elementpath = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":50
 * 
 * cdef object sys
 * import sys             # <<<<<<<<<<<<<<
 * 
 * cdef object re
 */
  __pyx_3 = __Pyx_Import(__pyx_kp_sys, 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree_sys);
  __pyx_v_4lxml_5etree_sys = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":53
 * 
 * cdef object re
 * import re             # <<<<<<<<<<<<<<
 * 
 * cdef object ITER_EMPTY
 */
  __pyx_5 = __Pyx_Import(__pyx_kp_re, 0); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree_re);
  __pyx_v_4lxml_5etree_re = __pyx_5;
  __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":56
 * 
 * cdef object ITER_EMPTY
 * ITER_EMPTY = iter(())             # <<<<<<<<<<<<<<
 * 
 * cdef object EMPTY_READ_ONLY_DICT
 */
  __pyx_6 = PyObject_GetIter(((PyObject *)__pyx_empty_tuple)); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree_ITER_EMPTY);
  __pyx_v_4lxml_5etree_ITER_EMPTY = __pyx_6;
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":59
 * 
 * cdef object EMPTY_READ_ONLY_DICT
 * EMPTY_READ_ONLY_DICT = python.PyDictProxy_New({})             # <<<<<<<<<<<<<<
 * 
 * # the rules
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyDictProxy_New(((PyObject *)__pyx_1)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT);
  __pyx_v_4lxml_5etree_EMPTY_READ_ONLY_DICT = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":75
 * 
 * # make the compiled-in debug state publicly available
 * DEBUG = __DEBUG             # <<<<<<<<<<<<<<
 * 
 * # global per-thread setup
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DEBUG, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":78
 * 
 * # global per-thread setup
 * tree.xmlThrDefIndentTreeOutput(1)             # <<<<<<<<<<<<<<
 * tree.xmlThrDefLineNumbersDefaultValue(1)
 * 
 */
  xmlThrDefIndentTreeOutput(1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":79
 * # global per-thread setup
 * tree.xmlThrDefIndentTreeOutput(1)
 * tree.xmlThrDefLineNumbersDefaultValue(1)             # <<<<<<<<<<<<<<
 * 
 * _initThreadLogging()
 */
  xmlThrDefLineNumbersDefaultValue(1);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":81
 * tree.xmlThrDefLineNumbersDefaultValue(1)
 * 
 * _initThreadLogging()             # <<<<<<<<<<<<<<
 * 
 * # initialize parser (and threading)
 */
  __pyx_f_4lxml_5etree__initThreadLogging();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":84
 * 
 * # initialize parser (and threading)
 * xmlparser.xmlInitParser()             # <<<<<<<<<<<<<<
 * 
 * # filename encoding
 */
  xmlInitParser();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":88
 * # filename encoding
 * cdef object _FILENAME_ENCODING
 * _FILENAME_ENCODING = sys.getfilesystemencoding()             # <<<<<<<<<<<<<<
 * if _FILENAME_ENCODING is None:
 *     _FILENAME_ENCODING = sys.getdefaultencoding()
 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_4lxml_5etree_sys, __pyx_kp_38); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__FILENAME_ENCODING);
  __pyx_v_4lxml_5etree__FILENAME_ENCODING = __pyx_5;
  __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":89
 * cdef object _FILENAME_ENCODING
 * _FILENAME_ENCODING = sys.getfilesystemencoding()
 * if _FILENAME_ENCODING is None:             # <<<<<<<<<<<<<<
 *     _FILENAME_ENCODING = sys.getdefaultencoding()
 * if _FILENAME_ENCODING is None:
 */
  __pyx_7 = (__pyx_v_4lxml_5etree__FILENAME_ENCODING == Py_None);
  if (__pyx_7) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":90
 * _FILENAME_ENCODING = sys.getfilesystemencoding()
 * if _FILENAME_ENCODING is None:
 *     _FILENAME_ENCODING = sys.getdefaultencoding()             # <<<<<<<<<<<<<<
 * if _FILENAME_ENCODING is None:
 *     _FILENAME_ENCODING = 'ascii'
 */
    __pyx_6 = PyObject_GetAttr(__pyx_v_4lxml_5etree_sys, __pyx_kp_getdefaultencoding); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_1 = PyObject_Call(__pyx_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_v_4lxml_5etree__FILENAME_ENCODING);
    __pyx_v_4lxml_5etree__FILENAME_ENCODING = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L22;
  }
  __pyx_L22:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":91
 * if _FILENAME_ENCODING is None:
 *     _FILENAME_ENCODING = sys.getdefaultencoding()
 * if _FILENAME_ENCODING is None:             # <<<<<<<<<<<<<<
 *     _FILENAME_ENCODING = 'ascii'
 * else:
 */
  __pyx_7 = (__pyx_v_4lxml_5etree__FILENAME_ENCODING == Py_None);
  if (__pyx_7) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":92
 *     _FILENAME_ENCODING = sys.getdefaultencoding()
 * if _FILENAME_ENCODING is None:
 *     _FILENAME_ENCODING = 'ascii'             # <<<<<<<<<<<<<<
 * else:
 *     _FILENAME_ENCODING = _FILENAME_ENCODING.encode(u"UTF-8")
 */
    Py_INCREF(__pyx_kp_39);
    Py_DECREF(__pyx_v_4lxml_5etree__FILENAME_ENCODING);
    __pyx_v_4lxml_5etree__FILENAME_ENCODING = __pyx_kp_39;
    goto __pyx_L23;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":94
 *     _FILENAME_ENCODING = 'ascii'
 * else:
 *     _FILENAME_ENCODING = _FILENAME_ENCODING.encode(u"UTF-8")             # <<<<<<<<<<<<<<
 * cdef char* _C_FILENAME_ENCODING
 * _C_FILENAME_ENCODING = _cstr(_FILENAME_ENCODING)
 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_4lxml_5etree__FILENAME_ENCODING, __pyx_kp_encode); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_INCREF(((PyObject *)__pyx_kp_40));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_kp_40));
    __pyx_5 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
    Py_DECREF(__pyx_v_4lxml_5etree__FILENAME_ENCODING);
    __pyx_v_4lxml_5etree__FILENAME_ENCODING = __pyx_5;
    __pyx_5 = 0;
  }
  __pyx_L23:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":96
 *     _FILENAME_ENCODING = _FILENAME_ENCODING.encode(u"UTF-8")
 * cdef char* _C_FILENAME_ENCODING
 * _C_FILENAME_ENCODING = _cstr(_FILENAME_ENCODING)             # <<<<<<<<<<<<<<
 * 
 * # set up some default namespace prefixes
 */
  __pyx_v_4lxml_5etree__C_FILENAME_ENCODING = PyString_AS_STRING(__pyx_v_4lxml_5etree__FILENAME_ENCODING);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":100
 * # set up some default namespace prefixes
 * cdef object _DEFAULT_NAMESPACE_PREFIXES
 * _DEFAULT_NAMESPACE_PREFIXES = {             # <<<<<<<<<<<<<<
 *     "http://www.w3.org/1999/xhtml": "html",
 *     "http://www.w3.org/1999/XSL/Transform": "xsl",
 */
  __pyx_6 = PyDict_New(); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":101
 * cdef object _DEFAULT_NAMESPACE_PREFIXES
 * _DEFAULT_NAMESPACE_PREFIXES = {
 *     "http://www.w3.org/1999/xhtml": "html",             # <<<<<<<<<<<<<<
 *     "http://www.w3.org/1999/XSL/Transform": "xsl",
 *     "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_41, __pyx_kp_42) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":102
 * _DEFAULT_NAMESPACE_PREFIXES = {
 *     "http://www.w3.org/1999/xhtml": "html",
 *     "http://www.w3.org/1999/XSL/Transform": "xsl",             # <<<<<<<<<<<<<<
 *     "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",
 *     "http://schemas.xmlsoap.org/wsdl/": "wsdl",
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_43, __pyx_kp_44) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":103
 *     "http://www.w3.org/1999/xhtml": "html",
 *     "http://www.w3.org/1999/XSL/Transform": "xsl",
 *     "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",             # <<<<<<<<<<<<<<
 *     "http://schemas.xmlsoap.org/wsdl/": "wsdl",
 *     # xml schema
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_45, __pyx_kp_46) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":104
 *     "http://www.w3.org/1999/XSL/Transform": "xsl",
 *     "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf",
 *     "http://schemas.xmlsoap.org/wsdl/": "wsdl",             # <<<<<<<<<<<<<<
 *     # xml schema
 *     "http://www.w3.org/2001/XMLSchema": "xs",
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_47, __pyx_kp_48) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":106
 *     "http://schemas.xmlsoap.org/wsdl/": "wsdl",
 *     # xml schema
 *     "http://www.w3.org/2001/XMLSchema": "xs",             # <<<<<<<<<<<<<<
 *     "http://www.w3.org/2001/XMLSchema-instance": "xsi",
 *     # dublic core
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_49, __pyx_kp_50) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":107
 *     # xml schema
 *     "http://www.w3.org/2001/XMLSchema": "xs",
 *     "http://www.w3.org/2001/XMLSchema-instance": "xsi",             # <<<<<<<<<<<<<<
 *     # dublic core
 *     "http://purl.org/dc/elements/1.1/": "dc",
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_51, __pyx_kp_52) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":109
 *     "http://www.w3.org/2001/XMLSchema-instance": "xsi",
 *     # dublic core
 *     "http://purl.org/dc/elements/1.1/": "dc",             # <<<<<<<<<<<<<<
 *     # objectify
 *     "http://codespeak.net/lxml/objectify/pytype" : "py",
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_53, __pyx_kp_54) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":111
 *     "http://purl.org/dc/elements/1.1/": "dc",
 *     # objectify
 *     "http://codespeak.net/lxml/objectify/pytype" : "py",             # <<<<<<<<<<<<<<
 * }
 * 
 */
  if (PyDict_SetItem(__pyx_6, __pyx_kp_55, __pyx_kp_56) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__DEFAULT_NAMESPACE_PREFIXES);
  __pyx_v_4lxml_5etree__DEFAULT_NAMESPACE_PREFIXES = ((PyObject *)__pyx_6);
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":115
 * 
 * # Error superclass for ElementTree compatibility
 * class Error(Exception):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_1 = PyDict_New(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_builtin_Exception);
  __pyx_3 = __Pyx_CreateClass(((PyObject *)__pyx_4), ((PyObject *)__pyx_1), __pyx_kp_Error, "lxml.etree"); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_Error, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":119
 * 
 * # module level superclass for all exceptions
 * class LxmlError(Error):             # <<<<<<<<<<<<<<
 *     u"""Main exception base class for lxml.  All other exceptions inherit from
 *     this one.
 */
  __pyx_5 = PyDict_New(); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_kp_Error); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_6);
  __pyx_6 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_5), "__doc__", __pyx_kp_57) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = __Pyx_CreateClass(((PyObject *)__pyx_4), ((PyObject *)__pyx_5), __pyx_kp_LxmlError, "lxml.etree"); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":123
 *     this one.
 *     """
 *     def __init__(self, message, error_log=None):             # <<<<<<<<<<<<<<
 *         if python.PY_VERSION_HEX >= 0x02050000:
 *             # Python >= 2.5 uses new style class exceptions
 */
  __pyx_1 = PyCFunction_New(&__pyx_mdef_4lxml_5etree_9LxmlError___init__, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_6 = PyMethod_New(__pyx_1, 0, __pyx_3); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_3, __pyx_kp___init__, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_LxmlError, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":135
 * 
 * cdef object _LxmlError
 * _LxmlError = LxmlError             # <<<<<<<<<<<<<<
 * 
 * cdef object error_super_init
 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__LxmlError);
  __pyx_v_4lxml_5etree__LxmlError = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":138
 * 
 * cdef object error_super_init
 * error_super_init = Error.__init__             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_Error); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_6 = PyObject_GetAttr(__pyx_1, __pyx_kp___init__); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree_error_super_init);
  __pyx_v_4lxml_5etree_error_super_init = __pyx_6;
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":142
 * 
 * # superclass for all syntax errors
 * class LxmlSyntaxError(LxmlError, SyntaxError):             # <<<<<<<<<<<<<<
 *     u"""Base class for all syntax errors.
 *     """
 */
  __pyx_3 = PyDict_New(); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(2); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
  Py_INCREF(__pyx_builtin_SyntaxError);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_builtin_SyntaxError);
  __pyx_5 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_3), "__doc__", __pyx_kp_58) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_CreateClass(((PyObject *)__pyx_4), ((PyObject *)__pyx_3), __pyx_kp_LxmlSyntaxError, "lxml.etree"); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_LxmlSyntaxError, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":147
 *     pass
 * 
 * class C14NError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Error during C14N serialisation.
 *     """
 */
  __pyx_6 = PyDict_New(); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
  __pyx_5 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_6), "__doc__", __pyx_kp_60) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __Pyx_CreateClass(((PyObject *)__pyx_4), ((PyObject *)__pyx_6), __pyx_kp_59, "lxml.etree"); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_59, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":184
 * 
 * cdef int _LIBXML_VERSION_INT
 * try:             # <<<<<<<<<<<<<<
 *     _LIBXML_VERSION_INT = int(
 *         re.match(u'[0-9]+', (tree.xmlParserVersion).decode(u"ASCII")).group(0))
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    /*try:*/ {

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":186
 * try:
 *     _LIBXML_VERSION_INT = int(
 *         re.match(u'[0-9]+', (tree.xmlParserVersion).decode(u"ASCII")).group(0))             # <<<<<<<<<<<<<<
 * except Exception:
 *     print u"Unknown libxml2 version: %s" % (tree.xmlParserVersion).decode(u"ASCII")
 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_match); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      __pyx_5 = __Pyx_PyBytes_FromString(xmlParserVersion); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_kp_decode); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_1 = PyTuple_New(1); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_INCREF(((PyObject *)__pyx_kp_62));
      PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_kp_62));
      __pyx_6 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
      __pyx_5 = PyTuple_New(2); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_INCREF(((PyObject *)__pyx_kp_61));
      PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_kp_61));
      PyTuple_SET_ITEM(__pyx_5, 1, __pyx_6);
      __pyx_6 = 0;
      __pyx_4 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      __pyx_1 = PyObject_GetAttr(__pyx_4, __pyx_kp_group); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_6 = PyTuple_New(1); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_int_0);
      __pyx_3 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_6), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(((PyObject *)__pyx_6)); __pyx_6 = 0;
      __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
      __pyx_3 = 0;
      __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      __pyx_2 = __pyx_PyInt_int(__pyx_4); if (unlikely((__pyx_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L24_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_v_4lxml_5etree__LIBXML_VERSION_INT = __pyx_2;
    }
    Py_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    Py_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    Py_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L28_try;
    __pyx_L24_error:;
    Py_XDECREF(__pyx_1); __pyx_1 = 0;
    Py_XDECREF(__pyx_6); __pyx_6 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":187
 *     _LIBXML_VERSION_INT = int(
 *         re.match(u'[0-9]+', (tree.xmlParserVersion).decode(u"ASCII")).group(0))
 * except Exception:             # <<<<<<<<<<<<<<
 *     print u"Unknown libxml2 version: %s" % (tree.xmlParserVersion).decode(u"ASCII")
 *     _LIBXML_VERSION_INT = 0
 */
    __pyx_2 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_2) {
      __Pyx_AddTraceback("lxml.etree");
      if (__Pyx_GetException(&__pyx_1, &__pyx_6, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":188
 *         re.match(u'[0-9]+', (tree.xmlParserVersion).decode(u"ASCII")).group(0))
 * except Exception:
 *     print u"Unknown libxml2 version: %s" % (tree.xmlParserVersion).decode(u"ASCII")             # <<<<<<<<<<<<<<
 *     _LIBXML_VERSION_INT = 0
 * 
 */
      __pyx_5 = __Pyx_PyBytes_FromString(xmlParserVersion); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_kp_decode); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      Py_INCREF(((PyObject *)__pyx_kp_64));
      PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_kp_64));
      __pyx_8 = PyObject_Call(__pyx_4, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_63), __pyx_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      Py_DECREF(__pyx_8); __pyx_8 = 0;
      __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      if (__Pyx_Print(((PyObject *)__pyx_4), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L26_except_error;}
      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;

      /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":189
 * except Exception:
 *     print u"Unknown libxml2 version: %s" % (tree.xmlParserVersion).decode(u"ASCII")
 *     _LIBXML_VERSION_INT = 0             # <<<<<<<<<<<<<<
 * 
 * LIBXML_VERSION = __unpackIntVersion(_LIBXML_VERSION_INT)
 */
      __pyx_v_4lxml_5etree__LIBXML_VERSION_INT = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L25_exception_handled;
    }
    __pyx_L26_except_error:;
    Py_XDECREF(__pyx_save_exc_type);
    Py_XDECREF(__pyx_save_exc_value);
    Py_XDECREF(__pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L25_exception_handled:;
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __pyx_L28_try:;
  }

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":191
 *     _LIBXML_VERSION_INT = 0
 * 
 * LIBXML_VERSION = __unpackIntVersion(_LIBXML_VERSION_INT)             # <<<<<<<<<<<<<<
 * LIBXML_COMPILED_VERSION = __unpackIntVersion(tree.LIBXML_VERSION)
 * LXML_VERSION = __unpackDottedVersion(tree.LXML_VERSION_STRING)
 */
  __pyx_5 = __pyx_f_4lxml_5etree___unpackIntVersion(__pyx_v_4lxml_5etree__LIBXML_VERSION_INT); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_LIBXML_VERSION, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":192
 * 
 * LIBXML_VERSION = __unpackIntVersion(_LIBXML_VERSION_INT)
 * LIBXML_COMPILED_VERSION = __unpackIntVersion(tree.LIBXML_VERSION)             # <<<<<<<<<<<<<<
 * LXML_VERSION = __unpackDottedVersion(tree.LXML_VERSION_STRING)
 * 
 */
  __pyx_8 = __pyx_f_4lxml_5etree___unpackIntVersion(LIBXML_VERSION); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_65, __pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_8); __pyx_8 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":193
 * LIBXML_VERSION = __unpackIntVersion(_LIBXML_VERSION_INT)
 * LIBXML_COMPILED_VERSION = __unpackIntVersion(tree.LIBXML_VERSION)
 * LXML_VERSION = __unpackDottedVersion(tree.LXML_VERSION_STRING)             # <<<<<<<<<<<<<<
 * 
 * __version__ = (tree.LXML_VERSION_STRING).decode(u"ASCII")
 */
  __pyx_4 = __Pyx_PyBytes_FromString(LXML_VERSION_STRING); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_1 = __pyx_f_4lxml_5etree___unpackDottedVersion(__pyx_4); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_LXML_VERSION, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":195
 * LXML_VERSION = __unpackDottedVersion(tree.LXML_VERSION_STRING)
 * 
 * __version__ = (tree.LXML_VERSION_STRING).decode(u"ASCII")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_6 = __Pyx_PyBytes_FromString(LXML_VERSION_STRING); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_3 = PyObject_GetAttr(__pyx_6, __pyx_kp_decode); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_5 = PyTuple_New(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_66));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_kp_66));
  __pyx_8 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_5), NULL); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(((PyObject *)__pyx_5)); __pyx_5 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp___version__, __pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_8); __pyx_8 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":415
 * 
 * cdef object _PREFIX_CACHE
 * _PREFIX_CACHE = __initPrefixCache()             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "etree_defs.h":
 */
  __pyx_4 = __pyx_f_4lxml_5etree___initPrefixCache(); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__PREFIX_CACHE);
  __pyx_v_4lxml_5etree__PREFIX_CACHE = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1172
 *         return _elementFactory(self._doc, c_node)
 * 
 *     def itersiblings(self, tag=None, *, preceding=False):             # <<<<<<<<<<<<<<
 *         u"""itersiblings(self, tag=None, preceding=False)
 * 
 */
  __pyx_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_67 = __pyx_1;
  __pyx_1 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1205
 *         return ElementDepthFirstIterator(self, tag, inclusive=False)
 * 
 *     def iterchildren(self, tag=None, *, reversed=False):             # <<<<<<<<<<<<<<
 *         u"""iterchildren(self, tag=None, reversed=False)
 * 
 */
  __pyx_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_68 = __pyx_6;
  __pyx_6 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1264
 *         return ElementDepthFirstIterator(self, tag)
 * 
 *     def itertext(self, tag=None, *, with_tail=True):             # <<<<<<<<<<<<<<
 *         u"""itertext(self, tag=None, with_tail=True)
 * 
 */
  __pyx_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_69 = __pyx_3;
  __pyx_3 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1322
 * 
 *     def xpath(self, _path, *, namespaces=None, extensions=None,
 *               smart_strings=True, **_variables):             # <<<<<<<<<<<<<<
 *         u"""xpath(self, _path, namespaces=None, extensions=None, smart_strings=True, **_variables)
 * 
 */
  __pyx_5 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_70 = __pyx_5;
  __pyx_5 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1577
 * 
 *     def write(self, file, *, encoding=None, method=u"xml",
 *               pretty_print=False, xml_declaration=None, with_tail=True):             # <<<<<<<<<<<<<<
 *         u"""write(self, file, encoding=None, method="xml",
 *                   pretty_print=False, xml_declaration=None, with_tail=True)
 */
  __pyx_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_72 = __pyx_8;
  __pyx_8 = 0;
  __pyx_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_73 = __pyx_4;
  __pyx_4 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":1727
 * 
 *     def xpath(self, _path, *, namespaces=None, extensions=None,
 *               smart_strings=True, **_variables):             # <<<<<<<<<<<<<<
 *         u"""xpath(self, _path, namespaces=None, extensions=None, smart_strings=True, **_variables)
 * 
 */
  __pyx_9 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_74 = __pyx_9;
  __pyx_9 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2076
 *     Iterates over the children of an element.
 *     """
 *     def __init__(self, _Element node not None, tag=None, *, reversed=False):             # <<<<<<<<<<<<<<
 *         cdef xmlNode* c_node
 *         self._initTagMatch(tag)
 */
  __pyx_10 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_75 = __pyx_10;
  __pyx_10 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2101
 *     You can pass the boolean keyword ``preceding`` to specify the direction.
 *     """
 *     def __init__(self, _Element node not None, tag=None, *, preceding=False):             # <<<<<<<<<<<<<<
 *         self._initTagMatch(tag)
 *         if preceding:
 */
  __pyx_11 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_76 = __pyx_11;
  __pyx_11 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2142
 *     cdef _Element _next_node
 *     cdef _Element _top_node
 *     def __init__(self, _Element node not None, tag=None, *, inclusive=True):             # <<<<<<<<<<<<<<
 *         self._top_node  = node
 *         self._next_node = node
 */
  __pyx_12 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_77 = __pyx_12;
  __pyx_12 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2208
 *     cdef object _nextEvent
 *     cdef _Element _start_element
 *     def __init__(self, _Element element not None, tag=None, *, with_tail=True):             # <<<<<<<<<<<<<<
 *         if with_tail:
 *             events = (u"start", u"end")
 */
  __pyx_13 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_78 = __pyx_13;
  __pyx_13 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2300
 *     return _elementFactory(doc, c_node)
 * 
 * PI = ProcessingInstruction             # <<<<<<<<<<<<<<
 * 
 * cdef class CDATA:
 */
  __pyx_14 = __Pyx_GetName(__pyx_m, __pyx_kp_79); if (unlikely(!__pyx_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_PI, __pyx_14) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_14); __pyx_14 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2468
 *     return isinstance(element, _Element)
 * 
 * def dump(_Element elem not None, *, pretty_print=True, with_tail=True):             # <<<<<<<<<<<<<<
 *     u"""dump(elem, pretty_print=True, with_tail=True)
 * 
 */
  __pyx_14 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_80 = __pyx_14;
  __pyx_14 = 0;
  __pyx_15 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_81 = __pyx_15;
  __pyx_15 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2477
 * 
 * def tostring(element_or_tree, *, encoding=None, method=u"xml",
 *              xml_declaration=None, pretty_print=False, with_tail=True):             # <<<<<<<<<<<<<<
 *     u"""tostring(element_or_tree, encoding=None, method="xml",
 *                 xml_declaration=None, pretty_print=False, with_tail=True)
 */
  __pyx_16 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_83 = __pyx_16;
  __pyx_16 = 0;
  __pyx_17 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_84 = __pyx_17;
  __pyx_17 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2538
 *     return [tostring(element_or_tree, *args, **kwargs)]
 * 
 * def tounicode(element_or_tree, *, method=u"xml", pretty_print=False,             # <<<<<<<<<<<<<<
 *               with_tail=True):
 *     u"""tounicode(element_or_tree, method="xml", pretty_print=False,
 */
  __pyx_18 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_86 = __pyx_18;
  __pyx_18 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2539
 * 
 * def tounicode(element_or_tree, *, method=u"xml", pretty_print=False,
 *               with_tail=True):             # <<<<<<<<<<<<<<
 *     u"""tounicode(element_or_tree, method="xml", pretty_print=False,
 *                  with_tail=True)
 */
  __pyx_19 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_87 = __pyx_19;
  __pyx_19 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":486
 * 
 * cdef object __RE_XML_ENCODING
 * __RE_XML_ENCODING = re.compile(             # <<<<<<<<<<<<<<
 *     ur'^(\s*<\?\s*xml[^>]+)\s+encoding\s*=\s*"[^"]*"\s*', re.U)
 * 
 */
  __pyx_20 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":487
 * cdef object __RE_XML_ENCODING
 * __RE_XML_ENCODING = re.compile(
 *     ur'^(\s*<\?\s*xml[^>]+)\s+encoding\s*=\s*"[^"]*"\s*', re.U)             # <<<<<<<<<<<<<<
 * 
 * cdef object __REPLACE_XML_ENCODING
 */
  __pyx_21 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_U); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_22 = PyTuple_New(2); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_88));
  PyTuple_SET_ITEM(__pyx_22, 0, ((PyObject *)__pyx_kp_88));
  PyTuple_SET_ITEM(__pyx_22, 1, __pyx_21);
  __pyx_21 = 0;
  __pyx_21 = PyObject_Call(__pyx_20, ((PyObject *)__pyx_22), NULL); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_20); __pyx_20 = 0;
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree___RE_XML_ENCODING);
  __pyx_v_4lxml_5etree___RE_XML_ENCODING = __pyx_21;
  __pyx_21 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":490
 * 
 * cdef object __REPLACE_XML_ENCODING
 * __REPLACE_XML_ENCODING = __RE_XML_ENCODING.sub             # <<<<<<<<<<<<<<
 * 
 * cdef object __HAS_XML_ENCODING
 */
  __pyx_20 = PyObject_GetAttr(__pyx_v_4lxml_5etree___RE_XML_ENCODING, __pyx_kp_sub); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree___REPLACE_XML_ENCODING);
  __pyx_v_4lxml_5etree___REPLACE_XML_ENCODING = __pyx_20;
  __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/apihelpers.pxi":493
 * 
 * cdef object __HAS_XML_ENCODING
 * __HAS_XML_ENCODING = __RE_XML_ENCODING.match             # <<<<<<<<<<<<<<
 * 
 * cdef object _stripEncodingDeclaration(object xml_string):
 */
  __pyx_22 = PyObject_GetAttr(__pyx_v_4lxml_5etree___RE_XML_ENCODING, __pyx_kp_match); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree___HAS_XML_ENCODING);
  __pyx_v_4lxml_5etree___HAS_XML_ENCODING = __pyx_22;
  __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":404
 * # global list log to collect error output messages from libxml2/libxslt
 * cdef _BaseErrorLog __GLOBAL_ERROR_LOG
 * __GLOBAL_ERROR_LOG = _RotatingErrorLog(__MAX_LOG_SIZE)             # <<<<<<<<<<<<<<
 * 
 * cdef __copyGlobalErrorLog():
 */
  __pyx_21 = PyTuple_New(1); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_int_100);
  PyTuple_SET_ITEM(__pyx_21, 0, __pyx_int_100);
  __pyx_20 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__RotatingErrorLog)), ((PyObject *)__pyx_21), NULL); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_21)); __pyx_21 = 0;
  if (!(__Pyx_TypeTest(__pyx_20, __pyx_ptype_4lxml_5etree__BaseErrorLog))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG));
  __pyx_v_4lxml_5etree___GLOBAL_ERROR_LOG = ((struct __pyx_obj_4lxml_5etree__BaseErrorLog *)__pyx_20);
  __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":531
 * 
 * 
 * class ErrorLevels:             # <<<<<<<<<<<<<<
 *     u"Libxml2 error levels"
 * 
 */
  __pyx_22 = PyDict_New(); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItemString(((PyObject *)__pyx_22), "__doc__", __pyx_kp_89) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_21 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_22), __pyx_kp_ErrorLevels, "lxml.etree"); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_ErrorLevels, __pyx_21) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_21); __pyx_21 = 0;
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":534
 *     u"Libxml2 error levels"
 * 
 * class ErrorDomains:             # <<<<<<<<<<<<<<
 *     u"Libxml2 error domains"
 * 
 */
  __pyx_20 = PyDict_New(); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItemString(((PyObject *)__pyx_20), "__doc__", __pyx_kp_90) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_21 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_20), __pyx_kp_ErrorDomains, "lxml.etree"); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_ErrorDomains, __pyx_21) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_21); __pyx_21 = 0;
  Py_DECREF(((PyObject *)__pyx_20)); __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":537
 *     u"Libxml2 error domains"
 * 
 * class ErrorTypes:             # <<<<<<<<<<<<<<
 *     u"Libxml2 error types"
 * 
 */
  __pyx_22 = PyDict_New(); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItemString(((PyObject *)__pyx_22), "__doc__", __pyx_kp_91) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_21 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_22), __pyx_kp_ErrorTypes, "lxml.etree"); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_ErrorTypes, __pyx_21) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_21); __pyx_21 = 0;
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":540
 *     u"Libxml2 error types"
 * 
 * class RelaxNGErrorTypes:             # <<<<<<<<<<<<<<
 *     u"Libxml2 RelaxNG error types"
 * 
 */
  __pyx_20 = PyDict_New(); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItemString(((PyObject *)__pyx_20), "__doc__", __pyx_kp_92) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_21 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_20), __pyx_kp_RelaxNGErrorTypes, "lxml.etree"); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_RelaxNGErrorTypes, __pyx_21) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_21); __pyx_21 = 0;
  Py_DECREF(((PyObject *)__pyx_20)); __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":554
 * 
 * cdef object __ERROR_LEVELS
 * __ERROR_LEVELS = (u"""\             # <<<<<<<<<<<<<<
 * NONE=0
 * WARNING=1
 */
  __pyx_22 = PyTuple_New(1); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_93));
  PyTuple_SET_ITEM(__pyx_22, 0, ((PyObject *)__pyx_kp_93));
  Py_DECREF(__pyx_v_4lxml_5etree___ERROR_LEVELS);
  __pyx_v_4lxml_5etree___ERROR_LEVELS = ((PyObject *)__pyx_22);
  __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":562
 * 
 * cdef object __ERROR_DOMAINS
 * __ERROR_DOMAINS = (u"""\             # <<<<<<<<<<<<<<
 * NONE=0
 * PARSER=1
 */
  __pyx_21 = PyTuple_New(1); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_94));
  PyTuple_SET_ITEM(__pyx_21, 0, ((PyObject *)__pyx_kp_94));
  Py_DECREF(__pyx_v_4lxml_5etree___ERROR_DOMAINS);
  __pyx_v_4lxml_5etree___ERROR_DOMAINS = ((PyObject *)__pyx_21);
  __pyx_21 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":1266
 * SCHEMAP_SRC_IMPORT_1_1=3064
 * """,
 * u"""\             # <<<<<<<<<<<<<<
 * SCHEMAP_SRC_IMPORT_1_2=3065
 * SCHEMAP_SRC_IMPORT_2=3066
 */
  __pyx_20 = PyTuple_New(10); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_95));
  PyTuple_SET_ITEM(__pyx_20, 0, ((PyObject *)__pyx_kp_95));
  Py_INCREF(((PyObject *)__pyx_kp_96));
  PyTuple_SET_ITEM(__pyx_20, 1, ((PyObject *)__pyx_kp_96));
  Py_INCREF(((PyObject *)__pyx_kp_97));
  PyTuple_SET_ITEM(__pyx_20, 2, ((PyObject *)__pyx_kp_97));
  Py_INCREF(((PyObject *)__pyx_kp_98));
  PyTuple_SET_ITEM(__pyx_20, 3, ((PyObject *)__pyx_kp_98));
  Py_INCREF(((PyObject *)__pyx_kp_99));
  PyTuple_SET_ITEM(__pyx_20, 4, ((PyObject *)__pyx_kp_99));
  Py_INCREF(((PyObject *)__pyx_kp_100));
  PyTuple_SET_ITEM(__pyx_20, 5, ((PyObject *)__pyx_kp_100));
  Py_INCREF(((PyObject *)__pyx_kp_101));
  PyTuple_SET_ITEM(__pyx_20, 6, ((PyObject *)__pyx_kp_101));
  Py_INCREF(((PyObject *)__pyx_kp_102));
  PyTuple_SET_ITEM(__pyx_20, 7, ((PyObject *)__pyx_kp_102));
  Py_INCREF(((PyObject *)__pyx_kp_103));
  PyTuple_SET_ITEM(__pyx_20, 8, ((PyObject *)__pyx_kp_103));
  Py_INCREF(((PyObject *)__pyx_kp_104));
  PyTuple_SET_ITEM(__pyx_20, 9, ((PyObject *)__pyx_kp_104));
  Py_DECREF(__pyx_v_4lxml_5etree___PARSER_ERROR_TYPES);
  __pyx_v_4lxml_5etree___PARSER_ERROR_TYPES = ((PyObject *)__pyx_20);
  __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":1346
 * 
 * cdef object __RELAXNG_ERROR_TYPES
 * __RELAXNG_ERROR_TYPES = (u"""\             # <<<<<<<<<<<<<<
 * RELAXNG_OK=0
 * RELAXNG_ERR_MEMORY=1
 */
  __pyx_22 = PyTuple_New(1); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_105));
  PyTuple_SET_ITEM(__pyx_22, 0, ((PyObject *)__pyx_kp_105));
  Py_DECREF(__pyx_v_4lxml_5etree___RELAXNG_ERROR_TYPES);
  __pyx_v_4lxml_5etree___RELAXNG_ERROR_TYPES = ((PyObject *)__pyx_22);
  __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlerror.pxi":1390
 * # --- END: GENERATED CONSTANTS ---
 * 
 * __initErrorConstants()             # <<<<<<<<<<<<<<
 */
  __pyx_f_4lxml_5etree___initErrorConstants();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/readonlytree.pxi":158
 *         return iter(self.getchildren())
 * 
 *     def iterchildren(self, tag=None, *, reversed=False):             # <<<<<<<<<<<<<<
 *         u"""iterchildren(self, tag=None, reversed=False)
 * 
 */
  __pyx_21 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_21)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_106 = __pyx_21;
  __pyx_21 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":421
 * # default setup: parser delegation
 * cdef ParserBasedElementClassLookup DEFAULT_ELEMENT_CLASS_LOOKUP
 * DEFAULT_ELEMENT_CLASS_LOOKUP = ParserBasedElementClassLookup()             # <<<<<<<<<<<<<<
 * 
 * set_element_class_lookup(DEFAULT_ELEMENT_CLASS_LOOKUP)
 */
  __pyx_20 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_ParserBasedElementClassLookup)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_20, __pyx_ptype_4lxml_5etree_ParserBasedElementClassLookup))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP));
  __pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP = ((struct __pyx_obj_4lxml_5etree_ParserBasedElementClassLookup *)__pyx_20);
  __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/classlookup.pxi":423
 * DEFAULT_ELEMENT_CLASS_LOOKUP = ParserBasedElementClassLookup()
 * 
 * set_element_class_lookup(DEFAULT_ELEMENT_CLASS_LOOKUP)             # <<<<<<<<<<<<<<
 */
  __pyx_22 = __Pyx_GetName(__pyx_m, __pyx_kp_28); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = PyTuple_New(1); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP));
  PyTuple_SET_ITEM(__pyx_20, 0, ((PyObject *)__pyx_v_4lxml_5etree_DEFAULT_ELEMENT_CLASS_LOOKUP));
  __pyx_23 = PyObject_Call(__pyx_22, ((PyObject *)__pyx_20), NULL); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_22); __pyx_22 = 0;
  Py_DECREF(((PyObject *)__pyx_20)); __pyx_20 = 0;
  Py_DECREF(__pyx_23); __pyx_23 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":3
 * # module-level API for namespace implementations
 * 
 * class LxmlRegistryError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class of lxml registry errors.
 *     """
 */
  __pyx_22 = PyDict_New(); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_23 = PyTuple_New(1); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_23, 0, __pyx_20);
  __pyx_20 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_22), "__doc__", __pyx_kp_107) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = __Pyx_CreateClass(((PyObject *)__pyx_23), ((PyObject *)__pyx_22), __pyx_kp_LxmlRegistryError, "lxml.etree"); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_23)); __pyx_23 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_LxmlRegistryError, __pyx_20) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_20); __pyx_20 = 0;
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":8
 *     pass
 * 
 * class NamespaceRegistryError(LxmlRegistryError):             # <<<<<<<<<<<<<<
 *     u"""Error registering a namespace extension.
 *     """
 */
  __pyx_23 = PyDict_New(); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlRegistryError); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_22 = PyTuple_New(1); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_22, 0, __pyx_20);
  __pyx_20 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_23), "__doc__", __pyx_kp_109) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = __Pyx_CreateClass(((PyObject *)__pyx_22), ((PyObject *)__pyx_23), __pyx_kp_108, "lxml.etree"); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_108, __pyx_20) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_20); __pyx_20 = 0;
  Py_DECREF(((PyObject *)__pyx_23)); __pyx_23 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/nsclasses.pxi":165
 * 
 * cdef object __FUNCTION_NAMESPACE_REGISTRIES
 * __FUNCTION_NAMESPACE_REGISTRIES = {}             # <<<<<<<<<<<<<<
 * 
 * def FunctionNamespace(ns_uri):
 */
  __pyx_22 = PyDict_New(); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES);
  __pyx_v_4lxml_5etree___FUNCTION_NAMESPACE_REGISTRIES = ((PyObject *)__pyx_22);
  __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":13
 * cdef class XMLSchema(_Validator)
 * 
 * class ParseError(LxmlSyntaxError):             # <<<<<<<<<<<<<<
 *     u"""Syntax error while parsing an XML document.
 * 
 */
  __pyx_20 = PyDict_New(); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_23 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlSyntaxError); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_22 = PyTuple_New(1); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_22, 0, __pyx_23);
  __pyx_23 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_20), "__doc__", __pyx_kp_110) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_23 = __Pyx_CreateClass(((PyObject *)__pyx_22), ((PyObject *)__pyx_20), __pyx_kp_ParseError, "lxml.etree"); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_ParseError, __pyx_23) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_23); __pyx_23 = 0;
  Py_DECREF(((PyObject *)__pyx_20)); __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":20
 *     pass
 * 
 * class XMLSyntaxError(ParseError):             # <<<<<<<<<<<<<<
 *     u"""Syntax error while parsing an XML document.
 *     """
 */
  __pyx_22 = PyDict_New(); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_23 = __Pyx_GetName(__pyx_m, __pyx_kp_ParseError); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = PyTuple_New(1); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_20, 0, __pyx_23);
  __pyx_23 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_22), "__doc__", __pyx_kp_111) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_23 = __Pyx_CreateClass(((PyObject *)__pyx_20), ((PyObject *)__pyx_22), __pyx_kp_XMLSyntaxError, "lxml.etree"); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_20)); __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":23
 *     u"""Syntax error while parsing an XML document.
 *     """
 *     def __init__(self, message, code, line, column):             # <<<<<<<<<<<<<<
 *         if python.PY_VERSION_HEX >= 0x02050000:
 *             # Python >= 2.5 uses new style class exceptions
 */
  __pyx_20 = PyCFunction_New(&__pyx_mdef_4lxml_5etree_14XMLSyntaxError___init__, 0); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_24 = PyMethod_New(__pyx_20, 0, __pyx_23); if (unlikely(!__pyx_24)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_20); __pyx_20 = 0;
  if (PyObject_SetAttr(__pyx_23, __pyx_kp___init__, __pyx_24) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_24); __pyx_24 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XMLSyntaxError, __pyx_23) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_23); __pyx_23 = 0;
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":33
 * 
 * cdef object _XMLSyntaxError
 * _XMLSyntaxError = XMLSyntaxError             # <<<<<<<<<<<<<<
 * 
 * class ParserError(LxmlError):
 */
  __pyx_20 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSyntaxError); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__XMLSyntaxError);
  __pyx_v_4lxml_5etree__XMLSyntaxError = __pyx_20;
  __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":35
 * _XMLSyntaxError = XMLSyntaxError
 * 
 * class ParserError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Internal lxml parser error.
 *     """
 */
  __pyx_24 = PyDict_New(); if (unlikely(!__pyx_24)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_23 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_22 = PyTuple_New(1); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_22, 0, __pyx_23);
  __pyx_23 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_24), "__doc__", __pyx_kp_112) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_20 = __Pyx_CreateClass(((PyObject *)__pyx_22), ((PyObject *)__pyx_24), __pyx_kp_ParserError, "lxml.etree"); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_22)); __pyx_22 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_ParserError, __pyx_20) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_20); __pyx_20 = 0;
  Py_DECREF(((PyObject *)__pyx_24)); __pyx_24 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":186
 * 
 * cdef _ParserDictionaryContext __GLOBAL_PARSER_CONTEXT
 * __GLOBAL_PARSER_CONTEXT = _ParserDictionaryContext()             # <<<<<<<<<<<<<<
 * __GLOBAL_PARSER_CONTEXT.initMainParserContext()
 * 
 */
  __pyx_23 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree__ParserDictionaryContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_23, __pyx_ptype_4lxml_5etree__ParserDictionaryContext))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT));
  __pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT = ((struct __pyx_obj_4lxml_5etree__ParserDictionaryContext *)__pyx_23);
  __pyx_23 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":187
 * cdef _ParserDictionaryContext __GLOBAL_PARSER_CONTEXT
 * __GLOBAL_PARSER_CONTEXT = _ParserDictionaryContext()
 * __GLOBAL_PARSER_CONTEXT.initMainParserContext()             # <<<<<<<<<<<<<<
 * 
 * cdef int _checkThreadDict(tree.xmlDict* c_dict):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->initMainParserContext(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":205
 * # name of Python unicode encoding as known to libxml2
 * cdef char* _UNICODE_ENCODING
 * _UNICODE_ENCODING = NULL             # <<<<<<<<<<<<<<
 * 
 * cdef void _setupPythonUnicode():
 */
  __pyx_v_4lxml_5etree__UNICODE_ENCODING = NULL;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":257
 *         return tree.xmlGetCharEncodingName(enc)
 * 
 * _setupPythonUnicode()             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_f_4lxml_5etree__setupPythonUnicode();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":465
 * 
 * cdef xmlparser.xmlExternalEntityLoader __DEFAULT_ENTITY_LOADER
 * __DEFAULT_ENTITY_LOADER = xmlparser.xmlGetExternalEntityLoader()             # <<<<<<<<<<<<<<
 * 
 * xmlparser.xmlSetExternalEntityLoader(_local_resolver)
 */
  __pyx_v_4lxml_5etree___DEFAULT_ENTITY_LOADER = xmlGetExternalEntityLoader();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":467
 * __DEFAULT_ENTITY_LOADER = xmlparser.xmlGetExternalEntityLoader()
 * 
 * xmlparser.xmlSetExternalEntityLoader(_local_resolver)             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  xmlSetExternalEntityLoader(__pyx_f_4lxml_5etree__local_resolver);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1166
 *     xmlparser.XML_PARSE_NOCDATA |
 *     xmlparser.XML_PARSE_NONET   |
 *     xmlparser.XML_PARSE_COMPACT             # <<<<<<<<<<<<<<
 *     )
 * 
 */
  __pyx_v_4lxml_5etree__XML_DEFAULT_PARSE_OPTIONS = (((XML_PARSE_NOENT | XML_PARSE_NOCDATA) | XML_PARSE_NONET) | XML_PARSE_COMPACT);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1208
 *     apply to the default parser.
 *     """
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,             # <<<<<<<<<<<<<<
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,
 */
  __pyx_22 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_22)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_113 = __pyx_22;
  __pyx_22 = 0;
  __pyx_20 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_20)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_114 = __pyx_20;
  __pyx_20 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1209
 *     """
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, ns_clean=False,             # <<<<<<<<<<<<<<
 *                  recover=False, remove_blank_text=False, compact=True,
 *                  resolve_entities=True, remove_comments=False,
 */
  __pyx_24 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_24)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_115 = __pyx_24;
  __pyx_24 = 0;
  __pyx_23 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_23)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_116 = __pyx_23;
  __pyx_23 = 0;
  __pyx_25 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_25)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_117 = __pyx_25;
  __pyx_25 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1210
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,             # <<<<<<<<<<<<<<
 *                  resolve_entities=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, target=None,
 */
  __pyx_26 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_26)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_118 = __pyx_26;
  __pyx_26 = 0;
  __pyx_27 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_27)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_119 = __pyx_27;
  __pyx_27 = 0;
  __pyx_28 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_28)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_120 = __pyx_28;
  __pyx_28 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1211
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,
 *                  resolve_entities=True, remove_comments=False,             # <<<<<<<<<<<<<<
 *                  remove_pis=False, strip_cdata=True, target=None,
 *                  encoding=None, XMLSchema schema=None):
 */
  __pyx_29 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_29)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_121 = __pyx_29;
  __pyx_29 = 0;
  __pyx_30 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_30)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_122 = __pyx_30;
  __pyx_30 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1212
 *                  recover=False, remove_blank_text=False, compact=True,
 *                  resolve_entities=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, target=None,             # <<<<<<<<<<<<<<
 *                  encoding=None, XMLSchema schema=None):
 *         cdef int parse_options
 */
  __pyx_31 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_31)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_123 = __pyx_31;
  __pyx_31 = 0;
  __pyx_32 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_32)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_124 = __pyx_32;
  __pyx_32 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1252
 *     and thus ignores comments and processing instructions.
 *     """
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,             # <<<<<<<<<<<<<<
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,
 */
  __pyx_33 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_33)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_125 = __pyx_33;
  __pyx_33 = 0;
  __pyx_34 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_34)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_126 = __pyx_34;
  __pyx_34 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1253
 *     """
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, ns_clean=False,             # <<<<<<<<<<<<<<
 *                  recover=False, remove_blank_text=False, compact=True,
 *                  resolve_entities=True, remove_comments=True,
 */
  __pyx_35 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_35)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_127 = __pyx_35;
  __pyx_35 = 0;
  __pyx_36 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_36)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_128 = __pyx_36;
  __pyx_36 = 0;
  __pyx_37 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_37)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_129 = __pyx_37;
  __pyx_37 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1254
 *     def __init__(self, *, attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,             # <<<<<<<<<<<<<<
 *                  resolve_entities=True, remove_comments=True,
 *                  remove_pis=True, strip_cdata=True, target=None,
 */
  __pyx_38 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_38)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_130 = __pyx_38;
  __pyx_38 = 0;
  __pyx_39 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_39)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_131 = __pyx_39;
  __pyx_39 = 0;
  __pyx_40 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_40)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_132 = __pyx_40;
  __pyx_40 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1255
 *                  load_dtd=False, no_network=True, ns_clean=False,
 *                  recover=False, remove_blank_text=False, compact=True,
 *                  resolve_entities=True, remove_comments=True,             # <<<<<<<<<<<<<<
 *                  remove_pis=True, strip_cdata=True, target=None,
 *                  encoding=None, schema=None):
 */
  __pyx_41 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_41)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_133 = __pyx_41;
  __pyx_41 = 0;
  __pyx_42 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_42)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_134 = __pyx_42;
  __pyx_42 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1256
 *                  recover=False, remove_blank_text=False, compact=True,
 *                  resolve_entities=True, remove_comments=True,
 *                  remove_pis=True, strip_cdata=True, target=None,             # <<<<<<<<<<<<<<
 *                  encoding=None, schema=None):
 *         XMLParser.__init__(self,
 */
  __pyx_43 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_43)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_135 = __pyx_43;
  __pyx_43 = 0;
  __pyx_44 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_44)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_136 = __pyx_44;
  __pyx_44 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1277
 * 
 * cdef XMLParser __DEFAULT_XML_PARSER
 * __DEFAULT_XML_PARSER = XMLParser()             # <<<<<<<<<<<<<<
 * 
 * __GLOBAL_PARSER_CONTEXT.setDefaultParser(__DEFAULT_XML_PARSER)
 */
  __pyx_45 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XMLParser)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_45)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_45, __pyx_ptype_4lxml_5etree_XMLParser))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER));
  __pyx_v_4lxml_5etree___DEFAULT_XML_PARSER = ((struct __pyx_obj_4lxml_5etree_XMLParser *)__pyx_45);
  __pyx_45 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1279
 * __DEFAULT_XML_PARSER = XMLParser()
 * 
 * __GLOBAL_PARSER_CONTEXT.setDefaultParser(__DEFAULT_XML_PARSER)             # <<<<<<<<<<<<<<
 * 
 * def set_default_parser(_BaseParser parser=None):
 */
  ((struct __pyx_vtabstruct_4lxml_5etree__ParserDictionaryContext *)__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT->__pyx_vtab)->setDefaultParser(__pyx_v_4lxml_5etree___GLOBAL_PARSER_CONTEXT, ((struct __pyx_obj_4lxml_5etree__BaseParser *)__pyx_v_4lxml_5etree___DEFAULT_XML_PARSER));

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1309
 *     htmlparser.HTML_PARSE_RECOVER |
 *     htmlparser.HTML_PARSE_NONET   |
 *     htmlparser.HTML_PARSE_COMPACT             # <<<<<<<<<<<<<<
 *     )
 * 
 */
  __pyx_v_4lxml_5etree__HTML_DEFAULT_PARSE_OPTIONS = ((HTML_PARSE_RECOVER | HTML_PARSE_NONET) | HTML_PARSE_COMPACT);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1340
 *     reasons.
 *     """
 *     def __init__(self, *, recover=True, no_network=True,             # <<<<<<<<<<<<<<
 *                  remove_blank_text=False, compact=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, target=None, encoding=None,
 */
  __pyx_45 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_45)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_137 = __pyx_45;
  __pyx_45 = 0;
  __pyx_46 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_46)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_138 = __pyx_46;
  __pyx_46 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1341
 *     """
 *     def __init__(self, *, recover=True, no_network=True,
 *                  remove_blank_text=False, compact=True, remove_comments=False,             # <<<<<<<<<<<<<<
 *                  remove_pis=False, strip_cdata=True, target=None, encoding=None,
 *                  XMLSchema schema=None):
 */
  __pyx_47 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_47)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_139 = __pyx_47;
  __pyx_47 = 0;
  __pyx_48 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_48)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_140 = __pyx_48;
  __pyx_48 = 0;
  __pyx_49 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_49)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_141 = __pyx_49;
  __pyx_49 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1342
 *     def __init__(self, *, recover=True, no_network=True,
 *                  remove_blank_text=False, compact=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, target=None, encoding=None,             # <<<<<<<<<<<<<<
 *                  XMLSchema schema=None):
 *         cdef int parse_options
 */
  __pyx_50 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_50)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_142 = __pyx_50;
  __pyx_50 = 0;
  __pyx_51 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_51)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_143 = __pyx_51;
  __pyx_51 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parser.pxi":1360
 * 
 * cdef HTMLParser __DEFAULT_HTML_PARSER
 * __DEFAULT_HTML_PARSER = HTMLParser()             # <<<<<<<<<<<<<<
 * 
 * ############################################################
 */
  __pyx_52 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_HTMLParser)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_52)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(__Pyx_TypeTest(__pyx_52, __pyx_ptype_4lxml_5etree_HTMLParser))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___DEFAULT_HTML_PARSER));
  __pyx_v_4lxml_5etree___DEFAULT_HTML_PARSER = ((struct __pyx_obj_4lxml_5etree_HTMLParser *)__pyx_52);
  __pyx_52 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":4
 * 
 * cdef object inspect_getargspec
 * from inspect import getargspec as inspect_getargspec             # <<<<<<<<<<<<<<
 * 
 * class _TargetParserResult(Exception):
 */
  __pyx_52 = PyList_New(1); if (unlikely(!__pyx_52)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_getargspec);
  PyList_SET_ITEM(__pyx_52, 0, __pyx_kp_getargspec);
  __pyx_53 = __Pyx_Import(__pyx_kp_inspect, ((PyObject *)__pyx_52)); if (unlikely(!__pyx_53)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_52)); __pyx_52 = 0;
  __pyx_52 = PyObject_GetAttr(__pyx_53, __pyx_kp_getargspec); if (unlikely(!__pyx_52)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree_inspect_getargspec);
  __pyx_v_4lxml_5etree_inspect_getargspec = __pyx_52;
  __pyx_52 = 0;
  Py_DECREF(__pyx_53); __pyx_53 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":6
 * from inspect import getargspec as inspect_getargspec
 * 
 * class _TargetParserResult(Exception):             # <<<<<<<<<<<<<<
 *     # Admittedly, this is somewhat ugly, but it's the easiest way
 *     # to push the Python level parser result through the parser
 */
  __pyx_53 = PyDict_New(); if (unlikely(!__pyx_53)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_52 = PyTuple_New(1); if (unlikely(!__pyx_52)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_52, 0, __pyx_builtin_Exception);
  __pyx_54 = __Pyx_CreateClass(((PyObject *)__pyx_52), ((PyObject *)__pyx_53), __pyx_kp__TargetParserResult, "lxml.etree"); if (unlikely(!__pyx_54)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_52)); __pyx_52 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/parsertarget.pxi":10
 *     # to push the Python level parser result through the parser
 *     # machinery towards the API level functions
 *     def __init__(self, result):             # <<<<<<<<<<<<<<
 *         self.result = result
 * 
 */
  __pyx_52 = PyCFunction_New(&__pyx_mdef_4lxml_5etree_19_TargetParserResult___init__, 0); if (unlikely(!__pyx_52)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_55 = PyMethod_New(__pyx_52, 0, __pyx_54); if (unlikely(!__pyx_55)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_52); __pyx_52 = 0;
  if (PyObject_SetAttr(__pyx_54, __pyx_kp___init__, __pyx_55) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_55); __pyx_55 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp__TargetParserResult, __pyx_54) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_54); __pyx_54 = 0;
  Py_DECREF(((PyObject *)__pyx_53)); __pyx_53 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":361
 *     cdef int (*_parse_chunk)(xmlparser.xmlParserCtxt* ctxt,
 *                              char* chunk, int size, int terminate) nogil
 *     def __init__(self, source, events=(u"end",), *, tag=None,             # <<<<<<<<<<<<<<
 *                  attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, remove_blank_text=False,
 */
  __pyx_52 = PyTuple_New(1); if (unlikely(!__pyx_52)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_144));
  PyTuple_SET_ITEM(__pyx_52, 0, ((PyObject *)__pyx_kp_144));
  __pyx_k_145 = ((PyObject *)__pyx_52);
  __pyx_52 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":362
 *                              char* chunk, int size, int terminate) nogil
 *     def __init__(self, source, events=(u"end",), *, tag=None,
 *                  attribute_defaults=False, dtd_validation=False,             # <<<<<<<<<<<<<<
 *                  load_dtd=False, no_network=True, remove_blank_text=False,
 *                  compact=True, resolve_entities=True, remove_comments=False,
 */
  __pyx_55 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_55)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_146 = __pyx_55;
  __pyx_55 = 0;
  __pyx_54 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_54)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_147 = __pyx_54;
  __pyx_54 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":363
 *     def __init__(self, source, events=(u"end",), *, tag=None,
 *                  attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, remove_blank_text=False,             # <<<<<<<<<<<<<<
 *                  compact=True, resolve_entities=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, encoding=None,
 */
  __pyx_53 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_53)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_148 = __pyx_53;
  __pyx_53 = 0;
  __pyx_56 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_56)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_149 = __pyx_56;
  __pyx_56 = 0;
  __pyx_57 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_57)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_150 = __pyx_57;
  __pyx_57 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":364
 *                  attribute_defaults=False, dtd_validation=False,
 *                  load_dtd=False, no_network=True, remove_blank_text=False,
 *                  compact=True, resolve_entities=True, remove_comments=False,             # <<<<<<<<<<<<<<
 *                  remove_pis=False, strip_cdata=True, encoding=None,
 *                  html=False, XMLSchema schema=None):
 */
  __pyx_58 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_58)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_151 = __pyx_58;
  __pyx_58 = 0;
  __pyx_59 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_59)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_152 = __pyx_59;
  __pyx_59 = 0;
  __pyx_60 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_60)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_153 = __pyx_60;
  __pyx_60 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":365
 *                  load_dtd=False, no_network=True, remove_blank_text=False,
 *                  compact=True, resolve_entities=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, encoding=None,             # <<<<<<<<<<<<<<
 *                  html=False, XMLSchema schema=None):
 *         cdef _IterparseContext context
 */
  __pyx_61 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_61)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_154 = __pyx_61;
  __pyx_61 = 0;
  __pyx_62 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_62)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_155 = __pyx_62;
  __pyx_62 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":366
 *                  compact=True, resolve_entities=True, remove_comments=False,
 *                  remove_pis=False, strip_cdata=True, encoding=None,
 *                  html=False, XMLSchema schema=None):             # <<<<<<<<<<<<<<
 *         cdef _IterparseContext context
 *         cdef char* c_encoding
 */
  __pyx_63 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_63)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_156 = __pyx_63;
  __pyx_63 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/iterparse.pxi":539
 *     cdef char*  _tag_name
 * 
 *     def __init__(self, element_or_tree, events=(u"end",), tag=None):             # <<<<<<<<<<<<<<
 *         cdef _Element root
 *         cdef int ns_count
 */
  __pyx_64 = PyTuple_New(1); if (unlikely(!__pyx_64)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_157));
  PyTuple_SET_ITEM(__pyx_64, 0, ((PyObject *)__pyx_kp_157));
  __pyx_k_158 = ((PyObject *)__pyx_64);
  __pyx_64 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xinclude.pxi":5
 * cimport xinclude
 * 
 * class XIncludeError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Error during XInclude processing.
 *     """
 */
  __pyx_65 = PyDict_New(); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_67 = PyTuple_New(1); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_67, 0, __pyx_66);
  __pyx_66 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_65), "__doc__", __pyx_kp_159) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_CreateClass(((PyObject *)__pyx_67), ((PyObject *)__pyx_65), __pyx_kp_XIncludeError, "lxml.etree"); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XIncludeError, __pyx_66) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_66); __pyx_66 = 0;
  Py_DECREF(((PyObject *)__pyx_65)); __pyx_65 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":3
 * # support for extension functions in XPath and XSLT
 * 
 * class XPathError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class of all XPath errors.
 *     """
 */
  __pyx_67 = PyDict_New(); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_65 = PyTuple_New(1); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_65, 0, __pyx_66);
  __pyx_66 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_67), "__doc__", __pyx_kp_160) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_CreateClass(((PyObject *)__pyx_65), ((PyObject *)__pyx_67), __pyx_kp_XPathError, "lxml.etree"); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_65)); __pyx_65 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XPathError, __pyx_66) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_66); __pyx_66 = 0;
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":8
 *     pass
 * 
 * class XPathEvalError(XPathError):             # <<<<<<<<<<<<<<
 *     u"""Error during XPath evaluation.
 *     """
 */
  __pyx_65 = PyDict_New(); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathError); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_67 = PyTuple_New(1); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_67, 0, __pyx_66);
  __pyx_66 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_65), "__doc__", __pyx_kp_161) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_CreateClass(((PyObject *)__pyx_67), ((PyObject *)__pyx_65), __pyx_kp_XPathEvalError, "lxml.etree"); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XPathEvalError, __pyx_66) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_66); __pyx_66 = 0;
  Py_DECREF(((PyObject *)__pyx_65)); __pyx_65 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":13
 *     pass
 * 
 * class XPathFunctionError(XPathEvalError):             # <<<<<<<<<<<<<<
 *     u"""Internal error looking up an XPath extension function.
 *     """
 */
  __pyx_67 = PyDict_New(); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathEvalError); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_65 = PyTuple_New(1); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_65, 0, __pyx_66);
  __pyx_66 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_67), "__doc__", __pyx_kp_162) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_CreateClass(((PyObject *)__pyx_65), ((PyObject *)__pyx_67), __pyx_kp_XPathFunctionError, "lxml.etree"); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_65)); __pyx_65 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XPathFunctionError, __pyx_66) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_66); __pyx_66 = 0;
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":18
 *     pass
 * 
 * class XPathResultError(XPathEvalError):             # <<<<<<<<<<<<<<
 *     u"""Error handling an XPath result.
 *     """
 */
  __pyx_65 = PyDict_New(); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathEvalError); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_67 = PyTuple_New(1); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_67, 0, __pyx_66);
  __pyx_66 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_65), "__doc__", __pyx_kp_163) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = __Pyx_CreateClass(((PyObject *)__pyx_67), ((PyObject *)__pyx_65), __pyx_kp_XPathResultError, "lxml.etree"); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XPathResultError, __pyx_66) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_66); __pyx_66 = 0;
  Py_DECREF(((PyObject *)__pyx_65)); __pyx_65 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":582
 *         return self._parent
 * 
 * class _ElementStringResult(str):             # <<<<<<<<<<<<<<
 *     # we need to use a Python class here, str cannot be C-subclassed
 *     # in Pyrex/Cython
 */
  __pyx_67 = PyDict_New(); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_66 = PyTuple_New(1); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
  PyTuple_SET_ITEM(__pyx_66, 0, ((PyObject *)((PyObject*)&PyString_Type)));
  __pyx_65 = __Pyx_CreateClass(((PyObject *)__pyx_66), ((PyObject *)__pyx_67), __pyx_kp_166, "lxml.etree"); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_66)); __pyx_66 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/extensions.pxi":585
 *     # we need to use a Python class here, str cannot be C-subclassed
 *     # in Pyrex/Cython
 *     def getparent(self):             # <<<<<<<<<<<<<<
 *         return self._parent
 * 
 */
  __pyx_66 = PyCFunction_New(&__pyx_mdef_4lxml_5etree_20_ElementStringResult_getparent, 0); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_68 = PyMethod_New(__pyx_66, 0, __pyx_65); if (unlikely(!__pyx_68)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_66); __pyx_66 = 0;
  if (PyObject_SetAttr(__pyx_65, __pyx_kp_getparent, __pyx_68) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_68); __pyx_68 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_166, __pyx_65) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_65); __pyx_65 = 0;
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":3
 * # XPath evaluation
 * 
 * class XPathSyntaxError(LxmlSyntaxError, XPathError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_66 = PyDict_New(); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_68 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlSyntaxError); if (unlikely(!__pyx_68)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_65 = __Pyx_GetName(__pyx_m, __pyx_kp_XPathError); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_67 = PyTuple_New(2); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_67, 0, __pyx_68);
  PyTuple_SET_ITEM(__pyx_67, 1, __pyx_65);
  __pyx_68 = 0;
  __pyx_65 = 0;
  __pyx_68 = __Pyx_CreateClass(((PyObject *)__pyx_67), ((PyObject *)__pyx_66), __pyx_kp_XPathSyntaxError, "lxml.etree"); if (unlikely(!__pyx_68)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_67)); __pyx_67 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XPathSyntaxError, __pyx_68) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_68); __pyx_68 = 0;
  Py_DECREF(((PyObject *)__pyx_66)); __pyx_66 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":11
 * cdef object _XPATH_SYNTAX_ERRORS
 * _XPATH_SYNTAX_ERRORS = (
 *     xmlerror.XML_XPATH_NUMBER_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_UNFINISHED_LITERAL_ERROR,
 *     xmlerror.XML_XPATH_VARIABLE_REF_ERROR,
 */
  __pyx_65 = PyInt_FromLong(XML_XPATH_NUMBER_ERROR); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":12
 * _XPATH_SYNTAX_ERRORS = (
 *     xmlerror.XML_XPATH_NUMBER_ERROR,
 *     xmlerror.XML_XPATH_UNFINISHED_LITERAL_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_VARIABLE_REF_ERROR,
 *     xmlerror.XML_XPATH_INVALID_PREDICATE_ERROR,
 */
  __pyx_67 = PyInt_FromLong(XML_XPATH_UNFINISHED_LITERAL_ERROR); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":13
 *     xmlerror.XML_XPATH_NUMBER_ERROR,
 *     xmlerror.XML_XPATH_UNFINISHED_LITERAL_ERROR,
 *     xmlerror.XML_XPATH_VARIABLE_REF_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_PREDICATE_ERROR,
 *     xmlerror.XML_XPATH_UNCLOSED_ERROR,
 */
  __pyx_68 = PyInt_FromLong(XML_XPATH_VARIABLE_REF_ERROR); if (unlikely(!__pyx_68)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":14
 *     xmlerror.XML_XPATH_UNFINISHED_LITERAL_ERROR,
 *     xmlerror.XML_XPATH_VARIABLE_REF_ERROR,
 *     xmlerror.XML_XPATH_INVALID_PREDICATE_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_UNCLOSED_ERROR,
 *     xmlerror.XML_XPATH_INVALID_CHAR_ERROR
 */
  __pyx_66 = PyInt_FromLong(XML_XPATH_INVALID_PREDICATE_ERROR); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":15
 *     xmlerror.XML_XPATH_VARIABLE_REF_ERROR,
 *     xmlerror.XML_XPATH_INVALID_PREDICATE_ERROR,
 *     xmlerror.XML_XPATH_UNCLOSED_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_CHAR_ERROR
 * )
 */
  __pyx_69 = PyInt_FromLong(XML_XPATH_UNCLOSED_ERROR); if (unlikely(!__pyx_69)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":16
 *     xmlerror.XML_XPATH_INVALID_PREDICATE_ERROR,
 *     xmlerror.XML_XPATH_UNCLOSED_ERROR,
 *     xmlerror.XML_XPATH_INVALID_CHAR_ERROR             # <<<<<<<<<<<<<<
 * )
 * 
 */
  __pyx_70 = PyInt_FromLong(XML_XPATH_INVALID_CHAR_ERROR); if (unlikely(!__pyx_70)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_71 = PyTuple_New(6); if (unlikely(!__pyx_71)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_71, 0, __pyx_65);
  PyTuple_SET_ITEM(__pyx_71, 1, __pyx_67);
  PyTuple_SET_ITEM(__pyx_71, 2, __pyx_68);
  PyTuple_SET_ITEM(__pyx_71, 3, __pyx_66);
  PyTuple_SET_ITEM(__pyx_71, 4, __pyx_69);
  PyTuple_SET_ITEM(__pyx_71, 5, __pyx_70);
  __pyx_65 = 0;
  __pyx_67 = 0;
  __pyx_68 = 0;
  __pyx_66 = 0;
  __pyx_69 = 0;
  __pyx_70 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS);
  __pyx_v_4lxml_5etree__XPATH_SYNTAX_ERRORS = ((PyObject *)__pyx_71);
  __pyx_71 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":21
 * cdef object _XPATH_EVAL_ERRORS
 * _XPATH_EVAL_ERRORS = (
 *     xmlerror.XML_XPATH_UNDEF_VARIABLE_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_UNDEF_PREFIX_ERROR,
 *     xmlerror.XML_XPATH_UNKNOWN_FUNC_ERROR,
 */
  __pyx_65 = PyInt_FromLong(XML_XPATH_UNDEF_VARIABLE_ERROR); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":22
 * _XPATH_EVAL_ERRORS = (
 *     xmlerror.XML_XPATH_UNDEF_VARIABLE_ERROR,
 *     xmlerror.XML_XPATH_UNDEF_PREFIX_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_UNKNOWN_FUNC_ERROR,
 *     xmlerror.XML_XPATH_INVALID_OPERAND,
 */
  __pyx_67 = PyInt_FromLong(XML_XPATH_UNDEF_PREFIX_ERROR); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":23
 *     xmlerror.XML_XPATH_UNDEF_VARIABLE_ERROR,
 *     xmlerror.XML_XPATH_UNDEF_PREFIX_ERROR,
 *     xmlerror.XML_XPATH_UNKNOWN_FUNC_ERROR,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_OPERAND,
 *     xmlerror.XML_XPATH_INVALID_TYPE,
 */
  __pyx_68 = PyInt_FromLong(XML_XPATH_UNKNOWN_FUNC_ERROR); if (unlikely(!__pyx_68)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":24
 *     xmlerror.XML_XPATH_UNDEF_PREFIX_ERROR,
 *     xmlerror.XML_XPATH_UNKNOWN_FUNC_ERROR,
 *     xmlerror.XML_XPATH_INVALID_OPERAND,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_TYPE,
 *     xmlerror.XML_XPATH_INVALID_ARITY,
 */
  __pyx_66 = PyInt_FromLong(XML_XPATH_INVALID_OPERAND); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":25
 *     xmlerror.XML_XPATH_UNKNOWN_FUNC_ERROR,
 *     xmlerror.XML_XPATH_INVALID_OPERAND,
 *     xmlerror.XML_XPATH_INVALID_TYPE,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_ARITY,
 *     xmlerror.XML_XPATH_INVALID_CTXT_SIZE,
 */
  __pyx_69 = PyInt_FromLong(XML_XPATH_INVALID_TYPE); if (unlikely(!__pyx_69)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":26
 *     xmlerror.XML_XPATH_INVALID_OPERAND,
 *     xmlerror.XML_XPATH_INVALID_TYPE,
 *     xmlerror.XML_XPATH_INVALID_ARITY,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_CTXT_SIZE,
 *     xmlerror.XML_XPATH_INVALID_CTXT_POSITION
 */
  __pyx_70 = PyInt_FromLong(XML_XPATH_INVALID_ARITY); if (unlikely(!__pyx_70)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":27
 *     xmlerror.XML_XPATH_INVALID_TYPE,
 *     xmlerror.XML_XPATH_INVALID_ARITY,
 *     xmlerror.XML_XPATH_INVALID_CTXT_SIZE,             # <<<<<<<<<<<<<<
 *     xmlerror.XML_XPATH_INVALID_CTXT_POSITION
 * )
 */
  __pyx_71 = PyInt_FromLong(XML_XPATH_INVALID_CTXT_SIZE); if (unlikely(!__pyx_71)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":28
 *     xmlerror.XML_XPATH_INVALID_ARITY,
 *     xmlerror.XML_XPATH_INVALID_CTXT_SIZE,
 *     xmlerror.XML_XPATH_INVALID_CTXT_POSITION             # <<<<<<<<<<<<<<
 * )
 * 
 */
  __pyx_72 = PyInt_FromLong(XML_XPATH_INVALID_CTXT_POSITION); if (unlikely(!__pyx_72)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_73 = PyTuple_New(8); if (unlikely(!__pyx_73)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_73, 0, __pyx_65);
  PyTuple_SET_ITEM(__pyx_73, 1, __pyx_67);
  PyTuple_SET_ITEM(__pyx_73, 2, __pyx_68);
  PyTuple_SET_ITEM(__pyx_73, 3, __pyx_66);
  PyTuple_SET_ITEM(__pyx_73, 4, __pyx_69);
  PyTuple_SET_ITEM(__pyx_73, 5, __pyx_70);
  PyTuple_SET_ITEM(__pyx_73, 6, __pyx_71);
  PyTuple_SET_ITEM(__pyx_73, 7, __pyx_72);
  __pyx_65 = 0;
  __pyx_67 = 0;
  __pyx_68 = 0;
  __pyx_66 = 0;
  __pyx_69 = 0;
  __pyx_70 = 0;
  __pyx_71 = 0;
  __pyx_72 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__XPATH_EVAL_ERRORS);
  __pyx_v_4lxml_5etree__XPATH_EVAL_ERRORS = ((PyObject *)__pyx_73);
  __pyx_73 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":97
 * 
 * cdef bint _XPATH_VERSION_WARNING_REQUIRED
 * if _LIBXML_VERSION_INT == 20627:             # <<<<<<<<<<<<<<
 *     _XPATH_VERSION_WARNING_REQUIRED = 1
 * else:
 */
  __pyx_7 = (__pyx_v_4lxml_5etree__LIBXML_VERSION_INT == 20627);
  if (__pyx_7) {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":98
 * cdef bint _XPATH_VERSION_WARNING_REQUIRED
 * if _LIBXML_VERSION_INT == 20627:
 *     _XPATH_VERSION_WARNING_REQUIRED = 1             # <<<<<<<<<<<<<<
 * else:
 *     _XPATH_VERSION_WARNING_REQUIRED = 0
 */
    __pyx_v_4lxml_5etree__XPATH_VERSION_WARNING_REQUIRED = 1;
    goto __pyx_L29;
  }
  /*else*/ {

    /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":100
 *     _XPATH_VERSION_WARNING_REQUIRED = 1
 * else:
 *     _XPATH_VERSION_WARNING_REQUIRED = 0             # <<<<<<<<<<<<<<
 * 
 * cdef class _XPathEvaluatorBase:
 */
    __pyx_v_4lxml_5etree__XPATH_VERSION_WARNING_REQUIRED = 0;
  }
  __pyx_L29:;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":232
 *     cdef _Element _element
 *     def __init__(self, _Element element not None, *, namespaces=None,
 *                  extensions=None, regexp=True, smart_strings=True):             # <<<<<<<<<<<<<<
 *         cdef xpath.xmlXPathContext* xpathCtxt
 *         cdef int ns_register_status
 */
  __pyx_65 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_65)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_167 = __pyx_65;
  __pyx_65 = 0;
  __pyx_67 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_67)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_168 = __pyx_67;
  __pyx_67 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":303
 *     """
 *     def __init__(self, _ElementTree etree not None, *, namespaces=None,
 *                  extensions=None, regexp=True, smart_strings=True):             # <<<<<<<<<<<<<<
 *         XPathElementEvaluator.__init__(
 *             self, etree._context_node, namespaces=namespaces,
 */
  __pyx_68 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_68)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_169 = __pyx_68;
  __pyx_68 = 0;
  __pyx_66 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_66)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_170 = __pyx_66;
  __pyx_66 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":348
 * 
 * def XPathEvaluator(etree_or_element, *, namespaces=None, extensions=None,
 *                    regexp=True, smart_strings=True):             # <<<<<<<<<<<<<<
 *     u"""XPathEvaluator(etree_or_element, namespaces=None, extensions=None, regexp=True, smart_strings=True)
 * 
 */
  __pyx_69 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_69)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_171 = __pyx_69;
  __pyx_69 = 0;
  __pyx_70 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_70)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_172 = __pyx_70;
  __pyx_70 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":388
 * 
 *     def __init__(self, path, *, namespaces=None, extensions=None,
 *                  regexp=True, smart_strings=True):             # <<<<<<<<<<<<<<
 *         cdef xpath.xmlXPathContext* xpathCtxt
 *         _XPathEvaluatorBase.__init__(self, namespaces, extensions,
 */
  __pyx_71 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_71)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_173 = __pyx_71;
  __pyx_71 = 0;
  __pyx_72 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_72)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_174 = __pyx_72;
  __pyx_72 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":442
 * cdef object _replace_strings
 * cdef object _find_namespaces
 * _replace_strings = re.compile('("[^"]*")|(\'[^\']*\')').sub             # <<<<<<<<<<<<<<
 * _find_namespaces = re.compile('({[^}]+})').findall
 * 
 */
  __pyx_73 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_73)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_74 = PyTuple_New(1); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_175);
  PyTuple_SET_ITEM(__pyx_74, 0, __pyx_kp_175);
  __pyx_75 = PyObject_Call(__pyx_73, ((PyObject *)__pyx_74), NULL); if (unlikely(!__pyx_75)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_73); __pyx_73 = 0;
  Py_DECREF(((PyObject *)__pyx_74)); __pyx_74 = 0;
  __pyx_73 = PyObject_GetAttr(__pyx_75, __pyx_kp_sub); if (unlikely(!__pyx_73)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_75); __pyx_75 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__replace_strings);
  __pyx_v_4lxml_5etree__replace_strings = __pyx_73;
  __pyx_73 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":443
 * cdef object _find_namespaces
 * _replace_strings = re.compile('("[^"]*")|(\'[^\']*\')').sub
 * _find_namespaces = re.compile('({[^}]+})').findall             # <<<<<<<<<<<<<<
 * 
 * cdef class ETXPath(XPath):
 */
  __pyx_74 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_75 = PyTuple_New(1); if (unlikely(!__pyx_75)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_kp_176);
  PyTuple_SET_ITEM(__pyx_75, 0, __pyx_kp_176);
  __pyx_73 = PyObject_Call(__pyx_74, ((PyObject *)__pyx_75), NULL); if (unlikely(!__pyx_73)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_74); __pyx_74 = 0;
  Py_DECREF(((PyObject *)__pyx_75)); __pyx_75 = 0;
  __pyx_74 = PyObject_GetAttr(__pyx_73, __pyx_kp_findall); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_73); __pyx_73 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__find_namespaces);
  __pyx_v_4lxml_5etree__find_namespaces = __pyx_74;
  __pyx_74 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xpath.pxi":454
 *     you pass ``smart_strings=False``.
 *     """
 *     def __init__(self, path, *, extensions=None, regexp=True, smart_strings=True):             # <<<<<<<<<<<<<<
 *         path, namespaces = self._nsextract_path(path)
 *         XPath.__init__(self, path, namespaces=namespaces,
 */
  __pyx_75 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_75)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_177 = __pyx_75;
  __pyx_75 = 0;
  __pyx_73 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_73)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_178 = __pyx_73;
  __pyx_73 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":5
 * cimport xslt
 * 
 * class XSLTError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class of all XSLT errors.
 *     """
 */
  __pyx_74 = PyDict_New(); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_77 = PyTuple_New(1); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_77, 0, __pyx_76);
  __pyx_76 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_74), "__doc__", __pyx_kp_179) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_CreateClass(((PyObject *)__pyx_77), ((PyObject *)__pyx_74), __pyx_kp_XSLTError, "lxml.etree"); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_77)); __pyx_77 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XSLTError, __pyx_76) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_76); __pyx_76 = 0;
  Py_DECREF(((PyObject *)__pyx_74)); __pyx_74 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":10
 *     pass
 * 
 * class XSLTParseError(XSLTError):             # <<<<<<<<<<<<<<
 *     u"""Error parsing a stylesheet document.
 *     """
 */
  __pyx_77 = PyDict_New(); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTError); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_74 = PyTuple_New(1); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_74, 0, __pyx_76);
  __pyx_76 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_77), "__doc__", __pyx_kp_180) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_CreateClass(((PyObject *)__pyx_74), ((PyObject *)__pyx_77), __pyx_kp_XSLTParseError, "lxml.etree"); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_74)); __pyx_74 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XSLTParseError, __pyx_76) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_76); __pyx_76 = 0;
  Py_DECREF(((PyObject *)__pyx_77)); __pyx_77 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":15
 *     pass
 * 
 * class XSLTApplyError(XSLTError):             # <<<<<<<<<<<<<<
 *     u"""Error running an XSL transformation.
 *     """
 */
  __pyx_74 = PyDict_New(); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTError); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_77 = PyTuple_New(1); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_77, 0, __pyx_76);
  __pyx_76 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_74), "__doc__", __pyx_kp_181) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_CreateClass(((PyObject *)__pyx_77), ((PyObject *)__pyx_74), __pyx_kp_XSLTApplyError, "lxml.etree"); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_77)); __pyx_77 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XSLTApplyError, __pyx_76) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_76); __pyx_76 = 0;
  Py_DECREF(((PyObject *)__pyx_74)); __pyx_74 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":20
 *     pass
 * 
 * class XSLTSaveError(XSLTError):             # <<<<<<<<<<<<<<
 *     u"""Error serialising an XSLT result.
 *     """
 */
  __pyx_77 = PyDict_New(); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTError); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_74 = PyTuple_New(1); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_74, 0, __pyx_76);
  __pyx_76 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_77), "__doc__", __pyx_kp_182) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_CreateClass(((PyObject *)__pyx_74), ((PyObject *)__pyx_77), __pyx_kp_XSLTSaveError, "lxml.etree"); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_74)); __pyx_74 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XSLTSaveError, __pyx_76) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_76); __pyx_76 = 0;
  Py_DECREF(((PyObject *)__pyx_77)); __pyx_77 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":25
 *     pass
 * 
 * class XSLTExtensionError(XSLTError):             # <<<<<<<<<<<<<<
 *     u"""Error registering an XSLT extension.
 *     """
 */
  __pyx_74 = PyDict_New(); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_GetName(__pyx_m, __pyx_kp_XSLTError); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_77 = PyTuple_New(1); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_77, 0, __pyx_76);
  __pyx_76 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_74), "__doc__", __pyx_kp_183) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_76 = __Pyx_CreateClass(((PyObject *)__pyx_77), ((PyObject *)__pyx_74), __pyx_kp_XSLTExtensionError, "lxml.etree"); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_77)); __pyx_77 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XSLTExtensionError, __pyx_76) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_76); __pyx_76 = 0;
  Py_DECREF(((PyObject *)__pyx_74)); __pyx_74 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":31
 * 
 * # version information
 * LIBXSLT_COMPILED_VERSION = __unpackIntVersion(xslt.LIBXSLT_VERSION)             # <<<<<<<<<<<<<<
 * LIBXSLT_VERSION = __unpackIntVersion(xslt.xsltLibxsltVersion)
 * 
 */
  __pyx_77 = __pyx_f_4lxml_5etree___unpackIntVersion(LIBXSLT_VERSION); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_184, __pyx_77) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_77); __pyx_77 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":32
 * # version information
 * LIBXSLT_COMPILED_VERSION = __unpackIntVersion(xslt.LIBXSLT_VERSION)
 * LIBXSLT_VERSION = __unpackIntVersion(xslt.xsltLibxsltVersion)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_76 = __pyx_f_4lxml_5etree___unpackIntVersion(xsltLibxsltVersion); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_LIBXSLT_VERSION, __pyx_76) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_76); __pyx_76 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":165
 * 
 * cdef xslt.xsltDocLoaderFunc XSLT_DOC_DEFAULT_LOADER
 * XSLT_DOC_DEFAULT_LOADER = xslt.xsltDocDefaultLoader             # <<<<<<<<<<<<<<
 * 
 * xslt.xsltSetLoaderFunc(_xslt_doc_loader)
 */
  __pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER = xsltDocDefaultLoader;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":167
 * XSLT_DOC_DEFAULT_LOADER = xslt.xsltDocDefaultLoader
 * 
 * xslt.xsltSetLoaderFunc(_xslt_doc_loader)             # <<<<<<<<<<<<<<
 * 
 * ################################################################################
 */
  xsltSetLoaderFunc(__pyx_f_4lxml_5etree__xslt_doc_loader);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":194
 *     """
 *     cdef xslt.xsltSecurityPrefs* _prefs
 *     def __init__(self, *, read_file=True, write_file=True, create_dir=True,             # <<<<<<<<<<<<<<
 *                  read_network=True, write_network=True):
 *         self._prefs = xslt.xsltNewSecurityPrefs()
 */
  __pyx_74 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_74)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_185 = __pyx_74;
  __pyx_74 = 0;
  __pyx_77 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_77)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_186 = __pyx_77;
  __pyx_77 = 0;
  __pyx_76 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_76)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_187 = __pyx_76;
  __pyx_76 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":195
 *     cdef xslt.xsltSecurityPrefs* _prefs
 *     def __init__(self, *, read_file=True, write_file=True, create_dir=True,
 *                  read_network=True, write_network=True):             # <<<<<<<<<<<<<<
 *         self._prefs = xslt.xsltNewSecurityPrefs()
 *         if self._prefs is NULL:
 */
  __pyx_78 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_78)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_188 = __pyx_78;
  __pyx_78 = 0;
  __pyx_79 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_79)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_189 = __pyx_79;
  __pyx_79 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":205
 *         self._setAccess(xslt.XSLT_SECPREF_WRITE_NETWORK, write_network)
 * 
 *     DENY_ALL = XSLTAccessControl(             # <<<<<<<<<<<<<<
 *         read_file=False, write_file=False, create_dir=False,
 *         read_network=False, write_network=False)
 */
  __pyx_80 = PyDict_New(); if (unlikely(!__pyx_80)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":206
 * 
 *     DENY_ALL = XSLTAccessControl(
 *         read_file=False, write_file=False, create_dir=False,             # <<<<<<<<<<<<<<
 *         read_network=False, write_network=False)
 * 
 */
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_read_file, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_write_file, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_create_dir, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":207
 *     DENY_ALL = XSLTAccessControl(
 *         read_file=False, write_file=False, create_dir=False,
 *         read_network=False, write_network=False)             # <<<<<<<<<<<<<<
 * 
 *     DENY_WRITE = XSLTAccessControl(
 */
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_read_network, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_write_network, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XSLTAccessControl)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_80)); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_80)); __pyx_80 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lxml_5etree_XSLTAccessControl->tp_dict, __pyx_kp_DENY_ALL, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_4lxml_5etree_XSLTAccessControl);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":209
 *         read_network=False, write_network=False)
 * 
 *     DENY_WRITE = XSLTAccessControl(             # <<<<<<<<<<<<<<
 *         read_file=True, write_file=False, create_dir=False,
 *         read_network=True, write_network=False)
 */
  __pyx_80 = PyDict_New(); if (unlikely(!__pyx_80)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":210
 * 
 *     DENY_WRITE = XSLTAccessControl(
 *         read_file=True, write_file=False, create_dir=False,             # <<<<<<<<<<<<<<
 *         read_network=True, write_network=False)
 * 
 */
  __pyx_81 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_read_file, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_write_file, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_create_dir, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":211
 *     DENY_WRITE = XSLTAccessControl(
 *         read_file=True, write_file=False, create_dir=False,
 *         read_network=True, write_network=False)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_81 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_read_network, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_80, __pyx_kp_write_network, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_81); __pyx_81 = 0;
  __pyx_81 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4lxml_5etree_XSLTAccessControl)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_80)); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_80)); __pyx_80 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4lxml_5etree_XSLTAccessControl->tp_dict, __pyx_kp_DENY_WRITE, __pyx_81) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_4lxml_5etree_XSLTAccessControl);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":356
 *     cdef _ErrorLog _error_log
 * 
 *     def __init__(self, xslt_input, *, extensions=None, regexp=True,             # <<<<<<<<<<<<<<
 *                  access_control=None):
 *         cdef xslt.xsltStylesheet* c_style
 */
  __pyx_80 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_80)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_190 = __pyx_80;
  __pyx_80 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":420
 *             return self._error_log.copy()
 * 
 *     def apply(self, _input, *, profile_run=False, **kw):             # <<<<<<<<<<<<<<
 *         u"""apply(self, _input,  profile_run=False, **kw)
 * 
 */
  __pyx_81 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_81)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_191 = __pyx_81;
  __pyx_81 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":441
 *         return _copyXSLT(self)
 * 
 *     def __call__(self, _input, *, profile_run=False, **kw):             # <<<<<<<<<<<<<<
 *         u"""__call__(self, _input, profile_run=False, **kw)
 * 
 */
  __pyx_82 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_82)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_192 = __pyx_82;
  __pyx_82 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":749
 * # functions like "output" and "write" are a potential security risk, but we
 * # rely on the user to configure XSLTAccessControl as needed
 * xslt.xsltRegisterAllExtras()             # <<<<<<<<<<<<<<
 * 
 * # enable EXSLT support for XSLT
 */
  xsltRegisterAllExtras();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":752
 * 
 * # enable EXSLT support for XSLT
 * xslt.exsltRegisterAll()             # <<<<<<<<<<<<<<
 * 
 * cdef void initTransformDict(xslt.xsltTransformContext* transform_ctxt):
 */
  exsltRegisterAll();

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":762
 * 
 * cdef object _FIND_PI_ATTRIBUTES
 * _FIND_PI_ATTRIBUTES = re.compile(ur'\s+(\w+)\s*=\s*["\']([^"\']+)["\']', re.U).findall             # <<<<<<<<<<<<<<
 * 
 * cdef object _RE_PI_HREF
 */
  __pyx_83 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_U); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = PyTuple_New(2); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_193));
  PyTuple_SET_ITEM(__pyx_85, 0, ((PyObject *)__pyx_kp_193));
  PyTuple_SET_ITEM(__pyx_85, 1, __pyx_84);
  __pyx_84 = 0;
  __pyx_84 = PyObject_Call(__pyx_83, ((PyObject *)__pyx_85), NULL); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_83); __pyx_83 = 0;
  Py_DECREF(((PyObject *)__pyx_85)); __pyx_85 = 0;
  __pyx_83 = PyObject_GetAttr(__pyx_84, __pyx_kp_findall); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_84); __pyx_84 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__FIND_PI_ATTRIBUTES);
  __pyx_v_4lxml_5etree__FIND_PI_ATTRIBUTES = __pyx_83;
  __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":765
 * 
 * cdef object _RE_PI_HREF
 * _RE_PI_HREF = re.compile(ur'\s+href\s*=\s*["\']([^"\']+)["\']')             # <<<<<<<<<<<<<<
 * 
 * cdef object _FIND_PI_HREF
 */
  __pyx_85 = PyObject_GetAttr(__pyx_v_4lxml_5etree_re, __pyx_kp_compile); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(((PyObject *)__pyx_kp_194));
  PyTuple_SET_ITEM(__pyx_84, 0, ((PyObject *)__pyx_kp_194));
  __pyx_83 = PyObject_Call(__pyx_85, ((PyObject *)__pyx_84), NULL); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  Py_DECREF(__pyx_v_4lxml_5etree__RE_PI_HREF);
  __pyx_v_4lxml_5etree__RE_PI_HREF = __pyx_83;
  __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":768
 * 
 * cdef object _FIND_PI_HREF
 * _FIND_PI_HREF = _RE_PI_HREF.findall             # <<<<<<<<<<<<<<
 * 
 * cdef object _REPLACE_PI_HREF
 */
  __pyx_85 = PyObject_GetAttr(__pyx_v_4lxml_5etree__RE_PI_HREF, __pyx_kp_findall); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__FIND_PI_HREF);
  __pyx_v_4lxml_5etree__FIND_PI_HREF = __pyx_85;
  __pyx_85 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":771
 * 
 * cdef object _REPLACE_PI_HREF
 * _REPLACE_PI_HREF = _RE_PI_HREF.sub             # <<<<<<<<<<<<<<
 * 
 * cdef XPath __findStylesheetByID
 */
  __pyx_84 = PyObject_GetAttr(__pyx_v_4lxml_5etree__RE_PI_HREF, __pyx_kp_sub); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_v_4lxml_5etree__REPLACE_PI_HREF);
  __pyx_v_4lxml_5etree__REPLACE_PI_HREF = __pyx_84;
  __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xslt.pxi":774
 * 
 * cdef XPath __findStylesheetByID
 * __findStylesheetByID = None             # <<<<<<<<<<<<<<
 * 
 * cdef _findStylesheetByID(_Document doc, id):
 */
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)__pyx_v_4lxml_5etree___findStylesheetByID));
  __pyx_v_4lxml_5etree___findStylesheetByID = ((struct __pyx_obj_4lxml_5etree_XPath *)Py_None);

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/lxml.etree.pyx":2629
 * # Validation
 * 
 * class DocumentInvalid(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Validation error.
 * 
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_195) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_DocumentInvalid, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DocumentInvalid, __pyx_85) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":4
 * cimport dtdvalid
 * 
 * class DTDError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class for DTD errors.
 *     """
 */
  __pyx_84 = PyDict_New(); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_83 = PyTuple_New(1); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_83, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_84), "__doc__", __pyx_kp_196) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_83), ((PyObject *)__pyx_84), __pyx_kp_DTDError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DTDError, __pyx_85) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":9
 *     pass
 * 
 * class DTDParseError(DTDError):             # <<<<<<<<<<<<<<
 *     u"""Error while parsing a DTD.
 *     """
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_197) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_DTDParseError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DTDParseError, __pyx_85) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/dtd.pxi":14
 *     pass
 * 
 * class DTDValidateError(DTDError):             # <<<<<<<<<<<<<<
 *     u"""Error while validating an XML document with a DTD.
 *     """
 */
  __pyx_84 = PyDict_New(); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_DTDError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_83 = PyTuple_New(1); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_83, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_84), "__doc__", __pyx_kp_198) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_83), ((PyObject *)__pyx_84), __pyx_kp_DTDValidateError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_DTDValidateError, __pyx_85) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":4
 * cimport relaxng
 * 
 * class RelaxNGError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class for RelaxNG errors.
 *     """
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_199) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_RelaxNGError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_RelaxNGError, __pyx_85) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":9
 *     pass
 * 
 * class RelaxNGParseError(RelaxNGError):             # <<<<<<<<<<<<<<
 *     u"""Error while parsing an XML document as RelaxNG.
 *     """
 */
  __pyx_84 = PyDict_New(); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_83 = PyTuple_New(1); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_83, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_84), "__doc__", __pyx_kp_200) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_83), ((PyObject *)__pyx_84), __pyx_kp_RelaxNGParseError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_RelaxNGParseError, __pyx_85) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/relaxng.pxi":14
 *     pass
 * 
 * class RelaxNGValidateError(RelaxNGError):             # <<<<<<<<<<<<<<
 *     u"""Error while validating an XML document with a RelaxNG schema.
 *     """
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_RelaxNGError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_202) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_201, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_201, __pyx_85) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":4
 * cimport xmlschema
 * 
 * class XMLSchemaError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class of all XML Schema errors
 *     """
 */
  __pyx_84 = PyDict_New(); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_83 = PyTuple_New(1); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_83, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_84), "__doc__", __pyx_kp_203) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_83), ((PyObject *)__pyx_84), __pyx_kp_XMLSchemaError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XMLSchemaError, __pyx_85) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":9
 *     pass
 * 
 * class XMLSchemaParseError(XMLSchemaError):             # <<<<<<<<<<<<<<
 *     u"""Error while parsing an XML document as XML Schema.
 *     """
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSchemaError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_204) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_XMLSchemaParseError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_XMLSchemaParseError, __pyx_85) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/xmlschema.pxi":14
 *     pass
 * 
 * class XMLSchemaValidateError(XMLSchemaError):             # <<<<<<<<<<<<<<
 *     u"""Error while validating an XML document with an XML Schema.
 *     """
 */
  __pyx_84 = PyDict_New(); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_XMLSchemaError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_83 = PyTuple_New(1); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_83, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_84), "__doc__", __pyx_kp_206) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_83), ((PyObject *)__pyx_84), __pyx_kp_205, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_205, __pyx_85) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":4
 * cimport schematron
 * 
 * class SchematronError(LxmlError):             # <<<<<<<<<<<<<<
 *     u"""Base class of all Schematron errors.
 *     """
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_LxmlError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_207) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_SchematronError, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_SchematronError, __pyx_85) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":9
 *     pass
 * 
 * class SchematronParseError(SchematronError):             # <<<<<<<<<<<<<<
 *     u"""Error while parsing an XML document as Schematron schema.
 *     """
 */
  __pyx_84 = PyDict_New(); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_SchematronError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_83 = PyTuple_New(1); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_83, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_84), "__doc__", __pyx_kp_209) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_83), ((PyObject *)__pyx_84), __pyx_kp_208, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_208, __pyx_85) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/schematron.pxi":14
 *     pass
 * 
 * class SchematronValidateError(SchematronError):             # <<<<<<<<<<<<<<
 *     u"""Error while validating an XML document with a Schematron schema.
 *     """
 */
  __pyx_83 = PyDict_New(); if (unlikely(!__pyx_83)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_GetName(__pyx_m, __pyx_kp_SchematronError); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_84 = PyTuple_New(1); if (unlikely(!__pyx_84)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyTuple_SET_ITEM(__pyx_84, 0, __pyx_85);
  __pyx_85 = 0;
  if (PyDict_SetItemString(((PyObject *)__pyx_83), "__doc__", __pyx_kp_211) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_85 = __Pyx_CreateClass(((PyObject *)__pyx_84), ((PyObject *)__pyx_83), __pyx_kp_210, "lxml.etree"); if (unlikely(!__pyx_85)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(((PyObject *)__pyx_84)); __pyx_84 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_kp_210, __pyx_85) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_85); __pyx_85 = 0;
  Py_DECREF(((PyObject *)__pyx_83)); __pyx_83 = 0;

  /* "/home/sbehnel/source/Python/lxml/lxml-2.1/src/lxml/c14n.pxd":1
 * from tree cimport xmlDoc, xmlOutputBuffer             # <<<<<<<<<<<<<<
 * from xpath cimport xmlNodeSet
 * 
 */
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
  __pyx_L1_error:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  Py_XDECREF(__pyx_12);
  Py_XDECREF(__pyx_13);
  Py_XDECREF(__pyx_14);
  Py_XDECREF(__pyx_15);
  Py_XDECREF(__pyx_16);
  Py_XDECREF(__pyx_17);
  Py_XDECREF(__pyx_18);
  Py_XDECREF(__pyx_19);
  Py_XDECREF(__pyx_20);
  Py_XDECREF(__pyx_21);
  Py_XDECREF(__pyx_22);
  Py_XDECREF(__pyx_23);
  Py_XDECREF(__pyx_24);
  Py_XDECREF(__pyx_25);
  Py_XDECREF(__pyx_26);
  Py_XDECREF(__pyx_27);
  Py_XDECREF(__pyx_28);
  Py_XDECREF(__pyx_29);
  Py_XDECREF(__pyx_30);
  Py_XDECREF(__pyx_31);
  Py_XDECREF(__pyx_32);
  Py_XDECREF(__pyx_33);
  Py_XDECREF(__pyx_34);
  Py_XDECREF(__pyx_35);
  Py_XDECREF(__pyx_36);
  Py_XDECREF(__pyx_37);
  Py_XDECREF(__pyx_38);
  Py_XDECREF(__pyx_39);
  Py_XDECREF(__pyx_40);
  Py_XDECREF(__pyx_41);
  Py_XDECREF(__pyx_42);
  Py_XDECREF(__pyx_43);
  Py_XDECREF(__pyx_44);
  Py_XDECREF(__pyx_45);
  Py_XDECREF(__pyx_46);
  Py_XDECREF(__pyx_47);
  Py_XDECREF(__pyx_48);
  Py_XDECREF(__pyx_49);
  Py_XDECREF(__pyx_50);
  Py_XDECREF(__pyx_51);
  Py_XDECREF(__pyx_52);
  Py_XDECREF(__pyx_53);
  Py_XDECREF(__pyx_54);
  Py_XDECREF(__pyx_55);
  Py_XDECREF(__pyx_56);
  Py_XDECREF(__pyx_57);
  Py_XDECREF(__pyx_58);
  Py_XDECREF(__pyx_59);
  Py_XDECREF(__pyx_60);
  Py_XDECREF(__pyx_61);
  Py_XDECREF(__pyx_62);
  Py_XDECREF(__pyx_63);
  Py_XDECREF(__pyx_64);
  Py_XDECREF(__pyx_65);
  Py_XDECREF(__pyx_66);
  Py_XDECREF(__pyx_67);
  Py_XDECREF(__pyx_68);
  Py_XDECREF(__pyx_69);
  Py_XDECREF(__pyx_70);
  Py_XDECREF(__pyx_71);
  Py_XDECREF(__pyx_72);
  Py_XDECREF(__pyx_73);
  Py_XDECREF(__pyx_74);
  Py_XDECREF(__pyx_75);
  Py_XDECREF(__pyx_76);
  Py_XDECREF(__pyx_77);
  Py_XDECREF(__pyx_78);
  Py_XDECREF(__pyx_79);
  Py_XDECREF(__pyx_80);
  Py_XDECREF(__pyx_81);
  Py_XDECREF(__pyx_82);
  Py_XDECREF(__pyx_83);
  Py_XDECREF(__pyx_84);
  Py_XDECREF(__pyx_85);
  __Pyx_AddTraceback("lxml.etree");
  #if PY_MAJOR_VERSION >= 3
  return NULL;
  #endif
}

static const char *__pyx_filenames[] = {
  "lxml.etree.pyx",
  "apihelpers.pxi",
  "parser.pxi",
  "serializer.pxi",
  "xmlid.pxi",
  "extensions.pxi",
  "proxy.pxi",
  "xmlerror.pxi",
  "readonlytree.pxi",
  "classlookup.pxi",
  "nsclasses.pxi",
  "docloader.pxi",
  "saxparser.pxi",
  "parsertarget.pxi",
  "iterparse.pxi",
  "xinclude.pxi",
  "xpath.pxi",
  "xslt.pxi",
  "xsltext.pxi",
  "dtd.pxi",
  "relaxng.pxi",
  "xmlschema.pxi",
  "schematron.pxi",
  "public-api.pxi",
  "python.pxd",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
        #endif
            goto invalid_keyword_type;
        } else {
            name = argnames;
            while (*name && (**name != key)) name++;
            if (*name) {
                if (name < first_kw_arg) goto arg_passed_twice;
                values[name-argnames] = value;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        strcmp(PyString_AS_STRING(**name),
                               PyString_AS_STRING(key)) == 0) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            strcmp(PyString_AS_STRING(**name),
                                   PyString_AS_STRING(key)) == 0) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}



static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


static INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    __Pyx_ErrFetch(type, value, tb);
    PyErr_NormalizeException(type, value, tb);
    if (PyErr_Occurred())
        goto bad;
    Py_INCREF(*type);
    Py_INCREF(*value);
    Py_INCREF(*tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    /* Make sure tstate is in a consistent state when we XDECREF
    these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    Py_XDECREF(*type);
    Py_XDECREF(*value);
    Py_XDECREF(*tb);
    return -1;
}


static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;

    #if PY_MAJOR_VERSION < 3
    py_modname = PyString_FromString(modname);
    #else
    py_modname = PyUnicode_FromString(modname);
    #endif
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    result = PyClass_New(bases, dict, name);
    #else
    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
    #endif
bad:
    Py_XDECREF(py_modname);
    return result;
}

#if PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject("stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}

static int __Pyx_Print(PyObject *arg_tuple, int newline) {
    PyObject *f;
    PyObject* v;
    int i;
    
    if (!(f = __Pyx_GetStdout()))
        return -1;
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                return -1;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            return -1;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0 &&
                isspace(Py_CHARMASK(s[len-1])) &&
                s[len-1] != ' ')
                    PyFile_SoftSpace(f, 0);
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            return -1;
        PyFile_SoftSpace(f, 0);
    }
    return 0;
}

#else /* Python 3 has a print function */
static int __Pyx_Print(PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (!__pyx_print) {
        __pyx_print = PyObject_GetAttrString(__pyx_b, "print");
        if (!__pyx_print)
            return -1;
    }
    if (!newline) {
        if (!__pyx_print_kwargs) {
            __pyx_print_kwargs = PyDict_New();
            if (!__pyx_print_kwargs)
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (!end_string)
                return -1;
            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
}
#endif

static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (obj == Py_None || PyObject_TypeCheck(obj, type))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
        Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            PyErr_Format(PyExc_ValueError,
                #if PY_VERSION_HEX < 0x02050000
                    "need more than %d values to unpack", (int)index);
                #else
                    "need more than %zd values to unpack", index);
                #endif
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        PyErr_SetString(PyExc_ValueError, "too many values to unpack");
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = PyObject_GetAttr(o, n);
    if (!r) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return 0;
}

static void __Pyx_WriteUnraisable(const char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_ExportFunction(char *name, void *f, char *sig) {
    PyObject *d = 0;
    PyObject *p = 0;
    d = PyObject_GetAttrString(__pyx_m, "__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, "__pyx_capi__", d) < 0)
            goto bad;
    }
    p = PyCObject_FromVoidPtrAndDesc(f, sig, 0);
    if (!p)
        goto bad;
    if (PyDict_SetItemString(d, name, p) < 0)
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(p);
    Py_XDECREF(d);
    return -1;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
    PyObject *pycobj = 0;
    int result;
    
    pycobj = PyCObject_FromVoidPtr(vtable, 0);
    if (!pycobj)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
        goto bad;
    result = 0;
    goto done;

bad:
    result = -1;
done:
    Py_XDECREF(pycobj);
    return result;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError, 
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s does not appear to be the correct type object",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    #if PY_MAJOR_VERSION < 3
    empty_string = PyString_FromStringAndSize("", 0);
    #else
    empty_string = PyBytes_FromStringAndSize("", 0);
    #endif
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode && (!t->is_identifier)) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_identifier || (t->is_unicode && t->intern)) {
            *t->p = PyUnicode_InternFromString(t->s);
        } else if (t->is_unicode) {
            *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   if (x == Py_True) return 1;
   else if (x == Py_False) return 0;
   else return PyObject_IsTrue(x);
}

static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
    if (PyInt_CheckExact(x)) {
        return PyInt_AS_LONG(x);
    }
    else if (PyLong_CheckExact(x)) {
        return PyLong_AsLongLong(x);
    }
    else {
        PY_LONG_LONG val;
        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
        val = __pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    if (PyInt_CheckExact(x)) {
        long val = PyInt_AS_LONG(x);
        if (unlikely(val < 0)) {
            PyErr_SetString(PyExc_TypeError, "Negative assignment to unsigned type.");
            return (unsigned PY_LONG_LONG)-1;
        }
        return val;
    }
    else if (PyLong_CheckExact(x)) {
        return PyLong_AsUnsignedLongLong(x);
    }
    else {
        PY_LONG_LONG val;
        PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
        val = __pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}


static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x) {
    if (sizeof(unsigned char) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        unsigned char val = (unsigned char)long_val;
        if (unlikely((val != long_val)  || (long_val < 0))) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned char");
            return (unsigned char)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x) {
    if (sizeof(unsigned short) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        unsigned short val = (unsigned short)long_val;
        if (unlikely((val != long_val)  || (long_val < 0))) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short");
            return (unsigned short)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE char __pyx_PyInt_char(PyObject* x) {
    if (sizeof(char) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        char val = (char)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to char");
            return (char)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE short __pyx_PyInt_short(PyObject* x) {
    if (sizeof(short) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        short val = (short)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to short");
            return (short)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE int __pyx_PyInt_int(PyObject* x) {
    if (sizeof(int) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        int val = (int)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to int");
            return (int)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE long __pyx_PyInt_long(PyObject* x) {
    if (sizeof(long) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        long val = (long)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long");
            return (long)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed char __pyx_PyInt_signed_char(PyObject* x) {
    if (sizeof(signed char) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed char val = (signed char)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed char");
            return (signed char)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed short __pyx_PyInt_signed_short(PyObject* x) {
    if (sizeof(signed short) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed short val = (signed short)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed short");
            return (signed short)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed int __pyx_PyInt_signed_int(PyObject* x) {
    if (sizeof(signed int) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed int val = (signed int)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed int");
            return (signed int)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE signed long __pyx_PyInt_signed_long(PyObject* x) {
    if (sizeof(signed long) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        signed long val = (signed long)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed long");
            return (signed long)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

static INLINE long double __pyx_PyInt_long_double(PyObject* x) {
    if (sizeof(long double) < sizeof(long)) {
        long long_val = __pyx_PyInt_AsLong(x);
        long double val = (long double)long_val;
        if (unlikely((val != long_val) )) {
            PyErr_SetString(PyExc_OverflowError, "value too large to convert to long double");
            return (long double)-1;
        }
        return val;
    }
    else {
        return __pyx_PyInt_AsLong(x);
    }
}

