core: allow blank nodes as predicates

since JSON-LD supports them when producing generalized RDF
This commit is contained in:
Marcel Otto 2017-04-07 15:44:36 +02:00
parent 425546349d
commit e09714158c

View file

@ -61,6 +61,10 @@ defmodule RDF.Triple do
@doc false
def convert_predicate(uri)
def convert_predicate(uri = %URI{}), do: uri
# Note: Although, RDF does not allow blank nodes for properties, JSON-LD allows
# them, by introducing the notion of "generalized RDF".
# TODO: Support an option `:strict_rdf` to explicitly disallow them or produce warnings or ...
def convert_predicate(bnode = %BlankNode{}), do: bnode
def convert_predicate(uri) when is_atom(uri) or is_binary(uri), do: RDF.uri(uri)
def convert_predicate(arg), do: raise RDF.Triple.InvalidPredicateError, predicate: arg