diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e3f4af32 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# JetBrains IDEs +.idea/ diff --git a/index.html b/index.html index f860ab89..911a9481 100644 --- a/index.html +++ b/index.html @@ -284,6 +284,48 @@ text-decoration: none; color: #666; } + + table.simple { + border-collapse: collapse; + width: 100%; + font-size: 14px; + } + + table.simple th, + table.simple td { + border: 1px solid #ddd; + padding: 8px; + vertical-align: top; /* Align text to the top */ + } + + table.simple th { + background-color: #f2f2f2; /* Light gray for headers */ + font-weight: bold; + text-align: left; + } + + table.simple tr:nth-child(even) { + background-color: #f9f9f9; /* Alternating row colors */ + } + + table.simple tr:hover { + background-color: #e9e9e9; /* Highlight on hover */ + } + + table.simple a { + color: #1a73e8; /* Make links a visible color */ + text-decoration: none; + } + + table.simple a:hover { + text-decoration: underline; + } + + table.simple td.error { + background-color: #FFA500; + color: #000; + font-weight: bold; + } @@ -5156,17 +5198,89 @@

Overview

and generating a JSON-LD document in expanded form for all RDF literals, IRIs and blank node identifiers. - If the useNativeTypes flag is set to true, - RDF literals with a - datatype IRI - that equals xsd:integer or xsd:double are converted - to a JSON numbers and RDF literals - with a datatype IRI - that equals xsd:boolean are converted to true or - false based on their - lexical form - as described in - . + + If the useNativeTypes flag is set + to true, RDF literals are converted to JSON values + based on their datatype IRI and lexical form, as described + in . +

+ + useNativeTypes is set to true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Unless the useRdfType flag is set to true, rdf:type predicates will be serialized as @type as long as the associated object is either an IRI or blank node identifier.

@@ -5477,10 +5591,24 @@

Algorithm

xsd:double and its lexical form is a valid xsd:integer or xsd:double - according [[XMLSCHEMA11-2]], set converted value + according to [[XMLSCHEMA11-2]], and if it is a numeric value + conformant to [[IEEE-754-2008]], then set converted value to the result of converting the lexical form - to a JSON number. + to a JSON number. + +
  • + Otherwise, if lexical form expresses a numeric value + outside of the ranges supported by [[IEEE-754-2008]], then set + converted value to a JSON string literal containing + said lexical form. +
  • +
  • + Otherwise, if lexical form expresses a non-numeric value, + such as "+INF"^^xsd:double, an + invalid JSON literal + error has been detected and processing is aborted. +
  • Otherwise, if processing mode is not `json-ld-1.0`, diff --git a/tests/fromRdf-manifest.jsonld b/tests/fromRdf-manifest.jsonld index 1764a682..bd64b011 100644 --- a/tests/fromRdf-manifest.jsonld +++ b/tests/fromRdf-manifest.jsonld @@ -195,6 +195,26 @@ "purpose": "Check list generation with rdf:first property and rdf:nil value.", "input": "fromRdf/0026-in.nq", "expect": "fromRdf/0026-out.jsonld" + }, { + "@id": "#t0027", + "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"], + "name": "native types flag set to true is ignored if the number provided is invalid in JSON", + "purpose": "Literals with datatype xsd:boolean, xsd:integer, and xsd:double are serialized using native scalar values, if possible", + "option": { + "useNativeTypes": true + }, + "input": "fromRdf/0027-in.nq", + "expect": "fromRdf/0027-out.jsonld" + }, { + "@id": "#t0028", + "@type": ["jld:NegativeEvaluationTest", "jld:FromRDFTest"], + "name": "native types flag set to true is ignored if the number provided is invalid in JSON", + "purpose": "+INF^^xsd:double causes a failure to serialize in JSON.", + "option": { + "useNativeTypes": true + }, + "input": "fromRdf/0028-in.nq", + "expectErrorCode": "invalid JSON literal" }, { "@id": "#tdi01", "@type": [ "jld:PositiveEvaluationTest", "jld:FromRDFTest" ], diff --git a/tests/fromRdf/0027-in.nq b/tests/fromRdf/0027-in.nq new file mode 100644 index 00000000..e23fd3fd --- /dev/null +++ b/tests/fromRdf/0027-in.nq @@ -0,0 +1,5 @@ + "true"^^ . + "false"^^ . + "1"^^ . + "1.1"^^ . + "0.1e999999999999999"^^ . diff --git a/tests/fromRdf/0027-out.jsonld b/tests/fromRdf/0027-out.jsonld new file mode 100644 index 00000000..f41d8df9 --- /dev/null +++ b/tests/fromRdf/0027-out.jsonld @@ -0,0 +1,12 @@ +[ + { + "@id": "http://example.com/Subj1", + "http://example.com/prop": [ + { "@value": true }, + { "@value": false }, + { "@value": 1 }, + { "@value": "1.1", "@type": "http://www.w3.org/2001/XMLSchema#decimal"}, + { "@value": "0.1e999999999999999", "@type": "http://www.w3.org/2001/XMLSchema#double"} + ] + } +] diff --git a/tests/fromRdf/0028-in.nq b/tests/fromRdf/0028-in.nq new file mode 100644 index 00000000..a4737b9e --- /dev/null +++ b/tests/fromRdf/0028-in.nq @@ -0,0 +1 @@ + "+INF"^^ .