AlkantarClanX12

Your IP : 18.119.192.2


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/xml/dom/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/xml/dom/__pycache__/minidom.cpython-35.pyc



��Yf�@s1dZddlZddlZddlmZmZmZmZddlTddl	m
Z
mZejj
jejj
jfZGdd�dejj
�Z
ee
dd	d
�ee
dd	d�ee
d
d	d�dd�Zdd�Zdd�Zdd�Zdd�ZGdd�de
�ZGdd�de
�Zeedd	d�eed
d	d�eed d	d!�Gd"d#�d#e�Zeed$d	d%�eZGd&d'�d'e�Zedd�ZGd(d)�d)e
�Zeed*d	d+�eed
d	d,�d-d.�ZGd/d0�d0�Z Gd1d2�d2e e
�Z!Gd3d4�d4e e
�Z"ee"d$d	d5�Gd6d7�d7e"�Z#ee#d8d	d9�ee#d:d	d;�d<d=�Z$d>d?�Z%Gd@dA�dAe"�Z&GdBdC�dCe#�Z'GdDdE�dEe�Z(ee(d$d	dF�GdGdH�dH�Z)GdIdJ�dJe)e e
�Z*GdKdL�dLe)e
�Z+GdMdN�dNe)e e
�Z,GdOdP�dPe
�Z-GdQdR�dRe�Z.dSdT�Z/GdUdV�dVe
e�Z0ee0dWd	dX�dYdZ�Z1d[d\�Z2d]d^�Z3ddd_d`�Z4ddadb�Z5ddcdd�Z6dS)eacSimple implementation of the Level 1 DOM.

Namespaces and other minor Level 2 features are also supported.

parse("foo.xml")

parseString("<foo><bar/></foo>")

Todo:
=====
 * convenience methods for getting elements and text.
 * more testing
 * bring some of the writer and linearizer code into conformance with this
        interface
 * SAX 2 namespaces
�N)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE�domreg)�*)�DOMImplementationLS�
DocumentLSc@sTeZdZdZdZdZdZdZeZ	dd�Z
ddd�Zddddd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dS)2�NodeNcCsdS)NT�)�selfr
r
�4/opt/alt/python35/lib64/python3.5/xml/dom/minidom.py�__bool__+sz
Node.__bool__cCs|jdd|�S)N�)�toprettyxml)r�encodingr
r
r�toxml.sz
Node.toxml�	�
cCs�|dkrtj�}n'tjtj�d|dddd�}|jtjkrp|j|d|||�n|j|d||�|dkr�|j�S|j	�j�SdS)Nr�errors�xmlcharrefreplace�newlinerr)
�io�StringIO�
TextIOWrapper�BytesIO�nodeTyper	�
DOCUMENT_NODE�writexml�getvalue�detach)r�indent�newlr�writerr
r
rr1s	
zNode.toprettyxmlcCs
t|j�S)N)�bool�
childNodes)rr
r
r�
hasChildNodesCszNode.hasChildNodescCs|jS)N)r$)rr
r
r�_get_childNodesFszNode._get_childNodescCs|jr|jdSdS)Nr)r$)rr
r
r�_get_firstChildIs	zNode._get_firstChildcCs|jr|jdSdS)N����)r$)rr
r
r�_get_lastChildMs	zNode._get_lastChildcCso|j|jkr@x't|j�D]}|j||�q"W|S|j|jkrztjjdt	|�t	|�f��|j
dk	r�|j
j|�|dkr�|j|�n�y|jj
|�}Wn!tk
r�tjj��YnX|jtkrt|�|jj||�||_||_|rY|j|d}||_||_n	d|_||_
|S)Nz%s cannot be child of %sr()r�DOCUMENT_FRAGMENT_NODE�tupler$�insertBefore�_child_node_types�xml�dom�HierarchyRequestErr�repr�
parentNode�removeChild�appendChild�index�
ValueError�NotFoundErr�_nodeTypes_with_children�_clear_id_cache�insert�nextSibling�previousSibling)r�newChild�refChild�cr6�noder
r
rr-Qs6	

					zNode.insertBeforecCs�|j|jkr=x$t|j�D]}|j|�q"W|S|j|jkrztjjdt	|�t	|�f��n|jt
kr�t|�|jdk	r�|jj
|�t||�d|_|S)Nz%s cannot be child of %s)rr+r,r$r5r.r/r0r1r2r9r:r3r4�
_append_childr<)rrAr@r
r
rr5qs	"

	zNode.appendChildcCsz|j|jkr8|j}|j|�|j||�S|j|jkrrtjjdt	|�t	|�f��||kr�dS|j
dk	r�|j
j|�y|jj|�}Wn!t
k
r�tjj��YnX||j|<||_
d|_
|jtks|jtkr"t|�|j|_|j|_d|_d|_|jra||j_|jrv||j_|S)Nz%s cannot be child of %s)rr+r<r4r-r.r/r0r1r2r3r$r6r7r8r9r:r=)rr>�oldChildr?r6r
r
r�replaceChild�s<	
	

		
				zNode.replaceChildcCs�y|jj|�Wn!tk
r7tjj��YnX|jdk	rV|j|j_|jdk	rt|j|j_d|_|_|jt	kr�t
|�d|_|S)N)r$�remover7r/r0r8r<r=rr9r:r3)rrCr
r
rr4�s

	zNode.removeChildcCs'g}x|jD]�}|jtjkr�|jsl|rG|j|d_|jr_|j|j_|j�q|r�|dj|jkr�|d}|j|j|_|j|_|jr�||j_|j�q|j|�q|j|�|jtj	kr|j
�qW||jdd�<dS)Nr(r)r)r))r$rr	�	TEXT_NODE�datar<r=�unlink�append�ELEMENT_NODE�	normalize)r�L�childrAr
r
rrK�s*		

	

zNode.normalizecCst|||jp|�S)N)�_clone_node�
ownerDocument)r�deepr
r
r�	cloneNode�szNode.cloneNodecCs|jjj||�S)N)rO�implementation�
hasFeature)r�feature�versionr
r
r�isSupported�szNode.isSupportedcCsdS)Nr
)rr
r
r�_get_localName�szNode._get_localNamecCs
||kS)Nr
)r�otherr
r
r�
isSameNode�szNode.isSameNodecCs|j|d�r|SdSdS)N)rV)rrTr
r
r�getInterface�szNode.getInterfacecCs6y|j|dSWnttfk
r1dSYnXdS)Nr)�
_user_data�AttributeError�KeyError)r�keyr
r
r�getUserData�szNode.getUserDatacCs�d}y
|j}Wn!tk
r6i}||_YnX||krQ||d}|dkryd}|dk	r�||=n||f||<|S)Nr)r[r\)rr^rG�handler�old�dr
r
r�setUserData�s


zNode.setUserDatacCsdt|d�r`xNt|jj��D]7\}\}}|dk	r%|j|||||�q%WdS)Nr[)�hasattr�listr[�itemsZhandle)r�	operation�srcZdstr^rGr`r
r
r�_call_user_data_handler�s(zNode._call_user_data_handlercCsYd|_|_|jrCx|jD]}|j�q#Wt�|_d|_d|_dS)N)r3rOr$rH�NodeListr=r<)rrMr
r
rrHs		zNode.unlinkcCs|S)Nr
)rr
r
r�	__enter__szNode.__enter__cCs|j�dS)N)rH)rZetZev�tbr
r
r�__exit__sz
Node.__exit__)!�__name__�
__module__�__qualname__�namespaceURIr3rOr<r=r�prefixr
rrr%r&r'r*r-r5rDr4rKrQrVrWrYrZr_rcrirHrkrmr
r
r
rr	"s:  
r	�
firstChild�doczFirst child node, or None.�	lastChildzLast child node, or None.�	localNamez"Namespace-local name of this node.cCsE|j}|r+|d}||_||_|j|�||_dS)Nr(r))r$r=r<rIr3)rrAr$Zlastr
r
rrBs	
		
rBcCs6x/|dk	r1|jtjkr%dS|j}qWdS)NTF)rr	rr3)rAr
r
r�_in_document&s

rwcCsM|rI|jdd�jdd�jdd�jdd�}|j|�d	S)
zWrites datachars to writer.�&z&amp;�<z&lt;�"z&quot;�>z&gt;N)�replace�write)r"rGr
r
r�_write_data.sr~cCsbx[|jD]P}|jtjkrJ|dks=|j|krJ|j|�t|||�q
W|S)Nr)r$rr	rJ�tagNamerI�_get_elements_by_tagName_helper)�parent�name�rcrAr
r
rr�5s
r�cCs�xy|jD]n}|jtjkr
|dks=|j|kre|dksX|j|kre|j|�t||||�q
W|S)Nr)r$rr	rJrvrqrI�"_get_elements_by_tagName_ns_helper)r�ZnsURIrvr�rAr
r
rr�=s
r�c@smeZdZejZdZdZdZdZ	ej
ejejej
ejejejfZdd�ZdS)�DocumentFragmentz#document-fragmentNcCst�|_dS)N)rjr$)rr
r
r�__init__TszDocumentFragment.__init__)rnrorpr	r+r�nodeName�	nodeValue�
attributesr3rJrF�CDATA_SECTION_NODE�ENTITY_REFERENCE_NODE�PROCESSING_INSTRUCTION_NODE�COMMENT_NODE�
NOTATION_NODEr.r�r
r
r
rr�Fs	r�c@seZdZd#ZejZd	Zd
Zd
Z	ej
ejfZe
d	d	dd�Zd
d�Zdd�Zdd�Zdd�Zeee�ZZdd�Zdd�Zeee�ZZdd�Zdd�Zeee�Zdd�Zdd �Zd!d"�Zd	S)$�Attr�_name�_valuerq�_prefixr$�
_localNamerO�ownerElementNFcCsGd|_||_||_||_t�|_|jjt��dS)N)r�r�rqr�rjr$rI�Text)r�qNamerqrvrrr
r
rr�bs				z
Attr.__init__cCs;y|jSWn)tk
r6|jjdd�dSYnXdS)N�:r(r))r�r\r��split)rr
r
rrWos
zAttr._get_localNamecCs|jS)N)�	specified)rr
r
r�_get_specifieduszAttr._get_specifiedcCs|jS)N)r�)rr
r
r�	_get_namexszAttr._get_namecCs)||_|jdk	r%t|j�dS)N)r�r�r:)r�valuer
r
r�	_set_name{s	zAttr._set_namecCs|jS)N)r�)rr
r
r�
_get_value�szAttr._get_valuecCsI||_||jd_|jdk	r5t|j�||jd_dS)Nr)r�r$rGr�r:)rr�r
r
r�
_set_value�s
	
zAttr._set_valuecCs|jS)N)r�)rr
r
r�_get_prefix�szAttr._get_prefixcCs�|j}|dkr9|r9|tkr9tjjd��||_|dkrZ|j}nd||jf}|jr�t|j�||_	dS)N�xmlnsz5illegal use of 'xmlns' prefix for the wrong namespacez%s:%s)
rqrr/r0�NamespaceErrr�rvr�r:r�)rrrZnsuriZnewNamer
r
r�_set_prefix�s					
zAttr._set_prefixcCs�|j}|dk	rk|j|j=|j|j|jf=|jrkd|_|jd8_|jj	d8_	x|j
D]}|j�quW|j
dd�=dS)NFr()r��_attrsr��_attrsNSrqrv�_is_id�_magic_id_nodesrO�_magic_id_countr$rH)r�elemrMr
r
rrH�s	
		zAttr.unlinkcCs�|jr
dS|j}|j}|dks7|dkr;dS|j|�}|dkrZdS|jry|j|j|j�S|j|j�SdS)NTF)	r�rOr��_get_elem_inforq�isIdNSrv�isIdr�)rrtr��infor
r
r�	_get_isId�s				zAttr._get_isIdcCs�|j}|j}|dks*|dkr.tS|j|�}|dkrMtS|jrl|j|j|j�S|j|j�SdS)N)	rOr��_no_typer�rq�getAttributeTypeNSrv�getAttributeTyper�)rrtr�r�r
r
r�_get_schemaType�s			zAttr._get_schemaType)r�r�rqr�r$r�rOr�) rnrorp�	__slots__r	�ATTRIBUTE_NODErr�r�r�rFr�r.rr�rWr�r�r��propertyr�r�r�r�r�r�r�r�rrrHr�r�r
r
r
rr�Xs.	r�r�z True if this attribute is an ID.z'Namespace-local name of this attribute.�
schemaTypezSchema type for this attribute.c@sieZdZdZd<Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
ddd�ZeZdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z dS)=�NamedNodeMapaThe attribute list is a transient interface to the underlying
    dictionaries.  Mutations here will change the underlying element's
    dictionary.

    Ordering is imposed artificially and does not reflect the order of
    attributes as found in an input document.
    r�r��
_ownerElementcCs||_||_||_dS)N)r�r�r�)r�attrsZattrsNSr�r
r
rr��s		zNamedNodeMap.__init__cCs
t|j�S)N)�lenr�)rr
r
r�_get_length�szNamedNodeMap._get_lengthcCs<y|t|jj��|SWntk
r7dSYnXdS)N)rer��keys�
IndexError)rr6r
r
r�item�s
zNamedNodeMap.itemcCs=g}x0|jj�D]}|j|j|jf�qW|S)N)r��valuesrIr�r�)rrLrAr
r
rrf�szNamedNodeMap.itemscCsFg}x9|jj�D](}|j|j|jf|jf�qW|S)N)r�r�rIrqrvr�)rrLrAr
r
r�itemsNS�s&zNamedNodeMap.itemsNScCs-t|t�r||jkS||jkSdS)N)�
isinstance�strr�r�)rr^r
r
r�__contains__�s
zNamedNodeMap.__contains__cCs
|jj�S)N)r�r�)rr
r
rr�szNamedNodeMap.keyscCs
|jj�S)N)r�r�)rr
r
r�keysNSszNamedNodeMap.keysNScCs
|jj�S)N)r�r�)rr
r
rr�szNamedNodeMap.valuesNcCs|jj||�S)N)r��get)rr�r�r
r
rr�
szNamedNodeMap.getcCsO|jt|dd�krdSt|�t|�kt|�t|�kSdS)Nr�r)r��getattr�id)rrXr
r
r�_cmpszNamedNodeMap._cmpcCs|j|�dkS)Nr)r�)rrXr
r
r�__eq__szNamedNodeMap.__eq__cCs|j|�dkS)Nr)r�)rrXr
r
r�__ge__szNamedNodeMap.__ge__cCs|j|�dkS)Nr)r�)rrXr
r
r�__gt__szNamedNodeMap.__gt__cCs|j|�dkS)Nr)r�)rrXr
r
r�__le__szNamedNodeMap.__le__cCs|j|�dkS)Nr)r�)rrXr
r
r�__lt__!szNamedNodeMap.__lt__cCs)t|t�r|j|S|j|SdS)N)r�r,r�r�)r�attname_or_tupler
r
r�__getitem__$szNamedNodeMap.__getitem__cCs�t|t�riy|j|}Wn:tk
r\t|�}|jj|_|j|�YnX||_n.t|t�s�t	d��|}|j|�dS)Nz%value must be a string or Attr object)
r�r�r�r]r�r�rO�setNamedItemr��	TypeError)r�attnamer�rAr
r
r�__setitem__+s
zNamedNodeMap.__setitem__cCs,y|j|SWntk
r'dSYnXdS)N)r�r])rr�r
r
r�getNamedItem:s
zNamedNodeMap.getNamedItemcCs2y|j||fSWntk
r-dSYnXdS)N)r�r])rrqrvr
r
r�getNamedItemNS@s
zNamedNodeMap.getNamedItemNScCsz|j|�}|dk	rgt|j�|j|j=|j|j|jf=t|d�rcd|_	|St
jj��dS)Nr�)
r�r:r�r�r�r�rqrvrdr�r/r0r8)rr��nr
r
r�removeNamedItemFs

	zNamedNodeMap.removeNamedItemcCs}|j||�}|dk	rjt|j�|j|j|jf=|j|j=t|d�rfd|_	|St
jj��dS)Nr�)
r�r:r�r�rqrvr�r�rdr�r/r0r8)rrqrvr�r
r
r�removeNamedItemNSRs

	zNamedNodeMap.removeNamedItemNScCs�t|t�s7tjjdt|�t|�f��|jj|j�}|r\|j	�||j|j<||j
|j|jf<|j
|_t|j�|S)Nz%s cannot be child of %s)r�r�r/r0r1r2r�r�r�rHr�rqrvr�r�r:)rrArar
r
rr�^s	

zNamedNodeMap.setNamedItemcCs
|j|�S)N)r�)rrAr
r
r�setNamedItemNSkszNamedNodeMap.setNamedItemNScCs%||}t|j�|j�dS)N)r:r�rH)rr�rAr
r
r�__delitem__ns

zNamedNodeMap.__delitem__cCs|j|j|jfS)N)r�r�r�)rr
r
r�__getstate__sszNamedNodeMap.__getstate__cCs|\|_|_|_dS)N)r�r�r�)r�stater
r
r�__setstate__vszNamedNodeMap.__setstate__)r�r�r�)!rnrorp�__doc__r�r�r�r�rfr�r�r�r�r�r��__len__r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr��s<
r�Zlengthz$Number of nodes in the NamedNodeMap.c@sFeZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)
�TypeInfo�	namespacer�cCs||_||_dS)N)r�r�)rr�r�r
r
rr��s	zTypeInfo.__init__cCsA|jr&d|jj|j|jfSd|jj|jfSdS)Nz<%s %r (from %r)>z<%s %r>)r��	__class__rnr�)rr
r
r�__repr__�s	zTypeInfo.__repr__cCs|jS)N)r�)rr
r
rr��szTypeInfo._get_namecCs|jS)N)r�)rr
r
r�_get_namespace�szTypeInfo._get_namespaceN)r�r�)rnrorpr�r�r�r�r�r
r
r
rr�s
r�c@s�eZdZdDZejZd
ZeZ	dZ
ejejejej
ejejfZed
d
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZeZd'd(�Zd)d*�Z d+d,�Z!e!Z"d-d.�Z#d/d0�Z$d1d2�Z%d3d4�Z&d5d6�Z'd7d7d7d8d9�Z(d:d;�Z)d<d=�Z*d>d?�Z+d@dA�Z,dBdC�Z-d
S)E�ElementrOr3rr�rrrqr�r$r�r�r<r=NrcCs]d|_||_|_||_||_t�|_d|_|_d|_	d|_
dS)N)r3rr�rrrqrjr$r<r=r�r�)rrrqrrrvr
r
rr��s			
	zElement.__init__cCs%|jdkr!i|_i|_dS)N)r�r�)rr
r
r�_ensure_attributes�s	zElement._ensure_attributescCs;y|jSWn)tk
r6|jjdd�dSYnXdS)Nr�r(r))r�r\rr�)rr
r
rrW�s
zElement._get_localNamecCs|jS)N)r)rr
r
r�_get_tagName�szElement._get_tagNamecCs\|jdk	r9x't|jj��D]}|j�q%Wd|_d|_tj|�dS)N)r�rer�rHr�r	)r�attrr
r
rrH�s		zElement.unlinkcCsB|jdkrdSy|j|jSWntk
r=dSYnXdS)Nr)r�r�r])rr�r
r
r�getAttribute�s
zElement.getAttributecCsH|jdkrdSy|j||fjSWntk
rCdSYnXdS)Nr)r�r�r])rrqrvr
r
r�getAttributeNS�s
zElement.getAttributeNScCs{|j|�}|dkrLt|�}||_|j|_|j|�n+||jkrw||_|jrwt|�dS)N)�getAttributeNoder�r�rO�setAttributeNoder�r:)rr�r�r�r
r
r�setAttribute�s			zElement.setAttributecCs�t|�\}}|j||�}|dkrjt||||�}||_|j|_|j|�nL||jkr�||_|jr�t|�|j|kr�||_||_	dS)N)
�_nssplit�getAttributeNodeNSr�r�rOr�r�r:rrr�)rrq�
qualifiedNamer�rr�	localnamer�r
r
r�setAttributeNS�s			
	zElement.setAttributeNScCs#|jdkrdS|jj|�S)N)r�r�)rZattrnamer
r
rr��szElement.getAttributeNodecCs)|jdkrdS|jj||f�S)N)r�r�)rrqrvr
r
rr�szElement.getAttributeNodeNScCs�|jd|fkr'tjjd��|j�|jj|jd�}|dk	rb|j|�|j	j|j
|jfd�}|dk	r�||k	r�|j|�t||�||k	r�|S||k	r�|SdS)Nzattribute node already owned)
r�r/r0ZInuseAttributeErrr�r�r�r��removeAttributeNoder�rqrv�_set_attribute_node)rr�Zold1Zold2r
r
rr�s

!

zElement.setAttributeNodecCsd|jdkrtjj��y|j|}Wn!tk
rRtjj��YnX|j|�dS)N)r�r/r0r8r�r]r�)rr�r�r
r
r�removeAttributes
zElement.removeAttributecCsj|jdkrtjj��y|j||f}Wn!tk
rXtjj��YnX|j|�dS)N)r�r/r0r8r]r�)rrqrvr�r
r
r�removeAttributeNS%s
zElement.removeAttributeNScCsu|dkrtjj��y|j|jWn!tk
rPtjj��YnXt|�|j�|j|_dS)N)	r/r0r8r�r�r]r:rHrO)rrAr
r
rr�.s


zElement.removeAttributeNodecCs |jdkrdS||jkS)NF)r�)rr�r
r
r�hasAttribute=szElement.hasAttributecCs&|jdkrdS||f|jkS)NF)r�)rrqrvr
r
r�hasAttributeNSBszElement.hasAttributeNScCst||t��S)N)r�rj)rr�r
r
r�getElementsByTagNameGszElement.getElementsByTagNamecCst|||t��S)N)r�rj)rrqrvr
r
r�getElementsByTagNameNSJszElement.getElementsByTagNameNScCsd|jt|�fS)Nz<DOM Element: %s at %#x>)rr�)rr
r
rr�NszElement.__repr__rc	CsW|j|d|j�|j�}t|j��}x@|D]8}|jd|�t|||j�|jd�q=W|jrB|jd�t|j�dkr�|jdj	t
jkr�|jdj|ddd�nH|j|�x+|jD] }|j|||||�q�W|j|�|jd|j|f�n|jd	|�dS)
Nryz %s="rzr{r(rrz</%s>%sz/>%s)
r}r�_get_attributes�sortedr�r~r�r$r�rr	rFr)	rr"r �	addindentr!r�Za_namesZa_namerAr
r
rrQs$
	
 

zElement.writexmlcCs |j�t|j|j|�S)N)r�r�r�r�)rr
r
rr�ls
zElement._get_attributescCs|jr
dSdSdS)NTF)r�)rr
r
r�
hasAttributesps	zElement.hasAttributescCs |j|�}|j|�dS)N)r��setIdAttributeNode)rr��idAttrr
r
r�setIdAttributexszElement.setIdAttributecCs#|j||�}|j|�dS)N)r�r�)rrqrvrr
r
r�setIdAttributeNS|szElement.setIdAttributeNScCs�|dks|j|j�r.tjj��t|�dk	rOtjj��|js�d|_|jd7_|j	j
d7_
t|�dS)NTr()rYr�r/r0r8�_get_containing_entref�NoModificationAllowedErrr�r�rOr�r:)rrr
r
rr��s		zElement.setIdAttributeNode)rOr3rr�rrrqr�r$r�r�r<r=).rnrorpr�r	rJrr�r�r�r�r�r�rFr�r�r.rr�r�rWr�rHr�r�r�r�r�r�r�ZsetAttributeNodeNSr�r�r�ZremoveAttributeNodeNSr�r�r�r�r�rr�r�rrr�r
r
r
rr��sT			
r�r�z*NamedNodeMap of attributes on the element.z%Namespace-local name of this element.cCsJt|�|j�||j|j<||j|j|jf<||_dS)N)r:r�r�r�r�rqrvr�)�elementr�r
r
rr��s


r�c@s�eZdZdZfZdZe�ZdZdZ	dd�Z
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zdd�ZdS)�	Childlessz�Mixin that makes childless-ness easy to implement and avoids
    the complexity of the Node methods that deal with children.
    NcCsdS)Nr
)rr
r
rr'�szChildless._get_firstChildcCsdS)Nr
)rr
r
rr*�szChildless._get_lastChildcCstjj|jd��dS)Nz nodes cannot have children)r/r0r1r�)rrAr
r
rr5�s	zChildless.appendChildcCsdS)NFr
)rr
r
rr%�szChildless.hasChildNodescCstjj|jd��dS)Nz nodes do not have children)r/r0r1r�)rr>r?r
r
rr-�s	zChildless.insertBeforecCstjj|jd��dS)Nz nodes do not have children)r/r0r8r�)rrCr
r
rr4�s	zChildless.removeChildcCsdS)Nr
)rr
r
rrK�szChildless.normalizecCstjj|jd��dS)Nz nodes do not have children)r/r0r1r�)rr>rCr
r
rrD�s	zChildless.replaceChild)rnrorpr�r�r�Z
EmptyNodeListr$rsrur'r*r5r%r-r4rKrDr
r
r
rr�s	rc@s�eZdZejZdZdd�Zdd�Zdd�Z	e
ee	�Zd	d
�Zdd�Z
e
ee
�Zd
d
d
dd�ZdS)�ProcessingInstruction�targetrGcCs||_||_dS)N)rrG)rrrGr
r
rr��s	zProcessingInstruction.__init__cCs|jS)N)rG)rr
r
r�_get_nodeValue�sz$ProcessingInstruction._get_nodeValuecCs
||_dS)N)rG)rr�r
r
r�_set_nodeValue�sz$ProcessingInstruction._set_nodeValuecCs|jS)N)r)rr
r
r�
_get_nodeName�sz#ProcessingInstruction._get_nodeNamecCs
||_dS)N)r)rr�r
r
r�
_set_nodeName�sz#ProcessingInstruction._set_nodeNamercCs'|jd||j|j|f�dS)Nz
%s<?%s %s?>%s)r}rrG)rr"r r�r!r
r
rr�szProcessingInstruction.writexmlN)rrG)rnrorpr	r�rr�r�r	r
r�r�rrr�rr
r
r
rr�s	rc@s�eZdZdZdd�Zdd	�ZeZd
d�Zdd
�Ze	ee�Z
Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�
CharacterData�_datarOr3r=r<cCs:d|_|_d|_|_d|_tj|�dS)Nr)rOr3r=r<rr	r�)rr
r
rr��s	zCharacterData.__init__cCs
t|j�S)N)r�rG)rr
r
rr��szCharacterData._get_lengthcCs|jS)N)r)rr
r
r�	_get_data�szCharacterData._get_datacCs
||_dS)N)r)rrGr
r
r�	_set_data�szCharacterData._set_datacCsK|j}t|�dkr$d}nd}d|jj|dd�|fS)N�
z...rz<DOM %s node "%r%s">r)rGr�r�rn)rrGZ	dotdotdotr
r
rr��s		zCharacterData.__repr__cCsx|dkrtjjd��|t|j�krEtjjd��|dkrctjjd��|j|||�S)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negative)r/r0�IndexSizeErrr�rG)r�offset�countr
r
r�
substringData�szCharacterData.substringDatacCs|j||_dS)N)rG)r�argr
r
r�
appendDataszCharacterData.appendDatacCs|dkrtjjd��|t|j�krEtjjd��|r{d|jd|�||j|d�f|_dS)Nrzoffset cannot be negativez#offset cannot be beyond end of dataz%s%s%s)r/r0rr�rG)rrrr
r
r�
insertDataszCharacterData.insertDatacCs�|dkrtjjd��|t|j�krEtjjd��|dkrctjjd��|r�|jd|�|j||d�|_dS)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negative)r/r0rr�rG)rrrr
r
r�
deleteDataszCharacterData.deleteDatacCs�|dkrtjjd��|t|j�krEtjjd��|dkrctjjd��|r�d|jd|�||j||d�f|_dS)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negativez%s%s%s)r/r0rr�rG)rrrrr
r
r�replaceDataszCharacterData.replaceDataN)rrOr3r=r<)rnrorpr�r�r�r�rrr�rGr�r�rrrrrr
r
r
rr
�s			
r
zLength of the string data.c@speZdZfZejZdZdZdd�Z	ddddd�Z
dd	�Zd
d�Zdd
�Z
dS)r�z#textNcCs�|dks!|t|j�kr3tjjd��|j�}|j|d�|_|j|_|j}|jr�||jj	kr�|dkr�|jj
|�n|jj||�|jd|�|_|S)Nrzillegal offset value)r�rGr/r0rr�rOr<r3r$r5r-)rrZnewText�nextr
r
r�	splitText0s!	zText.splitTextrcCs!t|d||j|f�dS)Nz%s%s%s)r~rG)rr"r r�r!r
r
rr?sz
Text.writexmlcCs�|jg}|j}xK|dk	rb|jtjtjfkr^|jd|j�|j}qPqW|j}xH|dk	r�|jtjtjfkr�|j|j�|j}qoPqoWdj	|�S)Nrr)
rGr=rr	rFr�r;r<rI�join)rrLr�r
r
r�_get_wholeTextDs		zText._get_wholeTextcCs�|j}|j}xK|dk	r_|jtjtjfkr[|j}|j|�|}qPqW|j}|s||j|�xK|dk	r�|jtjtjfkr�|j}|j|�|}qPqW|r�||_|SdSdS)N)	r3r=rr	rFr�r4r<rG)rZcontentr�r�rr
r
r�replaceWholeTextVs*			
		
	
		zText.replaceWholeTextcCs_|jj�rdSt|�}|dkr/dS|jj|�}|dkrQdS|j�SdS)NF)rG�strip�_get_containing_elementrOr��isElementContent)rr�r�r
r
r�!_get_isWhitespaceInElementContentrsz&Text._get_isWhitespaceInElementContent)rnrorpr�r	rFrr�r�rrrrr#r
r
r
rr�)s	r�ZisWhitespaceInElementContentzKTrue iff this text node contains only whitespace and is in element content.Z	wholeTextz.The text of all logically-adjacent text nodes.cCs?|j}x/|dk	r:|jtjkr.|S|j}qWdS)N)r3rr	rJ)rAr@r
r
rr!�s	
r!cCs?|j}x/|dk	r:|jtjkr.|S|j}qWdS)N)r3rr	r�)rAr@r
r
rr�s	
rc@s@eZdZejZdZdd�Zddddd�ZdS)�Commentz#commentcCstj|�||_dS)N)r
r�r)rrGr
r
rr��s
zComment.__init__rcCs<d|jkrtd��|jd||j|f�dS)Nz--z%'--' is not allowed in a comment nodez
%s<!--%s-->%s)rGr7r})rr"r r�r!r
r
rr�szComment.writexmlN)	rnrorpr	r�rr�r�rr
r
r
rr$�s	r$c@s:eZdZfZejZdZddddd�ZdS)�CDATASectionz#cdata-sectionrcCs<|jjd�dkr$td��|jd|j�dS)Nz]]>rz$']]>' not allowed in a CDATA sectionz<![CDATA[%s]]>)rG�findr7r})rr"r r�r!r
r
rr�szCDATASection.writexmlN)	rnrorpr�r	r�rr�rr
r
r
rr%�s	r%c@s�eZdZdZfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ReadOnlySequentialNamedNodeMap�_seqcCs
||_dS)N)r()r�seqr
r
rr��sz'ReadOnlySequentialNamedNodeMap.__init__cCs
t|j�S)N)r�r()rr
r
rr��sz&ReadOnlySequentialNamedNodeMap.__len__cCs
t|j�S)N)r�r()rr
r
rr��sz*ReadOnlySequentialNamedNodeMap._get_lengthcCs+x$|jD]}|j|kr
|Sq
WdS)N)r(r�)rr�r�r
r
rr��sz+ReadOnlySequentialNamedNodeMap.getNamedItemcCs:x3|jD](}|j|kr
|j|kr
|Sq
WdS)N)r(rqrv)rrqrvr�r
r
rr��sz-ReadOnlySequentialNamedNodeMap.getNamedItemNScCsLt|t�r!|j|�}n|j|�}|dkrHt|��|S)N)r�r,r�r�r])rZ
name_or_tuplerAr
r
rr��sz*ReadOnlySequentialNamedNodeMap.__getitem__cCs<|dkrdSy|j|SWntk
r7dSYnXdS)Nr)r(r�)rr6r
r
rr��s
z#ReadOnlySequentialNamedNodeMap.itemcCstjjd��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rr�r
r
rr��s	z.ReadOnlySequentialNamedNodeMap.removeNamedItemcCstjjd��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rrqrvr
r
rr��s	z0ReadOnlySequentialNamedNodeMap.removeNamedItemNScCstjjd��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rrAr
r
rr��s	z+ReadOnlySequentialNamedNodeMap.setNamedItemcCstjjd��dS)Nz"NamedNodeMap instance is read-only)r/r0r)rrAr
r
rr��s	z-ReadOnlySequentialNamedNodeMap.setNamedItemNScCs
|jgS)N)r()rr
r
rr��sz+ReadOnlySequentialNamedNodeMap.__getstate__cCs|d|_dS)Nr)r()rr�r
r
rr��sz+ReadOnlySequentialNamedNodeMap.__setstate__N)r()rnrorpr�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr'�s	r'z&Number of entries in the NamedNodeMap.c@s@eZdZdZdZdd�Zdd�Zdd	�Zd
S)�
Identifiedz@Mix-in class that supports the publicId and systemId attributes.�publicId�systemIdcCs||_||_dS)N)r+r,)rr+r,r
r
r�_identified_mixin_init�s	z!Identified._identified_mixin_initcCs|jS)N)r+)rr
r
r�
_get_publicId�szIdentified._get_publicIdcCs|jS)N)r,)rr
r
r�
_get_systemId�szIdentified._get_systemIdN)r+r,)rnrorpr�r�r-r.r/r
r
r
rr*�s
r*c@speZdZejZdZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dddd	d
�ZdS)�DocumentTypeNcCsIt�|_t�|_|r9t|�\}}||_|j|_dS)N)r'�entities�	notationsr�r�r�)rr�rrr�r
r
rr�	s	zDocumentType.__init__cCs|jS)N)�internalSubset)rr
r
r�_get_internalSubsetsz DocumentType._get_internalSubsetcCsY|jdkrQtd�}|j|_|j|_tjjj}|r:g|j_	g|j
_	xU|j
j	D]G}t|j|j|j
�}|j
j	j|�|j|||�qmWx|jj	D]q}t|j|j|j
|j�}|j|_|j|_|j|_|jj	j|�|j|||�q�W|j|||�|SdSdS)N)rOr0r�r�r/r0�UserDataHandler�NODE_CLONEDr1r(r2�Notationr+r,rIri�Entity�notationName�actualEncodingrrU)rrP�clonergr��notation�e�entityr
r
rrQs.zDocumentType.cloneNodercCs�|jd�|j|j�|jrL|jd||j||jf�n#|jro|jd||jf�|jdk	r�|jd�|j|j�|jd�|jd|�dS)Nz
<!DOCTYPE z%s  PUBLIC '%s'%s  '%s'z%s  SYSTEM '%s'z [�]r{)r}r�r+r,r3)rr"r r�r!r
r
rr/s
			

zDocumentType.writexml)rnrorpr	�DOCUMENT_TYPE_NODErr�r�r+r,r3r�r4rQrr
r
r
rr0s	r0c@s�eZdZdZejZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)r8NcCs2||_||_t�|_|j||�dS)N)r�r9rjr$r-)rr�r+r,r<r
r
rr�Fs		zEntity.__init__cCs|jS)N)r:)rr
r
r�_get_actualEncodingLszEntity._get_actualEncodingcCs|jS)N)r)rr
r
r�
_get_encodingOszEntity._get_encodingcCs|jS)N)rU)rr
r
r�_get_versionRszEntity._get_versioncCstjjd��dS)Nz(cannot append children to an entity node)r/r0r1)rr>r
r
rr5Us	zEntity.appendChildcCstjjd��dS)Nz+cannot insert children below an entity node)r/r0r1)rr>r?r
r
rr-Ys	zEntity.insertBeforecCstjjd��dS)Nz*cannot remove children from an entity node)r/r0r1)rrCr
r
rr4]s	zEntity.removeChildcCstjjd��dS)Nz)cannot replace children of an entity node)r/r0r1)rr>rCr
r
rrDas	zEntity.replaceChild)rnrorpr�r	ZENTITY_NODErr�r:rrUr�rArBrCr5r-r4rDr
r
r
rr8=s	r8c@s+eZdZejZdZdd�ZdS)r7NcCs||_|j||�dS)N)r�r-)rr�r+r,r
r
rr�is	zNotation.__init__)rnrorpr	r�rr�r�r
r
r
rr7es	r7c	@sjeZdZddddddddgZdd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)�DOMImplementation�core�1.0�2.0Nr/�ls-load�3.0cCs+|dkrd}|j�|f|jkS)Nr)�lower�	_features)rrTrUr
r
rrSyszDOMImplementation.hasFeaturec	Cs6|r'|jdk	r'tjjd��|j�}|dkoT|dkoT|dk}|rw|rwtjjd��|r
t|�\}}|dkr�|dkr�tjjd��|r�|r�tjjd��|j||�}|r�|j	|�|j	|�|r ||_|_
||_||_|S)Nz(doctype object owned by another DOM treezElement with no namer/z$http://www.w3.org/XML/1998/namespacezillegal use of 'xml' prefixz(illegal use of prefix without namespaces)
r3r/r0�WrongDocumentErr�_create_documentZInvalidCharacterErrr�r��createElementNSr5rO�doctyperR)	rrqr�rOrtZadd_root_elementrrr�rr
r
r�createDocument~s4		



		

		z DOMImplementation.createDocumentcCs"t|�}||_||_|S)N)r0r+r,)rr�r+r,rOr
r
r�createDocumentType�s		z$DOMImplementation.createDocumentTypecCs|j|d�r|SdSdS)N)rS)rrTr
r
rrZ�szDOMImplementation.getInterfacecCst�S)N)�Document)rr
r
rrM�sz"DOMImplementation._create_document)rErF)rErG)rEN)r/rF)r/rG)r/N)rHrI)rHN)	rnrorprKrSrPrQrZrMr
r
r
rrDns	-rDc@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�ElementInfoz�Object that represents content-model information for an element.

    This implementation is not expected to be used in practice; DOM
    builders should provide implementations which do the right thing
    using information available to it.

    rcCs
||_dS)N)r)rr�r
r
rr��szElementInfo.__init__cCstS)N)r�)r�anamer
r
rr��szElementInfo.getAttributeTypecCstS)N)r�)rrqrvr
r
rr��szElementInfo.getAttributeTypeNScCsdS)NFr
)rr
r
rr"�szElementInfo.isElementContentcCsdS)zQReturns true iff this element is declared to have an EMPTY
        content model.Fr
)rr
r
r�isEmpty�szElementInfo.isEmptycCsdS)z7Returns true iff the named attribute is a DTD-style ID.Fr
)rrTr
r
rr��szElementInfo.isIdcCsdS)z<Returns true iff the identified attribute is a DTD-style ID.Fr
)rrqrvr
r
rr��szElementInfo.isIdNScCs|jS)N)r)rr
r
rr��szElementInfo.__getstate__cCs
||_dS)N)r)rr�r
r
rr��szElementInfo.__setstate__N)r)rnrorpr�r�r�r�r�r"rUr�r�r�r�r
r
r
rrS�srScCsW|jtjkr+|jj�d|_n(t|�rS|jjj�d|j_dS)N)rr	r�	_id_cache�clear�_id_search_stackrwrO)rAr
r
rr:�s
r:c@s0eZdZdMZejejejejfZ	e
�ZejZ
dZdZdZdZdZZdZdZdZdZdZdZdZd	Zd
d�Zdd
�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd�Z&d d!�Z'd"d#�Z(d$d%�Z)d&d'�Z*d(d)�Z+d*d+�Z,d,d-�Z-d.d/�Z.d0d1�Z/d2d3�Z0d4d5�Z1d6d7�Z2d8d9�Z3d:d;�Z4d<d=�Z5d>d?�Z6d@dA�Z7dBdC�Z8dDdE�Z9dFdG�Z:dHdHdHddIdJ�Z;dKdL�Z<dS)NrR�
_elem_inforOrXr$rVz	#documentNFrcCs4d|_t�|_i|_i|_d|_dS)N)rOrjr$rYrVrX)rr
r
rr�
s
			zDocument.__init__cCs7|jr|j|jf}n	|j}|jj|�S)N)rqrvrrYr�)rrr^r
r
rr�s		zDocument._get_elem_infocCs|jS)N)r:)rr
r
rrAszDocument._get_actualEncodingcCs|jS)N)rO)rr
r
r�_get_doctypeszDocument._get_doctypecCs|jS)N)�documentURI)rr
r
r�_get_documentURI szDocument._get_documentURIcCs|jS)N)r)rr
r
rrB#szDocument._get_encodingcCs|jS)N)�errorHandler)rr
r
r�_get_errorHandler&szDocument._get_errorHandlercCs|jS)N)�
standalone)rr
r
r�_get_standalone)szDocument._get_standalonecCs|jS)N)�strictErrorChecking)rr
r
r�_get_strictErrorChecking,sz!Document._get_strictErrorCheckingcCs|jS)N)rU)rr
r
rrC/szDocument._get_versioncCs�|j|jkr:tjjdt|�t|�f��|jdk	rY|jj|�|jtj	kr�|j
�r�tjjd��tj||�S)Nz%s cannot be child of %sz two document elements disallowed)rr.r/r0r1r2r3r4r	rJ�_get_documentElementr5)rrAr
r
rr52s			zDocument.appendChildcCsmy|jj|�Wn!tk
r7tjj��YnXd|_|_d|_|j	|krid|_	|S)N)
r$rEr7r/r0r8r<r=r3�documentElement)rrCr
r
rr4Bs
		zDocument.removeChildcCs.x'|jD]}|jtjkr
|Sq
WdS)N)r$rr	rJ)rrAr
r
rrcNszDocument._get_documentElementcCs6|jdk	r%|jj�d|_tj|�dS)N)rOrHr	)rr
r
rrHSs
	zDocument.unlinkcCs|s
dS|jjddd�}|j|_|j|_|j|_x�|jD]�}t|||�}|jj|�s�t	�|jj
|�|jtj
kr�|jdks�t	�n0|jtjkr�|jdks�t	�||_||_qPW|jtjjj||�|S)N)rRrPrr_rUr$rNrOrY�AssertionErrorrIrr	rrdr@rOr3rir/r0r5r6)rrPr;r�Z
childcloner
r
rrQYs&	

zDocument.cloneNodecCst�}||_|S)N)r�rO)rrbr
r
r�createDocumentFragmentns		zDocument.createDocumentFragmentcCst|�}||_|S)N)r�rO)rrr=r
r
r�
createElementss	zDocument.createElementcCs:t|t�std��t�}||_||_|S)Nznode contents must be a string)r�r�r�r�rGrO)rrG�tr
r
r�createTextNodexs			zDocument.createTextNodecCs:t|t�std��t�}||_||_|S)Nznode contents must be a string)r�r�r�r%rGrO)rrGr@r
r
r�createCDATASection�s			zDocument.createCDATASectioncCst|�}||_|S)N)r$rO)rrGr@r
r
r�
createComment�s	zDocument.createCommentcCst||�}||_|S)N)rrO)rrrG�pr
r
r�createProcessingInstruction�s	z$Document.createProcessingInstructioncCs"t|�}||_d|_|S)Nr)r�rOr�)rr��ar
r
r�createAttribute�s		zDocument.createAttributecCs1t|�\}}t|||�}||_|S)N)r�r�rO)rrqr�rrrvr=r
r
rrN�s	zDocument.createElementNScCs=t|�\}}t||||�}||_d|_|S)Nr)r�r�rOr�)rrqr�rrrvrnr
r
r�createAttributeNS�s
		zDocument.createAttributeNScCs"t||||�}||_|S)N)r8rO)rr�r+r,r9r=r
r
r�_create_entity�s	zDocument._create_entitycCst|||�}||_|S)N)r7rO)rr�r+r,r�r
r
r�_create_notation�s	zDocument._create_notationcCs||jkr|j|S|jp)|js0dS|j}|dkr]|jg}||_n
|sgdSd}x�|r|j�}|jdd�|jD��|j|�}|r�xI|j	j
�D]�}|jr |j|j|j
�r�||j|j<|j|kr|}q�|js�Pq�|j|j�rg||j|j<|j|krZ|}q�|js�Pq�|jr�||j|j<|j|kr�|}q�|jdkr�Pq�WnQ|jrxE|j	j
�D]4}|jr�||j|j<|j|kr�|}q�W|dk	rpPqpW|S)NcSs%g|]}|jtkr|�qSr
)rr9)�.0rMr
r
r�
<listcomp>�s	z+Document.getElementById.<locals>.<listcomp>r()rVrYr�rXrd�pop�extendr$r�r�r�rqr�rvr�r�r�r�r�)rr��stack�resultrAr�r�r
r
r�getElementById�sZ											
zDocument.getElementByIdcCst||t��S)N)r�rj)rr�r
r
rr��szDocument.getElementsByTagNamecCst|||t��S)N)r�rj)rrqrvr
r
rr��szDocument.getElementsByTagNameNScCs|jj||�S)N)rRrS)rrTrUr
r
rrV�szDocument.isSupportedcCs[|jtjkr'tjjd��n$|jtjkrKtjjd��t|||�S)Nzcannot import document nodesz!cannot import document type nodes)rr	rr/r0�NotSupportedErrr@rN)rrArPr
r
r�
importNode�s
zDocument.importNodercCse|dkr |jd|�n|jd||f�x'|jD]}|j||||�qAWdS)Nz<?xml version="1.0" ?>z%<?xml version="1.0" encoding="%s"?>%s)r}r$r)rr"r r�r!rrAr
r
rr�s	zDocument.writexmlcCs�|j|k	r.tjjd||jf��|jtjtjfkr[tjjd��|t	krd|kr�|j
dd�\}}|dkr|tjjkrtjjd��q|dkr|tjjkr|jtjkrtjjd��d}|}nd}d}|jtjkr[|j
}|dk	ra|j}|j|�nd}||_||_||_||_|jtjkr�||_n5||_|dk	r�|j|�|r�|j|�|S)Nz?cannot rename nodes from other documents;
expected %s,
found %sz8renameNode() only applies to element and attribute nodesr�r(r�zillegal use of 'xmlns' prefixz$illegal use of the 'xmlns' attribute)rOr/r0rLrr	rJr�rzrr�rr�r�r�r�rrr�rqr�rr�r�r�)rr�rqr�rrrvrZis_idr
r
r�
renameNodesR														

zDocument.renameNode)rYrOrXr$rV)=rnrorpr�r	rJr�r�r@r.rDrRrrr�r�r�r3r=r<r:rr_rUrar]r[r�r�r�rArZr\rBr^r`rbrCr5r4rcrHrQrfrgrirjrkrmrorNrprqrrryr�r�rVr{rr|r
r
r
rrR�sh		
	
:rRrdz#Top-level element of this document.c
Cs�|jj|�r$tjjj}ntjjj}|jtj	kr�|j
|j|j�}xW|j
j�D]F}|j|j|j|j�|j|j|j�}|j|_qmW|r�x|jD]%}t|||�}|j|�q�Wn�|jtjkrM|j�}|r�x�|jD]%}t|||�}|j|�q!Wn�|jtjkrt|j|j�}nd|jtjkr�|j|j�}n=|jtjkr�|j|j |j�}n|jtj!kr�|j"|j�}n�|jtj#kr1|j$|j|j�}d|_|j|_n�|jtj%kr�|j|k	sXt&�tjjj}|j'j(|j)|j*|j+�}||_|r�g|j,_-g|j._-xm|j.j-D]_}	t/|	j|	j*|	j+�}
||
_|j.j-j0|
�t1|	d�r�|	j2||	|
�q�Wx�|j,j-D]�}t3|j|j*|j+|j4�}|j5|_5|j6|_6|j7|_7||_|j,j-j0|�t1|d�r,|j2||	|�q,Wntjj8dt9|���t1|d�r�|j2|||�|S)zo
    Clone a node and give it the new owner document.
    Called by Node.cloneNode and Document.importNode
    TrizCannot clone node %s):rOrYr/r0r5r6Z
