ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/xml/dom/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/xml/dom/__pycache__/minidom.cpython-34.pyo

�
j f��@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/python34/lib64/python3.4/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_lastChildcCsx|j|jkr@x't|j�D]}|j||�q"W|S|j|jkr}tjjdt	|�t	|�f��n|j
dk	r�|j
j|�n|dkr�|j|�n�y|jj
|�}Wn!tk
r�tjj��YnX|jtkrt|�n|jj||�||_||_|rb|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|�n|jdk	r�|jj
|�nt||�d|_|S)Nz%s cannot be child of %s)rr+r,r$r5r.r/r0r1r2r9r:r3r4�
_append_childr<)rrAr@r
r
rr5qs	"

	zNode.appendChildcCs�|j|jkr8|j}|j|�|j||�S|j|jkrutjjdt	|�t	|�f��n||kr�dS|j
dk	r�|j
j|�ny|jj|�}Wn!t
k
r�tjj��YnX||j|<||_
d|_
|jtks|jtkr+t|�n|j|_|j|_d|_d|_|jrm||j_n|jr�||j_n|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	rY|j|j_n|jdk	rz|j|j_nd|_|_|jt	kr�t
|�nd|_|S)N)r$�remover7r/r0r8r<r=rr9r:r3)rrCr
r
rr4�s

	zNode.removeChildcCs3g}x|jD]}|jtjkr�|jsr|rJ|j|d_n|jre|j|j_n|j�q|r�|dj|jkr�|d}|j|j|_|j|_|jr�||j_n|j�q|j|�q|j|�|jtj	kr|j
�qqW||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||krT||d}n|dkrd}|dk	r�||=q�n||f||<|S)Nr)r[r\)rr^rG�handler�old�dr
r
r�setUserData�s


zNode.setUserDatacCsjt|d�rfxTt|jj��D]:\}\}}|dk	r%|j|||||�q%q%WndS)Nr[)�hasattr�listr[�itemsZhandle)r�	operation�srcZdstr^rGr`r
r
r�_call_user_data_handler�s(zNode._call_user_data_handlercCs\d|_|_|jrFx|jD]}|j�q#Wt�|_nd|_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.cCsH|j}|r.|d}||_||_n|j|�||_dS)Nr(r))r$r=r<rIr3)rrAr$�lastr
r
rrBs	
	
rBcCs6x/|dk	r1|jtjkr%dS|j}qWdS)NTF)rr	rr3)rAr
r
r�_in_document&s

rxcCsP|rL|jdd�jdd�jdd�jdd�}|j|�nd	S)
zWrites datachars to writer.�&z&amp;�<z&lt;�"z&quot;�>z&gt;N)�replace�write)r"rGr
r
r�_write_data.srcCsex^|jD]S}|jtjkrM|dks=|j|krM|j|�nt|||�q
W|S)Nr)r$rr	rJ�tagNamerI�_get_elements_by_tagName_helper)�parent�name�rcrAr
r
rr�5sr�cCs�x|jD]t}|jtjkr
|dks=|j|krh|dksX|j|krh|j|�nt||||�q
q
W|S)Nr)r$rr	rJrvrqrI�"_get_elements_by_tagName_ns_helper)r�ZnsURIrvr�rAr
r
rr�=sr�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�ndS)N)r�r�r:)r�valuer
r
r�	_set_name{s	zAttr._set_namecCs|jS)N)r�)rr
r
r�
_get_value�szAttr._get_valuecCsL||_||jd_|jdk	r8t|j�n||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}|dkr?|r?|tkr?tjjd��q?n||_|dkr`|j}nd||jf}|jr�t|j�n||_	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	rq|j|j=|j|j|jf=|jrqd|_|jd8_|jj	d8_	qqnx|j
D]}|j�q{W|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)z_namez_valueznamespaceURIz_prefixz
childNodesz
_localNamez
ownerDocumentzownerElement) 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@sueZdZdZd>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 d<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|j|�dkS)Nr)r�)rrXr
r
r�__ne__$szNamedNodeMap.__ne__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||_n1t|t�s�t	d��n|}|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�getNamedItemNSCs
zNamedNodeMap.getNamedItemNScCs}|j|�}|dk	rjt|j�|j|j=|j|j|jf=t|d�rfd|_	n|St
jj��dS)Nr�)
r�r:r�r�r�r�rqrvrdr�r/r0r8)rr��nr
r
r�removeNamedItemIs

