[x3d-public] Is https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.json valid?

John Carlson yottzumm at gmail.com
Fri Jun 30 23:22:24 PDT 2023


I'm not too worried about JSON schema, I just want to make sure that the
X3D JSON is right, per the X3D4 standard architecture, with my own
eyeballs. I may just have a misunderstanding of the following Shape
standard.  I don't see a value field, just a metadata field.  I realize
value may be otherwise specified, but it's not in X3D tooltips either,
under Shape.

https://www.web3d.org/documents/specifications/19775-1/V4.0/Part01/components/shape.html#Shape

I'm not seeing that Shape has a value field, but I'm not too clear on
whether containerField equal to "metadata" or "value" should be used on
MetadataXxx statements in Shape and Text nodes in JSON.  It's highly
possible that I'm totally misunderstanding.

I understand that both -value and @value are likely possible at some point!

Here are my diffs to the HelloWorldProgramOutput.json to make it pass:

--- a/src/main/data/HelloWorldProgramOutput.json
+++ b/src/main/data/HelloWorldProgramOutput.json
@@ -156,7 +156,7 @@
           },
           {
             "@name":"translated",
-            "@content":"29 June 2023"
+            "@content":"30 June 2023"
           },
           {
             "@name":"generator",
@@ -950,15 +950,14 @@
               "-children":[
                 { "Shape":
                   {
-                    "-value":[
+                    "-metadata":
                       { "MetadataString":
                         {
                           "@name":"findThisNameValue",
                           "@DEF":"FindableMetadataStringTest",
                           "@value":["test case"]
                         }
-                      }
-                    ],
+                      },
                     "-appearance":
                       { "Appearance":
                         {
@@ -2206,15 +2205,14 @@
               "-children":[
                 { "Shape":
                   {
-                    "-value":[
+                    "-metadata":
                       { "MetadataString":
                         {
                           "@name":"findThisNameValue",
                           "@DEF":"FindableMetadataStringTest",
                           "@value":["test case"]
                         }
-                      }
-                    ],
+                      },
                     "-appearance":
                       { "Appearance":
                         {

Here's the diff to XML I have locally to make the JSON pass. See the blue
containerField.

diff --git a/src/main/data/HelloWorldProgramOutput.x3d
b/src/main/data/HelloWorldProgramOutput.x3d
index 99b309451..0d47bfed3 100644
--- a/src/main/data/HelloWorldProgramOutput.x3d
+++ b/src/main/data/HelloWorldProgramOutput.x3d
@@ -246,7 +246,7 @@ function clockTrigger (timeValue)
     <!-- Test success: declarative statement createDeclarativeShapeTests()
-->
     <Group DEF='DeclarativeGroupExample'>
       <Shape>
-        <MetadataString DEF='FindableMetadataStringTest'
name='findThisNameValue' value='"test case"'/>
+        <MetadataString DEF='FindableMetadataStringTest'
containerField='metadata'
name='findThisNameValue' value='"test case"'/>
         <Appearance DEF='DeclarativeAppearanceExample'>
           <!-- DeclarativeMaterialExample gets overridden by subsequently
added MaterialModulator ProtoInstance -->
           <ProtoInstance DEF='MyMaterialModulator'
name='MaterialModulator' containerField='material'/>



Thanks for a second set of eyeballs on this.

My guess is that X3DJSAIL is not reporting a containerField when it
should,  to produce a processable HelloWorldProgramOutput.x3d  that will
produce good JSON.  I do not have intermediate code right now.

So actually, it has nothing to do with JSON and everything to do with
X3DJSAIL XML output.  But yeah, if you want to fix it in X3DJSAIL instead
of X3dToJson.xslt, that would probably be easier, and very cool.

John

On Sat, Jul 1, 2023 at 12:28 AM Brutzman, Donald (Don) (CIV) <
brutzman at nps.edu> wrote:

> Hi John.  All of the JSON that you find is produced by our X3dToJson.xslt
> stylesheet, which hopefully meets all patterns we derived and documented at
>
>
>
>    - X3D to JSON Stylesheet Converter
>    - https://www.web3d.org/x3d/stylesheets/X3dToJson.html
>
>
>
> Well-formed JSON can be checked.  All of our online examples have a link
> to check via JSONLint, though tonight it is saying “unable to connect”
> (while providing plenty of advertising).
>
>
>
>    - X3D Example Archives: X3D4WA, X3D for Web Authors, Chapter 01
>    Technical Overview, Hello World
>    -
>    https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorldIndex.html
>    - upper-right inset box of links: .json
>    <https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.json>
>     (check
>    <https://jsonlint.com/?json=https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.json>
>    )
>    -
>    https://jsonlint.com/?json=https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.json
>
>
>
> If there are mistakes in our X3D .xml -> .json pattern or the conversion
> stylesheet, they can be fixed.
>
>
>
> Strict JSON validation isn’t possible until a JSON Schema is approved.  If
> you think that there is a Java-based implementation of the draft JSON
> Schema that is mature and stable enough to deserve our time, we can try
> adding that to our various build tools for X3D Example Archives and
> X3DJSAIL.
>
>
>
>    - http://json-schema.org
>
>
>
> 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:* Friday, June 30, 2023 8:24 PM
> *To:* Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>
> *Cc:* X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject:* Is
> https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.json
> valid?
>
>
>
> Don, if
>
>
>
>
> https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.json
>
>
>
> is supposed to be valid X3D JSON, please inform me.  Thanks!
>
>
>
> To ensure that -value is not a field of Shape in JSON, I have added the
> following exception in x3djsonld.py.
>
>
>
>
>
>         if parent in ("Text", "Shape") and key in ("value"):  # don't
> have value yet, sorry
>
>             # do value later
>
>             raise "-value not a supported field of Text or Shape, try
> -metadata?"
>
>             continue
>
>
>
> I can revert the code if necessary.  I'm trying to follow the standard as
> I see it.
>
>
>
> If -value under Shape is correct, then X3DJSAIL needs to support addValue
> (as I have it in Java) or setValue.  That's my opinion.
>
>
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230701/b64b778f/attachment.html>


More information about the x3d-public mailing list