Here's is a sample Java DefaultHandler2 for implementing multi-line comment to single line comments, while maintaining newlines outside of < ... >. If there's only one line of content in the comment, the empty comments are removed. I am providing compelling motivating content .x3d file as well. Feel free to use as open source under Web3D Consortium Open Source license in X3DJSAIL or X3D-Edit.
Here's the motivating example, which can be confirmed to work with X3dToPython.xslt (eventually).
please show expected example inputs and outputs for repeatability = thanks for your efforts.
Diff:
I have given up on the SAXParser as entirely unworkable, and instead provide the Java code. I will provide inputs and outputs in another message. Please review inputs and outputs to see if they meet goals. We should discuss whether spaces should be maintained in single comments output.
Last edit: John W Carlson 2026-01-15
Here are sample inputs and outputs. I believe these are as expected, except perhaps space preservation in comments, which is likely easily fixed. I can try to come up with more examples as well.
OK thanks for simpler examples. Even simpler excerpt (from JinScaled) follows.
You want to convert
to
So what you are requesting is not the original ticket title
83 Replacing Multiline comments with single line comments
but maybe better expressed as
with another example (ball.x3d) showing similar handling for long blocks of commented model code.
Appreciate your patient efforts, this is more understandable now.
This approach seems like better functionality for all of the converters, when possible. Further refinements might be able to follow after that, matching the capabilties of each file encoding (.x3d .xml, .x3dv, .x3dj .json etc.) and programming languages (java, python, etc.).
Am updating the ticket title correspondingly.
Last edit: Don Brutzman 2026-01-07
i am nearly ready to provide more examples in a zip, if needed. I realize this is low priority. It would be good for me to proceed now than later. I am dropping a link here for a reminder. https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/java/comments.sh
One thing to do would be to work on buffers instead of standard input and standard output.
Okay. Here are the examples. I am not pleased yet, and more can be done likely, but I'm going to move on from this for a while.
Thanks for a clearer problem statement, moving on is AOK...
As repeated multiple times before, I will not be reviewing massive zips.
With a clear problem statement, and a simple example excerpt, resolution will be possible. They are the key prerequisite for effective progress on any issue.
I look forward to getting the time to address things better across all of the converters used in the X3D Example Archives.
This doesn't compile. No hurry, I need to not kill my script if python dies.
https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaMaterials/ArtDecoExamples.py
$ python ArtDecoPrototypes.py
File "C:/Users/jcarl/X3DJSONLD/src/main/python/ArtDecoPrototypes.py", line 63
Material(ambientIntensity=1.0,diffuseColor=(0.536861,0.0529,0.245479),shininess=0.832432,specularColor=(0.805292,0.765198,0.747416))])),
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '[' on line 59
Last edit: John W Carlson 2026-03-30