[x3d-public] x3d.py roundtrip for Metadata nodes in v.3.3 and v.4.0

John Carlson yottzumm at gmail.com
Wed Nov 1 09:05:29 PDT 2023


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.

Dang cool!

On Wed, Nov 1, 2023 at 9:24 AM Andreas Plesch <andreasplesch at gmail.com>
wrote:

> A quick update:
>
> On Tue, Oct 31, 2023 at 3:49 PM Andreas Plesch <andreasplesch at gmail.com>
> wrote:
> >
> > Notes:
> >
> > x3d.py is autogenerated from X3DUOM:
> >
> > https://www.web3d.org/x3d/stylesheets/python/python.html#autogeneration
> >
> https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3duomToX3dPythonPackage.xslt
> >
> > X3DUOM has all necessary containerField default value information.
> >
> > But the first step may be to modify the stylesheet to generate
> > containerField attributes for all nodes, for simplicity. It looks like
> > the .XML() function would have to have an additional parameter 'field'
> > X3D(indentLevel, syntax, field) for each node.
> >
> > Postprocessing the generated XML is not possible since information was
> > irretrievably lost. But postprocessing the autogenerated x3d.py python
> > code may be possible since xslt is not for everyone.
>
> As a proof of concept I hacked a short awk (since I know it) script to
> process the latest x3d.py to include containerField support:
>
> https://github.com/andreasplesch/x3d-python-mod/blob/main/src/cfXML.awk
>
> It looks for the Concrete Nodes section, adds a field parameter to the
> .XML() output function, adds the containerField attribute to the
> output, and adds the field parameter to the .XML() calls for metadata,
> SFNode and MFNode field processing.
> The awk script is very brittle since it relies on comments in x3d.py
> to find the appropriate lines to modify. The hardest part was to get
> the quoting and escaping correct.
> It generates containerField attributes for all SF/MFNode fields except
> 'children'. Of course, most are unnecessary but filtering
> systematically for defaults would probably require involving X3DUOM
> and the generation stylesheet, similar to other XML related 'fields'
> such as style or class.
>
> The result is
> https://raw.githubusercontent.com/andreasplesch/x3d-python-mod/main/x3dcf.py
>
> The modified python script appears to work as expected by adding the
> appropriate containerField attributes in XML output for all the
> examples I tried.
> Realistically, this is as far as I can go with this but I think it may
> show how containerField support in XML output could be provided with
> x3d.py.
>
> -Andreas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20231101/59b1f34d/attachment-0001.html>


More information about the x3d-public mailing list