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

Subject: Re: [xsl] How to express this in XPath: "when condition do action" where condition cannot be evaluated until data arrives later
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Dec 2022 22:39:03 -0000
On 12/19/2022 7:45 PM, Roger L Costello costello@xxxxxxxxx wrote:
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?

I don't think the current language has anything like that, the closest I
have ever heard is indeed the Asynchronous XSLT talk/paper by Michael
Kay you cite below.

And in the context of asynchronous programming/APIs a few days ago the
oXygen guys presented a webinar about OpenAPI and AsyncAPI, I think,
integrated into oXygen 25. But I don't think any of that is tied so far
to XPath in oXygen or XPath with Saxon in oXygen, it is just another
feature in oXygen to design/explore/consume/test APIs defined according
to those two ways, not related to XML or XPath.



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

Current Thread