[gxml] Rolled back changes on GNode. Fixes to bug #771430.
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Rolled back changes on GNode. Fixes to bug #771430.
- Date: Wed, 14 Sep 2016 16:01:47 +0000 (UTC)
commit 3c38f1bde19a855b9c9a51ee7bf4d89f36503b5c
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Sep 14 11:00:12 2016 -0500
Rolled back changes on GNode. Fixes to bug #771430.
gxml/GXmlDomCollections.vala | 23 ++++++++++++++++-------
gxml/GXmlHashMapAttr.vala | 2 +-
gxml/GXmlNode.vala | 10 ++++++----
3 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/gxml/GXmlDomCollections.vala b/gxml/GXmlDomCollections.vala
index 0d43e90..7291646 100644
--- a/gxml/GXmlDomCollections.vala
+++ b/gxml/GXmlDomCollections.vala
@@ -22,7 +22,9 @@
using Gee;
-
+/**
+ * List of string tokens.
+ */
public class GXml.GDomTokenList : Gee.ArrayList<string>, GXml.DomTokenList {
protected DomElement _element;
protected string _attr = null;
@@ -47,18 +49,18 @@ public class GXml.GDomTokenList : Gee.ArrayList<string>, GXml.DomTokenList {
public new bool contains (string token) throws GLib.Error {
if (token == "")
- throw new GXml.DomError.SYNTAX_ERROR (_("DOM: No empty string could be toggle"));
+ throw new GXml.DomError.SYNTAX_ERROR (_("DOM: Invalid token. No empty string can could be used as
token to check if it is contained in token list"));
if (" " in token)
- throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included to
toggle"));
+ throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: Invalid token. No white spaces could be
included as token to check if it is contained in token list"));
return base.contains (token);
}
public new void add (string[] tokens) throws GLib.Error {
foreach (string s in tokens) {
if (s == "")
- throw new GXml.DomError.SYNTAX_ERROR (_("DOM: No empty string could be a token"));
+ throw new GXml.DomError.SYNTAX_ERROR (_("DOM: Invalid token. Empty string can't be as token"));
if (" " in s)
- throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included in
token"));
+ throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: Invalid token. White spaces can't be
used as token"));
base.add (s);
}
update ();
@@ -72,14 +74,21 @@ public class GXml.GDomTokenList : Gee.ArrayList<string>, GXml.DomTokenList {
}
update ();
}
+ /**
+ * A convenient method to remove or add tokens. If force is true, this method
+ * will add it to the list of tokens, same as {@link add}. If force is false
+ * will remove a token from the list {@link remove}
+ */
public bool toggle (string token, bool force = false, bool auto = true) throws GLib.Error {
if (token == "")
- throw new GXml.DomError.SYNTAX_ERROR (_("DOM: No empty string could be toggle"));
+ throw new GXml.DomError.SYNTAX_ERROR (_("DOM: Invalid token. Empty string can't be used as token"));
if (" " in token)
- throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included to
toggle"));
+ throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: Invalid token. White spaces can't be used as
token"));
if (contains (token) && auto) { // FIXME: missing force use
remove_at (index_of (token));
return false;
+ } else {
+ if (!force) return false;
}
update ();
return true;
diff --git a/gxml/GXmlHashMapAttr.vala b/gxml/GXmlHashMapAttr.vala
index 1883237..b6be800 100644
--- a/gxml/GXmlHashMapAttr.vala
+++ b/gxml/GXmlHashMapAttr.vala
@@ -289,7 +289,7 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
iterator ().next ();
var _parent = iterator ().get ().value.parent_node as DomElement;
if (size > 0 && node.owner_document != _parent.owner_document)
- throw new GXml.DomError.WRONG_DOCUMENT_ERROR (_("Invalid document when addin item to collection"));
+ throw new GXml.DomError.WRONG_DOCUMENT_ERROR (_("Invalid document when adding item to named node map
collection"));
if (read_only)
throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("This node collection is read only"));
if (node is GXml.DomAttr && _parent != node.parent_node)
diff --git a/gxml/GXmlNode.vala b/gxml/GXmlNode.vala
index 9f01a24..4a820ff 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/GXmlNode.vala
@@ -84,6 +84,8 @@ public abstract class GXml.GNode : Object,
switch (t) {
case GXml.NodeType.ELEMENT:
return new GElement (doc, node);
+ case GXml.NodeType.ATTRIBUTE:
+ return new GAttribute (doc, (Xml.Attr*) node);
case GXml.NodeType.TEXT:
return new GText (doc, node);
case GXml.NodeType.CDATA_SECTION:
@@ -285,23 +287,23 @@ public abstract class GXml.GNode : Object,
public DomNode insert_before (DomNode node, DomNode? child) throws GLib.Error {
if (!(node is GXml.GNode))
- throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid atemp to add invalid node type"));
+ throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid attemp to add invalid node type"));
if (child != null && !this.contains (child))
throw new DomError.NOT_FOUND_ERROR (_("Can't find child to insert node before"));
if (!(this is DomDocument
|| this is DomElement
|| this is DomDocumentFragment))
- throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid atemp to insert a node"));
+ throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid attemp to insert a node"));
if (!(node is DomDocumentFragment
|| node is DomDocumentType
|| node is DomElement
|| node is DomText
|| node is DomProcessingInstruction
|| node is DomComment))
- throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid atemp to insert an invalid node type"));
+ throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid attemp to insert an invalid node type"));
if ((node is DomText && this is DomDocument)
|| (node is DomDocumentType && !(this is DomDocument)))
- throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid atemp to insert a document's type or text node
to a invalid parent"));
+ throw new DomError.HIERARCHY_REQUEST_ERROR (_("Invalid attemp to insert a document's type or text node
to a 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]