[x3d-public] X3D XML Encoding lacks -explicit- support for NULL nodes

Don Brutzman brutzman at nps.edu
Sat Dec 12 19:36:22 PST 2015


Thank you so much for this very clear example.

Looks like NULL is defined in the X3D Abstract Specification under Annex 5 Field type reference:

=================================
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFNodeAndMFNode
5.3.12 SFNode and MFNode

The SFNode field specifies an X3D node. The MFNode field specifies zero or more nodes.

The default value of an uninitialized  SFNode field is NULL. The default value of an MFNode field is the empty list.
=================================

Also the Scene Authoring Interface has something to say:

=================================
http://www.web3d.org/documents/specifications/19775-2/V3.3/Part02/concepts.html#Node
4.4.8 Node

[...]
Node identifiers may also be used to represent an empty node. An empty SFNode or MFNode field value is represented by a NULL value. For empty MFNode fields, the count of available nodes shall be zero when the field value is NULL.
=================================

and
=================================
5.2.37 NULL
http://www.web3d.org/documents/specifications/19775-2/V3.3/Part02/dataRef.html#NULL

NULL represents the empty value. It contains no data or reference to any data type as a valid value to return from a service when nothing can be returned and yet no error is generated.
=================================

and
=================================
5.2.22 SAINode
http://www.web3d.org/documents/specifications/19775-2/V3.3/Part02/dataRef.html#SAINode

SAINode specifies an identifier for a node. Individual language bindings may place conditions on uniqueness allowing other methods for checking equivalent references to the same node. The node reference is not required to be part of the active scene graph.

A NULL value is a legal value for this data type. It is used to indicate that no node identifier is to be used. For example, for the Field service setValue (see 6.7.6 setValue), a value of NULL on an SFNode field type is used to clear the node that may have previously been set as the value.

The node concept is further defined in 4.4.8 Node.
=================================


Sorry but not 100% sure if the abstract specs are complete however...  Can the words above in 5.3.12, which refer to MFNode as a list, justify your example which is treating MFNode as an array?

In terms of scene definition, it is also not completely clear where NULL can appear.  Can you have a NULL node at the top of a scene - if so, how it is an uninitialized SFNode field?  How does a render cycle handle a NULL node?  What if a NULL and another peer SFNode field have the same containerField (i.e. field name) value?

We should be careful to think this through thoroughly before treating NULL as a first-class concept, rather than (perhaps) an incidental part of the ClassicVRML or SAIsyntax/nomenclature which is explicitly indicating a single empty field.

It would also be interesting to learn if other X3D players treated NULL consistently.

Simple rephrase:  your example is excellent, not yet certain if the abstract specifications support definition of NULL as completely as your example, we should make sure.