zNamedNodeMap.removeNamedItemcCs�|j||�}|dk	rmt|j�|j|j|jf=|j|j=t|d�rid|_	n|St
jj��dS)Nr�)
r�r:r�r�rqrvr�r�rdr�r/r0r8)rrqrvr�r
r
r�removeNamedItemNSUs

zNamedNodeMap.removeNamedItemNScCs�t|t�s:tjjdt|�t|�f��n|jj|j�}|rb|j	�n||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�as	"

zNamedNodeMap.setNamedItemcCs
|j|�S)N)r�)rrAr
r
r�setNamedItemNSnszNamedNodeMap.setNamedItemNScCs%||}t|j�|j�dS)N)r:r�rH)rr�rAr
r
r�__delitem__qs

zNamedNodeMap.__delitem__cCs|j|j|jfS)N)r�r�r�)rr
r
r�__getstate__vszNamedNodeMap.__getstate__cCs|\|_|_|_dS)N)r�r�r�)r�stater
r
r�__setstate__yszNamedNodeMap.__setstate__)z_attrsz_attrsNSz
_ownerElement)"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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__cCs,|jrd|j|jfSd|jSdS)Nz<TypeInfo %r (from %r)>z
<TypeInfo %r>)r�r�)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)z	namespacezname)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�ElementrOr3r�r�rrrqr�r$r�r�r<r=NrcCs]d|_||_|_||_||_t�|_d|_|_d|_	d|_
dS)N)r3r�r�rrrqrjr$r<r=r�r�)rr�rqrrrvr
r
rr��s			
	zElement.__init__cCs(|jdkr$i|_i|_ndS)N)r�r�)rr
r
r�_ensure_attributes�s	zElement._ensure_attributescCs;y|jSWn)tk
r6|jjdd�dSYnXdS)Nr�r(r))r�r\r�r�)rr
r
rrW�s
zElement._get_localNamecCs|jS)N)r�)rr
r
r�_get_tagName�szElement._get_tagNamecCs_|jdk	r<x*t|jj��D]}|j�q%Wnd|_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|�n1||jkr}||_|jr}t|�q}ndS)N)�getAttributeNoder�r�rO�setAttributeNoder�r:)rr�r�r�r
r
r�setAttribute�s			zElement.setAttributecCs�t|�\}}|j||�}|dkrjt||||�}||_|j|_|j|�nU||jkr�||_|jr�t|�q�n|j|kr�||_||_	ndS)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��n|j�|jj|jd�}|dk	rh|j|�n|j	j|j
|jfd�}|dk	r�||k	r�|j|�nt||�||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.setAttributeNodecCsg|jdkr!tjj��ny|j|}Wn!tk
rUtjj��YnX|j|�dS)N)r�r/r0r8r�r]r�)rr�r�r
r
r�removeAttributes
zElement.removeAttributecCsm|jdkr!tjj��ny|j||f}Wn!tk
r[tjj��YnX|j|�dS)N)r�r/r0r8r]r�)rrqrvr�r
r
r�removeAttributeNS's
zElement.removeAttributeNScCsx|dkrtjj��ny|j|jWn!tk
rStjj��YnXt|�|j�|j|_dS)N)	r/r0r8r�r�r]r:rHrO)rrAr
r
rr�0s


zElement.removeAttributeNodecCs |jdkrdS||jkS)NF)r�)rr�r
r
r�hasAttribute?szElement.hasAttributecCs&|jdkrdS||f|jkS)NF)r�)rrqrvr
r
r�hasAttributeNSDszElement.hasAttributeNScCst||t��S)N)r�rj)rr�r
r
r�getElementsByTagNameIszElement.getElementsByTagNamecCst|||t��S)N)r�rj)rrqrvr
r
r�getElementsByTagNameNSLszElement.getElementsByTagNameNScCsd|jt|�fS)Nz<DOM Element: %s at %#x>)r�r�)rr
r
rr�PszElement.__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)
Nrzz %s="r{r|r(rrz</%s>%sz/>%s)
r~r��_get_attributes�sortedr�rr�r$r�rr	rFr)	rr"r �	addindentr!r�Za_namesZa_namerAr
r
rrSs$
	
 

