[x3d-public] JSON encoding of unexpected additional attributes on Scene, head, ProtoBody and IS elements

Don Brutzman brutzman at nps.edu
Fri Nov 27 10:56:27 PST 2015

Thanks for the further dialog on the conversion issue.

I will work on whether the X3dToJson.xslt stylesheet can be more tolerant when it encounters unexpected attributes.  The result might not be valid X3D, but at least it will be valid JSON.  This is important for supporting experimentation.

Hopefully the JSON pattern we have established won't need modification...

On 11/25/2015 5:11 PM, Don Brutzman wrote:
> Hi John.  I checked and tested a number of scenes, the Scene tag looks OK and they are all continuing to pass without throwing jslint errors.
> I believe that the problem is in your Scene tag, it is not supposed to have attributes.  There are no corrolaries for those in other encodings.  Though I suppose we might well expect to have them since a <Scene> element might get decorated with attributes by DOM operations or other editing.
> Similar situation exists for elements head, Scene, ProtoBody and IS.  The current encoding treats those as containing simple objects rather than containing an array.
> I recommend taking the attribute off of Scene (if possible) so that you can proceed, and we think about this some more.  Am hesitant before opening a door that might encourage otherwise-invalid X3D content.


On 11/25/2015 3:07 PM, John Carlson wrote:
> Don, the stylesheet in X3D-Edit and the one I downloaded from here http://www.web3d.org/x3d/stylesheets/ <http://www.web3d.org/x3d/stylesheets/>*X3dToJson*.*xslt both produce this JSON which has a bad Scene object.*
> *
> *Note the object which is used as a key in the Scene:*
> *
> *“Scene”: { {*
> *
> *The second brace is illegal.  Please get a JSON parser or jsonlint-lines and use it.  Original X3D is include below:*
> *
> *John*
> { "X3D": {
>      "@id":"x3dElement",
>      "@showStat":false,
>      "@showLog":false,
>      "@style":"width:100%; height:100%; border:0; margin:0; padding:0;",
>      "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",

here was the problem, double braces, caused by translator confusion at having a DEF attribute appear as part of Scene.

>      "Scene": {
>        {
>          "@DEF":"scene",
>          "-children":[

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