1 // System.Xml.Xsl.XslTransform
4 // Tim Coleman <tim@timcoleman.com>
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) Copyright 2002 Tim Coleman
8 // (c) 2003 Ximian Inc. (http://www.ximian.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Collections
;
36 using System
.Runtime
.InteropServices
;
37 using System
.Security
;
38 using System
.Security
.Policy
;
39 using System
.Xml
.XPath
;
41 namespace System
.Xml
.Xsl
{
42 public sealed class XslTransform
{
44 XmlResolver xmlResolver
= new XmlUrlResolver ();
45 XslTransformImpl impl
;
48 public XslTransform ()
50 if (Environment
.GetEnvironmentVariable ("MONO_UNMANAGED_XSLT") == null)
51 impl
= new ManagedXslTransform ();
53 impl
= new UnmanagedXslTransform ();
57 [MonoTODO ("Security check.")]
59 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
61 public XmlResolver XmlResolver
{
69 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
71 public XmlReader
Transform (IXPathNavigable input
, XsltArgumentList args
)
73 return Transform (input
.CreateNavigator (), args
, xmlResolver
);
77 public XmlReader
Transform (IXPathNavigable input
, XsltArgumentList args
, XmlResolver resolver
)
79 XmlReader
Transform (IXPathNavigable input
, XsltArgumentList args
, XmlResolver resolver
)
82 return Transform (input
.CreateNavigator (), args
, resolver
);
86 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
88 public XmlReader
Transform (XPathNavigator input
, XsltArgumentList args
)
90 return Transform (input
, args
, xmlResolver
);
93 public XmlReader
Transform (XPathNavigator input
, XsltArgumentList args
, XmlResolver resolver
)
95 XmlReader
Transform (XPathNavigator input
, XsltArgumentList args
, XmlResolver resolver
)
98 // todo: is this right?
99 MemoryStream stream
= new MemoryStream ();
100 Transform (input
, args
, new XmlTextWriter (stream
, null), resolver
);
102 return new XmlTextReader (stream
);
106 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
108 public void Transform (IXPathNavigable input
, XsltArgumentList args
, TextWriter output
)
110 Transform (input
.CreateNavigator (), args
, output
, xmlResolver
);
113 public void Transform (IXPathNavigable input
, XsltArgumentList args
, TextWriter output
, XmlResolver resolver
)
115 void Transform (IXPathNavigable input
, XsltArgumentList args
, TextWriter output
, XmlResolver resolver
)
118 Transform (input
.CreateNavigator (), args
, output
, resolver
);
122 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
124 public void Transform (IXPathNavigable input
, XsltArgumentList args
, Stream output
)
126 Transform (input
.CreateNavigator (), args
, output
, xmlResolver
);
129 public void Transform (IXPathNavigable input
, XsltArgumentList args
, Stream output
, XmlResolver resolver
)
131 void Transform (IXPathNavigable input
, XsltArgumentList args
, Stream output
, XmlResolver resolver
)
134 Transform (input
.CreateNavigator (), args
, output
, resolver
);
138 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
140 public void Transform (IXPathNavigable input
, XsltArgumentList args
, XmlWriter output
)
142 Transform (input
.CreateNavigator (), args
, output
, xmlResolver
);
145 public void Transform (IXPathNavigable input
, XsltArgumentList args
, XmlWriter output
, XmlResolver resolver
)
147 void Transform (IXPathNavigable input
, XsltArgumentList args
, XmlWriter output
, XmlResolver resolver
)
150 Transform (input
.CreateNavigator (), args
, output
, resolver
);
154 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
156 public void Transform (XPathNavigator input
, XsltArgumentList args
, XmlWriter output
)
158 impl
.Transform (input
, args
, output
, xmlResolver
);
161 public void Transform (XPathNavigator input
, XsltArgumentList args
, XmlWriter output
, XmlResolver resolver
)
163 void Transform (XPathNavigator input
, XsltArgumentList args
, XmlWriter output
, XmlResolver resolver
)
166 impl
.Transform (input
, args
, output
, resolver
);
170 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
172 public void Transform (XPathNavigator input
, XsltArgumentList args
, Stream output
)
174 impl
.Transform (input
, args
, output
, xmlResolver
);
177 public void Transform (XPathNavigator input
, XsltArgumentList args
, Stream output
, XmlResolver resolver
)
179 void Transform (XPathNavigator input
, XsltArgumentList args
, Stream output
, XmlResolver resolver
)
182 impl
.Transform (input
, args
, output
, resolver
);
186 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
188 public void Transform (XPathNavigator input
, XsltArgumentList args
, TextWriter output
)
190 impl
.Transform (input
, args
, output
, xmlResolver
);
193 public void Transform (XPathNavigator input
, XsltArgumentList args
, TextWriter output
, XmlResolver resolver
)
195 void Transform(XPathNavigator input
, XsltArgumentList args
, TextWriter output
, XmlResolver resolver
)
198 impl
.Transform (input
, args
, output
, resolver
);
202 [Obsolete ("You should pass XmlResolver to Transform() method", false)]
204 public void Transform (string inputfile
, string outputfile
)
206 impl
.Transform (inputfile
, outputfile
, xmlResolver
);
210 public void Transform (string inputfile
, string outputfile
, XmlResolver resolver
)
212 void Transform (string inputfile
, string outputfile
, XmlResolver resolver
)
215 impl
.Transform (inputfile
, outputfile
, resolver
);
220 public void Load (string url
)
225 public void Load (string url
, XmlResolver resolver
)
227 impl
.Load (url
, resolver
);
231 [Obsolete("You should pass evidence.", false)]
233 public void Load (XmlReader stylesheet
)
235 Load (stylesheet
, null, null);
239 [Obsolete("You should pass evidence.", false)]
241 public void Load (XmlReader stylesheet
, XmlResolver resolver
)
243 Load (stylesheet
, resolver
, null);
247 [Obsolete("You should pass evidence.", false)]
249 public void Load (XPathNavigator stylesheet
)
251 Load (stylesheet
, null, null);
255 [Obsolete("You should pass evidence.", false)]
257 public void Load (XPathNavigator stylesheet
, XmlResolver resolver
)
259 Load (stylesheet
, resolver
, null);
263 [Obsolete("You should pass evidence.", false)]
265 public void Load (IXPathNavigable stylesheet
)
267 Load (stylesheet
.CreateNavigator(), null);
271 [Obsolete("You should pass evidence.", false)]
273 public void Load (IXPathNavigable stylesheet
, XmlResolver resolver
)
275 Load (stylesheet
.CreateNavigator(), resolver
);
278 // Introduced in .NET 1.1
280 public void Load (IXPathNavigable stylesheet
, XmlResolver resolver
, Evidence evidence
)
282 internal void Load (IXPathNavigable stylesheet
, XmlResolver resolver
, Evidence evidence
)
285 impl
.Load (stylesheet
.CreateNavigator(), resolver
, evidence
);
289 public void Load (XPathNavigator stylesheet
, XmlResolver resolver
, Evidence evidence
)
291 internal void Load (XPathNavigator stylesheet
, XmlResolver resolver
, Evidence evidence
)
294 impl
.Load (stylesheet
, resolver
, evidence
);
298 public void Load (XmlReader stylesheet
, XmlResolver resolver
, Evidence evidence
)
300 internal void Load (XmlReader stylesheet
, XmlResolver resolver
, Evidence evidence
)
303 impl
.Load (stylesheet
, resolver
, null);