def METHOD_NAME(attrs, xml=0):
    attrs = attrs.items()
    attrs.sort()
    parts = []
    append = parts.append
    for name, value in attrs:
        if xml:
            append('%s="%s"' % (name, escape(value)))
        else:
            # this is a little bogus, but should do for now
            if name == value and isnmtoken(value):
                append(value)
            elif istoken(value):
                if value == "no" + name:
                    append(value)
                else:
                    append("%s=%s" % (name, value))
            else:
                append('%s="%s"' % (name, escape(value)))
    if parts:
        parts.insert(0, '')
    return " ".join(parts)