[gxml] Fixes on DOM4 implementation
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixes on DOM4 implementation
- Date: Mon, 18 Jul 2016 05:45:22 +0000 (UTC)
commit 6dddafc3524c5208a9e03493ea977744ee4b6837
Author: Daniel Espinosa <esodan gmail com>
Date: Mon Jul 18 00:32:40 2016 -0500
Fixes on DOM4 implementation
This commit has some API changes. See at NEWS.
This commit don't compile due to valac Bug #768913.
NEWS | 11 +
configure.ac | 8 +-
gxml/Attribute.vala | 2 +-
gxml/Comment.vala | 2 +-
gxml/DomAttr.vala | 10 +-
gxml/DomCharacter.vala | 22 +-
gxml/DomCollections.vala | 137 ++++----
gxml/DomDocument.vala | 28 +-
gxml/DomElement.vala | 29 +-
gxml/DomEvents.vala | 6 +-
gxml/DomNode.vala | 22 +-
gxml/DomRange.vala | 14 +-
gxml/DomSets.vala | 43 ---
gxml/DomTraversal.vala | 73 ----
gxml/Element.vala | 16 +-
gxml/GHtml.vala | 40 +-
gxml/GXmlAttribute.vala | 18 +-
gxml/GXmlCharacter.vala | 41 ++
gxml/GXmlChildNode.vala | 64 ++++
gxml/GXmlComment.vala | 13 +-
gxml/GXmlDocument.vala | 180 ++++++----
gxml/GXmlDomCollections.vala | 144 ++------
gxml/GXmlDomEvents.vala | 16 +-
gxml/GXmlDomRange.vala | 132 ++++---
gxml/GXmlElement.vala | 134 ++++---
gxml/GXmlHashMapAttr.vala | 117 ++++++-
gxml/GXmlListChildren.vala | 7 +-
gxml/GXmlListNamespaces.vala | 38 +-
gxml/GXmlNamespace.vala | 2 +-
gxml/GXmlNode.vala | 52 ++--
gxml/GXmlProcessingInstruction.vala | 21 +-
gxml/GXmlText.vala | 31 +-
gxml/Makefile.am | 137 +++----
gxml/Node.vala | 33 +-
gxml/ProcessingInstruction.vala | 2 +-
gxml/SerializableGeeArrayList.vala | 2 +-
gxml/SerializableGeeDualKeyMap.vala | 2 +-
gxml/SerializableGeeHashMap.vala | 2 +-
gxml/SerializableGeeTreeMap.vala | 2 +-
gxml/SerializableObjectModel.vala | 14 +-
gxml/TAttribute.vala | 2 +-
gxml/TComment.vala | 2 +-
gxml/TDocument.vala | 26 +-
gxml/TElement.vala | 44 ++-
gxml/TNode.vala | 2 +-
gxml/TProcessingInstruction.vala | 2 +-
gxml/gxml-0.10.deps | 5 -
gxml/{gxml-0.10.pc.in => gxml-0.12.pc.in} | 0
gxml/libxml-Attr.vala | 2 +-
gxml/libxml-CharacterData.vala | 2 +-
gxml/libxml-Comment.vala | 2 +-
gxml/libxml-Element.vala | 21 +-
gxml/libxml-Node.vala | 2 +-
gxml/libxml-ProcessingInstruction.vala | 1 +
test/DocumentTest.vala | 2 +-
test/ElementTest.vala | 6 +-
test/GAttributeTest.vala | 24 +-
test/GDocumentTest.vala | 44 ++--
test/GElementTest.vala | 28 +-
test/HtmlDocumentTest.vala | 8 +-
test/Makefile.am | 4 +-
test/SerializableGeeArrayListTest.vala | 44 ++--
.../SerializableGeeCollections-TDocument-Test.vala | 76 ++--
test/SerializableGeeCollectionsTest.vala | 30 +-
test/SerializableGeeDualKeyMapTest.vala | 42 +-
test/SerializableGeeHashMapTest.vala | 50 ++--
test/SerializableGeeTreeMapTest.vala | 46 ++--
test/SerializableObjectModel-TDocument-Test.vala | 8 +-
test/SerializableObjectModelTest.vala | 64 ++--
test/TCDATATest.vala | 6 +-
test/TCommentTest.vala | 6 +-
test/TDocumentTest.vala | 394 ++++++++++----------
test/TElementTest.vala | 212 ++++++------
test/TProcessingInstructionTest.vala | 6 +-
test/gxml-performance.vala | 22 +-
75 files changed, 1523 insertions(+), 1379 deletions(-)
---
diff --git a/NEWS b/NEWS
index 043d475..8cb5e02 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,17 @@ Version 0.11.0
* Fixed vapi installation, honoring vala pc file
* Fixed Bug #760568
+* Removed Node.childs
+* DOM4 implementation:
+ API Changes:
+ * Node.children now is Node.children_nodes
+ * Element.set_ns_attr now use string for namespace, considering if prefix is included in URI.
+ API Addintions:
+ * DOM4 interfaces
+ * DOM4 collection implementations
+ * Node: get_elements_by_name (), get_elements_by_name_ns ()
+ Implementations:
+ * GNode series implement DOM4 interfaces
===============
Version 0.10.0
diff --git a/configure.ac b/configure.ac
index 46a561e..265f371 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ m4_define([project_nano_version], [0])
# increment current and set revision to 0
# If public symbols have been added since last release, increment age
# If public symbols have been removed since last release, set age to 0
-m4_define([project_lt_current], [10])
+m4_define([project_lt_current], [11])
m4_define([project_lt_revision], [0])
m4_define([project_lt_age], [0])
@@ -35,7 +35,7 @@ m4_define([project_full_version],
# You should set project_released to one in order to mark this as a released version
# and to avoid date on version number
-m4_define(project_released, [1])
+m4_define(project_released, [0])
m4_define([project_maybe_datestamp],
m4_if(project_released, [1],
[], [m4_esyscmd([date +.%Y%m%d | tr -d '\n\r'])]))
@@ -93,7 +93,7 @@ AC_SUBST([PROJECT_MAJOR_MINOR_VERSION])
# - If new versions are compatible with the actual one, just leave this untouched
# - If new version breaks API change it in order to allow paralled installations
# with old versions. Change name of pc files to use a new API too.
-API_VERSION=0.10
+API_VERSION=0.12
AC_SUBST([API_VERSION])
GXML_VERSION=project_base_version
@@ -285,7 +285,7 @@ AM_CONDITIONAL(PLATFORM_WIN32, [test x$platform_win32 = xyes])
AC_CONFIG_FILES([
Makefile
gxml/namespace-info.vala
-gxml/gxml-0.10.pc
+gxml/gxml-0.12.pc
gxml/Makefile
test/Makefile
test/test.xml
diff --git a/gxml/Attribute.vala b/gxml/Attribute.vala
index f3678cb..5d29fe1 100644
--- a/gxml/Attribute.vala
+++ b/gxml/Attribute.vala
@@ -32,6 +32,6 @@ using Gee;
*/
public interface GXml.Attribute : Object, GXml.Node {
public abstract Namespace @namespace { owned get; set; }
- public abstract string prefix { owned get; }
+ public abstract string? prefix { owned get; }
}
diff --git a/gxml/Comment.vala b/gxml/Comment.vala
index 6a073dd..368726c 100644
--- a/gxml/Comment.vala
+++ b/gxml/Comment.vala
@@ -29,6 +29,6 @@ public interface GXml.Comment : Object, GXml.Node
/**
* This should be implemented by returning {@link GXml.Node.value}
*/
- public abstract string str { owned get; }
+ public abstract string str { owned get; set; }
}
diff --git a/gxml/DomAttr.vala b/gxml/DomAttr.vala
index 6eb844d..8f52cac 100644
--- a/gxml/DomAttr.vala
+++ b/gxml/DomAttr.vala
@@ -21,11 +21,11 @@
*/
public interface GXml.DomAttr {
- public abstract string? namespace_uri { get; }
- public abstract string? prefix { get; }
- public abstract string local_name { get; }
- public abstract string name { get; }
- public abstract string @value { get; set; }
+ public abstract string? namespace_uri { owned get; }
+ public abstract string? prefix { owned get; }
+ public abstract string local_name { owned get; }
+ public abstract string name { owned get; }
+ public abstract string @value { owned get; set; }
public virtual bool specified { get { return true; } } // useless; always returns true
}
diff --git a/gxml/DomCharacter.vala b/gxml/DomCharacter.vala
index d2f897d..446848d 100644
--- a/gxml/DomCharacter.vala
+++ b/gxml/DomCharacter.vala
@@ -1,4 +1,4 @@
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/*
*
* Copyright (C) 2016 Daniel Espinosa <esodan gmail com>
@@ -20,11 +20,15 @@
* Daniel Espinosa <esodan gmail com>
*/
-public interface GXml.DomCharacterData : GLib.Object, GXml.DomNode, GXml.DomNonDocumentTypeChildNode,
GXml.DomChildNode {
+public interface GXml.DomCharacterData : GLib.Object,
+ GXml.DomNode,
+ GXml.DomNonDocumentTypeChildNode,
+ GXml.DomChildNode
+{
/**
* Null is an empty string.
*/
- public abstract string data { get; set; }
+ public abstract string data { owned get; set; }
public virtual ulong length { get { return this.data.length; } }
public virtual string substring_data (ulong offset, ulong count) throws GLib.Error {
@@ -43,26 +47,26 @@ public interface GXml.DomCharacterData : GLib.Object, GXml.DomNode, GXml.DomNonD
public virtual void delete_data (ulong offset, ulong count) throws GLib.Error {
replace_data (offset, count, "");
}
- public virtual void replace_data (ulong offset, ulong count, string data) throws GLib.Error {
+ public new virtual void replace_data (ulong offset, ulong count, string data) throws GLib.Error {
if (((int)offset) > this.data.length)
throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for replace data"));
int c = (int) count;
- if (((int)offset + c) > str.length) c = str.length - (int)offset;
+ if (((int)offset + c) > data.length) c = data.length - (int)offset;
string s = this.data[0:(int)offset];
string s2 = this.data[0:(s.length - (int)offset - c)];
string sr = data[0:(int)count];
- str = s+sr+s2;
+ this.data = (s+sr+s2).dup ();
}
}
public interface GXml.DomText : GXml.DomCharacterData {
- public abstract GXml.DomText split_text(ulong offset);
- public abstract string whole_text { get; }
+ public abstract GXml.DomText split_text(ulong offset) throws GLib.Error;
+ public abstract string whole_text { owned get; }
}
public interface GXml.DomProcessingInstruction : GXml.DomCharacterData {
- public abstract string target { get; }
+ public abstract string target { owned get; }
}
public interface GXml.DomComment : GXml.DomCharacterData {}
diff --git a/gxml/DomCollections.vala b/gxml/DomCollections.vala
index b79a084..1626a40 100644
--- a/gxml/DomCollections.vala
+++ b/gxml/DomCollections.vala
@@ -22,17 +22,17 @@
public interface GXml.DomNonElementParentNode : GLib.Object {
- public abstract DomElement? get_element_by_id (string elementId);
+ public abstract DomElement? get_element_by_id (string element_id) throws GLib.Error;
}
public interface GXml.DomParentNode : GLib.Object {
- public abstract DomHTMLCollection children { get; }
- public abstract DomElement? first_element_child { get; }
- public abstract DomElement? last_element_child { get; }
+ public abstract DomHTMLCollection children { owned get; }
+ public abstract DomElement? first_element_child { owned get; }
+ public abstract DomElement? last_element_child { owned get; }
public abstract ulong child_element_count { get; }
- public abstract DomElement? query_selector (string selectors);
- public abstract DomNodeList query_selector_all (string selectors);
+ public abstract DomElement? query_selector (string selectors) throws GLib.Error;
+ public abstract DomNodeList query_selector_all (string selectors) throws GLib.Error;
}
public interface GXml.DomNonDocumentTypeChildNode : GLib.Object {
@@ -50,38 +50,32 @@ public interface GXml.DomNodeList : GLib.Object, Gee.BidirList<GXml.DomNode> {
public abstract ulong length { get; }
}
-public interface GXml.DomHTMLCollection : GLib.Object, Gee.BidirList<GXml.DomNode> {
- public abstract ulong length { get; }
- public abstract DomElement? item (ulong index);
- public abstract DomElement? named_item (string name);
+public interface GXml.DomHTMLCollection : GLib.Object, Gee.BidirList<GXml.DomElement> {
+ public abstract new GXml.DomElement get (int index);
+ public virtual new GXml.DomElement[] to_array () {
+ return (GXml.DomElement[]) ((Gee.Collection<GXml.Element>) this).to_array ();
+ }
+ public virtual ulong length { get { return (ulong) size; } }
+ public virtual DomElement? item (ulong index) { return this.get ((int) index); }
+ public virtual DomElement? named_item (string name) {
+ foreach (GXml.DomElement e in this) {
+ if (e.node_name == name) return e;
+ }
+ return null;
+ }
}
-public interface GXml.DomNamedNodeMap : GLib.Object {
- public abstract DomNode get_named_item (string name);
- public abstract DomNode set_named_item (DomNode arg) throws GXml.DomError;
- public abstract DomNode remove_named_item (string name) throws GXml.DomError;
- public abstract DomNode item (ulong index);
- public abstract ulong length { get; }
- // Introduced in DOM Level 2:
- public abstract DomNode get_named_item_ns (string namespaceURI, string localName) throws GXml.DomError;
- // Introduced in DOM Level 2:
- public abstract DomNode set_named_item_ns (DomNode arg) throws GXml.DomError;
- // Introduced in DOM Level 2:
- public abstract DomNode remove_named_item_ns (string namespaceURI, string localName) throws GXml.DomError;
-}
-
-
public interface GXml.DomNodeIterator {
- public DomNode root { get; }
- public DomNode reference_node { get; }
- public bool pointer_before_reference_node { get; };
- public ulong what_to_show { get; }
- public DomNodeFilter? filter { get; }
+ public abstract DomNode root { get; }
+ public abstract DomNode reference_node { get; }
+ public abstract bool pointer_before_reference_node { get; }
+ public abstract ulong what_to_show { get; }
+ public abstract DomNodeFilter? filter { get; }
- public DomNode? next_node();
- public DomNode? previous_node();
+ public abstract DomNode? next_node();
+ public abstract DomNode? previous_node();
- public void detach();
+ public abstract void detach();
}
public class GXml.DomNodeFilter : Object {
@@ -91,21 +85,21 @@ public class GXml.DomNodeFilter : Object {
public const ushort FILTER_SKIP = 3;
// Constants for whatToShow
- public const ulong SHOW_ALL = 0xFFFFFFFF;
- public const ulong SHOW_ELEMENT = 0x1;
- public const ulong SHOW_ATTRIBUTE = 0x2; // historical
- public const ulong SHOW_TEXT = 0x4;
- public const ulong SHOW_CDATA_SECTION = 0x8; // historical
- public const ulong SHOW_ENTITY_REFERENCE = 0x10; // historical
- public const ulong SHOW_ENTITY = 0x20; // historical
- public const ulong SHOW_PROCESSING_INSTRUCTION = 0x40;
- public const ulong SHOW_COMMENT = 0x80;
- public const ulong SHOW_DOCUMENT = 0x100;
- public const ulong SHOW_DOCUMENT_TYPE = 0x200;
- public const ulong SHOW_DOCUMENT_FRAGMENT = 0x400;
- public const ulong SHOW_NOTATION = 0x800; // historical
-
- public ushort acceptNode(Node node); // FIXME: Should be a User defined method
+ public const ulong SHOW_ALL = (ulong) 0xFFFFFFFF;
+ public const ulong SHOW_ELEMENT = (ulong) 0x1;
+ public const ulong SHOW_ATTRIBUTE = (ulong) 0x2; // historical
+ public const ulong SHOW_TEXT = (ulong) 0x4;
+ public const ulong SHOW_CDATA_SECTION = (ulong) 0x8; // historical
+ public const ulong SHOW_ENTITY_REFERENCE = (ulong) 0x10; // historical
+ public const ulong SHOW_ENTITY = (ulong) 0x20; // historical
+ public const ulong SHOW_PROCESSING_INSTRUCTION = (ulong) 0x40;
+ public const ulong SHOW_COMMENT = (ulong) 0x80;
+ public const ulong SHOW_DOCUMENT = (ulong) 0x100;
+ public const ulong SHOW_DOCUMENT_TYPE = (ulong) 0x200;
+ public const ulong SHOW_DOCUMENT_FRAGMENT = (ulong) 0x400;
+ public const ulong SHOW_NOTATION = (ulong) 0x800; // historical
+
+ public delegate ushort AcceptNode(Node node); // FIXME: Should be a User defined method
}
public interface GXml.DomTreeWalker : Object {
@@ -123,30 +117,35 @@ public interface GXml.DomTreeWalker : Object {
public abstract DomNode? nextNode();
}
-public interface GXml.DomTokenList : Object, Gee.BidirList<string> {
+public interface GXml.DomNamedNodeMap : Object, Gee.Map<string,DomNode> {
public abstract ulong length { get; }
- public abstract string? item (ulong index);
- public abstract bool contains (string token) throw GLib.Error ;
- public abstract void add (string[] tokens) throw GLib.Error ;
- public abstract void remove (string[] tokens) throw GLib.Error ;
- public abstract bool toggle (string token, bool force = false) throws GLib.Error;
- public abstract string to_string ();
+ public abstract DomNode? item (ulong index);
+ public abstract DomNode? get_named_item (string name);
+ public abstract DomNode? set_named_item (DomNode node) throws GLib.Error;
+ public abstract DomNode? remove_named_item (string name) throws GLib.Error;
+ // Introduced in DOM Level 2:
+ public abstract DomNode? remove_named_item_ns (string namespace_uri, string localName) throws GLib.Error;
+ // Introduced in DOM Level 2:
+ public abstract DomNode? get_named_item_ns (string namespace_uri, string local_name) throws GLib.Error;
+ // Introduced in DOM Level 2:
+ public abstract DomNode? set_named_item_ns (DomNode node) throws GLib.Error;
}
-public interface GXml.DomSettableTokenList : Object, DOMTokenList {
- public abstract string value { get; set; }
+public interface GXml.DomTokenList : GLib.Object, Gee.BidirList<string> {
+ public abstract ulong length { get; }
+ public abstract string? item (ulong index);
+ public abstract bool contains (string token) throws GLib.Error;
+ public abstract void add (string[] tokens) throws GLib.Error;
+ public abstract void remove (string[] tokens);
+ /**
+ * If @auto is true, adds @token if not present and removing if it is, @force value
+ * is taken in account. If @auto is false, then @force is considered; if true adds
+ * @token, if false removes it.
+ */
+ public abstract bool toggle (string token, bool force = false, bool auto = true) throws GLib.Error;
+ public abstract string to_string ();
}
-public interface GXml.DomNamedNodeMap : Object {
- public ulong length { get; }
- public DomNode? item (ulong index);
- public DomNode? get_named_item (string name);
- public DomNode? set_named_item (DomNode node) throws GLib.Error;
- public DomNode? remove_named_item (string name) throws GLib.Error;
- // Introduced in DOM Level 2:
- public DomNode? remove_named_item_ns (string namespace_uri, string localName) throws GLib.Error;
- // Introduced in DOM Level 2:
- public DomNode? get_named_item_ns (string namespace_uri, string local_name) throws GLib.Error;
- // Introduced in DOM Level 2:
- public DomNode? set_named_item_ns (DomNode node) throws GLib.Error;
+public interface GXml.DomSettableTokenList : GXml.DomTokenList {
+ public abstract string @value { owned get; set; }
}
diff --git a/gxml/DomDocument.vala b/gxml/DomDocument.vala
index 422ae4d..ed79fff 100644
--- a/gxml/DomDocument.vala
+++ b/gxml/DomDocument.vala
@@ -1,4 +1,4 @@
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/*
*
* Copyright (C) 2016 Daniel Espinosa <esodan gmail com>
@@ -20,7 +20,11 @@
* Daniel Espinosa <esodan gmail com>
*/
-public interface GXml.DomDocument : GLib.Object, GXml.DomNode, GXml.DomParentNode,
GXml.DomNonElementParentNode {
+public interface GXml.DomDocument : GLib.Object,
+ GXml.DomNode,
+ GXml.DomParentNode,
+ GXml.DomNonElementParentNode
+{
public abstract DomImplementation implementation { get; }
public abstract string url { get; }
public abstract string document_uri { get; }
@@ -29,24 +33,24 @@ public interface GXml.DomDocument : GLib.Object, GXml.DomNode, GXml.DomParentNod
public abstract string character_set { get; }
public abstract string content_type { get; }
- public abstract DomDocumentType? doctype { get; }
- public abstract DomElement? document_element { get; }
+ public abstract DomDocumentType? doctype { owned get; }
+ public abstract DomElement? document_element { owned get; }
public abstract DomHTMLCollection get_elements_by_tag_name (string local_name);
public abstract DomHTMLCollection get_elements_by_tag_name_ns (string? namespace, string local_name);
public abstract DomHTMLCollection get_elements_by_class_name(string classNames);
public abstract DomElement create_element (string local_name) throws GLib.Error;
- public abstract DomElement create_element_ns (string? namespace, string qualified_name);
+ public abstract DomElement create_element_ns (string? namespace, string qualified_name) throws GLib.Error;
public abstract DomDocumentFragment create_document_fragment();
- public abstract DomText create_text_node (string data);
- public abstract DomComment create_comment (string data);
- public abstract DomProcessingInstruction create_processing_instruction (string target, string data);
+ public abstract DomText create_text_node (string data) throws GLib.Error;
+ public abstract DomComment create_comment (string data) throws GLib.Error;
+ public abstract DomProcessingInstruction create_processing_instruction (string target, string data) throws
GLib.Error;
public abstract DomNode import_node (DomNode node, bool deep = false) throws GLib.Error;
public abstract DomNode adopt_node (DomNode node) throws GLib.Error;
- public abstract DomEvent create_event (string interface);
+ public abstract DomEvent create_event (string interface) throws GLib.Error;
public abstract DomRange create_range();
@@ -65,7 +69,11 @@ public interface GXml.DomImplementation : GLib.Object {
public virtual bool has_feature() { return true; } // useless; always returns true
}
-public interface GXml.DomDocumentFragment : GLib.Object, GXml.DomNode, GXml.DomParentNode,
GXml.DomNonElementParentNode {}
+public interface GXml.DomDocumentFragment : GLib.Object,
+ GXml.DomNode,
+ GXml.DomParentNode,
+ GXml.DomNonElementParentNode
+{}
public interface GXml.DomDocumentType : GLib.Object, GXml.DomNode, GXml.DomChildNode {
public abstract string name { get; }
diff --git a/gxml/DomElement.vala b/gxml/DomElement.vala
index 3b9e556..d146ddc 100644
--- a/gxml/DomElement.vala
+++ b/gxml/DomElement.vala
@@ -20,21 +20,27 @@
* Daniel Espinosa <esodan gmail com>
*/
-public interface GXml.DomElement : GLib.Object, GXml.DomNode, GXml.DomParentNode,
GXml.DomNonDocumentTypeChildNode, GXml.DomChildNode {
- public abstract string? namespace_uri { get; }
- public abstract string? prefix { get; }
- public abstract string local_name { get; }
- public abstract string tag_name { get; }
-
- public abstract string id { get; set; }
- public abstract string class_name { get; set; }
+public interface GXml.DomElement : GLib.Object,
+ GXml.DomNode,
+ GXml.DomParentNode,
+ GXml.DomNonDocumentTypeChildNode,
+ GXml.DomChildNode
+{
+ public abstract string? namespace_uri { owned get; }
+ public abstract string? prefix { owned get; }
+ public abstract string local_name { owned get; }
+ public abstract string tag_name { owned get; }
+
+ public abstract string? id { owned get; set; }
+ public abstract string? class_name { owned get; set; }
public abstract DomTokenList class_list { owned get; }
- public abstract DomNamedNodeMap attributes { get; }
+ public abstract DomNamedNodeMap attributes { owned get; }
+
public abstract string? get_attribute (string name);
public abstract string? get_attribute_ns (string? namespace, string local_name);
- public abstract void set_attribute (string name, string value);
- public abstract void set_attribute_ns (string? namespace, string name, string value);
+ public abstract void set_attribute (string name, string? value);
+ public abstract void set_attribute_ns (string? namespace, string name, string? value);
public abstract void remove_attribute (string name);
public abstract void remove_attribute_ns (string? namespace, string local_name);
public abstract bool has_attribute (string name);
@@ -46,3 +52,4 @@ public interface GXml.DomElement : GLib.Object, GXml.DomNode, GXml.DomParentNode
public abstract DomHTMLCollection get_elements_by_class_name (string class_names);
}
+public class GXml.DomElementList : Gee.ArrayList<DomElement>, GXml.DomHTMLCollection {}
diff --git a/gxml/DomEvents.vala b/gxml/DomEvents.vala
index 92e78a5..7da2b2f 100644
--- a/gxml/DomEvents.vala
+++ b/gxml/DomEvents.vala
@@ -23,7 +23,7 @@
public interface GXml.DomEventTarget : GLib.Object {
public abstract void add_event_listener (string type, DomEventListener? callback, bool capture = false);
public abstract void remove_event_listener (string type, DomEventListener? callback, bool capture = false);
- public abstract bool dispatch_event (DomEvent event);
+ public abstract bool dispatch_event (DomEvent event) throws GLib.Error;
}
public interface GXml.DomEventListener : GLib.Object {
@@ -43,7 +43,7 @@ public interface GXml.DomEvent : GLib.Object {
public abstract bool default_prevented { get; }
- public abstract EventPhase event_phase { get; }
+ public abstract Phase event_phase { get; }
public abstract void stop_propagation ();
@@ -52,7 +52,7 @@ public interface GXml.DomEvent : GLib.Object {
public abstract void prevent_default ();
public abstract void init_event (string type, bool bubbles, bool cancelable);
- public enum EventPhase {
+ public enum Phase {
NONE = 0,
CAPTURING_PHASE,
AT_TARGET,
diff --git a/gxml/DomNode.vala b/gxml/DomNode.vala
index 2524f0d..f14b0f2 100644
--- a/gxml/DomNode.vala
+++ b/gxml/DomNode.vala
@@ -80,11 +80,6 @@ public interface GXml.DomNode : GLib.Object, GXml.DomEventTarget {
public abstract DomNode remove_child (DomNode child);
}
-// Introduced in DOM Level 3:
-const unsigned short VALIDATION_ERR = 16;
-// Introduced in DOM Level 3:
-const unsigned short TYPE_MISMATCH_ERR = 17;
-
public errordomain GXml.DomError {
INDEX_SIZE_ERROR = 1,
DOMSTRING_SIZE_ERROR,//
@@ -105,13 +100,21 @@ public errordomain GXml.DomError {
// Introduced in DOM Level 2:
NAMESPACE_ERROR,//
// Introduced in DOM Level 2:
- INVALID_ACCESS_ERROR,//
+ INVALID_ACCESS_ERROR,// 15
VALIDATION_ERROR,//
- TYPE_MISMATCH_ERROR//
+ TYPE_MISMATCH_ERROR,// 17
+ SECURITY_ERROR,// 18
+ NETWORK_ERROR, //19
+ ABORT_ERROR,//20
+ URL_MISMATCH_ERROR,//21
+ QUOTA_EXCEEDED_ERROR,//22
+ TIME_OUT_ERROR,//23
+ INVALID_NODE_TYPE_ERROR,//24
+ DATA_CLONE_ERROR//25
}
public class GXml.DomErrorName : GLib.Object {
- private Gee.HashMap names = new Gee.HashMap <string,int> ();
+ private Gee.HashMap<string,int> names = new Gee.HashMap <string,int> ();
construct {
names.set ("IndexSizeError", 1);
names.set ("HierarchyRequestError", 3);
@@ -140,9 +143,10 @@ public class GXml.DomErrorName : GLib.Object {
foreach (string k in names.keys) {
if (names.get (k) == error_code) return k;
}
+ return "";
}
public int get_code (string error_name) {
- if (!names.has (error_name)) return 0;
+ if (!names.has_key (error_name)) return 0;
return names.get (error_name);
}
}
diff --git a/gxml/DomRange.vala b/gxml/DomRange.vala
index c2c45b9..1733ced 100644
--- a/gxml/DomRange.vala
+++ b/gxml/DomRange.vala
@@ -20,7 +20,7 @@
* Daniel Espinosa <esodan gmail com>
*/
-public interface GXml.DomRange {
+public interface GXml.DomRange : GLib.Object {
public abstract DomNode start_container { get; }
public abstract ulong start_offset { get; }
public abstract DomNode end_container { get; }
@@ -38,13 +38,13 @@ public interface GXml.DomRange {
public abstract void select_node (DomNode node) throws GLib.Error;
public abstract void select_node_contents (DomNode node) throws GLib.Error;
- public abstract int compare_boundary_points (ushort how, DomRange sourceRange);
+ public abstract int compare_boundary_points (BoundaryPoints how, DomRange sourceRange) throws GLib.Error;
- public abstract void delete_contents ();
- public abstract DomDocumentFragment extract_contents();
- public abstract DomDocumentFragment clone_contents();
- public abstract void insertNode(DomNode node);
- public abstract void surroundContents(DomNode newParent);
+ public abstract void delete_contents () throws GLib.Error;
+ public abstract DomDocumentFragment? extract_contents() throws GLib.Error;
+ public abstract DomDocumentFragment? clone_contents() throws GLib.Error;
+ public abstract void insert_node(DomNode node);
+ public abstract void surround_contents(DomNode newParent);
public abstract DomRange clone_range();
public abstract void detach ();
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 25535e8..ca94ad1 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -57,7 +57,7 @@ public interface GXml.Element : Object, GXml.Node
/**
* Set an {@link GXml.Attribute} with a given name, value and namespace.
*/
- public abstract void set_ns_attr (Namespace ns, string name, string value);
+ public abstract void set_ns_attr (string ns, string name, string value);
/**
* Search for a {@link GXml.Attribute} with a given name and namespace uri.
*
@@ -80,16 +80,4 @@ public interface GXml.Element : Object, GXml.Node
* Convenient class for a list of {@link GXml.Element} objects based on
* {@link Gee.ListArray}, with good support for bindings.
*/
-public class GXml.ElementList : ArrayList<GXml.Element>, GXml.DomHTMLCollection
-{
- public new GXml.Element get (int index) { return base.get (index); }
- public new GXml.Element[] to_array () { return (GXml.Element[]) ((Gee.Collection<GXml.Element>)
this).to_array (); }
- public ulong length { get { return (ulong) size; } }
- public DomElement? item (ulong index) { get ((int) index); }
- public DomElement? named_item (string name) {
- foreach (GXml.Element e in this) {
- if (e.name == name) return e;
- }
- }
-}
-}
+public class GXml.ElementList : ArrayList<Element>, GXml.DomHTMLCollection {}
diff --git a/gxml/GHtml.vala b/gxml/GHtml.vala
index b8ddc99..c03900e 100644
--- a/gxml/GHtml.vala
+++ b/gxml/GHtml.vala
@@ -28,7 +28,7 @@ namespace GXml {
/**
* HML parsing suport. Document handling
*/
- public class HtmlDocument : GXml.xDocument {
+ public class HtmlDocument : GXml.GDocument {
public static int default_options {
get {
return Html.ParserOption.NONET | Html.ParserOption.NOWARNING |
Html.ParserOption.NOERROR | Html.ParserOption.NOBLANKS;
@@ -50,42 +50,40 @@ namespace GXml {
}
public HtmlDocument.from_string (string html, int options = 0) {
- base.from_libxml2 (Html.Doc.read_memory (html.to_utf8(), html.length, "", null,
options));
+ base.from_doc (Html.Doc.read_memory (html.to_utf8(), html.length, "", null, options));
}
/**
* Search all {@link GXml.Element} with a property called "class" and with a
* value as a class apply to a node.
- */
- public GXml.ElementList get_elements_by_class_name (string klass) {
- var rl = new GXml.ElementList ();
+ *//*
+ public GXml.DomElementList get_elements_by_class_name (string klass) {
+ var rl = new GXml.DomElementList ();
var l = root.get_elements_by_property_value ("class", klass);
- foreach (GXml.Node n in l) {
- if (!(n is GXml.Element)) continue;
- var p = n.attrs.get ("class");
+ foreach (GXml.DomElement n in l) {
+ var p = n.attributes.get ("class");
if (p == null) continue;
- if (" " in p.value) {
- foreach (string ks in p.value.split (" ")) {
+ if (" " in p.node_value) {
+ foreach (string ks in p.node_value.split (" ")) {
if (ks == klass)
- rl.add ((GXml.Element) n);
+ rl.add (n);
}
- } else if (klass == p.value) {
- rl.add ((GXml.Element) n);
+ } else if (klass == p.node_value) {
+ rl.add (n);
}
}
return rl;
- }
+ }*/
/**
* Get first node where 'id' attribute has given value.
- */
- public GXml.Element? get_element_by_id (string id) {
+ *//*
+ public GXml.DomElement? get_element_by_id (string id) {
var l = root.get_elements_by_property_value ("id", id);
- foreach (GXml.Node n in l) {
- if (!(n is Element)) continue;
- var p = n.attrs.get ("id");
+ foreach (GXml.DomElement n in l) {
+ var p = n.attributes.get ("id");
if (p == null) continue;
- if (p.value == id) return (GXml.Element?) n;
+ if (p.node_value == id) return (GXml.DomElement?) n;
}
return null;
- }
+ }*/
}
}
diff --git a/gxml/GXmlAttribute.vala b/gxml/GXmlAttribute.vala
index f5a5376..a3308a8 100644
--- a/gxml/GXmlAttribute.vala
+++ b/gxml/GXmlAttribute.vala
@@ -51,9 +51,9 @@ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr
}
}
- public override string GXml.Node.name {
+ public override string name {
owned get {
- return _attr->name.dup ();
+ return _attr->name.dup (); // FIXME: Check if name is namespace+local_name
}
}
public override string value {
@@ -73,7 +73,7 @@ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr
_node->set_ns_prop (_attr->ns, _attr->name, value);
}
}
- public string GXml.Attribute.prefix {
+ public string? prefix {
owned get {
if (_attr == null) return "";
if (_attr->ns == null) return "";
@@ -88,19 +88,19 @@ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr
}
// DomAttr implementation
public string? namespace_uri {
- get {
+ owned get {
if (namespace == null) return null;
return namespace.uri;
}
}
- public string? GXml.DomAttr.prefix {
+ /*public string? DomAttr.prefix {
get {
if (namespace == null) return null;
return namespace.prefix;
}
- }
- public string local_name { get { return (this as GXml.Node).name; } }
- public string GXml.DomAttr.name {
+ }*/
+ public string local_name { owned get { return (this as GXml.Node).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;
@@ -114,5 +114,5 @@ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr
set {
(this as GXml.Node).value = value;
}
- }
+ }*/
}
diff --git a/gxml/GXmlCharacter.vala b/gxml/GXmlCharacter.vala
new file mode 100644
index 0000000..faa8b82
--- /dev/null
+++ b/gxml/GXmlCharacter.vala
@@ -0,0 +1,41 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ *
+ * Copyright (C) 2016 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Espinosa <esodan gmail com>
+ */
+
+public class GXml.GCharacterData : GXml.GNonDocumentChildNode, GXml.Character,
+ GXml.DomCharacterData
+{
+ // GXml.Character
+ public string str {
+ owned get { return base.value; }
+ set { base.value = value; }
+ }
+ // GXml.DomCharacterData
+ public string data {
+ owned get {
+ return str;
+ }
+ set {
+ str = value;
+ }
+ }
+
+}
diff --git a/gxml/GXmlChildNode.vala b/gxml/GXmlChildNode.vala
new file mode 100644
index 0000000..408c927
--- /dev/null
+++ b/gxml/GXmlChildNode.vala
@@ -0,0 +1,64 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ *
+ * Copyright (C) 2016 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Espinosa <esodan gmail com>
+ */
+
+public class GXml.GChildNode : GXml.GNode,
+ GXml.DomChildNode
+{
+ // DomChildNode
+ public void remove () {
+ if (parent_node != null) {
+ var i = parent_node.child_nodes.index_of (this);
+ parent_node.child_nodes.remove_at (i);
+ }
+ }
+}
+
+public class GXml.GNonDocumentChildNode : GXml.GChildNode,
+ GXml.DomNonDocumentTypeChildNode
+{
+
+ // DomNonDocumentTypeChildNode
+ public DomElement? previous_element_sibling {
+ get {
+ if (parent_node != null) {
+ var i = parent_node.child_nodes.index_of (this);
+ if (i == 0) return null;
+ var n = parent_node.child_nodes.item (i - 1);
+ if (n is DomElement) return (DomElement) n;
+ return null;
+ }
+ return null;
+ }
+ }
+ public DomElement? next_element_sibling {
+ get {
+ if (parent_node != null) {
+ var i = parent_node.child_nodes.index_of (this);
+ if (i == parent_node.child_nodes.length - 1) return null;
+ var n = parent_node.child_nodes.item (i + 1);
+ if (n is DomElement) return (DomElement) n;
+ return null;
+ }
+ return null;
+ }
+ }
+}
diff --git a/gxml/GXmlComment.vala b/gxml/GXmlComment.vala
index 3fa02ff..897b8bd 100644
--- a/gxml/GXmlComment.vala
+++ b/gxml/GXmlComment.vala
@@ -24,7 +24,7 @@ using Gee;
/**
* Class implemeting {@link GXml.Comment} interface, not tied to libxml-2.0 library.
*/
-public class GXml.GComment : GXml.GNode, GXml.Comment, GXml.DomCharacterData, GXml.DomComment
+public class GXml.GComment : GXml.GCharacterData, GXml.Comment, GXml.DomComment
{
public GComment (GDocument doc, Xml.Node *node)
{
@@ -36,15 +36,4 @@ public class GXml.GComment : GXml.GNode, GXml.Comment, GXml.DomCharacterData, GX
return "#comment".dup ();
}
}
- // GXml.Comment
- public string str { owned get { return base.value; } }
- // GXml.DomCharacterData
- public string data {
- get {
- return str;
- }
- set {
- str = value;
- }
- }
}
diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala
index 8e729dc..612d633 100644
--- a/gxml/GXmlDocument.vala
+++ b/gxml/GXmlDocument.vala
@@ -27,9 +27,14 @@ using Xml;
* Class implemeting {@link GXml.Document} interface, not tied to libxml-2.0 library.
*
* This class use {@link Xml.TextWriter} to write down XML documents using
- * its contained {@link GXml.Node} childs or other XML structures.
+ * its contained {@link GXml.Node} children or other XML structures.
*/
-public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
+public class GXml.GDocument : GXml.GNode,
+ GXml.Document,
+ GXml.DomParentNode,
+ GXml.DomNonElementParentNode,
+ GXml.DomDocument,
+ GXml.DomXMLDocument
{
protected Xml.Doc* doc;
protected Xml.Buffer _buffer;
@@ -87,7 +92,7 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
}
// GXml.Node
public override Gee.Map<string,GXml.Node> attrs { owned get { return new GHashMapAttr (this, (Xml.Node*)
doc); } }
- public override Gee.BidirList<GXml.Node> children { owned get { return new GListChildren (this,
(Xml.Node*) doc); } }
+ public override Gee.BidirList<GXml.Node> children_nodes { owned get { return new GListChildren (this,
(Xml.Node*) doc); } }
public override Gee.List<GXml.Namespace> namespaces { owned get { return new GListNamespaces (this,
(Xml.Node*) doc); } }
public override GXml.Document document { get { return this; } }
// GXml.Document
@@ -101,8 +106,8 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
var r = doc->get_root_element ();
if (r == null) {
int found = 0;
- for (int i = 0; i < childs.size; i++) {
- GXml.Node n = childs.get (i);
+ for (int i = 0; i < children_nodes.size; i++) {
+ GXml.Node n = children_nodes.get (i);
if (n is GXml.Element) {
found++;
if (found == 1)
@@ -157,7 +162,7 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
#endif
Xml.Doc doc = new Xml.Doc ();
Xml.TextWriter tw = Xmlx.new_text_writer_doc (ref doc);
- TDocument.write_document (this, tw);
+ try { TDocument.write_document (this, tw); } catch { return "<?xml version=\"0\"?>"; }
string str;
int size;
doc.dump_memory (out str, out size);
@@ -189,7 +194,7 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
protected string _compat_mode = "";
protected string _character_set = "";
protected string _content_type = "";
- public DomImplementation implementation { get { return _implementation; } }
+ public DomImplementation implementation { get { return (DomImplementation) _implementation; } }
public string url { get { return _url; } }
public string document_uri { get { return _document_uri; } }
public string origin { get { return _origin; } }
@@ -198,17 +203,17 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
public string content_type { get { return _content_type; } }
protected DomDocumentType _doctype = null;
- public DomDocumentType? doctype { get { return _doctype; } }
- public DomElement? document_element { get { return root; } }
+ public DomDocumentType? doctype { owned get { return _doctype; } }
+ public DomElement? document_element { owned get { return (DomElement) root; } }
- public DomElement GXml.Document.create_element (string local_name) throws GLib.Error {
- return create_element_node (local_name);
+ public DomElement GXml.DomDocument.create_element (string local_name) throws GLib.Error {
+ return (DomElement) (this as Document).create_element (local_name);
}
- public DomElement create_element_ns (string? ns, string qualified_name) throws GLib.Error
+ public DomElement GXml.DomDocument.create_element_ns (string? ns, string qualified_name) throws GLib.Error
{
- var e = create_element (qualified_name);
+ var e = (this as GXml.Document).create_element (qualified_name);
e.set_namespace (ns, null);
- return e;
+ return e as DomElement;
}
public DomHTMLCollection get_elements_by_tag_name (string local_name) {
@@ -224,35 +229,35 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
public DomDocumentFragment create_document_fragment() {
return new GDocumentFragment (this);
}
- public DomText create_text_node (string data) {
- return create_text (data);
+ public DomText create_text_node (string data) throws GLib.Error {
+ return (DomText) create_text (data);
}
- public DomComment GXml.DomDocument.create_comment (string data) {
- return create_comment_node (data);
+ public DomComment GXml.DomDocument.create_comment (string data) throws GLib.Error {
+ return (DomComment) create_comment (data);
}
- public DomProcessingInstruction create_processing_instruction (string target, string data) {
- return create_pi (target, data);
+ public DomProcessingInstruction create_processing_instruction (string target, string data) throws
GLib.Error {
+ return (DomProcessingInstruction) create_pi (target, data);
}
public DomNode import_node (DomNode node, bool deep = false) throws GLib.Error {
if (node is DomDocument)
- throw new GXml.DomError (GXml.DomError.NOT_SUPPORTED_ERROR,_("Can't import a Document"));
- var dst = this.create_element_node ();
- GXml.Node.copy (this, dst, node, deep);
- return dst;
+ throw new GXml.DomError.NOT_SUPPORTED_ERROR (_("Can't import a Document"));
+ var dst = this.create_element (node.node_name);
+ GXml.Node.copy (this, dst, (GXml.Node) node, true);
+ return (DomNode) dst;
}
public DomNode adopt_node (DomNode node) throws GLib.Error {
if (node is DomDocument)
- throw new GXml.DomError (GXml.DomError.NOT_SUPPORTED_ERROR,_("Can't adopt a Document"));
- var dst = this.create_element_node (node.node_name);
- GXml.Node.copy (this, dst, node, deep);
- if (node.parent != null)
- node.parent.children.remove_at (node.parent.children.index_of (node));
- return dst;
+ throw new GXml.DomError.NOT_SUPPORTED_ERROR (_("Can't adopt a Document"));
+ var dst = this.create_element (node.node_name);
+ GXml.Node.copy (this, dst, (GXml.Node) node, true);
+ if (node.parent_node != null)
+ node.parent_node.child_nodes.remove_at (node.parent_node.child_nodes.index_of (node));
+ return (DomNode) dst;
}
- protected GLib.Object _constructor;
- public abstract DomEvent create_event (string iface) {
+ protected GXml.DomEvent _constructor;
+ public DomEvent create_event (string iface) {
var s = iface.down ();
if (s == "customevent") _constructor = new GXml.GDomCustomEvent ();
if (s == "event") _constructor = new GXml.GDomCustomEvent ();
@@ -266,10 +271,11 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
if (s == "touchevent") _constructor = null;
if (s == "uievent") _constructor = null;
if (s == "uievents") _constructor = null;
+ return _constructor;
}
public DomRange create_range() {
- return new GDomRange ();
+ return new GDomRange (this);
}
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
@@ -278,26 +284,58 @@ public class GXml.GDocument : GXml.GNode, GXml.Document, GXml.DomDocument
return new GDomNodeIterator (root, what_to_show, filter);
}
public DomTreeWalker create_tree_walker (DomNode root, ulong what_to_show = (ulong) 0xFFFFFFFF,
DomNodeFilter? filter = null) {
- return new GDomTreeWolker (root, what_to_show, filter);
+ return new GDomTreeWalker (root, what_to_show, filter);
+ }
+ // DomParentNode
+ public DomHTMLCollection children { owned get { return (DomHTMLCollection) children_nodes; } }
+ public DomElement? first_element_child {
+ owned get { return (DomElement) (this as Document).children_nodes.first (); }
+ }
+ public DomElement? last_element_child {
+ owned get { return (DomElement) (this as Document).children_nodes.last (); }
+ }
+ public ulong child_element_count { get { return (ulong) children_nodes.size; } }
+
+ public DomElement? query_selector (string selectors) throws GLib.Error {
+ return null; // FIXME
+ }
+ public DomNodeList query_selector_all (string selectors) throws GLib.Error {
+ return null; // FIXME
+ }
+ // DomNonElementParentNode
+ public DomElement? get_element_by_id (string element_id) throws GLib.Error {
+ foreach (DomElement n in children) {
+ if (!(n is DomElement)) continue;
+ if ((n as DomElement).get_attribute ("id") == element_id) return (DomElement) n;
+ }
+ return null;
}
}
public class GXml.GImplementation : GLib.Object, GXml.DomImplementation {
- public abstract DomDocumentType
+ public DomDocumentType
create_document_type (string qualified_name, string public_id, string system_id)
throws GLib.Error
{
-
+ return new GDocumentType.with_ids (qualified_name, public_id, system_id); // FIXME
+ }
+ public DomXMLDocument create_document (string? namespace,
+ string? qualified_name,
+ DocumentType? doctype = null)
+ throws GLib.Error
+ { return new GDocument (); } // FIXME
+ public Document create_html_document (string title) {
+ return new HtmlDocument (); // FIXME:
}
- public abstract DomXMLDocument create_document (string? namespace, string? qualified_name, DocumentType?
doctype = null) throws GLib.Error;
- public abstract Document create_html_document (string title);
-
- public virtual bool has_feature() { return true; } // useless; always returns true
}
-public class GXml.GDocumentType : GXml.GNode, GXml.DomNode, GXml.DomChildNode, GXml.DomDocumentType {
+public class GXml.GDocumentType : GXml.GChildNode,
+ GXml.DomNode,
+ GXml.DomChildNode,
+ GXml.DomDocumentType
+{
protected string _name = "";
protected string _public_id = "";
protected string _system_id = "";
@@ -322,53 +360,61 @@ public class GXml.GDocumentType : GXml.GNode, GXml.DomNode, GXml.DomChildNode, G
}
}
-public class GXml.GDocumentFragment : GXml.GNode, GXml.DomDocumentFragment {
- public GDocumentFragment (GXml.GDocument doc) {
- document = doc;
- }
+public class GXml.GDocumentFragment : GXml.GDocument,
+ GXml.DomDocumentFragment
+{
+ public GDocumentFragment (GXml.GDocument d) {
+ _doc = d._doc; // FIXME: https://www.w3.org/TR/dom/#dom-document-createdocumentfragment
+ }
}
public class GXml.GDomNodeIterator : Object, GXml.DomNodeIterator {
protected DomNode _root;
protected DomNode _reference_node;
- protected DomNode _pointer_before_reference_node;
- protected DomNode _what_to_show;
- protected DomFilter _filter;
- public GDomNodeIterator (DomNode n, what_to_show, filter) {
+ protected bool _pointer_before_reference_node;
+ protected ulong _what_to_show;
+ protected DomNodeFilter _filter;
+ public GDomNodeIterator (DomNode n, ulong what_to_show, DomNodeFilter filter) {
_root = n;
_what_to_show = what_to_show;
_filter = filter;
}
public DomNode root { get { return _root; } }
- public DomNode reference_node { get { return _reference_node; }} }
- public bool pointer_before_reference_node { get { return _pointer_before_reference_node; } };
+ public DomNode reference_node { get { return _reference_node; } }
+ public bool pointer_before_reference_node { get { return _pointer_before_reference_node; } }
public ulong what_to_show { get { return _what_to_show; } }
public DomNodeFilter? filter { get { return _filter; } }
- public DomNode? next_node() { return null; // FIXME;}
- public DomNode? previous_node() { return null; // FIXME;}
+ public DomNode? next_node() { return null; } // FIXME
+ public DomNode? previous_node() { return null; } // FIXME
- public void detach() { return null; // FIXME;}
+ public void detach() { return; } // FIXME
}
public class GXml.GDomTreeWalker : Object, GXml.DomTreeWalker {
- protected DomNode root { get; }
+ protected DomNode _root;
protected ulong _what_to_show;
protected DomNodeFilter? _filter;
protected DomNode _current_node;
- public DomNode root { get; }
- public ulong what_to_show { get; }
- public DomNodeFilter? filter { get; }
- public DomNode current_node { get; }
-
- public DomNode? parentNode() { return null; // FIXME: }
- public DomNode? firstChild() { return null; // FIXME: }
- public DomNode? lastChild() { return null; // FIXME: }
- public DomNode? previousSibling() { return null; // FIXME: }
- public DomNode? nextSibling() { return null; // FIXME: }
- public DomNode? previousNode() { return null; // FIXME: }
- public DomNode? nextNode() { return null; // FIXME: }
+ public DomNode root { get { return root; } }
+ public ulong what_to_show { get { return _what_to_show; } }
+ public DomNodeFilter? filter { get { return _filter; } }
+ public DomNode current_node { get { return _current_node; } }
+
+ public GDomTreeWalker (DomNode r, ulong w, DomNodeFilter f) {
+ _root = r;
+ _what_to_show = w;
+ _filter = f;
+ }
+
+ public DomNode? parentNode() { return null; }// FIXME
+ public DomNode? firstChild() { return null; } // FIXME
+ public DomNode? lastChild() { return null; }// FIXME
+ public DomNode? previousSibling() { return null; }// FIXME
+ public DomNode? nextSibling() { return null; }// FIXME
+ public DomNode? previousNode() { return null; }// FIXME
+ public DomNode? nextNode() { return null; }// FIXME
}
diff --git a/gxml/GXmlDomCollections.vala b/gxml/GXmlDomCollections.vala
index 6b6ad7b..7145955 100644
--- a/gxml/GXmlDomCollections.vala
+++ b/gxml/GXmlDomCollections.vala
@@ -23,7 +23,7 @@
using Gee;
-public interface GXml.GDomTokenList : Object, Gee.ArrayList<string> {
+public class GXml.GDomTokenList : Gee.ArrayList<string>, GXml.DomTokenList {
protected DomElement _element;
protected string _attr = null;
@@ -36,48 +36,53 @@ public interface GXml.GDomTokenList : Object, Gee.ArrayList<string> {
if (_attr != null) {
var av = _element.get_attribute (_attr);
if (av == "") return;
- string[] s = value.split (" ");
- for (int i = 0; i < s.length; i++) {
- (this as Gee.ArrayList<string>).add (s[i]);
+ if (" " in av) {
+ string[] s = av.split (" ");
+ for (int i = 0; i < s.length; i++) {
+ (this as Gee.ArrayList<string>).add (s[i]);
+ }
}
}
}
- public bool contains (string token) throw GLib.Error {
+ public new bool contains (string token) throws GLib.Error {
if (token == "")
throw new GXml.DomError.SYNTAX_ERROR (_("DOM: No empty string could be toggle"));
if (" " in token)
throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included to
toggle"));
return base.contains (token);
}
- public void add (string[] tokens) {
- if (token == "")
- throw new GXml.DomError.SYNTAX_ERROR (_("DOM: No empty string could be toggle"));
- if (" " in token)
- throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included to
toggle"));
+
+ 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"));
+ if (" " in s)
+ throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included in
token"));
base.add (s);
}
update ();
}
- public void remove (string[] tokens) {
+ public new void remove (string[] tokens) {
for (int i = 0; i < size; i++) {
+ string s = get (i);
foreach (string ts in tokens) {
if (s == ts) base.remove_at (i);
}
}
update ();
}
- public bool toggle (string token, bool force = false) throws GLib.Error {
+ 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"));
if (" " in token)
throw new GXml.DomError.INVALID_CHARACTER_ERROR (_("DOM: No white spaces should be included to
toggle"));
- if (contains (token) && !force) {
+ if (contains (token) && auto) { // FIXME: missing force use
remove_at (index_of (token));
return false;
}
update ();
+ return true;
}
public void update () {
if (_element == null) return;
@@ -87,7 +92,7 @@ public interface GXml.GDomTokenList : Object, Gee.ArrayList<string> {
public string to_string () {
string s = "";
for (int i = 0; i < size; i++ ) {
- s += t;
+ s += this.get (i);
if (i+1 < size) s += " ";
}
return s;
@@ -96,7 +101,7 @@ public interface GXml.GDomTokenList : Object, Gee.ArrayList<string> {
public class GXml.GDomSettableTokenList : GXml.GDomTokenList, GXml.DomSettableTokenList {
public string value {
- get { return to_string (); }
+ owned get { return to_string (); }
set {
string[] s = value.split (" ");
for (int i = 0; i < s.length; i++) {
@@ -104,117 +109,22 @@ public class GXml.GDomSettableTokenList : GXml.GDomTokenList, GXml.DomSettableTo
}
}
}
-}
-
-public class GXml.GDomNamedNodeMap : Object, GXml.DomNamedNodeMap {
- protected DomNode _parent;
- protected Gee.Map<string,DomNode> _col;
-
- public ulong length { get; }
-
- public GDomNamedNodeMap (DomNode node, Gee.Map<string,DomNode> col) {
- _parent = node;
- _col = col;
- }
- public DomNode? get_named_item (string name) {
- return _col.get (name);
- }
- /**
- * Search items in this collection and return the object found at
- * @index, but not order is warrantied
- *
- * If @index is greather than collection size, then last element found
- * is returned. This function falls back to first element found on any
- * issue.
- */
- public DomNode? item (ulong index) {
- int i = 0;
- if (index > _col.size) return null;
- foreach (DomNode node in _col.values) {
- if (i == si) return node;
- }
- return null;
- }
- public DomNode? set_named_item (DomNode node) throws GLib.Error {
- if (_col.size > 0 && node.document != parent.document)
- throw new GXml.DomError.WRONG_DOCUMENT_ERROR (_("Invalid document when addin item to collection"));
- if (_col.read_only)
- throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("This node collection is read only"));
- if (node is GXml.DomAttr && _parent != node.parent)
- throw new GXml.DomError.INUSE_ATTRIBUTE_ERROR (_("This node attribute is already in use by other
Element"));
- if (parent is GXml.DomElement && !(node is GXml.DomAttr))
- throw new GXml.DomError.HIERARCHY_REQUEST_ERROR (_("Trying to add an object to an Element, but it is
not an attribute"));
- if (parent is DomElement) {
- (parent as DomElement).set_attr (node.node_name, node.node_value);
- return node;
- }
- return null;
- }
- public DomNode? remove_named_item (string name) throws GLib.Error {
- var n = _col.get (name);
- if (n == null)
- throw new GXml.DomError.NOT_FOUND_ERROR (_("No node with name %s was found".printf (name)));
- if (_col.read_only)
- throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("Node collection is read only"));
- if (parent is DomElement) {
- var n = parent.get_attr (name);
- (parent as DomElement).set_attr (name, null);
- return n;
- }
- return null;
- }
- // Introduced in DOM Level 2:
- public DomNode? get_named_item_ns (string namespace_uri, string local_name) throws GLib.Error {
- foreach (DomNode n in _col.values) {
- if (n.namespace == null) continue;
- if (n.namespace.uri == namespace_uri && n.node_name == local_name)
- return n;
- }
- // FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
- return null;
- }
- // Introduced in DOM Level 2:
- public DomNode? set_named_item_ns (DomNode node) throws GLib.Error {
- if (_col.size > 0 && node.document != parent.document)
- throw new GXml.DomError.WRONG_DOCUMENT_ERROR (_("Invalid document when addin item to collection"));
- if (_col.read_only)
- throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("This node collection is read only"));
- if (node is GXml.DomAttr && _parent != node.parent)
- throw new GXml.DomError.INUSE_ATTRIBUTE_ERROR (_("This node attribute is already in use by other
Element"));
- if (parent is GXml.DomElement && !(node is GXml.DomAttr))
- throw new GXml.DomError.HIERARCHY_REQUEST_ERROR (_("Trying to add an object to an Element, but it is
not an attribute"));
- // FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
- if (parent is DomElement) {
- (parent as DomElement).set_attribute_ns (node.lookup_prefix ()+":"+node.lookup_namespace_uri (),
- node.node_name, node.node_value);
- return parent.get_attribute_ns (node.lookup_prefix ()+":"+node.lookup_namespace_uri (),
node.node_name);
- }
- return null;
- }
- // Introduced in DOM Level 2:
- public DomNode? remove_named_item_ns (string namespace_uri, string local_name) throws GLib.Error {
- if (!(parent is DomElement)) return null;
- var n = get_attribute_ns (namespace_uri, local_name);
- if (n == null)
- throw new GXml.DomError.NOT_FOUND_ERROR (_("No node with name %s was found".printf (name)));
- if (_col.read_only)
- throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("Node collection is read only"));
- // FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
- if (parent is DomElement) {
- (parent as DomElement).set_attribute_ns (namespace_uri, local_name);
- return n;
- }
- return null;
+ public GDomSettableTokenList (DomElement e, string? attr) {
+ base (e, attr);
}
+
}
-public class GXml.GDomHTMLCollection : GLib.ArrayList<GXml.DomElement> {
+public class GXml.GDomHTMLCollection : Gee.ArrayList<GXml.DomElement>,
+ GXml.DomHTMLCollection
+{
public ulong length { get { return size; } }
public DomElement? item (ulong index) { return base.get ((int) index); }
public DomElement? named_item (string name) {
foreach (DomElement e in this) {
if (e.node_name == name) return e;
}
+ return null;
}
}
diff --git a/gxml/GXmlDomEvents.vala b/gxml/GXmlDomEvents.vala
index a206e9e..c0f893a 100644
--- a/gxml/GXmlDomEvents.vala
+++ b/gxml/GXmlDomEvents.vala
@@ -40,20 +40,20 @@ public class GXml.GDomEvent : Object, GXml.DomEvent {
protected bool _default_prevented;
public bool default_prevented { get { return _default_prevented; } }
- protected EventPhase _event_phase;
- public EventPhase event_phase { get { return _event_phase; } }
+ protected DomEvent.Phase _event_phase;
+ public DomEvent.Phase event_phase { get { return _event_phase; } }
protected GXml.DomEvent.Flags _flags;
- public abstract void stop_propagation () {
- _flags = _flags && GXml.DomEvent.Flags.STOP_PROPAGATION_FLAG;
+ public void stop_propagation () {
+ _flags = _flags & GXml.DomEvent.Flags.STOP_PROPAGATION_FLAG;
}
- public abstract void stop_immediate_propagation () {
- _flags = _flags && GXml.DomEvent.Flags.STOP_IMMEDIATE_PROPAGATION_FLAG;
+ public void stop_immediate_propagation () {
+ _flags = _flags & GXml.DomEvent.Flags.STOP_IMMEDIATE_PROPAGATION_FLAG;
}
- public abstract void prevent_default () {
+ public void prevent_default () {
if (cancelable)
- _flags = _flags && GXml.DomEvent.Flags.CANCELED_FLAG;
+ _flags = _flags & GXml.DomEvent.Flags.CANCELED_FLAG;
}
public void init_event (string type, bool bubbles, bool cancelable) {
_etype = type;
diff --git a/gxml/GXmlDomRange.vala b/gxml/GXmlDomRange.vala
index e3fc2df..51a4a04 100644
--- a/gxml/GXmlDomRange.vala
+++ b/gxml/GXmlDomRange.vala
@@ -20,7 +20,9 @@
* Daniel Espinosa <esodan gmail com>
*/
+// FIXME Range could be a set of nodes or a set of character data
public class GXml.GDomRange : Object, GXml.DomRange {
+ protected DomDocument _document;
protected DomNode _start_container;
protected ulong _start_offset;
protected DomNode _end_container;
@@ -34,19 +36,35 @@ public class GXml.GDomRange : Object, GXml.DomRange {
public bool collapsed { get { return _collapse; } }
public DomNode common_ancestor_container { get { return _common_ancestor_container; } }
+ public GDomRange (DomDocument doc) {
+ _document = doc;
+ _start_container = doc;
+ _end_container = doc;
+ _start_offset = 0;
+ _end_offset = 0;
+ _common_ancestor_container = doc; //FIXME: Check spec
+ }
+
public void set_start (DomNode node, ulong offset) throws GLib.Error {
if (node is DomDocumentType)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start"));
- if (offset > node.length)
- throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to start"));
+ if (node is DocumentType)
+ if (offset > 0)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to start: for
document type"));
+ else
+ if (node is DomCharacterData)
+ if (offset > (node as DomCharacterData).length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to
start: for character data"));
+ else
+ if (offset > node.child_nodes.length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to
start: for children number"));
if (_end_container != null) {
- if (node.parent != _end_container.parent) {
+ if (node.parent_node != _end_container.parent_node) {
_start_container = _end_container;
_start_offset = _end_offset;
} else {
- var ni = node.parent.children.index_of (node);
- var ei = node.parent.children.index_of (_end_offset);
- if (ni > ei)
+ var ni = node.parent_node.child_nodes.index_of (node);
+ if (ni > offset)
_end_container = node;
_start_container = node;
_start_offset = offset;
@@ -55,19 +73,26 @@ public class GXml.GDomRange : Object, GXml.DomRange {
_start_container = node;
_start_offset = offset;
}
- public void set_end (DomNode node, ulong offset) throws GLib.Error {
+ public void set_end (DomNode node, ulong offset) throws GLib.Error {
if (node is DomDocumentType)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start"));
- if (offset > node.length)
- throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to start"));
+ if (node is DocumentType)
+ if (offset > 0)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to start: for
document type"));
+ else
+ if (node is DomCharacterData)
+ if (offset > (node as DomCharacterData).length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to
start: for character data"));
+ else
+ if (offset > node.child_nodes.length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for node to
start: for children number"));
if (_start_container != null) {
- if (node.parent != _start_container.parent) {
+ if (node.parent_node != _start_container.parent_node) {
_end_container = _start_container;
_end_offset = _start_offset;
} else {
- var ni = node.parent.children.index_of (node);
- var ei = node.parent.children.index_of (_start_offset);
- if (ni > ei)
+ var ni = node.parent_node.child_nodes.index_of (node);
+ if (ni > offset)
_start_container = node;
}
}
@@ -75,34 +100,34 @@ public class GXml.GDomRange : Object, GXml.DomRange {
_end_offset = offset;
}
public void set_start_before (DomNode node) throws GLib.Error {
- if (node.parent == null)
+ if (node.parent_node == null)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start before"));
- set_start (node.parent, node.parent.children.index_of (node));
+ set_start (node.parent_node, node.parent_node.child_nodes.index_of (node));
}
public void set_start_after (DomNode node) throws GLib.Error {
- if (node.parent == null)
+ if (node.parent_node == null)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start after"));
- var i = node.parent.children.index_of (node);
- if (i+1 < node.parent.children.size)
- set_start (node.parent, node.parent.children.index_of (node) + 1);
+ var i = node.parent_node.child_nodes.index_of (node);
+ if (i+1 < node.parent_node.child_nodes.size)
+ set_start (node.parent_node, node.parent_node.child_nodes.index_of (node) + 1);
else
- set_start (node.parent, node.parent.children.index_of (node));
+ set_start (node.parent_node, node.parent_node.child_nodes.index_of (node));
}
public void set_end_before (DomNode node) throws GLib.Error {
- if (node.parent == null)
+ if (node.parent_node == null)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start before"));
- set_end (node.parent, node.parent.children.index_of (node));
+ set_end (node.parent_node, node.parent_node.child_nodes.index_of (node));
}
public void set_end_after (DomNode node) throws GLib.Error {
- if (node.parent == null)
+ if (node.parent_node == null)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start after"));
- var i = node.parent.children.index_of (node);
- if (i+1 < node.parent.children.size)
- set_end (node.parent, node.parent.children.index_of (node) + 1);
+ var i = node.parent_node.child_nodes.index_of (node);
+ if (i+1 < node.parent_node.child_nodes.size)
+ set_end (node.parent_node, node.parent_node.child_nodes.index_of (node) + 1);
else
- set_end (node.parent, node.parent.children.index_of (node));
+ set_end (node.parent_node, node.parent_node.child_nodes.index_of (node));
}
- public abstract void collapse (bool to_start = false) throws GLib.Error {
+ public void collapse (bool to_start = false) throws GLib.Error {
if (to_start) {
_end_container = _start_container;
_end_offset = _start_offset;
@@ -112,24 +137,32 @@ public class GXml.GDomRange : Object, GXml.DomRange {
}
}
public void select_node (DomNode node) throws GLib.Error {
- if (node.parent == null)
+ if (node.parent_node == null)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start after"));
- var i = node.parent.children.index_of (node);
- set_start (node.parent, i);
- if (i + 1 < node.parent.children.size)
- set_end (node.parent, i + 1);
+ var i = node.parent_node.child_nodes.index_of (node);
+ set_start (node.parent_node, i);
+ if (i + 1 < node.parent_node.child_nodes.size)
+ set_end (node.parent_node, i + 1);
else
- set_end (node.parent, i);
+ set_end (node.parent_node, i);
}
public void select_node_contents (DomNode node) throws GLib.Error {
if (node is DomDocumentType)
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid node type to start"));
set_start (node, 0);
- set_end (node, node.length);
+ ulong length = 0;
+ if (node is DocumentType) length = 0;
+ else
+ if (node is DomCharacterData) length = (node as DomCharacterData).length;
+ else
+ length = node.child_nodes.length;
+ set_end (node, length);
}
- public abstract int compare_boundary_points (BoundaryPoints how, DomRange source_range) throws
GLib.Error {
- if (_start_container.parent != source_range.start_container.parent)
+ public int compare_boundary_points (GXml.DomRange.BoundaryPoints how,
+ DomRange source_range) throws GLib.Error
+ {
+ if (_start_container.parent_node != source_range.start_container.parent_node)
throw new DomError.WRONG_DOCUMENT_ERROR (_("Invalid root's in range"));
switch (how) {
case BoundaryPoints.START_TO_START:
@@ -138,7 +171,7 @@ public class GXml.GDomRange : Object, GXml.DomRange {
return 0;
break;
case BoundaryPoints.START_TO_END:
- set_start (_start_container, _start_container.children.size);
+ set_start (_start_container, _start_container.child_nodes.size);
set_end (source_range.end_container, 0);
return -1;
break;
@@ -156,20 +189,19 @@ public class GXml.GDomRange : Object, GXml.DomRange {
return 0;
}
- public void delete_contents () { return; // FIXME: }
- public DomDocumentFragment extract_contents() { return null; // FIXME:
- }
- public DomDocumentFragment clone_contents() { return null; // FIXME: }
- public void insertNode(DomNode node) { return null; // FIXME: }
- public void surroundContents(DomNode newParent) { return null; // FIXME: }
+ public void delete_contents () throws GLib.Error { return; }// FIXME:
+ public DomDocumentFragment? extract_contents() { return null; }// FIXME:
+ public DomDocumentFragment? clone_contents() { return null; }// FIXME:
+ public void insert_node(DomNode node) { return; }// FIXME:
+ public void surround_contents(DomNode newParent) { return; }// FIXME:
- public DomRange clone_range() { return this; // FIXME: }
- public void detach () { return; // FIXME: }
+ public DomRange clone_range() { return (DomRange) this.ref (); }// FIXME:
+ public void detach () { return; }// FIXME:
- public bool is_point_in_range (DomNode node, ulong offset) { return false; // FIXME: }
- public short compare_point (DomNode node, ulong offset) { return 0; // FIXME: }
+ public bool is_point_in_range (DomNode node, ulong offset) { return false; }// FIXME:
+ public short compare_point (DomNode node, ulong offset) { return 0; }// FIXME:
- public bool intersects_node (DomNode node) { return false; // FIXME: }
+ public bool intersects_node (DomNode node) { return false; }// FIXME:
- public string to_string () { return "DomRange"; // FIXME: }
+ public string to_string () { return "DomRange"; }// FIXME:
}
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index 252fe88..a184547 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -25,7 +25,10 @@ using Gee;
/**
* Class implemeting {@link GXml.Element} interface, not tied to libxml-2.0 library.
*/
-public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
+public class GXml.GElement : GXml.GNonDocumentChildNode,
+ GXml.Element, GXml.DomParentNode,
+ GXml.DomEventTarget,
+ GXml.DomElement
{
public GElement (GDocument doc, Xml.Node *node) {
_node = node;
@@ -69,13 +72,25 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
}
return null;
}
- public void set_ns_attr (Namespace ns, string name, string value) {
+ public void set_ns_attr (string ns, string name, string value) {
if (_node == null) return;
- var ins = _node->doc->search_ns (_node, ns.prefix);
+ string prefix = null;
+ string uri = "";
+ if (":" in ns) {
+ string[] s = ns.split(":");
+ prefix = s[0];
+ uri = s[1];
+ } else
+ uri = ns;
+ var ins = _node->doc->search_ns (_node, prefix);
if (ins != null) {
_node->set_ns_prop (ins, name, value);
return;
}
+ var nns = _node->new_ns (uri, prefix);
+ if (nns != null) {
+ _node->set_ns_prop (nns, name, value);
+ }
}
public GXml.Node get_ns_attr (string name, string uri) {
if (_node == null) return null;
@@ -104,7 +119,14 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
if (a == null) return;
a->remove ();
}
- public string GXml.Element.tag_name { owned get { return _node->name.dup (); } } // FIXME: Tag =
prefix:local_name
+ public string tag_name {
+ owned get {
+ if (_node == null) return name;
+ if (_node->ns != null)
+ return _node->ns->prefix+":"+name;
+ return name;
+ }
+ }
public override string to_string () {
var buf = new Xml.Buffer ();
buf.node_dump (_node->doc, _node, 1, 0);
@@ -112,30 +134,32 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
}
// GXml.DomElement
public string? namespace_uri {
- get {
- if (namespace != null)
- return namespace.uri;
+ owned get {
+ if (_node == null) return null;
+ if (_node->ns != null)
+ return _node->ns->href.dup ();
return null;
}
}
public string? prefix {
- get {
- if (namespace != null)
- return namespace.prefix;
+ owned get {
+ if (_node == null) return null;
+ if (_node->ns != null)
+ return _node->ns->prefix.dup ();
return null;
}
}
- public string local_name { get { return name; } }
- public string GXml.DomElement.tag_name {
+ public string local_name { owned get { return name; } }
+ /*public string GXml.DomElement.tag_name {
get {
if (namespace != null)
return namespace.prefix+":"+name;
return name;
}
- }
+ }*/
- public abstract string id {
- get {
+ public string? id {
+ owned get {
var p = attrs.get ("id");
if (p == null) return null;
return p.value;
@@ -148,8 +172,8 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
p.value = value;
}
}
- public abstract string class_name {
- get {
+ public string? class_name {
+ owned get {
var p = attrs.get ("class");
if (p == null) return null;
return p.value;
@@ -168,31 +192,14 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
}
}
- public DomNamedNodeMap attributes { get { return new GDomNamedNodeMap (this,(Map<string,DomNode>) attrs);
} }
- public string? get_attribute (string name) { return attrs.get (name); }
+ public DomNamedNodeMap attributes { owned get { return (DomNamedNodeMap) attrs; } }
+ public string? get_attribute (string name) { return attrs.get (name).value; }
public string? get_attribute_ns (string? namespace, string local_name) {
- return get_ns_attr (local_name, namespace);
+ return get_ns_attr (local_name, namespace).value;
}
- public void set_attribute (string name, string value) { set_attr (name, value); }
- public void set_attribute_ns (string? namespace, string name, string value) {
- GNamespace ns = null;
- if (namespace != null)
- ns = new GNamespace ();
- string prefix = null;
- string local_name = null;
- if (":" in name) {
- string[] s = namespace.split (":");
- prefix = s[0];
- local_name = s[1];
- } else {
- local_name = name;
- }
- if (ns != null) {
- ns.prefix = prefix;
- ns.uri = namespace;
- }
- // FIXME: Validate name as in Name and QName https://www.w3.org/TR/domcore/#dom-element-setattributens
- set_ns_attr (ns, local_name, value);
+ public void set_attribute (string name, string? value) { set_attr (name, value); }
+ public void set_attribute_ns (string? namespace, string name, string? value) {
+ set_ns_attr (namespace, local_name, value);
}
public void remove_attribute (string name) {
remove_attr (name);
@@ -200,7 +207,7 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
public void remove_attribute_ns (string? namespace, string local_name) {
remove_ns_attr (local_name, namespace);
}
- public bool has_attribute (string name) { return attrs.has (name); }
+ public bool has_attribute (string name) { return attrs.has_key (name); }
public bool has_attribute_ns (string? namespace, string local_name) {
var attr = _node->has_ns_prop (name, namespace);
if (attr == null) return false;
@@ -210,40 +217,61 @@ public class GXml.GElement : GXml.GNode, GXml.Element, GXml.DomElement
public DomHTMLCollection get_elements_by_tag_name (string local_name) {
var l = new GDomHTMLCollection ();
- foreach (GXml.Node n in children) {
+ foreach (GXml.DomNode n in child_nodes) {
if (!(n is GXml.DomElement)) continue;
- if ((n as GXml.DomElement).node_name == local_name)
- l.add (n);
+ if (n.node_name == local_name)
+ l.add ((DomElement) n);
}
return l;
}
public DomHTMLCollection get_elements_by_tag_name_ns (string? namespace, string local_name) {
var l = new GDomHTMLCollection ();
- foreach (GXml.Node n in children) {
+ string prefix = null;
+ string uri = namespace;
+ if (":" in namespace) {
+ string[] s = namespace.split (":");
+ prefix = s[0];
+ uri = s[1];
+ }
+ foreach (GXml.DomNode n in child_nodes) {
if (!(n is GXml.DomElement)) continue;
if ((n as GXml.DomElement).node_name == local_name
- && (n as GXml.DomNode).lookup_namespace_uri == namespace)
- l.add (n);
+ && n.lookup_namespace_uri (prefix) == uri)
+ l.add ((DomElement) n);
}
return l;
}
public DomHTMLCollection get_elements_by_class_name (string class_names) {
var l = new GDomHTMLCollection ();
- foreach (GXml.Node n in children) {
+ foreach (GXml.DomElement n in children) {
if (!(n is GXml.DomElement)) continue;
- if (!n.attrs.has ("class")) continue;
+ if (!n.attributes.has_key ("class")) continue;
if (" " in class_names) {
string[] cs = class_names.split (" ");
bool cl = true;
foreach (string s in cs) {
- if (!(s in n.attrs.get ("class").value)) cl = false;
+ if (!(s in n.attributes.get ("class").node_value)) cl = false;
}
if (cl)
- l.add (n);
+ l.add ((DomElement) n);
} else
- if (n.attrs.get ("class") == class_names)
- l.add (n);
+ if (n.attributes.get ("class").node_value == class_names)
+ l.add ((DomElement) n);
}
return l;
}
+ // DomParentNode
+ public new DomHTMLCollection children { owned get { return children; } }
+ public DomElement? first_element_child { owned get { return children.first (); } }
+ public DomElement? last_element_child { owned get { return children.last (); } }
+ public ulong child_element_count { get { return (ulong) children.size; } }
+
+ public DomElement? query_selector (string selectors) throws GLib.Error {
+ // FIXME:
+ throw new DomError.SYNTAX_ERROR (_("DomElement query_selector is not implemented"));
+ }
+ public DomNodeList query_selector_all (string selectors) throws GLib.Error {
+ // FIXME:
+ throw new DomError.SYNTAX_ERROR (_("DomElement query_selector_all is not implemented"));
+ }
}
diff --git a/gxml/GXmlHashMapAttr.vala b/gxml/GXmlHashMapAttr.vala
index 837142e..391ae88 100644
--- a/gxml/GXmlHashMapAttr.vala
+++ b/gxml/GXmlHashMapAttr.vala
@@ -25,7 +25,8 @@ using Gee;
/**
* Implementation of {@link Gee.AbstractMap} to handle {@link Xml.Node} attributes
*/
-public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>
+public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
+ GXml.DomNamedNodeMap
{
private GDocument _doc;
private Xml.Node *_node;
@@ -206,4 +207,118 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>
public bool read_only { get { return false; } }
public bool valid { get { return _current != null; } }
}
+ // DomNamedNodeMap
+ public ulong length { get { return size; } }
+
+ public DomNode? get_named_item (string name) {
+ return (DomNode?) this.get (name);
+ }
+ /**
+ * Search items in this collection and return the object found at
+ * @index, but not order is warrantied
+ *
+ * If @index is greather than collection size, then last element found
+ * is returned. This function falls back to first element found on any
+ * issue.
+ */
+ public DomNode? item (ulong index) {
+ int i = 0;
+ if (index > size) return null;
+ foreach (GXml.Node node in values) {
+ if (i == index) return (DomNode?) node;
+ }
+ return null;
+ }
+ public DomNode? set_named_item (DomNode node) throws GLib.Error {
+ var i = values.iterator ();
+ 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"));
+ 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)
+ throw new GXml.DomError.INUSE_ATTRIBUTE_ERROR (_("This node attribute is already in use by other
Element"));
+ if (_parent is GXml.DomElement && !(node is GXml.DomAttr))
+ throw new GXml.DomError.HIERARCHY_REQUEST_ERROR (_("Trying to add an object to an Element, but it is
not an attribute"));
+ if (_parent is DomElement) {
+ (_parent as DomElement).set_attribute (node.node_name, node.node_value);
+ return node;
+ }
+ return null;
+ }
+ public DomNode? remove_named_item (string name) throws GLib.Error {
+ var i = values.iterator ();
+ iterator ().next ();
+ var _parent = iterator ().get ().value.parent_node as DomElement;
+ var n = base.get (name);
+ if (n == null)
+ throw new GXml.DomError.NOT_FOUND_ERROR (_("No node with name %s was found".printf (name)));
+ if (read_only)
+ throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("Node collection is read only"));
+ if (_parent is DomElement) {
+ var a = _parent.attributes.get_named_item (name);
+ (_parent as DomElement).set_attribute (name, null);
+ return a;
+ }
+ return null;
+ }
+ // Introduced in DOM Level 2:
+ public DomNode? get_named_item_ns (string namespace_uri, string local_name) throws GLib.Error {
+ foreach (GXml.Node n in values) {
+ string uri = "";
+ if (!(n is DomElement || n is DomAttr)) continue;
+ if (n is DomElement) {
+ if ((n as DomElement).namespace_uri == null) continue;
+ uri = (n as DomElement).namespace_uri;
+ }
+ if (n is DomAttr) {
+ if ((n as DomAttr).namespace_uri == null) continue;
+ uri = (n as DomAttr).namespace_uri;
+ }
+ if (uri == namespace_uri && n.name == local_name)
+ return (GXml.DomNode?) n;
+ }
+ // FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
+ return null;
+ }
+ // Introduced in DOM Level 2:
+ public DomNode? set_named_item_ns (DomNode node) throws GLib.Error {
+ var i = values.iterator ();
+ 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"));
+ 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)
+ throw new GXml.DomError.INUSE_ATTRIBUTE_ERROR (_("This node attribute is already in use by other
Element"));
+ if (_parent is GXml.DomElement && !(node is GXml.DomAttr))
+ throw new GXml.DomError.HIERARCHY_REQUEST_ERROR (_("Trying to add an object to an Element, but it is
not an attribute"));
+ // FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
+ if (_parent is DomElement && node is DomAttr) {
+ (_parent as DomElement).set_attribute_ns ((node as DomAttr).prefix+":"+(node as DomAttr).namespace_uri,
+ node.node_name, node.node_value);
+ return _parent.attributes.get_named_item_ns ((node as DomAttr).prefix+":"+(node as
DomAttr).namespace_uri, node.node_name);
+ }
+ return null;
+ }
+ // Introduced in DOM Level 2:
+ public DomNode? remove_named_item_ns (string namespace_uri, string local_name) throws GLib.Error {
+ var i = values.iterator ();
+ iterator ().next ();
+ var _parent = iterator ().get ().value.parent_node as DomElement;
+ if (!(_parent is DomElement)) return null;
+ var n = _parent.attributes.get_named_item_ns (namespace_uri, local_name);
+ if (n == null)
+ throw new GXml.DomError.NOT_FOUND_ERROR (_("No node with name %s was found".printf (local_name)));
+ if (read_only)
+ throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("Node collection is read only"));
+ // FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
+ if (_parent is DomElement) {
+ (_parent as DomElement).set_attribute_ns (namespace_uri, local_name, null);
+ return n;
+ }
+ return null;
+ }
}
diff --git a/gxml/GXmlListChildren.vala b/gxml/GXmlListChildren.vala
index 7952038..59d3a0d 100644
--- a/gxml/GXmlListChildren.vala
+++ b/gxml/GXmlListChildren.vala
@@ -25,7 +25,8 @@ using Gee;
/**
* A {@link Gee.AbstractBidirList} implementation to access {@link Xml.Node} collection
*/
-public class GXml.GListChildren : AbstractBidirList<GXml.Node>, DomNodeList
+public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
+ DomNodeList, DomHTMLCollection
{
private GXml.GDocument _doc;
private Xml.Node *_node;
@@ -252,5 +253,9 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>, DomNodeList
// DomNodeList implementation
public DomNode? item (ulong index) { return (DomNode) @get ((int) index); }
public ulong length { get { return (ulong) size; } }
+ // DomHTMLCollection
+ public new GXml.DomElement GXml.DomHTMLCollection.get (int index) {
+ return (GXml.DomElement) this.get (index);
+ }
}
diff --git a/gxml/GXmlListNamespaces.vala b/gxml/GXmlListNamespaces.vala
index 5ef33d7..83c5f89 100644
--- a/gxml/GXmlListNamespaces.vala
+++ b/gxml/GXmlListNamespaces.vala
@@ -25,7 +25,7 @@ using Gee;
/**
* A {@link Gee.AbstractList} implementation to access {@link Xml.Ns} namespaces collection
*/
-public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
+public class GXml.GListNamespaces : Gee.AbstractList<GXml.Namespace>
{
private GDocument _doc;
private Xml.Node *_node;
@@ -35,7 +35,7 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
_doc = doc;
}
// List
- public override new GXml.Node @get (int index) {
+ public override new GXml.Namespace @get (int index) {
if (_node == null) return null;
var ns = _node->ns_def;
int i = 0;
@@ -48,7 +48,7 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
}
return null;
}
- public override int index_of (GXml.Node item) {
+ public override int index_of (GXml.Namespace item) {
if (_node == null) return -1;
if (!(item is GNamespace)) return -1;
var ns = _node->ns_def;
@@ -60,12 +60,12 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
}
return -1;
}
- public override void insert (int index, GXml.Node item) {}
- public override Gee.ListIterator<GXml.Node> list_iterator () { return new Iterator (_node); }
- public override GXml.Node remove_at (int index) { return null; }
- public override new 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 insert (int index, GXml.Namespace item) {}
+ public override Gee.ListIterator<GXml.Namespace> list_iterator () { return new Iterator (_node); }
+ public override GXml.Namespace remove_at (int index) { return null; }
+ public override new void @set (int index, GXml.Namespace item) {}
+ public override Gee.List<GXml.Namespace>? slice (int start, int stop) {
+ var l = new ArrayList<GXml.Namespace> ();
if (_node == null) return l;
var ns = _node->ns_def;
int i = 0;
@@ -79,13 +79,13 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
return l;
}
// Collection
- public override bool add (GXml.Node item) {
+ public override bool add (GXml.Namespace item) {
if (!(item is Namespace)) return false;
if (_node == null) return false;
return (_node->new_ns (((Namespace) item).uri, ((Namespace) item).prefix)) != null;
}
public override void clear () {}
- public override bool contains (GXml.Node item) {
+ public override bool contains (GXml.Namespace item) {
if (!(item is GNamespace)) return false;
if (_node == null) return false;
var ns = _node->ns_def;
@@ -94,8 +94,8 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
}
return false;
}
- public override Gee.Iterator<GXml.Node> iterator () { return new Iterator (_node); }
- public override bool remove (GXml.Node item) { return false; }
+ public override Gee.Iterator<GXml.Namespace> iterator () { return new Iterator (_node); }
+ public override bool remove (GXml.Namespace item) { return false; }
public override bool read_only { get { return false; } }
public override int size {
get {
@@ -109,8 +109,8 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
return i;
}
}
- public class Iterator : Object, Gee.Traversable<GXml.Node>, Gee.Iterator<GXml.Node>,
- Gee.ListIterator<GXml.Node> {
+ public class Iterator : Object, Gee.Traversable<GXml.Namespace>, Gee.Iterator<GXml.Namespace>,
+ Gee.ListIterator<GXml.Namespace> {
private Xml.Node *_node;
private Xml.Ns *_current;
private int i = -1;
@@ -118,16 +118,16 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
_node = node;
}
// ListIterator
- public void add (GXml.Node item) {
+ public void add (GXml.Namespace item) {
if (_node == null) return;
if (!(item is GXml.Namespace)) return;
var ns = (GXml.Namespace) item;
_node->new_ns (ns.uri, ns.prefix);
}
public int index () { return i; }
- public new void @set (GXml.Node item) {}
+ public new void @set (GXml.Namespace item) {}
// Iterator
- public new GXml.Node @get () { return new GNamespace (_current); }
+ public new GXml.Namespace @get () { return new GNamespace (_current); }
public bool has_next () {
if (_node->ns_def == null) return false;
if (_current != null)
@@ -146,7 +146,7 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Node>
public bool read_only { get { return false; } }
public bool valid { get { return (_current != null); } }
// Traversable
- public new bool @foreach (Gee.ForallFunc<GXml.Node> f) {
+ public new bool @foreach (Gee.ForallFunc<GXml.Namespace> f) {
while (has_next ()) {
next ();
if (!f(@get())) return false;
diff --git a/gxml/GXmlNamespace.vala b/gxml/GXmlNamespace.vala
index 8a884b3..461ea16 100644
--- a/gxml/GXmlNamespace.vala
+++ b/gxml/GXmlNamespace.vala
@@ -24,7 +24,7 @@ using Gee;
/**
* Class implemeting {@link GXml.Namespace}
*/
-public class GXml.GNamespace : GXml.GNode, GXml.Namespace
+public class GXml.GNamespace : Object, GXml.Namespace
{
private Xml.Ns *_ns;
public GNamespace (Xml.Ns* ns) { _ns = ns; }
diff --git a/gxml/GXmlNode.vala b/gxml/GXmlNode.vala
index 4f78d7d..faf1004 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/GXmlNode.vala
@@ -25,7 +25,7 @@ using Gee;
/**
* Base interface providing basic functionalities to all GXml interfaces.
*/
-public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
+public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode, GXml.DomEventTarget
{
protected GXml.GDocument _doc;
protected Xml.Node *_node;
@@ -39,7 +39,7 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
return ((_node->new_ns (uri, prefix)) != null);
}
public virtual Gee.Map<string,GXml.Node> attrs { owned get { return new GHashMapAttr (_doc, _node); } }
- public virtual Gee.BidirList<GXml.Node> children { owned get { return new GListChildren (_doc, _node); } }
+ public virtual Gee.BidirList<GXml.Node> children_nodes { owned get { return new GListChildren (_doc,
_node); } }
public virtual Gee.List<GXml.Namespace> namespaces { owned get { return new GListNamespaces (_doc, _node);
} }
public virtual GXml.Document document { get { return _doc; } }
public virtual GXml.Node parent {
@@ -105,6 +105,7 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
return null;
}
// DomNode Implementation
+ public DomNode.NodeType node_type { get { return (DomNode.NodeType) type_node; } } // FIXME:
public string node_name { owned get { return name; } }
protected string _base_uri = null;
@@ -118,9 +119,9 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
return null;
}
}
- public DomNodeList child_nodes { owned get { return children as DomNodeList; } }
- public DomNode? first_child { owned get { return children.first () as DomNode?; } }
- public DomNode? last_child { owned get { return children.last () as DomNode?; } }
+ public DomNodeList child_nodes { owned get { return children_nodes as DomNodeList; } }
+ public DomNode? first_child { owned get { return children_nodes.first () as DomNode?; } }
+ public DomNode? last_child { owned get { return children_nodes.last () as DomNode?; } }
public DomNode? previous_sibling {
owned get {
if (_node == null) return null;
@@ -144,7 +145,7 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
if (this is GXml.ProcessingInstruction) return this.@value;
if (this is GXml.Comment) return this.@value;
if (this is GXml.Document || this is GXml.Element) {
- foreach (GXml.Node n in children) {
+ foreach (GXml.Node n in children_nodes) {
if (n is GXml.Text) {
if (t == null) t = n.value;
else t += n.value;
@@ -156,19 +157,19 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
set {
if (this is GXml.Document || this is GXml.Element) {
var t = this.document.create_text (value);
- this.document.children.add (t);
+ this.document.children_nodes.add (t);
}
if (!(this is GXml.Text || this is GXml.Comment || this is GXml.ProcessingInstruction)) return;
this.@value = value;
}
}
- public bool has_child_nodes () { return (children.size > 0); }
+ public bool has_child_nodes () { return (children_nodes.size > 0); }
public void normalize () {
GXml.DomText t = null;
int[] r = {};
- for (int i = 0; i < children.size; i++) {
- var n = children.get (i);
+ for (int i = 0; i < children_nodes.size; i++) {
+ var n = children_nodes.get (i);
if (n is GXml.DomText) {
if ((t as GXml.DomText).length == 0) {
r += i;
@@ -183,7 +184,7 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
}
}
foreach (int j in r) {
- children.remove_at (j);
+ children_nodes.remove_at (j);
}
}
@@ -199,13 +200,13 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
public bool is_equal_node (DomNode? node) {
if (!(node is GXml.Node)) return false;
if (node == null) return false;
- if (this.children.size != (node as Node).children.size) 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;
}
- for (int i=0; i < children.size; i++) {
- if (!(children[i] as GXml.DomNode).is_equal_node ((node as GXml.Node?).children[i] as GXml.DomNode?))
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;
}
return true;
}
@@ -279,23 +280,30 @@ public abstract class GXml.GNode : Object, GXml.Node, GXml.DomNode
}
public DomNode insert_before (DomNode node, DomNode? child) {
- int i = children.index_of (child as GXml.Node);
- children.insert (i, (node as GXml.Node));
+ int i = children_nodes.index_of (child as GXml.Node);
+ children_nodes.insert (i, (node as GXml.Node));
return node;
}
public DomNode append_child (DomNode node) {
- children.add ((node as GXml.Node));
+ children_nodes.add ((node as GXml.Node));
return node;
}
public DomNode replace_child (DomNode node, DomNode child) {
- int i = children.index_of ((child as GXml.Node));
- children.remove_at (i);
- children.insert (i, (node as GXml.Node));
+ int i = children_nodes.index_of ((child as GXml.Node));
+ children_nodes.remove_at (i);
+ children_nodes.insert (i, (node as GXml.Node));
return child;
}
public DomNode remove_child (DomNode child) {
- int i = children.index_of ((child as GXml.Node));
- return (DomNode) children.remove_at (i);
+ int i = children_nodes.index_of ((child as GXml.Node));
+ return (DomNode) children_nodes.remove_at (i);
}
+ // DomEventTarget implementation
+ public void add_event_listener (string type, DomEventListener? callback, bool capture = false)
+ { return; } // FIXME:
+ public void remove_event_listener (string type, DomEventListener? callback, bool capture = false)
+ { return; } // FIXME:
+ public bool dispatch_event (DomEvent event)
+ { return false; } // FIXME:
}
diff --git a/gxml/GXmlProcessingInstruction.vala b/gxml/GXmlProcessingInstruction.vala
index b911a95..7356532 100644
--- a/gxml/GXmlProcessingInstruction.vala
+++ b/gxml/GXmlProcessingInstruction.vala
@@ -24,8 +24,8 @@ using Gee;
/**
* Class implemeting {@link GXml.ProcessingInstruction} interface, not tied to libxml-2.0 library.
*/
-public class GXml.GProcessingInstruction : GXml.GNode,
- GXml.ProcessingInstruction, GXml.DomCharacterData,
+public class GXml.GProcessingInstruction : GXml.GCharacterData,
+ GXml.ProcessingInstruction,
GXml.DomProcessingInstruction
{
public GProcessingInstruction (GDocument doc, Xml.Node *node)
@@ -34,19 +34,6 @@ public class GXml.GProcessingInstruction : GXml.GNode,
_doc = doc;
}
// GXml.ProcessingInstruction
- public string GXml.ProcessingInstruction.target { owned get { return name; } }
- public string GXml.ProcessingInstruction.data { owned get { return base.value; } }
- // GXml.DomCharacterData
- public string GXml.DomCharacterData.data {
- get {
- return (this as GXml.ProcessingInstruction).value;
- }
- set {
- (this as GXml.ProcessingInstruction).value = value;
- }
- }
- // GXml.DomProcessingInstruction
- public string GXml.DomProcessingInstruction.target {
- owned get { return (this as GXml.ProcessingInstruction).name; }
- }
+ public string target { owned get { return name; } }
+ public string data { owned get { return base.value; } set { base.value = value; } }
}
diff --git a/gxml/GXmlText.vala b/gxml/GXmlText.vala
index a3bcae4..35701bd 100644
--- a/gxml/GXmlText.vala
+++ b/gxml/GXmlText.vala
@@ -24,7 +24,7 @@ using Gee;
/**
* Class implemeting {@link GXml.Text} interface, not tied to libxml-2.0 library.
*/
-public class GXml.GText : GXml.GNode, GXml.Text, GXml.DomCharacterData, GXml.DomText
+public class GXml.GText : GXml.GCharacterData, GXml.Text, GXml.DomText
{
public GText (GDocument doc, Xml.Node *node)
{
@@ -36,15 +36,26 @@ public class GXml.GText : GXml.GNode, GXml.Text, GXml.DomCharacterData, GXml.Dom
return "#text".dup ();
}
}
- // GXml.Text
- public string str { owned get { return base.value; } }
- // GXml.DomCharacterData
- public string data {
- get {
- return str;
- }
- set {
- str = value;
+ // GXml.DomText
+ public GXml.DomText split_text(ulong offset) throws GLib.Error {
+ if (offset >= data.length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset to split text"));
+ long l = (long) offset;
+ string ns = data[0:l];
+ string nd = data[data.length - l: data.length];
+ var nt = this.owner_document.create_text_node (ns);
+ (this.parent_node.child_nodes as Gee.List<DomNode>).insert (this.parent_node.child_nodes.index_of
(this), nt);
+ return nt;
+ }
+ public string whole_text {
+ owned get {
+ string s = "";
+ if (this.previous_sibling is DomText)
+ s += (this.previous_sibling as DomText).whole_text;
+ s += data;
+ if (this.next_sibling is DomText)
+ s += (this.next_sibling as DomText).whole_text;
+ return s;
}
}
}
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 4a2ac73..3ba7263 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -1,4 +1,7 @@
--include $(top_srcdir)/git.mk
+
+# Library to create
+lib_LTLIBRARIES = libgxml-0.12.la
+
# Empty variable to be added elements later
CLEANFILES=
@@ -7,8 +10,6 @@ AM_VALAFLAGS=
### Library
-# Library to create
-lib_LTLIBRARIES = libgxml-0.10.la
# Vala source code
sources = \
@@ -17,6 +18,7 @@ sources = \
Attribute.vala \
Comment.vala\
CDATA.vala \
+ Character.vala \
Document.vala \
DocumentType.vala \
Element.vala \
@@ -84,10 +86,13 @@ sources = \
GHtml.vala \
GXmlAttribute.vala \
GXmlComment.vala \
+ GXmlCharacter.vala \
+ GXmlChildNode.vala \
GXmlCDATA.vala \
GXmlDocument.vala \
GXmlDomCollections.vala \
GXmlDomEvents.vala \
+ GXmlDomRange.vala \
GXmlElement.vala \
GXmlNamespace.vala \
GXmlNode.vala \
@@ -106,13 +111,32 @@ sources = \
DomMutationObservers.vala \
DomNode.vala \
DomRange.vala \
- DomSets.vala \
- DomTraversal.vala
+ $(NULL)
+
+
+# library flags
+libgxml_0_12_la_VALAFLAGS = \
+ --vapidir=$(VAPIDIR) \
+ $(ERROR_VALAFLAGS) \
+ --library=gxml-0.10 \
+ $(top_srcdir)/vapi/config.vapi \
+ $(top_srcdir)/vapi/xlibxml-1.0.vapi \
+ --vapidir=. \
+ --vapidir=$(top_srcdir)/vapi \
+ --pkg libxml-2.0 \
+ --pkg gee-0.8 \
+ --pkg gobject-2.0 \
+ --pkg gio-2.0 \
+ --includedir gxml \
+ --vapi gxml-0.12.vapi \
+ -H gxml.h \
+ $(NULL)
+
### General Compilation flags
-AM_CPPFLAGS = \
+libgxml_0_12_la_CPPFLAGS = \
-include $(CONFIG_HEADER) \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
@@ -121,19 +145,20 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
$(NULL)
-AM_CFLAGS = \
+libgxml_0_12_la_CFLAGS = \
-g \
$(GLIB_CFLAGS) \
$(LIBXML_CFLAGS) \
$(GIO_CFLAGS) \
$(GEE_CFLAGS) \
$(VALA_CFLAGS) \
+ -I$(top_srcdir) \
$(NULL)
if ENABLE_DEVHELP_DOCS
-AM_VALAFLAGS += \
+libgxml_0_12_la_VALAFLAGS += \
--vapi-comments
endif
@@ -141,33 +166,13 @@ endif
# -Wall # TODO: add this back when we can properly handle more libxml2/vala warnings
if DEBUG
- AM_VALAFLAGS += \
+ libgxml_0_12_la_VALAFLAGS += \
-D DEBUG \
--enable-mem-profiler \
-g
endif
-
-# library flags
-AM_VALAFLAGS += \
- --vapidir=$(VAPIDIR) \
- $(ERROR_VALAFLAGS) \
- --library=gxml-0.10 \
- $(top_srcdir)/vapi/config.vapi \
- $(top_srcdir)/vapi/xlibxml-1.0.vapi \
- --vapidir=. \
- --vapidir=$(top_srcdir)/vapi \
- --pkg libxml-2.0 \
- --pkg gee-0.8 \
- --pkg gobject-2.0 \
- --pkg gio-2.0 \
- --includedir gxml \
- --vapi gxml-0.10.vapi \
- -H gxml.h \
- -C \
- $(NULL)
-
-libgxml_0_10_la_LIBADD = \
+libgxml_0_12_la_LIBADD = \
$(GEE_LIBS) \
$(GIO_LIBS) \
$(GLIB_LIBS) \
@@ -175,52 +180,28 @@ libgxml_0_10_la_LIBADD = \
$(VALA_LIBS) \
$(NULL)
-libgxml_0_10_la_LDFLAGS = \
+libgxml_0_12_la_LDFLAGS = \
-version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)"
-vala-stamp: $(sources)
- @rm -f vala-temp
- @touch vala-temp
- $(VALAC) $(AM_VALAFLAGS) $^
- @mv -f vala-temp $@
-
-$(sources:.vala=.c): vala-stamp
-## Recover from the removal of $@
- @if test -f $@; then :; else \
- trap ’rm -rf vala-lock vala-stamp’ 1 2 13 15; \
- if mkdir vala-lock 2>/dev/null; then \
-## This code is being executed by the first process.
- rm -f vala-stamp; \
- $(MAKE) $(AM_MAKEFLAGS) vala-stamp; \
- rmdir vala-lock; \
- else \
-## This code is being executed by the follower processes.
-## Wait until the first process is done.
- while test -d vala-lock; do sleep 1; done; \
-## Succeed if and only if the first process succeeded.
- test -f vala-stamp; exit $$?; \
- fi; \
- fi
-
-libgxml_0_10_la_SOURCES= \
- $(sources:.vala=.c) \
+libgxml_0_12_la_SOURCES= \
+ $(sources) \
xlibxml.c
# .h header file
-gxml.h: libgxml-0.10.la
+gxml.h: libgxml-0.12.la
gxmldir= $(includedir)/gxml-$(API_VERSION)/gxml
gxml_HEADERS = gxml.h xlibxml.h
# .vapi Vala API file
-gxml-0.10.vapi: libgxml-0.10.la
+gxml-0.12.vapi: libgxml-0.12.la
vapidir = $(VAPIDIR)
dist_vapi_DATA = \
- gxml-0.10.vapi \
- gxml-0.10.deps \
+ gxml-0.12.vapi \
+ gxml-0.12.deps \
$(NULL)
# .pc pkg-config file
-pkgconfig_in = gxml-0.10.pc.in
+pkgconfig_in = gxml-0.12.pc.in
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pkgconfig_in:.in=)
@@ -241,9 +222,9 @@ if HAVE_INTROSPECTION
# Extract our dlname like libfolks does, see bgo#658002 and bgo#585116
# This is what g-ir-scanner does.
libgxml_dlname=\
- `$(SED) -nE "s/^dlname='([A-Za-z0-9.+-]+)'/\1/p" libgxml-0.10.la`
+ `$(SED) -nE "s/^dlname='([A-Za-z0-9.+-]+)'/\1/p" libgxml-0.12.la`
#libgxml_dlname=\
-# `$(GREP) -e dlname libgxml-0.10.la | $(SED) s/dlname=\'// | $(SED) s/\'//`
+# `$(GREP) -e dlname libgxml-0.12.la | $(SED) s/dlname=\'// | $(SED) s/\'//`
AM_VALAFLAGS += \
--gir=GXml-$(API_VERSION).gir
@@ -251,15 +232,15 @@ AM_VALAFLAGS += \
INTROSPECTION_GIRS = GXml-$(API_VERSION).gir
INTROSPECTION_COMPILER_ARGS = --includedir=. -l $(libgxml_dlname)
-GXml-0.10.gir: libgxml-0.10.la
+GXml-0.12.gir: libgxml-0.12.la
-GXml-0.10.typelib: $(INTROSPECTION_GIRS)
+GXml-0.12.typelib: $(INTROSPECTION_GIRS)
$(INTROSPECTION_COMPILER) $(INTROSPECTION_COMPILER_ARGS) $< -o $@
girdir = $(INTROSPECTION_GIRDIR)
gir_DATA = $(INTROSPECTION_GIRS)
typelibdir = $(INTROSPECTION_TYPELIBDIR)
-typelib_DATA = GXml-0.10.typelib
+typelib_DATA = GXml-0.12.typelib
CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
@@ -268,34 +249,34 @@ if PLATFORM_WIN32
AM_VALAFLAGS += \
--symbols=gxml.symbols
-libgxml_0_10_la_LDFLAGS += -shared -o libgxml-0.10.dll -no-undefined \
+libgxml_0_12_la_LDFLAGS += -shared -o libgxml-0.12.dll -no-undefined \
-out-imlib -export-all-symbols -output-def
-gxml.symbols: libgxml-0.10.la
+gxml.symbols: libgxml-0.12.la
-libgxml-0.10.def: gxml.symbols
+libgxml-0.12.def: gxml.symbols
(echo -e EXPRTS; $(CPP) -P $(DEF_FLAGS) \
- <$^ | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g' \
- | sort) > gxml.def.tmp && mv gxml.def.tmp libgxml-0.10.def
+ | sort) > gxml.def.tmp && mv gxml.def.tmp libgxml-0.12.def
-libgxml-0.10.def: libgxml-0.10.la
+libgxml-0.12.def: libgxml-0.12.la
libgxmldefdir=$(libdir)
-libgxmldef_DATA=libgxml-0.10.def
+libgxmldef_DATA=libgxml-0.12.def
CLEANFILES += \
gxml.symbols \
- libgxml-0.10.def
+ libgxml-0.12.def
BUILT_SOURCES += \
- libgxml-0.10.def
+ libgxml-0.12.def
endif
CLEANFILES += \
- vala-stamp \
$(pkgconfig_DATA) \
namespace-info.vala \
- $(sources:.vala=.c) \
- gxml-0.10.vapi \
+ gxml-0.12.vapi \
gxml.h
+
+-include $(top_srcdir)/git.mk
diff --git a/gxml/Node.vala b/gxml/Node.vala
index 826016a..12a5f23 100644
--- a/gxml/Node.vala
+++ b/gxml/Node.vala
@@ -32,20 +32,12 @@ public interface GXml.Node : Object
*/
public abstract Gee.List<GXml.Namespace> namespaces { owned get; }
/**
- * Collection of {@link GXml.Node} as childs.
+ * Collection of {@link GXml.Node} as children.
*
- * Depend on {@link GXml.Node} type, this childs could of different, like,
+ * Depends on {@link GXml.Node} type, this children could be different, like,
* elements, element's contents or properties.
*/
- [Deprecated (since="0.10.0", replace="children")]
- public virtual Gee.BidirList<GXml.Node> childs { owned get { return children; } }
- /**
- * Collection of {@link GXml.Node} as childs.
- *
- * Depend on {@link GXml.Node} type, this childs could of different, like,
- * elements, element's contents or properties.
- */
- public abstract Gee.BidirList<GXml.Node> children { owned get; }
+ public abstract Gee.BidirList<GXml.Node> children_nodes { owned get; }
/**
* Attributes in this {@link GXml.Node}.
*/
@@ -74,7 +66,7 @@ public interface GXml.Node : Object
* Get first child with given name, or null.
*/
public new virtual GXml.Node? get (string key) {
- foreach (var child in children)
+ foreach (var child in children_nodes)
if (child.name == key)
return child;
return null;
@@ -88,7 +80,7 @@ public interface GXml.Node : Object
{
var list = new GXml.ElementList ();
if (!(this is GXml.Element)) return list;
- foreach (var child in children) {
+ foreach (var child in children_nodes) {
if (child is GXml.Element) {
list.add_all (child.get_elements_by_property_value (property, value));
if (child.attrs == null) continue;
@@ -110,7 +102,7 @@ public interface GXml.Node : Object
{
var list = new GXml.ElementList ();
if (!(this is GXml.Element || this is GXml.Document)) return list;
- foreach (var child in children) {
+ foreach (var child in children_nodes) {
if (child is GXml.Element) {
list.add_all (child.get_elements_by_name (name));
if (name == child.name)
@@ -127,11 +119,12 @@ public interface GXml.Node : Object
{
var list = new GXml.ElementList ();
if (!(this is GXml.Element || this is GXml.Document)) return list;
- foreach (var child in children) {
+ foreach (var child in children_nodes) {
if (child is GXml.Element) {
list.add_all (child.get_elements_by_name (name));
- if (!(child.namespace == null && ns == null)) continue;
- if (name == child.name && child.namespace.uri == ns)
+ if (!(child.namespaces == null && child.namespaces.size != 0
+ && ns == null)) continue;
+ if (name == child.name && child.namespaces.get(0).uri == ns)
list.add ((GXml.Element) child);
}
}
@@ -192,7 +185,7 @@ public interface GXml.Node : Object
#if DEBUG
GLib.message ("Copying source's child nodes to destiny node");
#endif
- foreach (Node c in source.children) {
+ foreach (Node c in source.children_nodes) {
if (c is Element) {
if (c.name == null) continue;
#if DEBUG
@@ -206,7 +199,7 @@ public interface GXml.Node : Object
}
try {
var e = doc.create_element (c.name); // TODO: Namespace
- node.childs.add (e);
+ node.children_nodes.add (e);
copy (doc, e, c, deep);
} catch {}
}
@@ -216,7 +209,7 @@ public interface GXml.Node : Object
continue;
}
var t = doc.create_text (c.value);
- node.children.add (t);
+ node.children_nodes.add (t);
#if DEBUG
GLib.message (@"Copying source's Text node '$(source.name)' to destiny node with text: $(c.value)
: Size= $(node.childs.size)");
GLib.message (@"Added Text: $(node.childs.get (node.childs.size - 1))");
diff --git a/gxml/ProcessingInstruction.vala b/gxml/ProcessingInstruction.vala
index 91c19b0..2efa5bb 100644
--- a/gxml/ProcessingInstruction.vala
+++ b/gxml/ProcessingInstruction.vala
@@ -34,5 +34,5 @@ public interface GXml.ProcessingInstruction : Object, GXml.Node
/**
* The data used by the target, like {{{href="style.xsl" type="text/xml"}}}
*/
- public abstract string data { owned get; }
+ public abstract string data { owned get; set; }
}
diff --git a/gxml/SerializableGeeArrayList.vala b/gxml/SerializableGeeArrayList.vala
index 7ee66ae..169cc3f 100644
--- a/gxml/SerializableGeeArrayList.vala
+++ b/gxml/SerializableGeeArrayList.vala
@@ -64,7 +64,7 @@ public class GXml.SerializableArrayList<G> : Gee.ArrayList<G>, Serializable, Ser
#if DEBUG
GLib.message (@"Deserializing ArrayList on Element: $(_node.name)");
#endif
- foreach (GXml.Node n in _node.children) {
+ foreach (GXml.Node n in _node.children_nodes) {
deserialize_node (n);
}
}
diff --git a/gxml/SerializableGeeDualKeyMap.vala b/gxml/SerializableGeeDualKeyMap.vala
index eee2291..8647212 100644
--- a/gxml/SerializableGeeDualKeyMap.vala
+++ b/gxml/SerializableGeeDualKeyMap.vala
@@ -64,7 +64,7 @@ public class GXml.SerializableDualKeyMap<P,S,V> : Object, Gee.Traversable <V>, S
throw new SerializableError.UNSUPPORTED_TYPE_ERROR (_("%s: Value type '%s' is unsupported"),
this.get_type ().name (), value_type.name ());
}
- foreach (GXml.Node n in _node.children) {
+ foreach (GXml.Node n in _node.children_nodes) {
deserialize_node (n);
}
_deserialized = true;
diff --git a/gxml/SerializableGeeHashMap.vala b/gxml/SerializableGeeHashMap.vala
index 96b94f7..1592e6f 100644
--- a/gxml/SerializableGeeHashMap.vala
+++ b/gxml/SerializableGeeHashMap.vala
@@ -62,7 +62,7 @@ public class GXml.SerializableHashMap<K,V> : Gee.HashMap<K,V>, Serializable, Ser
this.get_type ().name (), value_type.name ());
}
if (_node is Element) {
- foreach (GXml.Node n in _node.children) {
+ foreach (GXml.Node n in _node.children_nodes) {
deserialize_node (n);
}
}
diff --git a/gxml/SerializableGeeTreeMap.vala b/gxml/SerializableGeeTreeMap.vala
index 6289097..e43ace3 100644
--- a/gxml/SerializableGeeTreeMap.vala
+++ b/gxml/SerializableGeeTreeMap.vala
@@ -62,7 +62,7 @@ public class GXml.SerializableTreeMap<K,V> : Gee.TreeMap<K,V>, Serializable, Ser
this.get_type ().name (), value_type.name ());
}
if (_node is Element) {
- foreach (GXml.Node n in _node.children) {
+ foreach (GXml.Node n in _node.children_nodes) {
deserialize_node (n);
}
}
diff --git a/gxml/SerializableObjectModel.vala b/gxml/SerializableObjectModel.vala
index 563b8bb..f1f94a0 100644
--- a/gxml/SerializableObjectModel.vala
+++ b/gxml/SerializableObjectModel.vala
@@ -110,7 +110,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
props += op.get_name ().down ();
}
bool found = false;
- foreach (GXml.Node n in _node.children) {
+ foreach (GXml.Node n in _node.children_nodes) {
if (n is GXml.Text) {
if (serialize_use_xml_node_value ()) continue;
}
@@ -168,7 +168,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
else
doc = node.document;
var element = (Element) doc.create_element (node_name ());
- node.children.add (element);
+ node.children_nodes.add (element);
set_default_namespace (element);
foreach (ParamSpec spec in list_serializable_properties ()) {
serialize_property (element, spec);
@@ -192,14 +192,14 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
#if DEBUG
GLib.message (@"Serialized Unknown Element NODE AS: $(e.to_string ())");
#endif
- element.children.add (e);
+ element.children_nodes.add (e);
}
if (n is Text && !serialize_use_xml_node_value ()) {
if (n.value == "") continue;
var t = doc.create_text (n.value._strip ());
- element.children.add (t);
+ element.children_nodes.add (t);
#if DEBUG
- GLib.message (@"Serialized Unknown Text Node: '$(n.value)' to '$(element.name)' : Size
$(element.children.size.to_string ())");
+ GLib.message (@"Serialized Unknown Text Node: '$(n.value)' to '$(element.name)' : Size
$(element.children_nodes.size.to_string ())");
#endif
}
}
@@ -213,7 +213,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
if (serialized_xml_node_value != null)
txt = serialized_xml_node_value;
var t = doc.create_text (txt);
- element.children.add (t);
+ element.children_nodes.add (t);
#if DEBUG
GLib.message (@"SET TEXT CHILD NODE FOR: $(get_type ().name ()): $(element.name): TEXT NODE '$txt'\n");
#endif
@@ -365,7 +365,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
#if DEBUG
GLib.message (@"Elements Nodes in Node: $(element.name)\n");
#endif
- foreach (Node n in element.children) {
+ foreach (Node n in element.children_nodes) {
#if DEBUG
GLib.message ("Node name is NULL?"+(n.name == null).to_string ());
if (n.name != null)
diff --git a/gxml/TAttribute.vala b/gxml/TAttribute.vala
index fa33812..f333b1a 100644
--- a/gxml/TAttribute.vala
+++ b/gxml/TAttribute.vala
@@ -51,7 +51,7 @@ public class GXml.TAttribute : GXml.TNode, GXml.Attribute
namespaces.add (value);
}
}
- public string prefix {
+ public string? prefix {
owned get {
return @namespace.prefix;
}
diff --git a/gxml/TComment.vala b/gxml/TComment.vala
index cadda77..451cf32 100644
--- a/gxml/TComment.vala
+++ b/gxml/TComment.vala
@@ -42,5 +42,5 @@ public class GXml.TComment : GXml.TNode, GXml.Comment
set { }
}
// GXml.Comment
- public string str { owned get { return _str.dup (); } }
+ public string str { owned get { return _str.dup (); } set { _str = value; }}
}
diff --git a/gxml/TDocument.vala b/gxml/TDocument.vala
index 4ea255d..1c2a59d 100644
--- a/gxml/TDocument.vala
+++ b/gxml/TDocument.vala
@@ -26,7 +26,7 @@ using Xml;
* Class implemeting {@link GXml.Document} interface, not tied to libxml-2.0 library.
*
* This class use {@link Xml.TextWriter} to write down XML documents using
- * its contained {@link GXml.Node} childs or other XML structures.
+ * its contained {@link GXml.Node} children or other XML structures.
*/
public class GXml.TDocument : GXml.TNode, GXml.Document
{
@@ -102,7 +102,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
return _namespaces.ref () as Gee.List<GXml.Namespace>;
}
}
- public override Gee.BidirList<GXml.Node> children {
+ public override Gee.BidirList<GXml.Node> children_nodes {
owned get {
if (_children == null) _children = new Gee.ArrayList<GXml.Node> ();
return _children.ref () as Gee.BidirList<GXml.Node>;
@@ -118,7 +118,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
* you haven't declared a namespace for this document or for its root element,
* and you define one for a child node, this one is added for the first time
* to document's namespaces, then this becomes the default namespace. To avoid
- * this, you should set a namespace for documento or its root, then childs.
+ * this, you should set a namespace for documento or its root, then children.
*
* Default {@link GXml.Namespace} for a document is the first
*/
@@ -140,8 +140,8 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
if (_children == null) _children = new Gee.ArrayList<GXml.Node> ();
if (_root == null) {
int found = 0;
- for (int i = 0; i < children.size; i++) {
- GXml.Node n = children.get (i);
+ for (int i = 0; i < children_nodes.size; i++) {
+ GXml.Node n = children_nodes.get (i);
if (n is GXml.Element) {
found++;
if (found == 1)
@@ -376,9 +376,9 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
}
// Non Elements
#if DEBUG
- GLib.message (@"Starting Element: writting Node '$(node.name)' childs");
+ GLib.message (@"Starting Element: writting Node '$(node.name)' children");
#endif
- foreach (GXml.Node n in node.childs) {
+ foreach (GXml.Node n in node.children_nodes) {
#if DEBUG
GLib.message (@"Child Node is: $(n.get_type ().name ())");
#endif
@@ -544,7 +544,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
tr.close ();
return ReadType.STOP;
}
- node.children.add (n);
+ node.children_nodes.add (n);
#if DEBUG
GLib.message ("ReadNode: next node:"+n.to_string ());
GLib.message ("ReadNode: next node attributes:"+(tr.has_attributes ()).to_string ());
@@ -600,7 +600,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
#if DEBUG
GLib.message ("Setting a NS Attribute: "+prefix+":"+attrname);
#endif
- (n as GXml.Element).set_ns_attr (new TNamespace (n.document, nsuri, prefix), attrname,
attrval);
+ (n as GXml.Element).set_ns_attr (prefix+":"+nsuri, attrname, attrval);
}
} else
(n as GXml.Element).set_attr (attrname, attrval);
@@ -625,7 +625,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
GLib.message ("ReadNode: Text Node : '"+txtval+"'");
#endif
n = node.document.create_text (txtval);
- node.children.add (n);
+ node.children_nodes.add (n);
break;
case Xml.ReaderType.CDATA:
var cdval = tr.value ();
@@ -634,7 +634,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
GLib.message ("ReadNode: CDATA Node : '"+cdval+"'");
#endif
n = node.document.create_cdata (cdval);
- node.children.add (n);
+ node.children_nodes.add (n);
break;
case Xml.ReaderType.ENTITY_REFERENCE:
#if DEBUG
@@ -654,7 +654,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
GLib.message ("ReadNode: PI Node : '"+pit+"' : '"+pival+"'");
#endif
n = node.document.create_pi (pit,pival);
- node.children.add (n);
+ node.children_nodes.add (n);
break;
case Xml.ReaderType.COMMENT:
var commval = tr.value ();
@@ -663,7 +663,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
GLib.message ("ReadNode: Comment Node : '"+commval+"'");
#endif
n = node.document.create_comment (commval);
- node.children.add (n);
+ node.children_nodes.add (n);
break;
case Xml.ReaderType.DOCUMENT:
#if DEBUG
diff --git a/gxml/TElement.vala b/gxml/TElement.vala
index e8e2966..4f90e47 100644
--- a/gxml/TElement.vala
+++ b/gxml/TElement.vala
@@ -51,7 +51,7 @@ public class GXml.TElement : GXml.TNode, GXml.Element
return _attrs.ref () as Gee.Map<string,GXml.Node>;
}
}
- public override Gee.BidirList<GXml.Node> children {
+ public override Gee.BidirList<GXml.Node> children_nodes {
owned get {
if (_children == null) _children = new TChildrenList (this);
return _children.ref () as Gee.BidirList<GXml.Node>;
@@ -80,15 +80,41 @@ public class GXml.TElement : GXml.TNode, GXml.Element
}
return null;
}
- public void set_ns_attr (Namespace ns, string name, string value) {
+ public void set_ns_attr (string ns, string name, string value) {
var att = new TAttribute (document, name, value);
- att.set_namespace (ns.uri, ns.prefix);
+ string prefix = null;
+ string uri = "";
+ if (":" in ns) {
+ string[] s = ns.split (":");
+ prefix = s[0];
+ uri = s[1];
+ } else
+ uri = ns;
+ att.set_namespace (uri, prefix);
att.set_parent (this);
- attrs.set (ns.prefix+":"+name, att);
+ string p = "";
+ if (prefix != null) p = prefix;
+ attrs.set (p+":"+name, att);
}
public void remove_attr (string name) {
if (attrs.has_key (name)) attrs.unset (name);
}
+ public void remove_ns_attr (string name, string uri) { // TODO: Test me!
+ string prefix = "";
+ string nuri = "";
+ if (":" in uri) {
+ string[] s = uri.split(":");
+ prefix = s[0];
+ nuri = uri;
+ } else
+ nuri = uri;
+ foreach (GXml.Node a in attrs.values) {
+ if (a.name == name)
+ if (((Attribute) a).namespace != null)
+ if (((Attribute) a).namespace.uri == nuri)
+ attrs.unset (prefix+":"+a.name);
+ }
+ }
public void normalize () {}
public string content {
owned get {
@@ -103,7 +129,7 @@ public class GXml.TElement : GXml.TNode, GXml.Element
private void calculate_content ()
{
_content = "";
- foreach (GXml.Node n in childs) {
+ foreach (GXml.Node n in children_nodes) {
if (n is Text) {
_content += n.value;
}
@@ -112,16 +138,16 @@ public class GXml.TElement : GXml.TNode, GXml.Element
private void update_content (string? val)
{
// Remove all GXml.Text elements
- for (int i = 0; i < childs.size; i++) {
- var n = childs.get (i);
+ for (int i = 0; i < children_nodes.size; i++) {
+ var n = children_nodes.get (i);
if (n is Text) {
//GLib.message (@"Removing Text at: $i");
- childs.remove_at (i);
+ children_nodes.remove_at (i);
}
}
if (val != null) {
var t = document.create_text (val);
- this.childs.add (t);
+ this.children_nodes.add (t);
}
}
}
diff --git a/gxml/TNode.vala b/gxml/TNode.vala
index 09d488f..65e8133 100644
--- a/gxml/TNode.vala
+++ b/gxml/TNode.vala
@@ -53,7 +53,7 @@ public abstract class GXml.TNode : Object, GXml.Node
}
public virtual string to_string () { return get_type ().name (); }
public virtual Gee.Map<string,GXml.Node> attrs { owned get { return new Gee.HashMap<string,GXml.Node> ();
} }
- public virtual Gee.BidirList<GXml.Node> children { owned get { return new TChildrenList (this); } }
+ public virtual Gee.BidirList<GXml.Node> children_nodes { owned get { return new TChildrenList (this); } }
public virtual GXml.Document document { get { return _doc; } }
public virtual string name { owned get { return _name.dup (); } }
public virtual Gee.List<GXml.Namespace> namespaces { owned get { return new Gee.ArrayList<GXml.Node> (); }
}
diff --git a/gxml/TProcessingInstruction.vala b/gxml/TProcessingInstruction.vala
index cedfdf9..ef40c1d 100644
--- a/gxml/TProcessingInstruction.vala
+++ b/gxml/TProcessingInstruction.vala
@@ -45,5 +45,5 @@ public class GXml.TProcessingInstruction : GXml.TNode, GXml.ProcessingInstructio
}
// GXml.ProcessingInstruction
public string target { owned get { return _target.dup (); } }
- public string data { owned get { return _data.dup (); } }
+ public string data { owned get { return _data.dup (); } set { _data = value; }}
}
diff --git a/gxml/gxml-0.10.pc.in b/gxml/gxml-0.12.pc.in
similarity index 100%
rename from gxml/gxml-0.10.pc.in
rename to gxml/gxml-0.12.pc.in
diff --git a/gxml/libxml-Attr.vala b/gxml/libxml-Attr.vala
index ef2b25c..e9cda6a 100644
--- a/gxml/libxml-Attr.vala
+++ b/gxml/libxml-Attr.vala
@@ -237,7 +237,7 @@ namespace GXml {
return "Attr(%s=\"%s\")".printf (this.name, this.value);
}
// GXml.Attribute
- public string prefix {
+ public string? prefix {
owned get {
if (node == null) return "";
if (node->ns == null) return "";
diff --git a/gxml/libxml-CharacterData.vala b/gxml/libxml-CharacterData.vala
index f7b6829..a77f878 100644
--- a/gxml/libxml-CharacterData.vala
+++ b/gxml/libxml-CharacterData.vala
@@ -169,7 +169,7 @@ namespace GXml {
* @param count The length in characters of the range that will be replaced
* @param new_segment The text that will be added
*/
- public void replace_data (ulong offset, ulong count, string new_segment) {
+ public new void replace_data (ulong offset, ulong count, string new_segment) {
if (! check_index_size ("replace_data", this.data.length, offset, count)) {
return;
}
diff --git a/gxml/libxml-Comment.vala b/gxml/libxml-Comment.vala
index c9a0c32..2882265 100644
--- a/gxml/libxml-Comment.vala
+++ b/gxml/libxml-Comment.vala
@@ -45,6 +45,6 @@ public class GXml.xComment : GXml.xCharacterData, GXml.Comment {
}
}
// GXml.Comment interface
- public string str { owned get { return this.data; } }
+ public string str { owned get { return this.data; } set { this.data = value; } }
}
diff --git a/gxml/libxml-Element.vala b/gxml/libxml-Element.vala
index 0166779..16ef98b 100644
--- a/gxml/libxml-Element.vala
+++ b/gxml/libxml-Element.vala
@@ -436,7 +436,7 @@ namespace GXml {
*
* This property search and contatenade all children {@link GXml.Text}
* in the {@link GXml.Node} and returns them, no mutter were they
- * are in the tree of childs. When setting, this property creates a new
+ * are in the tree of children. When setting, this property creates a new
* {@link GXml.Text} and add it to this {@link GXml.Element}.
*/
public string content {
@@ -452,10 +452,10 @@ namespace GXml {
set {
if (value != null) {
// Remove all GXml.Text elements by just one with given content
- for (int i = 0; i < childs.size; i++) {
- var n = childs.get (i);
+ for (int i = 0; i < children_nodes.size; i++) {
+ var n = children_nodes.get (i);
if (n is Text) {
- childs.remove_at (i);
+ children_nodes.remove_at (i);
}
}
var t = owner_document.create_text_node (value);
@@ -483,15 +483,24 @@ namespace GXml {
if (a == null) return null;
return new xAttr (a, this.owner_document);
}
- public void set_ns_attr (Namespace ns, string name, string uri) {
+ public void set_ns_attr (string ns, string name, string value) {
if (node == null) return;
var attr = this.owner_document.create_attribute (name);
attr.value = value;
this.set_attribute_node (attr);
- attr.set_namespace (ns.uri, ns.prefix);
+ string prefix = null;
+ string uri = "";
+ if (":" in ns) {
+ string[] s = ns.split (":");
+ prefix = s[0];
+ uri = s[1];
+ } else
+ prefix = ns;
+ attr.set_namespace (uri, prefix);
}
public void remove_attr (string name) {
remove_attribute (name);
}
+ public void remove_ns_attr (string name, string uri) { return; }
}
}
diff --git a/gxml/libxml-Node.vala b/gxml/libxml-Node.vala
index a5df45b..7cfa7d0 100644
--- a/gxml/libxml-Node.vala
+++ b/gxml/libxml-Node.vala
@@ -502,7 +502,7 @@ namespace GXml {
// GXml.Node interface implementations
public virtual Gee.List<GXml.Namespace> namespaces { owned get { return
(Gee.List<GXml.Namespace>) namespace_definitions.ref (); } }
- public virtual Gee.BidirList<GXml.Node> children { owned get { return (BidirList<GXml.Node>)
child_nodes.ref (); } }
+ public virtual Gee.BidirList<GXml.Node> children_nodes { owned get { return
(BidirList<GXml.Node>) child_nodes.ref (); } }
public virtual Gee.Map<string,GXml.Node> attrs { owned get { return (Map<string,GXml.Node>)
attributes.ref (); } }
public virtual string name { owned get { return node_name.dup (); } }
public virtual string @value { owned get { return node_value.dup (); } set { node_value =
value; } }
diff --git a/gxml/libxml-ProcessingInstruction.vala b/gxml/libxml-ProcessingInstruction.vala
index 4a80ca6..8048d8a 100644
--- a/gxml/libxml-ProcessingInstruction.vala
+++ b/gxml/libxml-ProcessingInstruction.vala
@@ -63,6 +63,7 @@ namespace GXml {
owned get {
return _data.dup ();
}
+ set { _data = value; }
}
/**
* The target name.
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index 4c638eb..334b44a 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -137,7 +137,7 @@ class DocumentTest : GXmlTest {
assert (d.root.name == "Project");
bool fname, fshordesc, fdescription, fhomepage;
fname = fshordesc = fdescription = fhomepage = false;
- foreach (GXml.Node n in d.root.childs) {
+ foreach (GXml.Node n in d.root.children_nodes) {
if (n.name == "name") fname = true;
if (n.name == "shortdesc") fshordesc = true;
if (n.name == "description") fdescription = true;
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index 43caed0..72eb5a4 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -457,9 +457,9 @@ class ElementTest : GXmlTest {
Test.add_func ("/gxml/element/parent", () => {
var doc = new xDocument.from_string ("<root><child/></root>");
assert (doc.root != null);
- assert (doc.root.children[0] != null);
- assert (doc.root.children[0].parent != null);
- assert (doc.root.children[0].parent.name == "root");
+ assert (doc.root.children_nodes[0] != null);
+ assert (doc.root.children_nodes[0].parent != null);
+ assert (doc.root.children_nodes[0].parent.name == "root");
assert (doc.root.parent == null);
});
}
diff --git a/test/GAttributeTest.vala b/test/GAttributeTest.vala
index bd8fe68..5737d71 100644
--- a/test/GAttributeTest.vala
+++ b/test/GAttributeTest.vala
@@ -28,20 +28,20 @@ class GAttributeTest : GXmlTest {
Test.add_func ("/gxml/gattribute/value", () => {
try {
GDocument doc = new GDocument.from_string ("<Wands
xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\"
wands:shell=\"oak\"/></Wands>");
- GAttribute attr = (GAttribute) doc.root.children[0].attrs.get ("price");
+ GAttribute attr = (GAttribute) doc.root.children_nodes[0].attrs.get ("price");
assert (attr != null);
assert (attr.name == "price");
assert (attr.value == "43.56");
attr.value = "56.1";
- assert (doc.root.children[0].to_string () == "<Wand price=\"56.1\"
wands:core=\"dragon heart cord\" wands:shell=\"oak\"/>");
+ assert (doc.root.children_nodes[0].to_string () == "<Wand price=\"56.1\"
wands:core=\"dragon heart cord\" wands:shell=\"oak\"/>");
// shell property is Namespaced, but no other property exists with same name
then this should work
- GAttribute shell = (GAttribute) doc.root.children[0].attrs.get ("shell");
+ GAttribute shell = (GAttribute) doc.root.children_nodes[0].attrs.get
("shell");
assert (shell != null);
assert (shell.name == "shell");
assert (shell.value == "oak");
shell.value = "Bad!?";
- Test.message (doc.root.children[0].to_string ());
- assert (doc.root.children[0].to_string () == "<Wand price=\"56.1\"
wands:core=\"dragon heart cord\" wands:shell=\"Bad!?\"/>");
+ Test.message (doc.root.children_nodes[0].to_string ());
+ assert (doc.root.children_nodes[0].to_string () == "<Wand price=\"56.1\"
wands:core=\"dragon heart cord\" wands:shell=\"Bad!?\"/>");
} catch (GLib.Error e) {
Test.message ("ERROR: "+e.message);
assert_not_reached ();
@@ -52,7 +52,7 @@ class GAttributeTest : GXmlTest {
GDocument doc = new GDocument.from_string ("<Wands
xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\"
wands:shell=\"oak\"/></Wands>");
assert (doc.root != null);
GXml.GNode root = (GXml.GNode) doc.root;
- GElement node = (GElement)root.children[0];
+ GElement node = (GElement)root.children_nodes[0];
GAttribute core = (GAttribute) node.attrs.get ("core");
assert (core != null);
@@ -84,7 +84,7 @@ class GAttributeTest : GXmlTest {
try {
GDocument doc = new GDocument.from_string ("<Wands
xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\"
wands:shell=\"oak\" shell=\"NoNs\"/></Wands>");
// User namespace prefix to find namespaced attribute
- var nspshell = ((GElement) doc.root.children[0]).get_attr ("wands:shell") as
GAttribute;
+ var nspshell = ((GElement) doc.root.children_nodes[0]).get_attr
("wands:shell") as GAttribute;
assert (nspshell != null);
assert (nspshell.name == "shell");
assert (nspshell.namespace != null);
@@ -92,7 +92,7 @@ class GAttributeTest : GXmlTest {
assert (nspshell.namespace.uri == "http://mom.co.uk/wands");
assert (nspshell.value == "oak");
// User namespace prefix to find namespaced attribute from Node.attrs
- var nspshell2 = doc.root.children[0].attrs.get ("wands:shell") as GAttribute;
+ var nspshell2 = doc.root.children_nodes[0].attrs.get ("wands:shell") as
GAttribute;
assert (nspshell2 != null);
assert (nspshell2.name == "shell");
assert (nspshell2.namespace != null);
@@ -100,13 +100,13 @@ class GAttributeTest : GXmlTest {
assert (nspshell2.namespace.uri == "http://mom.co.uk/wands");
assert (nspshell2.value == "oak");
// User no namespaced attribute
- var shell = ((GElement) doc.root.children[0]).get_attr ("shell") as
GAttribute;
+ var shell = ((GElement) doc.root.children_nodes[0]).get_attr ("shell") as
GAttribute;
assert (shell != null);
assert (shell.name == "shell");
assert (shell.namespace == null);
assert (shell.value == "NoNs");
// User no namespaced from Node.attrs
- var shell2 = doc.root.children[0].attrs.get ("shell") as GAttribute;
+ var shell2 = doc.root.children_nodes[0].attrs.get ("shell") as GAttribute;
assert (shell2 != null);
assert (shell2.name == "shell");
assert (shell2.namespace == null);
@@ -119,9 +119,9 @@ class GAttributeTest : GXmlTest {
Test.add_func ("/gxml/tw-attribute/parent", () => {
var doc = new GDocument ();
var e = doc.create_element ("root");
- doc.children.add (e);
+ doc.children_nodes.add (e);
var c = doc.create_element ("child");
- e.children.add (c);
+ e.children_nodes.add (c);
(e as GXml.Element).set_attr ("attr", "val");
assert (doc.root != null);
assert (doc.root.attrs["attr"] != null);
diff --git a/test/GDocumentTest.vala b/test/GDocumentTest.vala
index 669f640..ede9cb5 100644
--- a/test/GDocumentTest.vala
+++ b/test/GDocumentTest.vala
@@ -30,7 +30,7 @@ class GDocumentTest : GXmlTest {
try {
var d = new GDocument ();
var root = d.create_element ("root");
- d.children.add (root);
+ d.children_nodes.add (root);
assert (d.root != null);
Test.message ("Root name: "+d.root.name);
assert (d.root.name == "root");
@@ -102,7 +102,7 @@ class GDocumentTest : GXmlTest {
assert (d.root.name == "Project");
bool fname, fshordesc, fdescription, fhomepage;
fname = fshordesc = fdescription = fhomepage = false;
- foreach (GXml.Node n in d.root.children) {
+ foreach (GXml.Node n in d.root.children_nodes) {
if (n.name == "name") fname = true;
if (n.name == "shortdesc") fshordesc = true;
if (n.name == "description") fdescription = true;
@@ -145,8 +145,8 @@ class GDocumentTest : GXmlTest {
assert (doc.root != null);
root = doc.root;
assert (root.name == "Fruits");
- assert (root.children.size == 2);
- var n1 = root.children.get (0);
+ assert (root.children_nodes.size == 2);
+ var n1 = root.children_nodes.get (0);
assert (n1 != null);
assert (n1.name == "Apple");
} catch { assert_not_reached (); }
@@ -281,20 +281,20 @@ class GDocumentTest : GXmlTest {
Test.message (d.to_string ());
assert (d.root != null);
assert (d.root.name == "DataTypeTemplates");
- Test.message (d.root.children.size.to_string ());
- assert (d.root.children[0] is GXml.Text);
- assert (d.root.children[1] is GXml.Element);
- assert (d.root.children[2] is GXml.Text);
- assert (d.root.children[2].value == "\n");
- assert (d.root.children.size == 3);
- assert (d.root.children[1].name == "DAType");
- assert (d.root.children[1].children.size == 3);
- assert (d.root.children[1].children[1].name == "BDA");
- assert (d.root.children[1].children[1].children.size == 3);
- assert (d.root.children[1].children[1].children[1].name == "Val");
- assert (d.root.children[1].children[1].children[1].children.size == 1);
- assert (d.root.children[1].children[1].children[1].children[0] is GXml.Text);
- assert (d.root.children[1].children[1].children[1].children[0].value ==
"status_only");
+ Test.message (d.root.children_nodes.size.to_string ());
+ assert (d.root.children_nodes[0] is GXml.Text);
+ assert (d.root.children_nodes[1] is GXml.Element);
+ assert (d.root.children_nodes[2] is GXml.Text);
+ assert (d.root.children_nodes[2].value == "\n");
+ assert (d.root.children_nodes.size == 3);
+ assert (d.root.children_nodes[1].name == "DAType");
+ assert (d.root.children_nodes[1].children_nodes.size == 3);
+ assert (d.root.children_nodes[1].children_nodes[1].name == "BDA");
+ assert (d.root.children_nodes[1].children_nodes[1].children_nodes.size == 3);
+ assert (d.root.children_nodes[1].children_nodes[1].children_nodes[1].name ==
"Val");
+ assert
(d.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes.size == 1);
+ assert
(d.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes[0] is GXml.Text);
+ assert
(d.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes[0].value == "status_only");
} catch (GLib.Error e) { GLib.message ("ERROR: "+e.message); assert_not_reached (); }
});
Test.add_func ("/gxml/gdocument/libxml_to_string", () => {
@@ -317,9 +317,9 @@ class GDocumentTest : GXmlTest {
assert (doc.root.namespaces.size == 1);
assert (doc.root.namespaces[0].prefix == "gxml");
assert (doc.root.namespaces[0].uri == "http://www.gnome.org/GXml");
- assert (doc.root.children != null);
- assert (doc.root.children.size == 1);
- var c = doc.root.children[0];
+ assert (doc.root.children_nodes != null);
+ assert (doc.root.children_nodes.size == 1);
+ var c = doc.root.children_nodes[0];
c.set_namespace ("http://www.gnome.org/GXml2","gxml2");
assert (c.namespaces != null);
assert (c.namespaces.size == 1);
@@ -330,7 +330,7 @@ class GDocumentTest : GXmlTest {
assert (p == null);
Test.message ("ROOT: "+doc.root.to_string ());
assert (doc.root.to_string () == "<root
xmlns:gxml=\"http://www.gnome.org/GXml\"><child xmlns:gxml2=\"http://www.gnome.org/GXml2\"/></root>");
- (c as Element).set_ns_attr (doc.root.namespaces[0], "prop", "Ten");
+ (c as Element).set_ns_attr
(doc.root.namespaces[0].prefix+":"+doc.root.namespaces[0].uri, "prop", "Ten");
Test.message ("ROOT: "+doc.root.to_string ());
assert (c.attrs.size == 1);
var pt = c.attrs.get ("prop");
diff --git a/test/GElementTest.vala b/test/GElementTest.vala
index 9029cb1..24e4098 100644
--- a/test/GElementTest.vala
+++ b/test/GElementTest.vala
@@ -30,7 +30,7 @@ class GElementTest : GXmlTest {
GXml.GNode root = (GXml.GNode) doc.root;
assert (root != null);
assert (root.name == "Potions");
- GXml.GNode node = (GXml.GNode) root.children[0];
+ GXml.GNode node = (GXml.GNode) root.children_nodes[0];
assert (node != null);
assert (node.name == "Potion");
assert (node.namespaces != null);
@@ -49,7 +49,7 @@ class GElementTest : GXmlTest {
GDocument doc = new GDocument.from_string ("<root />");
assert (doc.root != null);
GElement elem = (GElement) doc.create_element ("alphanumeric");
- doc.root.children.add (elem);
+ doc.root.children_nodes.add (elem);
assert (elem.attrs != null);
assert (elem.attrs.size == 0);
elem.set_attr ("alley", "Diagon");
@@ -83,12 +83,12 @@ class GElementTest : GXmlTest {
var elem = doc.create_element ("country");
var t = doc.create_text ("New Zealand");
assert (t != null);
- elem.children.add (t);
+ elem.children_nodes.add (t);
Test.message ("Elem1:"+elem.to_string ());
assert (elem.to_string () == "<country>New Zealand</country>");
var elem2 = doc.create_element ("messy");
var t2 = doc.create_text ("<<>>");
- elem2.children.add (t2);
+ elem2.children_nodes.add (t2);
Test.message ("Elem2:"+elem2.to_string ());
assert (elem2.to_string () == "<messy>&lt;<>&gt;</messy>");
} catch (GLib.Error e) {
@@ -100,7 +100,7 @@ class GElementTest : GXmlTest {
try {
var doc = new GDocument ();
var root = (GElement) doc.create_element ("root");
- doc.children.add ((GNode) root);
+ doc.children_nodes.add ((GNode) root);
root.content = "TEXT1";
assert (root.to_string () == "<root>TEXT1</root>");
string s = doc.to_string ().split ("\n")[1];
@@ -114,11 +114,11 @@ class GElementTest : GXmlTest {
try {
var doc = new GDocument ();
var root = (GElement) doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
var n = (GElement) doc.create_element ("child");
- root.children.add (n);
+ root.children_nodes.add (n);
var t = doc.create_text ("TEXT1");
- root.children.add (t);
+ root.children_nodes.add (t);
string s = doc.to_string ().split ("\n")[1];
Test.message ("root="+root.to_string ());
assert (s == "<root><child/>TEXT1</root>");
@@ -131,11 +131,11 @@ class GElementTest : GXmlTest {
try {
var doc = new GDocument ();
var root = (GElement) doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
var n = (GElement) doc.create_element ("child");
- root.children.add (n);
+ root.children_nodes.add (n);
var t = (Text) doc.create_text ("TEXT1");
- root.children.add (t);
+ root.children_nodes.add (t);
string s = doc.to_string ().split ("\n")[1];
assert (s == "<root><child/>TEXT1</root>");
} catch (GLib.Error e) {
@@ -148,9 +148,9 @@ class GElementTest : GXmlTest {
assert (doc.root != null);
assert (doc.root.parent is GXml.Node);
assert (doc.root.parent is GXml.Document);
- assert (doc.root.children[0] != null);
- assert (doc.root.children[0].parent != null);
- assert (doc.root.children[0].parent.name == "root");
+ assert (doc.root.children_nodes[0] != null);
+ assert (doc.root.children_nodes[0].parent != null);
+ assert (doc.root.children_nodes[0].parent.name == "root");
});
}
}
diff --git a/test/HtmlDocumentTest.vala b/test/HtmlDocumentTest.vala
index 4c9ff0d..8995899 100644
--- a/test/HtmlDocumentTest.vala
+++ b/test/HtmlDocumentTest.vala
@@ -35,7 +35,7 @@ class HtmlDocumentTest : GXmlTest {
Test.message ("Searching for elemento with id 'user'...");
var n = doc.get_element_by_id ("user");
assert (n != null);
- assert (n.name == "p");
+ assert (n.node_name == "p");
assert (n is GXml.Element);
assert (((GXml.Element) n).content == "");
} catch (GLib.Error e){
@@ -59,9 +59,9 @@ class HtmlDocumentTest : GXmlTest {
assert (l.size == 2);
bool fdiv, fp;
fdiv = fp = false;
- foreach (GXml.Element e in l) {
- if (e.name == "div") fdiv = true;
- if (e.name == "p") fp = true;
+ foreach (GXml.DomElement e in l) {
+ if (e.node_name == "div") fdiv = true;
+ if (e.node_name == "p") fp = true;
}
assert (fdiv);
assert (fp);
diff --git a/test/Makefile.am b/test/Makefile.am
index 39e87e8..e264a77 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -100,7 +100,7 @@ AM_VALAFLAGS = \
--pkg gio-2.0 \
--pkg gee-0.8 \
--pkg posix \
- --pkg gxml-0.10 \
+ --pkg gxml-0.12 \
--pkg libxml-2.0 \
-C \
-g \
@@ -123,7 +123,7 @@ gxml_test_LDADD = \
$(GXML_LIBS) \
$(LIBXML_LIBS) \
$(GIO_LIBS) \
- ../gxml/libgxml-0.10.la
+ ../gxml/libgxml-0.12.la
$(NULL)
gxml_test_LDFLAGS = $(AM_LDFLAGS)
diff --git a/test/SerializableGeeArrayListTest.vala b/test/SerializableGeeArrayListTest.vala
index 479b0dd..c9b7184 100644
--- a/test/SerializableGeeArrayListTest.vala
+++ b/test/SerializableGeeArrayListTest.vala
@@ -123,12 +123,12 @@ class SerializableGeeArrayListTest : GXmlTest
c.add (o2);
var doc = new TDocument ();
var root = doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
c.serialize (root);
- assert (root.children.size == 2);
+ assert (root.children_nodes.size == 2);
bool found1 = false;
bool found2 = false;
- foreach (GXml.Node n in root.children) {
+ foreach (GXml.Node n in root.children_nodes) {
if (n is Element && n.name == "aelement") {
var name = n.attrs.get ("name");
if (name != null) {
@@ -196,7 +196,7 @@ class SerializableGeeArrayListTest : GXmlTest
ic.deserialize (iroot);
var doc = new TDocument ();
var root = doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
ic.serialize (root);
var c = new SerializableArrayList<AElement> ();
c.deserialize (root);
@@ -276,15 +276,15 @@ class SerializableGeeArrayListTest : GXmlTest
bag.serialize (d);
assert (d.root != null);
assert (d.root.name == "BigBag");
- assert (d.root.children.size == 2);
- assert (d.root.children[0].name == "SmallBag");
- assert (d.root.children[0].children.size == 2);
- assert (d.root.children[0].children[0].name == "Ball");
- assert (d.root.children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].name == "BallFill");
- assert (d.root.children[0].children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].children[0] is Text);
- assert (d.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].name == "SmallBag");
+ assert (d.root.children_nodes[0].children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is Text);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
//GLib.message (d.to_string ());
// Deserialize
var bagt = new BigBag ();
@@ -306,15 +306,15 @@ class SerializableGeeArrayListTest : GXmlTest
//GLib.message ("SECOND:"+d2.to_string ());
assert (d2.root != null);
assert (d2.root.name == "BigBag");
- assert (d2.root.children.size == 2);
- assert (d2.root.children[0].name == "SmallBag");
- assert (d2.root.children[0].children.size == 2);
- assert (d2.root.children[0].children[0].name == "Ball");
- assert (d2.root.children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].name == "BallFill");
- assert (d2.root.children[0].children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].children[0] is GXml.Text);
- assert (d2.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d2.root.children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].name == "SmallBag");
+ assert (d2.root.children_nodes[0].children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is
GXml.Text);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
} catch (GLib.Error e) {
GLib.message ("ERROR: "+e.message);
assert_not_reached ();
diff --git a/test/SerializableGeeCollections-TDocument-Test.vala
b/test/SerializableGeeCollections-TDocument-Test.vala
index 77b29bd..91e4f18 100644
--- a/test/SerializableGeeCollections-TDocument-Test.vala
+++ b/test/SerializableGeeCollections-TDocument-Test.vala
@@ -234,42 +234,42 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
sb.serialize (ndoc);
assert (ndoc.root != null);
assert (ndoc.root.name == "base");
- assert (ndoc.root.children.size == 2);
- var cz = ndoc.root.children.get (0);
+ assert (ndoc.root.children_nodes.size == 2);
+ var cz = ndoc.root.children_nodes.get (0);
assert (cz != null);
assert (cz.name.down () == "chargezone");
assert (cz.attrs.get ("name").value == "A1-1");
- assert (cz.children.size == 2);
+ assert (cz.children_nodes.size == 2);
bool fmactoy = false;
bool fmemphis = false;
- foreach (GXml.Node sh in cz.children) {
+ foreach (GXml.Node sh in cz.children_nodes) {
if (sh.name == "ship" && sh.attrs.get ("manufacturer").value == "MacToy") {
fmactoy = true;
assert (sh.attrs.get ("manufacturer").value == "MacToy");
assert (sh.attrs.get ("model").value == "A1234");
- assert (sh.children.size == 5); // 2 nodes 3 texts (identation)
+ assert (sh.children_nodes.size == 5); // 2 nodes 3 texts (identation)
bool falphac = false;
bool fgalax = false;
- foreach (GXml.Node s in sh.children){
+ foreach (GXml.Node s in sh.children_nodes){
if (s.name == "space" && s.attrs.get ("name").value == "Alpha Centaury") {
falphac = true;
assert (s.attrs.get ("name").value == "Alpha Centaury");
- assert (s.children.size == 2);
+ assert (s.children_nodes.size == 2);
bool fearth = false;
bool fplaton = false;
- foreach (GXml.Node p1 in s.children) {
+ foreach (GXml.Node p1 in s.children_nodes) {
if (p1.name == "planet" && p1.attrs.get ("name").value == "Earth") {
fearth = true;
assert (p1.name == "planet");
assert (p1.attrs.get ("name").value == "Earth");
- assert (p1.children.size == 2);
- var c1 = p1.children.get (0);
+ assert (p1.children_nodes.size == 2);
+ var c1 = p1.children_nodes.get (0);
assert (c1 != null);
assert (c1.name == "citizen");
assert (c1.attrs.get ("ctype").value == "Human");
assert (((Element)c1).content == "1M");
- assert (c1.children.size == 1);
- var c2 = p1.children.get (1);
+ assert (c1.children_nodes.size == 1);
+ var c2 = p1.children_nodes.get (1);
assert (c2 != null);
assert (c2.name == "citizen");
assert (c2.attrs.get ("ctype").value == "Ghost");
@@ -279,7 +279,7 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
fplaton = true;
assert (p1.name == "planet");
assert (p1.attrs.get ("name").value == "Platon");
- assert (p1.children.size == 0);
+ assert (p1.children_nodes.size == 0);
}
}
assert (fearth);
@@ -288,22 +288,22 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
if (s.name == "space" && s.attrs.get ("name").value == "Galax") {
fgalax = true;
assert (s.attrs.get ("name").value == "Galax");
- assert (s.children.size == 2);
+ assert (s.children_nodes.size == 2);
bool fsaminon = false;
- foreach (GXml.Node p in s.children) {
+ foreach (GXml.Node p in s.children_nodes) {
if (p.name == "planet" && p.attrs.get ("name").value == "Saminon") {
fsaminon = true;
- var h = p.children.get (0);
+ var h = p.children_nodes.get (0);
assert (h != null);
assert (h.name == "citizen");
assert (h.attrs.get ("ctype").value == "Humanes");
- assert (h.children.size == 1);
+ assert (h.children_nodes.size == 1);
assert (((Element) h).content == "100M");
- var j = p.children.get (1);
+ var j = p.children_nodes.get (1);
assert (j != null);
assert (j.name == "citizen");
assert (j.attrs.get ("ctype").value == "Jeties");
- assert (j.children.size == 1);
+ assert (j.children_nodes.size == 1);
assert (((Element) j).content == "1000M");
}
}
@@ -317,26 +317,26 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
assert (sh.name == "ship");
assert (sh.attrs.get ("manufacturer").value == "Memphis");
assert (sh.attrs.get ("model").value == "AB1");
- assert (sh.children.size == 3); // 1 node 3 texts (identation)
+ assert (sh.children_nodes.size == 3); // 1 node 3 texts (identation)
bool fbetac = false;
- foreach (GXml.Node s in sh.children){
+ foreach (GXml.Node s in sh.children_nodes){
if (s.name == "space" && s.attrs.get ("name").value == "Beta Centaury") {
fbetac = true;
assert (s.attrs.get ("name").value == "Beta Centaury");
- assert (s.children.size == 2);
+ assert (s.children_nodes.size == 2);
bool ftronex = false;
bool fpalax = false;
- foreach (GXml.Node p in s.children) {
+ foreach (GXml.Node p in s.children_nodes) {
if (p.name == "planet" && p.attrs.get ("name").value == "Tronex") {
ftronex = true;
assert (p.name == "planet");
assert (p.attrs.get ("name").value == "Tronex");
- assert (p.children.size == 2);
- var cp = p.children.get (0);
+ assert (p.children_nodes.size == 2);
+ var cp = p.children_nodes.get (0);
assert (cp.name == "citizen");
assert (cp.attrs.get ("ctype").value == "Human");
assert (((Element)cp).content == "10000M");
- var cp2 = p.children.get (1);
+ var cp2 = p.children_nodes.get (1);
assert (cp2.name == "citizen");
assert (cp2.attrs.get ("ctype").value == "Cat");
assert (((Element)cp2).content == "100000M");
@@ -345,7 +345,7 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
fpalax = true;
assert (p.name == "planet");
assert (p.attrs.get ("name").value == "Palax");
- assert (p.children.size == 0);
+ assert (p.children_nodes.size == 0);
}
}
assert (ftronex);
@@ -357,33 +357,33 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
}
assert (fmactoy);
assert (fmemphis);
- var st = ndoc.root.children.get (1);
+ var st = ndoc.root.children_nodes.get (1);
assert (st != null);
assert (st.name.down () == "storage");
assert (st.attrs.get ("name").value == "B4-A4");
- assert (st.children.size == 1);
+ assert (st.children_nodes.size == 1);
bool fr = false;
- foreach (GXml.Node r in st.children) {
+ foreach (GXml.Node r in st.children_nodes) {
if (r.name == "refaction" && r.attrs.get ("manufacturer").value == "MacToy") {
fr = true;
assert (r.name == "refaction");
assert (r.attrs.get ("manufacturer").value == "MacToy");
assert (r.attrs.get ("model").value == "Fly045");
- assert (r.children.size == 5); // 2 nodes 3 texts (identation)
+ assert (r.children_nodes.size == 5); // 2 nodes 3 texts (identation)
bool frmactoy = false;
bool frmega = false;
- foreach (GXml.Node rsh in r.children) {
+ foreach (GXml.Node rsh in r.children_nodes) {
if (rsh.name == "ship" && rsh.attrs.get ("manufacturer").value == "MacToy") {
frmactoy = true;
assert (rsh.attrs.get ("manufacturer").value == "MacToy");
assert (rsh.attrs.get ("model").value == "A1234");
- assert (rsh.children.size == 0);
+ assert (rsh.children_nodes.size == 0);
}
if (rsh.name == "ship" && rsh.attrs.get ("manufacturer").value == "MegaTrench") {
frmega = true;
assert (rsh.attrs.get ("manufacturer").value == "MegaTrench");
assert (rsh.attrs.get ("model").value == "G045-1");
- assert (rsh.children.size == 0);
+ assert (rsh.children_nodes.size == 0);
}
}
assert (frmactoy);
@@ -464,7 +464,7 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
s.serialize (doc);
assert (doc.root.name == "base");
//stdout.printf (@"$doc\n");
- foreach (GXml.Node n in doc.root.children) {
+ foreach (GXml.Node n in doc.root.children_nodes) {
if (n is Element) {
if (n.name == "ChargeZone") {
@@ -473,10 +473,10 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
bool unkfound = false;
bool tfound = false;
bool attrfound = false;
- foreach (GXml.Node sn in n.children) {
+ foreach (GXml.Node sn in n.children_nodes) {
if (sn is Element) {
if (sn.name == "refaction") {
- foreach (GXml.Node rn in sn.children) {
+ foreach (GXml.Node rn in sn.children_nodes) {
if (rn is Element) {
//stdout.printf (@"Refaction current node: '$(rn.name)'\n");
if (rn.name == "ship") {
@@ -488,7 +488,7 @@ class SerializableGeeCollectionsTDocumentTest : GXmlTest
attrfound = true;
assert (shanattr.value == "UNKNOWN ATTR");
}
- foreach (GXml.Node shn in rn.children) {
+ foreach (GXml.Node shn in rn.children_nodes) {
//stdout.printf (@"Refaction: Ship MegaTrench: Node: $(shn.name)\n");
if (shn is Text) {
tfound = true;
diff --git a/test/SerializableGeeCollectionsTest.vala b/test/SerializableGeeCollectionsTest.vala
index 10f7edf..ee508d2 100644
--- a/test/SerializableGeeCollectionsTest.vala
+++ b/test/SerializableGeeCollectionsTest.vala
@@ -421,14 +421,14 @@ class SerializableGeeCollectionsTest : GXmlTest
stdout.printf ("ERROR: Bad ROOT name\n");
assert_not_reached ();
}
- assert (ndoc.root.children.size > 0);
+ assert (ndoc.root.children_nodes.size > 0);
int i = 0;
- foreach (GXml.Node n in ndoc.root.children)
+ foreach (GXml.Node n in ndoc.root.children_nodes)
{
i++;
if (n is Text) { if (n.value != "") assert_not_reached (); }
if (n.name == "ChargeZone") {
- foreach (GXml.Node cn in n.children)
+ foreach (GXml.Node cn in n.children_nodes)
{
if (n is Text) { if (n.value != "") assert_not_reached (); }
@@ -540,7 +540,7 @@ class SerializableGeeCollectionsTest : GXmlTest
assert_not_reached ();
}
//stdout.printf (@"$doc\n");
- foreach (GXml.Node n in doc.root.children) {
+ foreach (GXml.Node n in doc.root.children_nodes) {
if (n is GElement) {
if (n.name == "ChargeZone") {
@@ -549,10 +549,10 @@ class SerializableGeeCollectionsTest : GXmlTest
bool unkfound = false;
bool tfound = false;
bool attrfound = false;
- foreach (GXml.Node sn in n.children) {
+ foreach (GXml.Node sn in n.children_nodes) {
if (sn is GElement) {
if (sn.name == "refaction") {
- foreach (GXml.Node rn in sn.children) {
+ foreach (GXml.Node rn in sn.children_nodes) {
if (rn is GElement) {
//stdout.printf (@"Refaction current node: '$(rn.name)'\n");
if (rn.name == "ship") {
@@ -570,7 +570,7 @@ class SerializableGeeCollectionsTest : GXmlTest
assert_not_reached ();
}
}
- foreach (GXml.Node shn in rn.children) {
+ foreach (GXml.Node shn in rn.children_nodes) {
//stdout.printf (@"Refaction: Ship MegaTrench: Node: $(shn.name)\n");
if (shn is Text) {
tfound = true;
@@ -645,10 +645,10 @@ class SerializableGeeCollectionsTest : GXmlTest
bag.serialize (d);
assert (d.root != null);
assert (d.root.name == "BigBag");
- assert (d.root.children.size == 2);
- assert (d.root.children[0].name == "SmallBag");
- assert (d.root.children[0].children.size == 2);
- assert (d.root.children[0].children[0].name == "Ball");
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].name == "SmallBag");
+ assert (d.root.children_nodes[0].children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes[0].name == "Ball");
// Deserialize
var bag2 = new BigBag ();
bag2.deserialize (d);
@@ -658,10 +658,10 @@ class SerializableGeeCollectionsTest : GXmlTest
bag2.serialize (d2);
assert (d2.root != null);
assert (d2.root.name == "BigBag");
- assert (d2.root.children.size == 2);
- assert (d2.root.children[0].name == "SmallBag");
- assert (d2.root.children[0].children.size == 2);
- assert (d2.root.children[0].children[0].name == "Ball");
+ assert (d2.root.children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].name == "SmallBag");
+ assert (d2.root.children_nodes[0].children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].children_nodes[0].name == "Ball");
} catch (GLib.Error e) {
GLib.message ("ERROR: "+e.message);
assert_not_reached ();
diff --git a/test/SerializableGeeDualKeyMapTest.vala b/test/SerializableGeeDualKeyMapTest.vala
index 5297810..1c4210e 100644
--- a/test/SerializableGeeDualKeyMapTest.vala
+++ b/test/SerializableGeeDualKeyMapTest.vala
@@ -181,16 +181,16 @@ class SerializableGeeDualKeyMapTest : GXmlTest
c.set (o4.owner, o4.name, o4);
var doc = new TDocument ();
var root = doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
c.serialize (root);
- assert (root.children.size == 4);
+ assert (root.children_nodes.size == 4);
bool found1 = false;
bool found2 = false;
bool found3 = false;
bool found4 = false;
int nodes = 0;
int i = 0;
- foreach (GXml.Node n in root.children) {
+ foreach (GXml.Node n in root.children_nodes) {
nodes++;
if (n is Element && n.name == "spaces") {
i++;
@@ -360,15 +360,15 @@ class SerializableGeeDualKeyMapTest : GXmlTest
bag.serialize (d);
assert (d.root != null);
assert (d.root.name == "BigBag");
- assert (d.root.children.size == 2);
- assert (d.root.children[0].name == "SmallBag");
- assert (d.root.children[0].children.size == 2);
- assert (d.root.children[0].children[0].name == "Ball");
- assert (d.root.children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].name == "BallFill");
- assert (d.root.children[0].children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].children[0] is Text);
- assert (d.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].name == "SmallBag");
+ assert (d.root.children_nodes[0].children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is Text);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
//GLib.message (d.to_string ());
// Deserialize
var bagt = new BigBag ();
@@ -398,15 +398,15 @@ class SerializableGeeDualKeyMapTest : GXmlTest
//GLib.message ("SECOND:"+d2.to_string ());
assert (d2.root != null);
assert (d2.root.name == "BigBag");
- assert (d2.root.children.size == 2);
- assert (d2.root.children[0].name == "SmallBag");
- assert (d2.root.children[0].children.size == 2);
- assert (d2.root.children[0].children[0].name == "Ball");
- assert (d2.root.children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].name == "BallFill");
- assert (d2.root.children[0].children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].children[0] is GXml.Text);
- assert (d2.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d2.root.children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].name == "SmallBag");
+ assert (d2.root.children_nodes[0].children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is
GXml.Text);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
} catch (GLib.Error e) {
GLib.message ("ERROR: "+e.message);
assert_not_reached ();
diff --git a/test/SerializableGeeHashMapTest.vala b/test/SerializableGeeHashMapTest.vala
index f741f1f..bb4e783 100644
--- a/test/SerializableGeeHashMapTest.vala
+++ b/test/SerializableGeeHashMapTest.vala
@@ -154,20 +154,20 @@ class SerializableGeeHashMapTest : GXmlTest
c.set (o2.name, o2);
var doc = new TDocument ();
var root = doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
c.serialize (root);
- assert (root.children.size > 0);
+ assert (root.children_nodes.size > 0);
bool found1 = false;
bool found2 = false;
- foreach (GXml.Node n in root.children) {
+ foreach (GXml.Node n in root.children_nodes) {
if (n is Element && n.name == "space") {
var name = n.attrs.get ("name");
if (name != null) {
if (name.value == "Big") found1 = true;
if (name.value == "Small") found2 = true;
}
- if (n.children.size > 0) {
- foreach (GXml.Node nd in n.children) {
+ if (n.children_nodes.size > 0) {
+ foreach (GXml.Node nd in n.children_nodes) {
if (nd is Text) {
if (nd.value != "FAKE TEXT") {
GLib.message (@"ERROR: node content don't much. Expected 'FAKE TEXT', got:
$(nd.value)\n$(doc)\n");
@@ -272,10 +272,10 @@ class SerializableGeeHashMapTest : GXmlTest
assert (doc.root != null);
assert (doc.root.name == "spacecontainer");
var root = doc.root;
- assert (root.children.size > 0);
+ assert (root.children_nodes.size > 0);
bool found1 = false;
bool found2 = false;
- foreach (GXml.Node n in root.children) {
+ foreach (GXml.Node n in root.children_nodes) {
if (n is Element && n.name == "space") {
var name = n.attrs.get ("name");
if (name != null) {
@@ -391,15 +391,15 @@ class SerializableGeeHashMapTest : GXmlTest
bag.serialize (d);
assert (d.root != null);
assert (d.root.name == "BigBag");
- assert (d.root.children.size == 2);
- assert (d.root.children[0].name == "SmallBag");
- assert (d.root.children[0].children.size == 2);
- assert (d.root.children[0].children[0].name == "Ball");
- assert (d.root.children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].name == "BallFill");
- assert (d.root.children[0].children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].children[0] is Text);
- assert (d.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].name == "SmallBag");
+ assert (d.root.children_nodes[0].children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is Text);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
//GLib.message (d.to_string ());
// Deserialize
var bagt = new BigBag ();
@@ -421,15 +421,15 @@ class SerializableGeeHashMapTest : GXmlTest
//GLib.message ("SECOND:"+d2.to_string ());
assert (d2.root != null);
assert (d2.root.name == "BigBag");
- assert (d2.root.children.size == 2);
- assert (d2.root.children[0].name == "SmallBag");
- assert (d2.root.children[0].children.size == 2);
- assert (d2.root.children[0].children[0].name == "Ball");
- assert (d2.root.children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].name == "BallFill");
- assert (d2.root.children[0].children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].children[0] is GXml.Text);
- assert (d2.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d2.root.children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].name == "SmallBag");
+ assert (d2.root.children_nodes[0].children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is
GXml.Text);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
} catch (GLib.Error e) {
GLib.message ("ERROR: "+e.message);
assert_not_reached ();
diff --git a/test/SerializableGeeTreeMapTest.vala b/test/SerializableGeeTreeMapTest.vala
index 4e811d9..c80ba3b 100644
--- a/test/SerializableGeeTreeMapTest.vala
+++ b/test/SerializableGeeTreeMapTest.vala
@@ -141,12 +141,12 @@ class SerializableGeeTreeMapTest : GXmlTest
c.set (o2.name, o2);
var doc = new TDocument ();
var root = doc.create_element ("root");
- doc.children.add (root);
+ doc.children_nodes.add (root);
c.serialize (root);
- assert (root.children.size == 2);
+ assert (root.children_nodes.size == 2);
bool found1 = false;
bool found2 = false;
- foreach (GXml.Node n in root.children) {
+ foreach (GXml.Node n in root.children_nodes) {
if (n is Element && n.name == "space") {
var name = n.attrs.get ("name");
if (name != null) {
@@ -259,10 +259,10 @@ class SerializableGeeTreeMapTest : GXmlTest
assert_not_reached ();
}
var root = doc.root;
- assert (root.children.size == 2);
+ assert (root.children_nodes.size == 2);
bool found1 = false;
bool found2 = false;
- foreach (GXml.Node n in root.children) {
+ foreach (GXml.Node n in root.children_nodes) {
if (n is Element && n.name == "space") {
var name = n.attrs.get ("name");
if (name != null) {
@@ -340,15 +340,15 @@ class SerializableGeeTreeMapTest : GXmlTest
bag.serialize (d);
assert (d.root != null);
assert (d.root.name == "BigBag");
- assert (d.root.children.size == 2);
- assert (d.root.children[0].name == "SmallBag");
- assert (d.root.children[0].children.size == 2);
- assert (d.root.children[0].children[0].name == "Ball");
- assert (d.root.children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].name == "BallFill");
- assert (d.root.children[0].children[0].children[0].children.size == 1);
- assert (d.root.children[0].children[0].children[0].children[0] is Text);
- assert (d.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].name == "SmallBag");
+ assert (d.root.children_nodes[0].children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is Text);
+ assert (d.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
//GLib.message (d.to_string ());
// Deserialize
var bagt = new BigBag ();
@@ -378,15 +378,15 @@ class SerializableGeeTreeMapTest : GXmlTest
//GLib.message ("SECOND:"+d2.to_string ());
assert (d2.root != null);
assert (d2.root.name == "BigBag");
- assert (d2.root.children.size == 2);
- assert (d2.root.children[0].name == "SmallBag");
- assert (d2.root.children[0].children.size == 2);
- assert (d2.root.children[0].children[0].name == "Ball");
- assert (d2.root.children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].name == "BallFill");
- assert (d2.root.children[0].children[0].children[0].children.size == 1);
- assert (d2.root.children[0].children[0].children[0].children[0] is GXml.Text);
- assert (d2.root.children[0].children[0].children[0].children[0].value == "golden dust");
+ assert (d2.root.children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].name == "SmallBag");
+ assert (d2.root.children_nodes[0].children_nodes.size == 2);
+ assert (d2.root.children_nodes[0].children_nodes[0].name == "Ball");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].name == "BallFill");
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes.size == 1);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0] is
GXml.Text);
+ assert (d2.root.children_nodes[0].children_nodes[0].children_nodes[0].children_nodes[0].value ==
"golden dust");
} catch (GLib.Error e) {
GLib.message ("ERROR: "+e.message);
assert_not_reached ();
diff --git a/test/SerializableObjectModel-TDocument-Test.vala
b/test/SerializableObjectModel-TDocument-Test.vala
index a450814..b122307 100644
--- a/test/SerializableObjectModel-TDocument-Test.vala
+++ b/test/SerializableObjectModel-TDocument-Test.vala
@@ -113,7 +113,7 @@ class SerializableObjectModelTDocumentTest : GXmlTest
bool com = false;
bool cus = false;
bool sal = false;
- foreach (GXml.Node n in element.children) {
+ foreach (GXml.Node n in element.children_nodes) {
//stdout.printf (@"Found GElement: $(n.name)");
if (n.name == "tag") {
//stdout.printf (@"Found: $(n.name)");
@@ -302,7 +302,7 @@ class SerializableObjectModelTDocumentTest : GXmlTest
var p = new Package ();
var doc = new TDocument ();
var r = (Element) doc.create_element ("PACKAGE");
- doc.children.add (r);
+ doc.children_nodes.add (r);
r.set_attr ("source", "Mexico/North");
r.set_attr ("destiny", "Brazil");
r.set_attr ("Unknown", "2/4.04");
@@ -324,11 +324,11 @@ class SerializableObjectModelTDocumentTest : GXmlTest
var p = new Package ();
var doc = new TDocument ();
var r = (Element) doc.create_element ("PACKAGE");
- doc.children.add (r);
+ doc.children_nodes.add (r);
r.set_attr ("source", "Mexico/North");
r.set_attr ("destiny", "Brazil");
var c = (Element) doc.create_element ("Unknown");
- r.children.add (c);
+ r.children_nodes.add (c);
c.set_attr ("prop","value");
p.deserialize (doc);
assert (p.unknown_serializable_nodes != null);
diff --git a/test/SerializableObjectModelTest.vala b/test/SerializableObjectModelTest.vala
index dce9d41..eb7691f 100644
--- a/test/SerializableObjectModelTest.vala
+++ b/test/SerializableObjectModelTest.vala
@@ -133,7 +133,7 @@ public class Package : ObjectModel
var str = tags.index (i);
node = (Element) element.document.create_element ("tag");
((Element) node).content = str;
- element.children.add (node);
+ element.children_nodes.add (node);
}
}
});
@@ -546,7 +546,7 @@ class SerializableObjectModelTest : GXmlTest
bool com = false;
bool cus = false;
bool sal = false;
- foreach (GXml.Node n in element.children) {
+ foreach (GXml.Node n in element.children_nodes) {
//stdout.printf (@"Found GElement: $(n.name)");
if (n.name == "tag") {
//stdout.printf (@"Found: $(n.name)");
@@ -805,8 +805,8 @@ class SerializableObjectModelTest : GXmlTest
stdout.printf (@"ERROR: NULL ATTRIBUTE SERIALIZATION: array found $(array.name)");
assert_not_reached ();
}
- if (doc.root.children.size > 0) {
- stdout.printf (@"ERROR: NULL ATTRIBUTE SERIALIZATION: Nodes found
$(doc.root.children.size > 0)");
+ if (doc.root.children_nodes.size > 0) {
+ stdout.printf (@"ERROR: NULL ATTRIBUTE SERIALIZATION: Nodes found
$(doc.root.children_nodes.size > 0)");
assert_not_reached ();
}
}
@@ -822,13 +822,13 @@ class SerializableObjectModelTest : GXmlTest
assert (doc.root != null);
assert (doc.root.name == "UnknownAttribute");
#if DEBUG
- GLib.message ("Document to use:\n"+doc.root.children.size.to_string ());
- foreach (GXml.Node n in doc.root.children) {
+ GLib.message ("Document to use:\n"+doc.root.children_nodes.size.to_string ());
+ foreach (GXml.Node n in doc.root.children_nodes) {
GLib.message ("Node in root: "+ n.name+ " Contents: "+n.value);
}
GLib.message ("Document root children:\n"+doc.to_string ());
#endif
- assert (doc.root.children.size == 2);
+ assert (doc.root.children_nodes.size == 2);
var unknown_property = new UnknownAttribute ();
try {
unknown_property.deserialize (doc);
@@ -884,16 +884,16 @@ class SerializableObjectModelTest : GXmlTest
</UnknownChild>
</UnknownNode>FAKE TEXT</UnknownAttribute>""");
assert (doc.root.name == "UnknownAttribute");
- assert (doc.root.children.size == 3);
- assert (doc.root.children[1].name == "UnknownNode");
- assert (doc.root.children[2].value == "FAKE TEXT");
- assert (doc.root.children[1].children.size == 3);
- assert (doc.root.children[1].children[1].name == "UnknownChild");
- assert (doc.root.children[1].children[1].children.size == 3);
- assert (doc.root.children[1].children[1].children[1].name == "UnknownChildTwo");
- assert (doc.root.children[1].children[1].children[1].children.size == 1);
- assert (doc.root.children[1].children[1].children[1].children[0] is GXml.Text);
- assert (doc.root.children[1].children[1].children[1].children[0].value == "SECOND FAKE
TEXT");
+ assert (doc.root.children_nodes.size == 3);
+ assert (doc.root.children_nodes[1].name == "UnknownNode");
+ assert (doc.root.children_nodes[2].value == "FAKE TEXT");
+ assert (doc.root.children_nodes[1].children_nodes.size == 3);
+ assert (doc.root.children_nodes[1].children_nodes[1].name == "UnknownChild");
+ assert (doc.root.children_nodes[1].children_nodes[1].children_nodes.size == 3);
+ assert (doc.root.children_nodes[1].children_nodes[1].children_nodes[1].name ==
"UnknownChildTwo");
+ assert
(doc.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes.size == 1);
+ assert
(doc.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes[0] is GXml.Text);
+ assert
(doc.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes[0].value == "SECOND FAKE
TEXT");
var unknown_property = new UnknownAttribute ();
try {
unknown_property.deserialize (doc);
@@ -910,16 +910,16 @@ class SerializableObjectModelTest : GXmlTest
#endif
assert (doc2.root != null);
assert (doc.root.name == "UnknownAttribute");
- assert (doc2.root.children.size == 3);
- assert (doc2.root.children[1].name == "UnknownNode");
- assert (doc2.root.children[1].children.size == 3);
- assert (doc2.root.children[2].value == "FAKE TEXT");
- assert (doc2.root.children[1].children[1].name == "UnknownChild");
- assert (doc2.root.children[1].children[1].children[1].name == "UnknownChildTwo");
- assert (doc2.root.children[1].children[1].children.size == 3);
- assert (doc2.root.children[1].children[1].children[1].children.size == 1);
- assert (doc2.root.children[1].children[1].children[1].children[0] is GXml.Text);
- assert (doc2.root.children[1].children[1].children[1].children[0].value == "SECOND
FAKE TEXT");
+ assert (doc2.root.children_nodes.size == 3);
+ assert (doc2.root.children_nodes[1].name == "UnknownNode");
+ assert (doc2.root.children_nodes[1].children_nodes.size == 3);
+ assert (doc2.root.children_nodes[2].value == "FAKE TEXT");
+ assert (doc2.root.children_nodes[1].children_nodes[1].name == "UnknownChild");
+ assert (doc2.root.children_nodes[1].children_nodes[1].children_nodes[1].name ==
"UnknownChildTwo");
+ assert (doc2.root.children_nodes[1].children_nodes[1].children_nodes.size == 3);
+ assert
(doc2.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes.size == 1);
+ assert
(doc2.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes[0] is GXml.Text);
+ assert
(doc2.root.children_nodes[1].children_nodes[1].children_nodes[1].children_nodes[0].value == "SECOND FAKE
TEXT");
}
catch (GLib.Error e) {
stdout.printf (@"Error: $(e.message)");
@@ -935,9 +935,9 @@ class SerializableObjectModelTest : GXmlTest
unknown_property.deserialize (doc);
var ndoc = new GDocument ();
unknown_property.serialize (ndoc);
- if (ndoc.root.children.size != 2) {
- stdout.printf (@"ERROR: Root incorrect child node number: found
'$(doc.root.children.size)\n");
- foreach (GXml.Node rn in ndoc.root.children) {
+ if (ndoc.root.children_nodes.size != 2) {
+ stdout.printf (@"ERROR: Root incorrect child node number: found
'$(doc.root.children_nodes.size)\n");
+ foreach (GXml.Node rn in ndoc.root.children_nodes) {
string nv = "__NULL__";
if (rn.value != null)
nv = rn.value;
@@ -946,7 +946,7 @@ class SerializableObjectModelTest : GXmlTest
stdout.printf (@"$(ndoc)\n");
assert_not_reached ();
}
- foreach (GXml.Node n in ndoc.root.children) {
+ foreach (GXml.Node n in ndoc.root.children_nodes) {
if (n is Text) {
if (n.value != "TEXT") {
stdout.printf (@"ERROR: Unknown Text GElement not set: found '$(n.value)\n");
@@ -1025,7 +1025,7 @@ UNKNOWN CONTENT
assert (pages != null);
assert (int.parse (pages.value) == manual.pages);
bool found = false;
- foreach (GXml.Node n in element.children) {
+ foreach (GXml.Node n in element.children_nodes) {
if (n is GXml.Text)
if (n.value == manual.get_contents ()) found = true;
}
diff --git a/test/TCDATATest.vala b/test/TCDATATest.vala
index ebecf5c..7825656 100644
--- a/test/TCDATATest.vala
+++ b/test/TCDATATest.vala
@@ -28,11 +28,11 @@ class TCDATATest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
var cd = d.create_cdata ("<test/>");
assert (cd.value == "<test/>");
- d.root.children.add (cd);
- assert (d.root.children.size == 1);
+ d.root.children_nodes.add (cd);
+ assert (d.root.children_nodes.size == 1);
string str = d.to_string ();
assert ("<root><![CDATA[<test/>]]></root>" in str);
#if DEBUG
diff --git a/test/TCommentTest.vala b/test/TCommentTest.vala
index 9ddc968..8900578 100644
--- a/test/TCommentTest.vala
+++ b/test/TCommentTest.vala
@@ -28,12 +28,12 @@ class TCommentTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
var c = d.create_comment ("This is a comment");
assert (c.name == "#comment");
assert (c.value == "This is a comment");
- d.root.children.add (c);
- assert (d.root.children.size == 1);
+ d.root.children_nodes.add (c);
+ assert (d.root.children_nodes.size == 1);
string str = d.to_string ();
assert ("<root><!--This is a comment--></root>" in str);
#if DEBUG
diff --git a/test/TDocumentTest.vala b/test/TDocumentTest.vala
index aeea0ac..a1df189 100644
--- a/test/TDocumentTest.vala
+++ b/test/TDocumentTest.vala
@@ -35,9 +35,9 @@ class TDocumentTest : GXmlTest {
var d = new TDocument ();
assert (d.name == "#document");
assert (d.root == null);
- assert (d.children != null);
+ assert (d.children_nodes != null);
assert (d.attrs != null);
- assert (d.children.size == 0);
+ assert (d.children_nodes.size == 0);
assert (d.value == null);
}
catch (GLib.Error e) {
@@ -51,8 +51,8 @@ class TDocumentTest : GXmlTest {
try {
var d = new TDocument ();
var e = d.create_element ("root");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "root");
assert (d.root.value == "");
@@ -70,8 +70,8 @@ class TDocumentTest : GXmlTest {
if (f.query_exists ()) f.delete ();
var d = new TDocument.from_path
(GXmlTestConfig.TEST_SAVE_DIR+"/t-test.xml");
var e = d.create_element ("root");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "root");
assert (d.root.value == "");
@@ -98,8 +98,8 @@ class TDocumentTest : GXmlTest {
if (f.query_exists ()) f.delete ();
var d = new TDocument.from_path
(GXmlTestConfig.TEST_SAVE_DIR+"/t-test.xml");
var e = d.create_element ("root");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "root");
assert (d.root.value == "");
@@ -135,16 +135,16 @@ class TDocumentTest : GXmlTest {
if (f.query_exists ()) f.delete ();
var d = new TDocument.from_path
(GXmlTestConfig.TEST_SAVE_DIR+"/t-test.xml");
var e = d.create_element ("root");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "root");
assert (d.root.value == "");
var root = (GXml.Element) d.root;
root.content = "GXml TDocument Test";
- assert (root.children.size == 1);
+ assert (root.children_nodes.size == 1);
assert (root.content == "GXml TDocument Test");
- var t = root.children.get (0);
+ var t = root.children_nodes.get (0);
assert (t.value == "GXml TDocument Test");
assert (t is GXml.Text);
//GLib.message (@"$d");
@@ -170,21 +170,21 @@ class TDocumentTest : GXmlTest {
if (f.query_exists ()) f.delete ();
var d = new TDocument.from_path
(GXmlTestConfig.TEST_SAVE_DIR+"/t-test.xml");
var e = d.create_element ("root");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "root");
assert (d.root.value == "");
var root = (GXml.Element) d.root;
var e1 = (GXml.Element) d.create_element ("child");
e1.set_attr ("name","Test1");
- assert (e1.children.size == 0);
- root.children.add (e1);
+ assert (e1.children_nodes.size == 0);
+ root.children_nodes.add (e1);
var e2 = (GXml.Element) d.create_element ("child");
e2.set_attr ("name","Test2");
- assert (e2.children.size == 0);
- root.children.add (e2);
- assert (root.children.size == 2);
+ assert (e2.children_nodes.size == 0);
+ root.children_nodes.add (e2);
+ assert (root.children_nodes.size == 2);
d.save ();
var istream = f.read ();
uint8[] buffer = new uint8[2048];
@@ -218,8 +218,8 @@ class TDocumentTest : GXmlTest {
#endif
var d = new TDocument.from_path (GXmlTestConfig.TEST_SAVE_DIR+"/t-large.xml");
var e = d.create_element ("bookstore");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "bookstore");
assert (d.root.value == "");
@@ -230,33 +230,33 @@ class TDocumentTest : GXmlTest {
#endif
for (int i = 0; i < 5000; i++){
var b = (GXml.Element) d.create_element ("book");
- r.children.add (b);
+ r.children_nodes.add (b);
var aths = (GXml.Element) d.create_element ("Authors");
- b.children.add (aths);
+ b.children_nodes.add (aths);
var ath1 = (GXml.Element) d.create_element ("Author");
- aths.children.add (ath1);
+ aths.children_nodes.add (ath1);
var name1 = (GXml.Element) d.create_element ("Name");
name1.content = "Fred";
- ath1.children.add (name1);
+ ath1.children_nodes.add (name1);
var email1 = (GXml.Element) d.create_element ("Email");
email1.content = "fweasley hogwarts co uk";
- ath1.children.add (email1);
+ ath1.children_nodes.add (email1);
var ath2 = (GXml.Element) d.create_element ("Author");
- aths.children.add (ath2);
+ aths.children_nodes.add (ath2);
var name2 = (GXml.Element) d.create_element ("Name");
name2.content = "Greoge";
- ath2.children.add (name2);
+ ath2.children_nodes.add (name2);
var email2 = (GXml.Element) d.create_element ("Email");
email2.content = "gweasley hogwarts co uk";
- ath2.children.add (email2);
+ ath2.children_nodes.add (email2);
}
- assert (d.root.children.size == 5000);
- foreach (GXml.Node n in d.root.children) {
- assert (n.children.size == 1);
- foreach (GXml.Node cn in n.children) {
- assert (cn.children.size == 2);
- foreach (GXml.Node ccn in cn.children) {
- assert (ccn.children.size == 2);
+ assert (d.root.children_nodes.size == 5000);
+ foreach (GXml.Node n in d.root.children_nodes) {
+ assert (n.children_nodes.size == 1);
+ foreach (GXml.Node cn in n.children_nodes) {
+ assert (cn.children_nodes.size == 2);
+ foreach (GXml.Node ccn in cn.children_nodes) {
+ assert (ccn.children_nodes.size == 2);
}
}
}
@@ -281,8 +281,8 @@ class TDocumentTest : GXmlTest {
#endif
var d = new TDocument.from_path (GXmlTestConfig.TEST_SAVE_DIR+"/t-large.xml");
var e = d.create_element ("bookstore");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "bookstore");
assert (d.root.value == "");
@@ -293,27 +293,27 @@ class TDocumentTest : GXmlTest {
#endif
for (int i = 0; i < 30000; i++){
var b = (GXml.Element) d.create_element ("book");
- r.children.add (b);
+ r.children_nodes.add (b);
var aths = (GXml.Element) d.create_element ("Authors");
- b.children.add (aths);
+ b.children_nodes.add (aths);
var ath1 = (GXml.Element) d.create_element ("Author");
- aths.children.add (ath1);
+ aths.children_nodes.add (ath1);
var name1 = (GXml.Element) d.create_element ("Name");
name1.content = "Fred";
- ath1.children.add (name1);
+ ath1.children_nodes.add (name1);
var email1 = (GXml.Element) d.create_element ("Email");
email1.content = "fweasley hogwarts co uk";
- ath1.children.add (email1);
+ ath1.children_nodes.add (email1);
var ath2 = (GXml.Element) d.create_element ("Author");
- aths.children.add (ath2);
+ aths.children_nodes.add (ath2);
var name2 = (GXml.Element) d.create_element ("Name");
name2.content = "Greoge";
- ath2.children.add (name2);
+ ath2.children_nodes.add (name2);
var email2 = (GXml.Element) d.create_element ("Email");
email2.content = "gweasley hogwarts co uk";
- ath2.children.add (email2);
+ ath2.children_nodes.add (email2);
}
- assert (d.root.children.size == 30000);
+ assert (d.root.children_nodes.size == 30000);
d.save ();
GLib.Test.message ("Reading saved file...");
var fr = GLib.File.new_for_path (GXmlTestConfig.TEST_SAVE_DIR+"/t-large.xml");
@@ -345,8 +345,8 @@ class TDocumentTest : GXmlTest {
dt.save_as (f);
var d = new TDocument ();
var e = d.create_element ("root");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root != null);
assert (d.root.name == "root");
assert (d.root.value == "");
@@ -372,7 +372,7 @@ class TDocumentTest : GXmlTest {
Test.add_func ("/gxml/t-document/to_string", () => {
var doc = new TDocument ();
var r = doc.create_element ("root");
- doc.children.add (r);
+ doc.children_nodes.add (r);
#if DEBUG
GLib.message (@"$(doc)");
#endif
@@ -384,7 +384,7 @@ class TDocumentTest : GXmlTest {
Test.add_func ("/gxml/t-document/namespace", () => {
try {
var doc = new TDocument ();
- doc.children.add (doc.create_element ("root"));
+ doc.children_nodes.add (doc.create_element ("root"));
doc.set_namespace ("http://www.gnome.org/GXml","gxml");
Test.message ("ROOT: "+doc.to_string ());
assert (doc.root != null);
@@ -392,10 +392,10 @@ class TDocumentTest : GXmlTest {
assert (doc.namespaces.size == 1);
assert (doc.namespaces[0].prefix == "gxml");
assert (doc.namespaces[0].uri == "http://www.gnome.org/GXml");
- doc.root.children.add (doc.create_element ("child"));
- assert (doc.root.children != null);
- assert (doc.root.children.size == 1);
- var c = doc.root.children[0];
+ doc.root.children_nodes.add (doc.create_element ("child"));
+ assert (doc.root.children_nodes != null);
+ assert (doc.root.children_nodes.size == 1);
+ var c = doc.root.children_nodes[0];
c.set_namespace ("http://www.gnome.org/GXml2","gxml2");
assert (c.namespaces != null);
assert (c.namespaces.size == 1);
@@ -408,7 +408,7 @@ class TDocumentTest : GXmlTest {
string[] str = doc.to_string ().split("\n");
assert (str[1] == "<root
xmlns:gxml=\"http://www.gnome.org/GXml\"><gxml2:child xmlns:gxml2=\"http://www.gnome.org/GXml2\"/></root>");
assert (doc.namespaces[0].prefix == "gxml");
- (c as Element).set_ns_attr (doc.namespaces[0], "prop", "Ten");
+ (c as Element).set_ns_attr
(doc.namespaces[0].prefix+":"+doc.namespaces[0].uri, "prop", "Ten");
Test.message ("ROOT: "+doc.root.to_string ());
assert (c.attrs.size == 1);
var pt = c.attrs.get ("gxml:prop");
@@ -436,26 +436,26 @@ class TDocumentTest : GXmlTest {
assert (d.root.name == "Sentences");
assert (d.root.attrs["audience"] != null);
assert (d.root.attrs["audience"].value == "All");
- assert (d.root.children.size == 7);
- var s1 = d.root.children[0];
+ assert (d.root.children_nodes.size == 7);
+ var s1 = d.root.children_nodes[0];
assert (s1 != null);
assert (s1.name == "Sentence");
var p1 = s1.attrs["lang"];
assert (p1 != null);
assert (p1.value == "en");
- assert (s1.children.size == 1);
- assert (s1.children[0] is GXml.Text);
- assert (s1.children[0].value == "I like the colour blue.");
- var s2 = d.root.children[1];
+ assert (s1.children_nodes.size == 1);
+ assert (s1.children_nodes[0] is GXml.Text);
+ assert (s1.children_nodes[0].value == "I like the colour blue.");
+ var s2 = d.root.children_nodes[1];
assert (s2 != null);
assert (s2.name == "Sentence");
var p2 = s2.attrs["lang"];
assert (p2 != null);
assert (p2.value == "es");
- assert (s2.children.size == 1);
- assert (s2.children[0] is GXml.Text);
- assert (s2.children[0].value == "Español");
- var s3 = d.root.children[2];
+ assert (s2.children_nodes.size == 1);
+ assert (s2.children_nodes[0] is GXml.Text);
+ assert (s2.children_nodes[0].value == "Español");
+ var s3 = d.root.children_nodes[2];
assert (s3 != null);
assert (s3.name == "Authors");
var p3 = s3.attrs["year"];
@@ -464,33 +464,33 @@ class TDocumentTest : GXmlTest {
var p31 = s3.attrs["collection"];
assert (p31 != null);
assert (p31.value == "Back");
- assert (s3.children.size == 2);
- assert (s3.children[0] is GXml.Element);
- assert (s3.children[0].name == "Author");
- assert (s3.children[1].name == "Author");
- var a1 = s3.children[0];
+ assert (s3.children_nodes.size == 2);
+ assert (s3.children_nodes[0] is GXml.Element);
+ assert (s3.children_nodes[0].name == "Author");
+ assert (s3.children_nodes[1].name == "Author");
+ var a1 = s3.children_nodes[0];
assert (a1 != null);
assert (a1.name == "Author");
- assert (a1.children.size == 2);
- assert (a1.children[0].name == "Name");
- assert (a1.children[0].children.size == 1);
- assert (a1.children[0].children[0] is GXml.Text);
- assert (a1.children[0].children[0].value == "Fred");
- assert (a1.children[1].name == "Email");
- assert (a1.children[1].children.size == 1);
- assert (a1.children[1].children[0] is GXml.Text);
- assert (a1.children[1].children[0].value == "fweasley hogwarts co uk");
- var a2 = s3.children[1];
+ assert (a1.children_nodes.size == 2);
+ assert (a1.children_nodes[0].name == "Name");
+ assert (a1.children_nodes[0].children_nodes.size == 1);
+ assert (a1.children_nodes[0].children_nodes[0] is GXml.Text);
+ assert (a1.children_nodes[0].children_nodes[0].value == "Fred");
+ assert (a1.children_nodes[1].name == "Email");
+ assert (a1.children_nodes[1].children_nodes.size == 1);
+ assert (a1.children_nodes[1].children_nodes[0] is GXml.Text);
+ assert (a1.children_nodes[1].children_nodes[0].value == "fweasley hogwarts co
uk");
+ var a2 = s3.children_nodes[1];
assert (a2 != null);
- assert (a2.children.size == 3);
- assert (a2.children[1].name == "Name");
- assert (a2.children[1].children.size == 1);
- assert (a2.children[1].children[0] is GXml.Text);
- assert (a2.children[1].children[0].value == "George");
- assert (a2.children[2].name == "Email");
- assert (a2.children[2].children.size == 1);
- assert (a2.children[2].children[0] is GXml.Text);
- assert (a2.children[2].children[0].value == "gweasley hogwarts co uk");
+ assert (a2.children_nodes.size == 3);
+ assert (a2.children_nodes[1].name == "Name");
+ assert (a2.children_nodes[1].children_nodes.size == 1);
+ assert (a2.children_nodes[1].children_nodes[0] is GXml.Text);
+ assert (a2.children_nodes[1].children_nodes[0].value == "George");
+ assert (a2.children_nodes[2].name == "Email");
+ assert (a2.children_nodes[2].children_nodes.size == 1);
+ assert (a2.children_nodes[2].children_nodes[0] is GXml.Text);
+ assert (a2.children_nodes[2].children_nodes[0].value == "gweasley hogwarts co
uk");
} catch (GLib.Error e) { GLib.message ("ERROR: "+e.message); assert_not_reached (); }
});
Test.add_func ("/gxml/t-document/read/namespace", () => {
@@ -506,23 +506,23 @@ class TDocumentTest : GXmlTest {
assert (d.root.namespaces[0].uri == "http://wiki.gnome.org/GXml");
assert (d.root.namespaces[1].prefix == "b");
assert (d.root.namespaces[1].uri == "http://book.org/schema");
- var a = d.root.children[2];
+ var a = d.root.children_nodes[2];
assert (a != null);
assert (a.name == "Authors");
assert (a.namespaces.size == 1);
assert (a.namespaces[0].uri == "http://author.org");
assert (a.namespaces[0].prefix == "auth");
- assert (a.children[0] != null);
- var a1 = a.children[0];
+ assert (a.children_nodes[0] != null);
+ var a1 = a.children_nodes[0];
assert (a1 != null);
assert (a1.name == "Author");
- var e = a1.children[1];
+ var e = a1.children_nodes[1];
assert (e != null);
assert (e.name == "Email");
assert (e.namespaces.size == 1);
assert (e.namespaces[0].prefix == "gxml");
assert (e.namespaces[0].uri == "http://wiki.gnome.org/GXml");
- var b = d.root.children [3];
+ var b = d.root.children_nodes [3];
assert (b != null);
assert (b.name == "Book");
assert (b.namespaces.size == 1);
@@ -541,14 +541,14 @@ class TDocumentTest : GXmlTest {
var f = GLib.File.new_for_path (GXmlTestConfig.TEST_DIR+"/t-read-test.xml");
assert (f.query_exists ());
var d = new TDocument.from_file (f);
- assert (d.children[0] is GXml.Comment);
- assert (d.children[0].value == " Top Level Comment ");
- var a = d.root.children[2];
+ assert (d.children_nodes[0] is GXml.Comment);
+ assert (d.children_nodes[0].value == " Top Level Comment ");
+ var a = d.root.children_nodes[2];
assert (a.name == "Authors");
- var a1 = a.children[1];
+ var a1 = a.children_nodes[1];
assert (a1.name == "Author");
- assert (a1.children[0] is GXml.Comment);
- assert (a1.children[0].value == " Inner comment");
+ assert (a1.children_nodes[0] is GXml.Comment);
+ assert (a1.children_nodes[0].value == " Inner comment");
//GLib.message ("Doc:"+d.to_string ());
} catch (GLib.Error e) { GLib.message ("ERROR: "+e.message); assert_not_reached (); }
});
@@ -558,17 +558,17 @@ class TDocumentTest : GXmlTest {
assert (f.query_exists ());
var d = new TDocument.from_file (f);
TDocument.read_doc (d, f, null);
- assert (d.children[1] is GXml.ProcessingInstruction);
- assert ((d.children[1] as GXml.ProcessingInstruction).target == "target");
- assert (d.children[1].value == "Content in target id=\"something\"");
+ assert (d.children_nodes[1] is GXml.ProcessingInstruction);
+ assert ((d.children_nodes[1] as GXml.ProcessingInstruction).target ==
"target");
+ assert (d.children_nodes[1].value == "Content in target id=\"something\"");
#if DEBUG
- //GLib.message ("Children:"+d.root.children.size.to_string ());
- foreach (GXml.Node n in d.root.children) {
+ //GLib.message ("Children:"+d.root.children_nodes.size.to_string ());
+ foreach (GXml.Node n in d.root.children_nodes) {
GLib.message ("Node name:"+n.name);
}
#endif
- assert (d.root.children.size == 7);
- var p = (d.root.children[4]);
+ assert (d.root.children_nodes.size == 7);
+ var p = (d.root.children_nodes[4]);
assert (p != null);
assert (p is GXml.ProcessingInstruction);
assert ((p as GXml.ProcessingInstruction).target == "css");
@@ -582,8 +582,8 @@ class TDocumentTest : GXmlTest {
assert (f.query_exists ());
var d = new TDocument.from_file (f);
TDocument.read_doc (d, f, null);
- assert (d.root.children.size == 7);
- var p = (d.root.children[5]);
+ assert (d.root.children_nodes.size == 7);
+ var p = (d.root.children_nodes[5]);
assert (p != null);
assert (p is GXml.CDATA);
assert ((p as GXml.CDATA).str == "<greeting>Hello, world!</greeting>");
@@ -602,7 +602,7 @@ class TDocumentTest : GXmlTest {
assert (d.root.name == "Project");
bool fname, fshordesc, fdescription, fhomepage;
fname = fshordesc = fdescription = fhomepage = false;
- foreach (GXml.Node n in d.root.children) {
+ foreach (GXml.Node n in d.root.children_nodes) {
if (n.name == "name") fname = true;
if (n.name == "shortdesc") fshordesc = true;
if (n.name == "description") fdescription = true;
@@ -631,26 +631,26 @@ class TDocumentTest : GXmlTest {
assert (d.root.name == "Sentences");
assert (d.root.attrs["audience"] != null);
assert (d.root.attrs["audience"].value == "All");
- assert (d.root.children.size == 7);
- var s1 = d.root.children[0];
+ assert (d.root.children_nodes.size == 7);
+ var s1 = d.root.children_nodes[0];
assert (s1 != null);
assert (s1.name == "Sentence");
var p1 = s1.attrs["lang"];
assert (p1 != null);
assert (p1.value == "en");
- assert (s1.children.size == 1);
- assert (s1.children[0] is GXml.Text);
- assert (s1.children[0].value == "I like the colour blue.");
- var s2 = d.root.children[1];
+ assert (s1.children_nodes.size == 1);
+ assert (s1.children_nodes[0] is GXml.Text);
+ assert (s1.children_nodes[0].value == "I like the colour blue.");
+ var s2 = d.root.children_nodes[1];
assert (s2 != null);
assert (s2.name == "Sentence");
var p2 = s2.attrs["lang"];
assert (p2 != null);
assert (p2.value == "es");
- assert (s2.children.size == 1);
- assert (s2.children[0] is GXml.Text);
- assert (s2.children[0].value == "Español");
- var s3 = d.root.children[2];
+ assert (s2.children_nodes.size == 1);
+ assert (s2.children_nodes[0] is GXml.Text);
+ assert (s2.children_nodes[0].value == "Español");
+ var s3 = d.root.children_nodes[2];
assert (s3 != null);
assert (s3.name == "Authors");
var p3 = s3.attrs["year"];
@@ -659,33 +659,33 @@ class TDocumentTest : GXmlTest {
var p31 = s3.attrs["collection"];
assert (p31 != null);
assert (p31.value == "Back");
- assert (s3.children.size == 2);
- assert (s3.children[0] is GXml.Element);
- assert (s3.children[0].name == "Author");
- assert (s3.children[1].name == "Author");
- var a1 = s3.children[0];
+ assert (s3.children_nodes.size == 2);
+ assert (s3.children_nodes[0] is GXml.Element);
+ assert (s3.children_nodes[0].name == "Author");
+ assert (s3.children_nodes[1].name == "Author");
+ var a1 = s3.children_nodes[0];
assert (a1 != null);
assert (a1.name == "Author");
- assert (a1.children.size == 2);
- assert (a1.children[0].name == "Name");
- assert (a1.children[0].children.size == 1);
- assert (a1.children[0].children[0] is GXml.Text);
- assert (a1.children[0].children[0].value == "Fred");
- assert (a1.children[1].name == "Email");
- assert (a1.children[1].children.size == 1);
- assert (a1.children[1].children[0] is GXml.Text);
- assert (a1.children[1].children[0].value == "fweasley hogwarts co uk");
- var a2 = s3.children[1];
+ assert (a1.children_nodes.size == 2);
+ assert (a1.children_nodes[0].name == "Name");
+ assert (a1.children_nodes[0].children_nodes.size == 1);
+ assert (a1.children_nodes[0].children_nodes[0] is GXml.Text);
+ assert (a1.children_nodes[0].children_nodes[0].value == "Fred");
+ assert (a1.children_nodes[1].name == "Email");
+ assert (a1.children_nodes[1].children_nodes.size == 1);
+ assert (a1.children_nodes[1].children_nodes[0] is GXml.Text);
+ assert (a1.children_nodes[1].children_nodes[0].value == "fweasley hogwarts co
uk");
+ var a2 = s3.children_nodes[1];
assert (a2 != null);
- assert (a2.children.size == 3);
- assert (a2.children[1].name == "Name");
- assert (a2.children[1].children.size == 1);
- assert (a2.children[1].children[0] is GXml.Text);
- assert (a2.children[1].children[0].value == "George");
- assert (a2.children[2].name == "Email");
- assert (a2.children[2].children.size == 1);
- assert (a2.children[2].children[0] is GXml.Text);
- assert (a2.children[2].children[0].value == "gweasley hogwarts co uk");
+ assert (a2.children_nodes.size == 3);
+ assert (a2.children_nodes[1].name == "Name");
+ assert (a2.children_nodes[1].children_nodes.size == 1);
+ assert (a2.children_nodes[1].children_nodes[0] is GXml.Text);
+ assert (a2.children_nodes[1].children_nodes[0].value == "George");
+ assert (a2.children_nodes[2].name == "Email");
+ assert (a2.children_nodes[2].children_nodes.size == 1);
+ assert (a2.children_nodes[2].children_nodes[0] is GXml.Text);
+ assert (a2.children_nodes[2].children_nodes[0].value == "gweasley hogwarts co
uk");
} catch (GLib.Error e) { GLib.message ("ERROR: "+e.message); assert_not_reached (); }
});
Test.add_func ("/gxml/t-document/read/string", () => {
@@ -695,17 +695,17 @@ class TDocumentTest : GXmlTest {
var d = new TDocument.from_string ("<root><child v=\"1\">TEXT</child><doc
year=\"2016\"><name>COMMUNICATIONS</name></doc></root>");
assert (d.root != null);
assert (d.root.name == "root");
- assert (d.root.children[0] != null);
- assert (d.root.children[0].name == "child");
- assert (d.root.children[0].children[0] is GXml.Text);
- assert (d.root.children[0].children[0].value == "TEXT");
- assert (d.root.children[1] != null);
- assert (d.root.children[1].name == "doc");
- assert (d.root.children[1].attrs["year"].value == "2016");
- assert (d.root.children[1].children[0] != null);
- assert (d.root.children[1].children[0].name == "name");
- assert (d.root.children[1].children[0].children[0] is GXml.Text);
- assert (d.root.children[1].children[0].children[0].value == "COMMUNICATIONS");
+ assert (d.root.children_nodes[0] != null);
+ assert (d.root.children_nodes[0].name == "child");
+ assert (d.root.children_nodes[0].children_nodes[0] is GXml.Text);
+ assert (d.root.children_nodes[0].children_nodes[0].value == "TEXT");
+ assert (d.root.children_nodes[1] != null);
+ assert (d.root.children_nodes[1].name == "doc");
+ assert (d.root.children_nodes[1].attrs["year"].value == "2016");
+ assert (d.root.children_nodes[1].children_nodes[0] != null);
+ assert (d.root.children_nodes[1].children_nodes[0].name == "name");
+ assert (d.root.children_nodes[1].children_nodes[0].children_nodes[0] is
GXml.Text);
+ assert (d.root.children_nodes[1].children_nodes[0].children_nodes[0].value ==
"COMMUNICATIONS");
} catch (GLib.Error e) { GLib.message ("ERROR: "+e.message); assert_not_reached (); }
});
Test.add_func ("/gxml/t-document/read/string/attrs", () => {
@@ -715,20 +715,20 @@ class TDocumentTest : GXmlTest {
var d = new TDocument.from_string ("<root
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><child v=\"1\" xsi:v=\"VType\">TEXT</child><doc
year=\"2016\"><name>COMMUNICATIONS</name></doc></root>");
assert (d.root != null);
assert (d.root.name == "root");
- assert (d.root.children[0] != null);
- assert (d.root.children[0].name == "child");
- GLib.message ("child attri: "+(d.root.children[0].attrs.size).to_string ());
- assert (d.root.children[0].attrs.size == 2);
- assert (d.root.children[0].attrs["v"] != null);
- assert (d.root.children[0].children[0] is GXml.Text);
- assert (d.root.children[0].children[0].value == "TEXT");
- assert (d.root.children[1] != null);
- assert (d.root.children[1].name == "doc");
- assert (d.root.children[1].attrs["year"].value == "2016");
- assert (d.root.children[1].children[0] != null);
- assert (d.root.children[1].children[0].name == "name");
- assert (d.root.children[1].children[0].children[0] is GXml.Text);
- assert (d.root.children[1].children[0].children[0].value == "COMMUNICATIONS");
+ assert (d.root.children_nodes[0] != null);
+ assert (d.root.children_nodes[0].name == "child");
+ GLib.message ("child attri: "+(d.root.children_nodes[0].attrs.size).to_string
());
+ assert (d.root.children_nodes[0].attrs.size == 2);
+ assert (d.root.children_nodes[0].attrs["v"] != null);
+ assert (d.root.children_nodes[0].children_nodes[0] is GXml.Text);
+ assert (d.root.children_nodes[0].children_nodes[0].value == "TEXT");
+ assert (d.root.children_nodes[1] != null);
+ assert (d.root.children_nodes[1].name == "doc");
+ assert (d.root.children_nodes[1].attrs["year"].value == "2016");
+ assert (d.root.children_nodes[1].children_nodes[0] != null);
+ assert (d.root.children_nodes[1].children_nodes[0].name == "name");
+ assert (d.root.children_nodes[1].children_nodes[0].children_nodes[0] is
GXml.Text);
+ assert (d.root.children_nodes[1].children_nodes[0].children_nodes[0].value ==
"COMMUNICATIONS");
} catch (GLib.Error e) { GLib.message ("ERROR: "+e.message); assert_not_reached (); }
});
Test.add_func ("/gxml/t-document/readtype", () => {
@@ -737,15 +737,15 @@ class TDocumentTest : GXmlTest {
assert (file.query_exists ());
var d = new TDocument.from_file (file);
assert (d.root != null);
- assert (d.root.children.size == 7);
- var n = d.root.children[6];
+ assert (d.root.children_nodes.size == 7);
+ var n = d.root.children_nodes[6];
assert (n != null);
assert (n.name == "ReadTop");
- assert (n.children.size == 9);
- var nc = n.children[3];
+ assert (n.children_nodes.size == 9);
+ var nc = n.children_nodes[3];
assert (nc != null);
assert (nc.name == "Read");
- assert (nc.children.size == 2);
+ assert (nc.children_nodes.size == 2);
GLib.message ("from file");
// Remove all unwanted
TDocument.ReadTypeFunc f1 = (node, tr)=>{
@@ -759,16 +759,16 @@ class TDocumentTest : GXmlTest {
var d2 = new TDocument.from_file_with_readtype_func (file, f1);
TDocument.read_doc (d2, file, f1);
assert (d2.root != null);
- assert (d2.root.children.size == 7);
- var n2 = d2.root.children[6];
+ assert (d2.root.children_nodes.size == 7);
+ var n2 = d2.root.children_nodes[6];
assert (n2 != null);
assert (n2.name == "ReadTop");
- assert (n2.children.size == 4);
+ assert (n2.children_nodes.size == 4);
Test.message (@"$d2");
- var nc2 = n2.children[2];
+ var nc2 = n2.children_nodes[2];
assert (nc2 != null);
assert (nc2.name == "Read");
- assert (nc2.children.size == 1);
+ assert (nc2.children_nodes.size == 1);
// Checking ReadType.STOP effect
Test.message ("from path");
TDocument.ReadTypeFunc f2 = (node, tr)=>{
@@ -782,50 +782,50 @@ class TDocumentTest : GXmlTest {
var d3 = new TDocument.from_path_with_readtype_func (file.get_path (), f2);
Test.message (@"$d3");
assert (d3.root != null);
- assert (d3.root.children.size == 7);
- var n3 = d3.root.children[6];
+ assert (d3.root.children_nodes.size == 7);
+ var n3 = d3.root.children_nodes[6];
assert (n3 != null);
assert (n3.name == "ReadTop");
- assert (n3.children.size == 4);
- var nc3 = n3.children[3];
+ assert (n3.children_nodes.size == 4);
+ var nc3 = n3.children_nodes[3];
assert (nc3 != null);
assert (nc3.name == "Read");
- assert (nc3.children.size == 1);
+ assert (nc3.children_nodes.size == 1);
// From URI
GLib.message ("from uri");
var d4 = new TDocument.from_uri_with_readtype_func (file.get_uri (), f2);
Test.message (@"$d3");
assert (d4.root != null);
- assert (d4.root.children.size == 7);
- var n4 = d4.root.children[6];
+ assert (d4.root.children_nodes.size == 7);
+ var n4 = d4.root.children_nodes[6];
assert (n4 != null);
assert (n4.name == "ReadTop");
- assert (n4.children.size == 4);
- var nc4 = n4.children[3];
+ assert (n4.children_nodes.size == 4);
+ var nc4 = n4.children_nodes[3];
assert (nc4 != null);
assert (nc4.name == "Read");
- assert (nc4.children.size == 1);
+ assert (nc4.children_nodes.size == 1);
// From Stream
GLib.message ("from stream");
var file2 = GLib.File.new_for_path
(GXmlTestConfig.TEST_DIR+"/t-read-test.xml");
var d5 = new TDocument.from_stream_with_readtype_func (file2.read (), f1);
assert (d5.root != null);
- assert (d5.root.children.size == 7);
- var n5 = d5.root.children[6];
+ assert (d5.root.children_nodes.size == 7);
+ var n5 = d5.root.children_nodes[6];
assert (n5 != null);
assert (n5.name == "ReadTop");
- assert (n5.children.size == 4);
+ assert (n5.children_nodes.size == 4);
Test.message (@"$d2");
- var nc5 = n5.children[2];
+ var nc5 = n5.children_nodes[2];
assert (nc5 != null);
assert (nc5.name == "Read");
- assert (nc5.children.size == 1);
+ assert (nc5.children_nodes.size == 1);
// From string
GLib.message ("from string");
var d6 = new TDocument.from_string_with_readtype_func
("<root><Read/><NoRead/><NoRead/><Read/><NoRead/></root>", f1);
assert (d6.root != null);
- assert (d6.root.children.size == 2);
- var n6 = d6.root.children[1];
+ assert (d6.root.children_nodes.size == 2);
+ var n6 = d6.root.children_nodes[1];
assert (n6 != null);
assert (n6.name == "Read");
} catch (GLib.Error e) {
diff --git a/test/TElementTest.vala b/test/TElementTest.vala
index d097fa5..56cb50f 100644
--- a/test/TElementTest.vala
+++ b/test/TElementTest.vala
@@ -30,20 +30,20 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var e = (Element) d.create_element ("element");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root.name == "element");
e.set_attr ("attr1","val1");
assert (d.root.attrs.get ("attr1") != null);
assert (d.root.attrs.get ("attr1").value == "val1");
assert (e.attrs.size == 1);
- assert (e.children.size == 0);
+ assert (e.children_nodes.size == 0);
var child = (Element) d.create_element ("child");
assert (child != null);
- e.children.add (child);
- assert (e.children.size == 1);
+ e.children_nodes.add (child);
+ assert (e.children_nodes.size == 1);
child.set_attr ("cattr1", "cval1");
- var c = (Element) e.children.get (0);
+ var c = (Element) e.children_nodes.get (0);
assert (c != null);
assert (c.name == "child");
assert (c.attrs.get ("cattr1") != null);
@@ -54,9 +54,9 @@ class TElementTest : GXmlTest {
assert (c.content == "");
c.content = "";
assert (c.content == "");
- assert (c.children.size == 1);
+ assert (c.children_nodes.size == 1);
c.content = "HELLO CONTENT";
- assert (c.children.size == 1);
+ assert (c.children_nodes.size == 1);
assert (c.content == "HELLO CONTENT");
} catch { assert_not_reached (); }
});
@@ -64,53 +64,53 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var e = (Element) d.create_element ("element");
- d.children.add (e);
- assert (d.children.size == 1);
+ d.children_nodes.add (e);
+ assert (d.children_nodes.size == 1);
assert (d.root.name == "element");
e.content = "HELLO";
assert (e.content == "HELLO");
- assert (d.root.children.size == 1);
+ assert (d.root.children_nodes.size == 1);
e.content = "TIME";
- assert (d.root.children.size == 1);
+ assert (d.root.children_nodes.size == 1);
assert (e.content == "TIME");
var t = d.create_text (" OTHER");
- e.children.add (t);
- assert (e.children.size == 2);
- assert (d.root.children.size == 2);
+ e.children_nodes.add (t);
+ assert (e.children_nodes.size == 2);
+ assert (d.root.children_nodes.size == 2);
assert (e.content == "TIME OTHER");
- e.children.clear ();
- assert (e.children.size == 0);
+ e.children_nodes.clear ();
+ assert (e.children_nodes.size == 0);
assert (e.content == "");
var c = d.create_element ("child");
- e.children.add (c);
+ e.children_nodes.add (c);
e.content = "KNOW";
- assert (e.children.size == 2);
+ assert (e.children_nodes.size == 2);
assert (e.content == "KNOW");
e.content = "";
- assert (e.children.size == 2);
- e.children.clear ();
+ assert (e.children_nodes.size == 2);
+ e.children_nodes.clear ();
assert (e.content == "");
var t1 = d.create_text ("TEXT1");
var c1 = d.create_element ("child2");
var t2 = d.create_text ("TEXT2");
- e.children.add (t1);
- e.children.add (c1);
- e.children.add (t2);
- assert (e.children.size == 3);
+ e.children_nodes.add (t1);
+ e.children_nodes.add (c1);
+ e.children_nodes.add (t2);
+ assert (e.children_nodes.size == 3);
assert (e.content == "TEXT1TEXT2");
e.content = null;
- assert (e.children.size == 1);
+ assert (e.children_nodes.size == 1);
} catch { assert_not_reached (); }
});
Test.add_func ("/gxml/t-element/namespaces/default", () => {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Set default namespace
d.set_namespace ("http://www.gnome.org/gxml", null);
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
string str = d.to_string ();
#if DEBUG
@@ -123,11 +123,11 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Set default namespace
d.set_namespace ("http://www.gnome.org/gxml", "gxml");
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
string str = d.to_string ();
#if DEBUG
@@ -140,11 +140,11 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Set default namespace
d.set_namespace ("http://www.gnome.org/gxml", null);
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
string str = d.to_string ();
#if DEBUG
@@ -157,12 +157,12 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Set default namespace
d.set_namespace ("http://www.gnome.org/gxml", "gxml");
d.prefix_default_ns = true;
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
string str = d.to_string ();
#if DEBUG
@@ -175,10 +175,10 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
r.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (r.namespaces.size == 1);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
@@ -186,7 +186,7 @@ class TElementTest : GXmlTest {
assert (r.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("nons");
- e.children.add (e2);
+ e.children_nodes.add (e2);
e2.set_namespace ("http://www.gnome.org/", null);
assert (e.namespaces.size == 1);
assert (r.namespaces.size == 1);
@@ -206,29 +206,29 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", null);
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
assert (e.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("children");
- e.children.add (e2);
+ e.children_nodes.add (e2);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (d.namespaces.size == 2);
var e3 = d.create_element ("nons");
- e.children.add (e3);
+ e.children_nodes.add (e3);
e3.set_namespace ("http://www.gnome.org/", "ns");
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
assert (d.namespaces.size == 3);
var e4 = d.create_element ("childrenons");
- e3.children.add (e4);
+ e3.children_nodes.add (e4);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
@@ -252,12 +252,12 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
d.prefix_default_ns = true;
d.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
r.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (r.namespaces.size == 1);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
@@ -265,14 +265,14 @@ class TElementTest : GXmlTest {
assert (r.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("nons");
- e.children.add (e2);
+ e.children_nodes.add (e2);
e2.set_namespace ("http://www.gnome.org/", "ns");
assert (e.namespaces.size == 1);
assert (r.namespaces.size == 1);
assert (e2.namespaces.size == 1);
assert (d.namespaces.size == 3);
var e22 = d.create_element ("nonsd");
- e2.children.add (e22);
+ e2.children_nodes.add (e22);
string str = d.to_string ();
#if DEBUG
GLib.message (@"$d");
@@ -289,29 +289,29 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", null);
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
assert (e.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("children");
- e.children.add (e2);
+ e.children_nodes.add (e2);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (d.namespaces.size == 2);
var e3 = d.create_element ("nons");
- e.children.add (e3);
+ e.children_nodes.add (e3);
e3.set_namespace ("http://www.gnome.org/", "ns");
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
assert (d.namespaces.size == 3);
var e4 = d.create_element ("childrenons");
- e3.children.add (e4);
+ e3.children_nodes.add (e4);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
@@ -335,38 +335,38 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", null);
// All namespaces declaration should be on root node
d.ns_top = true;
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
assert (e.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("children");
- e.children.add (e2);
+ e.children_nodes.add (e2);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (d.namespaces.size == 2);
var e3 = d.create_element ("nons");
- e.children.add (e3);
+ e.children_nodes.add (e3);
e3.set_namespace ("http://www.gnome.org/", "ns");
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
assert (d.namespaces.size == 3);
var e4 = d.create_element ("childrenons");
- e3.children.add (e4);
+ e3.children_nodes.add (e4);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
assert (e4.namespaces.size == 0);
assert (d.namespaces.size == 3);
var c2 = d.create_element ("soup");
- d.root.children.add (c2);
+ d.root.children_nodes.add (c2);
// apply default namespace, should avoid prefix
c2.set_namespace ("http://git.gnome.org/browse/gxml", null);
string str = d.to_string ();
@@ -388,24 +388,24 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", null);
// All namespaces declaration should be on root node
d.ns_top = true;
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
assert (e.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("children");
- e.children.add (e2);
+ e.children_nodes.add (e2);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (d.namespaces.size == 2);
var e3 = d.create_element ("nons");
- e.children.add (e3);
+ e.children_nodes.add (e3);
e3.set_namespace ("http://www.gnome.org/", null);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
@@ -413,14 +413,14 @@ class TElementTest : GXmlTest {
assert (d.namespaces.size == 3);
// This child should use http://www.gnome.org/ namespace by default, no prefix
var e4 = d.create_element ("childrenons");
- e3.children.add (e4);
+ e3.children_nodes.add (e4);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (e3.namespaces.size == 1);
assert (e4.namespaces.size == 0);
assert (d.namespaces.size == 3);
var c2 = d.create_element ("soup");
- d.root.children.add (c2);
+ d.root.children_nodes.add (c2);
// apply default namespace, should avoid prefix
c2.set_namespace ("http://git.gnome.org/browse/gxml", null);
string str = d.to_string ();
@@ -442,23 +442,23 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", null);
d.prefix_default_ns = true;
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
e.set_namespace ("http://developer.gnome.org/", "dg");
assert (e.namespaces.size == 1);
assert (d.namespaces.size == 2);
var e2 = d.create_element ("children");
- e.children.add (e2);
+ e.children_nodes.add (e2);
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
assert (d.namespaces.size == 2);
var e3 = d.create_element ("nons");
- e.children.add (e3);
+ e.children_nodes.add (e3);
e3.set_namespace ("http://www.gnome.org/", "ns");
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
@@ -466,7 +466,7 @@ class TElementTest : GXmlTest {
assert (d.namespaces.size == 3);
// This child should use http://www.gnome.org/ namespace by default, no prefix
var e4 = d.create_element ("childrenons");
- e3.children.add (e4);
+ e3.children_nodes.add (e4);
e4.set_namespace ("http://www.gnome.org/", "ns");
assert (e.namespaces.size == 1);
assert (e2.namespaces.size == 0);
@@ -474,7 +474,7 @@ class TElementTest : GXmlTest {
assert (e4.namespaces.size == 1);
assert (d.namespaces.size == 3);
var c2 = d.create_element ("soup");
- d.root.children.add (c2);
+ d.root.children_nodes.add (c2);
// apply default namespace, should avoid prefix
c2.set_namespace ("http://git.gnome.org/browse/gxml", null);
string str = d.to_string ();
@@ -496,22 +496,22 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
// All namespaces declaration should be on root node
d.prefix_default_ns = true;
var e = d.create_element ("child");
- r.children.add (e);
+ r.children_nodes.add (e);
assert (d.namespaces.size == 1);
var e2 = d.create_element ("children");
- e.children.add (e2);
+ e.children_nodes.add (e2);
var e3 = d.create_element ("nons");
- e.children.add (e3);
+ e.children_nodes.add (e3);
var e4 = d.create_element ("childrenons");
- e3.children.add (e4);
+ e3.children_nodes.add (e4);
var c2 = d.create_element ("soup");
- d.root.children.add (c2);
+ d.root.children_nodes.add (c2);
c2.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
string str = d.to_string ();
#if DEBUG
@@ -532,11 +532,11 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
d.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
var c = (Element) d.create_element ("child");
- r.children.add (c);
+ r.children_nodes.add (c);
c.set_attr ("at","val");
var a = c.get_attr ("at");
assert (a != null);
@@ -559,16 +559,16 @@ class TElementTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
// Default NS
r.set_namespace ("http://git.gnome.org/browse/gxml", "gxml");
var ns = new TNamespace (d, "http://books.net", "book");
r.set_namespace (ns.uri, ns.prefix);
var c = d.create_element ("child") as Element;
- r.children.add (c);
+ r.children_nodes.add (c);
c.set_attr ("source","http://books.net/sources/1");
assert (c.attrs.size == 1);
- c.set_ns_attr (ns, "source", "The History 2");
+ c.set_ns_attr ("book:http://books.net", "source", "The History 2");
assert (c.attrs.size == 2);
var nsa = c.get_ns_attr ("source", "http://books.net");
assert (nsa != null);
@@ -585,26 +585,26 @@ class TElementTest : GXmlTest {
Test.add_func ("/gxml/t-element/parent", () => {
var doc = new TDocument ();
var e = doc.create_element ("root");
- doc.children.add (e);
+ doc.children_nodes.add (e);
var c = doc.create_element ("child");
- e.children.add (c);
- assert (e.children.size == 1);
- assert (e.children[0] != null);
- assert (e.children[0].name == "child");
+ e.children_nodes.add (c);
+ assert (e.children_nodes.size == 1);
+ assert (e.children_nodes[0] != null);
+ assert (e.children_nodes[0].name == "child");
assert (c.parent != null);
assert (doc.root != null);
- assert (doc.root.children[0] != null);
- assert (doc.root.children[0].name == "child");
- assert (doc.root.children[0].parent != null);
- assert (doc.root.children[0].parent.name == "root");
+ assert (doc.root.children_nodes[0] != null);
+ assert (doc.root.children_nodes[0].name == "child");
+ assert (doc.root.children_nodes[0].parent != null);
+ assert (doc.root.children_nodes[0].parent.name == "root");
assert (doc.root.parent == null);
});
Test.add_func ("/gxml/t-element/attribute/parent", () => {
var doc = new TDocument ();
var e = doc.create_element ("root");
- doc.children.add (e);
+ doc.children_nodes.add (e);
var c = doc.create_element ("child");
- e.children.add (c);
+ e.children_nodes.add (c);
(e as GXml.Element).set_attr ("attr", "val");
assert (doc.root != null);
assert (doc.root.attrs["attr"] != null);
@@ -618,15 +618,15 @@ class TElementTest : GXmlTest {
var d = new TDocument ();
TDocument.read_doc (d, file, null);
assert (d.root != null);
- assert (d.root.children.size == 7);
- var n = d.root.children[6];
+ assert (d.root.children_nodes.size == 7);
+ var n = d.root.children_nodes[6];
assert (n != null);
assert (n.name == "ReadTop");
- assert (n.children.size == 9);
- var nc = n.children[3];
+ assert (n.children_nodes.size == 9);
+ var nc = n.children_nodes[3];
assert (nc != null);
assert (nc.name == "Read");
- assert (nc.children.size == 2);
+ assert (nc.children_nodes.size == 2);
// Remove all
Test.message ("Skiping nodes");
TDocument.ReadTypeFunc f1 = (node, tr)=>{
@@ -641,15 +641,15 @@ class TElementTest : GXmlTest {
TDocument.read_doc (d2, file, f1);
GLib.message (@"$d2");
assert (d2.root != null);
- assert (d2.root.children.size == 7);
- var n2 = d2.root.children[6];
+ assert (d2.root.children_nodes.size == 7);
+ var n2 = d2.root.children_nodes[6];
assert (n2 != null);
assert (n2.name == "ReadTop");
- assert (n2.children.size == 4);
- var nc2 = n2.children[2];
+ assert (n2.children_nodes.size == 4);
+ var nc2 = n2.children_nodes[2];
assert (nc2 != null);
assert (nc2.name == "Read");
- assert (nc2.children.size == 1);
+ assert (nc2.children_nodes.size == 1);
// Checking ReadType.STOP effect
Test.message ("Skiping nodes using ReadType.STOP");
//assert_not_reached ();
@@ -665,15 +665,15 @@ class TElementTest : GXmlTest {
TDocument.read_doc (d3, file, f2);
Test.message (@"STOPED:$d3");
assert (d3.root != null);
- assert (d3.root.children.size == 7);
- var n3 = d3.root.children[6];
+ assert (d3.root.children_nodes.size == 7);
+ var n3 = d3.root.children_nodes[6];
assert (n3 != null);
assert (n3.name == "ReadTop");
- assert (n3.children.size == 4);
- var nc3 = n3.children[3];
+ assert (n3.children_nodes.size == 4);
+ var nc3 = n3.children_nodes[3];
assert (nc3 != null);
assert (nc3.name == "Read");
- assert (nc3.children.size == 1);
+ assert (nc3.children_nodes.size == 1);
} catch (GLib.Error e) {
GLib.message ("Error: "+e.message);
assert_not_reached ();
diff --git a/test/TProcessingInstructionTest.vala b/test/TProcessingInstructionTest.vala
index b5cd718..424f33a 100644
--- a/test/TProcessingInstructionTest.vala
+++ b/test/TProcessingInstructionTest.vala
@@ -28,12 +28,12 @@ class TProcessingInstructionTest : GXmlTest {
try {
var d = new TDocument ();
var r = d.create_element ("root");
- d.children.add (r);
+ d.children_nodes.add (r);
var pi = d.create_pi ("xslt","transform");
assert (pi.name == "#processinginstruction");
assert (pi.value == "transform");
- d.root.children.add (pi);
- assert (d.root.children.size == 1);
+ d.root.children_nodes.add (pi);
+ assert (d.root.children_nodes.size == 1);
string str = d.to_string ();
assert ("<root><?xslt transform?></root>" in str);
#if DEBUG
diff --git a/test/gxml-performance.vala b/test/gxml-performance.vala
index 885e622..d0cb94d 100644
--- a/test/gxml-performance.vala
+++ b/test/gxml-performance.vala
@@ -210,8 +210,8 @@ public class Performance
* Iterate recursively through all node and children nodes in document.
*/
public static void iterate (GXml.Node node) {
- foreach (GXml.Node n in node.children) {
- int i = node.children.size;
+ foreach (GXml.Node n in node.children_nodes) {
+ int i = node.children_nodes.size;
string name = n.name;
string val = n.value;
#if DEBUG
@@ -526,9 +526,9 @@ public class Performance
assert (ce.elements2.elements.size == 125000);
ce.serialize (d);
assert (d.root != null);
- assert (d.root.children.size == 2);
- assert (d.root.children[0].children.size == 125000);
- assert (d.root.children[1].children.size == 125000);
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes.size == 125000);
+ assert (d.root.children_nodes[1].children_nodes.size == 125000);
time = Test.timer_elapsed ();
Test.minimized_result (time, "Created document: %g seconds", time);
Test.message ("Starting deserializing document: Disable collection deserialization...");
@@ -774,9 +774,9 @@ public class Performance
ce.serialize (d);
d.save_as (f);
assert (d.root != null);
- assert (d.root.children.size == 2);
- assert (d.root.children[0].children.size == 30000);
- assert (d.root.children[1].children.size == 30000);
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes.size == 30000);
+ assert (d.root.children_nodes[1].children_nodes.size == 30000);
time = Test.timer_elapsed ();
Test.minimized_result (time, "Created document: %g seconds", time);
Test.message ("Starting deserializing document: Disable collection deserialization...");
@@ -836,9 +836,9 @@ public class Performance
ce.serialize (d);
d.save_as (f);
assert (d.root != null);
- assert (d.root.children.size == 2);
- assert (d.root.children[0].children.size == 30000);
- assert (d.root.children[1].children.size == 30000);
+ assert (d.root.children_nodes.size == 2);
+ assert (d.root.children_nodes[0].children_nodes.size == 30000);
+ assert (d.root.children_nodes[1].children_nodes.size == 30000);
time = Test.timer_elapsed ();
Test.minimized_result (time, "Created document: %g seconds", time);
Test.message ("Starting deserializing document: Enable collection deserialization...");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]