[x3d-public] output of X3dToJson.xslt stylesheet. Is this what we want for #comment?

John Carlson yottzumm at gmail.com
Sat Apr 16 22:36:57 PDT 2016


Here I am to discuss comment handling in the X3dToJson.xslt stylesheet.  Some may not care, but it affects the x3d JSON schema, and where people can place comments in the JSON (which the schema checks), and how tools that post process the converted JSON can rearrange the JSON file (specifically the prototype expander), and roundtripping.

Note that you can’t currently put a JSON comment inside a -geometry or -material node from the stylesheet or in the schema or in the JSON even, the stylesheet moves it out of those nodes, reordering the nodes, making roundtrip impossible back to XML.  If we maintain that the functionality is still there, that’s fine, it’s just that the comment nodes will be reordered with respect to the other nodes, and I haven’t figured out yet how to add a comment to a -geometry node that’s coming from an SFNode which is really an MFNode because it has a comment the ProtoInstance fieldValue, which seems like they want a comment in each geometry field that the fieldValue replaces.

I include an XML and JSON result from the stylesheet for your perusal.  Specifically, I am pushing for all object container nodes to be arrays (or optionally arrays) so they can handle comments, like -geometry and -material container nodes.  This will affect downstream artifacts and is a major change.

One thing I can do is look at the type of the field in the ProtoInterface, see that it’s SFNode, and throw out all comments from the fieldValue in my ProtoExpander, and make the fieldValue an object instead of an array.  However, I am still concerned about reordering of comments, and if we solve the comment problem, we may solve my problem as well :).

John

Here is relevant info from: http://www.web3d.org/x3d/stylesheets/X3dToJson.html <http://www.web3d.org/x3d/stylesheets/X3dToJson.html>

Embedded JSON comments <>. 
Thousands of inquiries have been posted for many years why the JSON specification forbids comments. (Examples: Native comments are intentionally avoided by JSON specification <http://www.quora.com/How-do-I-write-comments-inside-a-JSON-document> and Can I use comments inside a JSON file? <http://stackoverflow.com/questions/244777/can-i-use-comments-inside-a-json-file>) Without providing a rationale, the suggested JavaScript approach is to use JSON.minify() to strip comments. 
Nevertheless, comments are an important capability in the X3D specification. Round-trippable inclusion of comments are an important optional custom feature of this X3D encoding. In order to best align JSON with X3D, comments are treated as first-class objects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160417/363d4e68/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: for.json
Type: application/json
Size: 13225 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160417/363d4e68/attachment-0001.json>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160417/363d4e68/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: for.x3d
Type: model/x3d+xml
Size: 5982 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160417/363d4e68/attachment-0001.x3d>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160417/363d4e68/attachment-0005.html>


More information about the x3d-public mailing list