[x3d-public] MFString quoting [was: interesting sample] JSON escaping example

Don Brutzman brutzman at nps.edu
Sun May 7 19:59:29 PDT 2017


On 5/6/2017 11:26 AM, Don Brutzman wrote:
> This worked very well.  All but a handful of scenes in the X3D Examples Archives are now passing jsonlint validation.  Remaining outliers have curious content, will investigate further and fix those individually.

Actually, sorry but no it didn't.  As John and Yves pointed out, several scenes were problematic.

Thanks for pointing out the problems, very helpful.

This got through the testing sequence because some earlier modifications were dropping blocks of text, avoiding diagnosis.  Plus John is only person currently round-tripping .json encoding back to .x3d encoding.

I took another major refactoring scrub through the X3dToJson.xslt stylesheet. Too many special cases in the prior version, it is more straightforward now.

Principles:
a. Preserve original content, not any encoding artifacts.
b. No xs:string types attributes, instead only SFString/MFString according to Object Model for X3D (OM4X3D).
c. Comments are still different, and do not contain SF/MFString or XML escaping rules.
    Thus only modification to <!-- comment --> content matches the JSON string diagram:
    [\ to \\] and [" to \"] which inside a comment leads to [\" to \\\"] rather than [\" passed through].

Only escaping performed is " or \ per JSON string railroad-track diagram.
http://www.web3d.org/x3d/stylesheets/X3dToJson.html#strings
       +=============================+
       |Any UNICODE character except |
       | " or \ or control character |
       +=============================+

Six diverse simple-to-tricky examples attached, as a current snapshot.

Primary X3D Specification example is found within X3dHeaderPrototypeSyntaxExamples.x3d, .json files, excerpted here:

===============================
<Shape containerField='proxy'>
   <!-- note that Collision proxy Shape is not rendered -->
   <Text string='"He said, \"Immel did it!\""'/>
   <!-- Equivalent alternative XML syntax: <Text string='"He said, \"Immel did it!\""'/> -->
===============================
"-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!\""]
	}
   },
===============================

Hopefully no other side effects were introduced during the refactoring.  Unit testing resuming.  Given the extent of refactoring of typed attribute value handling, I wouldn't assume that anything working before is necessarily working now.

Pending execution, as before the following will go up tonite or in morning.

> Log:
> http://www.web3d.org/x3d/content/examples/build.log.json.txt
> 
> Updated creation of .json scenes have been uploaded in the public archives, also available as a .zip.
> 
>      X3D Resources: Examples
>      http://www.web3d.org/x3d/content/examples/X3dResources.html#Examples
> 
>      http://www.web3d.org/x3d/content/examples/X3dExampleArchivesJsonScenes.zip

Once again, repeating until we get this all hanging together:

