[x3d-public] second round of X3D JSON conversion support using X3dToJson.xslt

Herbert Stocker herbert.stocker at bitmanagement.com
Mon Mar 9 22:41:07 PDT 2015


i'm sorry for the double post. Am always requesting too much from 
computers..

Now i have converted your version of JSON encoded X3D to incorporate my 
suggestions.
It's an HTML file that shows the changed JSON text.

It also passes that to JSON.parse() in order to verify that it is valid 
JSON.
--> If it shows a line of JSON code between the two <hr> lines, that worked.

And after that it has little JavaScript code to demonstrate accessing 
the generated object tree:
It first traverses the tree to get to that one SFColor value that is 
highlighted in red.
For this it uses the JavaScript expression 
X3D.Scene[1].children[1].children[0].appearance.material.diffuseColor .

Then it extracts the meta info from the header and generates a table out 
of this.
To do so, it uses the following JavaScript:

document.write('<table border=1>');
for(var Idx in X3D.head)
{
   var Item= X3D.head[Idx];
   if(Item._type == 'meta')
   {
     document.write('<tr><td>'+ toHtml(Item.name) +'</td><td>'+ 
toHtml(Item.content) +'</td></tr>');
   }
}
document.write('</table>');

Now i try to rewrite this piece of code to match the version of JSON 
without my suggestion:

document.write('<table border=1>');
for(var Idx in X3D.head)
{
for(var Type in X3D.head[Idx])
   {
     if(Type == 'meta')
     {
       var Item= X3D.head[Idx][Type];
       document.write('<tr><td>'+ toHtml(Item.name) +'</td><td>'+ 
toHtml(Item.content) +'</td></tr>');
     }
}
}
document.write('</table>');

Additional code marked in red.
There is a whole new nested loop for this to scan.
if(*Item._type* == 'meta') becomes for(var Type in X3D.head[Idx]) { 
if(Type == 'meta') ...  }

The HTML is attached, but also online at 
http://hersto.net/MailSupport/15-03-11-X3D-JSON/demo.html,
works in Firefox and is not meant to conform to any best practice in 
HTML, it just works.

best regards,

/Herbert Stocker


/
On 10.03.2015 06:12, Herbert Stocker wrote:
> Please don't read the previous  mail, it got headings messed up,
 > argh. This is the right, complete version:
 >
 >
 >
 > Hi Don and all,
 >
 > before jumping in on this, i've read all the discussions preceding
 > this. Took me about 3 hours. One can do this only on spare time. But
 > i was happy to see how people bring good arguments, factual and
 > respectful (of course). And i would have argued into the same
 > directions, too.
 >
 > Though you say yourself that your current iteration of the encoding
 > needs investigation,
 >> Still haven't compared it to interesting design alternatives
 >> previously posted by Cecile, Yvonne, Kristian, John and others.
 >> Continued exploration should help a "best of breed" emerge, the
 >> problem space continues to shrink.
 > i would like to mention a few things that come to mind. Maybe just to

<snip>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20150310/c4744cc7/attachment-0002.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20150310/c4744cc7/attachment-0003.html>


More information about the x3d-public mailing list