def getqname(namespaces, qname):
    """
    Convert a namespaced text value element to James Clark's universal form.

    For example::

        (Assuming the prefix "p" corresponds to "http://my.ns")

        p:foo => {http://my.ns}foo

    @type namespaces: C{iterable} of C{(str, str)}
    @param namespaces: An iterable of C{(prefix, url)} pairs for all the
        relevant namespaces

    @type qname: C{str}
    @param qname: The XML namespace prefix to convert

    @rtype: C{str}
    @return: Converted namespace value
    """
    names = qname.split(':', 1)
    if len(names) < 2:
        return names[0]

    prefix, local = names
    for p, url in namespaces:
        if prefix == p:
            return '{%s}%s' % (url, local)

    raise ValueError('Unknown namespace prefix: "%s"' % (prefix,))