===============================================================================
2023 may 07

Improve the quality of the PNG
    <scalar name="diagram_scale">0.1</scalar>
    <string name="diagram_unit">in</string>
Was
    <scalar name="diagram_scale">1</scalar>
    <string name="diagram_unit">px</string>

The PNG are bigger, and now a width must be specified when referencing a PNG,
otherwise the displayed railroad is way too big.
See for example NamedArguments-Spec.md
    sd_Arguments.png is 3462 × 980
    3462/150=23.08%     *2=46.16
    <img src="SyntaxDiagram/sd_Arguments.png" width="46.16%">

Must multiply the width by 2 because the github rendering is too small compared
to a local rendering.

===============================================================================
2023 may 06

Pfff...
Fighting during hours and days and weeks and months and years, ad nauseam, against
Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/javascript/WrapFactory
	at org.apache.batik.bridge.RhinoInterpreterFactory.createInterpreter(RhinoInterpreterFactory.java:82)

ALLELUIA!
Adolfo in this thread provided the solution
https://stackoverflow.com/questions/7891250/batik-not-in-classpath-error-when-running-servlet

Rhino is not in the Class-Path of MANIFEST.MF of batik-rasterizer-<version>.jar
WHY?????

Procedure:
go to the lib directory of Batik
mkdir tmp
cd tmp
# extract the content of the jar file into the current directory
jar -xf ../batik-rasterizer-<version>.jar
# create a copy of MANIFEST.MF and update it
cp META-INF/MANIFEST.MF .
edit ./MANIFEST.MF to add rhino-<version>.jar in Class-Path
REMEMBER: max length is 72, can break a line and continue it next line by starting with a space.
Here, I use TWO spaces because each jar is separated by a space, so the character after the first space is another space.
Class-Path: lib/batik-shared-resources-1.16.jar
  lib/batik-svgrasterizer-1.16.jar
  lib/batik-parser-1.16.jar
  ...
