Hi,
I am testing the scenario to migrate from MSMXL4 to .NET2.0 system.xml. I
experienced xsl file loading problem whenever the xsl file have a user
defined script in it. The error message is as follow:
"Objects of type 'Script2' do not have such a member"
The above error only happens when I set the XsltSettings.TrustedXslt ans use
the following statement to load xsl file:
objxslcompiledtransform.Load(input, XsltSettings.TrustedXslt , new
XmlUrlResolver());
Can anyone tell me what is happening here?
Sample Xsl script:
<msxsl:script language="javascript" implements-prefix="js">
<![CDATA[
// insert any JS needed here.
function datePassed(pstrDate) {
return (new Date(pstrDate.text) < new Date());
}
</msxsl:script>
Oleg Tkachenko [MVP] - 06 Jul 2006 11:26 GMT
> I am testing the scenario to migrate from MSMXL4 to .NET2.0 system.xml.
You should be aware that MSXML supports scripts written in Javascript,
while .NET supports scripts written in JScript.NET language.
> function datePassed(pstrDate) {
> return (new Date(pstrDate.text) < new Date());
> }
Make sure this is valid JScript.NET.

Signature
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Martin Honnen - 06 Jul 2006 13:15 GMT
> Sample Xsl script:
> <msxsl:script language="javascript" implements-prefix="js">
[quoted text clipped - 5 lines]
> }
> </msxsl:script>
The object model exposed to script is very different on the .NET
platform compared to MSXML.
I don't know what your aims are, if you need a stylesheet that works
with both the .NET platform and MSXML, or if you can change the
stylesheet to completely work with .NET.
Anyway, for the above function all you want to do is to compare some
date with the current date, that can be solved in XSLT in a much more
portable manner without a script extension function by simply defining a
global parameter in the stylesheet
<xsl:param name="currentDate" />
and setting that parameter before you run a transformation.
If you want to use an extension function in .NET then see
<http://msdn2.microsoft.com/en-us/library/wxaw5z5e.aspx>
it explains how XSLT/XPath types (like node set) are exposed as .NET
types to script.
An XSLT/XPath node set is exposed as an XPathNodeIterator thus your
extension function needs to use the XPathNodeIterator API
<http://msdn2.microsoft.com/en-us/library/system.xml.xpath.xpathnodeiterator.aspx>
Let us know whether that helps, if not then show us exactly how you call
your function in the stylesheet and what type of argument you pass in.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/