[x3d-public] x3d json schema validation on x3d resources examples results

Don Brutzman brutzman at nps.edu
Sun Mar 20 12:44:55 PDT 2016


Thanks for the additional validation tests John.

On 3/19/2016 2:55 PM, John Carlson wrote:
> We’re in the home stretch in JSON parsing on the X3D JSON examples.  Most of the remaining errors are in #comments
>
> John
>
> *json-parse json Illegal escape. at 3985 [character 31 line 125] examples//Basic/development/ScriptSyntaxExample.json*
>
>
>
> Example:
>
>   "@value":["\"","quote”]
>
> \& is not valid JSON.  Try \\& <smb://&> or \"

Original results viewable in further detail at

http://www.web3d.org/x3d/content/examples/Basic/development/#ScriptSyntaxExample
http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExample.html
http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExample.x3d
http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExample.json

The source being transcribed is intentionally difficult:
<field accessType='initializeOnly' name='stringTest2' type='MFString' value='"\&quot;" "quote"'/>

Looking closely at this using X3D-Edit, I think the initial backslash before the & was incorrect.

Modified version:
<field accessType='initializeOnly' name='stringTest2' type='MFString' value='"Quote &quot; character" "More Text"'/>

translated (almost) OK as

"field": [
// ...
{
   "@name":"stringTest2",
   "@accessType":"initializeOnly",
   "@type":"MFString",
   "@value":["Quote " character","More,Text"]
},

Note how "More,Text" got a comma inserted... incorrect type match by stylesheet converter.... ouch, thought we had fixed that!

Turns out, yes we had fixed that.  Current stylesheet has correct value, I will run an X3D-Edit update on this coming week.
"@value":["Quote " character","More Text"]

Because this is a not-very-functional test scene, I will change its name to ScriptSyntaxExampleTest.x3d

So that one is fixed in scene source, no change in converter.

New results will become visible at

http://www.web3d.org/x3d/content/examples/Basic/development/#ScriptSyntaxExampleTest
http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExampleTest.html
http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExampleTest.x3d
http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExampleTest.json


> *json-parse json Expected a ',' or ']' at 2242 [character 60 line 70] examples//Basic/development/TextExamples.json*

Source is OK:
<Text string='"I don't think so" "" "he said \"Hi\""'>

Results are 3 lines with middle line blank, expected to render as follows (image asl attached)
http://www.web3d.org/x3d/content/examples/Basic/development/_viewpoints/TextExamples.x3d._VP_Default_viewpoint.png

First off, found a bug in X3D-Edit editing pane where it dropped the last quote that was intended to be included by the author.  Fixed.

> Example:
>
> "@string":["I don't think so","" \"he said \"Hi\""],
>
>
> Should be:
>
> ["I don't think so",”","he said \"Hi\”"]

looks like a good diagnosis, the middle empty SFString element isn't getting separated from the following SFString value...

Added a rule and a constraint to MFString escape-quotes recursion; fixed.  Result attached.

> *json-parse json Expected a ',' or '}' at 2474 [character 41 line 70] examples//Basic/development/UnquotedTokensNavigationInfoAndFontStyle.json*
>
> Example:
>
> { "#comment":"\\" (backslash quote) escapes a quote mark so that it is a rendered character, instead of a line terminator."
>
> }

XML source:
<!-- \" (backslash quote) escapes a quote mark so that it is a rendered character, instead of a line terminator. -->

> Should be:
>
> { "#comment":"\" (backslash quote) escapes a quote mark so that it is a rendered character, instead of a line terminator."
>
> }

agreed; added stylesheet rule to trap this case, fixed, result attached.

> Perhaps it’s because we’re in a comment

fortunately the same set of quote escaping rules is used for comment, SFString and MFString; type awareness comes to the rescue once again.

> *json-parse json Duplicate key "-ErrorChildNodeFieldNameNotFound" examples//Basic/RigidBodyPhysics/CarDemoMain.json*

Yes, this is an intentional fault. ErrorChildNodeFieldNameNotFound occurs for illegal child nodes.

I will rename this error to IllegalChildNodeFieldNameNotFound.

This scene is not expected to convert.  See test indication in source:
<meta content='Test scene includes custom Xj3D components and elements, will not validate' name='warning'/>

> Example:
>
>          "-ErrorChildNodeFieldNameNotFound":[
>
>            { "WheelSensor":
>
>              {
>
>                "@name":"Wheel-0",
>
>                "@DEF":"WHEEL"
>
>              }
>
>            }
>
>          ],
>
>          "-ErrorChildNodeFieldNameNotFound":[
>
>            { "GamepadSensor":
>
>              {
>
>                "@name":"Gamepad-0",
>
>                "@DEF":"GAMEPAD"
>
>              }
>
>            }
>
>          ]
>
>
>
> Are these valid sensors? If so, they should be handled!

not valid

> *json-parse json Illegal escape. at 9785 [character 75 line 302] examples//Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.json*

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

>   { "#comment":"alternative: Text string='\"He said, \"Immel did it!\"\"'"
>                        }
>
> \" is not valid.  Should be \\&quot <smb://&quot>; or \” maybe needs to be all matches?   This is in a comment.

OK so the comment form (not the preceding Text form) is what is causing the problem.

experimenting on the json output is a helpful way to figure out the proper result.

in this case " should be left alone, and the \ should be escaped as \\

goal result:
"#comment":"alternative: Text string='\"He said, \\"Immel did it!\\"\"'"


> *json-parse json Expected a ',' or '}' at 3240 [character 108 line 93] examples//X3dForWebAuthors/Chapter02-GeometryPrimitives/TextSpecialCharacters.json*
> *
>                  { "#comment":"quotation \" can be used as part of X3D string if escaped with backslash: \\""
>
>                  },
> Extra \ not needed (perhaps it’s because it’s in a comment?

This was a really tricky case within a tricky set of cases.  Rather than risk bad fixes to the converter, I just simplified it.  Updates attached.


OK, we we got through another set of parsing improvements.  Nevertheless recursive parsing and escaping are a very subtle business, hopefully no side effects crept in.  Will next run the full regression suite and see if everything else still runs OK.

Again thanks for identifying these tests of interest.

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 --------------
A non-text attachment was scrubbed...
Name: TextExamples.x3d._VP_Default_viewpoint.png
Type: image/png
Size: 7132 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160320/2ca5bd52/attachment-0001.png>
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.0",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.0.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"TextExamples.x3d"
          },
          {
            "@name":"description",
            "@content":"Show different text examples."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"7 April 2001"
          },
          {
            "@name":"modified",
            "@content":"20 March 2016"
          },
          {
            "@name":"warning",
            "@content":"Warning: X3D Canonicalization (C14N) will scrub alternate XML character representations."
          },
          {
            "@name":"warning",
            "@content":"Usually this source document needs to be inspected and edited using a plain-text editor in order to see the differences in these XML-equivalent text representations."
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/development/TextExamples.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 March 2016"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "Transform":
            {
              "@translation":[-3,0,0],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["I don't think so","","he said \"Hi\""],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@DEF":"testFontStyle",
                                "@justify":["MIDDLE","MIDDLE"],
                                "@size":0.8
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0.1,0.7,0.7]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "@translation":[3,0,0],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["I don't think so","","he said \"Hi\""],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@USE":"testFontStyle"
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0.1,0.7,0.7]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          }
        ]
    }
  }
}
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.0",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.0.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"UnquotedTokensNavigationInfoAndFontStyle.x3d"
          },
          {
            "@name":"description",
            "@content":"This scene tests whether enclosing \"quote marks\" can be omitted for three tokenized fields in X3D. The X3dToVrml97.xsl translator does this for FontStyle family, FontStyle justify and NavigationInfo type."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"23 January 2001"
          },
          {
            "@name":"modified",
            "@content":"3 January 2004"
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/development/UnquotedTokensNavigationInfoAndFontStyle.x3d"
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/development/UnquotedTokensNavigationInfoAndFontStyle.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 March 2016"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "#comment":"note that ordinary XML encoding of a Strings attribute is type=' \"EXAMINE\" \"ANY\"' or'"
          },
          { "Transform":
            {
              "@translation":[-5,0,0],
              "-children":[
                { "Shape":
                  {
                    "-children":[
                      { "#comment":"\" (backslash quote) escapes a quote mark so that it is a rendered character, instead of a line terminator."
                      }
                    ],
                    "-geometry":
                      { "Text":
                        {
                          "@string":["This scene tests whether enclosing\" 21 \" \"quote marks\" can be omitted for\" 22 \" three tokenized fields in X3D.\" 23 \"\" 24 \"Inspect translated VRML source to see\" 25 \"\" 26 \"NavigationInfo { \" 27 \" type [ \"EXAMINE\" \"ANY\" ]\" 28 \"}\" 29 \"FontStyle {\" 30 \" family [ \"TYPEWRITER\" \"SANS\" ]\" 31 \" justify [ \"BEGIN\" \"MIDDLE\" ]\" 32 \"}"],
                          "-children":[
                            { "#comment":"Again note that ordinary XML encoding is a variation of family=\""TYPEWRITER" SANS\" justify='\"BEGIN\" \"MIDDLE\"'"
                            }
                          ],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@family":["TYPEWRITER","SANS"],
                                "@justify":["BEGIN","MIDDLE"],
                                "@size":0.5,
                                "@style":"BOLD"
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0.1,0.7,0.6]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          }
        ]
    }
  }
}
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.2",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.2.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
        "component": [
          {
            "@name":"Geospatial",
            "@level":1
          },
          {
            "@name":"NURBS",
            "@level":2
          },
          {
            "@name":"Core",
            "@level":2
          },
          {
            "@name":"Navigation",
            "@level":1
          },
          {
            "@name":"Text",
            "@level":1
          }
        ],
        "meta": [
          {
            "@name":"title",
            "@content":"X3dHeaderPrototypeSyntaxExamples.x3d"
          },
          {
            "@name":"description",
            "@content":"X3D scene header and prototype syntax examples. This example header indicates that the content is XML encoded, follows the Interactive Profile and explicitly lists additional necessary components. The X3D header may also contain additional semantic information. Used for specification EXAMPLE excerpts in 19776:1 XML Encoding."
          },
          {
            "@name":"created",
            "@content":"14 October 2002"
          },
          {
            "@name":"modified",
            "@content":"26 November 2015"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"specificationSection",
            "@content":"X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, 4.3 XML file syntax"
          },
          {
            "@name":"specificationUrl",
            "@content":"http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#XMLFileSyntax"
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 March 2016"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "ExternProtoDeclare":
            {
              "@name":"ViewPositionOrientation",
              "@url":["../../Savage/Tools/Authoring/ViewPositionOrientationPrototype.x3d#ViewPositionOrientation","https://savage.nps.edu/Savage/Tools/Authoring/ViewPositionOrientationPrototype.x3d#ViewPositionOrientation","../../Savage/Tools/Authoring/ViewPositionOrientationPrototype.wrl#ViewPositionOrientation","https://savage.nps.edu/Savage/Tools/Authoring/ViewPositionOrientationPrototype.wrl#ViewPositionOrientation"],
              "field": [
                {
                  "@name":"enabled",
                  "@accessType":"inputOutput",
                  "@type":"SFBool"
                },
                {
                  "@name":"traceEnabled",
                  "@accessType":"initializeOnly",
                  "@type":"SFBool"
                },
                {
                  "@name":"set_traceEnabled",
                  "@accessType":"inputOnly",
                  "@type":"SFBool"
                },
                {
                  "@name":"position_changed",
                  "@accessType":"outputOnly",
                  "@type":"SFVec3f"
                },
                {
                  "@name":"orientation_changed",
                  "@accessType":"outputOnly",
                  "@type":"SFRotation"
                },
                {
                  "@name":"outputViewpointString",
                  "@accessType":"outputOnly",
                  "@type":"MFString"
                }
              ]
            }
          },
          { "ProtoDeclare":
            {
              "@name":"NewWorldInfoNode",
              "ProtoBody": {
                  "-children":[
                    { "WorldInfo":
                      {
                        "@DEF":"ExamplePrototypeBody"
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoInstance":
            {
              "@name":"NewWorldInfoNode"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"EmissiveMaterial",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"onlyColor",
                      "@accessType":"inputOutput",
                      "@type":"SFColor",
                      "@value":[1,0,0]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "#comment":"Override default diffuseColor value 0.8 0.8 0.8"
                    },
                    { "Material":
                      {
                        "@diffuseColor":[0,0,0],
                        "-children":[
                          { "#comment":"Connect emissiveColor field of current node to onlyColor field of parent ProtoDeclare."
                          }
                        ],
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"emissiveColor",
                                "@protoField":"onlyColor"
                              }
                            ]
                        }
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoDeclare":
            {
              "@name":"ShiftGroupUp2m",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"children",
                      "@accessType":"inputOutput",
                      "@type":"MFNode",
                      "-children":[
                        { "Group":
                          {
                            "@DEF":"DefaultNodeValue",
                            "@bboxSize":[2,2,2],
                            "-children":[
                              { "#comment":"Authors need to override this node when creating the ProtoInstance fieldValue name=\"children\""
                              }
                            ]
                          }
                        }
                      ]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Transform":
                      {
                        "@translation":[0,2,0],
                        "-children":[
                          { "Group":
                            {
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"children",
                                      "@protoField":"children"
                                    }
                                  ]
                              }
                            }
                          }
                        ]
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoInstance":
            {
              "@name":"ShiftGroupUp2m"
            }
          },
          { "#comment":"===================="
          },
          { "Viewpoint":
            {
              "@DEF":"ExampleSingleElement",
              "@description":"Hello syntax"
            }
          },
          { "Group":
            {
              "@DEF":"ExampleChildElement",
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Box":
                        {
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0.6,0.4,0.2]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "@DEF":"TransformExampleUSE",
              "@rotation":[0,1,0,0.78],
              "@translation":[0,2.5,0],
              "-children":[
                { "Group":
                  {
                    "@USE":"ExampleChildElement"
                  }
                }
              ]
            }
          },
          { "Collision":
            {
              "-proxy":
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["He said, \"Immel did it!\""]
                        }
                      },
                    "-children":[
                      { "#comment":"alternative: Text string='\"He said, \\quot;Immel did it!\\quot;\"'"
                      }
                    ],
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                              }
                            }
                        }
                      }
                  }
                },
              "-children":[
                { "Group":
                  {
                    "@USE":"ExampleChildElement"
                  }
                }
              ]
            }
          },
          { "Transform":
            {
              "@translation":[0,-2.5,0],
              "-children":[
                { "Shape":
                  {
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "ProtoInstance":
                              {
                                "@name":"EmissiveMaterial",
                                "fieldValue": [
                                  {
                                    "@name":"onlyColor",
                                    "@value":[0.2,0.6,0.6]
                                  }
                                ]
                              }
                            }
                        }
                      },
                    "-geometry":
                      { "Text":
                        {
                          "@string":["X3D Header Prototype syntax examples","(view console for EXTERNPROTO output)"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"],
                                "@size":0.6
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          },
          { "ProtoInstance":
            {
              "@name":"ViewPositionOrientation",
              "fieldValue": [
                {
                  "@name":"enabled",
                  "@value":true
                }
              ]
            }
          },
          { "TimeSensor":
            {
              "@DEF":"Clock",
              "@cycleInterval":4,
              "@loop":true
            }
          },
          { "OrientationInterpolator":
            {
              "@DEF":"Spinner",
              "@key":[0,0.5,1],
              "@keyValue":[0,1,0,0,0,1,0,3.14159,0,1,0,6.28318]
            }
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"set_fraction",
              "@toNode":"Spinner"
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"Spinner",
              "@toField":"rotation",
              "@toNode":"TransformExampleUSE"
            }
          },
          { "Inline":
            {
              "@DEF":"someInline",
              "@url":["someUrl.x3d","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/someUrl.x3d"]
            }
          },
          { "PositionInterpolator":
            {
              "@DEF":"StayInPlace",
              "@key":[0,1],
              "@keyValue":[0,0,0,0,0,0]
            }
          },
          { "ROUTE":
            {
              "@fromField":"fraction_changed",
              "@fromNode":"Clock",
              "@toField":"set_fraction",
              "@toNode":"StayInPlace"
            }
          },
          { "ROUTE":
            {
              "@fromField":"value_changed",
              "@fromNode":"StayInPlace",
              "@toField":"set_translation",
              "@toNode":"someInlineRoot"
            }
          }
        ],
        "IMPORT": [
          {
            "@AS":"someInlineRoot",
            "@importedDEF":"someName",
            "@inlineDEF":"someInline"
          }
        ]
    }
  }
}
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.0",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.0.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"ScriptSyntaxExampleTest.x3d"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"8 January 2000"
          },
          {
            "@name":"modified",
            "@content":"20 March 2016"
          },
          {
            "@name":"description",
            "@content":"Script node syntax example, testing sample values of various types with simple escaping of apostrophe and quotation mark characters, with results shown on Browser console output."
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExampleTest.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit, http://www.web3d.org/x3d/content/README.X3D-Edit.txt"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 March 2016"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "Script":
            {
              "@DEF":"myScript",
              "@url":["NoSuchScript1.js","http://www.web3d.org/x3d/content/examples/Basic/development/NoSuchScript2.class.ignore"],
              "field": [
                {
                  "@name":"someSFBool",
                  "@accessType":"inputOnly",
                  "@type":"SFBool"
                },
                {
                  "@name":"someMFInt32",
                  "@accessType":"outputOnly",
                  "@type":"MFInt32"
                },
                {
                  "@name":"someMFFloats",
                  "@accessType":"initializeOnly",
                  "@type":"MFFloat",
                  "@value":[0.0,1.0,2.0]
                },
                {
                  "@name":"someStringField",
                  "@accessType":"initializeOnly",
                  "@type":"SFString",
                  "@value":"hello"
                },
                {
                  "@name":"stringTest1",
                  "@accessType":"initializeOnly",
                  "@type":"MFString",
                  "@value":["'","apostrophe"]
                },
                {
                  "@name":"stringTest2",
                  "@accessType":"initializeOnly",
                  "@type":"MFString",
                  "@value":["Quote " character","More Text"]
                },
                {
                  "@name":"someInitializedRotation",
                  "@accessType":"initializeOnly",
                  "@type":"SFRotation",
                  "@value":[0,1,0,0]
                },
                {
                  "@name":"someInitializedTime",
                  "@accessType":"initializeOnly",
                  "@type":"SFTime",
                  "@value":0
                }
              ],
              "#sourceText":[
"ecmascript:",
"",
"// Preferred style for inlined script code is contained CDATA",
"// in order to simplify use of characters < > \" \" ' ' etc. in source code",
"",
"// When inlined script code appears in url instead, XML special characters",
"// must be carefully 'escaped' or an incorrect translation will result.",
"",
"// url appears before contained code when translating to VRML encoding,",
"// so that external (possibly updated) code scripts can take precedence",
"",
"function someSFBool (value, timestamp)",
"{",
"\tBrowser.println ('someSFBool input event=' + value);",
"\tsomeMFInt32 = 0; // set outputOnly event, for example",
"}",
"function initialize (value)",
"{",
"\tBrowser.println ('    someMFFloats=' + someMFFloats);",
"\tBrowser.println ('someStringField=' + someStringField);",
"\tBrowser.println ('    stringTest1=' + stringTest1);",
"\tBrowser.println ('    stringTest2=' + stringTest2);",
"}"
]
            }
          },
          { "Anchor":
            {
              "@description":"Select text to view source documentation",
              "@url":["ScriptSyntaxExampleTest.html","http://www.web3d.org/x3d/content/examples/Basic/development/ScriptSyntaxExampleTest.html"],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["Script node syntax example,","Select this text to view source"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"]
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0.7,0.4,0.1]
                              }
                            }
                        }
                      }
                  }
                },
                { "#comment":"selectable Text to show Anchor description"
                },
                { "Shape":
                  {
                    "-geometry":
                      { "Box":
                        {
                          "@size":[11,2,0.001]
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@transparency":1
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          }
        ]
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScriptSyntaxExampleTest.x3d
Type: model/x3d+xml
Size: 3560 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160320/2ca5bd52/attachment-0002.x3d>
-------------- next part --------------
{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"TextSpecialCharacters.x3d"
          },
          {
            "@name":"description",
            "@content":"Text node demonstration of quotation, apostrophe, ampersand and backslash characters using X3D MFString escaping for XML character entities"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"12 July 2008"
          },
          {
            "@name":"modified",
            "@content":"2 October 2011"
          },
          {
            "@name":"reference",
            "@content":"Character entity references in HTML 4"
          },
          {
            "@name":"reference",
            "@content":"http://www.w3.org/TR/REC-html40/sgml/entities.html"
          },
          {
            "@name":"rights",
            "@content":"Copyright (c) Don Brutzman and Leonard Daly, 2008"
          },
          {
            "@name":"identifier",
            "@content":"http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter02-GeometryPrimitives/TextSpecialCharacters.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"20 March 2016"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"warning",
            "@content":"An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "Background":
            {
              "@skyColor":[1,1,1]
            }
          },
          { "Viewpoint":
            {
              "@description":"Default View",
              "@position":[0,0,15]
            }
          },
          { "Shape":
            {
              "-children":[
                { "#comment":"Empty string \"\" means to skip a line"
                },
                { "#comment":"The ampersand escape characters are based on XML rules"
                },
                { "#comment":"apostrophe ' is ' and needs to be escaped in single-quote delimiters used for string='value' attribute"
                },
                { "#comment":"ampersand & is & and needs to be escaped"
                },
                { "#comment":"quotation \" is " and isn't needed if single-quote delimiters used for string='value' attribute"
                },
                { "#comment":"quotation \" can be used as part of X3D string if escaped with backslash: \""
                },
                { "#comment":"backslash is used as escape character for \" (and itself) in X3D"
                },
                { "#comment":"character entities are listed in HTML specification and are good for any XML"
                }
              ],
              "-geometry":
                { "Text":
                  {
                    "@DEF":"DefaultText",
                    "@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"],
                    "-fontStyle":
                      { "FontStyle":
                        {
                          "@DEF":"CenteredFontStyle",
                          "@justify":["MIDDLE","MIDDLE"]
                        }
                      }
                  }
                },
              "-appearance":
                { "Appearance":
                  {
                    "-material":
                      { "Material":
                        {
                          "@DEF":"DefaultMaterial",
                          "@diffuseColor":[0.2,0.2,0.2]
                        }
                      }
                  }
                }
            }
          }
        ]
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextSpecialCharacters.x3d
Type: model/x3d+xml
Size: 2704 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160320/2ca5bd52/attachment-0003.x3d>


More information about the x3d-public mailing list