NODE_IMPORTEDrr	rJrNrqr�r�r�r�r�r�rvr�r$rNr5r+rfrFrirGr�rjr�rmrr�rkr�rpr@rerRrQr�r+r,r1r(r2r7rIrdrir8r9r:rrUrzr2)
rArPZnewOwnerDocumentrgr;r�rnrMr@r�r<r=r>r
r
rrNAs~					rNcCs:|jdd�}t|�dkr(|Sd|dfSdS)Nr�r(�r)r�r�)r�Zfieldsr
r
rr��sr�cCs<|||�}|j�\}}|j|�|j�|S)N)ZgetEventZ
expandNoderW)�func�args�kwargsZeventsZtoktypeZrootNoder
r
r�_do_pulldom_parse�s


r�cCsf|dkr0|r0ddlm}|j|�Sddlm}t|j|fd|d|i�SdS)z3Parse a file into a DOM by filename or file object.Nr)�expatbuilder)�pulldom�parser�bufsize)�xml.domr��parser�r�)�filer�r�r�r�r
r
rr��s
r�cCsY|dkr)ddlm}|j|�Sddlm}t|j|fd|i�SdS)z&Parse a file into a DOM from a string.Nr)r�)r�r�)r�r��parseStringr�r�)�stringr�r�r�r
r
rr��s
r�cCs[|rTt|t�r$tj|�}x-|D]%\}}tjj||�s+dSq+WtjS)N)r�r�rZ_parse_feature_stringrRrRrS)Zfeatures�f�vr
r
r�getDOMImplementation�sr�)7r�rr�r/rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrr0r	rJr�r9ZdefpropertyrBrwr~r�r�r�r��objectr�Z
AttributeListr�r�r�r�rrr
r�r!rr$r%r'r*r0r8r7rDrSr:rRrNr�r�r�r�r�r
r
r
r�<module>s�"
�
	y��)GU	><(	O*�OR