2003-07-30 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Xml.cs
index e3dc8d4a23d449fe9c3bc02415c8221cff6da2ed..15fb7f9b6d3a2915148672c5afab63674934d284 100644 (file)
@@ -1,17 +1,19 @@
-/**\r
- * Namespace: System.Web.UI.WebControls\r
- * Class:     Xml\r
- *\r
- * Author:  Gaurav Vaish\r
- * Maintainer: gvaish@iitk.ac.in\r
- * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
- * Implementation: yes\r
- * Status:  75%\r
- *\r
- * (C) Gaurav Vaish (2002)\r
- */\r
+//
+// System.Web.UI.WebControls.Xml.cs
+//
+// Authors:
+//   Gaurav Vaish (gvaish@iitk.ac.in)
+//   Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+// (C) Gaurav Vaish (2002)
+// (C) 2003 Andreas Nahr
+//\r
 \r
 using System;\r
+using System.ComponentModel;
+using System.ComponentModel.Design;\r
 using System.IO;\r
 using System.Xml;\r
 using System.Xml.Xsl;\r
@@ -22,7 +24,10 @@ using System.Web.UI;
 namespace System.Web.UI.WebControls\r
 {\r
        [DefaultProperty("DocumentSource")]\r
-       [PersistChildren(false)]\r
+       [PersistChildren(false)]
+       // TODO add control builder
+       //[ControlBuilder ()]
+       [Designer ("System.Web.UI.Design.WebControls.XmlDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]\r
        public class Xml : Control\r
        {\r
                private XmlDocument      document;\r
@@ -40,7 +45,7 @@ namespace System.Web.UI.WebControls
                {\r
                        XmlTextReader reader = new XmlTextReader(new StringReader("<xsl:stylesheet version='1.0' " +\r
                                                                "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>" +\r
-                                                               "<xsl:template match=\"\">" +\r
+                                                               "<xsl:template match=\"*\">" +\r
                                                                "<xsl:copy-of select=\".\"/>" +\r
                                                                "</xsl:template>" +\r
                                                                "</xsl:stylesheet>"));\r
@@ -52,12 +57,23 @@ namespace System.Web.UI.WebControls
                {\r
                }\r
 \r
-               [MonoTODO("Initialize_Document")]\r
-               private void LoadXmlDoc()\r
+               [MonoTODO("security")]\r
+               private void LoadXmlDoc ()\r
                {\r
-                       throw new NotImplementedException();\r
-               }\r
+                       if (documentContent != null && documentContent.Length > 0) {\r
+                               document = new XmlDocument();\r
+                               document.LoadXml (documentContent);\r
+                               return;\r
+                       }\r
 \r
+                       if (documentSource != null && documentSource.Length != 0) {\r
+                               document = new XmlDocument();\r
+                               document.Load (documentSource);\r
+                       }\r
+               }\r
+
+               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [WebSysDescription ("This is the XML document that is used for the XML Webcontrol.")]\r
                public XmlDocument Document\r
                {\r
                        get\r
@@ -74,7 +90,9 @@ namespace System.Web.UI.WebControls
                                document        = value;\r
                        }\r
                }\r
-\r
+
+               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [WebSysDescription ("The XML content that is transformed for the XML Webcontrol.")]\r
                public string DocumentContent\r
                {\r
                        get\r
@@ -88,7 +106,10 @@ namespace System.Web.UI.WebControls
                                documentContent = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (""), Bindable (true), WebCategory ("Behavior")]
+               [Editor ("System.Web.UI.Design.XmlUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               [WebSysDescription ("The URL or the source of the XML content that is transformed for the XML Webcontrol.")]\r
                public string DocumentSource\r
                {\r
                        get\r
@@ -105,7 +126,9 @@ namespace System.Web.UI.WebControls
                                documentSource  = value;\r
                        }\r
                }\r
-\r
+
+               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [WebSysDescription ("The XSL transform that is applied to this XML Webcontrol.")]\r
                public XslTransform Transform\r
                {\r
                        get\r
@@ -118,7 +141,10 @@ namespace System.Web.UI.WebControls
                                transform       = value;\r
                        }\r
                }\r
-\r
+
+               [DefaultValue (""), Bindable (true), WebCategory ("Behavior")]
+               [Editor ("System.Web.UI.Design.XmlUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+               [WebSysDescription ("An URL specifying the source that is used for the XSL transformation.")]\r
                public string TransformSource\r
                {\r
                        get\r
@@ -133,7 +159,9 @@ namespace System.Web.UI.WebControls
                                transformSource = value;\r
                        }\r
                }\r
-\r
+
+               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+               [WebSysDescription ("Arguments that are used by the XSL Transform.")]\r
                public XsltArgumentList TransformArgumentList\r
                {\r
                        get\r
@@ -153,31 +181,38 @@ namespace System.Web.UI.WebControls
                                DocumentContent = ((LiteralControl)obj).Text;\r
                                return;\r
                        }\r
-                       throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_of_Type", "Xml", GetType().Name.ToString()));\r
+                       throw new HttpException (HttpRuntime.FormatResourceString (\r
+                                                       "Cannot_Have_Children_of_Type",\r
+                                                       "Xml",\r
+                                                       GetType().Name));\r
                }\r
 \r
-               [MonoTODO("Initialize_xpathDocument")]\r
-               private void LoadXpathDoc()\r
+               [MonoTODO("security")]\r
+               private void LoadXpathDoc ()\r
                {\r
-                       if(documentContent != null && documentContent.Length > 0)\r
-                       {\r
-                               xpathDoc = new XPathDocument(new StringReader(documentContent));\r
+                       if(documentContent != null && documentContent.Length > 0) {\r
+                               xpathDoc = new XPathDocument (new StringReader (documentContent));\r
                                return;\r
                        }\r
-                       if(documentSource == null || documentSource.Length == 0)\r
-                       {\r
+\r
+                       if (documentSource != null && documentSource.Length != 0) {\r
+                               xpathDoc = new XPathDocument (MapPathSecure (documentSource));\r
                                return;\r
                        }\r
-                       throw new NotImplementedException();\r
                }\r
 \r
-               [MonoTODO("Initialize_Transform")]\r
-               private void LoadTransform()\r
+               [MonoTODO("security")]\r
+               private void LoadTransform ()\r
                {\r
-                       throw new ArgumentException();\r
+                       if (transform != null)\r
+                               return;\r
+\r
+                       if (transformSource != null && transformSource.Length != 0) {\r
+                               transform = new XslTransform ();\r
+                               transform.Load (MapPathSecure (transformSource));\r
+                       }\r
                }\r
 \r
-               [MonoTODO]\r
                protected override void Render(HtmlTextWriter output)\r
                {\r
                        if(document == null)\r
@@ -186,7 +221,7 @@ namespace System.Web.UI.WebControls
                        }\r
 \r
                        LoadTransform();\r
-                       if(document == null || xpathDoc == null)\r
+                       if(document == null && xpathDoc == null)\r
                        {\r
                                return;\r
                        }\r
@@ -203,3 +238,4 @@ namespace System.Web.UI.WebControls
                }\r
        }\r
 }\r
+\r