===============================================================================
2022 nov 11

The fragment | Arguments | is not shown in the generated bitmap.
Is it because <fragref>Arguments</fragref> is not in a <groupseq> ?
Yes, fixed.

<![CDATA[
             1         2         3         4         5         6
    12345678901234567890123456789012345678901234567890123456789012
  1
  2 Instruction CALL:
  3
  4 >>-CALL----+-name-----+----| Arguments |--------------------><
  5            +-(-expr-)-+
  6
]]>

<syntaxdiagram>
    <title>sd_Instruction_CALL</title>
    <groupseq>
        <kwd>CALL</kwd>
    </groupseq>
    <groupchoice>
        <var>name</var>
        <groupseq>
            <delim>(</delim>
            <var>expr</var>
            <delim>)</delim>
        </groupseq>
    </groupchoice>
    <fragref>Arguments</fragref>        <-- now in a block <groupseq>
</syntaxdiagram>


===============================================================================
2012 mar 05

Renamed files :
    directory.rex --> directory.cls
    help.rex --> help.cls
    string2args.rex --> string2args.cls
because help.rex was executed instead of help.exe when entering 'help' in ooRexxShell.


===============================================================================
2012 feb 04

Fix a bug in the XML parser : must not manage nested entities inside comments,
and must detect properly the end of the comment.
Symptom 1 : The parser raises "[error] Error line 41: EOF within an XML tag"
while parsing the rev 7467 of oodguide/Chapter06.xml.
Symptom 2 : After the fix for symptom 1, the parser raises
"[error] Error line 112 column 31: Invalid tag name"
Extract :
    line  41 : <!-- Chapter06 - List Views, Re-Sizing, and PopUps
    line 112 :      6.6    Utility Dialogs - <- ??? <What's this??> ...
    line 121 : -->


===============================================================================
2011 oct 16

todo :
oodialog/utilityclasses.xml

in <section id="mthPlus">, the syntax diagram
>>--"+"--point2----------------------------------><
can't be parsed. The "+" should be " + " to escape the plus character,
but then this is not conform to the initial intent.


in <section id="mthMinus">, the syntax diagram
>>--"-"--point2----------------------------------><
is parsed without error, but the result is not good :
The "-" is parsed like a normal line, instead of a minus character.
Should be " - " but then this is not conform to the initial intent.

So, in both cases, the problem is to recognize the quoted string as an escaped string...
[later]
No ! there is NO problem : the generated syntax diagram looks good, because the spaces
around the escaped character are removed.


===============================================================================
2011 august 20

Directory "makevalidxml" renamed to "transformxml".


===============================================================================
2010 april 28

Fix a bug in the tokenizer, which improves the performances : some attributes
can be calculated on demand, and keep the same value once calculated. They
are implemented with a get method which tests if the attribute has been already
calculated or not. The bug was a wrong expression passed to the var() BIF :
    var(my_attribute)
instead of
    var ('my_attribute')
Because of that, the attribute value was always re-calculated.
The performance gain is about 30s on oodialog/dialogObject (3'55 instead of 4'30).


===============================================================================
2010 march 4

Added option -reportlinks <linksFile>

In case of error, touch the transformed file with a low date & time, to force
selection at next run.


===============================================================================
2009 december 20

transformdir iterates over all the files, not just *.sgml
The files other than *.sgml are copied if needed (date comparison),
except the .svn files.
The file *.sgml are transformed if needed (date comparison).
Added the option -doit


===============================================================================
2009 december 19
The log file was not correctly opened : must be APPEND SHARED NOBUFFER to ensure
that each new line is added at the end of the file.

Fixed the transformation of a hierarchy of directories : must create each
intermediate directory (not only the outputDirectory given on command line).


===============================================================================
2009 november 29

Fixed a bug in the parser : The repetition separator (ex : comma in USE ARG)
was not included.


===============================================================================
2009 november 8

Starting to work on a bridge with BNF4OOo
http://sourceforge.net/projects/bnf4ooo/
a project of Franz Hohenegger, introduced by Rony.
I need the core of the program, not the OpenOffice interface.

