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

John Carlson yottzumm at gmail.com
Sun Jul 9 16:22:01 PDT 2017


@class is not in JSON, only in XML.  But since we are converting back to XML, it would be nice to have.

IMPORT is defined as:

                "IMPORT": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                                "type": "object",
                                "properties": {
                                        "@AS": {
                                                "type": "string"
                                        },
                                        "@importedDEF": {
                                                "type": "string"
                                        },
                                        "@inlineDEF": {
                                                "type": "string"
                                        }
                                },
                                "required": [
                                        "@importedDEF",
                                        "@inlineDEF"
                                ],
                                "additionalProperties": false
                        }
                },

EXPORT:
                "EXPORT": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                                "type": "object",
                                "properties": {
                                        "@AS": {
                                                "type": "string"
                                        },
                                        "@localDEF": {
                                                "type": "string"
                                        }
                                },
                                "required": [
                                        "@localDEF"
                                ],
                                "additionalProperties": false
                        }
                },

You will have to review the emails on these subjects, I believe.  I am not sure what action was taken.

I am not sure you can choose both an array and an object, but Roy would know better.

John

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Sunday, July 9, 2017 6:56 PM
To: Roy Walmsley; John Carlson
Cc: X3D Graphics public mailing list
Subject: X3D JSON schema validation problems: @class and IMPORT/EXPORTattributes

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170709/168ff3b1/attachment.html>


More information about the x3d-public mailing list