[xsl] How to express this in XPath: "when condition do action" where condition cannot be evaluated until data arrives later

Subject: [xsl] How to express this in XPath: "when condition do action" where condition cannot be evaluated until data arrives later
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Dec 2022 18:45:10 -0000
Hi Folks,

I have an XSLT program that processes XML files in a folder. Some of the XML
documents contain data about a car, like this:

<Car>
    <Make>Toyota</Make>
    <Model>Avalon</Model>
    <LicensePlate>12345</LicensePlate>
</Car>

At some point the XSLT program reads in that XML document and begins
processing it. The objective of processing is to output the license plate
number if the car is stolen and "" (not stolen) otherwise. However, the
document does not contain the necessary information to make that decision. The
information to make the decision arrives some time later, in another document:

<PoliceReport>
    <Car>
        <LicensePlate>12345</LicensePlate>
        <Status>Stolen<Status>
    </Car>
</PoliceReport>

So the desired processing behavior is this:

Read the next XML document.
If the XML document contains data about cars then
    Wait until the police report arrives ....
    .......... time elapses ........... the police
    report arrives: if it says the car is stolen
    then output "stolen" else output ""

I want to express that!

And, I want to express it, not in an XSLT program, but in a single XPath
expression!

The UNIX shell has an analogous functionality that I describe now. The "trap"
command can be added into a shell program. The command has this form:

	trap command signal

It has this meaning: During execution of the shell program, if 'signal' is
received, then execute 'command'.

Here's an example to illustrate how it may be used ('2' is the signal for the
user pressing Ctrl+c; i.e., for the user terminating the program):

	trap "rm WORKDIR/file; exit" 2

That means: If the program is suddenly terminated (by the user pressing
Ctrl+c), remove 'file' from the WORKDIR folder and then exit.

I want that kind of functionality! In XPath!

Is it possible to achieve that functionality using XPath? Or is this outside
the realm of XPath capabilities?

/Roger

For my own notes:

Potentially relevant information:

Michael Kay Balisage paper: Asynchronous XSLT

https://www.balisage.net/Proceedings/vol25/html/Kay01/BalisageVol25-Kay01.htm
l

Xalan-J Thread.sleep() function: all links I followed failed. Still
available?

Java Sleep() function:
https://www.geeksforgeeks.org/thread-sleep-method-in-java-with-examples/

Current Thread