zElement.writexmlcCs |j�t|j|j|�S)N)r�r�r�r�)rr
r
rr�ns
zElement._get_attributescCs|jr
dSdSdS)NTF)r�)rr
r
r�
hasAttributesrs	zElement.hasAttributescCs |j|�}|j|�dS)N)r��setIdAttributeNode)rr��idAttrr
r
r�setIdAttributezszElement.setIdAttributecCs#|j||�}|j|�dS)N)r�r)rrqrvrr
r
r�setIdAttributeNS~szElement.setIdAttributeNScCs�|dks|j|j�r1tjj��nt|�dk	rUtjj��n|js�d|_|jd7_|j	j
d7_
t|�ndS)NTr()rYr�r/r0r8�_get_containing_entref�NoModificationAllowedErrr�r�rOr�r:)rrr
r
rr�s		zElement.setIdAttributeNode)z
ownerDocumentz
parentNodeztagNameznodeNamezprefixznamespaceURIz
_localNamez
childNodesz_attrsz_attrsNSznextSiblingzpreviousSibling).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�rrrr
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)r	rG)rr	rGr
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~r	rG)rr"r r�r!r
r
rr�szProcessingInstruction.writexmlN)ztargetzdata)rnrorpr	r�rr�r�r
rr�r�rr
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��	__class__rn)rrGZ	dotdotdotr
r
rr��s		zCharacterData.__repr__cCs�|dkr!tjjd��n|t|j�krKtjjd��n|dkrltjjd��n|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�|dkr!tjjd��n|t|j�krKtjjd��n|r�d|jd|�||j|d�f|_ndS)Nrzoffset cannot be negativez#offset cannot be beyond end of dataz%s%s%s)r/r0rr�rG)rrrr
r
r�
insertData
szCharacterData.insertDatacCs�|dkr!tjjd��n|t|j�krKtjjd��n|dkrltjjd��n|r�|jd|�|j||d�|_ndS)Nrzoffset cannot be negativez#offset cannot be beyond end of datazcount cannot be negative)r/r0rr�rG)rrrr
r
r�
deleteDataszCharacterData.deleteDatacCs�|dkr!tjjd��n|t|j�krKtjjd��n|dkrltjjd��n|r�d|jd|�||j||d�f|_ndS)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)z_dataz
ownerDocumentz
parentNodezpreviousSiblingznextSibling)rnrorpr�r�r�r�rrr�rGr�r�rrrrrr
r
r
rr�s			
rzLength of the string data.c@speZdZfZejZdZdZdd�Z	ddddd�Z
dd	�Zd
d�Zdd
�Z
dS)r�z#textNcCs�|dks!|t|j�kr6tjjd��n|j�}|j|d�|_|j|_|j}|jr�||jj	kr�|dkr�|jj
|�q�|jj||�n|jd|�|_|S)Nrzillegal offset value)r�rGr/r0rrrOr<r3r$r5r-)rrZnewText�nextr
r
r�	splitText2s!	zText.splitTextrcCs!t|d||j|f�dS)Nz%s%s%s)rrG)rr"r r�r!r
r
rrAsz
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_wholeTextFs		zText._get_wholeTextcCs�|j}|j}xK|dk	r_|jtjtjfkr[|j}|j|�|}qPqW|j}|s|j|�nxK|dk	r�|jtjtjfkr�|j}|j|�|}q�Pq�W|r�||_|SdSdS)N)	r3r=rr	rFr�r4r<rG)rZcontentr�r�rr
r
r�replaceWholeTextXs*			
			
		zText.replaceWholeTextcCs_|jj�rdSt|�}|dkr/dS|jj|�}|dkrQdS|j�SdS)NF)rG�strip�_get_containing_elementrOr��isElementContent)rr�r�r
