[x3d-public] X3DJSAIL progress report: quote escapinig, node validation, .json improvements, containerField handling

Don Brutzman brutzman at nps.edu
Sun Mar 19 14:22:33 PDT 2017


Further updates now deployed:

- A  bunch of work for escaping quotes in the X3dToJson.xslt stylesheet
- Improved handling of quotation marks and escaping
- Validating acceptableNodeTypes for setting nodes

Now handling most (perhaps all?) containerField values OK.  Related documentation now available at

http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#containerField
========================================================================
X3D Scene Authoring Hints: containerField

>  For the XML encoding of .x3d scenes, containerField is the field name indicating a node's field relationship to its parent node.
>
> For example: <Transform><Shape containerField='children'/></Transform> shows that the Shape node is one of the children of the Transform node.
>
>     Default containerField values for each node are correct in most cases, so the need to override default containerField values is rare.
>     Example values include containerField='geometry' for Box node, containerField='children' for Group node, containerField='proxy' for hidden proxy shape within a Collision node, etc.
>     containerField attribute is part of XML encoding for X3D scenes, and corresponds to the always-declared field labels in the ClassicVRML and VRML97 file encodings.
>
> A small number of nodes have more than one field that can accept the same node type. Care must be taken with the following non-default child fields.
>
>     MetadataSet can have a single X3DMetadataNode node with default containerField='metadata', or multiple other X3DMetadataNode nodes with containerField='value'.
>     CADFace and CollidableShape can have a single default Shape node with containerField='shape'. CADFace can also accept an LOD or Transform node in this SFNode field.
>     Collision can contain multiple nodes with default containerField='children', or can have a single unrendered Shape, or X3DGroupingNode with containerField='proxy'.

========================================================================

Also rebuilt and uploaded all .json scenes in X3D Examples, see "Special testing distribution" at

	http://www.web3d.org/x3d/content/examples/X3dResources.html#Examples

Test excerpts follow, linked at

	X3DJSAIL Examples
	http://www.web3d.org/specifications/java/X3DJSAIL.html#Examples

http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.txt
========================================================================
<Shape>
	<Appearance>
		<Material/>
	</Appearance>
	<Text string='"X3D Java" "SAI Library" "X3DJSAIL"'>
		<MetadataSet name='EscapedQuotationMarksMetadataSet'>
			<MetadataString name='escapedQuotesTest2' value='"escaped quotation marks example 2: He said, \"Immel did it!\""'/>
		</MetadataSet>
		<FontStyle family='"SERIF"' justify='"MIDDLE" "MIDDLE"'/>
		<!-- escaped quotation marks example 3: He said, \"Immel did it!\" -->
		<!-- escaped quotation marks example 4: He said, \"Immel did it!\" -->
	</Text>
</Shape>
<Collision>
	<!-- test containerField='proxy' -->
	<Shape DEF='ProxyShape'>
		<Box/>
	</Shape>
</Collision>
========================================================================
{ "Shape":
   {
	"-appearance":
	  { "Appearance":
		{
		  "-material":
			{ "Material":
			  {
			  }
			}
		}
	  },
	"-geometry":
	  { "Text":
		{
		  "@string":["X3D Java","SAI Library","X3DJSAIL"],
		  "-metadata":
			{ "MetadataSet":
			  {
				"@name":"EscapedQuotationMarksMetadataSet",
				"-value":[
				  { "MetadataString":
					{
					  "@name":"escapedQuotesTest1",
					  "@value":["escaped quotation marks example 1: He said, \\\"Immel did it!\\\""]
					}
				  },
				  { "MetadataString":
					{
					  "@name":"escapedQuotesTest2",
					  "@value":["escaped quotation marks example 2: He said, \\\"Immel did it!\\\""]
					}
				  }
				]
			  }
			},
		  "-fontStyle":
			{ "FontStyle":
			  {
				"@justify":["MIDDLE","MIDDLE"]
			  }
			},
		  "-children":[
			{
			  "#comment":"escaped quotation marks example 3: He said, \\\"Immel did it!\\\""
			},
			{
			  "#comment":"escaped quotation marks example 4: He said, \\"Immel did it!\\""
			}
		  ]
		}
	  }
   }
},
{ "Collision":
   {
	"-children":[
	  {
		"#comment":"test containerField='proxy'"
	  }
	],
	"-proxy":
	  { "Shape":
		{
		  "@DEF":"ProxyShape",
		  "-geometry":
			{ "Box":
			  {
			  }
			}
		}
	  }
   }
},
========================================================================

On 3/13/2017 8:38 AM, Don Brutzman wrote:
> A new X3DLoaderObject is now ready that can read .x3d scenes using native Java DOM support, using Java Reflection to then create strongly typed X3DJSAIL scene objects.  Online at
>
>     X3DLoaderObject: Concrete class for loading an X3D graphics string, file or fragment encoded in XML.
>     http://www.web3d.org/specifications/java//javadoc/org/web3d/x3d/jsail/X3DLoaderObject.html
>
> with methods
>     getDomDocument() isLoadSuccessful() getValidationResult() getX3dObjectTree()
>     loadX3DfromFile(x3dFile) toStringX3D(org.w3c.dom.Node node) toX3dObjectTree(org.w3c.dom.Node node)
>
> Example result
>     https://svn.code.sf.net/p/x3d/code/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.Reloaded.x3d
>
> which is a reloaded and serialized output that exactly matches input scene
>     https://svn.code.sf.net/p/x3d/code/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.x3d
>
> This library improvement fixes a significant bug in field types, which are getting more robust.  Also add a variety of .normalize() utility methods and validation checks on negative SFTime/MFTime values.
>     http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/MFColorObject.html
>
> As ever, demonstration test source available in
>     http://www.web3d.org/specifications/java/examples/HelloWorldProgram.java
>
> Entire build online via
>     http://www.web3d.org/specifications/java/X3DJSAIL.html

Have fun with X3D Java using X3DJSAIL!  8)

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