> Thanks to all who helped sort out .json escaping of X3D strings (John Roy Andreas Yves + any others), just a tremendous team effort!
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 --------------
{ "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":"Text.x3d"
          },
          {
            "@name":"description",
            "@content":"Simple Text node: hello X3D!"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"25 March 2005"
          },
          {
            "@name":"modified",
            "@content":"10 January 2014"
          },
          {
            "@name":"rights",
            "@content":"Copyright (c) Don Brutzman and Leonard Daly, 2005"
          },
          {
            "@name":"identifier",
            "@content":"http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter02GeometryPrimitives/Text.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"07 May 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "Background":
            {
              "@skyColor":[1,1,1]
            }
          },
          { "Viewpoint":
            {
              "@description":"Text example",
              "@position":[0,0,3]
            }
          },
          { "Viewpoint":
            {
              "@description":"Book view",
              "@position":[0.89,-1.11,2.33]
            }
          },
          { "Shape":
            {
              "-geometry":
                { "Text":
                  {
                    "@DEF":"HelloText",
                    "@string":["hello","X3D!"],
                    "-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: Text.x3d
Type: model/x3d+xml
Size: 1414 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170507/4f3d20bb/attachment-0006.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": {
        "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":"7 May 2017"
          },
          {
            "@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":"07 May 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: 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":
                  {
                    "-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!\""]
                        }
                      },
                    "-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"]
            }
          },
          { "IMPORT":
            {
              "@AS":"someInlineRoot",
              "@importedDEF":"someName",
              "@inlineDEF":"someInline"
            }
          },
          { "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"
            }
          }
        ]
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: X3dHeaderPrototypeSyntaxExamples.x3d
Type: model/x3d+xml
Size: 6397 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170507/4f3d20bb/attachment-0007.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":"TextHaveFunWithX3D.x3d"
          },
          {
            "@name":"description",
            "@content":"Simple smiley-face example illustrating an emoticon character entity, used in an MFString Text."
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"26 April 2017"
          },
          {
            "@name":"modified",
            "@content":"26 April 2017"
          },
          {
            "@name":"Image",
            "@content":"TextHaveFunWithX3D.png"
          },
          {
            "@name":"reference",
            "@content":"http://unicode.org/emoji/charts/full-emoji-list.html"
          },
          {
            "@name":"reference",
            "@content":"https://en.wikipedia.org/wiki/Emoticons_(Unicode_block)"
          },
          {
            "@name":"reference",
            "@content":"https://en.wikipedia.org/wiki/Universal_Character_Set_characters"
          },
          {
            "@name":"reference",
            "@content":"https://www.w3.org/TR/html4/sgml/entities.html"
          },
          {
            "@name":"reference",
            "@content":"https://dev.w3.org/html5/html-author/charref"
          },
          {
            "@name":"reference",
            "@content":"https://www.w3.org/wiki/Common_HTML_entities_used_for_typography"
          },
          {
            "@name":"reference",
            "@content":"http://X3dGraphics.com"
          },
          {
            "@name":"reference",
            "@content":"http://www.web3d.org/x3d/content/examples/X3dResources.html"
          },
          {
            "@name":"rights",
            "@content":"Copyright Don Brutzman and Leonard Daly 2007"
          },
          {
            "@name":"subject",
            "@content":"emoji emoticon, X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com"
          },
          {
            "@name":"identifier",
            "@content":"http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter02GeometryPrimitives/TextHaveFunWithX3D.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"07 May 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "Background":
            {
              "@skyColor":[0.819608,0.984314,1]
            }
          },
          { "Shape":
            {
              "-children":[
                {
                  "#comment":"☺ = smiley face emoticon, and \"\" means skip a line"
                }
              ],
              "-geometry":
                { "Text":
                  {
                    "@string":["Have fun","with X3D!","",":) ☺"],
                    "-fontStyle":
                      { "FontStyle":
                        {
                          "@family":["SANS"],
                          "@justify":["MIDDLE","MIDDLE"],
                          "@style":"BOLD"
                        }
                      }
                  }
                },
              "-appearance":
                { "Appearance":
                  {
                    "-material":
                      { "Material":
                        {
                          "@ambientIntensity":0.25,
                          "@diffuseColor":[0,0.251004,0.239248],
                          "@shininess":0.06,
                          "@specularColor":[0.177935,0.249369,0.229278],
                          "-children":[
                            {
                              "#comment":"Universal Media Library: ArtDeco 19"
                            }
                          ]
                        }
                      }
                  }
                }
            }
          }
        ]
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextHaveFunWithX3D.x3d
Type: model/x3d+xml
Size: 2542 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170507/4f3d20bb/attachment-0008.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":"7 May 2017"
          },
          {
            "@name":"info",
            "@content":"See screenshot figures and various encoding conversions to note that multiple equivalences in XML character representations lead to consistent results despite slight differences in source."
          },
          {
            "@name":"reference",
            "@content":"TextSpecialCharactersScreenshotXmlSource.png"
          },
          {
            "@name":"reference",
            "@content":"TextSpecialCharactersScreenshotPrettyPrintHtml.png"
          },
          {
            "@name":"reference",
            "@content":"Character entity references in HTML 4, http://www.w3.org/TR/REC-html40/sgml/entities.html"
          },
          {
            "@name":"reference",
            "@content":"https://en.wikipedia.org/wiki/\"Hello,_World!\"_program"
          },
          {
            "@name":"rights",
            "@content":"Copyright (c) Don Brutzman and Leonard Daly, 2008"
          },
          {
            "@name":"identifier",
            "@content":"http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter02GeometryPrimitives/TextSpecialCharacters.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"07 May 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ],
        "-children":[
          {
            "#comment":"note quotes in comment and meta reference: https://en.wikipedia.org/wiki/\"Hello,_World!\"_program"
          }
        ]
    },
    "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 mark \" is " and isn't needed if single-quote delimiters used for string='value' attribute"
                },
                {
                  "#comment":"quotation mark \" character can be used within an X3D string value if escaped with backslash \\ as \\\""
                },
                {
                  "#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: 3291 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170507/4f3d20bb/attachment-0009.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":"Chopper.x3d"
          },
          {
            "@name":"description",
            "@content":"Rotor node provides animation and serves as an ExternProtoDeclare example"
          },
          {
            "@name":"creators",
            "@content":"Don Brutzman and Joe Williams"
          },
          {
            "@name":"created",
            "@content":"1 June 2002"
          },
          {
            "@name":"modified",
            "@content":"20 November 2015"
          },
          {
            "@name":"specificationSection",
            "@content":"X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, Annex C.16 Chopper"
          },
          {
            "@name":"specificationUrl",
            "@content":"http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/examples.html#Chopper"
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/Chopper.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"07 May 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "ExternProtoDeclare":
            {
              "@name":"Rotor",
              "@url":["Rotor.x3d#Rotor","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/Rotor.x3d#Rotor","Rotor.wrl#Rotor","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/Rotor.wrl#Rotor"],
              "field": [
                {
                  "@name":"rate",
                  "@accessType":"initializeOnly",
                  "@type":"SFTime"
                },
                {
                  "@name":"children",
                  "@accessType":"initializeOnly",
                  "@type":"MFNode"
                },
                {
                  "@name":"startTime",
                  "@accessType":"inputOutput",
                  "@type":"SFTime"
                },
                {
                  "@name":"stopTime",
                  "@accessType":"inputOutput",
                  "@type":"SFTime"
                }
              ]
            }
          },
          { "ProtoDeclare":
            {
              "@name":"Chopper",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"rotorSpeed",
                      "@accessType":"initializeOnly",
                      "@type":"SFTime",
                      "@value":1
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Group":
                      {
                        "-children":[
                          { "TouchSensor":
                            {
                              "@DEF":"Touch",
                              "@description":"touch to toggle rotor rotation"
                            }
                          },
                          { "Inline":
                            {
                              "@url":["ChopperBody.x3d","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ChopperBody.x3d","ChopperBody.wrl","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ChopperBody.wrl"]
                            }
                          },
                          { "ProtoInstance":
                            {
                              "@name":"Rotor",
                              "@DEF":"Top",
                              "fieldValue": [
                                {
                                  "@name":"stopTime",
                                  "@value":1
                                },
                                {
                                  "@name":"children",
                                  "-children":[
                                    { "Inline":
                                      {
                                        "@url":["ChopperRotor.x3d","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ChopperRotor.x3d","ChopperRotor.wrl","http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ChopperRotor.wrl"]
                                      }
                                    }
                                  ]
                                }
                              ],
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"rate",
                                      "@protoField":"rotorSpeed"
                                    }
                                  ]
                              }
                            }
                          }
                        ]
                      }
                    },
                    {
                      "#comment":"after first node in ProtoDeclare, remainder of nodes do not render"
                    },
                    { "Script":
                      {
                        "@DEF":"RotorScript",
                        "field": [
                          {
                            "@name":"startOrStopEngine",
                            "@accessType":"inputOnly",
                            "@type":"SFTime"
                          },
                          {
                            "@name":"startEngine",
                            "@accessType":"outputOnly",
                            "@type":"SFTime"
                          },
                          {
                            "@name":"stopEngine",
                            "@accessType":"outputOnly",
                            "@type":"SFTime"
                          },
                          {
                            "@name":"engineStarted",
                            "@accessType":"initializeOnly",
                            "@type":"SFBool",
                            "@value":false
                          }
                        ],
                        "#sourceText":[
"ecmascript:",
"",
"function startOrStopEngine(value)",
"{",
"\t// start or stop engine:",
"\tif (!engineStarted)",
"\t{",
"\t\tstartEngine = value;",
"\t\tengineStarted = true;",
"\t}",
"\telse",
"\t{",
"\t\tstopEngine = value;",
"\t\tengineStarted = false;",
"\t}",
"}"
]
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"touchTime",
                        "@fromNode":"Touch",
                        "@toField":"startOrStopEngine",
                        "@toNode":"RotorScript"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"startEngine",
                        "@fromNode":"RotorScript",
                        "@toField":"startTime",
                        "@toNode":"Top"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"stopEngine",
                        "@fromNode":"RotorScript",
                        "@toField":"stopTime",
                        "@toNode":"Top"
                      }
                    }
                  ]
              }
            }
          },
          { "Viewpoint":
            {
              "@description":"Example16",
              "@position":[0,0,5]
            }
          },
          { "Group":
            {
              "-children":[
                { "ProtoInstance":
                  {
                    "@name":"Chopper",
                    "@DEF":"MikesChopper"
                  }
                }
              ]
            }
          }
        ]
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Chopper.x3d
Type: model/x3d+xml
Size: 4007 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170507/4f3d20bb/attachment-0010.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":"Prototype.x3d"
          },
          {
            "@name":"description",
            "@content":"X3D encodings example: defining a Prototype, demonstration of IS/connect definitions."
          },
          {
            "@name":"creators",
            "@content":"Don Brutzman and Joe Williams"
          },
          {
            "@name":"created",
            "@content":"1 June 2002"
          },
          {
            "@name":"modified",
            "@content":"26 November 2015"
          },
          {
            "@name":"specificationSection",
            "@content":"X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, Annex C.4 Prototype example"
          },
          {
            "@name":"specificationUrl",
            "@content":"http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/examples.html#PrototypeExample"
          },
          {
            "@name":"identifier",
            "@content":"http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/Prototype.x3d"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"07 May 2017"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "ProtoDeclare":
            {
              "@name":"TwoColorTable",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"legColor",
                      "@accessType":"initializeOnly",
                      "@type":"SFColor",
                      "@value":[0.8,0.4,0.7]
                    },
                    {
                      "@name":"topColor",
                      "@accessType":"initializeOnly",
                      "@type":"SFColor",
                      "@value":[0.6,0.6,0.1]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Transform":
                      {
                        "-children":[
                          { "Transform":
                            {
                              "@translation":[0.0,0.6,0.0],
                              "-children":[
                                {
                                  "#comment":"table top"
                                },
                                { "Shape":
                                  {
                                    "-appearance":
                                      { "Appearance":
                                        {
                                          "-material":
                                            { "Material":
                                              {
                                                "@DEF":"TableTopMaterial",
                                                "IS": {
                                                    "connect": [
                                                      {
                                                        "@nodeField":"diffuseColor",
                                                        "@protoField":"topColor"
                                                      }
                                                    ]
                                                }
                                              }
                                            }
                                        }
                                      },
                                    "-geometry":
                                      { "Box":
                                        {
                                          "@size":[1.2,0.2,1.2]
                                        }
                                      }
                                  }
                                }
                              ]
                            }
                          },
                          { "Transform":
                            {
                              "@translation":[-0.5,0.0,-0.5],
                              "-children":[
                                {
                                  "#comment":"first table leg"
                                },
                                { "Shape":
                                  {
                                    "@DEF":"Leg",
                                    "-appearance":
                                      { "Appearance":
                                        {
                                          "-material":
                                            { "Material":
                                              {
                                                "@DEF":"LegMaterial",
                                                "@diffuseColor":[1.0,0.0,0.0],
                                                "IS": {
                                                    "connect": [
                                                      {
                                                        "@nodeField":"diffuseColor",
                                                        "@protoField":"legColor"
                                                      }
                                                    ]
                                                }
                                              }
                                            }
                                        }
                                      },
                                    "-geometry":
                                      { "Cylinder":
                                        {
                                          "@height":1.0,
                                          "@radius":0.1
                                        }
                                      }
                                  }
                                }
                              ]
                            }
                          },
                          { "Transform":
                            {
                              "@translation":[0.5,0.0,-0.5],
                              "-children":[
                                {
                                  "#comment":"another table leg"
                                },
                                { "Shape":
                                  {
                                    "@USE":"Leg"
                                  }
                                }
                              ]
                            }
                          },
                          { "Transform":
                            {
                              "@translation":[-0.5,0.0,0.5],
                              "-children":[
                                { "Shape":
                                  {
                                    "@USE":"Leg"
                                  }
                                },
                                {
                                  "#comment":"another table leg"
                                }
                              ]
                            }
                          },
                          { "Transform":
                            {
                              "@translation":[0.5,0.0,0.5],
                              "-children":[
                                { "Shape":
                                  {
                                    "@USE":"Leg"
                                  }
                                },
                                {
                                  "#comment":"another table leg"
                                }
                              ]
                            }
                          },
                          {
                            "#comment":"End of root Transform's children"
                          }
                        ]
                      }
                    },
                    {
                      "#comment":"End of root Transform"
                    }
                  ]
              }
            }
          },
          {
            "#comment":"End of prototype"
          },
          {
            "#comment":"The prototype is now defined. Although it contains a number of nodes, only the legColor and topColor fields are public. Instead of using the default legColor and topColor, this instance of the table has red legs and a green top:"
          },
          { "ProtoInstance":
            {
              "@name":"TwoColorTable",
              "fieldValue": [
                {
                  "@name":"legColor",
                  "@value":[1,0,0]
                },
                {
                  "@name":"topColor",
                  "@value":[0,1,0]
                }
              ]
            }
          },
          { "NavigationInfo":
            {
              "@type":["EXAMINE"]
            }
          },
          {
            "#comment":"Use the Examine viewer"
          }
        ]
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Prototype.x3d
Type: model/x3d+xml
Size: 3574 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170507/4f3d20bb/attachment-0011.x3d>


More information about the x3d-public mailing list