r
r�!_get_isWhitespaceInElementContenttsz&Text._get_isWhitespaceInElementContent)rnrorpr�r	rFrr�r�rrr r!r%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)rr�r)rrGr
r
rr��s
zComment.__init__rcCs?d|jkrtd��n|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�szComment.writexmlN)	rnrorpr	r�rr�r�rr
r
r
rr&�s	r&c@s:eZdZfZejZdZddddd�ZdS)�CDATASectionz#cdata-sectionrcCs?|jjd�dkr'td��n|jd|j�dS)Nz]]>rz$']]>' not allowed in a CDATA sectionz<![CDATA[%s]]>)rG�findr7r~)rr"r r�r!r
r
rr�szCDATASection.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.getNamedItemNScCsOt|t�r!|j|�}n|j|�}|dkrKt|��n|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)z_seq)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_systemIdszIdentified._get_systemIdN)zpublicIdzsystemId)rnrorpr�r�r/r0r1r
r
r
rr,�s
r,c@speZdZejZdZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dddd	d
�ZdS)�DocumentTypeNcCsLt�|_t�|_|r<t|�\}}||_n|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_internalSubsetcCs\|jdkrTtd�}|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�Wn|j|||�|SdSdS)N)rOr2r�r�r/r0�UserDataHandler�NODE_CLONEDr3r*r4�Notationr-r.rIri�Entity�notationName�actualEncodingrrU)rrP�clonergr��notation�e�entityr
r
rrQs.zDocumentType.cloneNodercCs�|jd�|j|j�|jrL|jd||j||jf�n&|jrr|jd||jf�n|jdk	r�|jd�|j|j�|jd�n|jd|�dS)Nz
<!DOCTYPE z%s  PUBLIC '%s'%s  '%s'z%s  SYSTEM '%s'z [�]r|)r~r�r-r.r5)rr"r r�r!r
r
rr1s
			
zDocumentType.writexml)rnrorpr	�DOCUMENT_TYPE_NODErr�r�r-r.r5r�r6rQrr
r
r
rr2s	r2c@s�eZdZdZejZdZdZdZ	dZ
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)r:NcCs2||_||_t�|_|j||�dS)N)r�r;rjr$r/)rr�r-r.r>r
r
rr�Hs		zEntity.__init__cCs|jS)N)r<)rr
r
r�_get_actualEncodingNszEntity._get_actualEncodingcCs|jS)N)r)rr
r
r�
_get_encodingQszEntity._get_encodingcCs|jS)N)rU)rr
r
r�_get_versionTszEntity._get_versioncCstjjd��dS)Nz(cannot append children to an entity node)r/r0r1)rr>r
r
rr5Ws	zEntity.appendChildcCstjjd��dS)Nz+cannot insert children below an entity node)r/r0r1)rr>r?r
r
rr-[s	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rDcs	zEntity.replaceChild)rnrorpr�r	ZENTITY_NODErr�r<rrUr�rCrDrEr5r-r4rDr
r
r
rr:?s	r:c@s+eZdZejZdZdd�ZdS)r9NcCs||_|j||�dS)N)r�r/)rr�r-r.r
r
rr�ks	zNotation.__init__)rnrorpr	r�rr�r�r
r
r
rr9gs	r9c	@sjeZdZddddddddgZdd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)�DOMImplementation�core�1.0�2.0Nr/�ls-load�3.0cCs.|dkrd}n|j�|f|jkS)Nr)�lower�	_features)rrTrUr
r
rrS{s	zDOMImplementation.hasFeaturec	CsK|r*|jdk	r*tjjd��n|j�}|dkoW|dkoW|dk}|r}|r}tjjd��n|rt|�\}}|dkr�|dkr�tjjd��n|r�|r�tjjd��n|j||�}|r|j	|�n|j	|�n|r5||_|_
n||_||_|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�rQrtZadd_root_elementrrr�rr
r
r�createDocument�s4	



			z DOMImplementation.createDocumentcCs"t|�}||_||_|S)N)r2r-r.)rr�r-r.rQr
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rO�sz"DOMImplementation._create_document)rGrH)rGrI)rGN)�xmlrH)rUrI)rUN)rJrK)rJN)	rnrorprMrSrRrSrZrOr
r
r
rrFps	-rFc@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.

    r�cCs
