ó
ôoQc           @   sP   d  Z  d Z d d l Td   Z d   Z d   Z d   Z d   Z d	   Z d
 S(   sĠ  Translate strings to and from SOAP 1.2 XML name encoding

Implements rules for mapping application defined name to XML names
specified by the w3 SOAP working group for SOAP version 1.2 in
Appendix A of "SOAP Version 1.2 Part 2: Adjuncts", W3C Working Draft
17, December 2001, <http://www.w3.org/TR/soap12-part2/#namemap>

Also see <http://www.w3.org/2000/xp/Group/xmlp-issues>.

Author: Gregory R. Warnes <Gregory.R.Warnes@Pfizer.com>
Date::  2002-04-25
Version 0.9.0

s   $Id$i˙˙˙˙(   t   *c         C   s:   |  j    p9 |  j   p9 |  d k p9 |  d k p9 |  d k S(   Nt   .t   -t   _(   t   isalphat   isdigit(   t   x(    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   _NCNameChar   s    c         C   s   |  j    p |  d k S(   NR   (   R   (   R   (    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   _NCNameStartChar   s    c         C   s  t  t |  d   d } t |  } | d k r? d | } nğ | d k rX d | } n˘ | d k rq d | } n | d k r d	 | } np | d
 k r£ d | } nW | d k rĵ d | } n> | d k rĠ d | } n% | d k rî d	 | } n t d   d | d S(   Ni    i   i   t   000t   00i   t   0i   t    i   i   i   i   s'   Illegal Value returned from hex(ord(x))t   _xR   (   t   hext   ordt   lent	   Exception(   R   t   hexvalt   hexlen(    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   _toUnicodeHex   s(    c         C   s   t  d |  d d !d  S(   Ns   u"\ui   i˙˙˙˙t   "(   t   eval(   R   (    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   _fromUnicodeHex7   s    c         C   sÈ  |  j  d  d k r0 |  j d d  \ } } n d } |  } t |  } t |  } g  } xAt |  D]3} | | d k  rħ | | d k rħ | | d d k rħ | j d  qg | d k rA| d k rA| d d k sé | d d	 k rA| d d
 k s	| d d k rA| d d k s)| d d k rA| j d | d  qg t | |  so| d k rt | |  r| j t	 | |   qg | j | |  qg W| rğd | d j
 |  f Sd j
 |  S(   s   Convert string to a XML name.t   :i˙˙˙˙i   u   _u   xu   _x005F_i    i   u   Xu   mu   Mi   u   lu   Lu   _xFFFF_s   %s:%su    N(   t   findt   splitt   Nonet   unicodeR   t   ranget   appendR   R   R   t   join(   t   stringt   prefixt	   localnamet   Tt   Nt   Xt   i(    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt	   toXMLname;   s*    4   .c         C   s1   t  d d |   } d   } t  d | |  } | S(   s#   Convert XML name to unicode string.t   _xFFFF_R   c         S   s   t  |  j d   S(   Ni    (   R   t   group(   t   matchobj(    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   fun^   s    s   _x[0-9A-Fa-f]{4}_(   t   sub(   R    t   retvalR+   (    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   fromXMLnameY   s    	N(	   t   __doc__t   identt   reR   R   R   R   R'   R.   (    (    (    s3   /usr/lib/python2.7/dist-packages/wstools/XMLname.pyt   <module>   s   
					