Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

Problem when Loading XSL file using XslCompiledTransform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jon - 05 Jul 2006 19:34 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.