||_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
)rrWr
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)ztagName)rnrorpr�r�r�r�r�r$rXr�r�r�r�r
r
r
rrV�srVcCsZ|jtjkr+|jj�d|_n+t|�rV|jjj�d|j_ndS)N)rr	r�	_id_cache�clear�_id_search_stackrxrO)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)NrT�
_elem_inforQr[r$rYz	#documentNFrcCs4d|_t�|_i|_i|_d|_dS)N)rQrjr$r\rYr[)rr
r
rr�s
			zDocument.__init__cCs7|jr|j|jf}n	|j}|jj|�S)N)rqrvr�r\r�)rrr^r
r
rr�s		zDocument._get_elem_infocCs|jS)N)r<)rr
r
rrCszDocument._get_actualEncodingcCs|jS)N)rQ)rr
r
r�_get_doctypeszDocument._get_doctypecCs|jS)N)�documentURI)rr
r
r�_get_documentURI"szDocument._get_documentURIcCs|jS)N)r)rr
r
rrD%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rE1szDocument._get_versioncCs�|j|jkr=tjjdt|�t|�f��n|jdk	r_|jj|�n|jtj	kr�|j
�r�tjjd��ntj||�S)Nz%s cannot be child of %sz two document elements disallowed)rr.r/r0r1r2r3r4r	rJ�_get_documentElementr5)rrAr
r
rr54s	"	zDocument.appendChildcCspy|jj|�Wn!tk
r7tjj��YnXd|_|_d|_|j	|krld|_	n|S)N)
r$rEr7r/r0r8r<r=r3�documentElement)rrCr
r
rr4Ds
	zDocument.removeChildcCs.x'|jD]}|jtjkr
|Sq
WdS)N)r$rr	rJ)rrAr
r
rrfPszDocument._get_documentElementcCs9|jdk	r(|jj�d|_ntj|�dS)N)rQrHr	)rr
r
rrHUs
zDocument.unlinkcCs�|s
dS|jjddd�}|j|_|j|_|j|_xo|jD]d}t|||�}|jj|�|jt	j
kr�n|jt	jkr�||_n||_
qPW|jtjjj||�|S)N)rRrRrrbrUr$rNrIrr	rrBrQr3rir/r0r7r8)rrPr=r�Z
childcloner
r
rrQ[s"

zDocument.cloneNodecCst�}||_|S)N)r�rO)rrbr
r
r�createDocumentFragmentps		zDocument.createDocumentFragmentcCst|�}||_|S)N)r�rO)rr�r?r
r
r�
createElementus	zDocument.createElementcCs=t|t�std��nt�}||_||_|S)Nznode contents must be a string)r�r�r�r�rGrO)rrG�tr
r
r�createTextNodezs			zDocument.createTextNodecCs=t|t�std��nt�}||_||_|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)rr	rG�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rP�s	zDocument.createElementNScCs=t|�\}}t||||�}||_d|_|S)Nr)r�r�rOr�)rrqr�rrrvrpr
r
r�createAttributeNS�s
		zDocument.createAttributeNScCs"t||||�}||_|S)N)r:rO)rr�r-r.r;r?r
