From 8baaa1d23149e6328cd67ba9edb14311b8a342b2 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 27 Jan 2025 14:42:58 -0800 Subject: [PATCH 01/10] #555 `.gitignore` JetBrains & `pyenv` files --- .gitignore | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2c28b57d..fafe4eeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -# Support JetBrains IDEs -.idea +# JetBrains IDEs +.idea/ + +# pyenv version file +.python-version From 10590b921cfc757875beb9500f18e143386b3646 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Sun, 12 Jan 2025 22:54:06 +0400 Subject: [PATCH 02/10] #555 If `useNativeTypes` is `true` but an RDF number cannot be converted to JSON number, fall back to default logic --- index.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index c966d7fb..6f2079da 100644 --- a/index.html +++ b/index.html @@ -5477,13 +5477,23 @@

Algorithm

xsd:double and its lexical form is a valid xsd:integer or xsd:double - according [[XMLSCHEMA11-2]], set converted value - to the result of converting the - lexical form - to a JSON number. + according to [[XMLSCHEMA11-2]], +
    +
  1. attempt to convert the lexical form to a JSON number + according to + [[RFC8785]] + JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers + procedure; +
  2. +
  3. + If the conversion is successful, set converted value + to its result. +
  4. +
+ -
  • Otherwise, if processing mode is not `json-ld-1.0`, +
  • 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 From f885de038f50145f5dbe97d292f2312480adc445 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Sun, 12 Jan 2025 22:55:04 +0400 Subject: [PATCH 03/10] #555 `fromRdf-manifest.jsonld#t0027` covers fallback logic in `useNativeTypes` mode --- tests/fromRdf-manifest.jsonld | 10 ++++++ tests/fromRdf/0027-in.nq | 12 +++++++ tests/fromRdf/0027-out.jsonld | 60 +++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/fromRdf/0027-in.nq create mode 100644 tests/fromRdf/0027-out.jsonld diff --git a/tests/fromRdf-manifest.jsonld b/tests/fromRdf-manifest.jsonld index 1764a682..689eaf4f 100644 --- a/tests/fromRdf-manifest.jsonld +++ b/tests/fromRdf-manifest.jsonld @@ -195,6 +195,16 @@ "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": "use native types flag with values that cannot be serialized to JSON", + "purpose": "useNativeTypes flag being true is disregarded for a value that cannot be serialized into a native JSON value.", + "option": { + "useNativeTypes": true + }, + "input": "fromRdf/0027-in.nq", + "expect": "fromRdf/0027-out.jsonld" }, { "@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..b03b0c80 --- /dev/null +++ b/tests/fromRdf/0027-in.nq @@ -0,0 +1,12 @@ + "true"^^ . + "false"^^ . + + "True"^^ . + "False"^^ . + + "1"^^ . + "1.1"^^ . + + "0.1e999999999999999"^^ . + "+INF"^^ . + "-INF"^^ . diff --git a/tests/fromRdf/0027-out.jsonld b/tests/fromRdf/0027-out.jsonld new file mode 100644 index 00000000..cc9f212a --- /dev/null +++ b/tests/fromRdf/0027-out.jsonld @@ -0,0 +1,60 @@ +{ + "@graph": [ + { + "@id": "http://example.com/boolean-native", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": true + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": false + } + ] + }, + { + "@id": "http://example.com/boolean-object", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": "True" + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": "False" + } + ] + }, + { + "@id": "http://example.com/number-native", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#integer", + "@value": 1 + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#decimal", + "@value": 1.1 + } + ] + }, + { + "@id": "http://example.com/number-object", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#double", + "@value": "0.1e999999999999999" + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#double", + "@value": "+INF" + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#double", + "@value": "-INF" + } + ] + } + ] +} From 9c402fd15a4e4b775e955eee552f65703171d9e6 Mon Sep 17 00:00:00 2001 From: anatoly-scherbakov Date: Sun, 12 Jan 2025 18:57:31 +0000 Subject: [PATCH 04/10] Automated report generation --- tests/expand-manifest.html | 4 ++-- tests/fromRdf-manifest.html | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/expand-manifest.html b/tests/expand-manifest.html index 85a273e9..145e21c4 100644 --- a/tests/expand-manifest.html +++ b/tests/expand-manifest.html @@ -941,7 +941,7 @@

    - Test t0041 @language: null resets the default language + Test t0041 @language: null
    @@ -950,7 +950,7 @@

    Type
    jld:PositiveEvaluationTest, jld:ExpandTest
    Purpose
    -
    +
    @language: null resets the default language
    input
    expand/0041-in.jsonld diff --git a/tests/fromRdf-manifest.html b/tests/fromRdf-manifest.html index ca803b4b..1ab97678 100644 --- a/tests/fromRdf-manifest.html +++ b/tests/fromRdf-manifest.html @@ -648,6 +648,34 @@

    +
    + Test t0027 use native types flag with values that cannot be serialized to JSON +
    +
    +
    +
    id
    +
    #t0027
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:FromRDFTest
    +
    Purpose
    +
    useNativeTypes flag being true is disregarded for a value that cannot be serialized into a native JSON value.
    +
    input
    +
    + fromRdf/0027-in.nq +
    +
    expect
    +
    + fromRdf/0027-out.jsonld +
    +
    Options
    +
    +
    +
    useNativeTypes
    +
    true
    +
    +
    +
    +
    Test tdi01 rdfDirection: null with i18n literal with direction and no language
    From a7c2291a274f64134e56359f80128ace8e2b8766 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Wed, 15 Jan 2025 00:45:10 +0400 Subject: [PATCH 05/10] #555 Introduce 2.4.3.3 in value conversion algorithm --- index.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 6f2079da..6c817976 100644 --- a/index.html +++ b/index.html @@ -5487,13 +5487,16 @@

    Algorithm

  • If the conversion is successful, set converted value - to its result. + to its result; +
  • +
  • + Otherwise, set type to datatype IRI of value.
  • -
  • If processing mode is not `json-ld-1.0`, +
  • 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 From 9b2e73e4b66043350f2b380562961850ee1e9a80 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Wed, 15 Jan 2025 13:21:09 +0400 Subject: [PATCH 06/10] #555 Fix punctuation in list --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 6c817976..3c93db1d 100644 --- a/index.html +++ b/index.html @@ -5477,17 +5477,17 @@

    Algorithm

    xsd:double and its lexical form is a valid xsd:integer or xsd:double - according to [[XMLSCHEMA11-2]], + according to [[XMLSCHEMA11-2]]:
      -
    1. attempt to convert the lexical form to a JSON number +
    2. Attempt to convert the lexical form to a JSON number according to [[RFC8785]] JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers - procedure; + procedure.
    3. If the conversion is successful, set converted value - to its result; + to its result.
    4. Otherwise, set type to datatype IRI of value. From 2affadbc7b75b00b88c4d5718280eedc2aac10c1 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Sat, 25 Jan 2025 22:34:58 +0400 Subject: [PATCH 07/10] #555 Insert `` tags as appropriate --- index.html | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 3c93db1d..bda0a77e 100644 --- a/index.html +++ b/index.html @@ -5479,18 +5479,26 @@

      Algorithm

      is a valid xsd:integer or xsd:double according to [[XMLSCHEMA11-2]]:
        -
      1. Attempt to convert the lexical form to a JSON number - according to - [[RFC8785]] - JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers - procedure. +
      2. + + Attempt to convert the lexical form to a JSON number + according to + [[RFC8785]] + JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers + procedure. +
      3. - If the conversion is successful, set converted value - to its result. + + If the conversion is successful, set converted value + to its result. +
      4. - Otherwise, set type to datatype IRI of value. + + Otherwise, set type to datatype IRI + of value. +
    5. From 33a652b58df504978bfec925a77734f436e4c520 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 25 Jan 2025 15:10:05 -0800 Subject: [PATCH 08/10] Add Candidate Correction change entry and anchor for useNativeTypes changes. --- index.html | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index bda0a77e..0ea9c894 100644 --- a/index.html +++ b/index.html @@ -5456,6 +5456,12 @@

      Algorithm

    6. Initialize converted value to value.
    7. Initialize type to null
    8. If useNativeTypes is true +
      + Candidate Correction 5 +

      This changes the behavior of using native numbers when useNativeTypes is `true`. + For more information, refer to issue 555. +

      +
      1. If the datatype IRI @@ -5477,30 +5483,30 @@

        Algorithm

        xsd:double and its lexical form is a valid xsd:integer or xsd:double - according to [[XMLSCHEMA11-2]]: -
          -
        1. - + according to [[XMLSCHEMA11-2]], + set converted value + to the result of converting the + lexical form + to a JSON number. + : +
            +
          1. Attempt to convert the lexical form to a JSON number according to [[RFC8785]] JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers procedure. - -
          2. -
          3. - +
          4. +
          5. If the conversion is successful, set converted value to its result. - -
          6. -
          7. - +
          8. +
          9. Otherwise, set type to datatype IRI of value. - -
          10. -
          +
        2. +
        +
    9. @@ -7077,6 +7083,9 @@

      Change log

      Embedding JSON-LD in HTML Documents [[JSON-LD11]] for treating script elements as a single document, as described in Candidate Correction 4. +
    10. 2025-01-25: Correct some corner cases in transforming RDF Number Literals + to JSON numbers when useNativeTypes is `true`, + as described in Candidate Correction 5.
    11. 2024-01-25: Change processing step for LoadDocumentCallback to not presume that the content type is for JSON, as described in Candidate Correction 6
    12. From 065444acad9f6d79f6da44eeb51de15f6059cdcc Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Sun, 9 Feb 2025 20:23:41 +0400 Subject: [PATCH 09/10] =?UTF-8?q?#555=20Commit=20suggestions=20=C2=A9=20@T?= =?UTF-8?q?allTed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ted Thibodeau Jr --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 0ea9c894..a440f6ef 100644 --- a/index.html +++ b/index.html @@ -5458,7 +5458,7 @@

      Algorithm

    13. If useNativeTypes is true
      Candidate Correction 5 -

      This changes the behavior of using native numbers when useNativeTypes is `true`. +

      This changes behavior when using native numbers where useNativeTypes is `true`. For more information, refer to issue 555.

      @@ -5492,7 +5492,7 @@

      Algorithm

      1. Attempt to convert the lexical form to a JSON number - according to + according to the [[RFC8785]] JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers procedure. From 10c39a96f36bee149030c6d42c949be90b2070f3 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Sun, 9 Feb 2025 20:36:57 +0400 Subject: [PATCH 10/10] =?UTF-8?q?#555=20Fixes=20to=20test=200027=20=C2=A9?= =?UTF-8?q?=20@pchampin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pierre-Antoine Champin --- tests/fromRdf/0027-in.nq | 1 - tests/fromRdf/0027-out.jsonld | 4 ---- 2 files changed, 5 deletions(-) diff --git a/tests/fromRdf/0027-in.nq b/tests/fromRdf/0027-in.nq index b03b0c80..8336cb89 100644 --- a/tests/fromRdf/0027-in.nq +++ b/tests/fromRdf/0027-in.nq @@ -5,7 +5,6 @@ "False"^^ . "1"^^ . - "1.1"^^ . "0.1e999999999999999"^^ . "+INF"^^ . diff --git a/tests/fromRdf/0027-out.jsonld b/tests/fromRdf/0027-out.jsonld index cc9f212a..f03c97a0 100644 --- a/tests/fromRdf/0027-out.jsonld +++ b/tests/fromRdf/0027-out.jsonld @@ -32,10 +32,6 @@ { "@type": "http://www.w3.org/2001/XMLSchema#integer", "@value": 1 - }, - { - "@type": "http://www.w3.org/2001/XMLSchema#decimal", - "@value": 1.1 } ] },