[x3d-public] X3D JSON...what is correct mapping to JSON?

John Carlson yottzumm at gmail.com
Sat Sep 18 21:58:37 PDT 2021


       <DISEntityManager>
         <DISEntityTypeMapping/>
       </DISEntityManager>


Gets mapped to

                { "DISEntityManager":
                   {
                     "-mapping":[
                       { "DISEntityTypeMapping":
                         {
                         }
                       }
                     ]
                   }
                 }

With X3dToJson.xslt, running a Saxon HE 10.5 engine.


Processed by X3DJSONLD,js, I get:


<DISEntityManager><DISEntityTypeMapping></DISEntityTypeMapping>
</DISEntityManager>


Then converted to JavaSerializer.js, I get:


          .addChild(new DISEntityManager()
             .addChild(new DISEntityTypeMapping()))))      ;

Converted to JavaScript (my serializer) as:

           .addChild((new autoclass.DISEntityManager())
             .addChild((new autoclass.DISEntityTypeMapping())))))      ;

Run the Java program to produce differences between input JSON and 
output JSON of:


diff Json.json Json.new.json
427c427
<                               "#comment":"alternative Java source: 
.setString(new String [] {\"One, Two, Comment\", \"\", \"He said, 
\\\"\"Immel did it!\\\"\"\"})"
---
 >                               "#comment":"alternative Java source: 
.setString(new String [] {\"One, Two, Comment\", \"\", \"He said, 
\\\"\"\"Immel did it!\\\"\"\"\"})"

I believe this has been reported, but right now, the balls in my court 
still.


I think what's going on is the containerField=mapping is being set by ???

this is evidenced  by the following;

Json.json:                    "-mapping":[
Json.new.json:                    "-mapping":[
Json.newPrettyPrint.intermediate.x3d: <DISEntityTypeMapping 
containerField='mapping'/>
Json.new.x3d:        <DISEntityTypeMapping containerField='mapping'/>

And generated JavaScript from X3dToNodeJS.xslt like:

       .addChild((new autoclass.DISEntityManager())
         .setMapping((new autoclass.DISEntityTypeMapping())))));

So what's more right? addChild or setMapping? If setMapping is right, 
can we see an implementation?

I did a bit more digging in X3DJSAIL, DISEntityManager.java


     private void handleFieldSynonyms()
     {
         String correctedContainerField;
         if (hasAncestorX3D() && 
findAncestorX3D().getVersion().startsWith("3"))
              correctedContainerField = "mapping";
         else correctedContainerField = "children";

         for (org.web3d.x3d.sai.Core.X3DNode element : children)
         {
             if (element instanceof 
org.web3d.x3d.sai.DIS.DISEntityTypeMapping)
                 ((X3DConcreteNode) 
element).setContainerFieldOverride(correctedContainerField);
         }
         }


What this means to me is I should upgrade the XML file to 4.0. That 
fixed the issue.


Very good.  I will work on upgrading x3d/stylesheeets/java/node/examples.

John





More information about the x3d-public mailing list