[x3d-public] Missing MetadataString in JSON (X3DJSAIL or X3dToJson.xslt).

Don Brutzman brutzman at nps.edu
Wed Jan 17 15:07:27 PST 2018


On 1/14/2018 9:44 AM, John Carlson wrote:
> Search for scene.addChildMetadataObject in HelloWorldProgramOutput.json and see that it’s not there…missing.  It’s there in Java and XML.
> [...]
> MetadataString still missing from JS outputted X3D XML (I’m hoping you get this this time, I don’t think you’ve seen it before).  Probably because it’s missing from the JSON and JS, but I haven’t investigated this time.

Wow that is a good catch and a very tricky business to sort out properly.

Wondering if you happened to notice that node missing in .json version, or was the omission revealed as part of round-trip testing/diffing?

The problem was due to a special case not considered by filtering in the X3dToJson.xslt stylesheet. It didn't recognize that default (empty, different-default value) containerField for the Metadata* nodes didn't match other "children" and so skipped over it.  This only occurred for Metadata* nodes at top level of the scene graph (i.e. child nodes of parent Scene).

So that now works.  Excerpt:
============================
"-children":[
[...]
           { "WorldInfo":
             {
               "@USE":"WorldInfoDEF"
             }
           },
           { "MetadataString":
             {
               "@name":"test",
               "@DEF":"scene.addChildMetadataObject",
               "@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
             }
           },
           { "LayerSet":
             {
               "@DEF":"scene.addChildLayerSetObjectTest"
             }
           },
============================

Alternatively we might consider assigning top-level Scene metadata nodes to a "-metadata" field.  That is perhaps more similar to other nodes, but: Scene is implicit in several encodings, -metadata fields elsewhere are SFNode, root-level Metadata* nodes should stay in sequence with other root-level nodes, and we have no need to be inventive here.

Keeping top-level Scene metadata nodes together with other top-level root nodes as "-children" seems more consistent.  This does seem to be a special case that we need to agree upon for JSON encoding, with TODO: confirm mantis, spec, tooltips and webpage are reviewed/approved/updated.

Mantis issue 1092 covers this issue extensively and notes preferred approach is to allow Metadata nodes as root nodes in Scene.  So today's improvements get us closer.  XML Schema and DTD are already aligned.
http://www.web3d.org/member-only/mantis/view.php?id=1092

Once finalized X3Dv4 specification will note X3DMetadataNodes allowed as root nodes:

	X3D Abstract Spec, 4.3.2 Root nodes
	http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/concepts.html#Rootnodes

Since scene-related metadata is becoming more and more prominent in CAD/medical design printing and scanning considerations, all simplifications for consistent use are helpful.

Improved tooltips for Scene element:
http://www.web3d.org/x3d/tooltips/X3dTooltips.html#Scene

Added note under Completed Work on documentation page. (you might want to review your section on Related Work there)
	X3D JSON Encoding
	http://www.web3d.org/x3d/stylesheets/X3dToJson.html	

For consistent method semantics, renamed addMetadata() method to addChild() in utility methods for SceneObject. (This also affected my DOM loader logic, might affect yours as well).
http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/SceneObject.html#addChild-org.web3d.x3d.sai.Core.X3DMetadataObject-

There is also now a whole bunch of trace debugging code added (and afterwards silenced) in the .xslt stylesheet, ready for helping diagnose future issues.

Thanks to Dick Puk for helpful discussions at Web3D Korea Chapter meeting in Seoul.

Smoke tests pass, changes checked in and deployed.  Have fun with X3D Metadata! :)

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



More information about the x3d-public mailing list