[x3d-public] JSON schema handling of Script url containing ecmascript source

Don Brutzman brutzman at nps.edu
Sun Aug 20 14:30:19 PDT 2017


Found the following problem with JSON schema handling of Script url containing 
source:

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

C:\x3d-code\www.web3d.org\x3d\content\examples\Vrml2Sourcebook/Chapter30Scripts//Figure30_1ScriptSlidingBall.json 
validation checking with json-schema-validator
--- BEGIN 
C:\x3d-code\www.web3d.org\x3d\content\examples\Vrml2Sourcebook\Chapter30Scripts\Figure30_1ScriptSlidingBall.json---
validation: FAILURE
[ {
   "level" : "error",
   "schema" : {
     "loadingURI" : 
"file:/C:/x3d-code/www.web3d.org/specifications/x3d-3.3-JSONSchema.json#",
     "pointer" : "/definitions/Script/properties/@url/items"
   },
   "instance" : {
     "pointer" : "/X3D/Scene/-children/3/Group/-children/8/Script/@url/0"
   },
   "domain" : "validation",
   "keyword" : "format",
   "attribute" : "uri",
   "message" : "string \"ecmascript: function set_fraction( fraction eventTime ) 
{ value_changed[0] = fraction; value_changed[1] = 0.0; value_changed[2] = 0.0; 
}\" is not a valid URI",
   "value" : "ecmascript: function set_fraction( fraction eventTime ) { 
value_changed[0] = fraction; value_changed[1] = 0.0; value_changed[2] = 0.0; }"
} ]
--- END 
C:\x3d-code\www.web3d.org\x3d\content\examples\Vrml2Sourcebook\Chapter30Scripts\Figure30_1ScriptSlidingBall.json---

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

http://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter30Scripts/Figure30_1ScriptSlidingBall.x3d

       <!-- Second Script example: executable code is placed in url field. This 
is legal, but no longer a recommended approach. -->
       <!-- Warning: avoid // inline comments or else canonicalization will hide 
all follow-on code! -->
       <Script DEF='MoverUsingUrlScript' url='"ecmascript: function 
set_fraction( fraction eventTime ) { value_changed[0] = fraction; 
value_changed[1] = 0.0; value_changed[2] = 0.0; }"'>
         <field accessType='inputOnly' name='set_fraction' type='SFFloat'/>
         <field accessType='outputOnly' name='value_changed' type='SFVec3f'/>
       </Script>

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

http://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter30Scripts/Figure30_1ScriptSlidingBall.json

{
   "#comment":"Second Script example: executable code is placed in url field. 
This is legal, but no longer a recommended approach."
},
{
   "#comment":"Warning: avoid // inline comments or else canonicalization will 
hide all follow-on code!"
},
{ "Script":
   {
     "@DEF":"MoverUsingUrlScript",
     "@url":["ecmascript: function set_fraction( fraction eventTime ) { 
value_changed[0] = fraction; value_changed[1] = 0.0; value_changed[2] = 0.0; }"],
     "field": [
       {
         "@name":"set_fraction",
         "@accessType":"inputOnly",
         "@type":"SFFloat"
       },
       {
         "@name":"value_changed",
         "@accessType":"outputOnly",
         "@type":"SFVec3f"
       }
     ]
   }
},

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

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