[x3d-public] Updated stylesheets test. Still failing!

John Carlson yottzumm at gmail.com
Thu May 27 19:51:42 PDT 2021


A second pair of eyes on the needed changes to X3dToJson.xslt and 
X3dToJava.xslt would be appreciated.  I updated the stylesheets from 
sourceforge, add I still see the following after running the 
stylesheets.  There are two issues here that still need action.


X3DJSONLD/src/main$ egrep 'setMetadata|Java.*Immel' 
data/HelloWorldProgramOutput.x3d data/HelloWorldProgramOutput.json 
{java,node}/net/x3djsonld/data/HelloWorldProgramOutput.* |grep -v 
class|grep -v @value

[ Note in the following original the quotes: ]

data/HelloWorldProgramOutput.x3d:          <!-- alternative Java source: 
.setString(new String [] {"One, Two, Comment", "", "He said, \"Immel did 
it!\""}) -->


[ Note the containerField in these, this will be important for 
addValue(...) below. ]

data/HelloWorldProgramOutput.x3d:            <MetadataString 
name='quotesTestC' containerField='value' value='"MFString example C, 
backslash-escaped quotes: He said, \"Immel did it!\""'/>
data/HelloWorldProgramOutput.x3d:            <MetadataString 
name='extraChildTest' containerField='value' value='"checks MetadataSet 
addValue() method"'/>


[ Note in the following the extra quotes around  Immel did it! Also note 
that this line got duplicated. See correct number of quotes in Java and 
JS below and X3D above. It appears like 2 extra \" have been added.  
Also see that "-children" is somewhat copied under 
"Scene"--ViewpointGroup at least and probably more ]

data/HelloWorldProgramOutput.json: "#comment":"alternative Java source: 
.setString(new String [] {\"One, Two, Comment\", \"\", \"He said, 
\\\"\"Immel did it!\\\"\"\"})"
data/HelloWorldProgramOutput.json: "#comment":"alternative Java source: 
.setString(new String [] {\"One, Two, Comment\", \"\", \"He said, 
\\\"\"Immel did it!\\\"\"\"})"
[snip]

[ The next two lines should be addValue(..) instead of setMetadata(...) 
I think.   See previous patch to X3dToJava.xslt Also note that 
X3dToNodeJS.xslt output is OK. Also below .xslt code]

java/net/x3djsonld/data/HelloWorldProgramOutput.java: .setMetadata(new 
MetadataString().setName("quotesTestC").setValue(new String[] {"MFString 
example C, backslash-escaped quotes: He said, \"Immel did it!\""}))
java/net/x3djsonld/data/HelloWorldProgramOutput.java: .setMetadata(new 
MetadataString().setName("extraChildTest").setValue(new String[] 
{"checks MetadataSet addValue() method"})))

[ note in the following the proper number of quotes, let's have JSON 
follow this pattern, if we can. ]

java/net/x3djsonld/data/HelloWorldProgramOutput.java: .addComments(" 
alternative Java source: .setString(new String [] {\"One, Two, 
Comment\", \"\", \"He said, \\\"Immel did it!\\\"\"}) ")
[snip[
node/net/x3djsonld/data/HelloWorldProgramOutput.js: .addComments(" 
alternative Java source: .setString(new String [] {\"One, Two, 
Comment\", \"\", \"He said, \\\"Immel did it!\\\"\"}) ")

Once we get the JSON updated, I'm thinking I may need to update my 
serializers based on the JSON.  I am unsure at this point what I'll get.

Thank you for your attention!  I think X3dToJava.xslt should generated 
addValue instead of setMetadata (when containerField = "value"), and 
X3dToJson.xslt should not generate extra \", and do what X3dToJava.xslt 
and X3dToNodeJS.xslt do for \" in a comment.


Note the following code in X3dToNodeJS.xslt may or may not work 
(X3dToJava.xslt uses /or/), so I moved the addValue section above the 
metadata containerField section in my X3dToJava.xslt:


                                 <xsl:when test="(local-name(..) = 
'MetadataSet') and (@containerField = 'metadata')">
<xsl:text>.setMetadata(</xsl:text>
                                         <xsl:apply-templates 
select="."/><!-- handle this node -->
<xsl:text>)</xsl:text>
                                 </xsl:when>
                                 <xsl:when test="(local-name(..) = 
'MetadataSet') and (@containerField = 'value')">
<xsl:text>.addValue(</xsl:text>
                                         <xsl:apply-templates 
select="."/><!-- handle this node -->
<xsl:text>)</xsl:text>
                                 </xsl:when>

John




More information about the x3d-public mailing list