def METHOD_NAME(
    external_package_ref: ExternalPackageRef, graph: Graph, package_node: URIRef, doc_namespace: str
):
    external_package_ref_node = BNode()
    graph.add((external_package_ref_node, RDF.type, SPDX_NAMESPACE.ExternalRef))
    graph.add(
        (
            external_package_ref_node,
            SPDX_NAMESPACE.referenceCategory,
            SPDX_NAMESPACE[f"referenceCategory_{snake_case_to_camel_case(external_package_ref.category.name)}"],
        )
    )
    if external_package_ref.reference_type in CATEGORY_TO_EXTERNAL_PACKAGE_REF_TYPES[external_package_ref.category]:
        graph.add(
            (
                external_package_ref_node,
                SPDX_NAMESPACE.referenceType,
                REFERENCE_NAMESPACE[external_package_ref.reference_type],
            )
        )
    else:
        graph.add(
            (
                external_package_ref_node,
                SPDX_NAMESPACE.referenceType,
                URIRef(f"{doc_namespace}#{external_package_ref.reference_type}"),
            )
        )
    graph.add((external_package_ref_node, SPDX_NAMESPACE.referenceLocator, Literal(external_package_ref.locator)))
    if external_package_ref.comment:
        graph.add((external_package_ref_node, RDFS.comment, Literal(external_package_ref.comment)))
    graph.add((package_node, SPDX_NAMESPACE.externalRef, external_package_ref_node))