[x3d-public] Scene is required? Autogenerating JSON Schema X3D required fields. How to handle default='NULL' from X3DUOM in JSON, JSON schema

John Carlson yottzumm at gmail.com
Wed Apr 25 21:00:22 PDT 2018


Don,

I don’t believe any of the below is a showstopper, except for the patch to the 4.0 schema.  It’s merely making the autogenerated schemas comply with the standard better (required properties and fields), and making the X3DUOM comply as well.  Here’s how we make X3DUOM comply:

• X3D Unified Object Model, the Scene field of X3D Statement should have use="required" to agree with 3.3 JSON Schema.
Also
• The 3.0, 3.1, 3.2 and 4.0 JSON schemas should be updated to the latest versions.

The autogenerated JSON Schemas, version 3.0, 3.1, 3.2, 3.3 and 4.0 should require Scene and encoding properties of X3D statement/object, per Roy's 3.3 JSON schema.  I noticed this while playing with the online validator at https://coderextreme.net/X3DJSONLD/src/main/html/validator.html   
Stated here:

ISO/IEC 19776-5:201x Table 4.2

In X3D Unified Object Model, the Scene field of X3D Statement should have use="required" to agree with 3.3 JSON Schema, I believe.  Currently, the X3D Unified Object Model has default="NULL" for Scene.   I will look into how to make Scene nullable yet required in JSON and JSON Schema if desired (I’m imagining something like “Scene” : null, or “Scene” : {} more likely).  I am not sure what would happen (to my whole tool chain!) if people started including null’s in their JSON, but we should test…Any good examples of a bare null (no quotes)  in our X3D JSON examples?

Here are some examples with "NULL".  I think they should be null instead. Likely you should change X3dToJson.xslt.  But we need to consult the working draft as well – how it wants to encode NULL.

$ find . -name '*.json' -print0| xargs -0 grep -l '"NULL"'
./Basic/development/X3dRetreatProtoExercise.json
./Basic/HumanoidAnimation/AllenDuttonProtoInstances.json
./Basic/HumanoidAnimation/HAnimPrototypes.json
./Basic/HumanoidAnimation/InterchangableActorsViaDynamicRoutingPrototypes.json
./Basic/HumanoidAnimation/NancyPrototypes.json
./Basic/Shaders/SimpleShader.json
./Savage/Tools/Animation/WaypointInterpolatorPrototype.json
./Savage/Tools/Terrain/GeoLocation3.json
./Savage/Tools/Terrain/GeoTerrainGrid.json

For @value, we’re leaving the type kind of open, but the X3DUOM says SFString.  Hmm.  The JSON schema says @value is {}.  Strange.  I don’t see how it gets generated that way, but I must have done it some tricky way 😊.  I guess that’s a puzzle for now.

There is no analogous field for encoding in X3DUOM, so we will hardcode its requirement in the JSON schema autogenerator.  I can also hardcode Scene’s requirement in the autogenerator, if necessary—I’ve already done it.  I just need to take it out if we add use=”required” to the Scene field in X3DUOM.

Let me know if you want me to update the online JSON schemas for these two properties, I’ve already updated x3d-3.3-JSONSchema.autogenerated.json, and there’s also a patch for the 4.0 JSON schema outstanding.

Attached is a new autogenerator.

That’s all for now!

John

Here’s the full patch:

Index: x3d-3.0-JSONSchema.json
===================================================================
--- x3d-3.0-JSONSchema.json     (revision 26720)
+++ x3d-3.0-JSONSchema.json     (working copy)
@@ -13720,6 +13720,8 @@
       },
       "required": [
         "@profile",
+        "Scene",
+        "encoding",
         "@version"
       ],
       "additionalProperties": false
Index: x3d-3.1-JSONSchema.json
===================================================================
--- x3d-3.1-JSONSchema.json     (revision 26720)
+++ x3d-3.1-JSONSchema.json     (working copy)
@@ -15700,6 +15700,8 @@
       },
       "required": [
         "@profile",
+        "Scene",
+        "encoding",
         "@version"
       ],
       "additionalProperties": false
Index: x3d-3.2-JSONSchema.json
===================================================================
--- x3d-3.2-JSONSchema.json     (revision 26720)
+++ x3d-3.2-JSONSchema.json     (working copy)
@@ -22492,6 +22492,8 @@
       },
       "required": [
         "@profile",
+        "Scene",
+        "encoding",
         "@version"
       ],
       "additionalProperties": false
Index: x3d-4.0-JSONSchema.json
===================================================================
--- x3d-4.0-JSONSchema.json     (revision 26720)
+++ x3d-4.0-JSONSchema.json     (working copy)
@@ -9220,7 +9220,6 @@
                 "r_metacarpophalangeal_joint_5",
                 "r_carpal_proximal_interphalangeal_joint_5",
                 "r_carpal_distal_interphalangeal_joint_5",
-                "r_carpal_distal_interphalangeal_joint_5",
                 "l_tarsometatarsal_joint",
                 "l_metatarsophalangeal_joint",
                 "l_tarsal_interphalangeal_joint",
@@ -24206,6 +24205,8 @@
       },
       "required": [
         "@profile",
+        "Scene",
+        "encoding",
         "@version"
       ],
       "additionalProperties": false

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180426/580c1aeb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: etgenerateJSONschema.py
Type: application/octet-stream
Size: 92391 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180426/580c1aeb/attachment-0001.obj>


More information about the x3d-public mailing list