[xsl] how to make a progress report in XSLT? (was "how to make a log file in XSLT?"

Subject: [xsl] how to make a progress report in XSLT? (was "how to make a log file in XSLT?"
From: "Jean-Luc Chevillard jeanluc.chevillard@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Mar 2023 12:51:37 -0000
Dear XSLT list members,

thanks to all those who answered my message of yesterday evening, available
at
https://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/202303
/msg00021.html

After reading Michael Kay's recommendation of "using xsl:message for
this, with a message listener that directs the output accordingly",
I read pp. 386-390 inside his 2008 big RED BOOK, which has been on my
shelf for a long time and which I consult frequently, but I realized
that using a "message listener" was not something I could do easily
without changing my focus, because I did not even know where to start.

The suggestion by Martin Honnen to "fool Saxon" is certainly above my
level of competence.

The suggestion by Liam R.E. Quin to use B+expath's file:read and
file:write, with fn:serialize()B; was also to high-flying for me

The remark by Dimitre Novatchev that B+requirement that the "log file"
must be an XML document is too-restricting in this problemB; made me
realize that I probably had not stated clearly why I wanted to have
what I called, probably erroneously, a "log file".

What I want to do is to record automatically, one by one, all the
small steps which represent, day after day, progress in long tasks of
data entering.

And after one month, or two months, or one year, etc, I can for
instance analyse the speed, and extrapolate the date of completion for
this or that aspect and have reasonable goals, and possibly define new
targets

I use XML and XSLT (with the help of oXygen) in order to prepare
electronic editions of ancient Tamil texts, some of which are
available on palm-leaf MSS,
and having a Tree-structured set of data (thanks to XML) is a great
advantage but I must keep a balance between
-- the time I spend entering data in XML, and analysing it
-- the time I spend creating new XSLT scripts or improving old ones.

It has now occurred to me that I should simply use
"xsl:result-document" for creating a new "small report" (with a name
based on the date and time), inside a dedicated "log" directory, each
time I run a given script.

For those who would like to see the type of data I am dealing with,
some html files created on the basis of a master XML file and of a
collection of images are available at

http://netamil.manuscript-cultures.uni-hamburg.de/na/jlc/cEnA/List_of_images_
(and_duplicates).html

With a modified version of my "log_book_experiment.xslt" script, I
have just created one small time-bound elementary report concerning a
single feature

The time bound report is called:

LOG_2023_03_13__12-48.xml

Its content is

++++++++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<item>At [2023-03-13 (12:48)], the number of processed rectangles is
310.</item>
++++++++++++++++++++

The modified  "log_book_experiment.xslt" script is provided at the bottom

My goal is to forget, most of the time, that these reports are
created, but from time to time to remember them, to find one hundred
of them  and to paste them together in a larger PROGRESS REPORT.

Inside each item, the relevant elements will of course be put inside
tags, for processing, but this first try wanted to be Human-readable
rather than Machine-readable.

Thanks for further additional suggestions

Best wishes to all

-- Jean-Luc Chevillard

https://htl.cnrs.fr/equipe/jl-chevillard/

++++++++++++++++++++++++++++++++++++++++++++++++++++
NEW VERSION OF THE "log_book_experiment.xslt" SCRIPT
++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:import href="copy.xslt"/>

    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:variable name="TIME_STAMP"
select="concat('[',format-date(current-date(), '[Y]-[M02]-[D02]'), '
(', format-time(current-time(), '[H]:[m]'), ')]')"/>

    <xsl:variable name="Time_bound_log_file_name"
        select="concat('log/LOG_',format-date(current-date(),
'[Y]_[M02]_[D02]'),'__',format-time(current-time(),
'[H01]-[m01]'),'.xml')"/>


    <xsl:template match="/">
        <xsl:message>Log file name will be B+<xsl:value-of
select="$Time_bound_log_file_name"/>B;.</xsl:message>
        <xsl:result-document href="{$Time_bound_log_file_name}">
            <item>At <xsl:value-of select="$TIME_STAMP"/>, the number
of processed rectangles is <xsl:value-of
select="count(//rectangle/status[string()='m'])"/>.</item>
        </xsl:result-document>
        <xsl:apply-templates select="root"/>
    </xsl:template>

</xsl:stylesheet>

Current Thread