[x3d-public] Can you make X3dToJson.xslt work with this file? multiple \"\"\"

Don Brutzman brutzman at nps.edu
Sat May 20 16:30:23 PDT 2017


On 5/19/2017 1:37 PM, John Carlson wrote:
> Thanks.  Version of X3dToJson.xslt is attached.  I am thinking \"\"\&quot might be something to match.

Thanks for the stylesheet effort.  I kept the parts that strip html tags and x3dom's specialized <X3D> attributes, we can continue on that another day.

The other parts for MFString recurision I wasn't really able to use.  The existing logic is quite complex/subtle, adding another branch would have been very hard to debug/maintain.  Instead used the debugging traces and improved the existing logic.  This is especially tricky because first you have to get through escape-backslash-characters-recurse template before continuing with escape-quote-characters-recurse template.

Took some doing but I got your special example to work, apparently without breaking anything else.  X3D for Advanced Modeling passes, others are in progress.

for your text.x3d example:

	<Text string='"Node\"\"\""'>

becomes
	"@string":["Node\"\"\""],

as expected.

I then tried to handle adjacent SFString values in an MFString list without intervening whitespace.

can handle typical

	<Text DEF='TextMessage' string='"Hello" "world!"'>
or
	<Text DEF='TextMessage' string='"Hello" "" "world!"'>

but not
	<Text DEF='TextMessage' string='"Hello""world!"'>
or
	<Text DEF='TextMessage' string='"Hello""""world!"'>

need to think about context-free parsing a bit more.  not yet sure how to get there from here.  that special case will require more work, perhaps another day.

X3dToJson.xslt changes checked in, will update json .zip tonight.

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: text.x3d
Type: model/x3d+xml
Size: 1263 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170520/c5e89888/attachment.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":"creator",
            "@content":"John W Carlson"
          },
          {
            "@name":"created",
            "@content":"December 13 2015"
          },
          {
            "@name":"title",
            "@content":"text.x3d"
          },
          {
            "@name":"identifier",
            "@content":"https://coderextreme.net/X3DJSONLD/text.x3d"
          },
          {
            "@name":"description",
            "@content":"test text"
          },
          {
            "@name":"generator",
            "@content":"Vim, X3D-Edit, https://savage.nps.edu/X3D-Edit"
          },
          {
            "@name":"translated",
            "@content":"20 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":[
          { "Transform":
            {
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["Node\"\"\""],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"],
                                "@size":5
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[0,0,1]
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          }
        ]
    }
  }
}


More information about the x3d-public mailing list