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

John Carlson yottzumm at gmail.com
Sun Apr 1 07:37:37 PDT 2018


Everything is working now, I replaced Andreas’ hack with createCDATASection();

And my code is getting smaller, thank god!  I can probably remove a lot of duplicated code!

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 8:39 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch
Subject: CDATA sections not showing up in Edge. X3DJSONLD.

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 for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 8:12 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch; GPU Group; Don Brutzman
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 for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 8:09 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch; GPU Group; Don Brutzman
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 for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 7:44 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch; GPU Group; Don Brutzman
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 for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 6:05 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch
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 for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 5:51 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch
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 for Windows 10

From: John Carlson
Sent: Sunday, April 1, 2018 5:04 AM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch
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)
2. XML Parser Error: Couldn't create IS reference: Field 'specularColor' and 'specularColor' in PROTO have different types.
x_ite.min.js (17,13252)
3. XML Parser Error: Unknown named or imported node 'Clock'.
x_ite.min.js (17,15070)
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 for Windows 10

From: John Carlson
Sent: Saturday, March 31, 2018 4:02 PM
To: holger.seelig at yahoo.de; x3d-public at web3d.org; Andreas Plesch
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








-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180401/ff8ac1b1/attachment-0001.html>


More information about the x3d-public mailing list