[x3d-public] JSON schema: type for IMPORT, EXPORT

yottzumm at gmail.com yottzumm at gmail.com
Mon May 8 20:49:06 PDT 2017


I like it when arrays are not nested inside arrays.

I’m having good progress on creating a new schema, and may find conflicts between the existing schema and the object model.  Fuzz testing is kind of fun.  As a side test, I am converting my fuzz to Java and see if it will compile (LOL).  I’m pretty amazed what will pass by the JSON schema now, and also what it catches.  

Plus I’m liking my new console interface to the validator.  Has anyone tried my online validator at http://coderextreme.net/X3DJSONLD/?  Much improved over jshint/jslint/JSON.parse/jsonlint (uses Ajv!).  Now with elision of sibling objects!

Do we want to migrate to the Draft 06 Meta Schema?

Are there any possibilities for converting the schematron to JSON?

Don’t forget you can use the JSON x3dvalidator to validate X3D JSON against Roy’s JSON schema.  Found here: https://github.com/coderextreme/x3dvalidate  Alex has 22 hours of effort in so far, and I’ve been porting over improvements and catching bugs in X3DJSONLD.

John

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Monday, May 8, 2017 11:18 PM
To: Roy Walmsley
Cc: 'John Carlson'; 'X3D Graphics public mailing list'
Subject: Re: JSON schema: type for IMPORT, EXPORT

oops, looks like i misread your note and got confused.  looks like you did find how to fix it, am happy to retest when you are like.

p.s. time to head home i guess...  once again, thanks!  8)

On 5/8/2017 8:13 PM, Don Brutzman wrote:
> Thanks for explaining, very helpful.  I believe that your description matches the attached example, where IMPORT appears in sequence next to other children.
> 
> jslint local and online validation also passes:
> 
> https://jsonlint.com/?json=http://www.web3d.org/x3d/content/examples/Basic/development/X3dHeaderPrototypeSyntaxExamples.json
> 
> However am still not grokking why the JSON Schema validation is unhappy.  Are IMPORT and EXPORT indeed handled similarly to ROUTE for all uses (such as child of Scene or ProtoBody)?
> 
> ========================================================================
> ant -f C:\\x3d-code\\www.web3d.org\\x3d\\content\\examples\\Basic processScenes.json
> get.saxon.check:
> found C:\x3d-code\www.web3d.org\x3d\tools\jar/saxon9he.jar: true
> get.saxon:
> processScenes.json:
> stylesheet compiled=false
> C:\x3d-code\www.web3d.org\x3d\content\examples\Basic/X3dSpecifications//X3dHeaderPrototypeSyntaxExamples.x3d processing with X3dToJson stylesheet
> C:\x3d-code\www.web3d.org\x3d\content\examples\Basic/X3dSpecifications//X3dHeaderPrototypeSyntaxExamples.json validation checking with jslint
> C:\x3d-code\www.web3d.org\x3d\content\examples\Basic/X3dSpecifications//X3dHeaderPrototypeSyntaxExamples.json validation checking with json-schema-validator
> --- BEGIN C:\x3d-code\www.web3d.org\x3d\content\examples\Basic\X3dSpecifications\X3dHeaderPrototypeSyntaxExamples.json---
> validation: FAILURE
> [ {
>    "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/18/IMPORT"
>    },
>    "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\content\examples\Basic\X3dSpecifications\X3dHeaderPrototypeSyntaxExamples.json---
> Java Result: 100
> echo.timestamp:
> timestamp 20:06:07 on 8 May 2017
> processScenes.json complete.
> BUILD SUCCESSFUL (total time: 3 seconds)
> ========================================================================
> 
> 
> On 5/8/2017 5:06 AM, Roy Walmsley wrote:
>> Hi Don,
>>
>> Here is a graphic of the JSON schema structure for IMPORT.
>>
>> As you can see, it is an array, but an array of objects. This is also the structure listed in the draft JSON encoding at 4.3.2.15 (see http://www.web3d.org/documents/specifications/19776-5/V3.3/Part05/concepts.html#IMPORTPropertySyntax). However, comparison is useful against the ROUTE statement, which is not an array, but an object. Here it is:
>>
>> And the draft text is at http://www.web3d.org/documents/specifications/19776-5/V3.3/Part05/concepts.html#ROUTEPropertySyntax. Now, note that the text talks about it being an optional property of some “-children” property arrays. So let us look at some of these:
>>
>>   * For the Scene object, the “-children” property (http://www.web3d.org/documents/specifications/19776-5/V3.3/Part05/concepts.html#SceneChildrenPropertySyntax) includes ROUTE, IMPORT and EXPORT statements, among others.
>>   * For the Node object, the “-children” property, where it may optionally be added (http://www.web3d.org/documents/specifications/19776-5/V3.3/Part05/concepts.html#NodeChildrenPropertySyntax) includes ROUTE, IMPORT and EXPORT, among others
>>   * Referring to the JSON schema, the “-children” definition, equivalent to nodes derived from X3DChildNode, includes ROUTE,  IMPORT and EXPORT, among others.
>>
>> Thus I conclude that wherever an IMPORT or EXPORT statement can be used, is (unless I have missed something) always in the context of an MFNode field, or else as a direct child of the Scene statement. Hence it is already part of an array, and therefore does not need to be an array in its own right. Therefore, I propose to remove the array portion from the JSON schema definition, if everyone is in agreement.
>>
>> Thanks for spotting this and raising it.
>>
>> All the best,
>>
>> Roy
>>
>> -----Original Message-----
>> From: Don Brutzman [mailto:brutzman at nps.edu]
>> Sent: 08 May 2017 03:26
>> 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: JSON schema: type for IMPORT, EXPORT
>>
>> x3d-3.3-JSONSchema.json says
>>
>>                                  "IMPORT": {
>>
>>                                                  "type": "array",
>>
>>                                  "EXPORT": {
>>
>>                                                  "type": "array",
>>
>> but likely should be structured similarly to
>>
>>                                  "ROUTE": {
>>
>>                                                  "type": "object",
>>
>> Diagnostic: test scene X3dHeaderPrototypeSyntaxExamples.json attached, with excerpt:
>>
>> { "IMPORT":
>>
>>     {
>>
>>                  "@AS":"someInlineRoot",
>>
>>                  "@importedDEF":"someName",
>>
>>                  "@inlineDEF":"someInline"
>>
>>     }
>>
>> },
>>
>> { "PositionInterpolator":
>>
>>     {
>>
>>                  "@DEF":"StayInPlace",
>>
>>                  "@key":[0,1],
>>
>>                  "@keyValue":[0,0,0,0,0,0]
>>
>>     }
>>
>> },
> 
> 
> all the best, Don


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/20170508/826565a7/attachment-0001.html>


More information about the x3d-public mailing list