[x3d-public] X3D JSON - comments preceding and following the X3D Element/Object

John Carlson yottzumm at gmail.com
Mon Jan 11 13:52:25 PST 2016


Well, we used to have an array around the X3D object, like the below.  I’m not sure I want to add it back though.

[
{ “#comment”: “My comment” },
{ “X3D”: { …
]
> On Jan 11, 2016, at 4:37 PM, Don Brutzman <brutzman at nps.edu> wrote:
> 
> Thanks for the helpful clarifications John, I understand your point now.
> 
> Certainly an excellent "edge case."  Your test case shows it sticking out like a sore thumb in JSON.
> 
> I would not expect such a comment to be part of a conversion to .json for several reasons:
> a. it is outside the X3D JSON object, so there is nowhere to put it in the resulting JSON.
> b. it is outside the X3D element in the .x3d XML file, so the X3dToJson.xslt stylesheet can either find it, filter it and/or move it.
> c. it could be added as a /* javascript comment */ either before or after the X3D JSON object is produced, but then the result would not be valid JSON anymore.
> 
> Comparison of similar comment legality in other X3D encodings and language bindings:
> - VRML97, ClassicVRML: comments allowed anywhere after initial header line #VRML V2.0 utf8 (or #X3D V3.3 utf8)
> - XML: allowed anywhere after initial XML header line <?xml version="1.0" encoding="UTF-8"?>
> - Compressed Binary: allowed, precisely matching the valid XML document
> - Javascript: allowed in source code but not part of X3D object
> - Java: allowed in source code but not part of X3D object
> 
> Potential ways to address it:
> 1. omit the comment
> 2. move the comment's location in the JSON scene graph by tucking the comment under the X3D root (which would now contain "head" "Scene" and "-children" keys).
> 3. report a warning regarding disposition when converting to JSON
> 4.something else?
> 
> Note that if we follow option 3, we again have the partial reordering issue: once it has landed in JSON, there is no way to tell if the original comment preceded or followed or was within the X3D root.  Your example illustrates that reshuffling nicely.
> 
> Once we have agreed-upon handling, I'll revise the X3dToJson.xslt conversion stylesheet accordingly to match.
> 
> Now added to the list of issues.  It is also something we will need to be explicit about in the future X3D JSON specification.
> 
> http://www.web3d.org/x3d/stylesheets/X3dToJson.html#Issues
> ==================================================================
> TODO open issues and action items
> 
> - Evaluate handling of #comment and ROUTE similar to other -children nodes.
> -- Decide and document how to handle "edge case" of comments appearing before or after X3D node, with comparison to other encodings and language bindings.
> ==================================================================
> 
> Thanks for contributing another excellent insight to improve this effort!
> 
> 
> On 1/11/2016 7:28 AM, John Carlson wrote:
>> For example, the following X3D XML:
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!--Comment before-->
>> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd">
>> <X3D profile="Interchange" version="3.3" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.3.xsd">
>>     <!--Comment before head-->
>>     <head>
>>         <meta name='title' content='FileName.x3d'/>
>>         <meta name='identifier' content='http://someAddress/somePath/FileName.x3d'/>
>>         <meta name='creator' content='Author Name'/>
>>         <meta name='description' content='topic sentence plus good summary'/>
>>         <meta name='generator' content='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
>>     </head>
>>     <!--comment between head and scene-->
>>     <Scene>
>>         <Group>
>>             <Shape> <Sphere/>
>>             <Appearance><Material diffuseColor="1 1 1"/></Appearance>
>>             </Shape>
>> 
>>         </Group>
>>     </Scene>
>>     <!--comment after scene-->
>> </X3D>
>> <!--Comment after—>
>> 
>> 
>> ——————————————————————
>> Becomes the X3D JSON below.  I think I have the most recent version of X3D-Edit.   If the stylesheet has been updated, let me know.
>> ——————————————————————
>> "-children":[
>>   { "#comment":"Comment before"
>>   },
>>   { "#comment":"Comment after"
>>   }
>> ],{ "X3D": {
>>     "@profile":"Interchange",
>>     "@version":3.3,
>>     "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
>>     "-children":[
>>       { "#comment":"Comment before head"
>>       },
>>       { "#comment":"comment between head and scene"
>>       },
>>       { "#comment":"comment after scene"
>>       }
>>     ],
>>     "head": {
>>         "meta": [
>>           {
>>             "@name":"title",
>>             "@content":"FileName.x3d"
>>           },
>>           {
>>             "@name":"identifier",
>>             "@content":"http://someAddress/somePath/FileName.x3d"
>>           },
>>           {
>>             "@name":"creator",
>>             "@content":"Author Name"
>>           },
>>           {
>>             "@name":"description",
>>             "@content":"topic sentence plus good summary"
>>           },
>>           {
>>             "@name":"generator",
>>             "@content":"X3D-Edit, https://savage.nps.edu/X3D-Edit"
>>           }
>>         ]
>>     },
>>     "Scene": {
>>         "-children":[
>>           { "Group":
>>             {
>>               "-children":[
>>                 { "Shape":
>>                   {
>>                     "-geometry":[
>>                       { "Sphere":
>>                         {
>>                         }
>>                       }
>>                     ],
>>                     "-appearance":[
>>                       { "Appearance":
>>                         {
>>                           "-material":[
>>                             { "Material":
>>                               {
>>                                 "@diffuseColor":[1,1,1]
>>                               }
>>                             }
>>                           ]
>>                         }
>>                       }
>>                     ]
>>                   }
>>                 }
>>               ]
>>             }
>>           }
>>         ]
>>     }
>>   }
>> }
> 
> 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