[x3d-public] X3DJSAIL progress report: quoteescapinig, nodevalidation, .jsonimprovements, containerField handling

yottzumm at gmail.com yottzumm at gmail.com
Mon Mar 20 23:47:21 PDT 2017


Google is my friend.  Here is how to run it from Java now:

                                        net.sf.saxon.Transform.main(new String[] {

                                                                "-warnings:recover",
                                                                "-o:"+out,
                                                                "-s:"+args[a],
                                                                "-xsl:X3dToJson.xslt" });

Found:

http://www.saxonica.com/documentation9.5/using-xsl/commandline.html

I am not sure why they couldn’t make it backwards compatible.  Perhaps on purpose.

John

Sent from Mail for Windows 10

From: yottzumm at gmail.com
Sent: Tuesday, March 21, 2017 2:41 AM
To: Don Brutzman
Cc: X3D Graphics public mailing list; Roy Walmsley
Subject: RE: X3DJSAIL progress report: quoteescapinig,nodevalidation,.jsonimprovements, containerField handling

Attached is full RunSaxon.java source code.  I’m puzzled, and I think there’s a difference in how you call it.  I will check X3DJSAIL.

John

Sent from Mail for Windows 10

From: yottzumm at gmail.com
Sent: Tuesday, March 21, 2017 2:32 AM
To: Don Brutzman
Cc: X3D Graphics public mailing list; Roy Walmsley
Subject: RE: X3DJSAIL progress report: quote escapinig,nodevalidation,.jsonimprovements, containerField handling

The saxon9he.jar works on some X3D files.  On others, my code reports:

Command line option -o requires a value
FATAL C:/x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/TreeFishPlaque.x3d > www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/TreeFishPlaque.json
There is no escape! 2

Is there some requirement for the output to start with C:/… or something like that?

John

Sent from Mail for Windows 10

From: yottzumm at gmail.com
Sent: Tuesday, March 21, 2017 2:12 AM
To: Don Brutzman
Cc: X3D Graphics public mailing list; Roy Walmsley
Subject: RE: X3DJSAIL progress report: quote escapinig, nodevalidation,.jsonimprovements, containerField handling

Comments embedded.

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Tuesday, March 21, 2017 1:16 AM
To: yottzumm at gmail.com
Cc: X3D Graphics public mailing list; Roy Walmsley
Subject: Re: X3DJSAIL progress report: quote escapinig, node validation,.jsonimprovements, containerField handling

On 3/20/2017 5:59 PM, yottzumm at gmail.com wrote:
> Is there some configuration setting for quoting in the X3dToJson.xslt stylesheet?

No, it should be explicit with no variations.

If you want to check for parameters and default settings in the future, here is parameter list at top of that stylesheet:

<xsl:stylesheet version="2.0" exclude-result-prefixes="ds saxon"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
                 xmlns:saxon="http://icl.com/saxon" saxon:trace="no">
     <!--
                 xmlns="http://www.w3.org/TR/xhtml1/strict"
                 xmlns:fn="http://www.w3.org/2005/xpath-functions" -->
                 
     <xsl:param name="stripComments"><xsl:text>false</xsl:text></xsl:param>
     <xsl:param name="stripDefaultAttributes"><xsl:text>true</xsl:text></xsl:param>
     <xsl:param name="indentEnabled"><xsl:text>true</xsl:text></xsl:param>
     <xsl:param name="sourceText"><xsl:text>strings</xsl:text></xsl:param> <!-- escaped | strings | plaintext -->
     <xsl:param name="traceEnabled" ><xsl:text>false</xsl:text></xsl:param>
     <xsl:param name="traceScripts" ><xsl:text>false</xsl:text></xsl:param>
                <!-- TODO future feature: whether to apply changes to meta references, url file extensions, etc. -->
     <xsl:param name="updateContent" ><xsl:text>false</xsl:text></xsl:param>

>   See differences between text.json and text.new.json (Search for string starting with Node.

I think that the conversion from XML .x3d to .json has to backslash-escape the contained \ and " characters independently.

In other words, \ becomes \\ and " becomes \"

Yes, but what does \" become  \\\" or \"?  What do I do for the Java?  You would think I have an extra \ or something.


Hence for examples

                http://www.web3d.org/specifications/java/X3DJSAIL.html#Examples
                http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d
                http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.json

you find the following correspondence:

<MetadataString name='escapedQuotesTest1' containerField='value' value='"escaped quotation marks example 1: He said, \"Immel did it!\""'/>

{ "MetadataString":
   {
                "@name":"escapedQuotesTest1",
                "@value":["escaped quotation marks example 1: He said, \\\"Immel did it!\\\""]
   }
},

Of course, escaping is especially important in <Text> nodes, where the author might want quote marks in the X3D string that the user sees.

Not sure whatever it was we had before, but it would seem this is the correct answer now.  Hope you will agree.

Good to confirm: can you round-trip the .json back to .x3d XML?


That’s text.x3d.new.  It’s WAY different.  Looks like

<Text containerField="geometry" string=""Node\\\"\\\"\\\""">

Please check text.java for correctness.  I’m not too sure about all this…  Seems like one X3dToJson.xslt run (text.x3d -> text.json) should be the same as another (text.json.intermediate.x3d -> text.new.json).  I can regen if you think it’s best.  The two X3D files are nearly identical.  Is it possible I am using two different style sheets?  text.json was translated today.

I figured it out.  I am using two different versions of the XSLT stylesheet jar.  One must be wrong.  Which is it?  RunSaxon.java (same as x3d resource examples I think) uses saxon9B.jar which is old.  So the original text.json is incorrect?  Please check.  Seems like I’m going to have to upgrade RunSaxon.java to the latest release (which do you recommend?).  How would I translate this Java code to the new form?

                                        net.sf.saxon.Transform.main(new String[] {

                                                                "-warnings:recover",
                                                                "-o",
                                                                out,
                                                                args[a],
                                                                "X3dToJson.xslt" });

I think we have a major conflict within one stylesheet vendor, or between stylesheet vendors.  Help!

I use:

ConfigurationProperties.setXsltEngine(ConfigurationProperties.XSLT_ENGINE_nativeJava);

In my Java to generate JSON.  What do you recommend?  I think we need to file a bug report with someone!  Please text all my X3D files for conversion to JSON with various stylesheet jar vendors!

John



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


More information about the x3d-public mailing list