On 12/12/2015 11:48 AM, Holger Seelig wrote:
>
>> <field name='foo' accessType='initializeOnly' type='MFNode'></field>
> This does only encode an empty array.
>
>
> An example would be an tic-tac-toe game we the author would place the items in an MFNode array and leaves the not setted game fields empty by assigning a NULL node:
>
> // Very simple example, because I have tried to keep it as simple as as posible:
>
> function tictactoe (X, O)
> {
>     // Where X and O are some geometries.
>
>     var transform = Browser .currentScene .createNode ("Transform");
>     var children  = transform .children;
>
>     children [0] = X;
>     children [1] = O;
>     children [2] = null;
>
>     children [3] = null;
>     children [4] = X;
>     children [5] = O;
>
>     children [6] = null;
>     children [7] = O;
>     children [8] = X;
>
>     // How can this be encoded in XML if we say:
>
>     Browser .println (transform .toXMLString ());
> }
>
> The example above shows that it is possible to assign NULL values at any index of a MFNode field.
>
> And if a MFNode field in a Script node is used to hold the items how could it be encoded if the score was SAVED and LATER LOADED for example? To illustrate the issue I placed the NULL-tag at the corresponding places. Maybe that way:
>
> <Script name='TicTacToe'>
>     <field accessType='inputOutput' type='MFNode' name='items'>
>        <Transform USE='X'/>
>        <Transform USE='O'/>
>        <NULL/>
>
>        <NULL/>
>        <Transform USE='X'/>
>        <Transform USE='O'/>
>
>        <NULL/>
>        <Transform USE='O'/>
>        <Transform USE='X'/>
>    </field>
> </Script>
>
> In a real game there would probably be another Transform around every X and O with some translation assigned but to keep the example simple I left it away.
>
> On the other hand it is very common for me that there is a null-value in a programming language, C++ has a nullptr value, C the NULL value JavaScript has the null object and that data can be null.
>
>
>
> Am 11.12.2015 um 00:03 schrieb Don Brutzman:
>> [modified subject line for precise understanding]
>>
>> Hi Holger, interesting problem.  Can we break it down and put it back
>> together please.
>>
>> First, there is implicit support for NULL nodes in Script, ProtoDeclare,
>> and ProtoInstance declarations.  Namely, any SFNode/MFNode
>> initializations for <field></field> and <fieldValue></fieldValue> can
>> simply be left empty.
>>
>> Second, a point of information.  X3D Schematron will report a warning
>> that an SFNode/MFNode initialization is empty, but can be silenced if an
>> author puts a comment in.  Example:
>>
>> <Script name='nullExample'>
>>   <field name='nihil' accessType='initializeOnly' type='SFNode'><!--
>> intentionally NULL --></field>
>>   <!-- etc. -->
>> </Script>
>>
>> Third, XML Recommendation syntax says that empty elements are the same
>> as singleton elements.  (X3D Canonicalization C14N will deliberately
>> combine empty elements into singletons for consistency.)  Equivalent
>> examples:
>>
>>      <Transform/>
>> and
>>      <Transform><Transform/>
>>
>> Fourth, I've never seen an example like yours but imagine it might be
>> definable using ClassicVRML syntax.  Wondering, can you think of an
>> example use case where an author might need this construct?
>>
>> Fifth, also wondering if your example including <NULL/> pseudo-elements
>> is considered equivalent to the following scene subgraph?
>>
>> <Script>
>>    <field accessType='inputOutput' type='MFNode' name='matrix'>
>>       <Transform USE='A'/>
>>       <Transform USE='B'/>
>>       <Transform USE='C'/>
>>    </field>
>> </Script>
>>
>> Appreciate your diligence in exploring this issue.
>>
>>
>> On 12/10/2015 12:31 PM, Holger Seelig wrote:
>>> Rewrote the X3D XML example,
>>> And is there support for NULL nodes in JSON Encoding considered?
>>>
>>> <Script>
>>>    <field accessType='inputOutput' type='MFNode' name='matrix'>
>>>       <Transform USE='A'/>
>>>       <NULL/>
>>>       <Transform USE='B'/>
>>>       <NULL/>
>>>       <Transform USE='C'/>
>>>    </field>
>>> </Script>
>>>
>>> Am 10.12.2015 um 21:14 schrieb Holger Seelig:
>>>> The X3D XML Encoding lacks support for NULL nodes.
>>>>
>>>> Althought it is possible with X3D Classic Encoding to write:
>>>>
>>>> Script {
>>>>    inputOutput MFNode matrix [ USE A, NULL, USE B, NULL, USE C ]
>>>> }
>>>>
>>>> it is not possible to do this in X3D XML Encoding, and therefore there
>>>> should probably something like a NULL-tag <NULL>.
>>>>
>>>> <Script>
>>>>    <field accessType='inputOutput' type='MFNode' name='matrix'>
>>>>       <Script USE='A'/>
>>>>       <NULL/>
>>>>       <Script USE='B'/>
>>>>       <NULL/>
>>>>       <Script USE='C'/>
>>>>    </field>
>>>> </Script>
>>
>> all the best, Don
>
>


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