diff --git a/index.html b/index.html index 2860eaf5..87adf2dd 100644 --- a/index.html +++ b/index.html @@ -5459,7 +5459,28 @@

Algorithm

RDF literal:
  1. Initialize a new empty map result.
  2. -
  3. Initialize converted value to value.
  4. +
  5. + Initialize converted value to null. +
    + Candidate Correction 10 +

    + 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. +

    +

    + Previously, the else clause was never reached even if a + native type couldn't be used, leaving only plain strings + where, e.g., language-tagged string literals were the source. + For more information, refer to + issue 670. +

    +
    +
  6. Initialize type to null
  7. If useNativeTypes is true
    @@ -5480,12 +5501,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.
  8. + of value matches "true" or "1", or false + if it matches "false" or "0".
  9. Otherwise, if the datatype IRI of value equals xsd:integer or @@ -5505,46 +5522,47 @@

    Algorithm

    If the conversion is successful, set converted value to its result.
  10. -
  11. - 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`: -
      +
    1. + If converted value is null, +
      1. Set converted value to the lexical form of value.
      2. -
      3. 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.
      4. -
      5. Add an entry `@direction` to result and set its value to the substring of the - fragment identifier following - the underscore (`"_"`).
      6. +
      7. 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.
      8. +
      9. Otherwise, if the datatype IRI of value starts with `https://www.w3.org/ns/i18n#`, + and {{JsonLdOptions/rdfDirection}} is `i18n-datatype`: +
          +
        1. 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.
        2. +
        3. Add an entry `@direction` to result and set its value to the substring of the + fragment identifier following + the underscore (`"_"`).
        4. +
        +
      10. +
      11. Otherwise, if value is a + language-tagged string + add an entry @language to result and set its value to the + language tag of value.
      12. +
      13. Otherwise, set type to the + datatype IRI + of value, unless it equals xsd:string which is ignored.
    2. -
    3. Otherwise, if value is a - language-tagged string - add an entry @language to result and set its value to the - language tag of value.
    4. -
    5. Otherwise, set type to the - datatype IRI - of value, unless it equals xsd:string which is ignored.
    6. Add an entry @value to result whose value is set to converted value.
    7. If type is not null, add an entry @type @@ -7088,6 +7106,9 @@

      Change log

      as described in Candidate Correction 8
    8. 2025-02-28: Simplify the Inverse Context Creation algorithm as described in Candidate Correction 8
    9. +
    10. 2026-06-06: Fix unconditional skip of other clauses when + useNativeTypes is `true`, as + described in Candidate Correction 10.
    11. 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" + } + ] + } +]