[x3d-public] X3D JSON schema validation problems: @class and IMPORT/EXPORT attributes

Roy Walmsley roy.walmsley at ntlworld.com
Mon Jul 10 06:17:21 PDT 2017


Don,

 

Agreed with John's later comment that @class is not included in JSON. In fact, let's take that one step further and note that it is not included in the abstract standard. Words containing the letters "class" only appear four times in clause 4 of 19775-1 V3.3, and not at all in clause 7. None of the instances is concerned with the "class" attribute that is included in 19776-1. And looking at 19776-1, clause 4.3.6 class attribute syntax, the text states:

 

“The class attribute is reserved for use with XML Cascading Style Sheets (see [CSS]).”

 

So the class attribute is only for the XML encoding (and anything derived from it). Therefore it should not appear in JSON. And it doesn't.

 

Now what about IMPORT and EXPORT.

 

Let's look at the draft text in the working draft for ISO/IEC CD 19776-5, clause 4.3.2.15 "IMPORT" property syntax. The text reads:

 

“The "IMPORT" property is an optional property of the "Scene" object. It is an array type, where each item is an object having the properties listed in Table 4.13. The first column lists the name of the property. The second column indicates whether the property is optional or required. The third column lists the reference to the detailed encoding of the property.”

 

Table 4.13 lists three properties "@AS" which is optional, and "@importedDEF" and "@inlineDEF", both of which are required. No other properties are permitted. 

 

The "EXPORT" property is defined in an analogous manner. Here is an example from the draft standard:

 

"EXPORT": [

   {

      "@AS": "myNodeAlias",

      "@localDEF": "myNode",

   }

]

 

Why is it done like that? Because JSON recommends, and we have followed this recommendation, that the property keys in any given object should not be duplicated. So, any single object, like "Scene", cannot have multiple IMPORT or EXPORT statements. They have to be collected together into an array. Each IMPORT statement has three properties, so needs to be an object.

 

Hope this helps,

 

All the best,

 

Roy

 

-----Original Message-----
From: Don Brutzman [mailto:brutzman at nps.edu] 
Sent: 09 July 2017 23:55
To: Roy Walmsley <roy.walmsley at ntlworld.com>; John Carlson <yottzumm at gmail.com>
Cc: X3D Graphics public mailing list <x3d-public at web3d.org>
Subject: X3D JSON schema validation problems: @class and IMPORT/EXPORT attributes

 

Finally getting "back up on the horse" to test JSON conversions using X3dToJson.xslt (hooray!)

 

Attached please find current version of X3DJSAIL output .x3d test scene, plus corresponding .json version.

 

Roy, it looks like there may be several omissions in the X3D JSON Schema:

 

a. @class attribute (previously untested) not recognized

 

b. IMPORT/EXPORT statements (previously untested) are apparently expecting an array when simple attributes are provided

 

{ "IMPORT":

   {

                "@AS":"WorldInfoDEF2",

                "@importedDEF":"WorldInfoDEF",

                "@inlineDEF":"inlineSceneDef"

   }

},

{ "EXPORT":

   {

                "@AS":"WorldInfoDEF3",

                "@localDEF":"WorldInfoDEF"

   }

},

 

Console output follows.  Please advise, TIA.

 

=====================================

translation input: test/HelloWorldProgramOutput.x3d ..expected output: test/HelloWorldProgramOutput.json Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode ..error checking with jslint jslint:test/HelloWorldProgramOutput.json:447:1:JavaScript URL.

jslint:test/HelloWorldProgramOutput.json:812:1:JavaScript URL.

Java Result: 1

..error checking with json-schema-validator

--- BEGIN C:\x3d-code\www.web3d.org\x3d\stylesheets\test\HelloWorldProgramOutput.json---

validation: FAILURE

[ {

   "level" : "error",

   "schema" : {

     "loadingURI" : "file:/C:/x3d-code/www.web3d.org/specifications/x3d-3.3-JSONSchema.json#",

     "pointer" : "/definitions/Box"

   },

   "instance" : {

     "pointer" : "/X3D/Scene/-children/5/Transform/-children/0/Anchor/-children/0/Shape/-geometry/Box"

   },

   "domain" : "validation",

   "keyword" : "additionalProperties",

   "message" : "object instance has properties which are not allowed by the schema: [\"@class\"]",

   "unwanted" : [ "@class" ]

}, {

   "level" : "error",

   "schema" : {

     "loadingURI" : "file:/C:/x3d-code/www.web3d.org/specifications/x3d-3.3-JSONSchema.json#",

     "pointer" : "/definitions/IMPORT"

   },

   "instance" : {

     "pointer" : "/X3D/Scene/-children/24/IMPORT"

   },

   "domain" : "validation",

   "keyword" : "type",

   "message" : "instance type (object) does not match any allowed primitive type (allowed: [\"array\"])",

   "found" : "object",

   "expected" : [ "array" ]

}, {

   "level" : "error",

   "schema" : {

     "loadingURI" : "file:/C:/x3d-code/www.web3d.org/specifications/x3d-3.3-JSONSchema.json#",

     "pointer" : "/definitions/EXPORT"

   },

   "instance" : {

     "pointer" : "/X3D/Scene/-children/25/EXPORT"

   },

   "domain" : "validation",

   "keyword" : "type",

   "message" : "instance type (object) does not match any allowed primitive type (allowed: [\"array\"])",

   "found" : "object",

   "expected" : [ "array" ]

} ]

--- END C:\x3d-code\www.web3d.org\x3d\stylesheets\test\HelloWorldProgramOutput.json---

Java Result: 100

=====================================

 

p.s. John it looks like MetadataString "@value conversion is incorrectly encoding " as " instead of \" (though #comment and other values look OK), will work on it.

all the best, Don

-- 

Don Brutzman  Naval Postgraduate School, Code USW/Br        <mailto:brutzman at nps.edu> brutzman at nps.edu

Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149

X3D graphics, virtual worlds, navy robotics  <http://faculty.nps.edu/brutzman> http://faculty.nps.edu/brutzman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170710/559b1b3d/attachment.html>


More information about the x3d-public mailing list