Your IP : 18.218.5.216


Current Path : /opt/alt/python311/lib64/python3.11/xml/dom/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/xml/dom/__pycache__/expatbuilder.cpython-311.opt-2.pyc

�

c��f�����	ddlmZmZmZddlmZmZmZddlmZddl	m
Z
mZddlm
Z
ejZejZejZejjZejjZejjZejjZej��Zejdd��ejdd��ejdd	��ejdd
��ejdd��ejdd��ejdd
��ejdd��ejdd��d�	ZGd�de��Zd�Zd�ZGd�d��ZeeefZGd�de��Z Gd�de��Z!Gd�de!��Z"Gd�de!��Z#dZ$d e$zZ%Gd!�d"e��Z&Gd#�d$��Z'Gd%�d&e'e��Z(Gd'�d(e'e&��Z)Gd)�d*e*��Z+Gd+�d,e��Z,d3d.�Z-d3d/�Z.d3d0�Z/d3d1�Z0d2�Z1dS)4�)�
xmlbuilder�minidom�Node)�EMPTY_NAMESPACE�EMPTY_PREFIX�XMLNS_NAMESPACE)�expat)�
_append_child�_set_attribute_node)�
NodeFilterN�cdata�enumeration�entity�entities�id�idref�idrefs�nmtoken�nmtokens)	�CDATA�ENUM�ENTITY�ENTITIES�ID�IDREF�IDREFS�NMTOKEN�NMTOKENSc�J�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
�ElementInfo��
_attr_info�_model�tagNameNc�0�||_g|_||_dS�N)r$r"r#)�selfr$�models   �;/opt/alt/python311/lib64/python3.11/xml/dom/expatbuilder.py�__init__zElementInfo.__init__?s�������������c�*�|j|j|jfSr&r!�r's r)�__getstate__zElementInfo.__getstate__Ds������T�\�9�9r+c�0�|\|_|_|_dSr&r!)r'�states  r)�__setstate__zElementInfo.__setstate__Gs��5:�2�����d�l�l�lr+c��|jD]F}|d|kr8|d}|ddkrtdcSt|dcS�GtjS)N����r�(r)r"�
_typeinfo_mapr�_no_type)r'�aname�info�ts    r)�getAttributeTypezElementInfo.getAttributeTypeJsn���O�	3�	3�D��A�w�%�����H���Q�4�3�;�;�(��0�0�0�0�(��b��2�2�2�2� ���r+c��tjSr&)rr7)r'�namespaceURI�	localNames   r)�getAttributeTypeNSzElementInfo.getAttributeTypeNSTs����r+c�v�|jr1|jd}|tjjtjjfvSdS�NrF)r#r	r(�
XML_CTYPE_ANY�XML_CTYPE_MIXED)r'�types  r)�isElementContentzElementInfo.isElementContentWs?���;�	��;�q�>�D���� 9� %�� ;� =�=�
=��5r+c�T�|jr |jdtjjkSdSrA)r#r	r(�XML_CTYPE_EMPTYr-s r)�isEmptyzElementInfo.isEmpty_s'���;�	��;�q�>�U�[�%@�@�@��5r+c�N�|jD]}|d|kr|ddkcS�dS)Nr3r4rF)r")r'r8r9s   r)�isIdzElementInfo.isIdesA���O�	(�	(�D��A�w�%����B�x�4�'�'�'�'� ��ur+c�0�|�||f��Sr&)rJ)r'�euri�ename�aurir8s     r)�isIdNSzElementInfo.isIdNSks���y�y�$���'�'�'r+r&)
�__name__�
__module__�__qualname__�	__slots__r*r.r1r;r?rErHrJrO�r+r)r r <s�������1�I�����
:�:�:�;�;�;� � � � � � ����������(�(�(�(�(r+r c�.�|�||��Sr&)�_intern_setdefault)�builder�ss  r)�_internrYos���%�%�a��+�+�+r+c�d�|�d��}|j}t|��dkr2|\}}}|||��}|�d|��}|||��}|||��}n@t|��dkr|\}}t}|||��x}}nt	d|z���|||��|||fS)N� ��:�z4Unsupported syntax: spaces in URIs not supported: %r)�splitrV�lenr�
ValueError)rW�name�parts�intern�uri�	localname�prefix�qnames        r)�_parse_ns_namerirs����J�J�s�O�O�E�
�
'�F�
�5�z�z�Q���!&���Y������'�'��!�6�6�9�9�-����u�e�$�$���F�9�i�0�0�	�	�	�U���q������Y���"�F�9�i�8�8�8��	�	��O�RV�V�W�W�W��6�#�s���Y���5�5r+c��eZdZ	dd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�ExpatBuilderNc���|�tj��}||_|jj�t	|jj��|_nd|_t|_d|_|�	��dSr&)
r�Options�_options�filter�FilterVisibilityController�_filterr�_finish_start_element�_parser�reset)r'�optionss  r)r*zExpatBuilder.__init__�sf���?� �(�*�*�G���
��=��+�5�d�m�6J�K�K�D�L�L��D�L�*,�D�&�����
�
�����r+c�*�	tj��Sr&)r	�ParserCreater-s r)�createParserzExpatBuilder.createParser�s��)��!�#�#�#r+c��	|jsm|���|_|jjj|_d|j_d|j_d|j_|�|j��|jS�NT)	rsrxrd�
setdefaultrV�buffer_text�ordered_attributes�specified_attributes�installr-s r)�	getParserzExpatBuilder.getParser�sl��E��|�	'��,�,�.�.�D�L�&*�l�&9�&D�D�#�'+�D�L�$�.2�D�L�+�04�D�L�-��L�L���&�&�&��|�r+c��	t�tdd��|_|j|_|jj|_d|_dS�NF)�theDOMImplementation�createDocumentr�document�curNode�
_elem_info�_cdatar-s r)rtzExpatBuilder.reset�sC��D�,�;�;��T�4�)�)��
��}����-�2�������r+c��	|j|_|j|_|j|_|j|_|jj	r|j
|_|j|_
|jjr|j|_|jjr%|j|_|j|_|j|_n|j|_|j|_|j|_|j|_|j|_ dSr&)!�start_doctype_decl_handler�StartDoctypeDeclHandler�first_element_handler�StartElementHandler�end_element_handler�EndElementHandler�
pi_handler�ProcessingInstructionHandlerrnr�entity_decl_handler�EntityDeclHandler�notation_decl_handler�NotationDeclHandler�comments�comment_handler�CommentHandler�cdata_sections�start_cdata_section_handler�StartCdataSectionHandler�end_cdata_section_handler�EndCdataSectionHandler�character_data_handler_cdata�CharacterDataHandler�character_data_handler�external_entity_ref_handler�ExternalEntityRefHandler�xml_decl_handler�XmlDeclHandler�element_decl_handler�ElementDeclHandler�attlist_decl_handler�AttlistDeclHandler�r'�parsers  r)rzExpatBuilder.install�s���L�)-�)H��&�%)�%?��"�#'�#;�� �.2�o��+��=�!�	@�'+�'?�F�$�%)�%?��"��=�!�	9�$(�$8�F�!��=�'�	F�.2�.N�F�+�,0�,J�F�)�*.�*K�F�'�'�*.�*E�F�'�*.�*J��'� $� 5���$(�$=��!�$(�$=��!�!�!r+c�r�	|���}d}		|�d��}|sn<|�|d��|r!|jjr|�|��d}�T|�dd��n#t$rYnwxYw|j}|���d|_|S)NTr3i@Fr+)	r��read�Parser��documentElement�
_setup_subset�ParseEscapertrs)r'�filer��first_buffer�buffer�docs      r)�	parseFilezExpatBuilder.parseFile�s���	����!�!����	�
%����7�+�+��������V�U�+�+�+��/�D�M�$A�/��&�&�v�.�.�.�$��
%�
�L�L��d�#�#�#�#���	�	�	��D�	�����m���
�
��������
s�A+B�
B�Bc���	|���}	|�|d��|�|��n#t$rYnwxYw|j}|���d|_|Srz)r�r�r�r�r�rtrs)r'�stringr�r�s    r)�parseStringzExpatBuilder.parseString�s���J����!�!��	��L�L���&�&�&����v�&�&�&�&���	�	�	��D�	�����m���
�
��������
s�+A�
A�Ac��	|jjrJt��}|�|��|���}||jj_dSdSr&)r��doctype�InternalSubsetExtractorr��	getSubset�internalSubset)r'r��	extractor�subsets    r)r�zExpatBuilder._setup_subset�s_��=��=� �	:�/�1�1�I��!�!�&�)�)�)��(�(�*�*�F�39�D�M�!�0�0�0�		:�	:r+c���|jj�|||��}|j|_t	|j|��||j_|jrV|j�|��tkr3d|j_|jj	d=d}d|j
_d|j
_|rE|�g|j
_g|j_d|j
_d|j
_|j|j
_dSdS�N���)r��implementation�createDocumentType�
ownerDocumentr
r�rq�
acceptNode�
FILTER_REJECT�
childNodesrsr�r�r�_seq�	notationsr�r��end_doctype_decl_handler�EndDoctypeDeclHandler)r'�doctypeName�systemId�publicId�has_internal_subsetr�s      r)r�z'ExpatBuilder.start_doctype_decl_handler�s����-�.�A�A���8�-�-�� $�
����d�m�W�-�-�-� '��
���<�	4�D�L�3�3�G�<�<�
�M�M�$(�D�M�!��
�(��,��G�-1�D�L�*�/3�D�L�,��	O��"�(*�� �%�)+��!�&�*.�D�L�'�8<�D�L�5�15�1N�D�L�.�.�.�
	O�	Or+c��|jjr|j|j_|j|j_|js|jst|_
dSdSdSr&)rnr�r�rsr�r�r�r�rqr�_finish_end_elementr-s r)r�z%ExpatBuilder.end_doctype_decl_handlers]���=�!�	?�*.�*>�D�L�'�48�O���1���	*�4�<�	*�')�D�$�$�$�	*�	*�	*�	*r+c��|j�||��}t|j|��|jr?|j�|��tkr|j�|��dSdSdSr&)r��createProcessingInstructionr
r�rqr�r��removeChild)r'�target�data�nodes    r)r�zExpatBuilder.pi_handlers{���}�8�8���F�F���d�l�D�)�)�)��<�	+�D�L�3�3�D�9�9�]�J�J��L�$�$�T�*�*�*�*�*�	+�	+�J�Jr+c��|jj}|jr\|jr3|djt
kr|d�|��dS|j�|��}d|_nY|r1|djtkr|d}|j
|z}||_
dStj��}||_
|j|_
t|j|��dS)Nr�T)r�r�r��_cdata_continue�nodeType�CDATA_SECTION_NODE�
appendDatar��createCDATASection�	TEXT_NODEr�r�Textr�r
)r'r�r�r��values     r)r�z)ExpatBuilder.character_data_handler_cdatas����\�,�
��;�	/��&�
� ��n�-�1C�C�C��2��)�)�$�/�/�/����=�3�3�D�9�9�D�#'�D� � �
�	/�J�r�N�3�y�@�@��b�>�D��I��$�E��D�I��F��<�>�>�D��D�I�!%��D���d�l�D�)�)�)�)�)r+c��|jj}|r/|djtkr|d}|j|z|_dStj��}|j|z|_|j|_t|j|��dSr�)
r�r�r�r�r�rr�r�r�r
)r'r�r�r�s    r)r�z#ExpatBuilder.character_data_handler&s|���\�,�
��	�*�R�.�1�Y�>�>��b�>�D��	�D�(�D�I��F��|�~�~���I��$��	�!�]����d�l�D�)�)�)�)�)r+c��|rdS|jjsdS|j�||||��}|�4|j�|��}	|j�|	��|jjjj�|��|j	r<|j	�
|��tkr|jjjjd=dSdSdSr�)rnrr��_create_entity�createTextNoder��appendr�r�rqr�r�)
r'�
entityName�is_parameter_entityr��baser�r��notationNamer��childs
          r)r�z ExpatBuilder.entity_decl_handler1s����	��F��}�%�	��F��}�+�+�J��,4�l�D�D�����M�0�0��7�7�E��O�"�"�5�)�)�)��
