Author: adar
Date: 2007-01-18 09:33:17 -0500 (Thu, 18 Jan 2007)
New Revision: 71262
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/XmlTest.cs
Log:
2007-01-18 Adar Wesley <[EMAIL PROTECTED]>
* Xml.cs: added support for XPathNavigator, fixed DocumentContent
to be compatible with MS 2.0, implemented EnableTheming, implemented
SkinID, fixed Focus behavior.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-01-18 14:03:48 UTC (rev 71261)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-01-18 14:33:17 UTC (rev 71262)
@@ -1,3 +1,9 @@
+2007-01-18 Adar Wesley <[EMAIL PROTECTED]>
+
+ * Xml.cs: added support for XPathNavigator, fixed DocumentContent
+ to be compatible with MS 2.0, implemented EnableTheming, implemented
+ SkinID, fixed Focus behavior.
+
2007-01-18 Vladimir Krasnov <[EMAIL PROTECTED]>
* Menu.js, Menu.js: added null reference checking for every getTree or
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs 2007-01-18
14:03:48 UTC (rev 71261)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Xml.cs 2007-01-18
14:33:17 UTC (rev 71262)
@@ -53,7 +53,10 @@
[ControlBuilder (typeof (XmlBuilder))]
public class Xml : Control {
// Property set variables
- XmlDocument xml_document;
+ XmlDocument xml_document;
+#if NET_2_0
+ XPathNavigator xpath_navigator;
+#endif
string xml_content;
string xml_file;
@@ -111,7 +114,11 @@
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string DocumentContent {
get {
+#if NET_2_0
+ return (xml_content != null)? xml_content : "";
+#else
return "";
+#endif
}
set {
@@ -152,15 +159,10 @@
[EditorBrowsable (EditorBrowsableState.Never)]
[Browsable (false)]
[DefaultValue (false)]
- [MonoTODO ("Theming is not implemented")]
public override bool EnableTheming
{
- get {
- return enable_theming;
- }
- set {
- enable_theming = value;
- }
+ get { return false; }
+ set { throw new NotSupportedException (); }
}
[DefaultValue ("")]
@@ -168,12 +170,10 @@
[Browsable (false)]
public override string SkinID
{
- get {
- return skin_id;
- }
- set {
- skin_id = value;
- }
+ // MSDN: Always returns an empty string (""). This
property is not supported.
+ get { return String.Empty; }
+ // MSDN: Any attempt to set the value of this property
throws a NotSupportedException exception.
+ set { throw new NotSupportedException ("SkinID is not
supported on Xml control"); }
}
#endif
@@ -232,15 +232,10 @@
#if NET_2_0
[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
- [MonoTODO ("Not implemented")]
public XPathNavigator XPathNavigator
{
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
+ get { return xpath_navigator; }
+ set { xpath_navigator = value; }
}
[EditorBrowsable (EditorBrowsableState.Never)]
@@ -252,6 +247,7 @@
[EditorBrowsable (EditorBrowsableState.Never)]
public override void Focus ()
{
+ throw new NotSupportedException ();
}
[EditorBrowsable (EditorBrowsableState.Never)]
@@ -268,20 +264,28 @@
#endif
override void Render (HtmlTextWriter output)
{
- XmlDocument xml_doc;
-
- if (xml_document != null)
- xml_doc = xml_document;
- else {
- if (xml_content != null){
- xml_doc = new XmlDocument ();
- xml_doc.LoadXml (xml_content);
- } else if (xml_file != null){
- xml_doc = new XmlDocument ();
- xml_doc.Load (MapPathSecure (xml_file));
- } else
- return;
+ XmlDocument xml_doc = null;
+
+#if NET_2_0
+ if (xpath_navigator == null) {
+#endif
+ if (xml_document != null)
+ xml_doc = xml_document;
+ else {
+ if (xml_content != null) {
+ xml_doc = new XmlDocument ();
+ xml_doc.LoadXml (xml_content);
+ }
+ else if (xml_file != null) {
+ xml_doc = new XmlDocument ();
+ xml_doc.Load (MapPathSecure
(xml_file));
+ }
+ else
+ return;
+ }
+#if NET_2_0
}
+#endif
XslTransform t = xsl_transform;
if (transform_file != null){
@@ -290,14 +294,32 @@
}
if (t != null){
- t.Transform (xml_doc, transform_arguments,
output, null);
+#if NET_2_0
+ if (xpath_navigator != null) {
+ t.Transform(xpath_navigator,
transform_arguments, output);
+ }
+ else {
+#endif
+ t.Transform (xml_doc,
transform_arguments, output, null);
+#if NET_2_0
+ }
+#endif
return;
}
XmlTextWriter xmlwriter = new XmlTextWriter (output);
xmlwriter.Formatting = Formatting.None;
- xml_doc.Save (xmlwriter);
-
+#if NET_2_0
+ if (xpath_navigator != null) {
+ xmlwriter.WriteStartDocument ();
+ xpath_navigator.WriteSubtree (xmlwriter);
+ }
+ else {
+#endif
+ xml_doc.Save (xmlwriter);
+#if NET_2_0
+ }
+#endif
}
protected override void AddParsedSubObject (object obj)
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/XmlTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/XmlTest.cs
2007-01-18 14:03:48 UTC (rev 71261)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/XmlTest.cs
2007-01-18 14:33:17 UTC (rev 71262)
@@ -151,15 +151,6 @@
Assert.AreEqual (null, xml.Transform, "V9");
#if NET_2_0
Assert.AreEqual (false, xml.EnableTheming,
"EnableTheming");
-#endif
- }
-
- [Test]
- [Category ("NotWorking")]
- public void Xml_Values_NotWorking ()
- {
- Xml xml = new Xml ();
-#if NET_2_0
Assert.AreEqual (String.Empty, xml.SkinID, "SkinID");
Assert.AreEqual (null, xml.XPathNavigator,
"XPathNavigator");
#endif
@@ -167,7 +158,6 @@
// Tests that invalid documents can be set before rendering.
[Test]
- [Category ("NotWorking")]
public void Xml_InvalidDocument ()
{
Xml xml = new Xml ();
@@ -232,6 +222,32 @@
sw.ToString (), "SP1");
}
+#if NET_2_0
+ [Test]
+ public void Xml_SourcePrecedence_2 ()
+ {
+ XmlPoker xml = new XmlPoker ();
+
+ XmlDocument xml_doc = new XmlDocument ();
+ xml_doc.LoadXml ("<document></document>");
+
+ xml.Document = xml_doc;
+
+ XmlDocument xml_navigator_doc = new XmlDocument ();
+ xml_navigator_doc.LoadXml ("<navigator></navigator>");
+
+ xml.XPathNavigator = xml_navigator_doc.CreateNavigator
();
+
+ StringWriter sw = new StringWriter ();
+ HtmlTextWriter hw = new HtmlTextWriter (sw);
+ xml.DoRender (hw);
+
+ Assert.AreEqual ("<?xml version=\"1.0\"
encoding=\"utf-16\"?><navigator></navigator>",
+ sw.ToString (),
"Xml_SourcePrecedence_2");
+
+ }
+#endif
+
[Test] public void Xml_DefaultTrasnform ()
{
XmlPoker xml = new XmlPoker ();
@@ -375,7 +391,6 @@
}
[Test]
- [Category ("NotWorking")] // Not implemented
public void XPathNavigable_1 ()
{
Xml xml = new Xml ();
@@ -386,7 +401,6 @@
[Test]
- [Category ("NotWorking")] // Not implemented
public void XPathNavigable_2 ()
{
Xml xml = new Xml ();
@@ -395,7 +409,20 @@
}
[Test]
- [Category ("NotWorking")]
+ public void XPathNavigatorInstance_1 ()
+ {
+ Xml xml = new Xml ();
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<document></document>");
+
+ xml.Document = doc;
+
+ XPathNavigator nav1 = xml.XPathNavigator;
+
+ Assert.IsNull (nav1, "XPathNavigatorInstance_1");
+ }
+
+ [Test]
[ExpectedException (typeof (NotSupportedException))]
public void Focus ()
{
@@ -405,7 +432,6 @@
[Test]
- [Category ("NotWorking")]
[ExpectedException (typeof (NotSupportedException))]
public void SkinID ()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches