[x3d-public] X3DJSAIL: Interesting exception, butitcouldbemyfault.Re:CommentsBlock.

John Carlson yottzumm at gmail.com
Wed May 24 03:28:44 PDT 2017


Ah, I am calling setValue on the field with an MFString String value (not object).  What to do? You told me what to do before.  I will look at your code.

I think the X3DJSAIL stylesheet will be okay with my patches (except we need to deal with how to clean up an MFString setValue, I think, now that the old quote cleanup code is commented out and I installed a new version with my patch.  I will undo that part of the patch and see what happens…).  Again, please test my Java code I sent a few messages back against your X3DJSAIL, and check the intermediate XML output.  I am thinking that my Java would be the first thing a  normal Java programmer would attempt and be surprised at the results in the XML.  Here’s my style with Scripts (probably needs to be documented).  I also have to deal with how the server-side of X3DJSONLD does not process URLs and the client-side does.  Hmm

Java:
"                   Browser.print('DUDES\\n'+'\"DUDETTES');\n"+
Json:
"\t\t    Browser.print('DUDES\n'+'\"DUDETTES');",
XML:
                Browser.print('DUDES\n'+'"DUDETTES');

Also let me know if my idea is so hairbrained, it will be impossible to deal with.

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Wednesday, May 24, 2017 2:05 AM
To: Don Brutzman; Roy Walmsley
Subject: RE: X3DJSAIL: Interesting exception, butitcouldbemyfault.Re:CommentsBlock.

Here also is the intermediate XML with the problem from X3DJSAIL.  I will get final XML in a second, but I have not been testing Nashorn, just Java.  This is why the problem is with X3DJSAIL (my version, this problem didn’t appear before my patches ☹).  We need to generate final XML or intermediate XML and compare to original.  I don’t believe X3dToJson.xslt is the problem, because I’m generating the JSON input to my Java serializer with X3dToJson.xslt, and it checks out.  So it’s either X3DJSAIL, or the way I am encoding strings in Java, which you can check out too.

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Wednesday, May 24, 2017 1:55 AM
To: Don Brutzman; Roy Walmsley
Subject: RE: X3DJSAIL: Interesting exception, but itcouldbemyfault.Re:CommentsBlock.

This one is better, but has a problem with MFStrings in Script field values.  I am attaching the Java code, the stylesheet and the original JSON and the new JSON.  Search for frontUrls and look at the end of the MFString.  I cannot send to X3D-public because the stylesheet file is too large, but if you like, I can send a diff there.  Plus I’ll send the XML so you can try with your own code.

John

Sent from Mail for Windows 10

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

Here’s an untested stylesheet with the diffs which you can test with my Java code which I just sent.  I will have to do a build and retest my code.  Will do.  I cannot test against your code because your code does not produce output.  You will have to test.

John

Here are the diffs between the stylesheets as well:


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.

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!\\"\"' ")

==============================
.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 \\\"

.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.


> 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/20170524/98f3c9a6/attachment-0001.html>


More information about the x3d-public mailing list