[x3d-public] X3DJSONLD Insight into Nashorn.js program outputs. Maybe you can duplicate this bug Don

John Carlson yottzumm at gmail.com
Mon Mar 19 20:12:26 PDT 2018


Nashorn code, but Java should work as well:

    var X3DJSONLD = Java.type("net.coderextreme.X3DJSONLD")
    var loader = new X3DJSONLD();
    var File = Java.type("java.io.File")
    var jsobj = loader.readJsonFile(new File("./examples/Nashorn.json"));
    var document = loader.loadJsonIntoDocument(jsobj);
    print(loader.serializeDOM(loader.getX3DVersion(jsobj), document));

Here’s how I run the program:

$ jjs -cp ../jars/X3DJSAIL.3.3.full.jar";"../classes examples/Quotes.js

from www.web3d.org/x3d/stylesheets/java/nashorn

What’s happening is the CDATA of X3D output sections is that each line is surrounded by "".  I can remove the quotes using X3DJSONLD, at least the starting and ending quotes, but I don’t know what’s adding quotes, except X3DJSONLD.java (somewhere).  Or do you have any idea where the quotes might be coming from?   The DOM serializer?  I guess it could be a configuration inside the DOM serializer.    The quotes are printed when the serialization is printed. Which may mean the document is corrupted.

    var document = loader.loadJsonIntoDocument(jsobj);

I guess tomorrow I will start stepping with the debugger.

We have near success!   Please check the Nashorn ant diffs for possible work on JavaScriptSerializer.js.    We are close!

Output XML files and input JSON are attached.   As well as an intermediate file produced by X3DJSAIL.    I don’t think that X3DJSAIL is doing this.

I have 2 placed to look right now, X3DJSONLD.java and the DOM serialization code.
Here is the DOM serialization code:

        public String serializeDOM(String x3dVersion, Document document) {
                DOMImplementationLS ls = (DOMImplementationLS)document.getImplementation();
                LSOutput output = ls.createLSOutput();
                LSSerializer ser = ls.createLSSerializer();
                ser.getDomConfig().setParameter("format-pretty-print", true);
                StringWriter writer = new StringWriter();
                output.setCharacterStream(writer);
                output.setEncoding("UTF-8");
                ser.write(document, output);
                String xml = writer.toString();
                xml = fixXML(xml, x3dVersion);
                return xml;
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180319/0f148a6d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Nashorn.json
Type: application/json
Size: 39620 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180319/0f148a6d/attachment-0001.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Nashorn.x3d
Type: application/octet-stream
Size: 21345 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180319/0f148a6d/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Nashorn0.x3d
Type: application/octet-stream
Size: 23673 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180319/0f148a6d/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NashornPrettyPrint.intermediate.x3d
Type: application/octet-stream
Size: 20907 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180319/0f148a6d/attachment-0005.obj>


More information about the x3d-public mailing list