Creates and xml element for the `doc` with the given `parent`
    and `tag` as the tagName.
    `attrib` should be a dictionary of string keys to primitives or dicts
        if the value is a dict, then the keys of the dict are joined with
        the `attrib` key using a colon. This deals with the badgerfish
        convention of nesting xmlns: attributes in a @xmnls object
    If `data` is not None, then it will be written as data. If it is a boolean,
        the xml true false will be writtten. Otherwise it will be
        converted to python unicode string, stripped and written.
    Returns the element created

def _create_sub_el(doc, parent, tag, attrib, data=None):
    """Creates and xml element for the `doc` with the given `parent`
    and `tag` as the tagName.
    `attrib` should be a dictionary of string keys to primitives or dicts
        if the value is a dict, then the keys of the dict are joined with
        the `attrib` key using a colon. This deals with the badgerfish
        convention of nesting xmlns: attributes in a @xmnls object
    If `data` is not None, then it will be written as data. If it is a boolean,
        the xml true false will be writtten. Otherwise it will be
        converted to python unicode string, stripped and written.
    Returns the element created
    """
    el = doc.createElement(tag)
    if attrib:
        if ('id' in attrib) and ('about' not in attrib):
            about_val = '#' + attrib['id']
            el.setAttribute('about', about_val)
        for att_key, att_value in attrib.items():
            if isinstance(att_value, dict):
                for inner_key, inner_val in att_value.items():
                    rk = ':'.join([att_key, inner_key])
                    el.setAttribute(rk, inner_val)
            else:
                el.setAttribute(att_key, att_value)
    if parent:
        parent.appendChild(el)
    if data is not None:
        if data is True:
            el.appendChild(doc.createTextNode('true'))
        elif data is False:
            el.appendChild(doc.createTextNode('false'))
        else:
            u = UNICODE(data).strip()
            if u:
                el.appendChild(doc.createTextNode(u))
    return el