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

Don Brutzman brutzman at nps.edu
Mon Jul 10 08:20:03 PDT 2017


thanks for checking these.

On 7/10/2017 6:17 AM, Roy Walmsley wrote:
> 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.

I had thought we had a Mantis issue about elevating the 'class' attribute to Abstract specification, and other encodings, since it seems to be essential to HTML5/CSS integration and we typically make all encodings fully symmetric in terms of expressive power.

Searched but couldn't find the Mantis issue however. Perhaps I overlooked it and you can locate it?

If not then I can post a specification comment so that the issue gets fully considered in Mantis as part of X3D v4 design.

> 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

Thanks Roy.  This will be good to sort out more closely.  I don't think this draft JSON specification is entirely correct; IMPORT and EXPORT statements can appear multiple times and anywhere in the scene graph, not just with the Scene (root) element.  Good practice for DEF readability/confirmation is to put each of them near their corresponding Inline node, but that isn't explicitly required.

===========================================================================
9.2.5 IMPORT statement
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/networking.html#IMPORTStatement

The following example illustrates the use of the IMPORT statement (Classic VRML encoding syntax):

DEF I1 Inline {
   url "someurl.x3d"
}
       . . .

IMPORT I1.rootTransform AS I1Root
DEF PI PositionInterpolator { ... }
ROUTE PI.value_changed TO I1Root.set_translation

===========================================================================
9.2.6 EXPORT statement
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/networking.html#EXPORTStatement

The following example illustrates the use of the EXPORT statement (Classic VRML encoding):

DEF T1 Transform {
    ...
}
      . . .

EXPORT T1 AS rootTransform

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

and related links

http://www.web3d.org/x3d/tooltips/X3dTooltips.html#IMPORT
http://www.web3d.org/specifications/X3dSchemaDocumentation3.3/x3d-3.3_IMPORT.html
http://www.web3d.org/specifications/X3dDoctypeDocumentation3.3.html#IMPORT
etc.

We should probably check the encoding documents further to ensure that each DEF precedes IMPORT/EXPORT, just as DEF precedes USE.  Or else NOTE that prior DEF definition is not a requirement.


> -----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 brutzman at nps.edu <mailto: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
> 


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



More information about the x3d-public mailing list