��&�+�2�2�4�8�8�8��<�	8�D�L�3�3�D�9�9�]�J�J��
�%�.�3�B�7�7�7�	8�	8�J�Jr+c��|j�|||��}|jjjj�|��|jr<|j�|��tkr|jjjjd=dSdSdSr�)	r��_create_notationr�r�r�r�rqr��
FILTER_ACCEPT)r'r�r�r�r�r�s      r)r�z"ExpatBuilder.notation_decl_handlerCs����}�-�-�l�H�h�O�O���
��'�,�3�3�D�9�9�9��<�	9�D�L�3�3�D�9�9�]�J�J��
�%�/�4�R�8�8�8�	9�	9�J�Jr+c���|j�|��}t|j|��|jr?|j�|��tkr|j�|��dSdSdSr&)r��
createCommentr
r�rqr�r�r�)r'r�r�s   r)r�zExpatBuilder.comment_handlerIsy���}�*�*�4�0�0���d�l�D�)�)�)��<�	+�D�L�3�3�D�9�9�]�J�J��L�$�$�T�*�*�*�*�*�	+�	+�J�Jr+c�"�d|_d|_dS)NTF�r�r�r-s r)r�z(ExpatBuilder.start_cdata_section_handlerOs�����$����r+c�"�d|_d|_dSr�r�r-s r)r�z&ExpatBuilder.end_cdata_section_handlerSs�����$����r+c��dS�Nr3rT)r'�contextr�r�r�s     r)r�z(ExpatBuilder.external_entity_ref_handlerWs���qr+c��|j�|jst|_|j|���_|�||��dSr&)rqr�rr��start_element_handlerr�r�)r'rb�
attributess   r)r�z"ExpatBuilder.first_element_handlerZsJ���<�����')�D�$�/3�/I������,��"�"�4��4�4�4�4�4r+c��|j�|��}t|j|��||_|rvt	dt|��d��D]W}t
j||tdt��}||dz}||_
|j|_t||���X||jj
ur|�|��dSdS)Nrr^r3)r��
createElementr
r��ranger`r�Attrrrr�r�rr�rr)r'rbr�r��i�ar�s       r)r�z"ExpatBuilder.start_element_handler`s����}�*�*�4�0�0���d�l�D�)�)�)�����	-��1�c�*�o�o�q�1�1�
-�
-���L��A���!%�|�5�5��"�1�Q�3������"&�-���#�D�!�,�,�,�,��t�}�4�4�4��&�&�t�,�,�,�,�,�5�4r+c�P�|jr�||jjurdS|j�|��}|tkrt|��n|tkrt|��ndS|j|_	|j�
|��|���dSdSr&)rqr�r��startContainerr��Rejecter�FILTER_SKIP�Skipper�
parentNoder�r��unlink)r'r��filts   r)rrz"ExpatBuilder._finish_start_elementqs����<�	��t�}�4�4�4����<�.�.�t�4�4�D��}�$�$���������$�$���
�
�
�
����?�D�L��O�'�'��-�-�-��K�K�M�M�M�M�M�#	�	r+c�V�|j}|j|_|�|��dSr&)r�rr�)r'rbr�s   r)r�z ExpatBuilder.end_element_handler�s-���,���)���� � ��)�)�)�)�)r+c�L�|j�|j��}|r|�||��|jrc||jjurdS|j�|��tkr2|j	�
|��|���dSdSdSr&)r��getr$�_handle_white_text_nodesrqr�r�r�r�r�r�r)r'r�r9s   r)r�z ExpatBuilder._finish_end_element�s�����"�"�7�?�3�3���	9��)�)�'�4�8�8�8��<�	!��$�-�7�7�7����|�&�&�w�/�/�=�@�@���(�(��1�1�1���� � � � � �	!�	!�A�@r+c��|jjs|���sdSg}|jD]@}|jt
kr.|j���s|�|���A|D]}|�	|���dSr&)
rn�whitespace_in_element_contentrEr�r�r�r��stripr�r�)r'r�r9�Lr�s     r)rz%ExpatBuilder._handle_white_text_nodes�s����M�7�	��(�(�*�*�	��F�

