xml_utils.py 521 Bytes
# -*- coding: utf-8 -*-
namespaces = {
  'tei': 'http://www.tei-c.org/ns/1.0',
  'xi': 'http://www.w3.org/2001/XInclude',
  'nkjp': 'http://www.nkjp.pl/ns/1.0',
  'xml': 'http://www.w3.org/XML/1998/namespace'
}

XML_ENTITIES = {
        '\"' : """,
        '\'' : "'",
        '&' : "&",
        '<' : "&lt;",
        '>' : "&gt;",
        }

def xml_escape(x):
    ret = ""
    for c in x:
        if c in XML_ENTITIES:
            ret += XML_ENTITIES[c]
        else:
            ret += c
    return ret