<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:360595559;
        mso-list-type:hybrid;
        mso-list-template-ids:-1136471928 -1 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I believe everything in the nashorn folder (see zip from prior message), except for examples, should be put in the X3DJSAIL jars.  Please make nashorn a top folder in the jar. Let me know when you have done so, so I can start work.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John</p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Sent: </b>Monday, December 18, 2017 4:52 AM<br><b>To: </b><a href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a>; <a href="mailto:brutzman@nps.edu">Don Brutzman</a><br><b>Subject: </b>Proceeding with calling javascript in X3DJSAIL jar (but I think weshould do it outside the jar first)</p></div><p class=MsoNormal><o:p> </o:p></p><ol style='margin-top:0in' start=1 type=1><li class=MsoNormal style='mso-list:l0 level1 lfo1'>We need to figure out if load() will work with items inside a jar. If not, we may have to put a lot of stuff in X3DJSAIL.<o:p></o:p></li><li class=MsoNormal style='mso-list:l0 level1 lfo1'>Require() can pull stuff out of the classpath, if programmed right. We should look into making sure we can load items from classpath in jvm-npm.js which implements require().  I may have removed that feature, not sure.  Download a new version with $ npm install jvm-npm –save then copy jvm-npm.js out of node_modules.<o:p></o:p></li><li class=MsoNormal style='mso-list:l0 level1 lfo1'>Ideally, we can remove the script from java/build.xml and call X3DJSAIL directly. See following patch<o:p></o:p></li></ol><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>$ svn diff CreateX3dSceneAccessInterfaceJava.xslt<o:p></o:p></p><p class=MsoNormal>Index: CreateX3dSceneAccessInterfaceJava.xslt<o:p></o:p></p><p class=MsoNormal>===================================================================<o:p></o:p></p><p class=MsoNormal>--- CreateX3dSceneAccessInterfaceJava.xslt      (revision 26074)<o:p></o:p></p><p class=MsoNormal>+++ CreateX3dSceneAccessInterfaceJava.xslt      (working copy)<o:p></o:p></p><p class=MsoNormal>@@ -3736,7 +3736,7 @@<o:p></o:p></p><p class=MsoNormal>                        bufferedWriter = Files.newBufferedWriter(intermediateJSFilePath, charset);<o:p></o:p></p><p class=MsoNormal>                        String tmpStr = "load('nashorn/jvm-npm.js');\nload('nashorn/repeatPolyfill.js');\nvar xmldom = require('nashorn/node_modules/xmldom');\nvar DOMParser = xmldom.DOMParser;\nvar XMLSerializer = new xmldom.XMLSerializer();\nvar DOMImplementation = new xmldom.DOMImplementation();\n";<o:p></o:p></p><p class=MsoNormal>                        bufferedWriter.write(tmpStr, 0, tmpStr.length());<o:p></o:p></p><p class=MsoNormal>-                       tmpStr = "var json = "+outputSceneText+";\nvar version = json['X3D']['@version'];\nvar docType = DOMImplementation.createDocumentType('X3D', 'ISO//Web3D//DTD X3D '+version+'//EN', 'http://www.web3d.org/specifications/x3d-'+version+'.dtd', null);\nvar document = DOMImplementation.createDocument(null, 'X3D', docType);\nvar mapToMethod = require('nashorn/node/mapToMethod.js');\n var mapToMethod2 = require('nashorn/node/mapToMethod2.js');\n var fieldTypes = require('nashorn/node/fieldTypes.js');\n load('nashorn/node/X3DJSONLD.js');\n load('nashorn/node/JavaScriptSerializer.js');\n var child = CreateElement('X3D');\n ConvertToX3DOM(json, '', child, 'flipper.json');\n print('Returning with', child);\n var output = new JavaScriptSerializer().serializeToString(json, child, '"+outputFilePath+"', mapToMethod, fieldTypes);\n var FileWriter = Java.type('java.io.FileWriter');\n var fw = new FileWriter('"+fileName+"');\n fw.write(output);\n fw.close();\n";<o:p></o:p></p><p class=MsoNormal>+                       tmpStr = "var json = "+outputSceneText+";\nvar version = json['X3D']['@version'];\nvar docType = DOMImplementation.createDocumentType('X3D', 'ISO//Web3D//DTD X3D '+version+'//EN', 'http://www.web3d.org/specifications/x3d-'+version+'.dtd', null);\nvar document = DOMImplementation.createDocument(null, 'X3D', docType);\nvar mapToMethod = require('nashorn/node/mapToMethod.js');\n var mapToMethod2 = require('nashorn/node/mapToMethod2.js');\n var fieldTypes = require('nashorn/node/fieldTypes.js');\n load('nashorn/node/X3DJSONLD.js');\n load('nashorn/node/JavaScriptSerializer.js');\n var child = CreateElement('X3D');\n ConvertToX3DOM(json, '', child, 'flipper.json');\n print('Returning with', child);\n var output = new JavaScriptSerializer().serializeToString(json, child, '"+fileName+"', mapToMethod, fieldTypes);\n var FileWriter = Java.type('java.io.FileWriter');\n var fw = new FileWriter('"+fileName+"');\n fw.write(output);\n fw.close();\n";<o:p></o:p></p><p class=MsoNormal>                        bufferedWriter.write(tmpStr, 0, tmpStr.length());<o:p></o:p></p><p class=MsoNormal>                        bufferedWriter.close(); // ensure file writing is complete<o:p></o:p></p><p class=MsoNormal>                 }<o:p></o:p></p><p class=MsoNormal>@@ -3745,10 +3745,9 @@<o:p></o:p></p><p class=MsoNormal>                        throw new X3DException("IOException when creating intermediateJSFileName " + intermediateJSFileName +<o:p></o:p></p><p class=MsoNormal>                                ", unable to save file: " + exception);<o:p></o:p></p><p class=MsoNormal>                 }<o:p></o:p></p><p class=MsoNormal>-/*<o:p></o:p></p><p class=MsoNormal>                 try {<o:p></o:p></p><p class=MsoNormal>                        ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");<o:p></o:p></p><p class=MsoNormal>-                       engine.eval("load('"+intermediateJSFilePath+"');");<o:p></o:p></p><p class=MsoNormal>+                       engine.eval("load('"+intermediateJSFileName+"');");<o:p></o:p></p><p class=MsoNormal>                        if (ConfigurationProperties.isDeleteIntermediateFiles()) // clean up when done<o:p></o:p></p><p class=MsoNormal>                                intermediateJSFilePath.toFile().deleteOnExit();<o:p></o:p></p><p class=MsoNormal>                                           engine.eval("print('Hello World!');");<o:p></o:p></p><p class=MsoNormal>@@ -3758,7 +3757,6 @@<o:p></o:p></p><p class=MsoNormal>                        throw new X3DException(errorNotice + "ScriptException when processing fileName " + intermediateJSFilePath +<o:p></o:p></p><p class=MsoNormal>                                ", unable to save result: " + exception);<o:p></o:p></p><p class=MsoNormal>                 }<o:p></o:p></p><p class=MsoNormal>-*/<o:p></o:p></p><p class=MsoNormal>                 return outputFilePath.toFile(); // success<o:p></o:p></p><p class=MsoNormal>        }<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>