473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem when Loading XSL file using XslCompiledTransform

Jon
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>

Jul 5 '06 #1
2 2494
Jon wrote:
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.

--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Jul 6 '06 #2


Jon wrote:

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>
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.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
5
by: Lis | last post by:
Hi, I have inconsistent behavior of document() function which I hope someone can explain. I have Windows Service (runs as LocalSystem) that perform some Xslt transformation. In the stylesheet...
1
by: mikepmyers | last post by:
I've done some research online and turned up with results that did not sit well with me. I’m using the System.Xml.XslCompiledTransform class as recommended by MS; however, it’s creating self-closing...
4
by: Christofer Dutz | last post by:
Hi, I am having a small problem, that is driving me nuts. My application reads some Xml and runs 2 Xsl Transformations to generate HTML. As soon as my second XSL introduces some <br/tags, the...
2
by: =?Utf-8?B?WVMgUmFt?= | last post by:
(Sorry if this post appears twice, as I couldn't see my initial post after 4 hours) Hi, I am using XML XSL to create a CSV file using Transformation. But during the transformation all the...
3
by: J055 | last post by:
Hi I'd like to get a populated datatable, create an in memory xml document (file shouldn't be more than a couple of meg), load an XSLT file, do a transform and stream it to a browser. What am I...
8
by: ajc308 | last post by:
I am using C# to transform an XML document which actually outputs another XML document using XslCompiledTransform and an XmlTextWriter. The code I am using is: XslCompiledTransform myXslTrans...
5
by: =?Utf-8?B?Um9iZXJ0?= | last post by:
Hello all, I have an XmlException being thrown trying to use XslCompiledTransform while using the google api. My suspicion is there is some html decoding happening that I want to prevent... ...
1
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have a piece of code that looks like this: XPathNavigator l_nav = xml_document.DocumentElement.CreateNavigator(); XslCompiledTransform l_xslt = new XslCompiledTransform();...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.