json_ld: proper JSON-LD Data Round Tripping

This commit is contained in:
Marcel Otto 2017-04-28 00:04:27 +02:00
parent e508c6d28a
commit a22e651468
2 changed files with 3 additions and 9 deletions

View file

@ -117,13 +117,13 @@ defmodule JSON.LD.Decoder do
datatype = item["@type"]
cond do
is_boolean(value) ->
value = to_string(value)
value = value |> RDF.Boolean.new |> RDF.Literal.canonical |> RDF.Literal.lexical
datatype = if is_nil(datatype), do: XSD.boolean, else: datatype
is_float(value) or (is_number(value) and datatype == to_string(XSD.double)) ->
value = to_string(value) # TODO: canonicalize according to Data Round Tripping
value = value |> RDF.Double.new |> RDF.Literal.canonical |> RDF.Literal.lexical
datatype = if is_nil(datatype), do: XSD.double, else: datatype
is_integer(value) or (is_number(value) and datatype == to_string(XSD.integer)) ->
value = to_string(value) # TODO: canonicalize according to Data Round Tripping
value = value |> RDF.Integer.new |> RDF.Literal.canonical |> RDF.Literal.lexical
datatype = if is_nil(datatype), do: XSD.integer, else: datatype
is_nil(datatype) ->
datatype =

View file

@ -9,18 +9,12 @@ defmodule JSON.LD.TestSuite.ToRdfTest do
end
test_cases("toRdf")
# TODO: JSON-LD Data Round Tripping
# |> Enum.filter(fn %{"@id" => id} -> id in ~w[#t0035] end)
# |> Enum.filter(fn %{"@id" => id} -> id in ~w[#t0101] end)
# TODO: Ordering problems
# |> Enum.filter(fn %{"@id" => id} -> id in ~w[#t0118] end)
# TODO: Fixed in Elixir 1.5
# |> Enum.filter(fn %{"@id" => id} -> id in ~w[#t0069] end)
# |> Enum.filter(fn %{"@id" => id} -> id in ~w[#t0102] end)
|> Enum.each(fn %{"name" => name, "input" => input} = test_case ->
if input in ~w[toRdf-0035-in.jsonld toRdf-0101-in.jsonld] do
@tag skip: "finish JSON-LD Data Round Tripping"
end
if input in ~w[toRdf-0069-in.jsonld toRdf-0102-in.jsonld] do
@tag skip: """
probably caused by a bug in Elixirs URI.merge which should be fixed with Elixir 1.5