<div><div dir="auto">I would use the Saxon 9 he XSL 2.0 Java transformer for stylesheets. Otherwise look for a DOM2JSONSerializer.js (xml2all.js) in X3DJSONLD. I would appreciate more eyes on that code.</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 26, 2020 at 7:27 PM Don Brutzman <<a href="mailto:brutzman@nps.edu">brutzman@nps.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[cc: Curt, Terry]<br>
<br>
Thanks for the interesting assets and information Andreas!<br>
<br>
Have automated our build conversions, using saxon 9 as conversion engine.<br>
<br>
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.<br>
<br>
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.<br>
<br>
<a href="https://json-schema.org" rel="noreferrer" target="_blank">https://json-schema.org</a><br>
<br>
Example prototype conversion:<br>
<br>
* X3D Example Archives: X3D for Web Authors, Chapter 14 Prototypes, View Frustum Prototype<br>
<a href="https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototypeIndex.html" rel="noreferrer" target="_blank">https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototypeIndex.html</a><br>
<a href="https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototype.json" rel="noreferrer" target="_blank">https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototype.json</a><br>
<a href="https://jsonlint.com/?json=https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototype.json" rel="noreferrer" target="_blank">https://jsonlint.com/?json=https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototype.json</a><br>
<br>
excerpt follows<br>
<br>
"ProtoBody": {<br>
"-children":[<br>
{ "Switch":<br>
{<br>
"@DEF":"VisibilitySwitch",<br>
"@whichChoice":-1,<br>
"-children":[<br>
{ "Transform":<br>
{<br>
"@DEF":"PositionTransform",<br>
"@rotation":[0,1,0,3.14159],<br>
"-children":[<br>
{ "Transform":<br>
{<br>
"@DEF":"OrientationTransform",<br>
"-children":[<br>
{ "Shape":<br>
{<br>
"-geometry":<br>
{ "IndexedLineSet":<br>
{<br>
"@DEF":"FrustumLines",<br>
"@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],<br>
"-coord":<br>
{ "Coordinate":<br>
{<br>
"@DEF":"FrustumCoordinate",<br>
"@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]<br>
}<br>
}<br>
}<br>
},<br>
"-appearance":<br>
{ "Appearance":<br>
{<br>
"-material":<br>
{ "Material":<br>
{<br>
"IS": {<br>
"connect": [<br>
{<br>
"@nodeField":"emissiveColor",<br>
"@protoField":"lineColor"<br>
}<br>
]<br>
}<br>
}<br>
}<br>
}<br>
}<br>
}<br>
},<br>
{ "Shape":<br>
{<br>
"-geometry":<br>
{ "Extrusion":<br>
{<br>
"@DEF":"FrustumExtrusion"<br>
}<br>
},<br>
"-appearance":<br>
{ "Appearance":<br>
{<br>
"@DEF":"FrustumAppearance",<br>
"-material":<br>
{ "Material":<br>
{<br>
"IS": {<br>
"connect": [<br>
{<br>
"@nodeField":"diffuseColor",<br>
"@protoField":"frustumColor"<br>
},<br>
{<br>
"@nodeField":"transparency",<br>
"@protoField":"transparency"<br>
}<br>
]<br>
}<br>
}<br>
}<br>
}<br>
}<br>
}<br>
},<br>
{ "Shape":<br>
{<br>
"-geometry":<br>
{ "Sphere":<br>
{<br>
"@radius":0.08<br>
}<br>
},<br>
"-appearance":<br>
{ "Appearance":<br>
{<br>
"@USE":"FrustumAppearance"<br>
}<br>
}<br>
}<br>
}<br>
]<br>
}<br>
}<br>
]<br>
}<br>
}<br>
]<br>
}<br>
},<br>
{ "Script":<br>
{<br>
"@DEF":"GeometryComputationScript",<br>
"@directOutput":true,<br>
"@url":["ViewFrustumPrototypeScript.js","<a href="http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototypeScript.js" rel="noreferrer" target="_blank">http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ViewFrustumPrototypeScript.js</a>"],<br>
"field": [<br>
{<br>
"@name":"visible",<br>
"@accessType":"inputOutput",<br>
"@appinfo":"Whether or not frustum geometry is rendered",<br>
"@type":"SFBool"<br>
},<br>
{<br>
"@name":"visibilitySwitchSelection",<br>
"@accessType":"outputOnly",<br>
"@appinfo":"Adjust Switch selection to make geometry visible or not",<br>
"@type":"SFInt32"<br>
},<br>
{<br>
"@name":"ViewpointNode",<br>
"@accessType":"initializeOnly",<br>
"@type":"SFNode",<br>
"-children":[<br>
{<br>
"#comment":"initialization node (if any) goes here"<br>
}<br>
]<br>
},<br>
{<br>
"@name":"NavigationInfoNode",<br>
"@accessType":"initializeOnly",<br>
"@type":"SFNode",<br>
"-children":[<br>
{<br>
"#comment":"initialization node (if any) goes here"<br>
}<br>
]<br>
},<br>
{<br>
"@name":"FrustumCoordinate",<br>
"@accessType":"initializeOnly",<br>
"@type":"SFNode",<br>
"-children":[<br>
{ "Coordinate":<br>
{<br>
"@USE":"FrustumCoordinate"<br>
}<br>
}<br>
]<br>
},<br>
{<br>
"@name":"FrustumExtrusion",<br>
"@accessType":"initializeOnly",<br>
"@type":"SFNode",<br>
"-children":[<br>
{ "Extrusion":<br>
{<br>
"@USE":"FrustumExtrusion"<br>
}<br>
}<br>
]<br>
},<br>
{<br>
"@name":"recompute",<br>
"@accessType":"inputOnly",<br>
"@type":"SFBool"<br>
},<br>
{<br>
"@name":"aspectRatio",<br>
"@accessType":"inputOutput",<br>
"@appinfo":"assumed ratio height/width",<br>
"@type":"SFFloat"<br>
},<br>
{<br>
"@name":"position_changed",<br>
"@accessType":"outputOnly",<br>
"@type":"SFVec3f"<br>
},<br>
{<br>
"@name":"orientation_changed",<br>
"@accessType":"outputOnly",<br>
"@type":"SFRotation"<br>
},<br>
{<br>
"@name":"spine_changed",<br>
"@accessType":"outputOnly",<br>
"@type":"MFVec3f"<br>
},<br>
{<br>
"@name":"scale_changed",<br>
"@accessType":"outputOnly",<br>
"@type":"MFVec2f"<br>
},<br>
{<br>
"@name":"point_changed",<br>
"@accessType":"outputOnly",<br>
"@type":"MFVec3f"<br>
},<br>
{<br>
"@name":"trace",<br>
"@accessType":"initializeOnly",<br>
"@type":"SFBool"<br>
}<br>
],<br>
"IS": {<br>
"connect": [<br>
{<br>
"@nodeField":"visible",<br>
"@protoField":"visible"<br>
},<br>
{<br>
"@nodeField":"ViewpointNode",<br>
"@protoField":"ViewpointNode"<br>
},<br>
{<br>
"@nodeField":"NavigationInfoNode",<br>
"@protoField":"NavigationInfoNode"<br>
},<br>
{<br>
"@nodeField":"aspectRatio",<br>
"@protoField":"aspectRatio"<br>
},<br>
{<br>
"@nodeField":"trace",<br>
"@protoField":"trace"<br>
}<br>
]<br>
}<br>
}<br>
},<br>
{ "ROUTE":<br>
{<br>
"@fromField":"visibilitySwitchSelection",<br>
"@fromNode":"GeometryComputationScript",<br>
"@toField":"whichChoice",<br>
"@toNode":"VisibilitySwitch"<br>
}<br>
},<br>
{ "ROUTE":<br>
{<br>
"@fromField":"position_changed",<br>
"@fromNode":"GeometryComputationScript",<br>
"@toField":"translation",<br>
"@toNode":"PositionTransform"<br>
}<br>
},<br>
{ "ROUTE":<br>
{<br>
"@fromField":"orientation_changed",<br>
"@fromNode":"GeometryComputationScript",<br>
"@toField":"rotation",<br>
"@toNode":"OrientationTransform"<br>
}<br>
},<br>
{ "ROUTE":<br>
{<br>
"@fromField":"spine_changed",<br>
"@fromNode":"GeometryComputationScript",<br>
"@toField":"set_spine",<br>
"@toNode":"FrustumExtrusion"<br>
}<br>
},<br>
{ "ROUTE":<br>
{<br>
"@fromField":"scale_changed",<br>
"@fromNode":"GeometryComputationScript",<br>
"@toField":"set_scale",<br>
"@toNode":"FrustumExtrusion"<br>
}<br>
},<br>
{ "ROUTE":<br>
{<br>
"@fromField":"point_changed",<br>
"@fromNode":"GeometryComputationScript",<br>
"@toField":"point",<br>
"@toNode":"FrustumCoordinate"<br>
}<br>
}<br>
]<br>
}<br>
On 1/26/2020 1:30 PM, Andreas Plesch wrote:<br>
> It was the xsl processor which had the problem, not the stylesheet.<br>
> <br>
> <a href="http://xsltransform.net/" rel="noreferrer" target="_blank">http://xsltransform.net/</a><br>
> <br>
> uses saxon 9 he and generates error-free and hopefully correct json.<br>
> <br>
> -Andreas<br>
> <br>
> On Sun, Jan 26, 2020 at 4:09 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>> wrote:<br>
>><br>
>> I was looking for a relatively easy way to convert from xml to the<br>
>> json encoding, using Don's xslt stylesheet<br>
>> (<a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJson.xslt#l26" rel="noreferrer" target="_blank">https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJson.xslt#l26</a>).<br>
>> After a while I found<br>
>><br>
>> <a href="https://xslttest.appspot.com/" rel="noreferrer" target="_blank">https://xslttest.appspot.com/</a><br>
>><br>
>> which seems to work pretty well but had some problem with Protos<br>
>><br>
>> Here is a test conversion of an old vrml scene:<br>
>><br>
>> <a href="https://gist.github.com/andreasplesch/4fb27cb9f3db9ee423066ae74d4aaae1" rel="noreferrer" target="_blank">https://gist.github.com/andreasplesch/4fb27cb9f3db9ee423066ae74d4aaae1</a><br>
>><br>
>> converted to xml with view3dscene.<br>
>><br>
>> The json has "-IllegalChildNodeFieldNameNotFound" in ProtoBodies.<br>
>> Could that be a result of insufficient capabilities of the xsl<br>
>> processor ? It says it supports XSLT 2.0.<br>
>><br>
>> Andreas<br>
>><br>
>><br>
>> --<br>
>> Andreas Plesch<br>
>> Waltham, MA 02453<br>
<br>
<br>
all the best, Don<br>
-- <br>
Don Brutzman Naval Postgraduate School, Code USW/Br <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149<br>
X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
<br>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div></div>