public override bool HasAttributes {
get {
+ if (attr != null)
+ return false;
XElement el = node as XElement;
- return el != null && el.HasAttributes;
+ if (el == null)
+ return false;
+ foreach (var at in el.Attributes ())
+ if (!at.IsNamespaceDeclaration)
+ return true;
+ return false;
}
}
public override bool HasChildren {
get {
+ if (attr != null)
+ return false;
XContainer c = node as XContainer;
return c != null && c.FirstNode != null;
}
public override bool IsEmptyElement {
get {
+ if (attr != null)
+ return false;
XElement el = node as XElement;
return el != null && el.IsEmpty;
}
get {
switch (NodeType) {
case XPathNodeType.Namespace:
- return attr.Name.Namespace == XNamespace.Blank ? String.Empty : attr.Name.LocalName;
+ return attr.Name.Namespace == XNamespace.None ? String.Empty : attr.Name.LocalName;
case XPathNodeType.Attribute:
return attr.Name.LocalName;
case XPathNodeType.Element:
default:
return LocalName;
}
- if (name.Namespace == XNamespace.Blank)
+ if (name.Namespace == XNamespace.None)
return name.LocalName;
XElement el = (node as XElement) ?? node.Parent;
if (el == null)
public override string NamespaceURI {
get {
switch (NodeType) {
+ case XPathNodeType.ProcessingInstruction:
case XPathNodeType.Namespace:
- return attr.Value;
+ return String.Empty;
case XPathNodeType.Attribute:
return attr.Name.NamespaceName;
case XPathNodeType.Element:
get {
XName name = null;
switch (NodeType) {
+ case XPathNodeType.ProcessingInstruction:
+ case XPathNodeType.Namespace:
+ return String.Empty;
case XPathNodeType.Attribute:
name = attr.Name;
break;
default:
return LocalName;
}
- if (name.Namespace == XNamespace.Blank)
+ if (name.Namespace == XNamespace.None)
return String.Empty;
XElement el = (node as XElement) ?? node.Parent;
if (el == null)
}
}
- [MonoTODO]
public override IXmlSchemaInfo SchemaInfo {
- get { throw new NotImplementedException (); }
+ get { return null; }
}
public override object UnderlyingObject {
case XPathNodeType.ProcessingInstruction:
return ((XPI) node).Data;
case XPathNodeType.Text:
- return ((XText) node).Value;
+ string s = String.Empty;
+ for (var xn = node as XText; xn != null; xn = xn.NextNode as XText)
+ s += xn.Value;
+ return s;
case XPathNodeType.Element:
case XPathNodeType.Root:
return GetInnerText ((XContainer) node);
public override bool MoveTo (XPathNavigator other)
{
XNodeNavigator nav = other as XNodeNavigator;
- if (nav == null || nav.node.Owner != node.Owner)
+ if (nav == null || nav.node.Document != node.Document)
return false;
node = nav.node;
attr = nav.attr;
public override bool MoveToFirstAttribute ()
{
+ if (attr != null)
+ return false;
XElement el = node as XElement;
if (el == null || !el.HasAttributes)
return false;
public override bool MoveToFirstChild ()
{
+ if (attr != null)
+ return false;
XContainer c = node as XContainer;
- if (c == null)
+ if (c == null || c.FirstNode == null)
return false;
node = c.FirstNode;
attr = null;
public override bool MoveToFirstNamespace (XPathNamespaceScope scope)
{
+ if (NodeType != XPathNodeType.Element)
+ return false;
for (XElement el = node as XElement; el != null; el = el.Parent) {
foreach (XAttribute a in el.Attributes ())
if (a.IsNamespaceDeclaration) {
return true;
}
- [MonoTODO]
public override bool MoveToId (string id)
{
- return false;
+ throw new NotSupportedException ("This XPathNavigator does not support IDs");
}
public override bool MoveToNext ()
{
- if (node.NextNode == null)
+ XNode xn = node.NextNode;
+ if (xn is XText)
+ for (; xn != null; xn = xn.NextNode)
+ if (!(xn.NextNode is XText))
+ break;
+ if (xn == null)
return false;
- node = node.NextNode;
+ node = xn;
attr = null;
- return false;
+ return true;
}
public override bool MoveToNextAttribute ()
if (scope == XPathNamespaceScope.Local)
return false;
+ if (attr == attr_ns_xml)
+ return false; // no next attribute
+
for (XElement el = ((XElement) attr.Parent).Parent; el != null; el = el.Parent) {
foreach (XAttribute a in el.Attributes ())
if (a.IsNamespaceDeclaration) {
attr = null;
return true;
}
- if (node.Parent == null)
+ if (node.Owner == null)
return false;
- node = node.Parent;
+ node = node.Owner;
return true;
}
public override void MoveToRoot ()
{
- node = node.Owner;
attr = null;
+ if (node.Document != null)
+ node = node.Document;
+ else
+ while (node.Owner != null)
+ node = node.Owner;
}
}
}