Skip to content
Back to top
View this page

# prov.identifier

`prov.identifier` implements PROV’s namespaced identifiers: a `Namespace` groups identifiers under a URI and an optional prefix, and a `QualifiedName` combines a namespace with a local part to name entities, activities, agents, and attributes. `Identifier` is the common base, also used directly to represent `xsd:anyURI` values. `prov.model.NamespaceManager` (see prov.model) tracks the namespaces registered on a bundle and resolves prefixes during parsing and serialization.

class prov.identifier.Identifier(uri: str)

  Bases: `object`

  Base class for all identifiers and also represents xsd:anyURI.

  property uri: str

    The URI associated with the current identifier.

  provn_representation() → str

    Return the PROV-N representation of this identifier as an xsd:anyURI literal.

class prov.identifier.QualifiedName(namespace: Namespace, localpart: str)

  Bases: `Identifier`

  Represents a qualified name, which combines a namespace and a local part for use in identifying entities in a namespace-aware context.

  This class facilitates handling and manipulation of qualified names, which combine a namespace and a local identifier. It supports string representation, hashing, and retrieval of individual components (namespace or local part).

  property namespace: Namespace

    Namespace of qualified name.

  property localpart: str

    Local part of qualified name.

  provn_bare_representation() → str

    Return the `prefix:local` PROV-N form used at IDENTIFIER positions.

    The local part’s PROV-N metacharacters (`= ' ( ) , : ; [ ]`) are backslash-escaped per grammar production [55] `PN_CHARS_ESC` (#223); the prefix is never escaped, as it cannot contain these characters.

  provn_representation() → str

    Return the PROV-N representation of this qualified name as a quoted string.

class prov.identifier.Namespace(prefix: str, uri: str)

  Bases: `object`

  PROV Namespace.

  property uri: str

    Namespace URI.

  property prefix: str

    Namespace prefix.

  contains(identifier: Identifier) → bool

    Check whether the given identifier’s URI is contained in this namespace.

    Parameters:

      identifier – Identifier (or URI string) to check.

    Returns:

      `True` if the identifier’s URI starts with this namespace’s URI, `False` otherwise (including when the URI cannot be determined).

  qname(identifier: str | Identifier) → QualifiedName | None

    Resolve an identifier to a `QualifiedName` in this namespace.

    Parameters:

      identifier – Identifier (or URI string) to resolve.

    Returns:

      A new `QualifiedName` in this namespace if `identifier`’s URI starts with this namespace’s URI, otherwise `None`.