From: Oleg T. <he...@us...> - 2005-10-29 21:14:44
|
Update of /cvsroot/mvp-xml/EXSLT/v2/src/Exslt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23054/v2/src/Exslt Modified Files: AssemblyInfo.cs Exslt.csproj ExsltContext.cs ExsltDatesAndTimes.cs ExsltMath.cs ExsltNamespaces.cs ExsltSets.cs ExsltTransform.cs GDNSets.cs Makefile Removed Files: ExsltNodeList.cs Log Message: Index: ExsltNamespaces.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/ExsltNamespaces.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ExsltNamespaces.cs 16 Oct 2005 20:07:08 -0000 1.1 +++ ExsltNamespaces.cs 29 Oct 2005 21:14:35 -0000 1.2 @@ -2,7 +2,7 @@ /// <summary> /// Exslt (and other) namespaces constants. /// </summary> - public class ExsltNamespaces { + public static class ExsltNamespaces { public const string DatesAndTimes = "http://exslt.org/dates-and-times"; public const string Math = "http://exslt.org/math"; public const string Random = "http://exslt.org/random"; Index: GDNSets.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/GDNSets.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- GDNSets.cs 16 Oct 2005 20:07:08 -0000 1.1 +++ GDNSets.cs 29 Oct 2005 21:14:35 -0000 1.2 @@ -1,9 +1,12 @@ #region using using System; -using System.Collections; +using System.Collections.Generic; using System.Xml.XPath; using System.Xml; +using System.Web.UI; + +using Mvp.Xml.Common.XPath; #endregion @@ -29,8 +32,8 @@ if(nodeset1.Count > 125 || nodeset2.Count > 125) return subset2(nodeset1, nodeset2); //else - ExsltNodeList nodelist1 = new ExsltNodeList(nodeset1, true); - ExsltNodeList nodelist2 = new ExsltNodeList(nodeset2, true); + XPathNavigatorIterator nodelist1 = new XPathNavigatorIterator(nodeset1, true); + XPathNavigatorIterator nodelist2 = new XPathNavigatorIterator(nodeset2, true); foreach(XPathNavigator nav in nodelist1) { @@ -38,9 +41,7 @@ { return false; } - } - - + } return true; } @@ -59,16 +60,15 @@ /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public bool subset2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2) { - ArrayList arDocs = new ArrayList(); + List<Pair> arDocs = new List<Pair>(); - ArrayList arNodes2 = new ArrayList(nodeset2.Count); + List<XPathNavigator> arNodes2 = new List<XPathNavigator>(nodeset2.Count); while(nodeset2.MoveNext()) { arNodes2.Add(nodeset2.Current.Clone()); } - auxEXSLT.findDocs(arNodes2, arDocs); while(nodeset1.MoveNext()) --- ExsltNodeList.cs DELETED --- Index: Makefile =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile 16 Oct 2005 20:07:08 -0000 1.1 +++ Makefile 29 Oct 2005 21:14:35 -0000 1.2 @@ -1,7 +1,7 @@ all: @echo off @echo ########### Building Exslt library... - csc /out:Mvp.Xml.Exslt.dll /target:library *.cs MultiOutput\*.cs /debug- /optimize+ + csc /out:Mvp.Xml.Exslt.dll /target:library *.cs MultiOutput\*.cs /debug- /optimize+ /r:Mvp.Xml.Common.dll nmake rename-methods rename-methods: Index: ExsltDatesAndTimes.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/ExsltDatesAndTimes.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ExsltDatesAndTimes.cs 16 Oct 2005 20:07:08 -0000 1.1 +++ ExsltDatesAndTimes.cs 29 Oct 2005 21:14:35 -0000 1.2 @@ -1832,7 +1832,7 @@ public string parseDate(string d, string format){ try{ DateTime date = DateTime.ParseExact(d, format, CultureInfo.CurrentCulture); - return XmlConvert.ToString(date); + return XmlConvert.ToString(date, XmlDateTimeSerializationMode.RoundtripKind); }catch(FormatException){ return ""; } Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/AssemblyInfo.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AssemblyInfo.cs 16 Oct 2005 20:07:08 -0000 1.1 +++ AssemblyInfo.cs 29 Oct 2005 21:14:35 -0000 1.2 @@ -11,12 +11,6 @@ // [assembly: AssemblyTitle("Mvp.Xml.Exslt")] [assembly: AssemblyDescription("MVP XML Library - EXSLT.NET Module")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: CLSCompliant(true)] @@ -34,32 +28,3 @@ [assembly: AssemblyVersion("2.0.*")] -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\<configuration>. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -//Signed in custom build - see Makefile -//[assembly: AssemblyKeyFile("exslt.snk")] -[assembly: AssemblyKeyName("")] Index: ExsltTransform.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/ExsltTransform.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ExsltTransform.cs 16 Oct 2005 20:07:08 -0000 1.1 +++ ExsltTransform.cs 29 Oct 2005 21:14:35 -0000 1.2 @@ -4,133 +4,134 @@ using System.Xml.Xsl; using System.Xml; using System.Xml.XPath; -using System.IO; +using System.IO; using System.Text; +using System.CodeDom.Compiler; #endregion namespace Mvp.Xml.Exslt { - /// <summary> - /// Enumeration used to indicate an EXSLT function namespace. - /// </summary> - [Flags] - public enum ExsltFunctionNamespace{ - None = 0, - Common = 1, - DatesAndTimes = 2, - Math = 4, - RegularExpressions = 8, - Sets = 16, - Strings = 32, - GDNDatesAndTimes = 64, - GDNSets = 128, - GDNMath = 256, - GDNRegularExpressions = 512, - GDNStrings = 1024, - Random = 2048, - GDNDynamic = 4096, - AllExslt = Common | DatesAndTimes | Math | Random | RegularExpressions | Sets | Strings, - All = Common | DatesAndTimes | Math | Random | RegularExpressions | Sets | Strings | - GDNDatesAndTimes | GDNSets | GDNMath | GDNRegularExpressions | GDNStrings | GDNDynamic - } - - /// <summary> - /// Transforms XML data using an XSLT stylesheet. Supports a number of EXSLT as - /// defined at http://www.exslt.org - /// </summary> - /// <remarks> - /// XslTransform supports the XSLT 1.0 syntax. The XSLT stylesheet must use the - /// namespace http://www.w3.org/1999/XSL/Transform. Additional arguments can also be - /// added to the stylesheet using the XsltArgumentList class. - /// This class contains input parameters for the stylesheet and extension objects which can be called from the stylesheet. - /// This class also recognizes functions from the following namespaces - /// * http://exslt.org/common - /// * http://exslt.org/dates-and-times - /// * http://exslt.org/math - /// * http://exslt.org/random - /// * http://exslt.org/regular-expressions - /// * http://exslt.org/sets - /// * http://exslt.org/strings - /// * http://gotdotnet.com/exslt/dates-and-times - /// * http://gotdotnet.com/exslt/math - /// * http://gotdotnet.com/exslt/regular-expressions - /// * http://gotdotnet.com/exslt/sets - /// * http://gotdotnet.com/exslt/strings - /// * http://gotdotnet.com/exslt/dynamic - /// </remarks> - public class ExsltTransform - { + /// <summary> + /// Enumeration used to indicate an EXSLT function namespace. + /// </summary> + [Flags] + public enum ExsltFunctionNamespace + { + None = 0, + DatesAndTimes = 1, + Math = 2, + RegularExpressions = 4, + Sets = 8, + Strings = 16, + GDNDatesAndTimes = 32, + GDNSets = 64, + GDNMath = 128, + GDNRegularExpressions = 256, + GDNStrings = 512, + Random = 1024, + GDNDynamic = 2056, + AllExslt = DatesAndTimes | Math | Random | RegularExpressions | Sets | Strings, + All = DatesAndTimes | Math | Random | RegularExpressions | Sets | Strings | + GDNDatesAndTimes | GDNSets | GDNMath | GDNRegularExpressions | GDNStrings | GDNDynamic + } - #region Private Fields and Properties - /// <summary> - /// Sync object. + /// Transforms XML data using an XSLT stylesheet. Supports a number of EXSLT as + /// defined at http://www.exslt.org /// </summary> - private object sync = new object(); + /// <remarks> + /// XslCompiledTransform supports the XSLT 1.0 syntax. The XSLT stylesheet must use the + /// namespace http://www.w3.org/1999/XSL/Transform. Additional arguments can also be + /// added to the stylesheet using the XsltArgumentList class. + /// This class contains input parameters for the stylesheet and extension objects which can be called from the stylesheet. + /// This class also recognizes functions from the following namespaces + /// * http://exslt.org/common + /// * http://exslt.org/dates-and-times + /// * http://exslt.org/math + /// * http://exslt.org/random + /// * http://exslt.org/regular-expressions + /// * http://exslt.org/sets + /// * http://exslt.org/strings + /// * http://gotdotnet.com/exslt/dates-and-times + /// * http://gotdotnet.com/exslt/math + /// * http://gotdotnet.com/exslt/regular-expressions + /// * http://gotdotnet.com/exslt/sets + /// * http://gotdotnet.com/exslt/strings + /// * http://gotdotnet.com/exslt/dynamic + /// </remarks> + public class ExsltTransform + { - /// <summary> - /// The XslTransform object wrapped by this class. - /// </summary> - private XslCompiledTransform xslTransform; - - /// <summary> - /// Bitwise enumeration used to specify which EXSLT functions should be accessible to - /// the ExsltTransform object. The default value is ExsltFunctionNamespace.All - /// </summary> - private ExsltFunctionNamespace _supportedFunctions = ExsltFunctionNamespace.All; + #region Private Fields and Properties - /// <summary> - /// Extension object which implements the functions in the http://exslt.org/math namespace - /// </summary> - private ExsltMath exsltMath = new ExsltMath(); + /// <summary> + /// Sync object. + /// </summary> + private object sync = new object(); - /// <summary> - /// Extension object which implements the functions in the http://exslt.org/random namespace - /// </summary> - private ExsltRandom exsltRandom = new ExsltRandom(); + /// <summary> + /// The XslTransform object wrapped by this class. + /// </summary> + private XslCompiledTransform xslTransform; - /// <summary> - /// Extension object which implements the functions in the http://exslt.org/dates-and-times namespace - /// </summary> - private ExsltDatesAndTimes exsltDatesAndTimes = new ExsltDatesAndTimes(); + /// <summary> + /// Bitwise enumeration used to specify which EXSLT functions should be accessible to + /// the ExsltTransform object. The default value is ExsltFunctionNamespace.All + /// </summary> + private ExsltFunctionNamespace _supportedFunctions = ExsltFunctionNamespace.All; - /// <summary> - /// Extension object which implements the functions in the http://exslt.org/regular-expressions namespace - /// </summary> - private ExsltRegularExpressions exsltRegularExpressions = new ExsltRegularExpressions(); + /// <summary> + /// Extension object which implements the functions in the http://exslt.org/math namespace + /// </summary> + private ExsltMath exsltMath = new ExsltMath(); - /// <summary> - /// Extension object which implements the functions in the http://exslt.org/strings namespace - /// </summary> - private ExsltStrings exsltStrings = new ExsltStrings(); + /// <summary> + /// Extension object which implements the functions in the http://exslt.org/random namespace + /// </summary> + private ExsltRandom exsltRandom = new ExsltRandom(); - /// <summary> - /// Extension object which implements the functions in the http://exslt.org/sets namespace - /// </summary> - private ExsltSets exsltSets = new ExsltSets(); + /// <summary> + /// Extension object which implements the functions in the http://exslt.org/dates-and-times namespace + /// </summary> + private ExsltDatesAndTimes exsltDatesAndTimes = new ExsltDatesAndTimes(); + + /// <summary> + /// Extension object which implements the functions in the http://exslt.org/regular-expressions namespace + /// </summary> + private ExsltRegularExpressions exsltRegularExpressions = new ExsltRegularExpressions(); + + /// <summary> + /// Extension object which implements the functions in the http://exslt.org/strings namespace + /// </summary> + private ExsltStrings exsltStrings = new ExsltStrings(); + + /// <summary> + /// Extension object which implements the functions in the http://exslt.org/sets namespace + /// </summary> + private ExsltSets exsltSets = new ExsltSets(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/dates-and-times namespace /// </summary> - private GDNDatesAndTimes gdnDatesAndTimes = new GDNDatesAndTimes(); - + private GDNDatesAndTimes gdnDatesAndTimes = new GDNDatesAndTimes(); + /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/regular-expressions namespace /// </summary> private GDNRegularExpressions gdnRegularExpressions = new GDNRegularExpressions(); - + /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/math namespace /// </summary> - private GDNMath gdnMath = new GDNMath(); - + private GDNMath gdnMath = new GDNMath(); + /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/sets namespace /// </summary> private GDNSets gdnSets = new GDNSets(); - + /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/strings namespace /// </summary> @@ -140,33 +141,30 @@ /// Extension object which implements the functions in the http://gotdotnet.com/exslt/dynamic namespace /// </summary> private GDNDynamic gdnDynamic = new GDNDynamic(); - + /// <summary> /// Boolean flag used to specify whether multiple output is supported. /// </summary> private bool _multiOutput = false; - #endregion + #endregion - #region Public Fields and Properties - -/// <summary> -/// Sets the XmlResolver used to resolve external resources when the -/// Transform method is called. -/// </summary> - public XmlResolver XmlResolver { set { this.xslTransform.XmlResolver = value; } } + #region Public Fields and Properties + + /// <summary> + /// Bitwise enumeration used to specify which EXSLT functions should be accessible to + /// the ExsltTransform object. The default value is ExsltFunctionNamespace.All + /// </summary> + public ExsltFunctionNamespace SupportedFunctions + { + set + { + if (Enum.IsDefined(typeof(ExsltFunctionNamespace), value)) + this._supportedFunctions = value; + } + get { return this._supportedFunctions; } + } -/// <summary> -/// Bitwise enumeration used to specify which EXSLT functions should be accessible to -/// the ExsltTransform object. The default value is ExsltFunctionNamespace.All -/// </summary> - public ExsltFunctionNamespace SupportedFunctions{ - set { if (Enum.IsDefined(typeof(ExsltFunctionNamespace), value)) - this._supportedFunctions = value; - } - get { return this._supportedFunctions; } - } - /// <summary> /// Boolean flag used to specify whether multiple output (via exsl:document) is /// supported. @@ -177,254 +175,419 @@ /// disabled by default. If you need multiple output support, set this property to /// true before the Transform() call. /// </summary> - public bool MultiOutput { - get { return _multiOutput; } - set { _multiOutput = value; } - } - - #endregion - - #region Constructors -/// <summary> -/// Constructor initializes class. -/// </summary> - public ExsltTransform(){ - this.xslTransform = new XslCompiledTransform(); - } - - #endregion - - #region Load() method Overloads - /// <summary> Loads the XSLT stylesheet contained in the IXPathNavigable</summary> - public void Load(IXPathNavigable ixn){ this.xslTransform.Load(ixn); } + public bool MultiOutput + { + get { return _multiOutput; } + set { _multiOutput = value; } + } + /// <summary> + /// Gets an <see cref="XmlWriterSettings"/> object that contains the output + /// information derived from the xsl:output element of the style sheet. + /// </summary> + public XmlWriterSettings OutputSettings + { + get { return xslTransform.OutputSettings; } + } - /// <summary> Loads the XSLT stylesheet specified by a URL</summary> - public void Load(string s){ this.xslTransform.Load(s); } + /// <summary> + /// Gets the TempFileCollection that contains the temporary files generated + /// on disk after a successful call to the Load method. + /// </summary> + public TempFileCollection TemporaryFiles + { + get { return xslTransform.TemporaryFiles; } + } - /// <summary> Loads the XSLT stylesheet contained in the XmlReader</summary> - public void Load(XmlReader reader){ this.xslTransform.Load(reader); } + #endregion - /// <summary> Loads the XSLT stylesheet contained in the XPathNavigator</summary> - public void Load(XPathNavigator navigator){ this.xslTransform.Load(navigator); } + #region Constructors + /// <summary> + /// Initializes a new instance of the ExsltTransform class. + /// </summary> + public ExsltTransform() + { + this.xslTransform = new XslCompiledTransform(); + } - /// <summary> Loads the XSLT stylesheet contained in the IXPathNavigable</summary> - public void Load(IXPathNavigable ixn, XmlResolver resolver){ this.xslTransform.Load(ixn, resolver); } + /// <summary> + /// Initializes a new instance of the ExsltTransform + /// class with the specified debug setting. + /// </summary> + public ExsltTransform(bool debug) + { + this.xslTransform = new XslCompiledTransform(debug); + } - /// <summary> Loads the XSLT stylesheet specified by a URL</summary> - public void Load(string s, XmlResolver resolver){ this.xslTransform.Load(s, resolver); } + #endregion - /// <summary> Loads the XSLT stylesheet contained in the XmlReader</summary> - public void Load(XmlReader reader, XmlResolver resolver){ this.xslTransform.Load(reader, resolver); } + #region Load() method Overloads + /// <summary> Loads the XSLT stylesheet contained in the IXPathNavigable</summary> + public void Load(IXPathNavigable ixn) { this.xslTransform.Load(ixn); } - /// <summary> Loads the XSLT stylesheet contained in the XPathNavigator</summary> - public void Load(XPathNavigator navigator, XmlResolver resolver) {this.xslTransform.Load(navigator, resolver); } + /// <summary> Loads the XSLT stylesheet specified by a URL</summary> + public void Load(string s) { this.xslTransform.Load(s); } - #endregion + /// <summary> Loads the XSLT stylesheet contained in the XmlReader</summary> + public void Load(XmlReader reader) { this.xslTransform.Load(reader); } - #region Transform() method Overloads + /// <summary> + /// Compiles the XSLT style sheet contained in the IXPathNavigable. + /// The XmlResolver resolves any XSLT import or include elements and the + /// XSLT settings determine the permissions for the style sheet. + /// </summary> + public void Load(IXPathNavigable stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) + { + this.xslTransform.Load(stylesheet, settings, stylesheetResolver); + } - /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to an XmlReader</summary> - public XmlReader Transform(IXPathNavigable ixn, XsltArgumentList arglist) - { - return this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist)); - } + /// <summary> + /// Loads and compiles the XSLT style sheet specified by the URI. + /// The XmlResolver resolves any XSLT import or include elements and the + /// XSLT settings determine the permissions for the style sheet. + /// </summary> + public void Load(string stylesheetUri, XsltSettings settings, XmlResolver stylesheetResolver) + { + this.xslTransform.Load(stylesheetUri, settings, stylesheetResolver); + } - /// <summary> Transforms the XML data in the input file and outputs the result to an output file</summary> - public void Transform(string infile, string outfile) - { - // Use using so that the file is not held open after the call + /// <summary> + /// Compiles the XSLT style sheet contained in the XmlReader. + /// The XmlResolver resolves any XSLT import or include elements and the + /// XSLT settings determine the permissions for the style sheet. + /// </summary> + public void Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) + { + this.xslTransform.Load(stylesheet, settings, stylesheetResolver); + } - using (StreamWriter outStream = new StreamWriter(outfile)) - { - if (_multiOutput) - this.xslTransform.Transform(new XPathDocument(infile), this.AddExsltExtensionObjects(null), - new MultiXmlTextWriter(outStream)); - else - this.xslTransform.Transform(new XPathDocument(infile), this.AddExsltExtensionObjects(null), outStream); - } - } + #endregion - /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an XmlReader</summary> - public XmlReader Transform(XPathNavigator navigator, XsltArgumentList arglist) - { - return this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist)); - } + #region Transform() method Overloads - /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to a Stream</summary> - public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, Stream stream) - { - if (_multiOutput) - this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), - new MultiXmlTextWriter(stream, Encoding.UTF8)); - else - this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), stream); - } + /// <summary> + /// Executes the transform using the input document specified by the + /// IXPathNavigable object and outputs the results to an XmlWriter. + /// </summary> + public void Transform(IXPathNavigable input, XmlWriter results) + { + this.xslTransform.Transform(input, AddExsltExtensionObjects(null), results); + } - /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to a TextWriter</summary> - public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, TextWriter writer) - { - if (_multiOutput) - this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), - new MultiXmlTextWriter(writer)); - else - this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), writer); - } + /// <summary> + /// Executes the transform using the input document specified by the URI + /// and outputs the results to a file. + /// </summary> + public void Transform(string inputUri, string resultsFile) + { + // Use using so that the file is not held open after the call + using (FileStream outStream = File.OpenWrite(resultsFile)) + { + if (_multiOutput) + { + this.xslTransform.Transform(new XPathDocument(inputUri), + this.AddExsltExtensionObjects(null), + new MultiXmlTextWriter(outStream, this.OutputSettings.Encoding)); + } + else + { + this.xslTransform.Transform(new XPathDocument(inputUri), + this.AddExsltExtensionObjects(null), + outStream); + } + } + } - /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to an XmlWriter</summary> - public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, XmlWriter writer) - { - this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), writer); - } - - /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to an MultiXmlTextWriter</summary> - public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, MultiXmlTextWriter writer) - { - this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), writer); + /// <summary> + /// Executes the transform using the input document specified by the URI + /// and outputs the results to an XmlWriter. + /// </summary> + public void Transform(string inputUri, XmlWriter results) + { + this.xslTransform.Transform(inputUri, + this.AddExsltExtensionObjects(null), results); } - /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to a Stream</summary> - public void Transform(XPathNavigator navigator, XsltArgumentList arglist, Stream stream) - { - if (_multiOutput) - this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), - new MultiXmlTextWriter(stream, Encoding.UTF8)); - else - this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), stream); - } + /// <summary> + /// Executes the transform using the input document specified by the + /// XmlReader object and outputs the results to an XmlWriter. + /// </summary> + public void Transform(XmlReader input, XmlWriter results) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(null), results); + } - /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to a TextWriter</summary> - public void Transform(XPathNavigator navigator, XsltArgumentList arglist, TextWriter writer) - { - if (_multiOutput) - this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), - new MultiXmlTextWriter(writer)); + /// <summary> + /// Executes the transform using the input document specified by the + /// IXPathNavigable object and outputs the results to a stream. + /// The XsltArgumentList provides additional runtime arguments. + /// </summary> + public void Transform(IXPathNavigable input, XsltArgumentList arguments, Stream results) + { + if (_multiOutput) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), + new MultiXmlTextWriter(results, this.OutputSettings.Encoding)); + } else - this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); - } - - /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an XmlWriter</summary> - public void Transform(XPathNavigator navigator, XsltArgumentList arglist, XmlWriter writer) - { - this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); - } - - /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an MultiXmlTextWriter</summary> - public void Transform(XPathNavigator navigator, XsltArgumentList arglist, MultiXmlTextWriter writer) - { - this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results); + } } - #endregion - - #region Public Methods - - #endregion + /// <summary> + /// Executes the transform using the input document specified by the + /// IXPathNavigable object and outputs the results to an TextWriter. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) + { + if (_multiOutput) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), + new MultiXmlTextWriter(results)); + } + else + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results); + } + } - #region Private Methods - /// <summary> - /// Adds the objects that implement the EXSLT extensions to the provided argument - /// list. The extension objects added depend on the value of the SupportedFunctions - /// property. - /// </summary> - /// <param name="list">The argument list</param> - /// <returns>An XsltArgumentList containing the contents of the list passed in - /// and objects that implement the EXSLT. </returns> - /// <remarks>If null is passed in then a new XsltArgumentList is constructed. </remarks> - private XsltArgumentList AddExsltExtensionObjects(XsltArgumentList list){ - if(list == null){ - list = new XsltArgumentList(); - } - - lock (sync) - { - //remove all our extension objects in case the XSLT argument list is being reused - list.RemoveExtensionObject(ExsltNamespaces.Common); - list.RemoveExtensionObject(ExsltNamespaces.Math); - list.RemoveExtensionObject(ExsltNamespaces.Random); - list.RemoveExtensionObject(ExsltNamespaces.DatesAndTimes); - list.RemoveExtensionObject(ExsltNamespaces.RegularExpressions); - list.RemoveExtensionObject(ExsltNamespaces.Strings); - list.RemoveExtensionObject(ExsltNamespaces.Sets); - list.RemoveExtensionObject(ExsltNamespaces.GDNDatesAndTimes); - list.RemoveExtensionObject(ExsltNamespaces.GDNMath); - list.RemoveExtensionObject(ExsltNamespaces.GDNRegularExpressions); - list.RemoveExtensionObject(ExsltNamespaces.GDNSets); - list.RemoveExtensionObject(ExsltNamespaces.GDNStrings); - list.RemoveExtensionObject(ExsltNamespaces.GDNDynamic); - - //add extension objects as specified by SupportedFunctions - if((this.SupportedFunctions & ExsltFunctionNamespace.Common) > 0) - { - list.AddExtensionObject(ExsltNamespaces.Common, this.exsltCommon); + /// <summary> + /// Executes the transform using the input document specified by the + /// IXPathNavigable object and outputs the results to an XmlWriter. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results); } - if((this.SupportedFunctions & ExsltFunctionNamespace.Math) > 0) - { - list.AddExtensionObject(ExsltNamespaces.Math, this.exsltMath); + /// <summary> + /// Executes the transform using the input document specified by the URI + /// and outputs the results to stream. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(string inputUri, XsltArgumentList arguments, Stream results) + { + if (_multiOutput) + { + this.xslTransform.Transform(inputUri, + this.AddExsltExtensionObjects(arguments), + new MultiXmlTextWriter(results, this.OutputSettings.Encoding)); + } + else + { + this.xslTransform.Transform(inputUri, + this.AddExsltExtensionObjects(arguments), results); + } } - if((this.SupportedFunctions & ExsltFunctionNamespace.Random) > 0) - { - list.AddExtensionObject(ExsltNamespaces.Random, this.exsltRandom); + /// <summary> + /// Executes the transform using the input document specified by the URI and + /// outputs the results to a TextWriter. + /// </summary> + public void Transform(string inputUri, XsltArgumentList arguments, TextWriter results) + { + if (_multiOutput) + { + this.xslTransform.Transform(inputUri, + this.AddExsltExtensionObjects(arguments), + new MultiXmlTextWriter(results)); + } + else + { + this.xslTransform.Transform(inputUri, + this.AddExsltExtensionObjects(arguments), results); + } } - if((this.SupportedFunctions & ExsltFunctionNamespace.DatesAndTimes) > 0) - { - list.AddExtensionObject(ExsltNamespaces.DatesAndTimes, this.exsltDatesAndTimes); + /// <summary> + /// Executes the transform using the input document specified by the URI + /// and outputs the results to an XmlWriter. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(string inputUri, XsltArgumentList arguments, XmlWriter results) + { + this.xslTransform.Transform(inputUri, + this.AddExsltExtensionObjects(arguments), results); } - if((this.SupportedFunctions & ExsltFunctionNamespace.RegularExpressions) > 0) - { - list.AddExtensionObject(ExsltNamespaces.RegularExpressions, this.exsltRegularExpressions); + /// <summary> + /// Executes the transform using the input document specified by the XmlReader + /// object and outputs the results to a stream. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(XmlReader input, XsltArgumentList arguments, Stream results) + { + if (_multiOutput) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), + new MultiXmlTextWriter(results, this.OutputSettings.Encoding)); + } + else + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results); + } } - if((this.SupportedFunctions & ExsltFunctionNamespace.Strings) > 0) - { - list.AddExtensionObject(ExsltNamespaces.Strings, this.exsltStrings); + /// <summary> + /// Executes the transform using the input document specified by the XmlReader + /// object and outputs the results to a TextWriter. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(XmlReader input, XsltArgumentList arguments, TextWriter results) + { + if (_multiOutput) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), + new MultiXmlTextWriter(results)); + } + else + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results); + } } - if((this.SupportedFunctions & ExsltFunctionNamespace.Sets) > 0) - { - list.AddExtensionObject(ExsltNamespaces.Sets, this.exsltSets); - } - - if((this.SupportedFunctions & ExsltFunctionNamespace.GDNDatesAndTimes) > 0) - { - list.AddExtensionObject(ExsltNamespaces.GDNDatesAndTimes, this.gdnDatesAndTimes); - } - - if((this.SupportedFunctions & ExsltFunctionNamespace.GDNMath) > 0) - { - list.AddExtensionObject(ExsltNamespaces.GDNMath, this.gdnMath); - } - - if((this.SupportedFunctions & ExsltFunctionNamespace.GDNRegularExpressions) > 0) - { - list.AddExtensionObject(ExsltNamespaces.GDNRegularExpressions, this.gdnRegularExpressions); - } - - if((this.SupportedFunctions & ExsltFunctionNamespace.GDNSets) > 0) - { - list.AddExtensionObject(ExsltNamespaces.GDNSets, this.gdnSets); + /// <summary> + /// Executes the transform using the input document specified by the XmlReader + /// object and outputs the results to an XmlWriter. + /// The XsltArgumentList provides additional run-time arguments. + /// </summary> + public void Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results); } - - if((this.SupportedFunctions & ExsltFunctionNamespace.GDNStrings) > 0) - { - list.AddExtensionObject(ExsltNamespaces.GDNStrings, this.gdnStrings); + + + /// <summary> + /// Executes the transform using the input document specified by the XmlReader + /// object and outputs the results to an XmlWriter. + /// The XsltArgumentList provides additional run-time arguments and the + /// XmlResolver resolves the XSLT document() function. + /// </summary> + public void Transform(XmlReader input, XsltArgumentList arguments, + XmlWriter results, XmlResolver documentResolver) + { + this.xslTransform.Transform(input, + this.AddExsltExtensionObjects(arguments), results, documentResolver); } - - if((this.SupportedFunctions & ExsltFunctionNamespace.GDNDynamic) > 0) - { - list.AddExtensionObject(ExsltNamespaces.GDNDynamic, this.gdnDynamic); + + #endregion + + #region Private Methods + + /// <summary> + /// Adds the objects that implement the EXSLT extensions to the provided argument + /// list. The extension objects added depend on the value of the SupportedFunctions + /// property. + /// </summary> + /// <param name="list">The argument list</param> + /// <returns>An XsltArgumentList containing the contents of the list passed in + /// and objects that implement the EXSLT. </returns> + /// <remarks>If null is passed in then a new XsltArgumentList is constructed. </remarks> + private XsltArgumentList AddExsltExtensionObjects(XsltArgumentList list) + { + if (list == null) + { + list = new XsltArgumentList(); + } + + lock (sync) + { + //remove all our extension objects in case the XSLT argument list is being reused + list.RemoveExtensionObject(ExsltNamespaces.Math); + list.RemoveExtensionObject(ExsltNamespaces.Random); + list.RemoveExtensionObject(ExsltNamespaces.DatesAndTimes); + list.RemoveExtensionObject(ExsltNamespaces.RegularExpressions); + list.RemoveExtensionObject(ExsltNamespaces.Strings); + list.RemoveExtensionObject(ExsltNamespaces.Sets); + list.RemoveExtensionObject(ExsltNamespaces.GDNDatesAndTimes); + list.RemoveExtensionObject(ExsltNamespaces.GDNMath); + list.RemoveExtensionObject(ExsltNamespaces.GDNRegularExpressions); + list.RemoveExtensionObject(ExsltNamespaces.GDNSets); + list.RemoveExtensionObject(ExsltNamespaces.GDNStrings); + list.RemoveExtensionObject(ExsltNamespaces.GDNDynamic); + + //add extension objects as specified by SupportedFunctions + + if ((this.SupportedFunctions & ExsltFunctionNamespace.Math) > 0) + { + list.AddExtensionObject(ExsltNamespaces.Math, this.exsltMath); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.Random) > 0) + { + list.AddExtensionObject(ExsltNamespaces.Random, this.exsltRandom); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.DatesAndTimes) > 0) + { + list.AddExtensionObject(ExsltNamespaces.DatesAndTimes, this.exsltDatesAndTimes); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.RegularExpressions) > 0) + { + list.AddExtensionObject(ExsltNamespaces.RegularExpressions, this.exsltRegularExpressions); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.Strings) > 0) + { + list.AddExtensionObject(ExsltNamespaces.Strings, this.exsltStrings); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.Sets) > 0) + { + list.AddExtensionObject(ExsltNamespaces.Sets, this.exsltSets); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.GDNDatesAndTimes) > 0) + { + list.AddExtensionObject(ExsltNamespaces.GDNDatesAndTimes, this.gdnDatesAndTimes); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.GDNMath) > 0) + { + list.AddExtensionObject(ExsltNamespaces.GDNMath, this.gdnMath); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.GDNRegularExpressions) > 0) + { + list.AddExtensionObject(ExsltNamespaces.GDNRegularExpressions, this.gdnRegularExpressions); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.GDNSets) > 0) + { + list.AddExtensionObject(ExsltNamespaces.GDNSets, this.gdnSets); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.GDNStrings) > 0) + { + list.AddExtensionObject(ExsltNamespaces.GDNStrings, this.gdnStrings); + } + + if ((this.SupportedFunctions & ExsltFunctionNamespace.GDNDynamic) > 0) + { + list.AddExtensionObject(ExsltNamespaces.GDNDynamic, this.gdnDynamic); + } + } + + return list; } - } - - return list; - } - #endregion + #endregion - } + } } Index: ExsltMath.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/ExsltMath.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ExsltMath.cs 16 Oct 2005 20:07:08 -0000 1.1 +++ ExsltMath.cs 29 Oct 2005 21:14:35 -0000 1.2 @@ -5,342 +5,366 @@ using System.Xml.XPath; using System.Collections.Generic; +using Mvp.Xml.Common.XPath; + #endregion namespace Mvp.Xml.Exslt { - /// <summary> - /// This class implements the EXSLT functions in the http://exslt.org/math namespace. - /// </summary> - public class ExsltMath { - /// <summary> - /// Implements the following function - /// number min(node-set) - /// </summary> - /// <param name="iterator"></param> - /// <returns></returns> - public double min(XPathNodeIterator iterator){ - - double min, t; - - if(iterator.Count == 0){ - return Double.NaN; - } - - try{ - - iterator.MoveNext(); - min = XmlConvert.ToDouble(iterator.Current.Value); + /// <summary> + /// This class implements the EXSLT functions in the http://exslt.org/math namespace. + /// </summary> + public class ExsltMath + { + /// <summary> + /// Implements the following function + /// number min(node-set) + /// </summary> + /// <param name="iterator"></param> + /// <returns></returns> + public double min(XPathNodeIterator iterator) + { + double min, t; - - while(iterator.MoveNext()){ - t = XmlConvert.ToDouble(iterator.Current.Value); - min = (t < min)? t : min; - } - - }catch(Exception){ - return Double.NaN; - } + if (iterator.Count == 0) + { + return Double.NaN; + } - return min; - } + try + { - - /// <summary> - /// Implements the following function - /// number max(node-set) - /// </summary> - /// <param name="iterator"></param> - /// <returns></returns> - public double max(XPathNodeIterator iterator){ + iterator.MoveNext(); + min = XmlConvert.ToDouble(iterator.Current.Value); - double max, t; - if(iterator.Count == 0){ - return Double.NaN; - } + while (iterator.MoveNext()) + { + t = XmlConvert.ToDouble(iterator.Current.Value); + min = (t < min) ? t : min; + } - try{ + } + catch + { + return Double.NaN; + } - iterator.MoveNext(); - max = XmlConvert.ToDouble(iterator.Current.Value); + return min; + } - - while(iterator.MoveNext()){ - t = XmlConvert.ToDouble(iterator.Current.Value); - max = (t > max)? t : max; - } - - }catch(Exception){ - return Double.NaN; - } - return max; - } - + /// <summary> + /// Implements the following function + /// number max(node-set) + /// </summary> + /// <param name="iterator"></param> + /// <returns></returns> + public double max(XPathNodeIterator iterator) + { + double max, t; - /// <summary> - /// Implements the following function - /// node-set highest(node-set) - /// </summary> - /// <param name="iterator">The input nodeset</param> - /// <returns>All the nodes that contain the max value in the nodeset</returns> - public XPathNodeIterator highest(XPathNodeIterator iterator){ + if (iterator.Count == 0) + { + return Double.NaN; + } - ExsltNodeList newList = new ExsltNodeList(); - double max, t; + try + { - if(iterator.Count == 0){ - return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); - } + iterator.MoveNext(); + max = XmlConvert.ToDouble(iterator.Current.Value); + while (iterator.MoveNext()) + { + t = XmlConvert.ToDouble(iterator.Current.Value); + max = (t > max) ? t : max; + } - try{ + } + catch + { + return Double.NaN; + } - iterator.MoveNext(); - max = XmlConvert.ToDouble(iterator.Current.Value); - newList.Add(iterator.Current.Clone()); + return max; + } - while (iterator.MoveNext()){ - t = XmlConvert.ToDouble(iterator.Current.Value); - - if(t > max){ - max = t; - newList.Clear(); - newList.Add(iterator.Current.Clone()); - }else if( t == max){ - newList.Add(iterator.Current.Clone()); - } - } - - }catch(Exception){ //return empty node set - newList.Clear(); - return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); - } - return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); - } + /// <summary> + /// Implements the following function + /// node-set highest(node-set) + /// </summary> + /// <param name="iterator">The input nodeset</param> + /// <returns>All the nodes that contain the max value in the nodeset</returns> + public XPathNodeIterator highest(XPathNodeIterator iterator) + { + if (iterator.Count == 0) + { + return EmptyXPathNodeIterator.Instance; + } + + double max, t; + List<XPathNavigator> newList = new List<XPathNavigator>(); + try + { + iterator.MoveNext(); + max = XmlConvert.ToDouble(iterator.Current.Value); + newList.Add(iterator.Current.Clone()); - /// <summary> - /// Implements the following function - /// node-set lowest(node-set) - /// </summary> - /// <param name="iterator">The input nodeset</param> - /// <returns>All the nodes that contain the min value in the nodeset</returns> - public XPathNodeIterator lowest(XPathNodeIterator iterator){ + while (iterator.MoveNext()) + { + t = XmlConvert.ToDouble(iterator.Current.Value); - IList<XPathNavigator> newList = new List<XPathNavigator>(); - double min, t; + if (t > max) + { + max = t; + newList.Clear(); + newList.Add(iterator.Current.Clone()); + } + else if (t == max) + { + newList.Add(iterator.Current.Clone()); + } + } + } + catch + { + //return empty node set + return EmptyXPathNodeIterator.Instance; + } - if(iterator.Count == 0){ - return newList; - } + return new XPathNavigatorIterator(newList); + } - try{ + /// <summary> + /// Implements the following function + /// node-set lowest(node-set) + /// </summary> + /// <param name="iterator">The input nodeset</param> + /// <returns>All the nodes that contain the min value in the nodeset</returns> + public XPathNodeIterator lowest(XPathNodeIterator iterator) + { + if (iterator.Count == 0) + { + return EmptyXPathNodeIterator.Instance; + } - iterator.MoveNext(); - min = XmlConvert.ToDouble(iterator.Current.Value); - newList.Add(iterator.Current.Clone()); + double max, t; + List<XPathNavigator> newList = new List<XPathNavigator>(); - while (iterator.MoveNext()){ - t = XmlConvert.ToDouble(iterator.Current.Value); - - if(t < min){ - min = t; - newList.Clear(); - newList.Add(iterator.Current.Clone()); - }else if( t == min){ - newList.Add(iterator.Current.Clone()); - } - } - - }catch(Exception){ //return empty node set - newList.Clear(); - return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); - } + try + { + iterator.MoveNext(); + max = XmlConvert.ToDouble(iterator.Current.Value); + newList.Add(iterator.Current.Clone()); - return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); - } + while (iterator.MoveNext()) + { + t = XmlConvert.ToDouble(iterator.Current.Value); - /// <summary> - /// Implements the following function - /// number abs(number) - /// </summary> - /// <param name="number"></param> - /// <returns></returns> - public double abs(double number){ + if (t < max) + { + max = t; + newList.Clear(); + newList.Add(iterator.Current.Clone()); + } + else if (t == max) + { + newList.Add(iterator.Current.Clone()); + } + } + } + catch + { + //return empty node set + return EmptyXPathNodeIterator.Instance; + } - return Math.Abs(number); - } + return new XPathNavigatorIterator(newList); + } - /// <summary> - /// Implements the following function - /// number sqrt(number) - /// </summary> - /// <param name="number"></param> - /// <returns></returns> - public double sqrt(double number){ + /// <summary> + /// Implements the following function + /// number abs(number) + /// </summary> + /// <param name="number"></param> + /// <returns></returns> + public double abs(double number) + { + return Math.Abs(number); + } + /// <summary> + /// Implements the following function + /// number sqrt(number) + /// </summary> + /// <param name="number"></param> + /// <returns></returns> + public double sqrt(double number) + { if (number < 0) return 0; - return Math.Sqrt(number); - } - - /// <summary> - /// Implements the following function - /// number power(number, number) - /// </summary> - /// <param name="x"></param> - /// <param name="y"></param> - /// <returns></returns> - public double power(double x, double y){ - - return Math.Pow(x, y); - } + return Math.Sqrt(number); + } - /// <summary> - /// Implements the following function - /// number log(number) - /// </summary> - /// <param name="x"></param> - /// <returns></returns> - public double log(double x){ + /// <summary> + /// Implements the following function + /// number power(number, number) + /// </summary> + /// <param name="x"></param> + /// <param name="y"></param> + /// <returns></returns> + public double power(double x, double y) + { + return Math.Pow(x, y); + } - return Math.Log(x); - } + /// <summary> + /// Implements the following function + /// number log(number) + /// </summary> + /// <param name="x"></param> + /// <returns></returns> + public double log(double x) + { + return Math.Log(x); + } - /// <summary> - /// Implements the following function - /// number constant(string, number) - /// </summary> - /// <param name="number"></param> - /// <returns>The specified constant or NaN</returns> - /// <remarks>This method only supports the constants - /// E and PI. Also the precision parameter is ignored.</remarks> - public double constant(string c, double precision){ - switch(c.ToUpper()) { + /// <summary> + /// Implements the following function + /// number constant(string, number) + /// </summary> + /// <param name="number"></param> + /// <returns>The specified constant or NaN</returns> + /// <remarks>This method only supports the constants + /// E and PI. Also the precision parameter is ignored.</remarks> + public double constant(string c, double precision) + { + switch (c.ToUpper()) + { case "E": return Math.E; case "PI": return Math.PI; - case "SQRRT2" : + case "SQRRT2": return Math.Sqrt(2); - case "LN2" : + case "LN2": return Math.Log(2); - case "LN10" : + case "LN10": return Math.Log(10); - case "LOG2E" : + case "LOG2E": return Math.Log(Math.E, 2); - case "SQRT1_2" : + case "SQRT1_2": return Math.Sqrt(.5); default: return Double.NaN; } - } - - /// <summary> - /// Implements the following function - /// number random() - /// </summary> - /// <param name="x"></param> - /// <returns></returns> - public double random(){ - - Random rand = new Random((int) DateTime.Now.Ticks); - return rand.NextDouble(); - } - - /// <summary> - /// Implements the following function - /// number sin(number) - /// </summary> - /// <param name="x"></param> - /// <returns></returns> - public double sin(double x){ - - return Math.Sin(x); - } - - /// <summary> - /// Implements the following function - /// number asin(number) - /// </summary> - /// <param name="x"></param> - /// <returns></returns> - public double asin(double x){ - - return Math.Asin(x); - } - - - /// <summary> - /// Implements the following function - /// number cos(number) - /// </summary> - /// <param name="x"></param> - /// <returns></returns> - ... [truncated message content] |