473,729 Members | 2,353 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 2535
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
2866
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
1503
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
8028
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
4341
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
6346
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
10992
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
22974
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
2857
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
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
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...
1
9200
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
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
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...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.