The goal is to generate a bnf representation of the syntax diagrams.

Current status :
The generated XML4BNF is wrong, so the BNF as well, but the integration is ok.
Can iterate over the whole doc and generate a BNF for each syntax diagram.


===============================================================================
2009 october 18

Modified the XML parser to support the following files :
    oodialog/dialogcontrolCommon.sgml
    oodialog/windowBaseCommon.sgml
    oodialog/windowExtensionsCommon.sgml
Now I can process these files, no longer needed to skip them in transformdir.rex

Added the support of "->" operator to let generate good syntax diagrams for rexxpg.
Changed the font family to monospace for oper in CSS because "->" was not looking
good with Times-New-Roman.
Why are these functions described with syntax diagrams ? They are not real syntax
diagrams...

I see a problem with the spaces in rexxpg... They are removed by the SGV processor
when they are at the end of the text, even if I use xml:space="preserve".
<svg:text xml:space="preserve">, </svg:text>
is displayed without trailing space.
This is bug 46127 in Batik.


===============================================================================
2009 october 11

Started implemention of the -xslt option.

Removed the -xinclude option because it is always used with -xslt and not supported
with -dsssl


===============================================================================
2009 october 10

Testing by hand the changes that must be done to let rxmath.sgml be edited with XXE.

Must apply the changes listed in section 2009 july 11.

Must use xinclude, because XXE does not support inclusion by entities.

I keep the entities to have the path declaration in a single place
<!ENTITY legalstuff "../shared/legalstuff.sgml">
<xi:include href="&legalstuff;"/>
but when saving the file, XXE saves as
<xi:include href="../shared/legalstuff.xml"/>
because the entities are expanded and replaced by their values.

A file which is xincluded must be a valid XML file on its own.
Must add that if needed :
<?xml version="1.0" standalone="no"?>
<!DOCTYPE root PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
where root is the root element of the xincluded file (ex : section, bookinfo, ...)

I have a problem with shared/legalstuff.sgml :
This file has several roots, so can't be xincluded as-is.
And no way to make it single-root.
Except if I put bookinfo in this file, and remove it from rxmath.sgml. But then I
have another problem : the value of subtitle and titleabrev are different for each
book. Will address that later...

When using xinclude, the following files must be in the directory "shared" :
docbook-1.png
oorexx.jpg
xinclude.mod :
    Must be included to extend the DocBook schema, to support <xi:include>
    (needed by the validating XML editors)


===============================================================================
2009 september 19

sd2image :
Added instructions to generate the file constants.js (included by each SVG file)
before calling Batik. By passing the parameter TARGET_FORMAT, I can select values
that are appropriate for the target format. First need : I want no wrap when
generating PNG.
Replaced xsltproc by saxon, because I plan to investigate the XSLT2 stylesheets
of DocBook 5. Better to have a single XSLT processor right now...

Oooops ! now 41 min to run :
transformdir -syntdiag trunk trunk.out
(36 min with xsltproc).
There are 52 sd_*.xml files to process.
Which makes 3 x 52 = 156 additional invocations of the java VM.
I revert to xsltproc. After all, the XSLT 2.0 stylesheets for DocBook are
still in beta stage, so...

Remember, to create a zip file which contains the HTML documentation :
find . -name "*.htm" -o -name "*.jpg" -o -name "*.png" | zip -@ myfile-html


Todo :
Implement -dsssl, -xslt and -xinclude.


===============================================================================
2009 september 17

Investigate why the PDF format is not supported as image format
by my current toolset.
The script to analyze is
\Cygwin\usr\share\sgml\docbook\utils-0.6.14\backends\pdf
Despite its name, this script is doing both frontend and backend
Added some echos and put in comment the rm commands to keep the intermediate files.

