Skip to content

Consider renaming Literal.ill_formed to Literal.ill_typed #1960

@aucampia

Description

@aucampia

From https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal

The literal value associated with a literal is:

  1. If the literal is a language-tagged string, then the literal value is a pair consisting of its lexical form and its language tag, in that order.
  2. If the literal's datatype IRI is in the set of recognized datatype IRIs, let d be the referent of the datatype IRI.
    • (a) If the literal's lexical form is in the lexical space of d, then the literal value is the result of applying the lexical-to-value mapping of d to the lexical form.
    • (b) Otherwise, the literal is ill-typed and no literal value can be associated with the literal. Such a case produces a semantic inconsistency but is not syntactically ill-formed. Implementations must accept ill-typed literals and produce RDF graphs from them. Implementations may produce warnings when encountering ill-typed literals.
  3. If the literal's datatype IRI is not in the set of recognized datatype IRIs, then the literal value is not defined by this specification.

Given that Literal.ill_formed is for 2b - I think it may be slightly more clear if it was Literal.ill_typed instead of Literal.ill_formed

rdflib/rdflib/term.py

Lines 698 to 709 in ba855c2

@property
def ill_formed(self) -> Optional[bool]:
"""
For `recognized datatype IRIs
<https://www.w3.org/TR/rdf11-concepts/#dfn-recognized-datatype-iris>`_,
this value will be `True` if the literal is ill formed, otherwise it
will be `False`. `Literal.value` (i.e. the `literal value <https://www.w3.org/TR/rdf11-concepts/#dfn-literal-value>`_) should always be defined if this property is `False`, but should not be considered reliable if this property is `True`.
If the literal's datatype is `None` or not in the set of `recognized datatype IRIs
<https://www.w3.org/TR/rdf11-concepts/#dfn-recognized-datatype-iris>`_ this value will be `None`.
"""
return self._ill_formed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions