[x3d-public] JSON encoding long line split in HelloWorldProgramOutput.java
Brutzman, Donald (Don) (CIV)
brutzman at nps.edu
Mon Jul 3 10:46:22 PDT 2023
Hi John. Trying to understand. I think you are saying that your .json output has unexpected newline characters.
I am not finding unexpected newlines in any of the following versions of that file:
* Published version at
* https://www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.json
* Version control at
* https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.json
* Locally built copy (attached)
The X3dToJson.xslt stylesheet source includes a warning about this:
<!-- saxon9he problem: fails due to line length, licensing issue: saxon:line-length="10000" -->
<!-- https://stackoverflow.com/questions/23084785/xslt-avoid-new-line-added-between-element-attributes/43301327#43301327 -->
<xsl:output method="text" encoding="UTF-8"/> <!-- output methods: xml html text -->
Which further refers to
* Saxon documentation, Serialization parameters
* https://www.saxonica.com/documentation12/index.html#!extensions/output-extras/serialization-parameters
saxon:line-length
integer
Default value 80. With the XML output method, attributes are output on a new line if they would otherwise extend beyond this column position. With the HTML output method, text lines are split at this line length when possible.
saxon:newline
string
Default value 10. Defines the string that is used by the text output method to represent a newline. The Windows line ending x0Dx0A (CRLF) may sometimes be preferred to the default of a single newline character, this can be specified using saxon:newline="
".
As inspection of stylesheet directory shows, I’m not using either these parameters. Current committed build is saxon-he-12.1.jar
Recommend that you look at your saxon version and invocation.
all the best, Don
--
Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149
X3D graphics, virtual worlds, navy robotics https://faculty.nps.edu/brutzman
From: John Carlson <yottzumm at gmail.com>
Sent: Monday, July 3, 2023 8:31 AM
To: Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>; X3D Graphics public mailing list <x3d-public at web3d.org>
Subject: Re: JSON encoding long line split in HelloWorldProgramOutput.java
I'm working on temporarily patching HelloWorldProgramOutput.json to make it so I can create Java from it. I know how to patch the java (Don, see below enclosed--previous message). I am now trying to repair the JSON I use to create it. Note that the Java I produce does not have two sets of @value diffs, probably because the JSON parser:
import javax.json.JsonObject;
dropped one with the same property name, as previously discussed. I suggest passing your JSON through jsonlint and diff, as this command does:
$ jsonlint C:/x3d-code/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.json <http://www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.json> | diff - ../../../data/HelloWorldProgramOutput.json
[snipped output, if you want evidence, mail me privately]
diff ../../../data/HelloWorldProgramOutput.json /c/x3d-code/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.json <http://www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.json>
103c103
< "@content":"1 July 2023"
---
> "@content":"3 July 2023"
226c226
< "@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in ..."]
---
> "@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
1482c1482
< "@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in ..."]
---
> "@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
2691c2691
< }
---
> }
\ No newline at end of file
On Mon, Jul 3, 2023 at 9:29 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com> > wrote:
There's no HelloHelloWorldProgramOutput.java in the java/examples folder?
I see the problem with the MetataString setValue method call:
---Original
203,204c203
< .addMetadata(new MetadataString("scene.addChildMetadata").setName("test").setValue(new String[] {"Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON
< encoding"}))
---Fixed
> .addMetadata(new MetadataString("scene.addChildMetadata").setName("test").setValue(new String[] {"Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"}))
Unquoted newlines are not allowed in Java. Search for the JSON at the end of the line, then join the two lines. Corrected source code is attached.
I'm not sure why Saxon??? is chopping the line in two. I will research other versions of Saxon. Maybe there was a change to X3dToJava.xslt>
Thanks!
John
c:/x3d-code/www.web3d.org/x3d/stylesheets/java/examples <http://www.web3d.org/x3d/stylesheets/java/examples>
$ ls -ltr *class *java
-rw-r--r-- 1 john 197121 285815 Jul 2 01:49 CleatClamp.class
-rw-r--r-- 1 john 197121 195539 Jul 2 01:49 CleatClamp.java
-rw-r--r-- 1 john 197121 114112 Jul 2 01:49 HelloWorldProgram.java
-rw-r--r-- 1 john 197121 36474 Jul 2 01:49 HelloWorldProgramOutput.class
-rw-r--r-- 1 john 197121 11911 Jul 2 01:49 flowers4.class
-rw-r--r-- 1 john 197121 69291 Jul 3 05:17 HelloWorldProgram.class
c:/x3d-code/www.web3d.org/x3d/stylesheets/java/examples <http://www.web3d.org/x3d/stylesheets/java/examples>
$ svn up .
Updating '.':
At revision 35199.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230703/b639047b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloWorldProgramOutput.json
Type: application/json
Size: 94303 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230703/b639047b/attachment-0001.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5464 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230703/b639047b/attachment-0001.p7s>
More information about the x3d-public
mailing list