def _type_to_template(qname, subject_type, predicate, object_type):
    """
    >>> _type_to_template(lambda x: "q:"+x, "subject", "pred", "object")
    'rdf/q:subject/q:pred/q:object.html'

    >>> _type_to_template(lambda x: "q:"+x, "subject", "pred", None)
    'rdf/q:subject/q:pred/rdf:Resource.html'

    >>> _type_to_template(lambda x: "q:"+x, "subject", None, "object")
    'rdf/q:subject/q:object.html'

    >>> _type_to_template(lambda x: "q:"+x, "subject", None, None)
    'rdf/q:subject.html'

    >>> _type_to_template(lambda x: "q:"+x, None, None, None)
    'rdf/rdf:Resource.html'
    """
    if not subject_type:
        subject_qname = "rdf:Resource"
    else:
        subject_qname = qname(subject_type)
    
    if not object_type:
        object_qname = "rdf:Resource"
    else:
        object_qname = qname(object_type)
        
    if predicate:
        bits = [subject_qname, qname(predicate), object_qname]
    elif object_type:
        bits = [subject_qname, object_qname]
    else:
        bits = [subject_qname]
        
    return "rdf/{}.html".format("/".join(bits))