[x3d-public] X3DJSAIL JSON loader (yes!)

John Carlson yottzumm at gmail.com
Wed May 20 22:02:13 PDT 2020


This is a long, but good read.

Indeed, here is a copy of the Java version of the JavaScript previously
sent.  If someone can take over this whole JSON -> DOM/XML conversion
process in Java (including net/coderextreme/X3DJSONLD.java--perhaps
incorporate it into the X3DJSAIL generation process, or a utils folder), it
would be appreciated, so I can keep primary focus on Node.js, ES6+, JSON,
and Nashorn.

https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/src/net/coderextreme/JsonConversion.java

If someone wants me to write a JSON -> X3DJSAIL converter instead of a JSON
-> Document -> X3DJSAIL converter, let me know, maybe we can work something
out...like you supporting creating the XSLT for XML -> ES6, and
updating X3dToES5.xslt and X3dToNodeJS.xslt (yes I realize we don't want to
run this on all the archives without careful appraisal. I suggest using
non-.js filenames.  We could use .mjs (module-based ecmascript) as a
possible extension for the ES6 archive files.

Perhaps it would be worth a meeting to introduce some features of ES6
(modules, import/export classes, setters, getters)?  I don't really have a
firm grip on it yet, but I can point in a general direction, since I've got
some working code (displays a cube in a Jupyter notebook.)  One important
strange thing is, you have to be in a module to call a module.

I'd like to get a feel how important SAI is for X3DOM, and whether X3DOM
users desire a standard SAI?  Also, people coming from the X3D browsers to
web browsers...can they or do they want to use X_ITE instead of X3DOM?

Do we need two implementations of ECMAScript SAI to qualify it as a
standard?  Would it be best to target what we have from X_ITE and the draft
in our XSLT coding, or branch out in a new direction with ES6?

Could ES6 inform us how to implement the ProtoExpander better?  If we have
a class environment, do we need a ProtoExpander environment?   Can we
convert Prototypes to JavaScript instead of clinging to XML and JSON?

Thanks,

John

On Wed, May 20, 2020 at 8:29 PM John Carlson <yottzumm at gmail.com> wrote:

> Note that that this feature is built entirely from the X3D sourceforge
> repository, that is, it's provided independent of X3DJSONLD (note that the
> main class is titled X3DJSONLD.java -- it's a pure java port of
> X3DJSONLD.js, and any shared code between X3DJSAIL and X3DJSONLD is for
> backup or testing reasons.
>
> On Wed, May 20, 2020 at 8:21 PM John Carlson <yottzumm at gmail.com> wrote:
>
>> https://www.web3d.org/specifications/java/X3DJSAIL.html
>>
>> say .json import/file load is TODO.
>>
>> Here is a sample Node.js file which shows the feature, and the Nashorn
>> has a similar example.
>>
>> var java = require('java');
>> var autoclass = require ('./X3Dautoclass');
>> var X3DJSONLD = java.import("net.coderextreme.X3DJSONLD")
>> var loader = new X3DJSONLD();
>> var File = java.import("java.io.File")
>> var jsobj = loader.readJsonFileSync(new
>> File("./examples/HelloWorldProgramOutput.json"));
>> var document = loader.loadJsonIntoDocumentSync(jsobj);
>> console.log(loader.serializeDOMSync(loader.getX3DVersionSync(jsobj),
>> document));
>> var X3DLoaderDOM = java.import("org.web3d.x3d.jsail.X3DLoaderDOM")
>> var xmlLoader = new X3DLoaderDOM();
>> var X3D0 = xmlLoader.toX3dObjectTreeSync(document);
>> X3D0.toFileX3DSync("./examples/Json.x3d");
>> X3D0.toFileJSONSync("./examples/Json.json");
>>
>>
>> Note that this is easily converted to Java.  I've done it once, in fact.
>> All these pure Java functions (minus Sync) are available in Java code.
>>
>> This leverages a port provided to X3DJSAIL which does the JSON -> DOM
>> conversion in the X3DJSONLD.java class.
>>
>> Might I suggest that browser vendors leverage X3DJSAIL jars and openjdk
>> to support X3D JSON until a C/C++ version is complete?  Some lubrication
>> ($$) is currently required to get a C/C++ version pushed out the door (I
>> can't stand dealing with Xerces, CMake, autoconf), but last time I tried
>> it, the alpha version worked.
>>
>> John
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200521/7bb5b319/attachment-0001.html>


More information about the x3d-public mailing list