<div dir="auto">You are awesome, Andreas! Awk would not have been my choice, but apparently, you made it work! Perhaps I will make a Perl script based on your awk. A python script could be written to process X3DUOM and probably do the matching as well.</div><div dir="auto"><br></div><div dir="auto">Dang cool!</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 1, 2023 at 9:24 AM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com">andreasplesch@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A quick update:<br>
<br>
On Tue, Oct 31, 2023 at 3:49 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>> wrote:<br>
><br>
> Notes:<br>
><br>
> x3d.py is autogenerated from X3DUOM:<br>
><br>
> <a href="https://www.web3d.org/x3d/stylesheets/python/python.html#autogeneration" rel="noreferrer" target="_blank">https://www.web3d.org/x3d/stylesheets/python/python.html#autogeneration</a><br>
> <a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3duomToX3dPythonPackage.xslt" rel="noreferrer" target="_blank">https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3duomToX3dPythonPackage.xslt</a><br>
><br>
> X3DUOM has all necessary containerField default value information.<br>
><br>
> But the first step may be to modify the stylesheet to generate<br>
> containerField attributes for all nodes, for simplicity. It looks like<br>
> the .XML() function would have to have an additional parameter 'field'<br>
> X3D(indentLevel, syntax, field) for each node.<br>
><br>
> Postprocessing the generated XML is not possible since information was<br>
> irretrievably lost. But postprocessing the autogenerated x3d.py python<br>
> code may be possible since xslt is not for everyone.<br>
<br>
As a proof of concept I hacked a short awk (since I know it) script to<br>
process the latest x3d.py to include containerField support:<br>
<br>
<a href="https://github.com/andreasplesch/x3d-python-mod/blob/main/src/cfXML.awk" rel="noreferrer" target="_blank">https://github.com/andreasplesch/x3d-python-mod/blob/main/src/cfXML.awk</a><br>
<br>
It looks for the Concrete Nodes section, adds a field parameter to the<br>
.XML() output function, adds the containerField attribute to the<br>
output, and adds the field parameter to the .XML() calls for metadata,<br>
SFNode and MFNode field processing.<br>
The awk script is very brittle since it relies on comments in x3d.py<br>
to find the appropriate lines to modify. The hardest part was to get<br>
the quoting and escaping correct.<br>
It generates containerField attributes for all SF/MFNode fields except<br>
'children'. Of course, most are unnecessary but filtering<br>
systematically for defaults would probably require involving X3DUOM<br>
and the generation stylesheet, similar to other XML related 'fields'<br>
such as style or class.<br>
<br>
The result is <a href="https://raw.githubusercontent.com/andreasplesch/x3d-python-mod/main/x3dcf.py" rel="noreferrer" target="_blank">https://raw.githubusercontent.com/andreasplesch/x3d-python-mod/main/x3dcf.py</a><br>
<br>
The modified python script appears to work as expected by adding the<br>
appropriate containerField attributes in XML output for all the<br>
examples I tried.<br>
Realistically, this is as far as I can go with this but I think it may<br>
show how containerField support in XML output could be provided with<br>
x3d.py.<br>
<br>
-Andreas<br>
</blockquote></div></div>