���_�	 �	 �E��~��*�*�5�:�3C�3C�3E�3E�*����������	$�	$�E����U�#�#�#�#�	$�	$r+c��|j�|��}|�t||��|j|<dS||_dSr&)r�r
r r#)r'rbr(r9s    r)r�z!ExpatBuilder.element_decl_handler�sE����"�"�4�(�(���<�$/��e�$<�$<�D�O�D�!�!�!� �D�K�K�Kr+c
��|j�|��}|�t|��}||j|<|j�d|dd|d||g��dS�Nr)r�r
r r"r�)r'�elemrbrD�default�requiredr9s       r)r�z!ExpatBuilder.attlist_decl_handler�sr����"�"�4�(�(���<��t�$�$�D�$(�D�O�D�!�����
�4��t�W�a��x�@�	B�	B�	B�	B�	Br+c�~�||j_||j_|dkr|rd|j_dSd|j_dSdS)NrTF)r��version�encoding�
standalone)r'rrrs    r)r�zExpatBuilder.xml_decl_handler�sN�� '��
��!)��
����?�?��
1�+/��
�(�(�(�+0��
�(�(�(�	�?r+r&)rPrQrRr*rxr�rtrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�rr�r�r�rTr+r)rkrk�s������������$�$�$�	�	�	����>�>�>�.���,���:�:�:�O�O�O�**�*�*�+�+�+�*�*�*�(	*�	*�	*�8�8�8�$9�9�9�+�+�+�%�%�%�%�%�%����5�5�5�-�-�-�"���.*�*�*�
	!�	!�	!�$�$�$�" � � �B�B�B�1�1�1�1�1r+rkc�J�eZdZ	dZd�Zd�Zd�Zeje	j
eje	jej
e	jeje	jeje	jeje	jeje	jeje	jeje	jeje	jeje	jeje	j iZ!dS)rp�roc��||_dSr&r)r'ros  r)r*z#FilterVisibilityController.__init__�s
������r+c��|j|j}|jj|zrV|j�|��}|t
krt�|tvrtdt|��z���|StS)Nz)startContainer() returned illegal value: )�_nodetype_maskr�ro�
whatToShowr�FILTER_INTERRUPTr��_ALLOWED_FILTER_RETURNSra�reprr�)r'r��mask�vals    r)rz)FilterVisibilityController.startContainer�s����"�4�=�1���;�!�D�(�		!��+�,�,�T�2�2�C��&�&�&�!�!��1�1�1� �A�D��I�I�M�O�O�O��J� � r+c�~�|j|j}|jj|zr�|j�|��}|t
krt�|tkr5|j}|j	dd�D]}|�
|���tS|tvrtdt|��z���|StS)Nz%acceptNode() returned illegal value: )rr�rorr�r r�rrr��appendChildr�r!rar"r�)r'r�r#r$�parentr�s      r)r�z%FilterVisibilityController.acceptNode�s����"�4�=�1���;�!�D�(�	!��+�(�(��.�.�C��&�&�&�!�!��k�!�!����!�_�Q�Q�Q�/�.�.�E��&�&�u�-�-�-�-�$�$��1�1�1� �=��S�	�	�I�K�K�K��J� � r+N)"rPrQrRrSr*rr�r�ELEMENT_NODEr�SHOW_ELEMENT�ATTRIBUTE_NODE�SHOW_ATTRIBUTEr��	SHOW_TEXTr��SHOW_CDATA_SECTION�ENTITY_REFERENCE_NODE�SHOW_ENTITY_REFERENCE�ENTITY_NODE�SHOW_ENTITY�PROCESSING_INSTRUCTION_NODE�SHOW_PROCESSING_INSTRUCTION�COMMENT_NODE�SHOW_COMMENT�
DOCUMENT_NODE�
SHOW_DOCUMENT�DOCUMENT_TYPE_NODE�SHOW_DOCUMENT_TYPE�DOCUMENT_FRAGMENT_NODE�SHOW_DOCUMENT_FRAGMENT�
NOTATION_NODE�
SHOW_NOTATIONrrTr+r)rprp�s�������5��I����!�!�!�!�!�!�*	
��*�*A���*�*C���*�*>���*�*G��"�*�*J���*�*@��(�*�*P���*�*A���*�*B���*�*G��#�*�*K���*�*B�

�N�N�Nr+rpc��eZdZdZd�ZdS)�FilterCrutch)�_builder�_level�
_old_start�_old_endc��d|_||_|j}|j|_|j|_|j|_|j|_dSr)	rAr@rsr�rBr�rCr�r�)r'rWr�s   r)r*zFilterCrutch.__init__sG�������
���� �4����0��
�%)�%?��"�#'�#;�� � � r+N)rPrQrRrSr*rTr+r)r?r?s(������>�I�<�<�<�<�<r+r?c�$�eZdZdZd�Zd�Zd�ZdS)rrTc�v�t�||��|j}dD]}t||d���dS)N)r�r�r�r�r�r�)r?r*rs�setattr)r'rWr�rbs    r)r*zRejecter.__init__sQ�����d�G�,�,�,�����	(�	(�D�
�F�D�$�'�'�'�'�	(�	(r+c�$�|jdz|_dSr�)rA�r'�argss  r)r�zRejecter.start_element_handlers���k�A�o����r+c��|jdkr@|jj}|j�|��|j|_|j|_dS|jdz
|_dS�Nrr3)rAr@rsrrBr�rCr�)r'rJr�s   r)r�zRejecter.end_element_handler sZ���;�!����]�*�F��M�!�!�&�)�)�)�)-��F�&�'+�}�F�$�$�$��+��/�D�K�K�Kr+N)rPrQrRrSr*r�r�rTr+r)rrsF�������I�
(�
(�
(�&�&�&�*�*�*�*�*r+rc��eZdZdZd�Zd�ZdS)rrTc�p�|jj}|j|�|jj|ur|jdz|_dSdSr�)r@r�rBrA)r'rJr�s   r)r�zSkipper.start_element_handler-sD���}�$���������=� ��,�,��+��/�D�K�K�K�-�,r+c��|jdkr5|j|jj_|j|jj_d|_dS|jdz
|_|j|�dSrL)rArBr@rsr�rCr�rIs  r)r�zSkipper.end_element_handler3s\���;�!���9=��D�M�!�5�6:�m�D�M�!�3� �D�M�M�M��+��/�D�K��D�M�4� � � � r+N)rPrQrRrSr�r�rTr+r)rr*s7�������I�*�*�*�	!�	!�	!�	!�	!r+rz8http://xml.python.org/entities/fragment-builder/internalz�<!DOCTYPE wrapper
  %%s [
  <!ENTITY fragment-builder-internal
    SYSTEM "%s">
%%s
]>
<wrapper %%s
>&fragment-builder-internal;</wrapper>c�<�eZdZ	d	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	dS)
�FragmentBuilderNc��|jtkr||_||_n|j|_||_t
�||��dSr&)r�r6�originalDocumentr�r�rkr*)r'r�rus   r)r*zFragmentBuilder.__init__[sO����}�,�,�$+�D�!�"�D�L�L�$+�$9�D�!�"�D�L����d�G�,�,�,�,�,r+c�H�t�|��d|_dSr&)rkrt�fragmentr-s r)rtzFragmentBuilder.resetds!�����4� � � ���
�
�
r+c�R�	|�|�����Sr&)r�r��r'r�s  r)r�zFragmentBuilder.parseFilehs#��	�����	�	���,�,�,r+c���	||_|���}|jj}d}|rH|jp|���}|jrd|j�d|j�d�}n|jr
d|jz}nd}|���}t|||fz}	|�
|d��n#|����xYw|j}|���|S)N�zPUBLIC "z" "�"zSYSTEM "%s"T)
�_sourcer�rSr�r��_getDeclarationsr�r��_getNSattrs�_FRAGMENT_BUILDER_TEMPLATEr�rtrU)	r'r�r�r��identr��nsattrsr�rUs	         r)r�zFragmentBuilder.parseStringms
��	�������!�!���'�/�����	��+�F�t�/D�/D�/F�/F�F���
9�
9�#�,�,�,�g�.>�.>�.>�@����!�
9�%��(8�8����F��"�"�$�$��-����0H�H��	��L�L��4�(�(�(�(��	��J�J�L�L�L������=���
�
�����s�B0�0Cc�d�	|jjj}d}|�rt|jj��D]Y}|j�|��}|r|dz}|�d|j��}|jr|�d|j�d|j	�d�}�L|�d|j	�d�}�Zt|j
j��D]�}|j
�|��}|r|dz}|�d|j��}|jr|�d|j�d|j	�d	�}n'|j	r|�d|j	�d	�}n|�d
|jj�d	�}|j
r|�d|j
��}|dz}��|S)
NrYz
  z<!NOTATION z	 PUBLIC "z"
             "z">z	 SYSTEM "z	<!ENTITY rZz "z
 NOTATION �>)r�r�r�r�r��length�item�nodeNamer�r�r�
