Groups | Blog | Home
all groups > dotnet xml > july 2005 >

dotnet xml : Question about XSLTransform and extensions


fawzib.rojas NO[at]SPAM gmail.com
7/7/2005 1:28:28 PM
I have the following class and function:

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

public void Transform(XmlDocument xml,XmlDocument xsl){
XPathDocument xp_doc;
XslTransform xsl_trans;
XsltArgumentList xslArg = new XsltArgumentList();
MathExtension ex=new MathExtension();
// add extension
xslArg.AddExtensionObject("xalan://java.lang.Math",ex);
// create and load objects
xp_doc=new XPathDocument(new XmlNodeReader(xml));
xsl_trans=new XslTransform();
xsl_trans.Load(
new XmlNodeReader(xsl),null,Assembly.GetCallingAssembly().Evidence
);
// do transformation
xsl_trans.Transform(xp_doc,xslArg,new XmlNodeWriter(FDoc,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?
Martin Honnen
7/8/2005 12:00:00 AM


[quoted text, click to view]


[quoted text, click to view]

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
AddThis Social Bookmark Button