2 // System.Web.UI.WebControls.Xml.cs
5 // Miguel de Icaza (miguel@novell.com)
7 // (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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;
36 using System.Xml.XPath;
37 using System.Collections;
40 namespace System.Web.UI.WebControls {
43 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
44 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
46 [DefaultProperty ("DocumentSource")]
47 [Designer ("System.Web.UI.Design.WebControls.XmlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
49 [PersistChildren (true)]
51 [PersistChildren (false)]
53 [ControlBuilder (typeof (XmlBuilder))]
54 public class Xml : Control {
55 // Property set variables
56 XmlDocument xml_document;
60 XslTransform xsl_transform;
61 XsltArgumentList transform_arguments;
62 string transform_file;
73 [EditorBrowsable (EditorBrowsableState.Never)]
74 [MonoTODO ("Anything else?")]
75 public override string ClientID
82 [MonoTODO ("Anything else?")]
83 [EditorBrowsable (EditorBrowsableState.Never)]
84 public override ControlCollection Controls
94 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
96 [Obsolete ("Use the XPathNavigator property instead by creating an XPathDocument and calling CreateNavigator().")]
98 public XmlDocument Document {
106 xml_document = value;
111 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
112 public string DocumentContent {
130 [Editor ("System.Web.UI.Design.XmlUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
132 [Editor ("System.Web.UI.Design.XmlUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
134 [WebSysDescription ("")]
135 [WebCategory ("Behavior")]
136 public string DocumentSource {
138 if (xml_file == null)
152 [EditorBrowsable (EditorBrowsableState.Never)]
154 [DefaultValue (false)]
155 [MonoTODO ("Theming is not implemented")]
156 public override bool EnableTheming
159 return enable_theming;
162 enable_theming = value;
167 [EditorBrowsable (EditorBrowsableState.Never)]
170 public override string SkinID
183 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
184 [WebSysDescription ("")]
185 [WebCategory ("Behavior")]
186 public XslTransform Transform {
188 return xsl_transform;
192 transform_file = null;
193 xsl_transform = value;
198 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
199 [WebSysDescription ("")]
200 [WebCategory ("Behavior")]
201 public XsltArgumentList TransformArgumentList {
203 return transform_arguments;
207 transform_arguments = value;
216 [Editor ("System.Web.UI.Design.XslUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
218 [Editor ("System.Web.UI.Design.XslUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
220 public string TransformSource {
222 if (transform_file == null)
224 return transform_file;
228 transform_file = value;
229 xsl_transform = null;
234 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
237 public XPathNavigator XPathNavigator
240 throw new NotImplementedException ();
243 throw new NotImplementedException ();
247 [EditorBrowsable (EditorBrowsableState.Never)]
248 public override Control FindControl (string id)
253 [EditorBrowsable (EditorBrowsableState.Never)]
254 public override void Focus ()
258 [EditorBrowsable (EditorBrowsableState.Never)]
259 public override bool HasControls ()
270 override void Render (HtmlTextWriter output)
274 if (xml_document != null)
275 xml_doc = xml_document;
277 if (xml_content != null){
278 xml_doc = new XmlDocument ();
279 xml_doc.LoadXml (xml_content);
280 } else if (xml_file != null){
281 xml_doc = new XmlDocument ();
282 xml_doc.Load (MapPathSecure (xml_file));
287 XslTransform t = xsl_transform;
288 if (transform_file != null){
289 t = new XslTransform ();
290 t.Load (MapPathSecure (transform_file));
294 t.Transform (xml_doc, transform_arguments, output, null);
298 XmlTextWriter xmlwriter = new XmlTextWriter (output);
299 xmlwriter.Formatting = Formatting.None;
300 xml_doc.Save (xmlwriter);
304 protected override void AddParsedSubObject (object obj)
306 LiteralControl lc = obj as LiteralControl;
309 xml_document = new XmlDocument ();
310 xml_document.LoadXml (lc.Text);
312 throw new HttpException (
313 String.Format ("Objects of type {0} are not supported as children of the Xml control",
319 protected override ControlCollection CreateControlCollection ()
321 return new EmptyControlCollection (this);
325 protected override IDictionary GetDesignModeState ()