Multiplexer.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. // System.Xml.Xsl.XslTransform
  2. //
  3. // Authors:
  4. // Tim Coleman <[email protected]>
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) Copyright 2002 Tim Coleman
  8. // (c) 2003 Ximian Inc. (http://www.ximian.com)
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System;
  31. using System.Collections;
  32. using System.IO;
  33. using System.Text;
  34. using System.Runtime.InteropServices;
  35. using System.Security;
  36. using System.Security.Policy;
  37. using System.Xml.XPath;
  38. namespace System.Xml.Xsl {
  39. public sealed class XslTransform {
  40. XmlResolver xmlResolver = new XmlUrlResolver ();
  41. XslTransformImpl impl;
  42. #region Constructors
  43. public XslTransform ()
  44. {
  45. if (Environment.GetEnvironmentVariable ("MONO_UNMANAGED_XSLT") == null)
  46. impl = new ManagedXslTransform ();
  47. else
  48. impl = new UnmanagedXslTransform ();
  49. }
  50. #endregion
  51. [MonoTODO ("Security check.")]
  52. #if NET_1_1
  53. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  54. #endif
  55. public XmlResolver XmlResolver {
  56. set {
  57. xmlResolver = value;
  58. }
  59. }
  60. #region Transform
  61. #if NET_1_1
  62. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  63. #endif
  64. public XmlReader Transform (IXPathNavigable input, XsltArgumentList args)
  65. {
  66. return Transform (input.CreateNavigator (), args, xmlResolver);
  67. }
  68. #if NET_1_1
  69. public XmlReader Transform (IXPathNavigable input, XsltArgumentList args, XmlResolver resolver)
  70. #else
  71. XmlReader Transform (IXPathNavigable input, XsltArgumentList args, XmlResolver resolver)
  72. #endif
  73. {
  74. return Transform (input.CreateNavigator (), args, resolver);
  75. }
  76. #if NET_1_1
  77. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  78. #endif
  79. public XmlReader Transform (XPathNavigator input, XsltArgumentList args)
  80. {
  81. return Transform (input, args, xmlResolver);
  82. }
  83. #if NET_1_1
  84. public XmlReader Transform (XPathNavigator input, XsltArgumentList args, XmlResolver resolver)
  85. #else
  86. XmlReader Transform (XPathNavigator input, XsltArgumentList args, XmlResolver resolver)
  87. #endif
  88. {
  89. // todo: is this right?
  90. MemoryStream stream = new MemoryStream ();
  91. Transform (input, args, new XmlTextWriter (stream, null), resolver);
  92. stream.Position = 0;
  93. return new XmlTextReader (stream);
  94. }
  95. #if NET_1_1
  96. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  97. #endif
  98. public void Transform (IXPathNavigable input, XsltArgumentList args, TextWriter output)
  99. {
  100. Transform (input.CreateNavigator (), args, output, xmlResolver);
  101. }
  102. #if NET_1_1
  103. public void Transform (IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
  104. #else
  105. void Transform (IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
  106. #endif
  107. {
  108. Transform (input.CreateNavigator (), args, output, resolver);
  109. }
  110. #if NET_1_1
  111. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  112. #endif
  113. public void Transform (IXPathNavigable input, XsltArgumentList args, Stream output)
  114. {
  115. Transform (input.CreateNavigator (), args, output, xmlResolver);
  116. }
  117. #if NET_1_1
  118. public void Transform (IXPathNavigable input, XsltArgumentList args, Stream output, XmlResolver resolver)
  119. #else
  120. void Transform (IXPathNavigable input, XsltArgumentList args, Stream output, XmlResolver resolver)
  121. #endif
  122. {
  123. Transform (input.CreateNavigator (), args, output, resolver);
  124. }
  125. #if NET_1_1
  126. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  127. #endif
  128. public void Transform (IXPathNavigable input, XsltArgumentList args, XmlWriter output)
  129. {
  130. Transform (input.CreateNavigator (), args, output, xmlResolver);
  131. }
  132. #if NET_1_1
  133. public void Transform (IXPathNavigable input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
  134. #else
  135. void Transform (IXPathNavigable input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
  136. #endif
  137. {
  138. Transform (input.CreateNavigator (), args, output, resolver);
  139. }
  140. #if NET_1_1
  141. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  142. #endif
  143. public void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output)
  144. {
  145. impl.Transform (input, args, output, xmlResolver);
  146. }
  147. #if NET_1_1
  148. public void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
  149. #else
  150. void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
  151. #endif
  152. {
  153. impl.Transform (input, args, output, resolver);
  154. }
  155. #if NET_1_1
  156. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  157. #endif
  158. public void Transform (XPathNavigator input, XsltArgumentList args, Stream output)
  159. {
  160. impl.Transform (input, args, output, xmlResolver);
  161. }
  162. #if NET_1_1
  163. public void Transform (XPathNavigator input, XsltArgumentList args, Stream output, XmlResolver resolver)
  164. #else
  165. void Transform (XPathNavigator input, XsltArgumentList args, Stream output, XmlResolver resolver)
  166. #endif
  167. {
  168. impl.Transform (input, args, output, resolver);
  169. }
  170. #if NET_1_1
  171. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  172. #endif
  173. public void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output)
  174. {
  175. impl.Transform (input, args, output, xmlResolver);
  176. }
  177. #if NET_1_1
  178. public void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
  179. #else
  180. void Transform(XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
  181. #endif
  182. {
  183. impl.Transform (input, args, output, resolver);
  184. }
  185. #if NET_1_1
  186. [Obsolete ("You should pass XmlResolver to Transform() method", false)]
  187. #endif
  188. public void Transform (string inputfile, string outputfile)
  189. {
  190. impl.Transform (inputfile, outputfile, xmlResolver);
  191. }
  192. #if NET_1_1
  193. public void Transform (string inputfile, string outputfile, XmlResolver resolver)
  194. #else
  195. void Transform (string inputfile, string outputfile, XmlResolver resolver)
  196. #endif
  197. {
  198. impl.Transform (inputfile, outputfile, resolver);
  199. }
  200. #endregion
  201. #region Load
  202. public void Load (string url)
  203. {
  204. Load (url, null);
  205. }
  206. public void Load (string url, XmlResolver resolver)
  207. {
  208. impl.Load (url, resolver);
  209. }
  210. #if NET_1_1
  211. [Obsolete("You should pass evidence.", false)]
  212. #endif
  213. public void Load (XmlReader stylesheet)
  214. {
  215. Load (stylesheet, null, null);
  216. }
  217. #if NET_1_1
  218. [Obsolete("You should pass evidence.", false)]
  219. #endif
  220. public void Load (XmlReader stylesheet, XmlResolver resolver)
  221. {
  222. Load (stylesheet, resolver, null);
  223. }
  224. #if NET_1_1
  225. [Obsolete("You should pass evidence.", false)]
  226. #endif
  227. public void Load (XPathNavigator stylesheet)
  228. {
  229. Load (stylesheet, null, null);
  230. }
  231. #if NET_1_1
  232. [Obsolete("You should pass evidence.", false)]
  233. #endif
  234. public void Load (XPathNavigator stylesheet, XmlResolver resolver)
  235. {
  236. Load (stylesheet, resolver, null);
  237. }
  238. #if NET_1_1
  239. [Obsolete("You should pass evidence.", false)]
  240. #endif
  241. public void Load (IXPathNavigable stylesheet)
  242. {
  243. Load (stylesheet.CreateNavigator(), null);
  244. }
  245. #if NET_1_1
  246. [Obsolete("You should pass evidence.", false)]
  247. #endif
  248. public void Load (IXPathNavigable stylesheet, XmlResolver resolver)
  249. {
  250. Load (stylesheet.CreateNavigator(), resolver);
  251. }
  252. // Introduced in .NET 1.1
  253. #if NET_1_1
  254. public void Load (IXPathNavigable stylesheet, XmlResolver resolver, Evidence evidence)
  255. #else
  256. internal void Load (IXPathNavigable stylesheet, XmlResolver resolver, Evidence evidence)
  257. #endif
  258. {
  259. impl.Load (stylesheet.CreateNavigator(), resolver, evidence);
  260. }
  261. #if NET_1_1
  262. public void Load (XPathNavigator stylesheet, XmlResolver resolver, Evidence evidence)
  263. #else
  264. internal void Load (XPathNavigator stylesheet, XmlResolver resolver, Evidence evidence)
  265. #endif
  266. {
  267. impl.Load (stylesheet, resolver, evidence);
  268. }
  269. #if NET_1_1
  270. public void Load (XmlReader stylesheet, XmlResolver resolver, Evidence evidence)
  271. #else
  272. internal void Load (XmlReader stylesheet, XmlResolver resolver, Evidence evidence)
  273. #endif
  274. {
  275. impl.Load (stylesheet, resolver, null);
  276. }
  277. #endregion
  278. }
  279. }