[x3d-public] Proposal: Language-specific declarative encodings forJavaandPython, Call for research into C/C++/C#

John Carlson yottzumm at gmail.com
Wed Jul 24 13:29:12 PDT 2019


It’s pretty amazing that the python is an order of magnitude less in line count than my JavaScript serializers, particularly the JavaSerializer (484 lines).

If some whiz wants to use libraries etc, to clean up my JavaScript and Python code, have at it!

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Wednesday, July 24, 2019 3:19 PM
To: X3D Graphics public mailing list; Peitso, Loren (CIV); Don Brutzman; aono at tut.jp; Roy Walmsley; myeongwonlee at gmail.com; blhelfer at gmail.com
Subject: RE: Proposal: Language-specific declarative encodings forJavaandPython, Call for research into C/C++/C#

I found and interesting def on stackoverflow (not the marked answer). https://stackoverflow.com/questions/7684333/converting-xml-to-dictionary-using-elementtree

Here is the results it produced with HelloWorld.x3d (below).  I suggest the following changes:   arrays for MF fields and vectors, that is, we should use X3DUOM info to enhance this.

This is nearly X3D JSON except for the quotes and the arrays and children fields.

{'X3D': {'head': {'meta': [{'@content': 'HelloWorld.x3d', '@name': 'title'}, {'@content': 'Simple X3D scene example: Hello World!', '@name': 'description'}, {'@content': '30 October 2000', '@name': 'created'}, {'@content': '14 April 2017', '@name': 'modified'}, {'@content': 'Don Brutzman', '@name': 'creator'}, {'@content': 'HelloWorld.tall.png', '@name': 'Image'}, {'@content': 'http://en.wikipedia.org/wiki/Hello_world', '@name': 'reference'}, {'@content': 'https://en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program', '@name': 'reference'}, {'@content': 'https://en.wikipedia.org/wiki/"Hello,_World!"_program', '@name': 'reference'}, {'@content': 'http://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world', '@name': 'reference'}, {'@content': 'http://www.HelloWorldExample.net', '@name': 'reference'}, {'@content': 'http://www.web3D.org', '@name': 'reference'}, {'@content': 'http://www.web3d.org/realtime-3d/news/internationalization-x3d', '@name': 'reference'}, {'@content': 'http://www.web3d.org/x3d/content/examples/HelloWorld.x3d', '@name': 'reference'}, {'@content': 'http://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes', '@name': 'reference'}, {'@content': 'http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d', '@name': 'identifier'}, {'@content': 'http://www.web3d.org/x3d/content/examples/license.html', '@name': 'license'}, {'@content': 'X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit', '@name': 'generator'}, {'@content': 'HelloWorld.wrl', '@name': 'reference'}, {'@content': 'HelloWorld.x3dv', '@name': 'reference'}, {'@content': 'HelloWorld.x3db', '@name': 'reference'}, {'@content': 'HelloWorld.xhtml', '@name': 'reference'}, {'@content': 'HelloWorld.json', '@name': 'reference'}]}, 'Scene': {'WorldInfo': {'@title': 'Hello world!'}, 'Group': {'Viewpoint': {'@DEF': 'ViewUpClose', '@centerOfRotation': '0 -1 0', '@description': 'Hello world!', '@position': '0 -1 7'}, 'Transform': [{'Shape': {'Sphere': None, 'Appearance': {'Material': {'@DEF': 'MaterialLightBlue', '@diffuseColor': '0.1 0.5 1'}, 'ImageTexture': {'@DEF': 'ImageCloudlessEarth', '@url': '"earth-topo.png" "earth-topo.jpg" "earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"'}}}, '@rotation': '0 1 0 3'}, {'Shape': {'Text': {'FontStyle': {'@justify': '"MIDDLE" "MIDDLE"'}, '@DEF': 'TextMessage', '@string': '"Hello" "world!"'}, 'Appearance': {'Material': {'@USE': 'MaterialLightBlue'}}}, '@translation': '0 -2 0'}]}}, '@profile': 'Immersive', '@version': '3.3', '@{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation': 'http://www.web3d.org/specifications/x3d-3.3.xsd'}}


What else should we consider in this python dict encoding example? If python x3d SAI can produce an XML string, I can convert it to a dict for output.

The code is available from me on request.

Should we consider loading a dict instead of a DOM tree?

What can we learn from 36 lines of code that we can apply to our serializers and converters?

Thanks,

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Wednesday, July 24, 2019 2:14 PM
To: X3D Graphics public mailing list; Peitso, Loren (CIV); Don Brutzman; aono at tut.jp; Roy Walmsley; myeongwonlee at gmail.com; blhelfer at gmail.com
Subject: RE: Proposal: Language-specific declarative encodings for JavaandPython, Call for research into C/C++/C#

More thoughts.  Can the new Python API that Don is writing produce a dict?



Sent from Mail for Windows 10

From: John Carlson
Sent: Wednesday, July 24, 2019 1:04 PM
To: X3D Graphics public mailing list; Peitso, Loren (CIV); Don Brutzman; aono at tut.jp; Roy Walmsley; myeongwonlee at gmail.com; blhelfer at gmail.com
Subject: Proposal: Language-specific declarative encodings for Java andPython, Call for research into C/C++/C#

In this message, I am proposing 2 new X3D encodings, specifically Python dict and Java Object array encodings.  These provide relatively library type-free  declarative encodings in specific languages, so that authors have a choice to use their own imperative language to specify a compiled scenegraph in a declarative way without type explosion and instead of bringing in an additional non-native language like XML or JSON.   It may be possible to duplicate this feature in C,C# and C++, but that research has not been done to my knowledge. I have converted XML to Java Object arrays and back, so I know that’s feasible.  My understanding of Python dicts is that they are like JSON, so that should be doable as well.

I can generate some “Hello, World” demonstration examples if people are interested.  I will base these new encodings on my DOM (XML for Leonard’s sake) -> JSON converter, DOM2JSONSerializer.js or Python’s DOM API  (If there’s a DOM-like API),  I think, and will be placed under the “X3DLD” banner as I move to more generic loaders than JSON -> DOM.  Specifically, I want to develop loaders independent of JSON but in the same vein as JSON until the X3D JSON is standardized.
Your feedback is welcome!

Also, here is a call for research into C/C#/C++ native declarative encodings (non-SAI).

I propose that I start on the Python dict encoding first.   Should I use JavaScript or Python as a base language?  Can someone point me at Python DOM?  Thanks!

I also propose that X3DJSAIL+converters be extended to produce these 2 encodings after a Proof-of-Concept is created in JavaScript or Python.

Someone who wants to create a renderer for these encodings would be a welcome member to team.

Wishing you a SAI-free life,

John Carlson




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190724/422f6383/attachment.html>


More information about the x3d-public mailing list