[x3d-public] X3DJSAIL: Interesting exception, but it could bemyfault.Re:CommentsBlock.

John Carlson yottzumm at gmail.com
Tue May 23 20:12:34 PDT 2017


Java programs which I think produce bad JSON—not same as previous copy that I checked for accuracy.  (but the JSON could be old.  I checked the dates I think).  I am providing what I think is the original JSON, and diffs between all my JSON new and old as jsondiffs.txt.  Repository diffs are below.  You should be able to generate the output JSON by running the programs.  But check the folder where the *.new.json is going.


I was unable to double-check the attachment for X3dHeader… but it should be the right one.

Browser.json is missing a \n between embedded and between in the meta content.  In summary, it looks like trailing MFString quotes (renderable) are missing, \\\\ in Java isn’t translated to \\\\ in JSON, and \n in SFStrings are stripped.  There was something in scripts too, but that is not apparent in the diffs right now.

Good luck.  I already tried patching this. You may have to change your X3dToJava.xslt code as well.

Attached.

Differences in JSON:
-                          "@string":["I don't think so","","he said \"Hi\""],
+                          "@string":["I don't think so","","he said \"Hi"],

-                          "@string":["I don't think so","","he said \"Hi\""],
+                          "@string":["I don't think so","","he said \"Hi"],

