[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 12:38:20 PDT 2023
For a post-processor someone could test X3dTidy.xslt or the canonicalizer
to see if they add containerFields.
If I remember, I can look into X3dTidy, since I already have that in mostly
in place here:
https://github.com/coderextreme/x3dschema
The batchtidy ant target is in build.xml
I already filter container fields from JSON. We’re just focused on XML
(x3d.py output) at this point. Please ignore any ant targets that use JSON
as they are still being tested. I do not have any x3d.py output in this
repository that I know of.
As a side note, if x3d.py could take some form of input, perhaps through an
adjunct package using a python dict, this would be much easier. I’ve tried
more than twice to accomplish this.
John
On Tue, Oct 31, 2023 at 1:24 PM John Carlson <yottzumm at gmail.com> wrote:
> Another idea is to write a post-processor to add containerField output.
> I’m not volunteering.
>
> John
>
> On Tue, Oct 31, 2023 at 12:21 PM Andreas Plesch <andreasplesch at gmail.com>
> 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:
>>
>> ..
>> <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
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20231031/d2679c64/attachment.html>
More information about the x3d-public
mailing list