[x3d-public] X3DJSAIL still broken! XML actually. Potential Fix to XSLT

John Carlson yottzumm at gmail.com
Thu Jul 1 14:06:50 PDT 2021


Clarification below:

On 7/1/21 3:29 PM, John Carlson wrote:

> Actually, I believe *XML* export is failing from X3DJSAIL.  XML output 
> causes the X3dToJson.xslt to produce bad results.
>
> See below code.
>
> See pretty printed code attached from X3DJSAIL export.  Search for 
> multiple versions of backTexture causing the JSON generation to get 
> messed up.
>
> Perhaps we should add a schematron hint for when backTexture, etc. is 
> repeated in a ComposedCubeMapTexture?
>
> Java looks fine. Your Java looks good too.


That is, both versions of ball.java look good. These aren't produced by 
X3DJSAIL, rather I generated them with my serializer and your 
X3dToJava.xslt, with my RunSaxon.java


Sorry I didn't make that clear before.


To fix, I suggest, using this template:

      if (hasAncestorX3D() &&
findAncestorX3D().getVersion().startsWith("3"))
              correctedContainerField = "back";
         else correctedContainerField = "backTexture";

and replace back 1 and back 2 with appropriate sides of cube. Then 
sprinkle the filled in templates in the code below.

I fully realize you want an XSLT patch.  Here's a potential patch.  I 
will test against ball.x3d, but you'll have to test the other cases.  
I'm not sure why you put in the commented out code.


$ svn diff CreateX3dSceneAccessInterfaceJava.xslt
Index: CreateX3dSceneAccessInterfaceJava.xslt
===================================================================
--- CreateX3dSceneAccessInterfaceJava.xslt      (revision 32276)
+++ CreateX3dSceneAccessInterfaceJava.xslt      (working copy)
@@ -12960,13 +12960,13 @@
              <xsl:text>
          String correctedContainerField;</xsl:text>
              <xsl:for-each 
select="InterfaceDefinition/field[string-length(@synonym) > 0][@type = 
'SFNode']">
-                <xsl:if test="(position() = 1)">
+                <!--xsl:if test="(position() = 1)"-->
                      <xsl:text disable-output-escaping="yes"><![CDATA[
          if (hasAncestorX3D() && 
findAncestorX3D().getVersion().startsWith("3"))
               correctedContainerField = "]]></xsl:text><xsl:value-of 
select="@synonym"/><xsl:text>";
          else correctedContainerField = "</xsl:text> <xsl:value-of 
select="@name"/><xsl:text>";
  </xsl:text>
-                </xsl:if>
+                <!--/xsl:if-->
                  <xsl:variable name="CamelCaseName"><!-- upper camel 
case -->
                      <xsl:value-of 
select="translate(substring(@name,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
                      <xsl:value-of select="substring(@name,2)"/>


TTYS.

John


>
> x3d/stylesheets/java/src/org/web3d/x3d/jsail/CubeMapTexturing/ComposedCubeMapTexture.java 
>
>> /**
>>          * Utility method to adjust field synonyms
>>          * @see <a
>> href="https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#fieldNameChanges">X3D 
>>
>> Scene Authoring Hints: X3D4 Field name changes for improved
>> consistency</a>
>>      */
>>     private void handleFieldSynonyms()
>>     {
>>         String correctedContainerField;
>>         if (hasAncestorX3D() &&
>> findAncestorX3D().getVersion().startsWith("3"))
>>              correctedContainerField = "back";
>>         else correctedContainerField = "backTexture";
>>
>>         if      (getBackTexture() != null)
>>                  ((X3DConcreteNode)
>> getBackTexture()).setContainerFieldOverride(correctedContainerField);
>>         else if (getBackTextureProtoInstance() != null)
>>                  ((X3DConcreteNode)
>> getBackTextureProtoInstance()).setContainerFieldOverride(correctedContainerField); 
>>
>>
>>         if      (getBottomTexture() != null)
>>                  ((X3DConcreteNode)
>> getBottomTexture()).setContainerFieldOverride(correctedContainerField);
>>         else if (getBottomTextureProtoInstance() != null)
>>                  ((X3DConcreteNode)
>> getBottomTextureProtoInstance()).setContainerFieldOverride(correctedContainerField); 
>>
>>
>>         if      (getFrontTexture() != null)
>>                  ((X3DConcreteNode)
>> getFrontTexture()).setContainerFieldOverride(correctedContainerField);
>>         else if (getFrontTextureProtoInstance() != null)
>>                  ((X3DConcreteNode)
>> getFrontTextureProtoInstance()).setContainerFieldOverride(correctedContainerField); 
>>
>>
>>         if      (getLeftTexture() != null)
>>                  ((X3DConcreteNode)
>> getLeftTexture()).setContainerFieldOverride(correctedContainerField);
>>         else if (getLeftTextureProtoInstance() != null)
>>                  ((X3DConcreteNode)
>> getLeftTextureProtoInstance()).setContainerFieldOverride(correctedContainerField); 
>>
>>
>>         if      (getRightTexture() != null)
>>                  ((X3DConcreteNode)
>> getRightTexture()).setContainerFieldOverride(correctedContainerField);
>>         else if (getRightTextureProtoInstance() != null)
>>                  ((X3DConcreteNode)
>> getRightTextureProtoInstance()).setContainerFieldOverride(correctedContainerField); 
>>
>>
>>         if      (getTopTexture() != null)
>>                  ((X3DConcreteNode)
>> getTopTexture()).setContainerFieldOverride(correctedContainerField);
>>         else if (getTopTextureProtoInstance() != null)
>>                  ((X3DConcreteNode)
>> getTopTextureProtoInstance()).setContainerFieldOverride(correctedContainerField); 
>>
>>         } 



More information about the x3d-public mailing list