[x3d-public] X3dToJson.xslt changes for X3D JSON schema

John Carlson yottzumm at gmail.com
Thu Dec 19 01:21:58 PST 2024


If this is being reviewed for file size, I need a disability accommodation
to allow it.  Apparently I cannot communicate properly without images.

There are probably thousands of X3D archive that are wrong, they use a
string to represent an MFString instead of an array, including this one:

web3d.org/x3d/content/examples/ConformanceNist/Appearance/Appearance/ImageTextureChild.json
<https://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/Appearance/ImageTextureChild.json>

Here's a snapshot:

[image: image.png]

I am not sure about the green part of the patch below, but @transitionType
an X3D MFString that's an array in X3D JSON schema as well.  Please test
the patched X3dToJson.xlst with @transitionType.
My JSON files do not contain transitionType, so I haven't tested that with
X3D JSON schema.  What I see in the X3D JSON zip on X3D resources examples
is a string array for @transitionType.  Why is @transitionType rendered
differently than @type in the zip archive?

Here's an example that has the NavigationInfo @type as an array, not an
string:

https://www.web3d.org/x3d/stylesheets/X3dToJson.html

[image: image.png]

Yet the stylesheet on sourceforge doesn't produce that, as evidenced by the
JSON in the first image.

I have a vision problem too.  It happens.

I think Holger will stand by me to say that all MFStrings in JSON should be
arrays, not strings.

The reason this is coming up is because I continually have to patch
X3dToJson.xslt for new changes to fix output.  I am considering switching
back to Holger's x3d-tidy, but the command line options are not as suitable
as I like for batch files, and I may fork it instead. So I can either
maintain my own stylesheet, or my own x3d-tidy.  I already have a working
stylesheet.

John


Here are changes to make NavigationType @type in X3D JSON validatable with
X3D JSON schema.

$ diff -c /c/Users/jcarl/www.web3d.org/x3d/stylesheets/X3dToJson.xslt
./X3dToJson.xslt
*** /c/Users/jcarl/www.web3d.org/x3d/stylesheets/X3dToJson.xslt 2024-12-18
22:11:31.726779000 -0600
--- ./X3dToJson.xslt    2024-12-19 00:15:58.877419300 -0600
***************
*** 1017,1023 ****
                          <xsl:text>"</xsl:text>
                      </xsl:when>
                      <!-- single string -->
!                     <xsl:when test="($attributeType = 'SFString') or
                                      not(local-name() ='url') and
not(ends-with(local-name(),'Url')) and
                                         ((local-name()='value') and

 ((contains(local-name(../..),'Proto') or
contains(local-name(../../..),'Proto')) and
--- 1017,1024 ----
                          <xsl:text>"</xsl:text>
                      </xsl:when>
                      <!-- single string -->
!                   <xsl:when test="not((local-name(..)='NavigationInfo')
   and ((local-name()='type') or (local-name()='transitionType')))
!                                and (($attributeType = 'SFString') or
                                      not(local-name() ='url') and
not(ends-with(local-name(),'Url')) and
                                         ((local-name()='value') and

 ((contains(local-name(../..),'Proto') or
contains(local-name(../../..),'Proto')) and
***************
*** 1027,1033 ****
                                          (local-name()='name')       or
(local-name()='description') or (local-name()='accessType') or
                                          (local-name()='marking')    or
(local-name()='description') or
                                        (local-name()='nodeField')  or
(local-name()='protoField')  or
!                                         ((local-name()='type') and
not(local-name(..)='NavigationInfo')))
                                       ">
                          <!-- debug -->
                          <xsl:if test="$debugTrace">
--- 1028,1034 ----
                                          (local-name()='name')       or
(local-name()='description') or (local-name()='accessType') or
                                          (local-name()='marking')    or
(local-name()='description') or
                                        (local-name()='nodeField')  or
(local-name()='protoField')  or
!                                         ((local-name()='type') and
not(local-name(..)='NavigationInfo'))))
                                       ">
                          <!-- debug -->
                          <xsl:if test="$debugTrace">
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241219/c7a103fd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 53042 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241219/c7a103fd/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 60083 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20241219/c7a103fd/attachment-0003.png>


More information about the x3d-public mailing list