示例#1
0
def cdata_custom():
    """Confirm custom cdata modifiations escape all characters
    except opening and closing cdata tags.
    """
    xml = '<![CDATA[<u><b>underline and bold&lt;/u&gt;&lt;/b&gt;]]>'
    e = Encoder()
    d = e.encode(xml)
    encoded_xml = '<![CDATA[&lt;u&gt;&lt;b&gt;underline and bold&lt;/u&gt;&lt;/b&gt;]]>'
    assert d == encoded_xml
示例#2
0
def cdata_custom():
    """Confirm custom cdata modifiations escape all characters
    except opening and closing cdata tags.
    """
    xml = '<![CDATA[<u><b>underline and bold&lt;/u&gt;&lt;/b&gt;]]>'
    e = Encoder()
    d = e.encode(xml)
    encoded_xml = '<![CDATA[&lt;u&gt;&lt;b&gt;underline and bold&lt;/u&gt;&lt;/b&gt;]]>'
    assert d == encoded_xml
示例#3
0
B{far} better.

XML namespaces in suds are represented using a (2) element tuple
containing the prefix and the URI.  Eg: I{('tns', 'http://myns')}

@var encoder: A I{pluggable} XML special character processor used to
    encode/decode strings.
@type encoder: L{Encoder}
"""

from suds.sax.enc import Encoder

#
# pluggable XML special character encoder.
#
encoder = Encoder()


def splitPrefix(name):
    """
    Split the name into a tuple (I{prefix}, I{name}).  The first element in
    the tuple is I{None} when the name does't have a prefix.
    @param name: A node name containing an optional prefix.
    @type name: basestring
    @return: A tuple containing the (2) parts of I{name}
    @rtype: (I{prefix}, I{name})
    """
    if isinstance(name, basestring) \
        and ':' in name:
        return tuple(name.split(':', 1))
    else: