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

John Carlson yottzumm at gmail.com
Mon Mar 19 20:16:08 PDT 2018


I’ve removed the serializer without fixing the problem, but I introduced the X3DJSAIL serializer, so who can tell?

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Monday, March 19, 2018 11:12 PM
To: x3d-public at web3d.org; Don Brutzman
Subject: X3DJSONLD Insight into Nashorn.js program outputs. Maybe you canduplicate this bug Don

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/037a65af/attachment.html>


More information about the x3d-public mailing list