• Convert an IRI string to an RDF node, handling both prefixed names and full IRIs

    This function provides consistent IRI handling across the SPARQL schema package.

    Logic:

    • No colon: treat as local name with default prefix (:name)
    • Has colon: check if prefix is in prefixMap
      • If in prefixMap: leave as-is (will be resolved by PREFIX declarations)
      • Otherwise: treat as full URL and use df.namedNode

    Parameters

    • iri: string

      The IRI string (can be prefixed or full)

    • prefixMap: Prefixes = {}

      Prefix mappings (e.g., { "schema": "http://schema.org/" })

    Returns string | NamedNode<string>

    RDF node (either string for prefixed or NamedNode for full IRI)

    // No prefix - becomes default prefix
    convertIRIToNode('name', {}) // Returns: ':name'

    // Known prefix - left as-is
    convertIRIToNode('schema:Person', { schema: 'http://schema.org/' }) // Returns: 'schema:Person'

    // Unknown prefix or full IRI - becomes NamedNode
    convertIRIToNode('http://example.org/entity', {}) // Returns: NamedNode
    convertIRIToNode('urn:x121', {}) // Returns: NamedNode