473,769 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about XSLTransform and extensions

I have the following class and function:

class MathExtension{
public double max(double a,double b){
Console.WriteLi ne("math:max("+ a.ToString()+", "+b.ToString()+ ")");
return Math.Max(a,b);
}
}

public void Transform(XmlDo cument xml,XmlDocument xsl){
XPathDocument xp_doc;
XslTransform xsl_trans;
XsltArgumentLis t xslArg = new XsltArgumentLis t();
MathExtension ex=new MathExtension() ;
// add extension
xslArg.AddExten sionObject("xal an://java.lang.Math" ,ex);
// create and load objects
xp_doc=new XPathDocument(n ew XmlNodeReader(x ml));
xsl_trans=new XslTransform();
xsl_trans.Load(
new XmlNodeReader(x sl),null,Assemb ly.GetCallingAs sembly().Eviden ce
);
// do transformation
xsl_trans.Trans form(xp_doc,xsl Arg,new XmlNodeWriter(F Doc,true),null) ;
}

when I do a transformation and use something like:

<xsl:value-of select="my_obj: max(number(@an_ attribute),0.01 )"/>

The first parameter always says "NaN", what am I doing wrong? Is there
a problem with the number() function? is there another way to do it?

Nov 12 '05 #1
1 1102


fa**********@gm ail.com wrote:

when I do a transformation and use something like:

<xsl:value-of select="my_obj: max(number(@an_ attribute),0.01 )"/>

The first parameter always says "NaN", what am I doing wrong?


What is the context node in that xsl:value-of select expression, does it
have an attribute named @an_attribute, which value does the attribute have?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

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

Similar topics

5
611
by: Victor Fees | last post by:
I have an XML string in a database that I would like to display using XSLT. All of that works like a champ, but I can't figure out how to embed the XML inside an ASPX page. For example, I have an ASPX page with a Header User Control and a Footer User Control. I'd like to put the transformed XML right in the middle. It seems like this is something that should be doable, but I can't quite figure it out. Is anyone out there doing this,...
2
5822
by: Anthony Bouch | last post by:
Can anyone tell me why I receive the following compiler warning after having recently upgraded to VS.Net 2003 and .Net 1.1? Warning CS0618: 'System.Xml.Xsl(System.Xml.XPath.IXPathNavigable, System.Xml.Xsl.XsltArgumentList, System.Xml.XmlWriter)' is obsolete: 'You should pass XmlResolver to Transform() method' XPathDocument xmlData = new XPathDocument(memStream); XslTransform xslTransform = new XslTransform();...
1
1892
by: Rodger McNab | last post by:
While parsing xpath expressions within an XSLT document the .NET XslTransform class seems to delete the first "/" after a "]" within an expression containing a "|". This problem can be demonstrated by the following short C# program. The program throws an exception saying that "ac" is an invalid XPath expression. using System; using System.Xml; using System.Xml.XPath; using System.Xml.Xsl;
1
1963
by: NicoAgenci | last post by:
Hello, I have a page in .net (DEFAULT.ASPX), i load a XmlDocument, and a XslTransform to Add a XsltArgumentList (with the param : urlPage), and send all to a <asp:xml> in the page. The <asp:xml> is good with xml and xsl, but the param is not fill with the value ? Do you have a solution ??? Thanx
2
6044
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public XmlDocument TransformXmlDoc(XmlDocument docToTransform, string xsltFilePath) { //load the xslt
3
2270
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We use this so that we can specify different templates to be used by the same xml node. Know that we could use global params, but would rather not have to update all teh stylesheets and any code that uses msxml and the same stylesheets.
1
1135
by: shell shell via .NET 247 | last post by:
How do you get the underlying Xslt stylesheet content from an XslTransform object that has been created and loaded with a stylesheet file or some text? Assume a method will create an XslTransform object, load it with a stylesheet file or some text, and return this object. public XslTransform Create() { XslTransform xslt = new XslTransform(); xslt.Load("style.xsl"); //or load with some built-in stylesheet text return xslt; }
1
2795
by: manlio | last post by:
how can I load a XSL string (not an xsl file!!) with XslTransform ??? If I use the code: // Create a new XslTransform class and load the stylesheet XslTransform myXslTransform = new XslTransform(); myXslTransform.Load("myFile.xsl"); it run, but I need load an XSL string:
0
223
by: Mike | last post by:
Hello, I am using XML webcontrol on my form to display my transformed xml as html. I am having a warning about using XslTransform (being obsolete). The warning told me to use the new class XslCompiledTransform. The problem is the XML control only accepts the XslTransform object for its .Transform property. See code below. Any ideas? Thanks
0
9589
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
10045
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
9994
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,...
1
7408
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
6673
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
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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
3561
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.