# recreate the jar file
jar cmf MANIFEST.MF batik-rasterizer-<version>.jar org/*
backup the original lib/batik-rasterizer-<version>.jar
replace it by the new one with the updated MANIFEST.MF
THAT'S IT! NOW IT WORKS!!!!


===============================================================================
2023 apr 02

Under MacOs ARM with java/jdk/bellsoft/jdk-19.0.2-full.jdk, batik-1.7 is no longer working :-(
java -jar $BATIK_RASTERIZER_JAR
Exception in thread "main" java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release

Same error with batik 1.15
java -jar /local/XmlToolSet/batik-1.15/batik-rasterizer-1.15.jar
Exception in thread "main" java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release

I install batik 1.16
No more exception about security manager
but...
Pfff... Again
Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/javascript/WrapFactory
	at org.apache.batik.bridge.RhinoInterpreterFactory.createInterpreter(RhinoInterpreterFactory.java:82)

echo $CLASSPATH
/local/rexx/bsf4oorexx/BSF4ooRexx_install_v641-20220131-ga/bsf4oorexx/bsf4ooRexx-v641-20220131-bin.jar:
Still this error if I delete CLASSPATH
Still this error if I delete rhino-1.7.7.jar in batik-1.16/lib
Still this error if I declare CLASSPATH=/Users/Shared/local/XmlToolSet/batik-1.16/lib:/Users/Shared/local/XmlToolSet/batik-1.16/lib/rhino-1.7.7.jar


===============================================================================
2022 oct 20

Under MacOs
[error] Batik's rasterizer failed when converting to PNG
Exception in thread "main" java.lang.NoClassDefFoundError: org/mozilla/javascript/WrapFactory

https://github.com/robander/svg-syntaxdiagrams
https://github.com/robander/svg-syntaxdiagrams/issues/3
    Comments:
    - I fixed the problem by downloading a binary release of Rhino, and copying the rhino-1.7.9.jar file to the dita-ot-2.5.4\lib directory.
    - Not sure what caused this - I was only ever able to reproduce the error by deleting the Rhino code that was stored within the Batik library.
jlf: NOT WORKING WITH BATIK which is aleady delivered with rhino-1.7.7.jar

Current version of batik installed is batik-1.13
I install the latest version of Batik: batik-1.15
Still exception

I download latest version of Rhino
https://github.com/mozilla/rhino/releases/tag/Rhino1_7_14_Release
and put rhino-1.7.14.jar in the lib folder of Batik
Still exception

Was using jdk-17.0.4.1-full.jdk
Try with system Java (current version 1.8.0_131)
Still exception

It works with an old version of Batik : batik-1.7


===============================================================================
2014 may 31

Railroad diagram generator
http://bottlecaps.de/rr/ui


===============================================================================
2009 sept 18

constants.xml :
I made a wrong assumption about diagram_max_width.
This constant is not used to limit the witdth of the image, it's used to
calculate the xscale. If too small, then the xscale will be < 1.0 and the
image's contents will become less readable. So assign a big value to it (10000)
and tune the constant diagram_wrap_width to ensure that the syntax diagrams
will fit in the page.

Hum, I see that the syntax diagram of String~translate 5.1.3.64 does not fit in
the page. It's probably because no wrap was possible (would need two continuation
points, and I think that syntaxdiagram2svg can't do that).
So, I re-assign to diagram_max_width the same value as diagram_wrap_width.
See also :
MutableBuffer~translate 5.4.14.32
Format 7.4.33
SysStemCopy 8.66

Use CSS @media types to select different fonts for PDF and HTML :
PDF : Times-New-Roman 10pt
HTML : Times-New-Roman 12pt

When generating PNG, I'd like to use an "infinite" value, to have no wrapping.
Done by modifying the XSLT script make-constants.xsl and passing a parameter
("PDF" or "PNG") from the script sd2image.rex.
Not sure it's a good idea :
see oodialog\sd_basedialog\sd_Animated_Buttons_ConnectAnimatedButton.png


===============================================================================
2009 sept 13

Small tuning in CSS and resources :
No longer use bold.
Adjust diagram max width (still too big, I think).

transform.xsl :
Changed the way the titles (or lack of titles) are managed.
Currently, the fragments have their own full name, no need of title in their
enclosing syntax diagram.


===============================================================================
2009 july 11

I have a small documentation which gives examples of railroads generated
from DITA syntax diagrams, but I can't remember from where I downloaded it...
[14/09/2009]
I remember now : from http://tech.groups.yahoo.com/group/dita-users/files/
search for syntaxdiagram-doc.zip

In the meantime, remember that :
http://www.ditainfocenter.com/eclipsehelp/index.jsp?topic=/org.ditausers.infomanager.LangSpec1.1/common/pr-d.html
http://en.wikipedia.org/wiki/Syntax_diagram
http://www.cs.man.ac.uk/~pjj/bnf/bnf.html
http://ditaa.sourceforge.net/


===============================================================================
2009 june 29

generate.rex :
No need to iterate over the svg files. Batik rasterizer does that automatically.

I find that the letters of the keywords are a little bit blurred.
--> Changed the CSS stylesheet to declare stroke-width: 0.0; instead of 0.1
Since the look is better, changed all the 0.1 to 0.0

Another possible improvement : in constants.xml, there is a suggestion to try
diagram_scale=0.28
diagram_unit=in
This is lot more CPU intensive, and I needed to declare a bigger heap for java.
The resolution is better but the png are bigger and very slow to display.
--> not activated for now.

To investigate : I see that integer.png has small boxes floating near the symbols.
It's probably because of <synnote>.


===============================================================================
2009 june 28

About Clapham :
http://julianhyde.blogspot.com/2009/05/clapham-railroad-diagram-generator.html
In the comments :
<<
Tom Copeland said...
Also, FWIW, Eric Dahlstrom saw this and tweeted "that svg output is not very pretty,
suggest using either svg paths or rects directly, and to make sure text is placed correctly".
Probably the "use paths or rects" means more to you than it does to me :-)
>>


Other investigation :
http://dita.xml.org/wiki/plugins-for-the-dita-open-toolkit
--> downloaded the "Plus" plugins from
http://tech.groups.yahoo.com/group/dita-users/files/Demos/
This set of plug-ins for Dita contains a plug-in that can work alone :
com.moldflow.dita.syntaxdiagram2svg
Extract from its doc :
<<
This plugin is not strictly part of the Plus plugins, though it was developed in parallel
with them.  It is possible to use this plugin independently in your own transformation
by importing the XSLT template <filepath>xsl/syntaxdiagram2svg.xsl
>>
--> I had to modify a lot of things in this stylesheet (mechanical changes : had to replace
the tests contains(@class,...)  by name()=
Now I have something working (SVG output) but I can't visualize it...
According to Deborah Picket (http://tech.groups.yahoo.com/group/dita-users/message/12082) :
<<
You need a JavaScript-aware SVG renderer (I use Batik) to dynamically size the syntax diagram
to envelop the text that each box contains
>>
--> so I downloaded Batik...
The file js/constants.js is missing.
Ok, this file is generated by transforming resource/constants.xml using xsl/make-constants.xsl.
Now it works, and the look is great.

I see that <fragment> does not work.
Probably because the search algorithm is based on <topic>, that I don't have in the raw syntax diagram.
--> fixed, now we have the referencing box, but no referenced diagram...
--> fixed, fragments are now generated as separate SVG files.

Is it possible to reuse the best of Clapham and syntaxdiagram2svg ?
The XML file read by syntaxdiagram2svg is diffcult to enter by hand, but the output is great.
The BNF or WSN files supported by Clapham are lot easier to enter by hand, but the output is not very pretty.
What about generating the XML file from the BNF|WSN ?
[19 sep 2009] no longer topical


===============================================================================
2009 june 27

Found a reference to Clapham on reddit, and decided to have a look...

Output is not perfect, but that's a start...
I'm curious to see if I can modify this generator to :
- remove the boxes
- remove the title, to keep only the railroad
- have optional elements under the main line
- fix this bug : when last node is optional, it's inserted twice
(2009 june 28 : I give up these tasks... The output of com.moldflow.dita.syntaxdiagram2svg is far better !)

Clapham supports two dialects, so I test both.

Comments /* */ are not supported by the wsn parser.
--> cloned what's done in the bnf parser
Had to install javacc
and to replace javacc.jar (downloaded by Clapham) by the latest version from javacc
