[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Xml/Private/XmlDocum...
From: |
Gopal.V |
Subject: |
[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Xml/Private/XmlDocum... |
Date: |
Mon, 27 Mar 2006 18:19:47 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnetlib
Branch:
Changes by: Gopal.V <address@hidden> 06/03/27 18:19:46
Modified files:
. : ChangeLog
System.Xml/Private: XmlDocumentNavigator.cs
System.Xml/XPath: XPathNavigator.cs
System.Xml/XPath/Private: XPathEvaluate.tc XPathIterators.cs
Log message:
Union operators and xml node order comparisons for XPath
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2376&tr2=1.2377&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/Private/XmlDocumentNavigator.cs.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XPath/XPathNavigator.cs.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XPath/Private/XPathEvaluate.tc.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Xml/XPath/Private/XPathIterators.cs.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2376 pnetlib/ChangeLog:1.2377
--- pnetlib/ChangeLog:1.2376 Mon Mar 27 14:03:45 2006
+++ pnetlib/ChangeLog Mon Mar 27 18:19:46 2006
@@ -1,45 +1,85 @@
+
+2006-03-27 Gopal V <address@hidden>
+
+ * System.Xml/Private/XmlDocumentNavigator.cs,
+ System.Xml/XPath/XPathNavigator.cs: Implement node order
+ comparisons and add duplicate checks for namespaces.
+
+ * System.Xml/XPath/Private/XPathEvaluate.tc,
+ System.Xml/XPath/Private/XPathIterators.cs: Union operator.
+
2006-03-27 Heiko Weiss <address@hidden>
- * System.Windows.Forms/ControlToolkitMgr.cs: New file, new class for
handling create windows thread safe.
- * System.Windows.Forms/Control.cs: using ControlToolkitManager to
create toolkitWindow thread safe. Now we can Destroy windows, if parent is set
to null. Fixed DockStyle problem.
- * System.Windows.Forms/Form.cs: using ControlToolkitManager to create
toolkitWindow thread safe. Fixed Mdi forms not working.
- * System.Windows.Forms/MdiClient.cs: using ControlToolkitManager to
create toolkitWindow thread safe.
- * System.Windows.Forms/PopupControl.cs: using ControlToolkitManager to
create toolkitWindow thread safe.
+ * System.Windows.Forms/ControlToolkitMgr.cs: New file, new class
+ for handling create windows thread safe.
+
+ * System.Windows.Forms/Control.cs: using ControlToolkitManager to
+ create toolkitWindow thread safe. Now we can Destroy windows, if
+ parent is set to null. Fixed DockStyle problem.
+
+ * System.Windows.Forms/Form.cs: using ControlToolkitManager to
+ create toolkitWindow thread safe. Fixed Mdi forms not working.
+
+ * System.Windows.Forms/MdiClient.cs: using ControlToolkitManager
+ to create toolkitWindow thread safe.
+
+ * System.Windows.Forms/PopupControl.cs: using ControlToolkitManager
+ to create toolkitWindow thread safe.
+
* System.Windows.Forms/TreeView.cs: fixed drawing plus and minus
buttons.
2006-03-23 Heiko Weiss <address@hidden>
- * System.Windows.Forms/Control.cs: removed my last change in Reparent
of Controls, because it breaked using invokes.
+ * System.Windows.Forms/Control.cs: removed my last change in Reparent
+ of Controls, because it breaked using invokes.
+
* System.Windows.Forms/Control.cs: optimized dispose, changed
ForceLayout
2006-03-21 Heiko Weiss <address@hidden>
- * System.Windows.Forms/Form.cs: CloseRequest, do nothing if Form was
desposed
- * System.Windows.Forms/Control.cs: changed handling of setting Parent
to null, or reparent the control.
+ * System.Windows.Forms/Form.cs: CloseRequest, do nothing if Form
+ was desposed
+
+ * System.Windows.Forms/Control.cs: changed handling of setting
+ Parent to null, or reparent the control.
+
* System.Drawing.Xsharp/DrawingWindow.cs: fixed Dispose.
2006-03-20 Heiko Weiss <address@hidden>
- * System.Windows.Form/Control.cs : fixed Dispose, Controls.Remove(),
DestroyHandle
+ * System.Windows.Form/Control.cs : fixed Dispose, Controls.Remove(),
+ DestroyHandle
+
* System.Windows.Form/ContainerControl.cs : added AfterControlRemoved
2006-03-20 Peter Flaig <address@hidden>
- * System.Windows.Forms/TextBox.cs : always draw disabled textbox with
gray, if backcolor not gray
- * System.Windows.Forms/ControlPaint.cs: fixed bug in calculating color
FromHSB
+ * System.Windows.Forms/TextBox.cs : always draw disabled textbox with
gray,
+ if backcolor not gray
+
+ * System.Windows.Forms/ControlPaint.cs: fixed bug in calculating color
+ FromHSB
2006-03-16 Heiko Weiss <address@hidden>
- * System.Windows.Form/ScrollableControl.cs : replaced setting
EventHandler HandleCreated with OnHandleCreated
- * System.Windows.Form/Control.cs : call base.Dispose(...) if
CONFIG_COMPONENT_MODEL
+ * System.Windows.Form/ScrollableControl.cs : replaced setting
+ EventHandler HandleCreated with OnHandleCreated
+
+ * System.Windows.Form/Control.cs : call base.Dispose(...) if
+ CONFIG_COMPONENT_MODEL
2006-03-14 Heiko Weiss <address@hidden>
- * System.Window.Forms/Form.cs: Fixed closing dialog stopping
Application.InnerMessageLoop if Form was shown with ShowDialog
- * Xsharp/DoubleBuffer.cs: Added query widget.HasWidgetHandle, if widget
was detroyed (was Exception before)
- * Xsharp/Drawable.cs: added Method bool HasWidgetHandle() to get if
widget handle is valid
+ * System.Window.Forms/Form.cs: Fixed closing dialog stopping
+ Application.InnerMessageLoop if Form was shown with ShowDialog
+
+ * Xsharp/DoubleBuffer.cs: Added query widget.HasWidgetHandle, if
+ widget was detroyed (was Exception before)
+
+ * Xsharp/Drawable.cs: added Method bool HasWidgetHandle() to get
+ if widget handle is valid
2006-03-14 Heiko Weiss <address@hidden>
Index: pnetlib/System.Xml/Private/XmlDocumentNavigator.cs
diff -u pnetlib/System.Xml/Private/XmlDocumentNavigator.cs:1.10
pnetlib/System.Xml/Private/XmlDocumentNavigator.cs:1.11
--- pnetlib/System.Xml/Private/XmlDocumentNavigator.cs:1.10 Mon Mar 6
12:28:09 2006
+++ pnetlib/System.Xml/Private/XmlDocumentNavigator.cs Mon Mar 27 18:19:46 2006
@@ -27,6 +27,7 @@
using System;
using System.Xml;
using System.Xml.XPath;
+using System.Collections;
internal class XmlDocumentNavigator : XPathNavigator, IHasXmlNode
@@ -38,6 +39,8 @@
/* xml:xmlns="http://www.w3.org/XML/1998/namespace" */
private XmlAttribute xmlAttr = null;
+ private ArrayList nsNames = null;
+
public XmlDocumentNavigator(XmlNode node) : base()
{
this.node = node;
@@ -46,6 +49,8 @@
this.xmlAttr = document.CreateAttribute("xmlns", "xml",
XmlDocument.xmlns);
this.xmlAttr.Value = XmlDocument.xmlnsXml;
+
+ this.nsNames = null;
}
public XmlDocumentNavigator(XmlDocumentNavigator copy)
@@ -74,7 +79,7 @@
{
return node.GetNamespaceOfPrefix(name);
}
-
+
public override bool IsSamePosition(XPathNavigator other)
{
XmlDocumentNavigator nav = (other as XmlDocumentNavigator);
@@ -90,6 +95,14 @@
nsAttr = nav.nsAttr;
document = nav.document;
xmlAttr = nav.xmlAttr;
+ if(nav.nsNames == null || nav.nsNames.IsReadOnly)
+ {
+ nsNames = nav.nsNames;
+ }
+ else
+ {
+ nsNames = ArrayList.ReadOnly(nav.nsNames);
+ }
return true;
}
return false;
@@ -182,9 +195,8 @@
{
foreach(XmlAttribute attr in element.Attributes)
{
- /* TODO: checks for duplicates, not
cheat */
if(attr.NamespaceURI ==
XmlDocument.xmlns
- && (attr.Name != "xmlns"))
+ &&
!CheckForDuplicateNS(attr.Name, attr.Value))
{
NamespaceAttribute = attr;
return true;
@@ -201,8 +213,7 @@
if(namespaceScope == XPathNamespaceScope.All)
{
- /* TODO: implement better duplicate checking */
- if(((Object)nsAttr) != ((Object)this.xmlAttr))
+ if(!CheckForDuplicateNS(xmlAttr.Name, xmlAttr.Value))
{
NamespaceAttribute = xmlAttr;
return true;
@@ -238,9 +249,8 @@
{
foreach(XmlAttribute attr in element.Attributes)
{
- /* TODO: checks for duplicates, not
cheat */
if(attr.NamespaceURI ==
XmlDocument.xmlns
- && (attr.Name != "xmlns"))
+ &&
!CheckForDuplicateNS(attr.Name,attr.Value))
{
NamespaceAttribute = attr;
return true;
@@ -329,9 +339,8 @@
for(int j = i+1; j < owner.Attributes.Count;
j++)
{
attr = owner.Attributes[j];
- /* TODO: checks for duplicates, not
cheat */
if(attr.NamespaceURI ==
XmlDocument.xmlns
- && (attr.Name != "xmlns"))
+ &&
!CheckForDuplicateNS(attr.Name, attr.Value))
{
return attr;
}
@@ -390,8 +399,7 @@
if(namespaceScope == XPathNamespaceScope.All)
{
- /* TODO: implement better duplicate checking */
- if(((Object)nsAttr) != ((Object)this.xmlAttr))
+ if(!CheckForDuplicateNS(xmlAttr.Name, xmlAttr.Value))
{
NamespaceAttribute = xmlAttr;
return true;
@@ -695,11 +703,60 @@
}
set
{
- /* TODO: keep track of all available ns values */
this.nsAttr = value;
+
+ if(value != null)
+ {
+ if(this.nsNames == null)
+ {
+ this.nsNames = new ArrayList();
+ }
+ else if(this.nsNames.IsReadOnly)
+ {
+ this.nsNames = new
ArrayList(this.nsNames);
+ }
+
+ this.nsNames.Add(value.Value);
+ }
+ else
+ {
+ this.nsNames = null;
+ }
}
}
+ // return true if the namespace has been seen before
+ private bool CheckForDuplicateNS(String name, String ns)
+ {
+ // XmlNameTable to the rescue, we can compare names as objects
+ if(this.nsNames != null && this.nsNames.Contains((Object)name))
+ {
+ // duplicate
+ return true;
+ }
+
+ /* tricky part: setting xmlns='' in your XML causes
+ the default namespace to be *seen* but forgotten.
+ */
+
+ if(ns == String.Empty)
+ {
+ if(this.nsNames == null)
+ {
+ this.nsNames = new ArrayList();
+ }
+ else if(this.nsNames.IsReadOnly)
+ {
+ this.nsNames = new ArrayList(this.nsNames);
+ }
+ this.nsNames.Add(NameTable.Get("xmlns"));
+
+ return true;
+ }
+
+ return false;
+ }
+
XmlNode IHasXmlNode.GetNode()
{
return CurrentNode;
Index: pnetlib/System.Xml/XPath/Private/XPathEvaluate.tc
diff -u pnetlib/System.Xml/XPath/Private/XPathEvaluate.tc:1.8
pnetlib/System.Xml/XPath/Private/XPathEvaluate.tc:1.9
--- pnetlib/System.Xml/XPath/Private/XPathEvaluate.tc:1.8 Sat Mar 4
13:46:55 2006
+++ pnetlib/System.Xml/XPath/Private/XPathEvaluate.tc Mon Mar 27 18:19:46 2006
@@ -285,6 +285,13 @@
((bool)node.right.EvaluateAs(iterator, XPathResultType.Boolean) ==
true));
}
+EvaluateInternal(UnionExpression)
+{
+ XPathBaseIterator left =
(XPathBaseIterator)node.left.Evaluate(iterator);
+ XPathBaseIterator right =
(XPathBaseIterator)node.right.Evaluate(iterator);
+ return new XPathUnionIterator((XPathBaseIterator)iterator, left,
right);
+}
+
EvaluateInternal(FunctionCallExpression)
{
@@ -464,3 +471,7 @@
{
return null; /* TODO */
}
+
+/*
+ * vim: sw=4 ts=4 syntax=cs
+ */
Index: pnetlib/System.Xml/XPath/Private/XPathIterators.cs
diff -u pnetlib/System.Xml/XPath/Private/XPathIterators.cs:1.8
pnetlib/System.Xml/XPath/Private/XPathIterators.cs:1.9
--- pnetlib/System.Xml/XPath/Private/XPathIterators.cs:1.8 Sat Mar 4
13:46:55 2006
+++ pnetlib/System.Xml/XPath/Private/XPathIterators.cs Mon Mar 27 18:19:46 2006
@@ -943,7 +943,127 @@
return pos;
}
}
- }
+ }
+
+ internal class XPathUnionIterator : XPathSimpleIterator
+ {
+ XPathBaseIterator left;
+ XPathBaseIterator right;
+ bool moveLeft = true;
+ bool moveRight = true;
+
+ public XPathUnionIterator(XPathBaseIterator iterator,
+
XPathBaseIterator left,
+
XPathBaseIterator right)
+ : base(iterator)
+ {
+ this.left = left;
+ this.right = right;
+ this.current = null;
+ }
+
+ /* caveat: the base ctor gets the useless parent arg */
+ public XPathUnionIterator(XPathUnionIterator copy) :
base(copy.parent)
+ {
+ this.left = (XPathBaseIterator)copy.left.Clone();
+ this.right = (XPathBaseIterator)copy.right.Clone();
+ this.moveRight = copy.moveRight;
+ this.moveLeft = copy.moveLeft;
+ }
+
+ public override bool MoveNext()
+ {
+ // TODO: investigate removing these variables
+ bool movedRight = false;
+ bool movedLeft = false;
+
+ if(!moveLeft && !moveRight)
+ {
+ return false;
+ }
+
+ if(moveLeft)
+ {
+ movedLeft = left.MoveNext();
+ }
+ if(moveRight)
+ {
+ movedRight = right.MoveNext();
+ }
+
+ if(moveLeft && !movedLeft && moveRight && !movedRight)
+ {
+ return false;
+ }
+
+ if(moveLeft && !movedLeft)
+ {
+ moveLeft = false;
+ current = right.Current.Clone();
+ pos++;
+ return true;
+ }
+
+ if(moveRight && !movedRight)
+ {
+ /* from next time, don't move right */
+ moveRight = false;
+ current = left.Current.Clone();
+ pos++;
+ return true;
+ }
+
+ // both moves were successful or we had leftover nodes
from
+ // one side now we need to chose which side to output
first
+
+ XmlNodeOrder order =
left.Current.ComparePosition(right.Current);
+
+ switch(order)
+ {
+ case XmlNodeOrder.Same:
+ {
+ moveRight = moveLeft = true;
+ current = left.Current.Clone();
+ pos++;
+ return true;
+ }
+ break;
+
+ case XmlNodeOrder.Before:
+ case XmlNodeOrder.Unknown:
+ {
+ moveLeft = true;
+ moveRight = false;
+ current = left.Current.Clone();
+ pos++;
+ return true;
+ }
+ break;
+
+ case XmlNodeOrder.After:
+ {
+ moveLeft = false;
+ moveRight = true;
+ current = right.Current.Clone();
+ pos++;
+ return true;
+ }
+ break;
+ default:
+ {
+ throw new XPathException("Could
understand node relationship : "+order.ToString(), null);
+ }
+ break;
+ }
+
+ return false;
+ }
+
+ public override XPathNodeIterator Clone()
+ {
+ return new XPathUnionIterator(this);
+ }
+ }
}
Index: pnetlib/System.Xml/XPath/XPathNavigator.cs
diff -u pnetlib/System.Xml/XPath/XPathNavigator.cs:1.9
pnetlib/System.Xml/XPath/XPathNavigator.cs:1.10
--- pnetlib/System.Xml/XPath/XPathNavigator.cs:1.9 Mon Mar 6 12:28:09 2006
+++ pnetlib/System.Xml/XPath/XPathNavigator.cs Mon Mar 27 18:19:46 2006
@@ -49,26 +49,114 @@
return Clone();
}
- [TODO]
public virtual XmlNodeOrder ComparePosition(XPathNavigator nav)
{
- throw new
NotImplementedException("ComparePosition");
+ if(IsSamePosition(nav))
+ {
+ return XmlNodeOrder.Same;
+ }
+
+ if(IsDescendant(nav))
+ {
+ return XmlNodeOrder.Before;
+ }
+ else if(nav.IsDescendant(this))
+ {
+ return XmlNodeOrder.After;
+ }
+
+ XPathNavigator copy = this.Clone();
+ XPathNavigator other = nav.Clone();
+
+ /* now, it gets expensive - we find the
+ closest common ancestor. But these two
+ might be from totally different places.
+
+ Someone should re-implement this somewhere,
+ so that it is faster for XmlDocument.
+ */
+ int common = 0;
+ int otherDepth = 0;
+ int copyDepth = 0;
+
+ copy.MoveToRoot();
+ other.MoveToRoot();
+
+ if(!copy.IsSamePosition(other))
+ {
+ return XmlNodeOrder.Unknown;
+ }
+
+ /* what do you think ? I'm made of GC space ? */
+ copy.MoveTo(this);
+ other.MoveTo(nav);
+
+ while(other.MoveToParent())
+ {
+ otherDepth++;
+ }
+
+ while(copy.MoveToParent())
+ {
+ copyDepth++;
+ }
+
+ common = (otherDepth > copyDepth) ? copyDepth :
otherDepth;
+
+ other.MoveTo(nav);
+ copy.MoveTo(this);
+
+ // traverse both till you get to depth == common
+ for(;otherDepth > common; otherDepth--)
+ {
+ other.MoveToParent();
+ }
+ for(;copyDepth > common; copyDepth--)
+ {
+ copy.MoveToParent();
+ }
+
+ other.MoveTo(nav);
+ copy.MoveTo(this);
+
+ XPathNavigator copy1 = copy.Clone();
+ XPathNavigator other1 = other.Clone();
+
+ while(copy.IsSamePosition(other))
+ {
+ copy1.MoveTo(copy);
+ other1.MoveTo(other);
+
+ copy.MoveToParent();
+ other.MoveToParent();
+ }
+
+ copy.MoveTo(copy1);
+ other.MoveTo(other1);
+
+ // Now copy & other are siblings and can be
compared
+ while(copy.MoveToNext())
+ {
+ if(copy.IsSamePosition(other))
+ {
+ return XmlNodeOrder.Before;
+ }
+ }
+
+ return XmlNodeOrder.After;
}
- [TODO]
public virtual XPathExpression Compile(String xpath)
{
XPathParser parser = new XPathParser();
return parser.Parse(xpath);
}
- [TODO]
public virtual Object Evaluate(XPathExpression expr)
{
return Evaluate(expr, new
XPathSelfIterator(this,null));
}
- [TODO]
public virtual Object Evaluate(XPathExpression expr,
XPathNodeIterator context)
{
@@ -79,7 +167,6 @@
return null;
}
- [TODO]
public virtual Object Evaluate(String xpath)
{
XPathExpression expr = Compile(xpath);
@@ -90,10 +177,20 @@
public abstract String GetNamespace(String name);
- [TODO]
public virtual bool IsDescendant(XPathNavigator nav)
{
- throw new
NotImplementedException("IsDescendant");
+ if(nav != null)
+ {
+ nav = nav.Clone();
+ while(nav.MoveToParent())
+ {
+ if(IsSamePosition(nav))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
}
public abstract bool IsSamePosition(XPathNavigator other);