Menu

#83 Replacing a single multiline comment with multiple single-line comments

X3D4
open
None
2026-03-30
2026-01-06
No

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.

Related

Tickets: #83

Discussion

  • John W Carlson

    John W Carlson - 2026-01-06

    Here's the motivating example, which can be confirmed to work with X3dToPython.xslt (eventually).

     
  • Don Brutzman

    Don Brutzman - 2026-01-06

    please show expected example inputs and outputs for repeatability = thanks for your efforts.

     
  • John W Carlson

    John W Carlson - 2026-01-07
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +0,0 @@
    -CommentNormalizingHandler.java (8.9 kB; application/octet-stream)
    
     
  • John W Carlson

    John W Carlson - 2026-01-07

    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
  • Don Brutzman

    Don Brutzman - 2026-01-07

    OK thanks for simpler examples. Even simpler excerpt (from JinScaled) follows.

    You want to convert

    <!-- 
      0 0 0 at floor between feet, 
      default I pose (relaxed attention) 
      model gaze toward +Z, 
      +x to model left, +y up, 
      right-hand rule. -->
    

    to

    < ! -- 0 0 0 at floor between feet, -->
    < ! -- default I pose (relaxed attention) -->
    <! -- model gaze toward +Z, -->
    < ! -- +x to model left, +y up, -->
    < ! -- right-hand rule. -->

    So what you are requesting is not the original ticket title

    • 83 Replacing Multiline comments with single line comments

    but maybe better expressed as

    • Replacing a single multiline comment with multiple single-line comments

    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
  • Don Brutzman

    Don Brutzman - 2026-01-07
    • summary: Replacing Multiline comments with single line comments in Java. Open Source donation --> Replacing a single multiline comment with multiple single-line comments
     
  • John W Carlson

    John W Carlson - 2026-01-15

    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.

     
  • John W Carlson

    John W Carlson - 2026-01-16

    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.

     
  • Don Brutzman

    Don Brutzman - 2026-01-16

    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.

     
  • John W Carlson

    John W Carlson - 2026-03-30

    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

Log in to post a comment.