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

Holger Seelig holger.seelig at yahoo.de
Sat Dec 12 11:48:03 PST 2015


> <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


-- 
Holger Seelig
Mediengestalter Digital – Digital Media Designer

Scheffelstraße 31a
04277 Leipzig
Germany

Cellular: +49 1577 147 26 11
E-Mail:   holger.seelig at yahoo.de
Web:      http://titania.create3000.de

Future to the fantasy ★ ★



More information about the x3d-public mailing list