diff --git a/index.html b/index.html
index 642a47d8..318d2426 100644
--- a/index.html
+++ b/index.html
@@ -5418,7 +5418,9 @@
Algorithm
RDF literal:
- Initialize a new empty map result.
- - Initialize converted value to value.
+ -
+ Initialize converted value to null.
+
- Initialize type to
null
- If useNativeTypes is
true
@@ -5433,12 +5435,8 @@ Algorithm
of value equals xsd:boolean, set
converted value to true if the
lexical form
-
- of value matches "true" or "1", or false
- if it matches "false" or "0".
-
- If it matches neither,
- set type to xsd:boolean.
+ of value matches "true" or "1", or false
+ if it matches "false" or "0".
- Otherwise, if the
datatype IRI
of value equals
xsd:integer or
@@ -5458,46 +5456,47 @@ Algorithm
If the conversion is successful, set converted value
to its result.
- -
- Otherwise, set type to datatype IRI
- of value.
-
- Otherwise, if processing mode is not `json-ld-1.0`,
- and value is a JSON literal,
- set converted value to the result of
- turning the lexical value of value
- into the JSON-LD internal representation, and set type to @json.
- If the lexical value of value is not valid JSON according to
- the JSON Grammar [[RFC8259]],
- an invalid JSON literal
- error has been detected and processing is aborted.
- Otherwise, if the datatype IRI of value starts with `https://www.w3.org/ns/i18n#`,
- and {{JsonLdOptions/rdfDirection}} is `i18n-datatype`:
-
+ -
+ If converted value is
null,
+
- Set converted value to the lexical form of value.
- - If the string prefix of the fragment identifier
- of the datatype IRI up until the underscore (`"_"`) is not empty,
- add an entry `@language` to result and set its value to that prefix.
-
As `@direction` may be used without `@language`,
- it is possible, and legitimate, to create a datatype IRI
- such as `http://w3.org/ns/i18n#_ltr`, which does not encode a language tag.
- - Add an entry `@direction` to result and set its value to the substring of the
- fragment identifier following
- the underscore (`"_"`).
+ - If processing mode is not `json-ld-1.0`,
+ and value is a JSON literal,
+ set converted value to the result of
+ turning the lexical value of value
+ into the JSON-LD internal representation, and set type to
@json.
+ If the lexical value of value is not valid JSON according to
+ the JSON Grammar [[RFC8259]],
+ an invalid JSON literal
+ error has been detected and processing is aborted.
+ - Otherwise, if the datatype IRI of value starts with `https://www.w3.org/ns/i18n#`,
+ and {{JsonLdOptions/rdfDirection}} is `i18n-datatype`:
+
+ - If the string prefix of the fragment identifier
+ of the datatype IRI up until the underscore (`"_"`) is not empty,
+ add an entry `@language` to result and set its value to that prefix.
+
As `@direction` may be used without `@language`,
+ it is possible, and legitimate, to create a datatype IRI
+ such as `http://w3.org/ns/i18n#_ltr`, which does not encode a language tag.
+ - Add an entry `@direction` to result and set its value to the substring of the
+ fragment identifier following
+ the underscore (`"_"`).
+
+
+ - Otherwise, if value is a
+ language-tagged string
+ add an entry
@language to result and set its value to the
+ language tag of value.
+ - Otherwise, set type to the
+ datatype IRI
+ of value, unless it equals
xsd:string which is ignored.
- - Otherwise, if value is a
- language-tagged string
- add an entry
@language to result and set its value to the
- language tag of value.
- - Otherwise, set type to the
- datatype IRI
- of value, unless it equals
xsd:string which is ignored.
- Add an entry
@value to result whose value
is set to converted value.
- If type is not
null, add an entry @type
@@ -7034,6 +7033,23 @@ Change log
once and for all in this step, rather than in each iteration.
For more information, refer to issue 633.
+ -
+ 2026-06-06:
+ Fix the
+ RDF to Object Conversion algorithm,
+ which unconditionally skipped else clauses when
+ useNativeTypes was `true`, even if a
+ native type couldn't be used. This resulted in plain strings where, e.g.,
+ language-tagged string literals were the source.
+ Instead, let converted value be initially unset, and only
+ actively set if a native type can be used. Then group the other cases
+ in an else block, defaulting to use the lexical form of
+ value. Since type is set in the final else clause
+ (unless it equals xsd:string), there is no need to set it in
+ the clause for useNativeTypes.
+ For more information, refer to
+ issue 670.
+
diff --git a/tests/fromRdf-manifest.jsonld b/tests/fromRdf-manifest.jsonld
index 787e4089..9e0bd705 100644
--- a/tests/fromRdf-manifest.jsonld
+++ b/tests/fromRdf-manifest.jsonld
@@ -205,6 +205,16 @@
},
"input": "fromRdf/0027-in.nq",
"expect": "fromRdf/0027-out.jsonld"
+ }, {
+ "@id": "#t0028",
+ "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"],
+ "name": "use native types flag with non-native values",
+ "purpose": "Ensure that useNativeTypes flag being true does not interfere with values that cannot be serialized into a native value.",
+ "option": {
+ "useNativeTypes": true
+ },
+ "input": "fromRdf/0028-in.nq",
+ "expect": "fromRdf/0028-out.jsonld"
}, {
"@id": "#tdi01",
"@type": [ "jld:PositiveEvaluationTest", "jld:FromRDFTest" ],
diff --git a/tests/fromRdf/0028-in.nq b/tests/fromRdf/0028-in.nq
new file mode 100644
index 00000000..8cdda3ea
--- /dev/null
+++ b/tests/fromRdf/0028-in.nq
@@ -0,0 +1,5 @@
+ "string" .
+ "hello"@en .
+ "No"^^ .
+ "AAA"^^ .
+ "{\"x\": 1}"^^ .
diff --git a/tests/fromRdf/0028-out.jsonld b/tests/fromRdf/0028-out.jsonld
new file mode 100644
index 00000000..ba4db3f1
--- /dev/null
+++ b/tests/fromRdf/0028-out.jsonld
@@ -0,0 +1,28 @@
+[
+ {
+ "@id": "http://example.com",
+ "http://example.com/property": [
+ {
+ "@value": "string"
+ },
+ {
+ "@language": "en",
+ "@value": "hello"
+ },
+ {
+ "@value": "No",
+ "@type": "http://www.w3.org/2001/XMLSchema#boolean"
+ },
+ {
+ "@value": "AAA",
+ "@type": "http://www.w3.org/2001/XMLSchema#double"
+ },
+ {
+ "@value": {
+ "x": 1
+ },
+ "@type": "@json"
+ }
+ ]
+ }
+]