This command :
cd trunk/rxmath
docbook2pdf -d ../shared/oorexx.print.dsl rxmath.sgml
triggers this execution :
jade -t tex -o rxmath.tex -i print -d /cygdrive/d/local/Rexx/ooRexx/svn/incubator/DocMusings/makevalidxml/test/trunk.out/rxmath/../shared/oorexx.print.dsl /cygdrive/d/local/Rexx/ooRexx/svn/incubator/DocMusings/makevalidxml/test/trunk.out/rxmath/rxmath.sgml
pdfjadetex rxmath.tex >rxmath.tmp
pdfjadetex rxmath.tex >/dev/null
pdfjadetex rxmath.tex >/dev/null

Good news ! When I replace .png by .pdf in rxmath.tex, and run pdfjadetex rxmath.tex
then the PDF images are used and the quality in rxmath.pdf is very good, even at zoom 400%.
Now, how to do that automatically ?

Remember :
http://www.miwie.org/docbkmake/docbookmk.html
    Explains how to use a single reference to the image, without extension,
    by customizing :
    find-displayable-object (in common/dbcommon.dsl)
    graphic-file (in html/dbgraph.dsl and print/dbgraph.dsl)

Remember :
%graphic-default-extension%
    data-filename
        find-displayable-object
            select-displayable-object --> preferred-mediaobject-extensions
                $mediaobject$

Finally, it's easy to support PDF format, just define %graphic-default-extension%
in the customization layer, with the right value :
pdf in oorexx.print.dsl
    (define %graphic-default-extension%
      ;; Default extension for graphic FILEREFs
      "pdf")
    (define preferred-mediaobject-extensions
      (list "pdf" "eps" "ps" "jpg" "jpeg" "png"))
png in oorexx.html.dsl
    (define %graphic-default-extension%
      ;; Default extension for graphic FILEREFs
      "png")
and don't include the file extension in fileref of imagedata.

Todo :
Implement -dsssl, -xslt and -xinclude.


===============================================================================
2009 september 12

Generated the 4.0.0 documentation with syntax diagrams as image.
Configuration :
WinXP + Cygwin + OpenJade + TexLive
For an example of generated PDF, go to :
http://sites.google.com/site/jfaucherfr/oorexx/syntax-diagrams

Procedure :
Go to directory docs/releases/4.0.0
Copy the directory trunk to trunk.out
Apply the fixes described below (9 aug and 5 sept ) in trunk
Run : transformdir -syntdiag trunk trunk.out (25 min on my laptop).
[20 sept 2009] 25 min when generating only PNG, 36 min when generating both PDF and PNG.
Go to directory trunk.out and make the doc as usual.
The syntax diagrams that can't be converted remain as text.

Remember :
There are errors remaining in oodialog : userdialog.sgml and utilityclasses.
The files windowBaseCommon.sgml and windowExtensionsCommon.sgml are not processed.
[18 oct 2009] Now the files windowBaseCommon.sgml and windowExtensionsCommon.sgml are processed.

Todo :
Improve the quality of the image, the PNG looks a little bit blurred.
Two image formats are generated from SVG : PDF and PNG
PDF images are very good, even if viewed at 400%.
The transformed XML contains a reference to each format, but the references
to the PDF are not taken into account.

Todo :
Implement -dsssl, -xslt and -xinclude.


===============================================================================
2009 september 5

Now process recursively the directories.

Added option -syntdiag
When the input <file>.sgml contains at least one syntax diagram, a file
sd_<file>.xml is created, which contains (for each syntax diagram) the text of
the syntax diagram, a diagnostic and (if valid) a DITA XML representation.

To be recognized as a syntax diagram, the text must be in CDATA and must contain
at least one entry point ">>" or "|-" at the begining of line.

