[x3d-public] No mutable maps in Saxon; DEF/USE solution?
John Carlson
yottzumm at gmail.com
Sat Mar 28 01:59:10 PDT 2026
Correction, only first USE=‘X’, not all of them before the DEF=‘X’
https://claude.ai/share/ea29239f-adc6-4dbd-b84c-a49ba8413c83
Looks like same link?
On Sat, Mar 28, 2026 at 3:52 AM John Carlson <yottzumm at gmail.com> wrote:
> Untested XSLT 1.0 and 2.0. YMMV!
>
> Prompt:
>
> in XSLT, how do I find the first node with an attribute with a the name
> USE, but the same value as and before a node with the attribute with the
> name DEF. Swap the two nodes, then do this for all nodes that have DEF and
> USE. The nodes swapped should have the same tag.
>
> Response:
>
> This is the
> *identity-transform-with-selective-swap* if you’re not going to use AI.
>
>
> https://claude.ai/share/ea29239f-adc6-4dbd-b84c-a49ba8413c83
>
> Please test thoroughly if you’re going to use this. And use proper
> attribution, of course!
>
> Hoping that we can see something like this soon, I might try it in my
> pipeline, if no one else cares to try it. But I would have to dig into the
> guts of X3DJSAIL, and that stylesheet is super scary!
>
> John
>
> On Sat, Mar 28, 2026 at 3:28 AM John Carlson <yottzumm at gmail.com> wrote:
>
>> Finding nodes before or after a node in XSLT. Google search.
>>
>> John
>>
>>
>>
>> On Sat, Mar 28, 2026 at 3:17 AM John Carlson <yottzumm at gmail.com> wrote:
>>
>>> path() in XSLT:
>>>
>>> https://stackoverflow.com/questions/38602029/generate-xpath-from-node-using-xslt-2#:~:text=Comments,-Add%20a%20comment&text=A%20couple%20of%20points.,element%20names%20are%20context%2Dfree.
>>>
>>> Read Michael Kay’s comment before using his code….
>>>
>>> On Sat, Mar 28, 2026 at 2:59 AM John Carlson <yottzumm at gmail.com> wrote:
>>>
>>>> The issue with why there’s no DEF/USE reordering in X3DJSAIL and
>>>> X3DPSAIL apparently stems from Saxon not being able to handle mutable
>>>> maps/lookup tables. So let’s build a map per scene, but don’t build it in
>>>> the X3dTo….xslt, but as a generated XSLT map, perhaps in another file,
>>>> XSLT or not.
>>>>
>>>> Perhaps we need to write a preprocessor to map DEF/USE values to a list
>>>> of XPath expressions in a file per XML scene which allows the DEF node and
>>>> first USE node for a particular DEF value to be found with an XPath. If
>>>> the DEF node isn’t the first XPath for a given DEF/USE value, then the DEF
>>>> node is swapped with the first USE node with the same DEF value. We can
>>>> probably export this as a stylesheet per XML scene.
>>>>
>>>> Will this actually work?
>>>>
>>>> Criticism welcome!
>>>>
>>>> I’d say Don could probably whip this up really quick if he can retrieve
>>>> XPaths for all DEF and USE nodes in a scene. Maybe Vince could as well.
>>>> What implementation language do we use?
>>>>
>>>> Do PROTOs affect this?
>>>>
>>>> Sorry for all the emails today!
>>>>
>>>> I finally got outside the box as they used to say.
>>>>
>>>> John
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20260328/900e2aac/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IMG_0757.png
Type: image/png
Size: 371894 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20260328/900e2aac/attachment-0001.png>
More information about the x3d-public
mailing list