[x3d-public] Replacing USE with DEF

John Carlson yottzumm at gmail.com
Fri Mar 27 22:26:56 PDT 2026


I get that USE *may* reduce complexity, but here I am dealing with DEF/USE
being out of order because people want me to comply with a vendor lock-in
of field ordering.  Plus they’re capable of dealing with complex recursive
data structures and algorithms, user interfaces and stumble at a
map/object?  Is that an XSLT issue?

Please Google “How to implement a map or object in Saxon?” And figure out
the best way to use it.

Consider:

<xsl:variable name="updatedMap" select="map:put($myMap, 'newKey',
'newValue')"/>

Apparently, maps are immutable??, so you have to create a new one to
update.  Maybe ask Saxonica for a mutable map?

I don’t understand why you would want to work  with XSLT, again.  Let’s
look at the stylesheet to Java converter some more, perhaps.  If you don’t
like programming, that’s totally understandable.   That’s often where AI
can help advanced people.  That’s pretty much how I created the converter.

I don’t think you need a map in Saxon, though, Python/Java should work ok.

Just implement a DEF/USE to node reference lookup map and be done with it.
You can look up the unique node’s DEF/USE by calling node.getDEF() or
node.getUSE().  They should be the same value.  If there’s no entry in the
map when outputting, put out DEF, and put an entry in the map, if there’s
an entry, then output a USE instead of a map.  If you need to include a
namespace in the map, create a namespaces to DEF/USE lookup map map.

https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/util/HashMap.html

Maybe add a reference count if you’re worried about reclaiming memory.  If
the reference count goes to zero, remove the entry in the DEF/USE map.
Create a tiny object to hold the reference count and the node reference,
and put that in the DEF/USEmap instead of the node reference alone.

I can map out the Java code if you like:

public Node get(String namespace, String DEFUSE) // returns Node in
namespace if DEF/USE present in namespace, otherwise null

public boolean put(String namespace, String DEFUSE, Node node) //
increments count to 1, returns false if node already exists, otherwise
true, puts node in namespace at DEFUSE.

There’s probably SAI for the above.

public int getCount(String namespace, String DEFUSE) // get number of
references

public void setCount(String namespace, String DEFUSE) // set the reference
count

public void incrementCount(String namespace, String DEFUSE) // increment
reference count

public int decrementCount(String namespace, String DEFUSE) // decrement and
returns Node’s reference count. Stops at zero and nulls stored Node.

Maybe send Saxonica this specification and see what they can suggest.

John

On Fri, Mar 27, 2026 at 8:22 PM Don Brutzman <don.brutzman at gmail.com> wrote:

> It is not possible to avoid USE, it is fully integrated functionality in
> the specification.  No need to reengineer the specification.
>
> Again recommend working on one very simple case at a time, to narrow down
> each problem and fix it.  Complexity obscures diagnosis.
>
> all the best, Don
> --
> X3D Graphics, Maritime Robotics, Distributed Simulation
> Relative Motion Consulting  https://RelativeMotion.info
>
>
> On Fri, Mar 27, 2026 at 6:08 PM John Carlson via x3d-public <
> x3d-public at web3d.org> wrote:
>
>> Replacing USE with DEF would massively improve the JSON schema.   I vote
>> for that!   It would massively improve the error reporting as well.
>>
>> What does FreeWRL think?
>>
>> No need for two attributes for the same meaning.
>>
>> USE and DEF code be used interchangeably, and container fields could
>> specify parents.
>>
>> The only problem I see is when USE and DEF are used together, but that’s
>> already an issue.
>>
>> John
>>
> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20260328/de1acfa0/attachment-0001.html>


More information about the x3d-public mailing list