[bcl] Remove ONLY_1_1 defines from class libs
[mono-project.git] / mcs / class / System.Web / System.Web.UI.WebControls / Xml.cs
blob940602eb3ddd5a1600710580bffd3e53738de388
1 //
2 // System.Web.UI.WebControls.Xml.cs
3 //
4 // Authors:
5 // Miguel de Icaza (miguel@novell.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.ComponentModel;
31 using System.Security.Permissions;
32 using System.Xml;
33 using System.Xml.Xsl;
35 using System.Xml.XPath;
36 using System.Collections;
38 namespace System.Web.UI.WebControls {
40 // CAS
41 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
42 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
43 // attributes
44 [DefaultProperty ("DocumentSource")]
45 [Designer ("System.Web.UI.Design.WebControls.XmlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
46 [PersistChildren (true)]
47 [ControlBuilder (typeof (XmlBuilder))]
48 public class Xml : Control {
49 // Property set variables
50 XmlDocument xml_document;
51 XPathNavigator xpath_navigator;
52 string xml_content;
53 string xml_file;
55 XslTransform xsl_transform;
56 XsltArgumentList transform_arguments;
57 string transform_file;
59 public Xml ()
63 [EditorBrowsable (EditorBrowsableState.Never)]
64 [MonoTODO ("Anything else?")]
65 public override string ClientID
67 get {
68 return base.ClientID;
72 [MonoTODO ("Anything else?")]
73 [EditorBrowsable (EditorBrowsableState.Never)]
74 public override ControlCollection Controls
76 get {
77 return base.Controls;
82 [Browsable(false)]
83 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
84 [Obsolete ("Use the XPathNavigator property instead by creating an XPathDocument and calling CreateNavigator().")]
85 public XmlDocument Document {
86 get {
87 return xml_document;
90 set {
91 xml_content = null;
92 xml_file = null;
93 xml_document = value;
97 [Browsable(false)]
98 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
99 public string DocumentContent {
100 get {
101 return (xml_content != null)? xml_content : "";
104 set {
105 xml_content = value;
106 xml_file = null;
107 xml_document = null;
111 [DefaultValue ("")]
112 [UrlProperty]
113 [Editor ("System.Web.UI.Design.XmlUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
114 [WebSysDescription ("")]
115 [WebCategory ("Behavior")]
116 [MonoLimitation ("Absolute path to the file system is not supported; use a relative URI instead.")]
117 public string DocumentSource {
118 get {
119 if (xml_file == null)
120 return "";
122 return xml_file;
125 set {
126 xml_content = null;
127 xml_file = value;
128 xml_document = null;
132 [EditorBrowsable (EditorBrowsableState.Never)]
133 [Browsable (false)]
134 [DefaultValue (false)]
135 public override bool EnableTheming
137 get { return false; }
138 set { throw new NotSupportedException (); }
141 [DefaultValue ("")]
142 [EditorBrowsable (EditorBrowsableState.Never)]
143 [Browsable (false)]
144 public override string SkinID
146 // MSDN: Always returns an empty string (""). This property is not supported.
147 get { return String.Empty; }
148 // MSDN: Any attempt to set the value of this property throws a NotSupportedException exception.
149 set { throw new NotSupportedException ("SkinID is not supported on Xml control"); }
153 [Browsable (false)]
154 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
155 [WebSysDescription ("")]
156 [WebCategory ("Behavior")]
157 public XslTransform Transform {
158 get {
159 return xsl_transform;
162 set {
163 transform_file = null;
164 xsl_transform = value;
168 [Browsable (false)]
169 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
170 [WebSysDescription ("")]
171 [WebCategory ("Behavior")]
172 public XsltArgumentList TransformArgumentList {
173 get {
174 return transform_arguments;
177 set {
178 transform_arguments = value;
182 [DefaultValue ("")]
183 [Editor ("System.Web.UI.Design.XslUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
184 [MonoLimitation ("Absolute path to the file system is not supported; use a relative URI instead.")]
185 public string TransformSource {
186 get {
187 if (transform_file == null)
188 return "";
189 return transform_file;
192 set {
193 transform_file = value;
194 xsl_transform = null;
198 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
199 [Browsable (false)]
200 public XPathNavigator XPathNavigator
202 get { return xpath_navigator; }
203 set { xpath_navigator = value; }
206 [EditorBrowsable (EditorBrowsableState.Never)]
207 public override Control FindControl (string id)
209 return null;
212 [EditorBrowsable (EditorBrowsableState.Never)]
213 public override void Focus ()
215 throw new NotSupportedException ();
218 [EditorBrowsable (EditorBrowsableState.Never)]
219 public override bool HasControls ()
221 return false;
224 protected internal
225 override void Render (HtmlTextWriter output)
227 XmlDocument xml_doc = null;
229 if (xpath_navigator == null) {
230 if (xml_document != null)
231 xml_doc = xml_document;
232 else {
233 if (xml_content != null) {
234 xml_doc = new XmlDocument ();
235 xml_doc.LoadXml (xml_content);
237 else if (xml_file != null) {
238 xml_doc = new XmlDocument ();
239 xml_doc.Load (MapPathSecure (xml_file));
241 else
242 return;
246 XslTransform t = xsl_transform;
247 if (transform_file != null){
248 t = new XslTransform ();
249 t.Load (MapPathSecure (transform_file));
252 if (t != null){
253 if (xpath_navigator != null) {
254 t.Transform(xpath_navigator, transform_arguments, output);
256 else {
257 t.Transform (xml_doc, transform_arguments, output, null);
259 return;
262 XmlTextWriter xmlwriter = new XmlTextWriter (output);
263 xmlwriter.Formatting = Formatting.None;
264 if (xpath_navigator != null) {
265 xmlwriter.WriteStartDocument ();
266 xpath_navigator.WriteSubtree (xmlwriter);
268 else {
269 xml_doc.Save (xmlwriter);
273 protected override void AddParsedSubObject (object obj)
275 LiteralControl lc = obj as LiteralControl;
277 if (lc != null){
278 xml_document = new XmlDocument ();
279 xml_document.LoadXml (lc.Text);
280 } else {
281 throw new HttpException (
282 String.Format ("Objects of type {0} are not supported as children of the Xml control",
283 obj.GetType ()));
287 protected override ControlCollection CreateControlCollection ()
289 return new EmptyControlCollection (this);
292 [MonoTODO("Always returns null")]
293 protected override IDictionary GetDesignModeState ()
295 return null;