Some errors are detected during the tokenization or the parsing :
oodialog\basedialog.sgml
    line 1837, near aBaseDialog~AutoDetection : must be terminated by ><
    line 2662, near aBaseDialog~ConnectMouseCapture : must be terminated by ><
    line 2801, near >>-aBaseDialog~ConnectKeyPress( : must shift the line one character to the right
oodialog\listcontrolc.sgml :
    line 1862, near aListControl~ModifyColumn : replace "." by "+"
oodialog\standarddialog.sgml :
    line 856, near >>-aCheckList~Init( : the second >> must be a continuation >-
    line 1206, near FileNameDialog( : replace the first "+" by "-"
    line 1664, near >>--CheckList( : the second >> must be a continuation >-
oodialog\userdialog.sgml :
    line 6593, near >>--addInput( : a "+" is missing for "+-,-style-+"
    line 6896, near >>--addInputGroup( : a "+" is missing for "+-,-style-+"
    line 7391, near >>--addInputGroup( : a "+" is missing for "+-,-style-+"
    and the same error which occurs several times : wrong optional declaration (I think), not fixed :
    line 1056, near dlg~addGroupBox(
    line 2337, near addRadioGroup(
    line 2576, near addRadioStem(
    line 3117, near addCheckGroup(
    line 3368, near addCheckBoxStem(
    line 3694, near dlg~addStatic(
    line 4543, near addWhiteRect(-
    line 4659, near addWhiteFrame(
    line 4775, near addGrayRect(
    line 4891, near addGrayFrame(
    line 5007, near addBlackRect(
    line 5123, near addBlackFrame(
    line 5239, near addEtchedFramed(
    line 5354, near addEtchedHorizontal(
    line 5469, near addEtchedVertical(
oodialog\utilityclasses.sgml :
    line 241, near >>-.DlgUtil~version( : two "+" are missing
    line 315, near >>-.DlgUtil~comCtl32Version( : two "+" are missing
    line 2121, near aDlgAreaU~Init(Dialog : this sd looks strange, don't know how to fix that...
rexxref\collclasses.sgml :
    line 1314, near makeString(-+ :
        replace the second "+" by "-" and move the end of the choice (CHAR) to the same position as (LINE)
    line 1676, near toString(-+ :
        replace the second "+" by "-" and move the end of the choice (CHAR) to the same position as (LINE)
rexxref\dire.sgml :
    line 362, near >>-::CONSTANT : must be terminated by ><
rexxref\funct.sgml :
    line 3431, near >>-RANDOM( : the final "+" of "+--min--+" must be shifted one character to the right
    line 4937, near >>-TRANSLATE( :
        the closing parenthesis is not at the right place, must be after the last parameter
        the three lines of the last block "+-pos-+  +-,length-+" must be moved one line upper
        (to be similar to string~translate)
        BUT... Seems still not good to me : TRANSLATE("abcdef", , , , 2, 3) is NOT allowed by the diagram
        pos and length should be declared optional in the continuation of pad (I think)
rexxref\fundclasses.sgml :
    line 2719, near >>-caselessCompareTo( : a " " must be replaced by "-"
    line 2881, near >>-caselessMatch( : the last "+" must be shifted to the right, to align it with the upper "+"
    line 3189, near >>-compareTo( : a " " must be replaced by "-"
    line 4097, near >>-match( : the last "+" must be shifted to the right, to align it with the upper "+"
    line 4169, near >>-max-+ : replace the "." by "+" (or the "+" by ".")
    line 4199, near >>-min-+ : replace the "." by "+" (or the "+" by ".")
    line 5603, near >>-call-+ : replace the "." by "+" (or the "+" by ".")
    line 4669, near >>-translate : the last "+" must be shifted to the right, to align it with the upper "+"
        This syntax diagram seems not good : translate(, , , 3, 2) is NOT allowed by the diagram
rexxref\instrc.sgml :
    line 388, near >>-CALL : must end with ><
    line 388, near >>-CALL : replace the space after name- by "-"
    line 390, near >>-CALL : must align the end choice with the upper "+"
rexxref\intro.sgml :
    line 1900, near >>-receiver-+ : replace "+" by "." (or "." by "+")
rexxref\preface.sgml :
    line 163, near |--expansion : this syntax diagram must be put in CDATA to be recognized.
rexxref\rexutil.sgml :
    line 2029, near >>-SysGetMessage( :
        not supported, the 2nd "+" has no counterpart (must have a -+-, not just a -+)
        solution : do a clean separation for each end of choice
    line 2035, near >>-SysGetMessage( : the 2nd "+" must be shifted one character left, to be aligned
    line 2086, near >>-SysGetMessageX( :
        not supported, the 2nd "+" has no counterpart (must have a -+-, not just a -+)
        solution : do a clean separation for each end of choice
    line 2212, near 2nd >>-SysIni( : the line must be shifted 10 characters to the left
    line 3366, near >>-SysShutdownSystem( :
        replace "*" by "+"
        not supported, the 2nd "+" has no counterpart (must have a -+-, not just a -+)
        solution : do a clean separation for each end of choice
rexxref\utilityclasses.sgml :
    line 141, near >>-fromNormalDate( : the 3rd "+" has no counterpart
    line 169, near >>-fromEuropeanDate( : the 3rd "+" has no counterpart
    line 199, near >>-fromOrderedDate( : the 3rd "+" has no counterpart
    line 228, near >>-fromStandardDate( : the 3rd "+" has no counterpart
    line 256, near >>-fromUsaDate( : the 3rd "+" has no counterpart
    line 446, near >>-init(year,month,day-+ : the last "+" must be replaced by ")"
    line 3303, near >>-caselessMatch( : the last "+" must be shifted to the right, to be aligned
    line 3718, near >>-match( : the last "+" must be shifted to the right, to be aligned
    line 3993, near >>-translate : the last "+" must be shifted to the right, to align it with the upper "+"
        This syntax diagram seems not good (same problem as string~translate)
rxftp\rxftp :
    line 1096, near myftpobj~FtpSetUser( : the 2nd "+" has no counterpart

Remember, fragments :
rexxref\funct.sgml : Stream commands
rexxref\instrc.sgml : DO repetitor, conditional
rexxref\instrc.sgml : LOOP repetitor, conditional
rexxref\instrc.sgml : RAISE options, options exit
rexxref\streamclasses.sgml : Stream commands
rexxref\streamclasses.sgml : Stream open
winextensions\winregistry.sgml : open access


Todo : Implement -dsssl, -xslt and -xinclude.


===============================================================================
2009 august 09

Renamed makevalidxml to transformfile because the script is not limited to
making a valid XML file.

Added transformdir which lets process all the sgml files of a given directory.
Transformation in place is not allowed, must pass an output directory different
from input directory. Does not process recursively, so must process separately
each directory under trunk.
Ex :
rexx transformdir.rex trunk/rexxref trunk/rexxref.new

A minimal conformity checking is done, and some errors are found :
buildmachine\vmware.sgml
    line 2 : missing closing ">" : <title
oodialog\editcontrolc.sgml
    line 1393 : Uppercase "L" in <Listitem>
    line 1501 : Uppercase "L" in <Listitem>
    line 1573 : Uppercase "L" in <Listitem>
    line 1643 : Uppercase "L" in <Listitem>
oodialog\progressbarc.sgml
    line 173 : Missing quotes around mthStep in <link linkend=mthStep>
    line 180 : Missing quotes around mthStep in <section id=mthStep>
oodialog\windowBaseCommon.sgml
    Lot of errors because railroad not in cdata
    For the moment, I skip this file when iterating over the sgml files
oodialog\windowExtensionsCommon.sgml
    Lot of errors because railroad not in cdata
    For the moment, I skip this file when iterating over the sgml files
readme\newinrelease.sgml
    line 407 : Insert the missing </listitem></varlistentry> after </para>
               to close <varlistentry> at line 401 and <listitem> at line 402
readme\windows.sgml
    line 107 : <para> has no closing </para>
    line 510 : <para> has no closing </para>
rexxpg\api.sgml
    line 4294 : <</para>
rexxpg\classicapi.sgml
    line 3042 : missing closing ">" : </title
rexxref\instrc.sgml
    line 3576 : Use &lt; instead of "<" in <computeroutput><=</computeroutput>
winextensions\windowmanager.sgml
    line 56 : lower case <computeroutput>winSystm.cls</COMPUTEROUTPUT>
winextensions\wineventlog.sgml
    line 55 : lower case <computeroutput>winSystm.cls</COMPUTEROUTPUT>

Except these errors, all the sgml files are parsed correctly. A diff between the
original version and the generated file shows zero difference.
Unbalanced <imagedata> and <colspec> are supported (that will be easy to generate
a valid XML with balanced tags).
In fact, I realize it will be easy to do a roundtrip sgml docbook-->xml docbook
and vice versa.

Todo : Implement -dsssl, -xslt and -xinclude.


===============================================================================
2009 july 26

[out of subject, but...]
Continuation of the profiling of csvStream.
Valgrind gives the total number of instructions executed during the profiling.
stream :                   38 770 387 when reading all_cp_docs-500.txt (1 title line, 498 data lines)
csvStream :             1 104 254 540 when reading the same file
csvStreamBufferized :   1 212 977 855 when reading the same file
ratio is 28:1 for csvStream compared to stream
ratio is 31:1 for csvStreamBufferized compared to stream

See http://jean-louis.faucher.perso.neuf.fr/ooRexx/profiling/csv/
In the directories stream, csvStream and csvStreamBufferized, there are :
callgrind.out.1 : profiling datas when working on all_cp_docs-1.txt (1 title line, 1 data line)
callgrind.out.500 : profiling datas when working on all_cp_docs-500.txt (1 title line, 498 data lines)
main-1.png : callgraph with cumulative instructions numbers on each node (the top-level node is 100%)
main-500.png : idem

I'm investigating why there is a so big difference between the stream implementation
and the two other implementations based on the class csvStream (I have the same problem
with the XML parser).

stream : main.1         main =     9 835 350 instructions
stream : main.500       main =    31 172 287 instructions
ratio = 3.17

csvStream : main.1      main =    17 712 222 instructions
csvStream : main.500    main = 1 096 656 440 instructions
ratio = 61.92 !!!!!

Similar results for csvStreamBufferized (even slightly worst, which is surprising...)

To analyze the profiling data, you need kcachegrind. With this tool, you can sort the nodes
by individual cost (local instruction number, call counter) and see the associated source.


===============================================================================
2009 july 18

[out of subject, but...]
Continuation of the previous observation about performance : I use valgrind
to profile the execution of csvStreamBufferized under Linux.
During the study, I discovered a bug with relative paths under Linux, which
took me some time to analyze and (partially) fix.
Did not spent more time on profiling this day...


===============================================================================
2009 july 13

I made a test on one of my XML files :
3908 Kb, 98261 node(), 53510 text()
Conclusion : it's *very* slow... About 15 min to process the file !

I made already the same observation for the class csvStream :
Reading a file which contains 243658 lignes made of 12 fields :
- without csvStream (only line=stream~linein; parse var line...) : 00:00:04
- with csvStream : 00:03:24, 50 times slower !!!
- with csvStreamBufferized (a version where I use MutableBuffer) : 00:03:38 (!)

Since I use MutableBuffer, the problem is not in the construction of strings by
appending one character at a time...
It's not either in the fact I create an instance of MutableBuffer for each XML tag,
because in csvStreamBufferized I create the buffer only once and reset it at each line.


===============================================================================
2009 july 12

The first step has been reached...
The command makevalidxml can read a SGML file and print it to stdout unchanged (same layout).
But behind the scene, I have all the informations needed to transform the XML where needed.
The following options remain to implement :
-fix
-xinclude


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

I need effectively to modify the XML parser, to keep the text as-is :
- getchar returns EOL as any other char.
- Each chunk has a value in its text property, to be used for printing as-is.


Things to fix to have a valid XML :

<?xml version="1.0" standalone="no">
must be
<?xml version="1.0" standalone="no"?>

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.2//EN"
must have a system identifier
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"

<imagedata> must be completed by </imagedata>
<colspec> must be completed by </colspec>


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

First step :
I want to see if I can read an sgml file with the XML parser, and dump it almost as-is
(I want to keep the current layout in the files).
I don't know if I can do that only by overriding the public methods, so I made a
copy of the parser.

Second step :
Generate a valid XML file.

Third step :
Write a script which iterates over the sgml files from a given root and generates
a valid XML file for each sgml file.

For the moment, nothing implemented...