firstChildr�r�)r'r�rXr��notationrs      r)r\z FragmentBuilder._getDeclarations�s���	�
�,�,�4�����	��7�,�3�4�4�	
C�	
C��"�,�1�1�!�4�4���#��F�
�A�)*���H�,=�,=�>���$�C��1�1�h�/�/�/��1B�1B�1B�D�A�A�./�Q�Q��0A�0A�0A�B�A�A��7�+�2�3�3�
�
�� �)�.�.�q�1�1���#��F�
�A�'(�q�q�&�/�/�:���?�@��1�1�f�o�o�o�v����@�A�A��_�@�,-�A�A�v����?�A�A�%&�Q�Q��(9�(>�(>�(>�?�A��&�D�,-�A�A�v�/B�/B�C�A���G����r+c��dS)NrYrTr-s r)r]zFragmentBuilder._getNSattrs�s���rr+c��|tkr�|j}|j}|j�|��}|j|_|j���|_|j|_	|�|j	d��||_||_d|_	n#||_||_d|_	wxYwdSt�|||||��S)NTr�)�$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDr�r�rs�ExternalEntityParserCreaterS�createDocumentFragmentrUr�r[rkr�)r'r�r�r�r��old_document�old_cur_noder�s        r)r�z+FragmentBuilder.external_entity_ref_handler�s����;�;�;� �=�L��<�L��\�<�<�W�E�E�F� �1�D�M� �M�@�@�B�B�D�M��=�D�L�
$����T�\�4�0�0�0�+��� ,��
�#����� ,��� ,��
�#���#�#�#�#��2��;�;��g�t�X�x�9�9�
9s�+B�B3r&)
rPrQrRr*rtr�r�r\r]r�rTr+r)rQrQRs��������-�-�-�-����-�-�-�
���8"�"�"�H���9�9�9�9�9r+rQc�.�eZdZ	d�Zd�Zd�Zd�Zd�ZdS)	�
Namespacesc��g|_dSr&)�_ns_ordered_prefixesr-s r)�_initNamespaceszNamespaces._initNamespaces�s��%'��!�!�!r+c�@�	tjd���}d|_|S)Nr[)�namespace_separatorT)r	rw�namespace_prefixesr�s  r)rxzNamespaces.createParser�s%��5��#��<�<�<��$(��!��
r+c�r�	t�||��|jjr|j|_dSdSr&)rkrrn�namespace_declarations�start_namespace_decl_handler�StartNamespaceDeclHandlerr�s  r)rzNamespaces.install�sF��<����T�6�*�*�*��=�/�	3��1�
�,�,�,�	3�	3r+c�@�	|j�||f��dSr&)rrr�)r'rgres   r)ryz'Namespaces.start_namespace_decl_handler�s&��=��!�(�(�&�#��7�7�7�7�7r+c���d|vrt||��\}}}}nt}|}d}t}tj||||��}|j|_t|j|��||_|j	r�|j	D]y\}}|r.tj
t|d|z��t|d��}n!tj
dtdt��}||_
|j|_t||���z|j	dd�=|r�|���|j}	|j}
t%dt'|��d��D]�}||}||dz}
d|vr9t||��\}}}}tj
||||��}||	|<||
||f<n2tj
|t|t��}||	|<||
t|f<|j|_|
|_
||_��dSdS)Nr[�xmlns:�xmlnsrr^r3)rirrr�Elementr�r�r
r�rrr�rYrr�r�_ensure_attributes�_attrs�_attrsNSr�r`�ownerElement)r'rbr�rerfrgrhr�r�r�r�r�r8r�s              r)r�z Namespaces.start_element_handler�s$���$�;�;�,:�4��,F�,F�)�C��F�E�E�!�C��E��I�!�F���u�c�6�9�=�=��!�]����d�l�D�)�)�)�����$�	-�#�8�	
-�	
-�����<���W�T�8�f�3D�%E�%E�%4�f�g�G�G�A�A� ��W�o�%,�l�<�<�A����"&�-���#�D�!�,�,�,�,��)�!�!�!�,��	&��#�#�%�%�%��[�F��}�H��1�c�*�o�o�q�1�1�
&�
&��"�1�
��"�1�Q�3����%�<�<�4B�4��4O�4O�1�C��F�E���U�C��F�C�C�A�$%�F�5�M�12�H�c�9�-�.�.���U�O�%*�L�:�:�A�$%�F�5�M�9:�H�o�u�5�6�"&�-������!%����'	&�	&�
&�
&r+Fc��|j}d|vrt||��\}}}}|j|_|�|��dS)Nr[)r�rirr�)r'rbr�rerfrgrhs       r)r�zNamespaces.end_element_handlersP���l�G��d�{�{�0>�t�T�0J�0J�-��Y���#�-�D�L��$�$�W�-�-�-�-�-r+N)	rPrQrRrsrxrryr�r�rTr+r)rprp�sc������A�'�'�'�
���3�3�3�8�8�8�-&�-&�-&�^.�.r+rpc��eZdZ	d�ZdS)�ExpatBuilderNSc�b�t�|��|���dSr&)rkrtrsr-s r)rtzExpatBuilderNS.reset)s.�����4� � � ��������r+N)rPrQrRrtrTr+r)r�r�&s&������4�����r+r�c��eZdZ	d�Zd�ZdS)�FragmentBuilderNSc�b�t�|��|���dSr&)rQrtrsr-s r)rtzFragmentBuilderNS.reset1s.�����d�#�#�#��������r+c��	d}|j}g}|rst|d��rZ|j���D]@\}}||vr�
|�|��|rd|z}nd}|r|�d|�d|�d�}�7d|�d|�d�}�A|j}|�s|S)	NrY�_ns_prefix_urir}r~z
    z='�'r[)r��hasattrr��itemsr�r)r'�attrsr�rrgre�declnames       r)r]zFragmentBuilderNS._getNSattrs5s���	����,�����	)��w� 0�1�1�

=�#*�#9�#?�#?�#A�#A�=�=�K�F�C���{�{� ��H�H�V�$�$�$��+�#+�f�#4���#*���=�5:�U�U�H�H�H�c�c�c� J���=�/7�h�h���� <����(�G��	)� �r+N)rPrQrRrtr]rTr+r)r�r�.s5������4��������r+r�c��eZdZ	dS)r�N)rPrQrRrTr+r)r�r�Ss������O��Dr+r�c�>�eZdZ	dZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dS)	r�Nc��	|jSr&)r�r-s r)r�z!InternalSubsetExtractor.getSubset\s
��5��{�r+c�`�	t�||��dS#t$rYdSwxYwr&)rkr�r�rWs  r)r�z!InternalSubsetExtractor.parseFile`sE��	��"�"�4��.�.�.�.�.���	�	�	��D�D�	������
-�-c�`�	t�||��dS#t$rYdSwxYwr&)rkr�r�)r'r�s  r)r�z#InternalSubsetExtractor.parseStringfsE��	��$�$�T�6�2�2�2�2�2���	�	�	��D�D�	���r�c�6�|j|_|j|_dSr&)r�r�r�r�r�s  r)rzInternalSubsetExtractor.installls��)-�)H��&�%)�%?��"�"�"r+c��|r:|���}g|_|jj|_|j|_dSt
���r&)r�r�r��DefaultHandlerr�r�r�)r'rbr�r�r�r�s      r)r�z2InternalSubsetExtractor.start_doctype_decl_handlerpsH���	 ��^�^�%�%�F��D�K�$(�K�$6�F�!�+/�+H�F�(�(�(��-�-�r+c��d�|j���dd���dd��}||_t���)NrYz
�
�
)�joinr��replacer�)r'rXs  r)r�z0InternalSubsetExtractor.end_doctype_decl_handlerzsF���G�G�D�K� � �(�(���6�6�>�>�t�T�J�J������m�m�r+c��t���r&)r�)r'rbr�s   r)r�z-InternalSubsetExtractor.start_element_handlers���m�m�r+)rPrQrRr�r�r�r�rr�r�r�rTr+r)r�r�Ws�������L�
�F����������@�@�@� � � ����
����r+r�Tc��	|rt��}nt��}t|t��r>t	|d��5}|�|��}ddd��n#1swxYwYn|�|��}|S�N�rb)r�rk�
isinstance�str�openr�)r��
namespacesrW�fp�results     r)�parser��s�����!� �"�"����.�.���$����)�
�$��
�
�	+���&�&�r�*�*�F�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+���"�"�4�(�(���Ms�A(�(A,�/A,c�l�	|rt��}nt��}|�|��Sr&)r�rkr�)r�r�rWs   r)r�r��s;����!� �"�"����.�.�����v�&�&�&r+c��	|rt|��}nt|��}t|t��r>t	|d��5}|�|��}ddd��n#1swxYwYn|�|��}|Sr�)r�rQr�r�r�r�)r�r�r�rWr�r�s      r)�
parseFragmentr��s�����+�#�G�,�,���!�'�*�*���$����)�
�$��
�
�	+���&�&�r�*�*�F�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+���"�"�4�(�(���Ms�A*�*A.�1A.c�p�	|rt|��}nt|��}|�|��Sr&)r�rQr�)r�r�r�rWs    r)�parseFragmentStringr��sA����+�#�G�,�,���!�'�*�*�����v�&�&�&r+c�N�	|jrt|��St|��Sr&)r�r�rk)rus r)�makeBuilderr��s,��6���%��g�&�&�&��G�$�$�$r+)T)2�xml.domrrrrrr�xml.parsersr	�xml.dom.minidomr
r�xml.dom.NodeFilterrr�r�r6�DOMBuilderFilterr�r�rr �getDOMImplementationr��TypeInfor6�objectr rYrirkr!rpr?rrrjr^rQrpr�r��	Exceptionr�r�r�r�r�r�r�rTr+r)�<module>r�sU���:.�-�-�-�-�-�-�-�-�-�B�B�B�B�B�B�B�B�B�B�������>�>�>�>�>�>�>�>�)�)�)�)�)�)��N�	��,���"�
��+�9�
��+�9�
��)�5���.�?��3�w�3�5�5��!�� ��w�/�/� �� ��}�5�5� �� ��x�0�0� �� ��z�2�2� �� ��t�,�,� �� ��w�/�/� �� ��x�0�0� �� ��y�1�1� �� ��z�2�2�
�
�
�1(�1(�1(�1(�1(�&�1(�1(�1(�f,�,�,�6�6�6�&|1�|1�|1�|1�|1�|1�|1�|1�B
)�-��E��7
�7
�7
�7
�7
��7
�7
�7
�t
<�
<�
<�
<�
<�6�
<�
<�
<�*�*�*�*�*�|�*�*�*�8!�!�!�!�!�l�!�!�!�2?�%�*�+�	+��r9�r9�r9�r9�r9�l�r9�r9�r9�j\.�\.�\.�\.�\.�\.�\.�\.�~�����Z�����"�"�"�"�"�
�O�"�"�"�J	�	�	�	�	�)�	�	�	�)�)�)�)�)�l�)�)�)�X����$'�'�'�'�����(	'�	'�	'�	'�%�%�%�%�%r+

?>