<div dir="auto">That’s a pretty good idea, Vince. I’d prefer Python over XSLT though.</div><div dir="auto"><br></div><div dir="auto">I hope we can address critical issues before cosmetic ones.</div><div dir="auto"><br></div><div dir="auto">I know I’ve talked about decorator patterns. Integration into a GUI tool and modifying the Canonicalizer or X3dTidy.xslt might be preferred, since I think they have GUI.</div><div dir="auto"><br></div><div dir="auto">But first, a command line tool.</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 1, 2023 at 12:17 PM Vincent Marchetti <<a href="mailto:vmarchetti@kshell.com">vmarchetti@kshell.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My thought would be to identify (best case) or write (worst case) an XSLT script which performs the generic XML processing task of<br>
removing xml attributes whose values match the default specified in an associated DTD, or schema<br>
<br>
This is listed as an uncompleted task in a project page on web3d site: <a href="https://www.web3d.org/x3d/tools/canonical/doc/x3dTools.htm" rel="noreferrer" target="_blank">https://www.web3d.org/x3d/tools/canonical/doc/x3dTools.htm</a><br>
<br>
So the pipeling would be:<br>
Run x3dcf.py script that adds containerField everywhere; then run the xslt script that removes the containerField attributes which match the default -- which is, as been noted, the large majority of them.<br>
<br>
Vince Marchetti<br>
<br>
<br>
> On Nov 1, 2023, at 12:58 PM, Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>> wrote:<br>
> <br>
> I did take a look at the generator stylesheet but could not get very far.<br>
> X3DUOM has the containerField default information separate from<br>
> fields, so it could not be processed along with the fields. Perhaps a<br>
> static CONTAINERFIELDDEFAULT() class method could work at class init,<br>
> and then be used to check at XML output.<br>
> I tried<br>
> <br>
> <a href="https://linangdata.com/xslt-tester/" rel="noreferrer" target="_blank">https://linangdata.com/xslt-tester/</a><br>
> <br>
> for no-setup fiddling with SaxonJS2. It takes the large X3DUOM xml and<br>
> the large xslt but there is a dependance on the external tooltips xml<br>
> document which I could not get rid of.<br>
> <br>
> It should be possible to use Python etree or similar to first ingest<br>
> X3DUOM default containerField data, add a class method like above to<br>
> each concrete Node in x3d.py, and then do the same as the awk script.<br>
> <br>
> -Andreas<br>
> <br>
> On Wed, Nov 1, 2023 at 10:23 AM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>> wrote:<br>
>> <br>
>> 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>
> <br>
> <br>
> <br>
> -- <br>
> Andreas Plesch<br>
> Waltham, MA 02453<br>
> <br>
> _______________________________________________<br>
> x3d-public mailing list<br>
> <a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
> <a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
<br>
<br>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div></div>