r
r�_create_entity�s	zDocument._create_entitycCst|||�}||_|S)N)r9rO)rr�r-r.r�r
r
r�_create_notation�s	zDocument._create_notationcCs0||jkr|j|S|jp)|js0dS|j}|dkr]|jg}||_n
|sgdSd}x�|r+|j�}|jdd�|jD��|j|�}|r�xa|j	j
�D]�}|jr&|j|j|j
�r�||j|j<|j|kr|}q#|js#Pq#q�q�|j|j�rp||j|j<|j|kr`|}q�|js�Pq�q�|jr�||j|j<|j|kr�|}q�|jdkr�Pq�q�q�WnZ|jrxN|j	j
�D]:}|jr�||j|j<|j|kr|}qq�q�Wn|dk	rpPqpqpW|S)NcSs%g|]}|jtkr|�qSr
)rr9)�.0rMr
r
r�
<listcomp>�s	z+Document.getElementById.<locals>.<listcomp>r()rYr\r�r[rg�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'|jtjkrNtjjd��nt|||�S)Nzcannot import document nodesz!cannot import document type nodes)rr	rr/r0�NotSupportedErrrBrN)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	r1tjjd||jf��n|jtjtjfkratjjd��n|t	krd|kr�|j
dd�\}}|dkr|tjjkrtjjd��qq'|dkr|tjjkr|jtjkrtjjd��nd}|}nd}d}|jtjkrj|j
}|dk	rp|j}|j|�qpnd}||_||_||_||_|jtjkr�||_n;||_|dk	r�|j|�|r�|j|�q�n|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/r0rNrr	rJr�r|rr�rr�r�r�r�rrr�rqr�r�r�r�r)rr�rqr�rrrvrZis_idr
r
r�
renameNode
sR												
zDocument.renameNode)z
_elem_infozdoctypez_id_search_stackz
childNodesz	_id_cache)=rnrorpr�r	rJr�r�rBr.rFrRrrr�r�r�r3r=r<r<rrbrUrdr`r^r�r�r�rCr]r_rDrarcrerEr5r4rfrHrQrhrirkrlrmrorqrPrrrsrtr{r�r�rVr}rr~r
r
r
rrT�sh		
	
:rTrgz#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�x3|jD]%}t|||�}|j|�q�Wq�n�|jtjkrS|j�}|r�x3|jD]%}t|||�}|j|�q$Wq�n|jtjkrz|j|j�}nX|jtjkr�|j|j�}n1|jtjkr�|j|j |j�}n|jtj!kr�|j"|j�}n�|jtj#kr7|j$|j|j�}d|_|j|_n�|jtj%kr�tjjj}|j&j'|j(|j)|j*�}||_|r�g|j+_,g|j-_,xp|j-j,D]b}	t.|	j|	j)|	j*�}
||
_|j-j,j/|
�t0|	d�r�|	j1||	|
�q�q�Wx�|j+j,D]�}t2|j|j)|j*|j3�}|j4|_4|j5|_5|j6|_6||_|j+j,j/|�t0|d�r |j1||	|�q q Wq�ntjj7dt8|���t0|d�r�|j1|||�n|S)zo
    Clone a node and give it the new owner document.
    Called by Node.cloneNode and Document.importNode
    TrizCannot clone node %s)9rOrYr/r0r7r8Z
NODE_IMPORTEDrr	rJrPrqr�r�r�r�r�r�rvr�r$rNr5r+rhrFrkrGr�rlr�ror	r�rmr�rrrBrRrSr�r-r.r3r*r4r9rIrdrir:r;r<rrUr|r2)
rArPZnewOwnerDocumentrgr=r�rprMr@r�r>r?r@r
r
rrNCs|					 rNcCs:|jdd�}t|�dkr(|Sd|dfSdS)Nr�r(�r)r�r�)r�Zfieldsr
r
rr��sr�cCs<|||�}|j�\}}|j|�|j�|S)N)ZgetEventZ
expandNoderZ)�func�args�kwargsZeventsZtoktypeZrootNoder
r
r�_do_pulldom_parse�s


r�cCsh|dkr0|r0ddlm}|j|�Sddlm}t|j|fi|d6|d6�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�cCsZ|dkr)ddlm}|j|�Sddlm}t|j|fi|d6�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�cCsa|rZt|t�r'tj|�}nx0|D]%\}}tjj||�s.dSq.WntjS)N)r�r�rZ_parse_feature_stringrTrRrS)Zfeatures�f�vr
r
r�getDOMImplementation�sr�)7r�rr�r/rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrr0r	rJr�r9ZdefpropertyrBrxrr�r�r�r��objectr�Z
AttributeListr�r�r�r�rrrr�r#rr&r'r)r,r2r:r9rFrVr:rTrNr�r�r�r�r�r
r
r
r�<module>s�"
�
	y��)GU	><(	O*�OR


Zerion Mini Shell 1.0