[x3d-public] X3JSONLD.java...serious problems with XML ecmascript output.

John Carlson yottzumm at gmail.com
Sat Dec 30 03:46:48 PST 2023


  Replace this function in X3DJSONLD.java:

      public void CDATACreateFunction(Document document, Element element,
JsonArray value) {
                // System.err.println("GOT HERE IN CDATA");
                StringBuffer sb = new StringBuffer();
                for (int i = 0; i < value.size(); i++) {
                        if (i > 0) {
                                sb.append("\n");
                        }
                        sb.append(value.get(i).toString()
                        // .replaceAll("&#xD;", "")
                        .replaceAll("^\"", "")
                        .replaceAll("\\\\t", "\t")
                        .replaceAll("\"$", "")
                        .replaceAll("<", "<")
                        .replaceAll(">", ">")
                        .replaceAll("&", "&")
                        .replaceAll(""", "\""));
                        // .replaceAll("'([^'\r\n]*)\n([^']*)'",
"'$1\\r\\n$2'")
                }
                String str = sb.toString();
                CDATASection cdata = document.createCDATASection(str);
                element.appendChild(cdata);
        }

Add this at line 72 of Validate.java:

 transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "Script");

I will check in new https://coderextreme.net/x3dschema files when testing
is complete

John
On Sat, Dec 30, 2023 at 4:49 AM John Carlson <yottzumm at gmail.com> wrote:

> When converting JSON to XML, X3DJSONLD.java does not do a complete job,
> leaving entities, escaped tabs, and quotes.
>
> I am trying to clean it up.
>
> Thanks fof your patience.
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20231230/9cf95d16/attachment.html>


More information about the x3d-public mailing list