mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 17:02:10 -10:00
* XsltCompileExceptionTests.cs: Added tests for ctors. * XsltExceptionTests.cs: Added tests for ctors. * XslTransformTests.cs: Added tests for validation of <xsl:output> attributes. * System.Xml_test.dll.sources: Added XsltCompilerExceptionTests.cs and XsltExceptionTests.cs. * IXsltContextFunction.cs: Fixed line endings (all CRLF). * IXsltContextVariable.cs: Fixed line endings (all CRLF). * XsltContext.cs: Fixed line endings (all CRLF). * XsltCompileException.cs: Fixed line endings (all CRLF). Fixed message to correspond with both MS.NET 1.x and 2.0. * XslTransform.cs: Fixed line endings (all CRLF). * XsltArgumentList.cs: Fixed line endings (all CRLF). * XsltException.cs: Fixed line endings (all CRLF). Fixed message to correspond with MS.NET 1.x and 2.0. * XslVariable.cs: Beautify error messages. * XslElement.cs: Same. * XslAvt.cs: Same. * XslAttribute.cs: Same. * XslApplyTemplates.cs: Same. * XslTemplateContent.cs: Same. * XslCallTemplate.cs: Same. * XslCopy.cs: Same. * XslChoose.cs: Same. * ScriptCompilerInfo.cs: Fixed line endings. * XslStylesheet.cs: Beautify error messages. * Debug.cs: Fixed line endings. * XslOutput.cs: Indent is now bool instead of string, use MoveToAttribute to navigate through attributes instead of using GetAttribute, as we also need to distinguish attributes with zero-length value from attributes that are not specified for correct implementation of DOCTYPE. Implemented validation for value of "omit-xml-declaration", "standalone" and "indent". We now throw a XsltCompileException for unknown attribute. * XmlWriterEmitter.cs: only skip WriteDocType is systemId is null. * HtmlEmitter.cs: XslOutput.Indent is now bool. Fixed WriteDocType to match MS.NET. * XmlDecimalFormat.cs: Beautify error messages. * XslTemplate.cs: Beautify error messages. * GenericOutputter.cs: XslOutput.Indent is now bool. * Compiler.cs: Beautify error messages. svn path=/trunk/mcs/; revision=54780
162 lines
5.1 KiB
C#
162 lines
5.1 KiB
C#
// System.Xml.Xsl.XsltArgumentList
|
|
//
|
|
// Author: Tim Coleman <[email protected]>
|
|
// (C) Copyright 2002 Tim Coleman
|
|
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
//
|
|
|
|
using System.Collections;
|
|
using System.Security.Permissions;
|
|
using System.Xml.XPath;
|
|
|
|
namespace System.Xml.Xsl
|
|
{
|
|
#if !NET_2_0
|
|
sealed
|
|
#endif
|
|
public class XsltArgumentList
|
|
{
|
|
#region Fields
|
|
|
|
internal Hashtable extensionObjects;
|
|
internal Hashtable parameters;
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public XsltArgumentList ()
|
|
{
|
|
extensionObjects = new Hashtable ();
|
|
parameters = new Hashtable ();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Event
|
|
#if NET_2_0
|
|
|
|
public event XsltMessageEncounteredEventHandler XsltMessageEncountered;
|
|
|
|
#endif
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
|
public void AddExtensionObject (string namespaceUri, object extension)
|
|
{
|
|
if (namespaceUri == null)
|
|
throw new ArgumentException ("The namespaceUri is a null reference.");
|
|
if (namespaceUri == "http://www.w3.org/1999/XSL/Transform")
|
|
throw new ArgumentException ("The namespaceUri is http://www.w3.org/1999/XSL/Transform.");
|
|
if (extensionObjects.Contains (namespaceUri))
|
|
throw new ArgumentException ("The namespaceUri already has an extension object associated with it.");
|
|
|
|
extensionObjects [namespaceUri] = extension;
|
|
}
|
|
|
|
public void AddParam (string name, string namespaceUri, object parameter)
|
|
{
|
|
|
|
if (namespaceUri == null)
|
|
throw new ArgumentException ("The namespaceUri is a null reference.");
|
|
|
|
if (namespaceUri == "http://www.w3.org/1999/XSL/Transform")
|
|
throw new ArgumentException ("The namespaceUri is http://www.w3.org/1999/XSL/Transform.");
|
|
|
|
if (name == null)
|
|
throw new ArgumentException ("The parameter name is a null reference.");
|
|
|
|
|
|
// TODO:
|
|
// verify that the name is a valid name according to
|
|
// the W3C XML specification
|
|
|
|
XmlQualifiedName qName = new XmlQualifiedName (name, namespaceUri);
|
|
|
|
if (parameters.Contains (qName))
|
|
throw new ArgumentException ("The namespaceUri already has a parameter associated with it.");
|
|
|
|
parameter = ValidateParam (parameter);
|
|
|
|
parameters [qName] = parameter;
|
|
}
|
|
|
|
public void Clear ()
|
|
{
|
|
extensionObjects.Clear ();
|
|
parameters.Clear ();
|
|
}
|
|
|
|
public object GetExtensionObject (string namespaceUri)
|
|
{
|
|
return extensionObjects [namespaceUri];
|
|
}
|
|
|
|
public object GetParam (string name, string namespaceUri)
|
|
{
|
|
if (name == null)
|
|
throw (new ArgumentException ("The parameter name is a null reference."));
|
|
|
|
XmlQualifiedName qName = new XmlQualifiedName (name, namespaceUri);
|
|
return parameters [qName];
|
|
}
|
|
|
|
public object RemoveExtensionObject (string namespaceUri)
|
|
{
|
|
object extensionObject = this.GetExtensionObject (namespaceUri);
|
|
extensionObjects.Remove (namespaceUri);
|
|
return extensionObject;
|
|
}
|
|
|
|
public object RemoveParam (string name, string namespaceUri)
|
|
{
|
|
XmlQualifiedName qName = new XmlQualifiedName (name, namespaceUri);
|
|
object parameter = this.GetParam (name, namespaceUri);
|
|
parameters.Remove (qName);
|
|
return parameter;
|
|
}
|
|
|
|
private object ValidateParam (object parameter)
|
|
{
|
|
if (parameter is string) return parameter;
|
|
if (parameter is bool) return parameter;
|
|
if (parameter is double) return parameter;
|
|
if (parameter is XPathNavigator) return parameter;
|
|
if (parameter is XPathNodeIterator) return parameter;
|
|
|
|
if (parameter is Int16) return (double) (Int16) parameter;
|
|
if (parameter is UInt16) return (double) (UInt16) parameter;
|
|
if (parameter is Int32) return (double) (Int32) parameter;
|
|
if (parameter is Int64) return (double) (Int64) parameter;
|
|
if (parameter is UInt64) return (double) (UInt64) parameter;
|
|
if (parameter is Single) return (double) (Single) parameter;
|
|
if (parameter is decimal) return (double) (decimal) parameter;
|
|
|
|
return parameter.ToString ();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|