[x3d-public] online xslt transformer

Don Brutzman brutzman at nps.edu
Sun Jan 26 17:26:25 PST 2020


[cc: Curt, Terry]

Thanks for the interesting assets and information Andreas!

Have automated our build conversions, using saxon 9 as conversion engine.

Noticed you had a lower-case "<inline>" in your gist example.  Generally my transformations are as strict as possible so that could be the cause of the error you got.

Our validation of JSON source will get stricter once they finalize JSON Schema and provide source, John Carlson can hardly wait to get to that point.

	https://json-schema.org

Example prototype conversion:

* X3D Example Archives: X3D for Web Authors, Chapter 14 Prototypes, View Frustum Prototype
   https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototypeIndex.html
   https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototype.json
   https://jsonlint.com/?json=https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototype.json

excerpt follows

"ProtoBody": {
     "-children":[
       { "Switch":
         {
           "@DEF":"VisibilitySwitch",
           "@whichChoice":-1,
           "-children":[
             { "Transform":
               {
                 "@DEF":"PositionTransform",
                 "@rotation":[0,1,0,3.14159],
                 "-children":[
                   { "Transform":
                     {
                       "@DEF":"OrientationTransform",
                       "-children":[
                         { "Shape":
                           {
                             "-geometry":
                               { "IndexedLineSet":
                                 {
                                   "@DEF":"FrustumLines",
                                   "@coordIndex":[0,1,2,3,0,-1,4,5,6,7,4,-1,0,4,-1,1,5,-1,2,6,-1,3,7,-1],
                                   "-coord":
                                     { "Coordinate":
                                       {
                                         "@DEF":"FrustumCoordinate",
                                         "@point":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
                                       }
                                     }
                                 }
                               },
                             "-appearance":
                               { "Appearance":
                                 {
                                   "-material":
                                     { "Material":
                                       {
                                         "IS": {
                                             "connect": [
                                               {
                                                 "@nodeField":"emissiveColor",
                                                 "@protoField":"lineColor"
                                               }
                                             ]
                                         }
                                       }
                                     }
                                 }
                               }
                           }
                         },
                         { "Shape":
                           {
                             "-geometry":
                               { "Extrusion":
                                 {
                                   "@DEF":"FrustumExtrusion"
                                 }
                               },
                             "-appearance":
                               { "Appearance":
                                 {
                                   "@DEF":"FrustumAppearance",
                                   "-material":
                                     { "Material":
                                       {
                                         "IS": {
                                             "connect": [
                                               {
                                                 "@nodeField":"diffuseColor",
                                                 "@protoField":"frustumColor"
                                               },
                                               {
                                                 "@nodeField":"transparency",
                                                 "@protoField":"transparency"
                                               }
                                             ]
                                         }
                                       }
                                     }
                                 }
                               }
                           }
                         },
                         { "Shape":
                           {
                             "-geometry":
                               { "Sphere":
                                 {
                                   "@radius":0.08
                                 }
                               },
                             "-appearance":
                               { "Appearance":
                                 {
                                   "@USE":"FrustumAppearance"
                                 }
                               }
                           }
                         }
                       ]
                     }
                   }
                 ]
               }
             }
           ]
         }
       },
       { "Script":
         {
           "@DEF":"GeometryComputationScript",
           "@directOutput":true,
           "@url":["ViewFrustumPrototypeScript.js","http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototypeScript.js"],
           "field": [
             {
               "@name":"visible",
               "@accessType":"inputOutput",
               "@appinfo":"Whether or not frustum geometry is rendered",
               "@type":"SFBool"
             },
             {
               "@name":"visibilitySwitchSelection",
               "@accessType":"outputOnly",
               "@appinfo":"Adjust Switch selection to make geometry visible or not",
               "@type":"SFInt32"
             },
             {
               "@name":"ViewpointNode",
               "@accessType":"initializeOnly",
               "@type":"SFNode",
               "-children":[
                 {
                   "#comment":"initialization node (if any) goes here"
                 }
               ]
             },
             {
               "@name":"NavigationInfoNode",
               "@accessType":"initializeOnly",
               "@type":"SFNode",
               "-children":[
                 {
                   "#comment":"initialization node (if any) goes here"
                 }
               ]
             },
             {
               "@name":"FrustumCoordinate",
               "@accessType":"initializeOnly",
               "@type":"SFNode",
               "-children":[
                 { "Coordinate":
                   {
                     "@USE":"FrustumCoordinate"
                   }
                 }
               ]
             },
             {
               "@name":"FrustumExtrusion",
               "@accessType":"initializeOnly",
               "@type":"SFNode",
               "-children":[
                 { "Extrusion":
                   {
                     "@USE":"FrustumExtrusion"
                   }
                 }
               ]
             },
             {
               "@name":"recompute",
               "@accessType":"inputOnly",
               "@type":"SFBool"
             },
             {
               "@name":"aspectRatio",
               "@accessType":"inputOutput",
               "@appinfo":"assumed ratio height/width",
               "@type":"SFFloat"
             },
             {
               "@name":"position_changed",
               "@accessType":"outputOnly",
               "@type":"SFVec3f"
             },
             {
               "@name":"orientation_changed",
               "@accessType":"outputOnly",
               "@type":"SFRotation"
             },
             {
               "@name":"spine_changed",
               "@accessType":"outputOnly",
               "@type":"MFVec3f"
             },
             {
               "@name":"scale_changed",
               "@accessType":"outputOnly",
               "@type":"MFVec2f"
             },
             {
               "@name":"point_changed",
               "@accessType":"outputOnly",
               "@type":"MFVec3f"
             },
             {
               "@name":"trace",
               "@accessType":"initializeOnly",
               "@type":"SFBool"
             }
           ],
           "IS": {
               "connect": [
                 {
                   "@nodeField":"visible",
                   "@protoField":"visible"
                 },
                 {
                   "@nodeField":"ViewpointNode",
                   "@protoField":"ViewpointNode"
                 },
                 {
                   "@nodeField":"NavigationInfoNode",
                   "@protoField":"NavigationInfoNode"
                 },
                 {
                   "@nodeField":"aspectRatio",
                   "@protoField":"aspectRatio"
                 },
                 {
                   "@nodeField":"trace",
                   "@protoField":"trace"
                 }
               ]
           }
         }
       },
       { "ROUTE":
         {
           "@fromField":"visibilitySwitchSelection",
           "@fromNode":"GeometryComputationScript",
           "@toField":"whichChoice",
           "@toNode":"VisibilitySwitch"
         }
       },
       { "ROUTE":
         {
           "@fromField":"position_changed",
           "@fromNode":"GeometryComputationScript",
           "@toField":"translation",
           "@toNode":"PositionTransform"
         }
       },
       { "ROUTE":
         {
           "@fromField":"orientation_changed",
           "@fromNode":"GeometryComputationScript",
           "@toField":"rotation",
           "@toNode":"OrientationTransform"
         }
       },
       { "ROUTE":
         {
           "@fromField":"spine_changed",
           "@fromNode":"GeometryComputationScript",
           "@toField":"set_spine",
           "@toNode":"FrustumExtrusion"
         }
       },
       { "ROUTE":
         {
           "@fromField":"scale_changed",
           "@fromNode":"GeometryComputationScript",
           "@toField":"set_scale",
           "@toNode":"FrustumExtrusion"
         }
       },
       { "ROUTE":
         {
           "@fromField":"point_changed",
           "@fromNode":"GeometryComputationScript",
           "@toField":"point",
           "@toNode":"FrustumCoordinate"
         }
       }
     ]
}
On 1/26/2020 1:30 PM, Andreas Plesch wrote:
> It was the xsl processor which had the problem, not the stylesheet.
> 
> http://xsltransform.net/
> 
> uses saxon 9 he and generates error-free and hopefully correct json.
> 
> -Andreas
> 
> On Sun, Jan 26, 2020 at 4:09 PM Andreas Plesch <andreasplesch at gmail.com> wrote:
>>
>> I was looking for a relatively easy way to convert from xml to the
>> json encoding, using Don's xslt stylesheet
>> (https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJson.xslt#l26).
>> After a while I found
>>
>> https://xslttest.appspot.com/
>>
>> which seems to work pretty well but had some problem with Protos
>>
>> Here is a test conversion of an old vrml scene:
>>
>> https://gist.github.com/andreasplesch/4fb27cb9f3db9ee423066ae74d4aaae1
>>
>> converted to xml with view3dscene.
>>
>> The json has "-IllegalChildNodeFieldNameNotFound" in ProtoBodies.
>> Could that be a result of insufficient capabilities of the xsl
>> processor ? It says it supports XSLT 2.0.
>>
>> Andreas
>>
>>
>> --
>> Andreas Plesch
>> Waltham, MA 02453


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