-                    "@string":["Character entity substitutions:","empty string \"\" skips a line:","","apostrophe ' is '","ampersand & is &","quote mark \" is "","backslash \\ is X3D escape character","double backslash \\\\ is X3D backslash \\ character","Pi Π is Π XML character entity"],
+                    "@string":["Character entity substitutions:","empty string \"\" skips a line:","","apostrophe ' is '","ampersand & is &","quote mark \" is "","backslash \\ is X3D escape character","double backslash \\ is X3D backslash \\ character","Pi Π is Π XML character entity"],

-                          "@string":["He said, \"Immel did it!\""]
+                          "@string":["He said, \"Immel did it!"]

           {
             "@name":"description",
-            "@content":"a script test with embedded \n between single quotes"
+            "@content":"a script test with embedded between single quotes"
           },

-                          "@string":["Node\"\"\""],
+                          "@string":["Node\""],

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Tuesday, May 23, 2017 9:58 PM
To: Don Brutzman
Cc: X3D Graphics public mailing list
Subject: RE: X3DJSAIL: Interesting exception, but it could bemyfault.Re:CommentsBlock.



Sent from Mail for Windows 10

From: Don Brutzman
Sent: Tuesday, May 23, 2017 8:14 PM
To: John Carlson
Cc: X3D Graphics public mailing list
Subject: Re: X3DJSAIL: Interesting exception, but it could be myfault.Re:CommentsBlock.

Comments embedded in red.
On 5/22/2017 10:47 PM, John Carlson wrote:
> For example, Look at the MFStringObjects in this file.

online via

http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamplesIndex.html

==============================
.x3d
         <Text string='"He said, \"Immel did it!\""'/>
         <!-- alternative: Text string='"He said, \"Immel did it!\""' -->

.java
         .setGeometry(new TextObject().setString(new MFStringObject("\"He said, \\\"Immel did it!\\\"\"")))

         .addComments(" alternative: Text string='\"He said, \\"Immel did it!\\"\"' ")

Ideal Java (please try with XML export)
         .setGeometry(new TextObject().setString(new MFStringObject(new String [] {"He said, \"Immel did it!\""})))
==============================
.json
"-children":[
   {
                "#comment":"note that Collision proxy Shape is not rendered"
   },
   {
                "#comment":"alternative: Text string='\"He said, \\"Immel did it!\\"\"'"
   }
],
"-geometry":
   { "Text":
                {
                  "@string":["He said, \"Immel did it!\""]
                }
   },
==============================

> First off, they aren’t arrays.

For the Java, there are multiple ways to create an MFString using X3DJSAIL.  Your preference may vary.

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Text/TextObject.html#method.summary

TextObject has multiple setters for the Text @string field:

                setString(java.util.ArrayList<java.lang.String> newValue)
  
                setString(MFStringObject newValue)

                setString(SFStringObject newValue)

                TextObject          setString(java.lang.String newValue)

                TextObject          setString(java.lang.String[] newValue)

Further there are mutliple ways to create an SFStringObject and MFStringObject; 4 constructors and 6 setValue methods each.

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFStringObject.html
http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/MFStringObject.html

This flexibility makes it easy for java programmers to use whichever data structure they prefer, seldom needing to do their own data conversion (which can be error prone), with strong typing for unambiguous results.

> Secondly, they have a awful lot of \’s
> 
> John

XML .x3d: must escape quote as \"

.java:     must escape backslash as \\ and quote as \" which results in \\\"

But if your true goal is ", then it should be \”, which is exactly what you did above!

.json:     must escape quote as " as \" or \"

note that comments are a little different because they are not SF/MFStrings but just text.  So " does not require extra backslash character(s).

I think it is just fine if you are producing X3D -> .java that is a little different, as long as we get correct/consistent results.

I am not getting correct results.  That is the problem.  I will provide more data/programs.

John


> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
> 
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Tuesday, May 23, 2017 12:56 AM
> *To: *Don Brutzman <mailto:brutzman at nps.edu>
> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *Subject: *RE: X3DJSAIL: Interesting exception, but it could be my fault.Re:CommentsBlock.
> 
> Don, be sure the quotes, escapes etc in the Java generated from these files is what we want.  Also test all the way through X3DJSAIL and compare X3D output to X3D input.
> 
> 
> I gotta get something to eat.
> 
> Thanks,
> 
> John
> 
> Attached.
> 
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
> 
> *From: *Don Brutzman <mailto:brutzman at nps.edu>
> *Sent: *Monday, May 22, 2017 11:47 PM
> *To: *John Carlson <mailto:yottzumm at gmail.com>
> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *Subject: *Re: X3DJSAIL: Interesting exception, but it could be my fault. Re:CommentsBlock.
> 
> On 5/21/2017 2:01 AM, Don Brutzman wrote:
> 
>  > these are fixed but there is still a gap in the chain when nested protoypes occur.  not a CommentsBlock problem.
> 
> Those issues are now fixed.  Build report:  improved handling of ProtoInstance getNodeByDEF, getFieldType, getAccessType plus additional utility methods.
> 
> =================================================================================================================
> 
> ProtoInstance utility methods
> 
> http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/ProtoInstanceObject.html#method.summary
> 
> hasExternProtoDeclare()
> 
> Determine whether a corresponding ExternProtoDeclare with same name is connected in this scene graph.
> 
> hasProtoDeclare()
> 
> Determine whether a corresponding ProtoDeclare with same name is connected in this scene graph.
> 
> getExternProtoDeclare()
> 
> Provide corresponding ExternProtoDeclare with same name if connected in this scene graph.
> 
> getProtoDeclare()
> 
> Provide corresponding ProtoDeclare with same name if connected in this scene graph.
> 
> =================================================================================================================
> 
> As a result, test shows support is included for nested ProtoInstance nodes.  Example attached, updated X3DJSAIL deployed.
> 
> These corrections fix some "false negative" warnings on ROUTEs in the archives.  I'll rerun all Java examples tonight to clean them up.
> 
>  > On 5/20/2017 7:02 PM, John Carlson wrote:
> 
>  >> Have not triaged.  Code is attached.  And so is XML
> 
>  >>
> 
>  >> org.web3d.x3d.sai.InvalidProtoException: ExternProtoDeclare name='CameraShot' with field name='moves' cannot have any initial value (found "[org.web3d.x3d.jsail.Core.CommentsBlock at 5cb0d902]"). Instead use ProtoInstance fieldValue to override the original default ProtoDeclare field value.
> 
>  >>
> 
>  >> org.web3d.x3d.sai.InvalidProtoException: ExternProtoDeclare name='CameraShot' with field name='moves' cannot have any initial value (found "[org.web3d.x3d.jsail.Core.CommentsBlock at 5cb0d902]"). Instead use ProtoInstance fieldValue to override the original default ProtoDeclare field value.
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.ExternProtoDeclareObject.setFieldList(ExternProtoDeclareObject.java:331)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.ExternProtoDeclareObject.validate(ExternProtoDeclareObject.java:842)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.SceneObject.validate(SceneObject.java:626)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.X3DObject.validate(X3DObject.java:1880)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.X3DObject.toFileJSON(X3DObject.java:750)
> 
>  >>
> 
>  >>          at net.coderextreme.data.CameraExamples.main(CameraExamples.java:80)
> 
>  >>
> 
>  >> Exception in thread "main" org.web3d.x3d.sai.InvalidProtoException: ExternProtoDeclare name='CameraShot' with field name='moves' cannot have any initial value (found "[org.web3d.x3d.jsail.Core.CommentsBlock at 5cb0d902]"). Instead use ProtoInstance fieldValue to override the original default ProtoDeclare field value.
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.ExternProtoDeclareObject.setFieldList(ExternProtoDeclareObject.java:331)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.ExternProtoDeclareObject.validate(ExternProtoDeclareObject.java:842)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.SceneObject.validate(SceneObject.java:626)
> 
>  >>
> 
>  >>         at org.web3d.x3d.jsail.Core.X3DObject.validate(X3DObject.java:1880)
> 
>  >>
> 
>  >>          at org.web3d.x3d.jsail.Core.X3DObject.toFileJSON(X3DObject.java:750)
> 
>  >>
> 
>  >>          at net.coderextreme.data.CameraExamples.main(CameraExamples.java:80)
> 
>  >>
> 
>  >
> 
>  >
> 
>  > all the best, Don
> 
> 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 http://faculty.nps.edu/brutzman
> 


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 http://faculty.nps.edu/brutzman


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextExamples.java
Type: application/octet-stream
Size: 6746 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextSpecialCharacters.java
Type: application/octet-stream
Size: 7121 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: X3dHeaderPrototypeSyntaxExamples.java
Type: application/octet-stream
Size: 13677 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0007.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: browser.java
Type: application/octet-stream
Size: 4541 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0008.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: text.java
Type: application/octet-stream
Size: 4785 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0009.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: browser.json
Type: application/json
Size: 1918 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0005.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: text.json
Type: application/json
Size: 2449 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0006.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextExamples.json
Type: application/json
Size: 5181 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0007.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextSpecialCharacters.json
Type: application/json
Size: 4740 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0008.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: X3dHeaderPrototypeSyntaxExamples.json
Type: application/json
Size: 14184 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0009.json>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: jsondiffs.txt
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170523/a0973fa0/attachment-0001.txt>


More information about the x3d-public mailing list