[x3d-public] x3d.py roundtrip for Metadata nodes in v.3.3 and v.4.0
Andreas Plesch
andreasplesch at gmail.com
Tue Oct 31 10:19:57 PDT 2023
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:
..
<Scene>
<!-- Core profile can only contain WorldInfo and Metadata nodes. here!!! -->
<WorldInfo title='EmptySceneCoreProfile.x3d'/>
<WorldInfo title='EmptySceneCoreProfile.x3d'>
<MetadataSet name='NodeSet' containerField='metadata'>
<MetadataBoolean containerField='value' name='BooleanData'
value='true false'/>
<MetadataDouble containerField='value' name='DoubleData' value='1 2 3'/>
<MetadataFloat containerField='value' name='FloatData' value='4 5 6'/>
<MetadataInteger containerField='value' name='IntegerData' value='7 8 9'/>
<MetadataString containerField='value' name='StringData'
value='"Empty Scene" "Core Profile"'/>
</MetadataSet>
</WorldInfo>
</Scene>
...
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:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN"
"https://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Core' version='3.3'
xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'>
<head>
...
</head>
<Scene>
<WorldInfo title='EmptySceneCoreProfile.x3d'/>
<WorldInfo title='EmptySceneCoreProfile.x3d'>
<MetadataSet name='NodeSet'>
<MetadataBoolean name='BooleanData' value='true false'/>
<MetadataDouble name='DoubleData' value='1 2 3'/>
<MetadataFloat name='FloatData' value='4 5 6'/>
<MetadataInteger name='IntegerData' value='7 8 9'/>
<MetadataString name='StringData' value='"Empty Scene" "Core Profile"'/>
</MetadataSet>
</WorldInfo>
</Scene>
</X3D>
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
More information about the x3d-public
mailing list