[x3d-public] Suggestions for handling CDATA in python Was: Re: x3d.py programs that compile and run.

John Carlson yottzumm at gmail.com
Sun Jan 16 06:46:31 PST 2022


Here's some JavaScript that may help convert CDATA into "sourceCode" for
python:

                        } else if (element.childNodes.hasOwnProperty(cn) &&
node.nodeType == 4) {
                                str += "\n"+element.nodeName+stack[0];
                                str +=
".setSourceCode('''"+node.nodeValue.split(/\r?\n/).map(function(x) {
                                        return x.
                                                replace(/\\/g, '\\\\').
                                                replace(/"/g, '\\"')
                                                replace(/$/g, '\\')
                                                /*
                                                .replace(/\\n/g, "\\\\n")
                                                */
                                        ;
                                        }).join('\\n\"+\n\"')+"''')\n";
                        }

Assuming you have a DOM document with CDATA sections.

John

On Sun, Jan 16, 2022 at 8:09 AM John Carlson <yottzumm at gmail.com> wrote:

> Here's a start on x3d.py programs that compile and run:
>
>  ~/X3DJSONLD/src/main/shell $ bash local.sh 2>&1 |grep
> ^...python.net.coderextreme
> ../python/net/coderextreme/data/abox.py
> ../python/net/coderextreme/data/app.py
> ../python/net/coderextreme/data/asmallbox.py
> ../python/net/coderextreme/data/asteroids.py
> ../python/net/coderextreme/data/BindingOperations.py
> ../python/net/coderextreme/data/BoxEm.py
> ../python/net/coderextreme/data/bubble.py
> ../python/net/coderextreme/data/CoordinateAxes.py
> ../python/net/coderextreme/data/HAnimModelsHandsFeet.py
> ../python/net/coderextreme/data/MyBounce.py
> ../python/net/coderextreme/data/rubik.py
> ../python/net/coderextreme/data/rubikFurnace.py
> ../python/net/coderextreme/data/rubikOnFire.py
> ../python/net/coderextreme/data/sphere.py
> ../python/net/coderextreme/data/ThreeDTexture.py
> ../python/net/coderextreme/data/ViewFrustumExample.py
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20220116/0c334b56/attachment.html>


More information about the x3d-public mailing list