[x3d-public] Issue with X3dToJava.xslt. Can't addComments to setUSE
Brutzman, Donald (Don) (CIV)
brutzman at nps.edu
Sun Feb 18 16:42:34 PST 2024
[cc: x3d-public]
John, the question is answered in your message. You can't add comments to a
USE node.
This design choice is intentional to maximize interoperability across
programming languages and file encodings. If you are wondering why:
* There is no requirement for a USE node to include a comment.
* USE nodes have no way of including a comment in VRML file encodings,
though an XML element with a USE attribute can contain a comment in XML
encoding.
* USE nodes might follow a comment, or be followed by a comment, and
so authors are not impeded.
* If X3DJSAIL were to allow comments with USE nodes, there would be no
consistent way to perform round-trip conversions.
Authoring suggestion: if you want to be descriptive about the purpose of a
USE node, then be descriptive when creating the DEF/USE label. Creating
good names is a good authoring practice, for many reasons. Example:
* <Material DEF='MyMagnificentPurpleMaterial' diffuseColor='1 0 1'/>
* <Material USE='MyMagnificentPurpleMaterial'/>
When a converter encounters an XML .x3d file that has an embedded comment
within a USE node, and the converter is not stripping comments, best
practice for conversion is to let the comment follow the USE node. For
example:
* <Material DEF='MyMagnificentPurpleMaterial' diffuseColor='1 0 1'>
<!-- A descriptive comment -->
</Material>
becomes
* ClassicVRML, VRML:
material USE MyMagnificentPurpleMaterial
# A descriptive comment
* XML:
<Material DEF='MyMagnificentPurpleMaterial' diffuseColor='1 0 1'>
<!-- A descriptive comment -->
In Java, your exception example
.addChild(new Transform().setScale(.2,.2,.2)
.addChild(new Shape().setUSE("Torus")
.addComments(" Knot "))
is better expressed as
.addChild(new Transform().setScale(.2,.2,.2)
.addChild(new Shape().setUSE("Torus"))
.addComments(" Knot ")
p.s. relevant "Doctor Doctor" joke:
* A guy sees his doctor out in town one day and says, "Doctor, my arm
really hurts when I bend it this way (he bends it), do you have any advice?"
* The doctor says "don't bend it that way."
* https://allnurses.com/old-joke-arm-pain-t731263
* Addendum for U.S. patients without health insurance: "That will be
$800 please."
* Ow :0
all the best, Don
--
Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149
X3D graphics, virtual worlds, navy robotics https://faculty.nps.edu/brutzman
From: John Carlson <yottzumm at gmail.com>
Sent: Sunday, February 18, 2024 1:50 PM
To: Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>; Joe D Williams
<joedwil at earthlink.net>
Subject: Issue with X3dToJava.xslt. Can't addComments to setUSE
Java and original X3D attached. I will look for a new version in the
archives.
I'm not sure how to patch my serializer, so I'm looking for some insight.
It appears that X3DJSAIL says that comments can't be applied to a USE node.
$ java -Xss1g -Xmx4g -cp
.;C:/Users/john/pythonSAI/saxon-he-12.1.jar;C:/Users/john/pythonSAI/X3DJSAIL
.4.0.full.jar net/x3djsonld/data/Trebuchet
Build this X3D model, showing validation diagnostics...
*** Further hints on X3DJSAIL errors and exceptions at
*** https://www.web3d.org/specifications/java/X3DJSAIL.html
Exception in thread "main" org.web3d.x3d.sai.InvalidFieldValueException:
addComments(" Knot ")
cannot be applied to a USE node (USE='Torus') which only contains a
reference to a DEF node
at org.web3d.x3d.jsail.Shape.Shape.addComments(Shape.java:1346)
at net.x3djsonld.data.Trebuchet.initialize(Trebuchet.java:292)
at net.x3djsonld.data.Trebuchet.<init>(Trebuchet.java:113)
at net.x3djsonld.data.Trebuchet.main(Trebuchet.java:643)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240219/f6a10d05/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5464 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240219/f6a10d05/attachment-0001.p7s>
More information about the x3d-public
mailing list