external program call

Here should go questions about transforming XML with XSLT and FOP.
romuld
Posts: 2
Joined: Sat Jun 07, 2008 6:12 pm

external program call

Post by romuld »

Hello!
Can I use xslt transforming if I need to call some external program?

For example, during processing <mytag input_name="somename"/> by the template
<xsl:template match="mytag">
<xsl:variable name="output_name" select="concat('url(',$input_name,'.png',')')"/>
<!-- Here I need call to "my_program $output_name" -->
</xsl:template>

need call external executable "my_program", with parameters. I.e. some equivalent of 'exec' or 'system' in C-language.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: external program call

Post by sorin_ristache »

Hello,

You cannot call an external program from an XSLT stylesheet. You can do that only from an XSLT extension used in an XSLT stylesheet. In the implementation of an extension function or extension element you can do any processing allowed by the language used for writing the extension, including calling an external program. For example look here for Saxon extensions and here for Xalan extensions.


Regards,
Sorin
romuld
Posts: 2
Joined: Sat Jun 07, 2008 6:12 pm

Re: external program call

Post by romuld »

Thank you!
In Saxon it works!

This is an expression to call notepad.exe in Windows:
<xsl:value-of select="Runtime:exec(Runtime:getRuntime(), 'notepad.exe')"
xmlns:Runtime="java:java.lang.Runtime"/>
mjmanthey
Posts: 3
Joined: Sat Sep 20, 2008 4:46 am

Re: external program call

Post by mjmanthey »

When I transform the stylesheet (mentioned in this thread) extenally using Saxon (Transform.exe), I always get the following output:

<?xml version="1.0" encoding="UTF-8"?>java.lang.VMRuntime$DotNetProcess@38248fc

Does anyone see this? Is there anyway to prevent the output?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: external program call

Post by sorin_ristache »

Hello,

It seems the .NET 1.1 framework is not installed or is not installed correctly on your Windows computer. I assume you refer to the Saxon.NET distribution, not the Saxon processor as Java library. Saxon.NET requires the .NET 1.1 framework available from the Microsoft website to be installed. Can you check that .NET 1.1 is installed correctly on your computer?

The same requirement is valid for using Saxon.NET in Oxygen as documented in the User Manual.


Regards,
Sorin
Post Reply