def toXMLname(string):
if string.find('<STR_LIT::>') != -<NUM_LIT:1> :<EOL><INDENT>(prefix, localname) = string.split('<STR_LIT::>',<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>prefix = None<EOL>localname = string<EOL><DEDENT>T = str(localname)<EOL>N = len(localname)<EOL>X = [];<EOL>for i in range(N) :<EOL><INDENT>if i< N-<NUM_LIT:1> and T[i]=='<STR_LIT:_>' and T[i+<NUM_LIT:1>]=='<STR_LIT:x>':<EOL><INDENT>X.append('<STR_LIT>')<EOL><DEDENT>elif i==<NUM_LIT:0> and N >= <NUM_LIT:3> and( T[<NUM_LIT:0>]=='<STR_LIT:x>' or T[<NUM_LIT:0>]=='<STR_LIT:X>' ) and( T[<NUM_LIT:1>]=='<STR_LIT:m>' or T[<NUM_LIT:1>]=='<STR_LIT:M>' ) and( T[<NUM_LIT:2>]=='<STR_LIT:l>' or T[<NUM_LIT:2>]=='<STR_LIT:L>' ):<EOL><INDENT>X.append('<STR_LIT>' + T[<NUM_LIT:0>])<EOL><DEDENT>elif (not _NCNameChar(T[i])) or (i==<NUM_LIT:0> and not _NCNameStartChar(T[i])):<EOL><INDENT>X.append(_toUnicodeHex(T[i]))<EOL><DEDENT>else:<EOL><INDENT>X.append(T[i])<EOL><DEDENT><DEDENT>if prefix:<EOL><INDENT>return "<STR_LIT>" % (prefix, '<STR_LIT>'.join(X))<EOL><DEDENT>return '<STR_LIT>'.join(X)<EOL>
Convert string to a XML name.