Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,467 @@
2009-11-09 Jb Evain <jbevain@novell.com>
* XslCompiledTransform.cs: ifdef the temporary files collection
for MonoTouch.
2008-12-09 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : Fixed bug #450797, patch by Jonathan
Anderson. Preserve whitespace-only text in xsl:text.
2008-06-03 Atsushi Enomoto <atsushi@ximian.com>
* XslTransform.cs : add pretty simple printing debugger.
2008-05-22 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : in XmlWriterSettings, use
ConformanceLevel.Fragment to allow fragment output.
In Transform(string,string), use TextWriter output instead of
XmlWriter to control xml declaration output.
Fixed bug #391424.
2007-12-27 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : when loading XmlReader as an input to
Transform(), preserve whitespaces in the input document. Based on
the patch by Tor Lillqvist (part of #349375 fix).
2007-10-10 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : actually previous change was not enough.
Added a commented-out example of debugger method usage.
2007-10-10 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : a bit more of debugging help. Now it
stores stylesheet elements when "enableDebug" is true.
2007-06-28 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs XslTransform.cs : initial attempt to
support external debugger.
2006-11-30 Atsushi Enomoto <atsushi@ximian.com>
* XslTransform.cs, XsltException.cs : added XSLT stack frame debug
support, based on the patch by Michael Meeks.
2006-10-27 Atsushi Enomoto <atsushi@ximian.com>
* XsltContext.cs : finally created a non-copyright-infringing test
for bug #46751 and fixed it.
2006-07-06 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : making stub more complete :|
2006-05-29 Gert Driesen <drieseng@users.sourceforge.net>
* XsltContext.cs: Ctors are public in .NET 1.1. Fixes warnings in
class status page. Set eol-style to CRLF.
2006-05-08 Atsushi Enomoto <atsushi@ximian.com>
* XslTransform.cs : fixed ObsoleteAttributes. It won't be harmful
as we have working XslCompiledTransform stubs.
2006-02-22 Atsushi Enomoto <atsushi@ximian.com>
* XsltContext.cs : don't expect that it is always XsltCompiledContext
which is being evaluated in XPathExpression. Dispatch overriden
methods. Fixed bug #46751.
2006-01-25 Atsushi Enomoto <atsushi@ximian.com>
* XsltContext.cs : fixed method signatures found by updated
corcompare.
2005-12-23 Gert Driesen <drieseng@users.sourceforge.net>
* 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.
2005-11-22 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledTransform.cs : added non-compiler transformer (aka. stub).
2005-11-07 Atsushi Enomoto <atsushi@ximian.com>
* XsltException.cs : under 2.0, some properties are virtual.
2005-11-07 Andrew Skiba <andrews@mainsoft.com>
* XslTransform.cs: throw meaningful exception when Transform is
called before Load
2005-10-08 Gert Driesen <drieseng@users.sourceforge.net>
* XsltSettings.cs: Marked sealed.
2005-09-16 Atsushi Enomoto <atsushi@ximian.com>
* XslTransform.cs : When Transform() returns XmlReader, allow empty
results. Fixed bug #76115.
2005-08-31 Sebastien Pouliot <sebastien@ximian.com>
* XsltArgumentList.cs: Added a LinkDemand for Unrestricted on
AddExtensionObject method.
* XsltCompileException.cs: Added a Demand for SerializationFormatter
on GetObjectData method.
* XsltException.cs: Added a Demand for SerializationFormatter on
GetObjectData method.
2005-08-01 Gert Driesen <drieseng@users.sourceforge.net>
* XsltArgumentList.cs: No longer sealed in .NET 2.0.
* XsltException.cs: Message override is back in .NET 2.0 Beta 2.
2005-06-27 Atsushi Enomoto <atsushi@ximian.com>
* XsltMessageEncounteredEventArgs.cs : it seems abstract.
* XsltSettings.cs : There is another .ctor().
2005-06-27 Atsushi Enomoto <atsushi@ximian.com>
* XsltSettings.cs,
XsltMessageEncounteredEventArgs.cs,
XsltMessageEncounteredEventHandler.cs : new files for net_2_0.
* XsltArgumentList.cs : added 2.0 message event.
2005-04-03 Ben Maurer <bmaurer@ximian.com>
* *.cs: Kill unmanaged xslt and the multiplexing hack.
2005-03-22 Atsushi Enomoto <atsushi@ximian.com>
* XslTransform.cs : commented out warned code.
2005-03-09 Atsushi Enomoto <atsushi@ximian.com>
* XsltContext.cs : removed GetNsm() from IStaticXsltContext and added
LookupNamespace() instead.
* BUGS-MS.txt : more bug info.
2005-03-04 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : more bug info.
2005-02-25 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : still more bug info.
2005-02-25 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : more bug info.
2005-02-24 Atsushi Enomoto <atsushi@ximian.com>
* XslTransformImpl.cs : Load() should use argument XmlResolver to
get file stream. This fixes bug #72942.
* BUGS-MS.txt : more bug info.
2005-02-23 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : all output_outputXXX comparison does not make sense.
2005-02-22 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : explaination on the last standalone test revert.
2005-02-21 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : more bug records.
2005-02-18 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : more bug records.
2005-02-17 Atsushi Enomoto <atsushi@ximian.com>
* BUGS-MS.txt : added MS bug information.
2005-02-17 Atsushi Enomoto <atsushi@ximian.com>
* ManagedXslTransform.cs : no need to write XML declaration here.
2004-12-08 Atsushi Enomoto <atsushi@ximian.com>
* XsltException.cs, XsltCompileException.cs :
added SecurityPermissionAttributes.
2004-10-09 Atsushi Enomoto <atsushi@ximian.com>
* XsltException.cs : Message is incorrectly regarded only after 2.0
(while it *disappeared* in 2.0).
2004-08-30 Atsushi Enomoto <atsushi@ximian.com>
* XsltException.cs : Message property is not overriden in NET_2_0.
2004-08-30 Atsushi Enomoto <atsushi@ximian.com>
* XsltException.cs : added NET_2_0 constructors too.
2004-08-30 Atsushi Enomoto <atsushi@ximian.com>
* XsltCompileException.cs : added NET_2_0 constructors.
Hide property Message under NET_2_0.
2004-05-06 Atsushi Enomoto <atsushi@ximian.com>
* ManagedXslTransform.cs : For Stream input, use StreamWriter for
input to GenericOutputter. Passing XmlWriter causes unexpected
xml declaration output.
2004-03-27 Atsushi Enomoto <atsushi@ximian.com>
* XsltContext.cs : Supply NameTable to base ctor().
2004-03-22 Atsushi Enomoto <atsushi@ximian.com>
* XsltException.cs, XsltCompileException.cs : They had used
message field which were never set.
2004-01-16 Atsushi Enomoto <atsushi@ximian.com>
* Multiplexer.cs : Pass stream parameters as is (to handle
encoding correctly). Patch by Dariusz Olszewski. Bug #52913 fixed.
* ManagedXslTransform.cs : In ctor() with stream, pass encoding
parameter also for managed transformer.
2004-01-15 Atsushi Enomoto <atsushi@ximian.com>
* ManagedXslTransform.cs : Pass TextReader's encoding for outputter.
don't write start and end document.
2003-12-25 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Multiplexer.cs : Now we use managed XSLT engine by default.
Added obsolete attribute to Transform()s without xmlresolver.
2003-12-07 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XsltException.cs, XsltCompileException.cs : Added locatable .ctor().
2003-12-05 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Multiplexer.cs : set_XmlResolver is marked as obsolete.
Added new Transform() methods introduced in .NET 1.1.
CRLF and LF are desparately mixed, so adjusted to LF.
* XslTransform.cs :
CRLF and LF are desparately mixed, so adjusted to CRLF.
2003-12-02 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslTransformImpl.cs : Load(XmlReader) should pass XmlSpace.Preserve
to XPathDocument.ctor().
2003-11-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* ManagedXslTransform.cs : Now WriteStartDocument() is moved internal to
GenericOutputter.
2003-11-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* ManagedXslTransform.cs : Transform() should raise an error if no
stylesheet was loaded.
2003-10-04 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslTransformImpl.cs : Load(url, resolver) now uses XPathDocument
.ctor(url, xmlSpace).
2003-08-30 Oleg Tkachenko <oleg@tkachenko.com>
* ManagedXslTransform.cs: Outputter/Emitter selection logic is moved
to GenericOutputter.
2003-08-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: commented out Cleanup () because of bug #47776.
2003-08-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* Multiplexer.cs: fixed infinite recursion bug.
2003-08-20 Ben Maurer <bmaurer@users.sourceforge.net>
* ManagedXslTransform.cs: sync API (Oleg).
2003-08-19 Ben Maurer <bmaurer@users.sourceforge.net>
* ManagedXslTransform.cs: sync to API changes.
2003-08-18 Ben Maurer <bmaurer@users.sourceforge.net>
* ManagedXslTransform.cs, XslTransformImpl.cs: Add support for
encoding.
2003-08-18 Ben Maurer <bmaurer@users.sourceforge.net>
* *.cs: Support for xsl:output. (Oleg)
2003-08-17 Ben Maurer <bmaurer@users.sourceforge.net>
* XslTransformImpl.cs: close XmlTextWriter when we create it.
2003-08-14 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslTransformImpl.cs, XslTransform.cs, Multiplexer.cs,
ManagedXslTransform.cs : Added Evidence args introduced in .NET 1.1.
2003-08-11 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* XsltCompileException.cs: Fixed/ Implemented rest
* XsltException.cs: Added internal constructor
2003-08-04 Ben Maurer <bmaurer@users.sourceforge.net>
* ManagedXslTransform.cs: use the resolver given.
2003-07-30 Ben Maurer <bmaurer@users.sourceforge.net>
* ManagedXslTransform.cs: Hold reference to CompiledStyle, not the
XslTransformProcessor. Will help with thread safty.
2003-07-30 Ben Maurer <bmaurer@users.sourceforge.net>
* ManagedXslTransform.cs: remove verbose debugging messages
2003-07-28 Ben Maurer <bmaurer@users.sourceforge.net>
* XslTransform.cs: Use the new XslTransformImpl class
* XslTransformImpl.cs: An abstract class for Xsl transforms
* UnmanagedXslTransform.cs: Contains the code that was in
XslTransform.cs
2003-07-27 Piers Haken <piersh@friskit.com>
* XsltArgumentList.cs:
fix type conversions in ValidateParam
allow creating params with null namespaceUri
2003-07-05 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslTransform.cs : fixed WriteTree() and WriteCurrentNode() to follow
the recent changes of XPathNavigator implementations.
2003-07-02 Zoltan Varga <vargaz@freemail.hu>
* XslTransform.cs (Transform): Call xsltSaveResultToFilename instead
of first reading the result into a string to conserve memory.
2003-06-30 Zoltan Varga <vargaz@freemail.hu>
* XslTransform.cs (GetStringFromDocument): Read the result using
xsltSaveResultToString, since the XML document returned by
applyStylesheet is missing the output processing done due to the
usage of the xsl:output directive.
2003-06-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XslTransform.cs : Fixed Transform (string, string) not to call
File.OpenWrite() that *appends* (not truncates) existing files.
2003-06-01 Joshua Tauberer <tauberer@for.net>
* XslTransform.cs: Cache extension object delegates
between calls to Transform.
2003-05-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: fixed NullReferenceExceptions after the last
change (which, btw, should have included a ChangeLog entry).
2003-05-27 Joshua Tauberer <tauberer@for.net>
* XslTransform.cs: Initial support for extension objects.
Known issues:
-Extension method signatures must match exactly to the
types of parameters that the method is called with from
the stylesheet.
-Node set parameters are converted to an ArrayList of
strings.
2003-05-27 Ben Maurer <bmaurer@users.sourceforge.net>
* XslTransform.cs: unsafe classes need unsafe!
2003-05-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: fixed bug #42739.
2003-05-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: fixed bug #42747.
2003-05-01 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: flush the writers when done. Fixes bug #42040.
2003-03-10 Alan Tam <Tam@SiuLung.com>
* XslTransform.cs: Fixed a bug when no args is passed
2003-03-10 Alan Tam <Tam@SiuLung.com>
* XslTransform.cs: Implemented boolean, number and string parameters.
(Node Set and Node Iterator parameters and Extension Objects are left.)
* XsltAttributeList.cs: Loosened access modifiers.
2003-02-20 Nick Drochak <ndrochak@gol.com>
* XslTransform.cs: Remove confusing and unused parameter.
2003-01-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: don't free the xml document used for the style sheet.
xmlFreeStylesheet already does it. Correctly close the element tag for
elements that don't have children. Added a couple of checks more.
2003-01-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: fixed a couple of Transform overloads and changed the
library name in DllImport to make it work on windows too.
2003-01-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* XslTransform.cs: implemented all Load and Transform methods. It uses
libxml2 and libxslt. No more temp files. It's slow and memory consuming,
but, well, that's XSLT... ;-). Idea from Zdravko Tashev.
Now the Xsl web control works.
2002-09-23 Duncan Mak <duncan@ximian.com>
* XslTransform.cs (Laod): Implemented the simple version that
takes one XPathNavigator as argument.
(Save): New private method for recreating the XML in text from a
XPathNavigator
(WriteCurrentNode):
(WriteTree): private methods for generating the text XML from the
XPathNavigator tree.
2002-09-20 Duncan Mak <duncan@ximian.com>
* XslTransform.cs (Load): Implemented the methods, not
including the ones that deal with XPathNavigator (hopefully those
will come later).
(Transform): Implemented the version that saves directly to a file.
(Save): New private method for recreating the XML in text from
from an XmlReader
We're now P/Invoking libxslt for doing XSLT work.
2002-06-23 Piers Haken <piersh@friskit.com>
* XsltContext.cs: added 'PreserveWhitespace' abstract method

View File

@@ -0,0 +1,49 @@
// System.Xml.Xsl.IXsltContextFunction
//
// Author: Tim Coleman <tim@timcoleman.com>
// (C) Copyright 2002 Tim Coleman
//
// 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;
using System.Xml.XPath;
namespace System.Xml.Xsl
{
public interface IXsltContextFunction
{
#region Properties
XPathResultType [] ArgTypes { get; }
int Maxargs { get; }
int Minargs { get; }
XPathResultType ReturnType { get; }
#endregion
#region Methods
object Invoke (XsltContext xsltContext, object [] args, XPathNavigator docContext);
#endregion
}
}

View File

@@ -0,0 +1,48 @@
// System.Xml.Xsl.IXsltContextVariable
//
// Author: Tim Coleman <tim@timcoleman.com>
// (C) Copyright 2002 Tim Coleman
//
// 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;
using System.Xml.XPath;
namespace System.Xml.Xsl
{
public interface IXsltContextVariable
{
#region Properties
bool IsLocal { get; }
bool IsParam { get; }
XPathResultType VariableType { get; }
#endregion
#region Methods
object Evaluate (XsltContext xsltContext);
#endregion
}
}

View File

@@ -0,0 +1,257 @@
// XslCompiledTransform.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// 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;
using System.CodeDom.Compiler;
using System.Collections;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Policy;
using System.Xml.XPath;
using Mono.Xml.Xsl;
namespace System.Xml.Xsl
{
[MonoTODO]
// FIXME: Of cource this is just a stub for now.
public sealed class XslCompiledTransform
{
bool enable_debug;
object debugger;
CompiledStylesheet s;
#if !TARGET_JVM && !MOBILE
// TempFileCollection temporary_files;
#endif
XmlWriterSettings output_settings = new XmlWriterSettings ();
public XslCompiledTransform ()
: this (false)
{
}
public XslCompiledTransform (bool enableDebug)
{
enable_debug = enableDebug;
if (enable_debug)
debugger = new NoOperationDebugger ();
output_settings.ConformanceLevel = ConformanceLevel.Fragment;
}
[MonoTODO]
public XmlWriterSettings OutputSettings {
get { return output_settings; }
}
#if !TARGET_JVM && !MOBILE
[MonoTODO]
public TempFileCollection TemporaryFiles {
get { return null; /*temporary_files;*/ }
}
#endif
#region Transform
public void Transform (string inputUri, string resultsFile)
{
using (Stream outStream = File.Create (resultsFile)) {
Transform (new XPathDocument (inputUri, XmlSpace.Preserve), null, outStream);
}
}
public void Transform (string inputUri, XmlWriter results)
{
Transform (inputUri, null, results);
}
public void Transform (string inputUri, XsltArgumentList arguments, Stream results)
{
Transform (new XPathDocument (inputUri, XmlSpace.Preserve), arguments, results);
}
public void Transform (string inputUri, XsltArgumentList arguments, TextWriter results)
{
Transform (new XPathDocument (inputUri, XmlSpace.Preserve), arguments, results);
}
public void Transform (string inputUri, XsltArgumentList arguments, XmlWriter results)
{
Transform (new XPathDocument (inputUri, XmlSpace.Preserve), arguments, results);
}
public void Transform (XmlReader input, XmlWriter results)
{
Transform (input, null, results);
}
public void Transform (XmlReader input, XsltArgumentList arguments, Stream results)
{
Transform (new XPathDocument (input, XmlSpace.Preserve), arguments, results);
}
public void Transform (XmlReader input, XsltArgumentList arguments, TextWriter results)
{
Transform (new XPathDocument (input, XmlSpace.Preserve), arguments, results);
}
public void Transform (XmlReader input, XsltArgumentList arguments, XmlWriter results)
{
Transform (input, arguments, results, null);
}
public void Transform (IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
{
Transform (input.CreateNavigator (), arguments, results);
}
public void Transform (IXPathNavigable input, XsltArgumentList arguments, Stream results)
{
Transform (input.CreateNavigator (), arguments, results);
}
public void Transform (IXPathNavigable input, XmlWriter results)
{
Transform (input, null, results);
}
public void Transform (IXPathNavigable input, XsltArgumentList arguments, XmlWriter results)
{
Transform (input.CreateNavigator (), arguments, results, null);
}
public void Transform (XmlReader input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
{
Transform (new XPathDocument (input, XmlSpace.Preserve).CreateNavigator (), arguments, results, documentResolver);
}
void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
{
if (s == null)
throw new XsltException ("No stylesheet was loaded.", null);
Outputter outputter = new GenericOutputter (output, s.Outputs, null);
new XslTransformProcessor (s, debugger).Process (input, outputter, args, resolver);
output.Flush ();
}
void Transform (XPathNavigator input, XsltArgumentList args, Stream output)
{
XslOutput xslOutput = (XslOutput)s.Outputs[String.Empty];
Transform (input, args, new StreamWriter (output, xslOutput.Encoding));
}
void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output)
{
if (s == null)
throw new XsltException ("No stylesheet was loaded.", null);
Outputter outputter = new GenericOutputter(output, s.Outputs, output.Encoding);
new XslTransformProcessor (s, debugger).Process (input, outputter, args, null);
outputter.Done ();
output.Flush ();
}
#endregion
#region Load
private XmlReader GetXmlReader (string url)
{
XmlResolver res = new XmlUrlResolver ();
Uri uri = res.ResolveUri (null, url);
Stream s = res.GetEntity (uri, null, typeof (Stream)) as Stream;
XmlTextReader xtr = new XmlTextReader (uri.ToString (), s);
xtr.XmlResolver = res;
XmlValidatingReader xvr = new XmlValidatingReader (xtr);
xvr.XmlResolver = res;
xvr.ValidationType = ValidationType.None;
return xvr;
}
public void Load (string stylesheetUri)
{
using (XmlReader r = GetXmlReader (stylesheetUri)) {
Load (r);
}
}
public void Load (XmlReader stylesheet)
{
Load (stylesheet, null, null);
}
public void Load (IXPathNavigable stylesheet)
{
Load (stylesheet.CreateNavigator(), null, null);
}
public void Load (IXPathNavigable stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
{
Load (stylesheet.CreateNavigator(), settings, stylesheetResolver);
}
public void Load (XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
{
Load (new XPathDocument (stylesheet, XmlSpace.Preserve).CreateNavigator (), settings, stylesheetResolver);
}
public void Load (string stylesheetUri, XsltSettings settings, XmlResolver stylesheetResolver)
{
Load (new XPathDocument (stylesheetUri, XmlSpace.Preserve).CreateNavigator (), settings, stylesheetResolver);
}
private void Load (XPathNavigator stylesheet,
XsltSettings settings, XmlResolver stylesheetResolver)
{
s = new Compiler (debugger, false).Compile (stylesheet, stylesheetResolver, null);
}
#endregion
}
class NoOperationDebugger
{
protected void OnCompile (XPathNavigator input)
{
}
protected void OnExecute (XPathNodeIterator currentNodeset, XPathNavigator style, XsltContext context)
{
//ShowLocationInTrace (style);
}
/*
string ShowLocationInTrace (XPathNavigator style)
{
IXmlLineInfo li = style as IXmlLineInfo;
return li != null ? String.Format ("at {0} ({1},{2})", style.BaseURI, li.LineNumber, li.LinePosition) : "(no debug info available)";
}
*/
}
}

View File

@@ -0,0 +1,298 @@
// System.Xml.Xsl.XslTransform
//
// Authors:
// Tim Coleman <tim@timcoleman.com>
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) Copyright 2002 Tim Coleman
// (c) 2003 Ximian Inc. (http://www.ximian.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;
using System.Collections;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Policy;
using System.Xml.XPath;
using Mono.Xml.Xsl;
namespace System.Xml.Xsl {
internal class SimpleXsltDebugger
{
public void OnCompile (XPathNavigator style)
{
Console.Write ("Compiling: ");
PrintXPathNavigator (style);
Console.WriteLine ();
}
public void OnExecute (XPathNodeIterator currentNodeSet, XPathNavigator style, XsltContext xsltContext)
{
Console.Write ("Executing: ");
PrintXPathNavigator (style);
Console.WriteLine (" / NodeSet: (type {1}) {0} / XsltContext: {2}", currentNodeSet, currentNodeSet.GetType (), xsltContext);
}
void PrintXPathNavigator (XPathNavigator nav)
{
IXmlLineInfo li = nav as IXmlLineInfo;
li = li != null && li.HasLineInfo () ? li : null;
Console.Write ("({0}, {1}) element {2}", li != null ? li.LineNumber : 0, li != null ? li.LinePosition : 0, nav.Name);
}
}
[Obsolete]
public sealed class XslTransform {
internal static readonly bool TemplateStackFrameError;
internal static readonly TextWriter TemplateStackFrameOutput;
static XslTransform ()
{
string env = Environment.GetEnvironmentVariable ("MONO_XSLT_STACK_FRAME");
switch (env) {
case "stdout":
TemplateStackFrameOutput = Console.Out;
break;
case "stderr":
TemplateStackFrameOutput = Console.Error;
break;
case "error":
TemplateStackFrameError = true;
break;
}
}
static object GetDefaultDebugger ()
{
string env = Environment.GetEnvironmentVariable ("MONO_XSLT_DEBUGGER");
if (env == null)
return null;
if (env == "simple")
return new SimpleXsltDebugger ();
object obj = Activator.CreateInstance (Type.GetType (env));
return obj;
}
public XslTransform ()
: this (GetDefaultDebugger ())
{
}
internal XslTransform (object debugger)
{
this.debugger = debugger;
}
object debugger;
CompiledStylesheet s;
XmlResolver xmlResolver = new XmlUrlResolver ();
[MonoTODO] // FIXME: audit security check
public XmlResolver XmlResolver {
set {
xmlResolver = value;
}
}
#region Transform
public XmlReader Transform (IXPathNavigable input, XsltArgumentList args)
{
return Transform (input.CreateNavigator (), args, xmlResolver);
}
public XmlReader Transform (IXPathNavigable input, XsltArgumentList args, XmlResolver resolver)
{
return Transform (input.CreateNavigator (), args, resolver);
}
public XmlReader Transform (XPathNavigator input, XsltArgumentList args)
{
return Transform (input, args, xmlResolver);
}
public XmlReader Transform (XPathNavigator input, XsltArgumentList args, XmlResolver resolver)
{
// todo: is this right?
MemoryStream stream = new MemoryStream ();
Transform (input, args, new XmlTextWriter (stream, null), resolver);
stream.Position = 0;
return new XmlTextReader (stream, XmlNodeType.Element, null);
}
public void Transform (IXPathNavigable input, XsltArgumentList args, TextWriter output)
{
Transform (input.CreateNavigator (), args, output, xmlResolver);
}
public void Transform (IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
{
Transform (input.CreateNavigator (), args, output, resolver);
}
public void Transform (IXPathNavigable input, XsltArgumentList args, Stream output)
{
Transform (input.CreateNavigator (), args, output, xmlResolver);
}
public void Transform (IXPathNavigable input, XsltArgumentList args, Stream output, XmlResolver resolver)
{
Transform (input.CreateNavigator (), args, output, resolver);
}
public void Transform (IXPathNavigable input, XsltArgumentList args, XmlWriter output)
{
Transform (input.CreateNavigator (), args, output, xmlResolver);
}
public void Transform (IXPathNavigable input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
{
Transform (input.CreateNavigator (), args, output, resolver);
}
public void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output)
{
Transform (input, args, output, xmlResolver);
}
public void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
{
if (s == null)
throw new XsltException ("No stylesheet was loaded.", null);
Outputter outputter = new GenericOutputter (output, s.Outputs, null);
new XslTransformProcessor (s, debugger).Process (input, outputter, args, resolver);
output.Flush ();
}
public void Transform (XPathNavigator input, XsltArgumentList args, Stream output)
{
Transform (input, args, output, xmlResolver);
}
public void Transform (XPathNavigator input, XsltArgumentList args, Stream output, XmlResolver resolver)
{
XslOutput xslOutput = (XslOutput)s.Outputs[String.Empty];
Transform (input, args, new StreamWriter (output, xslOutput.Encoding), resolver);
}
public void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output)
{
Transform (input, args, output, xmlResolver);
}
public void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
{
if (s == null)
throw new XsltException ("No stylesheet was loaded.", null);
Outputter outputter = new GenericOutputter(output, s.Outputs, output.Encoding);
new XslTransformProcessor (s, debugger).Process (input, outputter, args, resolver);
outputter.Done ();
output.Flush ();
}
public void Transform (string inputfile, string outputfile)
{
Transform (inputfile, outputfile, xmlResolver);
}
public void Transform (string inputfile, string outputfile, XmlResolver resolver)
{
using (Stream s = new FileStream (outputfile, FileMode.Create, FileAccess.ReadWrite)) {
Transform(new XPathDocument (inputfile).CreateNavigator (), null, s, resolver);
}
}
#endregion
#region Load
public void Load (string url)
{
Load (url, null);
}
public void Load (string url, XmlResolver resolver)
{
XmlResolver res = resolver;
if (res == null)
res = new XmlUrlResolver ();
Uri uri = res.ResolveUri (null, url);
using (Stream s = res.GetEntity (uri, null, typeof (Stream)) as Stream) {
XmlTextReader xtr = new XmlTextReader (uri.ToString (), s);
xtr.XmlResolver = res;
XmlValidatingReader xvr = new XmlValidatingReader (xtr);
xvr.XmlResolver = res;
xvr.ValidationType = ValidationType.None;
Load (new XPathDocument (xvr, XmlSpace.Preserve).CreateNavigator (), resolver, null);
}
}
public void Load (XmlReader stylesheet)
{
Load (stylesheet, null, null);
}
public void Load (XmlReader stylesheet, XmlResolver resolver)
{
Load (stylesheet, resolver, null);
}
public void Load (XPathNavigator stylesheet)
{
Load (stylesheet, null, null);
}
public void Load (XPathNavigator stylesheet, XmlResolver resolver)
{
Load (stylesheet, resolver, null);
}
public void Load (IXPathNavigable stylesheet)
{
Load (stylesheet.CreateNavigator(), null);
}
public void Load (IXPathNavigable stylesheet, XmlResolver resolver)
{
Load (stylesheet.CreateNavigator(), resolver);
}
// Introduced in .NET 1.1
public void Load (IXPathNavigable stylesheet, XmlResolver resolver, Evidence evidence)
{
Load (stylesheet.CreateNavigator(), resolver, evidence);
}
public void Load (XPathNavigator stylesheet, XmlResolver resolver, Evidence evidence)
{
s = new Compiler (debugger, true).Compile (stylesheet, resolver, evidence);
}
public void Load (XmlReader stylesheet, XmlResolver resolver, Evidence evidence)
{
Load (new XPathDocument (stylesheet, XmlSpace.Preserve).CreateNavigator (), resolver, evidence);
}
#endregion
}
}

View File

@@ -0,0 +1,159 @@
// System.Xml.Xsl.XsltArgumentList
//
// Author: Tim Coleman <tim@timcoleman.com>
// (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
{
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
#pragma warning disable 67
[MonoTODO]
public event XsltMessageEncounteredEventHandler XsltMessageEncountered;
#pragma warning restore 67
#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
}
}

View File

@@ -0,0 +1,84 @@
//
// System.Xml.Xsl.XsltCompileException.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) Copyright 2002 Tim Coleman
// (C) 2003 Andreas Nahr
// 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.Runtime.Serialization;
using System.Xml.XPath;
using System.Security.Permissions;
namespace System.Xml.Xsl
{
[Serializable]
public class XsltCompileException : XsltException
{
#region Constructors
public XsltCompileException ()
{
}
public XsltCompileException (string message)
: base (message)
{
}
public XsltCompileException (string message, Exception innerException)
: base (message, innerException)
{
}
protected XsltCompileException (SerializationInfo info, StreamingContext context )
: base (info, context)
{
}
public XsltCompileException (Exception inner, String sourceUri, int lineNumber, int linePosition)
: base (lineNumber != 0 ? "{0} at {1}({2},{3}). See InnerException for details." : "{0}.",
"XSLT compile error", inner, lineNumber, linePosition, sourceUri)
{
}
internal XsltCompileException (string message, Exception innerException, XPathNavigator nav)
: base (message, innerException, nav)
{
}
#endregion
#region Methods
[SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
}
#endregion
}
}

View File

@@ -0,0 +1,85 @@
// System.Xml.Xsl.XsltContext
//
// Author: Tim Coleman <tim@timcoleman.com>
// (C) Copyright 2002 Tim Coleman
//
// 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;
using System.Xml;
using System.Xml.XPath;
namespace System.Xml.Xsl
{
public abstract class XsltContext : XmlNamespaceManager
{
#region Constructors
protected XsltContext ()
: base (new NameTable ())
{
}
protected XsltContext (NameTable table)
: base (table)
{
}
#endregion
#region Properties
public abstract bool Whitespace { get; }
public abstract bool PreserveWhitespace (XPathNavigator node);
#endregion
#region Methods
public abstract int CompareDocument (string baseUri, string nextbaseUri);
public abstract IXsltContextFunction ResolveFunction (string prefix, string name, XPathResultType [] ArgTypes);
public abstract IXsltContextVariable ResolveVariable (string prefix, string name);
#endregion
#region XSLT Internal Calls
internal virtual IXsltContextVariable ResolveVariable (XmlQualifiedName name)
{
return ResolveVariable (LookupPrefix (name.Namespace), name.Name);
}
internal virtual IXsltContextFunction ResolveFunction (XmlQualifiedName name, XPathResultType [] argTypes)
{
return ResolveFunction (name.Name, name.Namespace, argTypes);
}
#endregion
}
// The static XSLT context, will try to simplify what it can
internal interface IStaticXsltContext
{
Expression TryGetVariable (string nm);
Expression TryGetFunction (XmlQualifiedName nm, FunctionArguments args);
XmlQualifiedName LookupQName (string s);
string LookupNamespace (string prefix);
}
}

View File

@@ -0,0 +1,156 @@
//
// System.Xml.Xsl.XsltException.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) Copyright 2002 Tim Coleman
// (C) 2003 Andreas Nahr
// 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.Globalization;
using System.Runtime.Serialization;
using System.Xml.XPath;
using System.Security.Permissions;
namespace System.Xml.Xsl
{
[Serializable]
public class XsltException : SystemException
{
static string CreateMessage (string message, XPathNavigator nav)
{
IXmlLineInfo li = nav as IXmlLineInfo;
int lineNumber = li != null ? li.LineNumber : 0;
int linePosition = li != null ? li.LinePosition : 0;
string sourceUri = nav != null ? nav.BaseURI : string.Empty;
if (lineNumber != 0) {
return CreateMessage ("{0} at {1}({2},{3}).", message, lineNumber, linePosition, sourceUri);
}
return CreateMessage ("{0}.", message, lineNumber, linePosition, sourceUri);
}
static string CreateMessage (string msgFormat, string message, int lineNumber, int linePosition, string sourceUri)
{
return string.Format (CultureInfo.InvariantCulture, msgFormat,
message, sourceUri, lineNumber.ToString (CultureInfo.InvariantCulture),
linePosition.ToString (CultureInfo.InvariantCulture));
}
#region Fields
int lineNumber;
int linePosition;
string sourceUri;
string templateFrames;
#endregion
#region Constructors
public XsltException ()
: this (string.Empty, (Exception) null)
{
}
public XsltException (string message)
: this (message, (Exception) null)
{
}
public XsltException (string message, Exception innerException)
: this ("{0}", message, innerException, 0, 0, (string) null)
{
}
protected XsltException (SerializationInfo info, StreamingContext context)
{
lineNumber = info.GetInt32 ("lineNumber");
linePosition = info.GetInt32 ("linePosition");
sourceUri = info.GetString ("sourceUri");
templateFrames = info.GetString ("templateFrames");
}
internal XsltException (string msgFormat, string message, Exception innerException, int lineNumber, int linePosition, string sourceUri)
: base (CreateMessage (msgFormat, message, lineNumber, linePosition, sourceUri), innerException)
{
this.lineNumber = lineNumber;
this.linePosition = linePosition;
this.sourceUri = sourceUri;
}
internal XsltException (string message, Exception innerException, XPathNavigator nav)
: base (CreateMessage (message, nav), innerException)
{
IXmlLineInfo li = nav as IXmlLineInfo;
this.lineNumber = li != null ? li.LineNumber : 0;
this.linePosition = li != null ? li.LinePosition : 0;
this.sourceUri = nav != null ? nav.BaseURI : string.Empty;
}
#endregion
#region Properties
public virtual int LineNumber {
get { return lineNumber; }
}
public virtual int LinePosition {
get { return linePosition; }
}
public override string Message {
get {
return templateFrames != null ? base.Message + templateFrames : base.Message;
}
}
public virtual string SourceUri {
get { return sourceUri; }
}
#endregion
#region Methods
[SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
info.AddValue ("lineNumber", lineNumber);
info.AddValue ("linePosition", linePosition);
info.AddValue ("sourceUri", sourceUri);
info.AddValue ("templateFrames", templateFrames);
}
internal void AddTemplateFrame (string frame)
{
templateFrames += frame;
}
#endregion
}
}

View File

@@ -0,0 +1,43 @@
//
// XsltMessageEncounteredEventArgs.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2005, Novell Inc,
//
//
// 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;
namespace System.Xml.Xsl
{
public abstract class XsltMessageEncounteredEventArgs : EventArgs
{
public abstract string Message { get; }
protected XsltMessageEncounteredEventArgs ()
{
}
}
}

View File

@@ -0,0 +1,35 @@
//
// XsltMessageEncounteredEventHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2005 Novell Inc,
//
//
// 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.
//
namespace System.Xml.Xsl
{
public delegate void XsltMessageEncounteredEventHandler (
Object sender, XsltMessageEncounteredEventArgs e);
}

View File

@@ -0,0 +1,92 @@
//
// XsltSettings.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2005 Novell Inc,
//
//
// 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.
//
namespace System.Xml.Xsl
{
public sealed class XsltSettings
{
static readonly XsltSettings defaultSettings;
static readonly XsltSettings trustedXslt;
static XsltSettings ()
{
defaultSettings = new XsltSettings (true);
trustedXslt = new XsltSettings (true);
trustedXslt.enableDocument = true;
trustedXslt.enableScript = true;
}
public static XsltSettings Default {
get { return defaultSettings; }
}
public static XsltSettings TrustedXslt {
get { return trustedXslt; }
}
bool readOnly;
bool enableDocument;
bool enableScript;
public XsltSettings ()
{
}
public XsltSettings (bool enableDocumentFunction,
bool enableScript)
{
this.enableDocument = enableDocumentFunction;
this.enableScript = enableScript;
}
private XsltSettings (bool readOnly)
{
this.readOnly = readOnly;
}
public bool EnableDocumentFunction {
get { return enableDocument; }
set {
if (!readOnly)
enableDocument = value;
// otherwise silently ignored.
}
}
public bool EnableScript {
get { return enableScript; }
set {
if (!readOnly)
enableScript = value;
// otherwise silently ignored.
}
}
}
}