예제 #1
0
def _find_namespace_for_prefix(node, prefix):

    "Find the namespace definition node in the given 'node' for 'prefix'."

    current = libxml2mod.xmlNodeGetNsDefs(node)
    while current is not None:
        if libxml2mod.name(current) == prefix:
            return current
        current = libxml2mod.next(current)
    return None
예제 #2
0
def _find_namespace_for_prefix(node, prefix):

    "Find the namespace definition node in the given 'node' for 'prefix'."

    current = libxml2mod.xmlNodeGetNsDefs(node)
    while current is not None:
        if libxml2mod.name(current) == prefix:
            return current
        current = libxml2mod.next(current)
    return None
예제 #3
0
def _get_invented_prefix(node, ns):
    current = libxml2mod.xmlNodeGetNsDefs(node)
    prefixes = []
    while current is not None:
        current_prefix = libxml2mod.name(current)
        prefixes.append(current_prefix)
        current = libxml2mod.next(current)
    i = 0
    while 1:
        prefix = "NS%d" % i
        if prefix not in prefixes:
            return prefix
        i += 1
예제 #4
0
def _get_invented_prefix(node, ns):
    current = libxml2mod.xmlNodeGetNsDefs(node)
    prefixes = []
    while current is not None:
        current_prefix = libxml2mod.name(current)
        prefixes.append(current_prefix)
        current = libxml2mod.next(current)
    i = 0
    while 1:
        prefix = "NS%d" % i
        if prefix not in prefixes:
            return prefix
        i += 1
예제 #5
0
파일: macrolib.py 프로젝트: kp7/plan
def _find_namespace(node, ns, prefix):

    """
    Find the namespace definition node in the given 'node' for the given 'ns'
    and 'prefix'.
    """

    new_ns = None
    current = libxml2mod.xmlNodeGetNsDefs(node)
    while current is not None:
        if _check_namespace(current, ns, prefix):
            new_ns = current
            break
        current = libxml2mod.next(current)
    if new_ns is None:
        node_ns = libxml2mod.xmlNodeGetNs(node)
        if node_ns is not None and _check_namespace(node_ns, ns, prefix):
            new_ns = node_ns
    return new_ns
예제 #6
0
def _find_namespace(node, ns, prefix):

    """
    Find the namespace definition node in the given 'node' for the given 'ns'
    and 'prefix'.
    """

    # Special treatment for XML namespace.

    if prefix == "xml" and ns == xml.dom.XML_NAMESPACE:
        return libxml2mod.xmlSearchNsByHref(Node_ownerDocument(node), node, xml.dom.XML_NAMESPACE)

    new_ns = None
    current = libxml2mod.xmlNodeGetNsDefs(node)
    while current is not None:
        if _check_namespace(current, ns, prefix):
            new_ns = current
            break
        current = libxml2mod.next(current)
    if new_ns is None:
        node_ns = libxml2mod.xmlNodeGetNs(node)
        if node_ns is not None and _check_namespace(node_ns, ns, prefix):
            new_ns = node_ns
    return new_ns
예제 #7
0
def _find_namespace(node, ns, prefix):

    """
    Find the namespace definition node in the given 'node' for the given 'ns'
    and 'prefix'.
    """

    # Special treatment for XML namespace.

    if prefix == "xml" and ns == xml.dom.XML_NAMESPACE:
        return libxml2mod.xmlSearchNsByHref(Node_ownerDocument(node), node, xml.dom.XML_NAMESPACE)

    new_ns = None
    current = libxml2mod.xmlNodeGetNsDefs(node)
    while current is not None:
        if _check_namespace(current, ns, prefix):
            new_ns = current
            break
        current = libxml2mod.next(current)
    if new_ns is None:
        node_ns = libxml2mod.xmlNodeGetNs(node)
        if node_ns is not None and _check_namespace(node_ns, ns, prefix):
            new_ns = node_ns
    return new_ns