[x3d-public] CDATA sections not showing up in Edge. X3DJSONLD.

Leonard Daly Leonard.Daly at realism.com
Sun Apr 1 16:38:40 PDT 2018


John,

Note that in HTML (V5.2 standard - 
https://www.w3.org/TR/html52/syntax.html#cdata-sections), CDATA can only 
be used in foreign content (MATHML and SVG are explicitly mentioned). It 
use to be common practice to put CDATA around JavaScript contents; but 
all browsers that support WebGL also support JavaScript, so that would 
not be necessary.

Leonard Daly



> So it looks like:
>
> xmlDoc.createCDATASection("<sample>This is an element</sample>");
>
> is the standard way of creating a CDATA section, and this works in 
> X3DJSONLD server side.  Can we use this in Edge with the other hack to 
> get CDATA sections in place?  Or will using the HTML document variable 
> throw us off?  I guess we should be using an XML document and 
> definitely not the HTML document, eh?
>
> Looks like the way to get an XML document in the browser is:
>
> /var documentType/= 
> document.implementation.createDocumentType(/qualifiedNameStr/, 
> /publicId/, /systemId/)
> var xmlDoc = document.implementation.createDocument(/namespaceURI/, 
> /qualifiedNameStr/, /documentType/);
>
> Can anyone confirm?  I’d like to get this into X3DJSONLD GUI asap. 
> It’s already in my server side code with xmldom.
>
> Probably I’ll start working on this now. I’m not sure what putting an 
> xml document in HTML will do however, when I put it in a textarea, 
> so…help!
> Thanks,
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Sunday, April 1, 2018 8:12 AM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>; GPU Group 
> <mailto:gpugroup at gmail.com>; Don Brutzman <mailto:brutzman at nps.edu>
> *Subject: *RE: possible issue with X_ITE with 
> Edge;CDATAsectionsnotshowingupinEdge XML textareas. Problem with other 
> browsers.
>
> Loading JSON definitely prevents animation from happening in the X_ITE 
> XML text section in Edge.  That’s the CDATA section I think.  Load 
> bubs.json for example.
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Sunday, April 1, 2018 8:09 AM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>; GPU Group 
> <mailto:gpugroup at gmail.com>; Don Brutzman <mailto:brutzman at nps.edu>
> *Subject: *RE: possible issue with X_ITE with Edge; 
> CDATAsectionsnotshowingupinEdge XML textareas. Problem with other 
> browsers.
>
> Both serialized XML versions load work from URLs after adding CDATA 
> sections to XML.  Otherwise, the script isn’t run in Edge. Andreas, do 
> you have some magic for adding CDATA sections in Edge?  Thanks!
>
>
> I also replaced the < when hand editing the CDATA sections.  So 
> that may be an issue as well
>
> Attached.
>
> Getting closer.
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Sunday, April 1, 2018 7:44 AM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>; GPU Group 
> <mailto:gpugroup at gmail.com>; Don Brutzman <mailto:brutzman at nps.edu>
> *Subject: *RE: possible issue with X_ITE with Edge; CDATA 
> sectionsnotshowingupinEdge XML textareas. Problem with other browsers.
>
> 1.XML5656: Illegal qualified name character.
>
> 2.[object Error]: {description: "Unable to get property 'setup' of 
> undefined or null reference", message: "Unable to get property 'setup' 
> of undefined or null reference", number: -2146823281, stack: 
> "TypeError: Unable to get property 'setup' of undefined or null 
> reference at createX3DFromString 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:43:22971) 
> at Anonymous function 
> (https://coderextreme.net/X3DJSONLD/src/main/node/loaderJQuery.js:203:3) 
> at h 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:4:24940) 
> at c.add 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:4:25057) 
> at T 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:43:29332) 
> at t 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:43:30467) 
> at load_X_ITE_XML 
> (https://coderextreme.net/X3DJSONLD/src/main/node/loaderJQuery.js:201:2) 
> at loadXmlBrowsers 
> (https://coderextreme.net/X3DJSONLD/src/main/node/loaderJQuery.js:80:4) 
> at Anonymous function 
> (https://coderextreme.net/X3DJSONLD/src/main/node/loaderJQuery.js:289:8) 
> at Anonymous function 
> (https://coderextreme.net/X3DJSONLD/src/main/node/loaderJQuery.js:437:3)"}
>
> Still having an issue or two with createX3DFromString in Edge, but 
> either the initial XML load works, or the XML -> My JSON -> XML 
> conversion works, but the JSON -> XML conversion does not work.  The 
> JSON load (of Don’s JSON) does not produces a good XML string for 
> createX3DFromString or something.  I will verify, but there’s no issue 
> loading JSON with importJS that I can tell—it’s the best at loading 
> 😊. Or URLs work too. Don’s XML is attached as don.txt and my XML is 
> attached as john.txt.  So I think the don.txt is failing.  I will test 
> them as URLs.
>
> However the file doesn’t load in the other browsers besides web 
> browser, and I’m wondering why.  I think it’s because coordIndex 
> cannot be initialized from a script, or the MFVec3f constructor ☹ Can 
> some tell me how to add an SFVec3f to an MFVec3f in the general case?  
> Should I add the SFVec3f to MFVec3f after creating it by doing a push()?
>
> Other vendors, let me know.  Attached is the file.  I now believe the 
> JSON file produces the above error
>
>
> I’m thinking the standard may not be flexible enough for 
> non-declarative graphics, which is unfortunate—but I didn’t look at MF 
> field methods in general.
>
> Doug, also see if you can get this file working in FreeWRL.
>
>
> I do recall an older version of this file working with other browsers, 
> so I know it’s possible!
>
> Thanks,
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Sunday, April 1, 2018 6:05 AM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>
> *Subject: *RE: possible issue with X_ITE with Edge; CDATA sections 
> notshowingupinEdge XML textareas.
>
> The color has been fixed by changing the type from SFVec3f to SFColor 
> (whew).
>
> https://coderextreme.net/X3DJSONLD/src/main/html/x_ite.xhtml
>
> Thanks!
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Sunday, April 1, 2018 5:51 AM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>
> *Subject: *RE: possible issue with X_ITE with Edge; CDATA sections not 
> showingupinEdge XML textareas.
>
> The only issue now is the color of the ProtoInstances (passed as 
> parameters to the Protos) in the XML.  I will put into a URL and test.
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Sunday, April 1, 2018 5:04 AM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>
> *Subject: *RE: possible issue with X_ITE with Edge; CDATA sections not 
> showingup inEdge XML textareas.
>
> More info.  When I load flowers2.x3d XML without converted JSON -> XML 
> (comment out call to updateFromJson()).
>
> 1.XML Parser Error: Couldn't create IS reference: Field 'diffuseColor' 
> and 'diffuseColor' in PROTO have different types.
>
> x_ite.min.js (17,13252) 
> <https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js>
>
> 2.XML Parser Error: Couldn't create IS reference: Field 
> 'specularColor' and 'specularColor' in PROTO have different types.
>
> x_ite.min.js (17,13252) 
> <https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js>
>
> 3.XML Parser Error: Unknown named or imported node 'Clock'.
>
> x_ite.min.js (17,15070) 
> <https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js>
>
> 4.XML Parser Error: Unknown named or imported node 'OrbitPath'.
>
> The display comes up in X_ITE XML with no color and no animation.
>
> So likely there’s a problem with my XML and CDATA.  But I think the 
> JSON may be okay (the conversion from JSON -> XML), at least for JSON 
> parsing and X3DOM.
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for 
> Windows 10
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Saturday, March 31, 2018 4:02 PM
> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>; 
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>; Andreas Plesch 
> <mailto:andreasplesch at gmail.com>
> *Subject: *possible issue with X_ITE with Edge; CDATA sections not 
> showing up inEdge XML textareas.
>
> Holger, Andreas, files converted JSON -> XML in Chrome and Firefox 
> have CDATA sections, but Edge doesn’t have CDATA sections when looking 
> at serialized XML text, from my several time look.   We need a better 
> hack below in X3DJSONLD for Edge, I think, but investigate below:
>
> function CDATACreateFunction(document, element, str) {
>
>         var y = str.replace(/\\"/g, "\\\"")
>
>                 .replace(/</g, "<")
>
>                 .replace(/>/g, ">")
>
>                 .replace(/&/g, "&");
>
>         do {
>
>                 str = y;
>
>                 y = str.replace(/'([^'\r\n]*)\n([^']*)'/g, "'$1\\n$2'");
>
>                 if (str !== y) {
>
>                         // console.error("CDATA Replacing",str,"with",y);
>
>                 }
>
>         } while (y != str);
>
>  var domParser = new DOMParser();
>
>         var cdataStr = '<script> <![CDATA[ ' + y + ' ]]> </script>'; 
> // has to be wrapped into an element
>
>         var scriptDoc = domParser .parseFromString (cdataStr, 
> 'application/xml');
>
>         var cdata = scriptDoc .children[0] .childNodes[1]; // space 
> after script is childNode[0]
>
>         element .appendChild(cdata);
>
> }
>
> Holger, there may be an issue with:
>
> browser.replaceWorld(browser.createX3DFromString(content)); // where 
> content is XML
>
> in the Edge browser for X_ITE.  No problems with Chrome or Firefox in 
> that regard.
>
> This is with 4.1.5.
>
> You can see it online here: 
> https://coderextreme.net/X3DJSONLD/src/main/html/index.html
>
> Select ../data/flowers2.json from the upper left selection (this is 
> converted to XML (not DOM, although I could) and loaded into X_ITE).  
> If you paste flowers2.x3d into the XML section, you might see that the 
> flowers aren’t colored, but black and white for some reason 
> (PROTOs?).  Note that you may have to reload because failed 
> replaceWorlds will freeze the canvas, I think.
>
> Also ../data/force.json has no animation with Edge and the XML 
> version.  I feel this may be the CDATA above, but it also may be due 
> to an initializeOnly field on an Extrusion (spine).
>
> These errors may be due to initializeOnly fields (modifying Extrusion 
> spline, IFS coordIndexes) which aren’t tested with browser.importJS??? 
> (not sure—may want to check).  Note that X3DJSAIL does not validate 
> flowers2.json (converted to flowers2.java), so likely there’s an issue 
> with that file.  I’m also getting XML5656: Illegal qualified name 
> character. And [object Error]: {description: "Unable to get property 
> 'setup' of undefined or null reference", message: "Unable to get 
> property 'setup' of undefined or null reference", number: -2146823281, 
> stack: "TypeError: Unable to get property 'setup' of undefined or null 
> reference at createX3DFromString 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:43:22971) 
> at Anonymous function 
> (http://localhost:3000/node/loaderJQuery.js:204:3) at h 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:4:24940) 
> at c.add 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:4:25057) 
> at T 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:43:29332) 
> at t 
> (https://cdn.rawgit.com/create3000/x_ite/4.1.5/dist/x_ite.min.js:43:30467) 
> at load_X_ITE_XML (http://localhost:3000/node/loaderJQuery.js:202:2) 
> at loadXmlBrowsers (http://localhost:3000/node/loaderJQuery.js:80:4) 
> at Anonymous function 
> (http://localhost:3000/node/loaderJQuery.js:290:8) at Anonymous 
> function (http://localhost:3000/node/loaderJQuery.js:438:3)"}
>
> Again, all this is working fine in Chrome and Firefox as far as I 
> know. Well X3DOM isn’t currently working in Chrome. Sigh!
>
> Thanks,
>
> John
>
>
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org


-- 
*Leonard Daly*
3D Systems & Cloud Consultant
LA ACM SIGGRAPH Past Chair
President, Daly Realism - /Creating the Future/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180401/99cff358/attachment-0001.html>


More information about the x3d-public mailing list