[gxml] Node: interface removed
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Node: interface removed
- Date: Thu, 4 Jul 2019 23:43:50 +0000 (UTC)
commit 9c031a11c53f02f41b5fd1bb2d97b10058e4ca30
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Jul 4 18:37:51 2019 -0500
Node: interface removed
Fix issue #8
gxml/DocumentType.vala | 29 ------
gxml/GXmlAttribute.vala | 14 +--
gxml/GXmlDocument.vala | 22 ++---
gxml/GXmlDomRange.vala | 6 +-
gxml/GXmlElement.vala | 29 +++---
gxml/GXmlListChildren.vala | 52 +++++-----
gxml/GXmlNode.vala | 59 ++++++------
gxml/Node.vala | 229 --------------------------------------------
gxml/meson.build | 2 -
test/DomGDocumentTest.vala | 3 -
test/GHtmlDocumentTest.vala | 16 ++--
11 files changed, 103 insertions(+), 358 deletions(-)
---
diff --git a/gxml/GXmlAttribute.vala b/gxml/GXmlAttribute.vala
index 25cc279..fb34d2d 100644
--- a/gxml/GXmlAttribute.vala
+++ b/gxml/GXmlAttribute.vala
@@ -94,9 +94,9 @@ public class GXml.GAttribute : GXml.GNode, GXml.DomAttr
return _attr->ns->prefix.dup ();
}
}
- public override GXml.Node parent {
+ public override GXml.DomNode parent {
owned get {
- GXml.Node nullnode = null;
+ GXml.DomNode nullnode = null;
if (_attr == null) return nullnode;
return to_gnode (document as GDocument, _node);
}
@@ -114,20 +114,20 @@ public class GXml.GAttribute : GXml.GNode, GXml.DomAttr
return namespace.prefix;
}
}*/
- public string local_name { owned get { return (this as GXml.Node).name; } }
+ public string local_name { owned get { return (this as GXml.GNode).name; } }
/*public string GXml.DomAttr.name {
get {
- if (namespace == null) return (this as GXml.Node).name;
- string s = namespace.prefix+":"+(this as GXml.Node).name;
+ if (namespace == null) return (this as GXml.DomNode).name;
+ string s = namespace.prefix+":"+(this as GXml.DomNode).name;
return s;
}
}
public string @value {
get {
- return (this as GXml.Node).value;
+ return (this as GXml.DomNode).value;
}
set {
- (this as GXml.Node).value = value;
+ (this as GXml.DomNode).value = value;
}
}*/
}
diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala
index 60f3ac1..3dad3b4 100644
--- a/gxml/GXmlDocument.vala
+++ b/gxml/GXmlDocument.vala
@@ -28,7 +28,7 @@ using Xml;
* powered by libxml-2.0 library.
*
* This class use {@link Xml.TextWriter} to write down XML documents using
- * its contained {@link GXml.Node} children or other XML structures.
+ * its contained {@link GXml.DomNode} children or other XML structures.
*/
public class GXml.GDocument : GXml.GNode,
GXml.DomParentNode,
@@ -90,9 +90,9 @@ public class GXml.GDocument : GXml.GNode,
}
return false;
}
- // GXml.Node
- public override Gee.Map<string,GXml.Node> attrs { owned get { return new GHashMapAttr (this, (Xml.Node*)
doc) as Gee.Map<string,GXml.Node>; } }
- public override Gee.BidirList<GXml.Node> children_nodes { owned get { return new GListChildren (this,
(Xml.Node*) doc) as Gee.BidirList<GXml.Node>; } }
+ // GXml.DomNode
+ public override Gee.Map<string,GXml.DomNode> attrs { owned get { return new GHashMapAttr (this,
(Xml.Node*) doc) as Gee.Map<string,GXml.DomNode>; } }
+ public override Gee.BidirList<GXml.DomNode> children_nodes { owned get { return new GListChildren (this,
(Xml.Node*) doc) as Gee.BidirList<GXml.DomNode>; } }
public override Gee.List<GXml.Namespace> namespaces { owned get { return new GListNamespaces (this,
doc->get_root_element()) as Gee.List<GXml.Namespace>; } }
public override GXml.DomDocument document { get { return this; } }
// GXml.DomDocument
@@ -101,13 +101,13 @@ public class GXml.GDocument : GXml.GNode,
public bool prefix_default_ns { get; set; default = false; }
public bool backup { get; set; default = true; }
public GLib.File file { get; set; }
- public GXml.Node root {
+ public GXml.DomNode root {
owned get {
var r = doc->get_root_element ();
if (r == null) {
int found = 0;
for (int i = 0; i < children_nodes.size; i++) {
- GXml.Node n = children_nodes.get (i);
+ GXml.DomNode n = children_nodes.get (i);
if (n is GXml.DomElement) {
found++;
if (found == 1)
@@ -121,13 +121,13 @@ public class GXml.GDocument : GXml.GNode,
return new GElement (this, r);
}
}
- public GXml.Node create_pi (string target, string data)
+ public GXml.DomNode create_pi (string target, string data)
{
var pi = doc->new_pi (target, data);
return new GProcessingInstruction (this, pi);
}
- public GXml.Node create_text (string text)
+ public GXml.DomNode create_text (string text)
{
var t = doc->new_text (text);
return new GText (this, t);
@@ -256,7 +256,7 @@ public class GXml.GDocument : GXml.GNode,
GXml.DomNode dst = null;
if (node is DomElement) {
dst = (this as DomDocument).create_element (node.node_name);
- GXml.Node.copy (this, (GXml.Node) dst, (GXml.Node) node, deep);
+ GXml.DomNode.copy (this, (GXml.DomNode) dst, (GXml.DomNode) node, deep);
if (document_element == null) {
this.append_child (dst);
return dst;
@@ -279,7 +279,7 @@ public class GXml.GDocument : GXml.GNode,
throw new GXml.DomError.NOT_SUPPORTED_ERROR (_("Can't adopt a Document"));
if (this == node.owner_document) return node;
var dst = this.create_element (node.node_name);
- GXml.Node.copy (this, dst as GXml.Node, (GXml.Node) node, true);
+ GXml.DomNode.copy (this, dst as GXml.DomNode, (GXml.DomNode) node, true);
if (node.parent_node != null)
node.parent_node.child_nodes.remove_at (node.parent_node.child_nodes.index_of (node));
if (this.document_element == null)
@@ -341,7 +341,7 @@ public class GXml.GDocument : GXml.GNode,
var cs = new CssSelectorParser ();
cs.parse (selectors);
var l = new GomNodeList();
- foreach (GXml.Node e in children_nodes) {
+ foreach (GXml.DomNode e in children_nodes) {
if (!(e is DomElement)) continue;
if (cs.match (e as DomElement))
l.add (e as DomNode);
diff --git a/gxml/GXmlDomRange.vala b/gxml/GXmlDomRange.vala
index af61fa1..3be7357 100644
--- a/gxml/GXmlDomRange.vala
+++ b/gxml/GXmlDomRange.vala
@@ -51,7 +51,7 @@ public class GXml.GDomRange : Object, GXml.DomRange {
public void set_start (DomNode node, int offset) throws GLib.Error {
if (node is DomDocumentType)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start"));
- if (node is DocumentType)
+ if (node is DomDocumentType)
if (offset > 0)
throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to start: for
document type"));
else
@@ -79,7 +79,7 @@ public class GXml.GDomRange : Object, GXml.DomRange {
public void set_end (DomNode node, int offset) throws GLib.Error {
if (node is DomDocumentType)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start"));
- if (node is DocumentType)
+ if (node is DomDocumentType)
if (offset > 0)
throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to start: for
document type"));
else
@@ -154,7 +154,7 @@ public class GXml.GDomRange : Object, GXml.DomRange {
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start"));
set_start (node, 0);
int length = 0;
- if (node is DocumentType) length = 0;
+ if (node is DomDocumentType) length = 0;
else
if (node is DomCharacterData) length = (node as DomCharacterData).length;
else
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index e462307..409fa93 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -37,7 +37,7 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
_node = node;
_doc = doc;
}
- // GXml.Node
+ // GXml.DomNode
public override string value
{
owned get {
@@ -52,7 +52,7 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
if (":" in aname) return;
_node->set_prop (aname, avalue);
}
- public GXml.Node? get_attr (string name)
+ public GXml.DomNode? get_attr (string name)
{
if (_node == null) return null;
string prefix = null;
@@ -94,7 +94,7 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
_node->set_ns_prop (nns, qname, value);
}
}
- public GXml.Node? get_ns_attr (string name, string uri) {
+ public GXml.DomNode? get_ns_attr (string name, string uri) {
if (_node == null) return null;
var a = _node->has_ns_prop (name, uri);
if (a == null) return null;
@@ -142,7 +142,12 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
}
}
public override string to_string () {
- return write_string ();
+ try {
+ return write_string ();
+ } catch (GLib.Error e) {
+ warning (_("Error while converting Element to string: %s"), e.message);
+ }
+ return "";
}
public string write_string (GLib.Cancellable? cancellable = null) {
var buf = new Xml.Buffer ();
@@ -185,28 +190,28 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
owned get {
var p = attrs.get ("id");
if (p == null) return null;
- return p.value;
+ return (p as GNode).value;
}
set {
var p = attrs.get ("id");
if (p == null)
set_attr ("id",value);
else
- p.value = value;
+ (p as GNode).value = value;
}
}
public string? class_name {
owned get {
var p = attrs.get ("class");
if (p == null) return null;
- return p.value;
+ return (p as GNode).value;
}
set {
var p = attrs.get ("class");
if (p == null)
set_attr ("class",value);
else
- p.value = value;
+ (p as GNode).value = value;
}
}
public DomTokenList class_list {
@@ -219,12 +224,12 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
public string? get_attribute (string name) {
var p = attrs.get (name);
if (p == null) return null;
- return p.value;
+ return (p as GNode).value;
}
public string? get_attribute_ns (string? namespace, string local_name) {
var p = get_ns_attr (local_name, namespace);
if (p == null) return null;
- return p.value;
+ return (p as GNode).value;
}
public void set_attribute (string name, string value) throws GLib.Error { set_attr (name, value); }
public void set_attribute_ns (string? namespace, string name, string value) throws GLib.Error {
@@ -329,9 +334,9 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
throws GXml.XPathError
{
GXml.XPathObject nullobj = null;
- if (!(this is GXml.Node))
+ if (!(this is GXml.DomNode))
return nullobj;
- string data = (this as GXml.Node).to_string();
+ string data = (this as GXml.GNode).to_string();
var ndoc = Xml.Parser.read_memory (data, data.length);
var gdoc = new GXml.GDocument.from_doc (ndoc);
var context = new Xml.XPath.Context (ndoc);
diff --git a/gxml/GXmlListChildren.vala b/gxml/GXmlListChildren.vala
index bf7016c..7e82a8a 100644
--- a/gxml/GXmlListChildren.vala
+++ b/gxml/GXmlListChildren.vala
@@ -25,7 +25,7 @@ using Gee;
/**
* A {@link Gee.AbstractBidirList} implementation to access {@link Xml.Node} collection
*/
-public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
+public class GXml.GListChildren : AbstractBidirList<GXml.DomNode>,
DomNodeList, DomHTMLCollection
{
private GXml.GDocument _doc;
@@ -34,12 +34,12 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
_node = node;
_doc = doc;
}
- public new override Gee.BidirListIterator<GXml.Node> bidir_list_iterator () {
+ public new override Gee.BidirListIterator<GXml.DomNode> bidir_list_iterator () {
return new Iterator (_doc, _node);
}
// List
- public override GXml.Node @get (int index) {
- GXml.Node nullnode = null;
+ public override GXml.DomNode @get (int index) {
+ GXml.DomNode nullnode = null;
if (_node == null) return nullnode;
var n = _node->children;
int i = 0;
@@ -52,7 +52,7 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
}
return nullnode;
}
- public override int index_of (GXml.Node item) {
+ public override int index_of (GXml.DomNode item) {
if (_node == null) return -1;
if (!(item is GNode)) return -1;
var n = _node->children;
@@ -67,17 +67,17 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
/**
* Insert @item before @index
*/
- public override void insert (int index, GXml.Node item) {
+ public override void insert (int index, GXml.DomNode item) {
var n = @get (index);
if (n == null) return;
(n as GXml.GNode).get_internal_node ()->add_prev_sibling ((item as GXml.GNode).get_internal_node ());
}
- public override Gee.ListIterator<GXml.Node> list_iterator () { return new Iterator (_doc, _node); }
+ public override Gee.ListIterator<GXml.DomNode> list_iterator () { return new Iterator (_doc, _node); }
/**
* Removes a node at @index. This method never returns a valid pointer.
*/
- public override GXml.Node remove_at (int index) {
- GXml.Node nullnode = null;
+ public override GXml.DomNode remove_at (int index) {
+ GXml.DomNode nullnode = null;
if (index > size || index < 0) return nullnode;
var n = @get (index);
if (n == null) return nullnode;
@@ -89,9 +89,9 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
/**
* This method is ignored by default.
*/
- public override void @set (int index, GXml.Node item) {}
- public override Gee.List<GXml.Node>? slice (int start, int stop) {
- var l = new ArrayList<GXml.Node> ();
+ public override void @set (int index, GXml.DomNode item) {}
+ public override Gee.List<GXml.DomNode>? slice (int start, int stop) {
+ var l = new ArrayList<GXml.DomNode> ();
if (_node == null) return l;
var n = _node->children;
int i = 0;
@@ -104,7 +104,7 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
}
return l;
}
- public override bool add (GXml.Node item) {
+ public override bool add (GXml.DomNode item) {
if (_node == null) return false;
if (!(item is GNamespace))
return (_node->add_child (((GNode) item).get_internal_node ())) != null;
@@ -115,7 +115,7 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
if (_node == null) return;
_node->children->free_list ();
}
- public override bool contains (GXml.Node item) {
+ public override bool contains (GXml.DomNode item) {
if (_node == null) return false;
if (!(item is GXml.GNode)) return false;
var n = _node->children;
@@ -125,8 +125,8 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
}
return false;
}
- public override Gee.Iterator<GXml.Node> iterator () { return new Iterator (_doc, _node); }
- public override bool remove (GXml.Node item) {
+ public override Gee.Iterator<GXml.DomNode> iterator () { return new Iterator (_doc, _node); }
+ public override bool remove (GXml.DomNode item) {
if (_node == null) return false;
if (!(item is GXml.GNode)) return false;
var n = _node->children;
@@ -154,11 +154,11 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
}
public override bool read_only { get { return false; } }
// Iterator
- public class Iterator : Object, Traversable<GXml.Node>,
- Gee.Iterator<GXml.Node>,
- Gee.BidirIterator<GXml.Node>,
- Gee.ListIterator<GXml.Node>,
- BidirListIterator<GXml.Node> {
+ public class Iterator : Object, Traversable<GXml.DomNode>,
+ Gee.Iterator<GXml.DomNode>,
+ Gee.BidirIterator<GXml.DomNode>,
+ Gee.ListIterator<GXml.DomNode>,
+ BidirListIterator<GXml.DomNode> {
private GDocument _doc;
private Xml.Node *_node;
private Xml.Node *_current;
@@ -171,19 +171,19 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
/**
* This method is ignored by default.
*/
- public void insert (GXml.Node item) {}
+ public void insert (GXml.DomNode item) {}
// ListIterator
/**
* This method is ignored by default.
*/
- public void add (GXml.Node item) {}
+ public void add (GXml.DomNode item) {}
public int index () { return i; }
/**
* This method is ignored by default.
*/
- public new void @set (GXml.Node item) {}
+ public new void @set (GXml.DomNode item) {}
// Iterator
- public new GXml.Node @get () { return GNode.to_gnode (_doc, _node); }
+ public new GXml.DomNode @get () { return GNode.to_gnode (_doc, _node); }
public bool has_next () {
if (_node == null) return false;
if (_node->children == null) return false;
@@ -209,7 +209,7 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
}
public bool read_only { get { return false; } }
public bool valid { get { return (_current != null); } }
- public new bool @foreach (Gee.ForallFunc<GXml.Node> f) {
+ public new bool @foreach (Gee.ForallFunc<GXml.DomNode> f) {
while (has_next ()) {
next ();
if (!f(@get())) return false;
diff --git a/gxml/GXmlNode.vala b/gxml/GXmlNode.vala
index 9eb80c7..8a8a757 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/GXmlNode.vala
@@ -34,8 +34,7 @@ public errordomain GXml.Error {
*/
public abstract class GXml.GNode : Object,
GXml.DomEventTarget,
- GXml.DomNode,
- GXml.Node
+ GXml.DomNode
{
protected GXml.GDocument _doc;
protected Xml.Node *_node;
@@ -57,13 +56,13 @@ public abstract class GXml.GNode : Object,
if (_node == null) return false;
return ((_node->new_ns (uri, prefix)) != null);
}
- public virtual Gee.Map<string,GXml.Node> attrs { owned get { return new GHashMapAttr (_doc, _node) as
Gee.Map<string,GXml.Node>; } }
- public virtual Gee.BidirList<GXml.Node> children_nodes { owned get { return new GListChildren (_doc,
_node) as Gee.BidirList<GXml.Node>; } }
+ public virtual Gee.Map<string,GXml.DomNode> attrs { owned get { return new GHashMapAttr (_doc, _node) as
Gee.Map<string,GXml.DomNode>; } }
+ public virtual Gee.BidirList<GXml.DomNode> children_nodes { owned get { return new GListChildren (_doc,
_node) as Gee.BidirList<GXml.DomNode>; } }
public virtual Gee.List<GXml.Namespace> namespaces { owned get { return new GListNamespaces (_doc, _node)
as Gee.List<GXml.Namespace>; } }
public virtual GXml.DomDocument document { get { return _doc; } }
- public virtual GXml.Node parent {
+ public virtual GXml.DomNode parent {
owned get {
- GXml.Node nullnode = null;
+ GXml.DomNode nullnode = null;
if (_node == null) return nullnode;
return to_gnode (document as GDocument, _node->parent);
}
@@ -94,8 +93,8 @@ public abstract class GXml.GNode : Object,
public virtual string to_string () { return get_type ().name (); }
public Xml.Node* get_internal_node () { return _node; }
// Static
- public static GXml.Node to_gnode (GXml.GDocument doc, Xml.Node *node) {
- GXml.Node nullnode = null;
+ public static GXml.DomNode to_gnode (GXml.GDocument doc, Xml.Node *node) {
+ GXml.DomNode nullnode = null;
var t = (GXml.NodeType) node->type;
switch (t) {
case GXml.NodeType.ELEMENT:
@@ -200,10 +199,10 @@ public abstract class GXml.GNode : Object,
if (this is GXml.DomComment) return this.@value;
if (this is GXml.DomDocument || this is GXml.DomElement) {
message ("Is Element");
- foreach (GXml.Node n in children_nodes) {
+ foreach (GXml.DomNode n in children_nodes) {
if (n is GXml.DomText) {
- if (t == null) t = n.value;
- else t += n.value;
+ if (t == null) t = (n as GNode).value;
+ else t += (n as GNode).value;
}
}
}
@@ -211,8 +210,12 @@ public abstract class GXml.GNode : Object,
}
set {
if (this is GXml.DomDocument || this is GXml.DomElement) {
- var t = this.document.create_text_node (value);
- (this.document as Node).children_nodes.add (t as Node);
+ try {
+ var t = this.document.create_text_node (value);
+ this.document.child_nodes.add (t);
+ } catch (GLib.Error e) {
+ warning (_("Error while setting text content to node: %s"), e.message);
+ }
}
if (!(this is GXml.DomText || this is GXml.DomComment || this is GXml.DomProcessingInstruction))
return;
this.@value = value;
@@ -240,22 +243,22 @@ public abstract class GXml.GNode : Object,
return (DomNode) GNode.to_gnode (_doc, n);
}
public bool is_equal_node (DomNode? node) {
- if (!(node is GXml.Node)) return false;
+ if (!(node is GXml.DomNode)) return false;
if (node == null) return false;
- if (this.children_nodes.size != (node as Node).children_nodes.size) return false;
- foreach (GXml.Node a in attrs.values) {
- if (!(node as GXml.Node?).attrs.has_key (a.name)) return false;
- if (a.value != (node as GXml.Node).attrs.get (a.name).value) return false;
+ if (this.children_nodes.size != node.child_nodes.size) return false;
+ foreach (GXml.DomNode a in attrs.values) {
+ if (!(node as GXml.GNode?).attrs.has_key (a.node_name)) return false;
+ if ((a as GNode).value != ((node as GXml.GNode).attrs.get (a.node_name) as GNode).value) return false;
}
for (int i=0; i < children_nodes.size; i++) {
- if (!(children_nodes[i] as GXml.DomNode).is_equal_node ((node as GXml.Node?).children_nodes[i] as
GXml.DomNode?)) return false;
+ if (!(children_nodes[i] as GXml.DomNode).is_equal_node ((node as GXml.DomNode?).child_nodes[i] as
GXml.DomNode?)) return false;
}
return true;
}
public DomNode.DocumentPosition compare_document_position (DomNode other) {
if ((this as GXml.DomNode) == other) return DomNode.DocumentPosition.NONE;
- if (this.document != (other as GXml.Node).document || other.parent_node == null) {
+ if (this.document != (other as GXml.DomNode).owner_document || other.parent_node == null) {
var p = DomNode.DocumentPosition.DISCONNECTED & DomNode.DocumentPosition.IMPLEMENTATION_SPECIFIC;
if ((&this) > (&other))
p = p & DomNode.DocumentPosition.PRECEDING;
@@ -285,13 +288,13 @@ public abstract class GXml.GNode : Object,
public string? lookup_prefix (string? nspace) {
if (_node == null) return null;
if (parent == null) return null;
- if (this is GXml.DocumentType || this is GXml.DomDocumentFragment) return null;
+ if (this is GXml.DomDocumentType || this is GXml.DomDocumentFragment) return null;
var ns = _node->doc->search_ns_by_href (_node, nspace);
if (ns == null) return null;
return ns->prefix;
}
public string? lookup_namespace_uri (string? prefix) {
- if (this is GXml.DocumentType || this is GXml.DomDocumentFragment) return null;
+ if (this is GXml.DomDocumentType || this is GXml.DomDocumentFragment) return null;
var ns = _node->doc->search_ns (_node, prefix);
if (ns == null) return null;
return ns->href;
@@ -324,11 +327,11 @@ public abstract class GXml.GNode : Object,
throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid attempt to insert a document's type or text
node to an invalid parent"));
//FIXME: We should follow steps for DOM4 observers in https://www.w3.org/TR/dom/#concept-node-pre-insert
if (child != null) {
- int i = this.children_nodes.index_of (child as GXml.Node);
- children_nodes.insert (i, (node as GXml.Node));
+ int i = this.children_nodes.index_of (child as GXml.DomNode);
+ children_nodes.insert (i, (node as GXml.DomNode));
return node;
}
- children_nodes.add ((node as GXml.Node));
+ children_nodes.add ((node as GXml.DomNode));
return node;
}
public DomNode append_child (DomNode node) throws GLib.Error {
@@ -354,10 +357,10 @@ public abstract class GXml.GNode : Object,
|| (node is DomDocumentType && !(this is DomDocument)))
throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid attempt to insert a document's type or text
node to an invalid parent"));
//FIXME: Checks for HierarchyRequestError for https://www.w3.org/TR/dom/#concept-node-replace
- int i = children_nodes.index_of ((child as GXml.Node));
+ int i = children_nodes.index_of ((child as GXml.DomNode));
children_nodes.remove_at (i);
if (i < children_nodes.size)
- children_nodes.insert (i, (node as GXml.Node));
+ children_nodes.insert (i, (node as GXml.DomNode));
if (i >= children_nodes.size)
child_nodes.add (node);
return child;
@@ -365,7 +368,7 @@ public abstract class GXml.GNode : Object,
public DomNode remove_child (DomNode child) throws GLib.Error {
if (!this.contains (child))
throw new DomError.NOT_FOUND_ERROR (_("Can't find child node to remove or child have a different
parent"));
- int i = children_nodes.index_of ((child as GXml.Node));
+ int i = children_nodes.index_of ((child as GXml.DomNode));
return (DomNode) children_nodes.remove_at (i);
}
// DomEventTarget implementation
diff --git a/gxml/meson.build b/gxml/meson.build
index 77a16ff..53b7053 100644
--- a/gxml/meson.build
+++ b/gxml/meson.build
@@ -38,7 +38,6 @@ configure_file(output : 'config.h',
valasources = files ([
'Collections.vala',
'CssSelectorParser.vala',
- 'DocumentType.vala',
'DomAttr.vala',
'DomCharacter.vala',
'DomCollections.vala',
@@ -85,7 +84,6 @@ valasources = files ([
'GXmlText.vala',
'GXPathObject.vala',
'Namespace.vala',
- 'Node.vala',
'NodeType.vala',
'Parser.vala',
'Schema.vala',
diff --git a/test/DomGDocumentTest.vala b/test/DomGDocumentTest.vala
index d157a72..9c97766 100644
--- a/test/DomGDocumentTest.vala
+++ b/test/DomGDocumentTest.vala
@@ -351,9 +351,6 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
assert (n.node_name == "code");
n.set_attribute ("id","0y1");
n.set_attribute ("class","login black");
- assert ((n as GXml.Node).namespaces.size == 1);
- assert ((n as GXml.Node).namespaces[0].uri == "http://live.gnome.org/GXml");
- assert ((n as GXml.Node).namespaces[0].prefix == "gxml");
assert (n.namespace_uri == "http://live.gnome.org/GXml");
assert (n.prefix == "gxml");
assert (n.local_name == "code");
diff --git a/test/GHtmlDocumentTest.vala b/test/GHtmlDocumentTest.vala
index eead0d9..9887e5a 100644
--- a/test/GHtmlDocumentTest.vala
+++ b/test/GHtmlDocumentTest.vala
@@ -30,8 +30,8 @@ class GHtmlDocumentTest : GXmlTest {
try {
var doc = new GHtmlDocument.from_path (GXmlTestConfig.TEST_DIR+"/index.html");
Test.message ("Checking root element...");
- assert (doc.root != null);
- assert (doc.root.name.down () == "html".down ());
+ assert (doc.document_element != null);
+ assert (doc.document_element.node_name.down () == "html".down ());
Test.message ("Searching for elemento with id 'user'...");
var n = doc.get_element_by_id ("user");
assert (n != null);
@@ -48,10 +48,10 @@ class GHtmlDocumentTest : GXmlTest {
try {
var doc = new GHtmlDocument.from_path (GXmlTestConfig.TEST_DIR+"/index.html");
Test.message ("Checking root element...");
- assert (doc.root != null);
- assert (doc.root.name.down () == "html".down ());
+ assert (doc.document_element != null);
+ assert (doc.document_element.node_name.down () == "html".down ());
Test.message ("Searching for element with property class and value app...");
- var np = doc.root.get_elements_by_property_value ("class","app");
+ var np = doc.document_element.get_elements_by_property_value ("class","app");
assert (np != null);
assert (np.size == 2);
Test.message ("Searching for elemento with class 'app'...");
@@ -87,9 +87,9 @@ class GHtmlDocumentTest : GXmlTest {
</html>
";
var doc = new GHtmlDocument.from_string_doc (sdoc);
- assert (doc.root != null);
- assert (doc.root.name.down () == "html".down ());
- var ln = doc.root.get_elements_by_property_value ("type","text/javascript");
+ assert (doc.document_element != null);
+ assert (doc.document_element.node_name.down () == "html".down ());
+ var ln = doc.document_element.get_elements_by_property_value
("type","text/javascript");
assert (ln != null);
assert (ln.size == 1);
var np = ln.item (0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]