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

John Carlson yottzumm at gmail.com
Tue Oct 31 16:38:08 PDT 2023


This is one reason why I changed the VRML and JSON children container
fields in x3d.py to use the actual field name instead of children.

Did this cause other problems?  IDK.

John

On Tue, Oct 31, 2023 at 5:24 PM Joe D Williams <joedwil at earthlink.net>
wrote:

> > But the first step may be to modify the stylesheet to generate
> containerField attributes for all nodes,
>
> ContainerField like any otherfiled does not need tobe inthecode if
> thedefault iscorrect.
> There are only a few cases where the  containerField is not the default
> value.
>
>
>
>
> -----Original Message-----
> From: Andreas Plesch <andreasplesch at gmail.com>
> Sent: Oct 31, 2023 12:50 PM
> To: John Carlson <yottzumm at gmail.com>
> Cc: Joe D Williams <joedwil at earthlink.net>, X3D Graphics public mailing
> list <x3d-public at web3d.org>
> Subject: Re: [x3d-public] x3d.py roundtrip for Metadata nodes in v.3.3 and
> v.4.0
>
> 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.
>
> -Andreas
>
>
>
> On Tue, Oct 31, 2023 at 2:10 PM John Carlson wrote:
> >
> > Thank you Andreas for bringing this up. x3d.py as of last night, did not
> output any containerFields.
> >
> > I don’t think that putting containerFields everywhere is the right
> solution. It would be great if x3d.py could figure out what containerField
> field to use, like for HAnimHumanoid's skeleton, skin fields, and
> joints/segments/sites fields. Right now, x3d.py prevents the user from
> specifying any containerFields, because x3d.py controls pretty much all
> output. My idea was to pass an optional containerField to an XML method,
> but since ix3d.py is created with a stylesheet, this will affect many XML
> methods potentially, so this will need to be controlled carefully.
> >
> > I have a lot of related experience trying to get containerField right
> for X3DJSONLD/X3DJSAIL when creating DOM from JSON in
> https://github.com/coderextreme/x3dschema/blob/main/X3DJSONLD.java.
> Here's my current results. More logic probably needs to be added for the
> skin fields
> >
> > public Element CreateElement(Document document, String key, String
> containerField) {
> > Element child = document.createElement(key);
> > if (containerField != null &&
> > ((containerField.equals("geometry") &&
> key.equals("IndexedFaceSet")) ||
> > (containerField.equals("geometry") && key.equals("Text")) ||
> > (containerField.equals("geometry") &&
> key.equals("IndexedTriangleSet")) ||
> > (containerField.equals("geometry") && key.equals("Sphere")) ||
> > (containerField.equals("geometry") && key.equals("Cylinder")) ||
> > (containerField.equals("geometry") && key.equals("Cone")) ||
> > (containerField.equals("geometry") && key.equals("LineSet")) ||
> > (containerField.equals("geometry") &&
> key.equals("IndexedLineSet")) ||
> > (containerField.equals("geometry") && key.equals("Box")) ||
> > (containerField.equals("geometry") && key.equals("Extrusion")) ||
> > (containerField.equals("geometry") &&
> key.equals("GeoElevationGrid")) ||
> > (containerField.equals("shape") && key.equals("Shape")) ||
> > (containerField.equals("skin") && key.equals("Shape")) ||
> > (containerField.endsWith("exture") &&
> key.equals("ImageTexture")) ||
> > (key.equals("HAnimSegment")) ||
> > (key.equals("HAnimSite")) ||
> > (key.equals("HAnimMotion")) ||
> > (containerField.equals("skinCoord") && key.equals("Coordinate"))
> || // overwrite coord with skinCoord, if set
> > (containerField.equals("skin") && key.equals("IndexedFaceSet"))
> ||
> > ((containerField.equals("skinBindingCoords") ||
> containerField.equals("skinCoord")) && key.equals("Coordinate")) ||
> > ((containerField.equals("normal") ||
> containerField.equals("skinBindingNormals") ||
> containerField.equals("skinNormal")) && key.equals("Normal")) ||
> > ((containerField.equals("skeleton") || containerField.equals("children")
> || containerField.equals("joints")) && key.equals("HAnimJoint"))
> > )) {
> > elementSetAttribute(child, "containerField", containerField);
> > }
> > return child;
> > }
> >
> > if ((containerField == null || containerField.equals("children"))
> && parentkey.equals("HAnimJoint") &&
> element.getTagName().equals("HAnimHumanoid")) {
> > containerField = "joints";
> > }
> > if ((containerField == null || containerField.equals("coord"))
> && parentkey.equals("Coordinate") &&
> element.getTagName().equals("HAnimHumanoid")) {
> > containerField = "skinCoord";
> > }
> > child = CreateElement(document, parentkey, containerField);
> >
> >
> > I don't know if something similar could be added for x3d.py or whether
> x3d.py can be sufficiently tested. I am willing to put in effort to run
> code output from X3dToPython.xslt in the archive, which I know no one else
> wants to do. But someone else will have to go through possibly the tons of
> output from tovrmlx3d that is created. My recommendation is to do
> onesies-twosies as Don suggested and likes. I will try to set up a testing
> framework with a modified X3dToPython.xslt. This will take away from my WS
> work.
> >
> > On Tue, Oct 31, 2023 at 12:21 PM Andreas Plesch wrote:
> >>
> >> x3d.py may not quite manage a roundtrip back to XML for MetadataSet.
> >>
> >>
> https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview/EmptySceneCoreProfileIndex.html
> >>
> >> has the model in XML encoding:
> >>
> >> ..
> >>
> >>
> >>
> >>
> >>
> >> > value='true false'/>
> >>
> >>
> >>
> >> > value='"Empty Scene" "Core Profile"'/>
> >>
> >>
> >>
> >> ...
> >>
> >> Running
> https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter01TechnicalOverview/EmptySceneCoreProfile.py
> >>
> >> with the latest x3d.py confirms well formedness of the .XML() output.
> >>
> >> Uncommenting the diagnostic line to print the XML output gives this XML:
> >>
> >>
> >> > "https://www.web3d.org/specifications/x3d-3.3.dtd">
> >> > xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
> >> xsd:noNamespaceSchemaLocation='
> https://www.web3d.org/specifications/x3d-3.3.xsd'>
> >>
> >> ...
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> The Metadata containerField attributes of the original XML encoding
> >> were omitted. This is ok for most Metadata nodes since the default
> >> containerField value is 'value'.
> >>
> >>
> https://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_MetadataSet.html#Link561
> >> defines the default value for the MetadataSet containerField attribute
> >> also as 'value'. However, in the example the containerField attribute
> >> value for the MetadataSet node needs to be 'metadata' and not 'value',
> >> in the x3d.py generated XML.
> >>
> >> I believe this may be an example of what John encountered.
> >>
> >> One option for x3d.py may be to generate containerField attributes for
> >> all nodes since x3d.py will know the field name for which a node is
> >> the value. Perhaps it suffices to do this for all nodes where the
> >> containerField attribute value would not be 'children'. It may not be
> >> practical to embed the containerField default values for all nodes in
> >> the x3d.py source.
> >>
> >> I just noticed that x3d.py explicitly generates X3D 3.3 xml output.
> >> The above only applies to X3D 4.0. However, the same issue persists in
> >> a flipped way with X3D 3.3 which has 'metadata' as default
> >> containerField value for Metadata nodes. This means in the x3d.py
> >> generated output all Metadata nodes except for MetadataSet would need
> >> an explicit containerField value of 'value'.
> >>
> >> -Andreas
> >> --
> >> Andreas Plesch
> >> Waltham, MA 02453
> >>
> >> _______________________________________________
> >> x3d-public mailing list
> >> x3d-public at web3d.org
> >> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
>
>
> --
> Andreas Plesch
> Waltham, MA 02453
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20231031/02d025de/attachment.html>


More information about the x3d-public mailing list