473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem when Loading XSL file using XslCompiledTran sform

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.Tr ustedXslt ans use
the following statement to load xsl file:

objxslcompiledt ransform.Load(i nput, XsltSettings.Tr ustedXslt , new
XmlUrlResolver( ));

Can anyone tell me what is happening here?

Sample Xsl script:
<msxsl:script language="javas cript" implements-prefix="js">
<![CDATA[
// insert any JS needed here.

function datePassed(pstr Date) {
return (new Date(pstrDate.t ext) < new Date());
}
</msxsl:script>

Jul 5 '06 #1
2 2518
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(pstr Date) {
return (new Date(pstrDate.t ext) < 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="javas cript" implements-prefix="js">
<![CDATA[
// insert any JS needed here.

function datePassed(pstr Date) {
return (new Date(pstrDate.t ext) < 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="currentDa te" />
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 XPathNodeIterat or thus your
extension function needs to use the XPathNodeIterat or API
<http://msdn2.microsoft .com/en-us/library/system.xml.xpat h.xpathnodeiter ator.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
2858
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 parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
5
1497
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 I load another Xml document using document("http://localhost/myfile.xml") syntax. I use XmlUriResolver object with credentials set to DefaultCredentials and pass it to the Transform method.
1
8026
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 tags that I don’t want, example: * My XSLT has: <script language="javascript" src="client_scripts/VehInInv.js"></script> * Using the XslCompiledTransform class I get: <script language="javascript" src="client_scripts/VehInInv.js"/> -- notice...
4
4337
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 application crashes with the same error message I would get when writing <brand no closing tag. To make everything a little stranger, even <br></brseems to be bad while <lbr/is fine. Ive tried some other tag names and the problem only appears with...
2
6344
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 Newline characters (CHR 10) is getting translated to Carriage Return and New Line (CHR 13 and CHR 10) causing problems in the display.
3
10983
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 Missing please? MemoryStream strm = new MemoryStream(); XmlWriter writer = XmlWriter.Create(strm);
8
22967
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 = new XslCompiledTransform(); myXslTrans.Load("sortByExtension.xsl"); XmlTextWriter myWriter = new XmlTextWriter("result.xml", null); myXslTrans.Transform(tvXML, null, myWriter); myWriter.Close();
5
2851
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... something like this being changed into this
1
1930
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(); l_xslt.Load(xsl_document_location); l_xslt.Transform(l_nav, null, output_stream); //l_xslt.Transform(l_nav, null, new StreamWriter("TRANSFORMED.html"));
0
8675
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.