[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Shell execution from xslt


Subject: Re: [xsl] Shell execution from xslt
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 20 Sep 2014 22:35:11 -0000

> Hi everyone,
>
> Is anyone aware of any xslt library that supports calling shell commands? I
thinking about writing my own but wanted to know what is out there currently.

I'm not aware of anything.
>
> What I am thinking about is something like:
> <xsl:for-each select="shell('ls -1')/line">
> ...
> </xsl:for-each>
> where each line would be a line of shell output.
>
> I am also curious if within the constraints of the xslt spec, is it possible
to take streaming data from the return of an xpath function?
>

There are certainly no constraints in the spec.

In Saxon you can write a function that returns its results in the form of an
iterator; Saxon will access items from the iterator on demand. This means for
example that if you do

d:list-files()[1]

where list-files is implemented this way, it will call the extension function
to get the first item in the result sequence and then stop.

Given your example, however, in the case of Saxon it would be better to
implement the extension function in Java rather than in shell-script.

Michael Kay
Saxonica


Current Thread
Keywords