[x3d-public] X3D to JSON Stylesheet Converter - tools; omitting overall [array brackets]

Don Brutzman brutzman at nps.edu
Fri Nov 6 16:24:29 PST 2015


1. John thanks for the separate email about pulling out the enclosing brackets.  Will do that as part of next round.

Another supporting rationale for that: putting several X3D elements in an array might be an author choice - so we can leave it to the JSON programmer/designer to decide.  No need to unnecessarily foist that on everyone as a requirement - an X3D object should be available as an object, rather than array that always has length of 1.

Other issues being worked, previewed here for consideration:

2. Test trial, I added an XSLT code block to remove default attributes with default values, but that makes comma management even more difficult...  and so have thought of another XSLT approach for comma filtering (rather than predictive insertion) and will try that this weekend.

3. Commas for attributes also relate closely to figuring out comma handling for handling comments.  The JSON rule is that adjacent objects are separated by commas, but no comma after the last peer.  Figuring out "which is last?" actually becomes difficult when contained-node order is shuffled to place like elements adjacent to each other.  thus am considering possibilities where we might handle comments similarly to ROUTEs (which need to get pushed to the end of whichever set of peers they are next to).  Since original order if the scene graph cannot be strictly matched in JSON, perhaps for any given set of peer elements there needs to be a processing order of ProtoDeclare/ExternProtoDeclare, nodes/ProtoInstances, comments, and ROUTEs to avoid violating DEF/USE predeclaration constraints.

rephrase: some re-ordering of child nodes/comments/ROUTEs is necessary to match JSON requirements.  although this is not preserving exact round-trippability, am aiming for functional equivalence and no insertion of side-effect errors.

4. Also agree with direction of your various emails about json schema autogeneration: but we don't have to get a tool to behave perfectly.  That is often really difficult, not to mention brittle over time.  Therefore if you get something in the ball park, then we can switch to manual tuning testing and maintenance, in version control, in tandem with the encoding testing with examples.

5. We have yet another trick in our toolbag:  Roy and I have been autogenerating API interfaces for .x3d (XML), .x3dv (Classic VRML) and even Java APIs (SAI).  So if you get a JSON schema somewhere close, and tuning shows that indeed it can work, then we might adapt another stylesheet that autogenerates that agreed-upon X3D JSON schema pattern using the authoritative X3D XML schema information.

Good luck with your next steps.


On 11/5/2015 4:49 AM, Don Brutzman wrote:
> thanks for the tool links.
>
> have added links for the tools that seemed to offer most general interest and usefulness to authors at
>
>      http://www.web3d.org/x3d/stylesheets/X3dToJson.html#Tools
>
> in the meantime, while using
>
>      Json Parser Online
>      http://json.parser.online.fr
>
> noticed that we have been wrapping every X3D JSON scene in [array brackets] for no apparent reason... probably a holdover from an early example.
>
> OK to remove those?  for example,
> [
>   { "X3D":[
>      {
>        "@profile":"Immersive",
>        "@version":3.3,
>        "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
>        "head":[
>        ],
>        "Scene":[
>        ]
>      }
>    ]
>   }
> ]
>
> becomes
>
>   { "X3D":[
>      {
>        "@profile":"Immersive",
>        "@version":3.3,
>        "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
>        "head":[
>        ],
>        "Scene":[
>        ]
>      }
>    ]
>   }
>
> 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



More information about the x3d-public mailing list