Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - calling executable during transformation >Thread Next - Re: calling executable during transformation Re: calling executable during transformationTo: NULL Date: 3/3/2006 10:01:00 PM
<anywherenotes@g...> wrote in message
news:1141418119.940806.139100@p......
> Is there a way to call executable while performing xslt?
> So what I need, is to open an xml file (with embeded xsl document) in
> IE, and xsl would run executable to get part of data.
>
> My xml document contains data that has to be passed to executable to
> get additional data, for example, by document can contain stock name,
> and executable can lookup the price of the stock based on the name, so
> that the final output (on IE screen) would contain the stock name and
> price.
> The xml file and program are not looking up stock symbols, I am just
> trying illustrate why one would need this functionality.
>
> Is it possible to do what I am describing? (calling executable from xsl
> file?)
> This is not intended to hack anyone's system. The file will be on the
> machine on which the browser is being opened, it's not being downloaded
> off the internet - it's a local file, so no security issues.
>
> Thank you.
> Alex
XSL will be subject to the same restrictions a IE.
But it would be something like this:-
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:script="urn:schemas-mycompany-com:script"
>
<xsl:output method="xml" encoding="UTF-8" />
<msxsl:script language="JScript" implements-prefix="script">
function myFunc(nodelist) {
var aObject = new ActiveXObject("myLib.myClass")
return aObject.DoSomething(nodelist)
}
</msxsl:script>
<xsl:template match="/ | @* | * | node()">
<xsl:copy>
<xsl:apply-templates select="@* | * | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="stkcode">
<xsl:copy><xsl:value-of select="script:myFunc(.)" /></xsl:copy>
</xsl:template>
</xsl:stylesheet>
In this example all elements with the tag 'stkcode' are passed to a method
called DoSomething on an instance of a myLib.myClass object. The return
value is inserted in to the output.
Your myLib.dll will need to be installed and marked safe for scripting.
Anthony.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
