[gxml: 6/16] * XNode to DomNode
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml: 6/16] * XNode to DomNode
- Date: Fri, 27 Jul 2012 09:30:32 +0000 (UTC)
commit 41851f32a7262901dacf01258d289d5d7339485b
Author: Richard Schwarting <aquarichy gmail com>
Date: Fri Jul 27 11:03:58 2012 +0200
* XNode to DomNode
gxml/Attr.vala | 18 ++--
gxml/BackedNode.vala | 30 ++--
gxml/Document.vala | 20 ++--
gxml/DocumentType.vala | 2 +-
gxml/{XNode.vala => DomNode.vala} | 32 +++---
gxml/Element.vala | 34 +++---
gxml/Entity.vala | 14 +-
gxml/EntityReference.vala | 2 +-
gxml/Makefile.am | 2 +-
gxml/NamespaceAttr.vala | 2 +-
gxml/NodeList.vala | 202 ++++++++++++++--------------
gxml/Notation.vala | 2 +-
gxml/ProcessingInstruction.vala | 2 +-
gxml/Serializable.vala | 4 +-
gxml/Serialization.vala | 18 ++-
gxml/{libgxml-0.2.pc.in => libgxml.pc.in} | 0
test/AttrTest.vala | 8 +-
test/DocumentTest.vala | 8 +-
test/{XNodeTest.vala => DomNodeTest.vala} | 0
test/ElementTest.vala | 42 +++---
test/GXmlTest.vala | 2 +-
test/Makefile.am | 2 +-
test/TextTest.vala | 2 +-
test/XmlSerializableTest.vala | 14 +-
24 files changed, 232 insertions(+), 230 deletions(-)
---
diff --git a/gxml/Attr.vala b/gxml/Attr.vala
index 3ca7f2b..f400d36 100644
--- a/gxml/Attr.vala
+++ b/gxml/Attr.vala
@@ -20,7 +20,7 @@ namespace GXml {
* represented as strings but can also be subtrees for some
* Nodes. For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-637646024]]
*/
- public class Attr : XNode {
+ public class Attr : DomNode {
/**
* { inheritDoc}
*/
@@ -99,7 +99,7 @@ namespace GXml {
nice to use elem.node->get/set_prop (name[,value]) :S */
get {
this._node_value = "";
- foreach (XNode child in this.child_nodes) {
+ foreach (DomNode child in this.child_nodes) {
this._node_value += child.node_value;
// TODO: verify that Attr node's child types'
// node_values are sufficient for building the Attr's value.
@@ -109,7 +109,7 @@ namespace GXml {
internal set {
try {
// TODO: consider adding an empty () method to NodeList
- foreach (XNode child in this.child_nodes) {
+ foreach (DomNode child in this.child_nodes) {
// TODO: this doesn't clear the actual underlying attributes' values, is this what we want to do? It works if we eventually sync up values
this.remove_child (child);
}
@@ -125,7 +125,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- /* already doc'd in XNode */
+ /* already doc'd in DomNode */
public override NodeList? child_nodes {
owned get {
// TODO: always create a new one?
@@ -187,25 +187,25 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
+ public override DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
return this.child_nodes.insert_before (new_child, ref_child);
}
/**
* { inheritDoc}
*/
- public override XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ public override DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
return this.child_nodes.replace_child (new_child, old_child);
}
/**
* { inheritDoc}
*/
- public override XNode? remove_child (XNode old_child) throws DomError {
+ public override DomNode? remove_child (DomNode old_child) throws DomError {
return this.child_nodes.remove_child (old_child);
}
/**
* { inheritDoc}
*/
- public override XNode? append_child (XNode new_child) throws DomError {
+ public override DomNode? append_child (DomNode new_child) throws DomError {
return this.child_nodes.append_child (new_child);
}
/**
@@ -217,7 +217,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? clone_nodes (bool deep) {
+ public override DomNode? clone_nodes (bool deep) {
return this; // STUB
}
}
diff --git a/gxml/BackedNode.vala b/gxml/BackedNode.vala
index 315fc3d..e013a06 100644
--- a/gxml/BackedNode.vala
+++ b/gxml/BackedNode.vala
@@ -9,7 +9,7 @@ namespace GXml {
* Vala wants base classes to be at least as public as
* subclasses.
*/
- public class BackedNode : XNode {
+ public class BackedNode : DomNode {
/** Private properties */
internal Xml.Node *node;
@@ -19,7 +19,7 @@ namespace GXml {
// Considered using node->doc instead, but some subclasses don't have corresponding Xml.Nodes
this.node = node;
- // Save the correspondence between this Xml.Node* and its XNode
+ // Save the correspondence between this Xml.Node* and its DomNode
owner.node_dict.insert (node, this);
// TODO: Consider checking whether the Xml.Node* is already recorded. It shouldn't be.
}
@@ -134,11 +134,11 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? parent_node {
+ public override DomNode? parent_node {
get {
return this.owner_document.lookup_node (this.node->parent);
// TODO: is parent never null? parent is probably possible to be null, like when you create a new element unattached
- // return new XNode (this.node->parent);
+ // return new DomNode (this.node->parent);
// TODO: figure out whether we really want to recreate wrapper objects each time
}
internal set {
@@ -160,11 +160,11 @@ namespace GXml {
}
}
- private XNode? _first_child;
+ private DomNode? _first_child;
/**
* { inheritDoc}
*/
- public override XNode? first_child {
+ public override DomNode? first_child {
get {
_first_child = this.child_nodes.first ();
return _first_child;
@@ -174,11 +174,11 @@ namespace GXml {
}
}
- private XNode? _last_child;
+ private DomNode? _last_child;
/**
* { inheritDoc}
*/
- public override XNode? last_child {
+ public override DomNode? last_child {
get {
_last_child = this.child_nodes.last ();
return _last_child;
@@ -190,7 +190,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? previous_sibling {
+ public override DomNode? previous_sibling {
get {
return this.owner_document.lookup_node (this.node->prev);
}
@@ -200,7 +200,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? next_sibling {
+ public override DomNode? next_sibling {
get {
return this.owner_document.lookup_node (this.node->next);
}
@@ -225,25 +225,25 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
+ public override DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
return this.child_nodes.insert_before (new_child, ref_child);
}
/**
* { inheritDoc}
*/
- public override XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ public override DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
return this.child_nodes.replace_child (new_child, old_child);
}
/**
* { inheritDoc}
*/
- public override XNode? remove_child (XNode old_child) /*throws DomError*/ {
+ public override DomNode? remove_child (DomNode old_child) /*throws DomError*/ {
return this.child_nodes.remove_child (old_child);
}
/**
* { inheritDoc}
*/
- public override XNode? append_child (XNode new_child) /*throws DomError*/ {
+ public override DomNode? append_child (DomNode new_child) /*throws DomError*/ {
if (new_child.owner_document != this.owner_document && new_child.get_type ().is_a (typeof (GXml.BackedNode))) {
/* The point here is that a node from another document should
have a copy made to be integrated into this one, so we don't
@@ -267,7 +267,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override XNode? clone_nodes (bool deep) {
+ public override DomNode? clone_nodes (bool deep) {
return this; // STUB
}
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 0e06e70..5f9d288 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -45,18 +45,18 @@ namespace GXml {
* more, see:
* [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#i-Document]]
*/
- public class Document : XNode {
+ public class Document : DomNode {
/* *** Private properties *** */
/**
* This contains a map of Xml.Nodes that have been
- * accessed and the GXml XNode we created to represent
- * them on-demand. That way, we don't create an XNode
+ * accessed and the GXml DomNode we created to represent
+ * them on-demand. That way, we don't create an DomNode
* for EVERY node, even if the user never actually
* accesses it.
*/
- internal HashTable<Xml.Node*, XNode> node_dict = new HashTable<Xml.Node*, XNode> (GLib.direct_hash, GLib.direct_equal);
- // We don't want want to use XNode's Xml.Node or its dict
+ internal HashTable<Xml.Node*, DomNode> node_dict = new HashTable<Xml.Node*, DomNode> (GLib.direct_hash, GLib.direct_equal);
+ // We don't want want to use DomNode's Xml.Node or its dict
// internal HashTable<Xml.Attr*, Attr> attr_dict = new HashTable<Xml.Attr*, Attr> (null, null);
/**
@@ -79,8 +79,8 @@ namespace GXml {
internal Xml.Doc *xmldoc;
/* *** Private methods *** */
- internal unowned XNode? lookup_node (Xml.Node *xmlnode) {
- unowned XNode domnode;
+ internal unowned DomNode? lookup_node (Xml.Node *xmlnode) {
+ unowned DomNode domnode;
if (xmlnode == null) {
return null; // TODO: consider throwing an error instead
@@ -88,7 +88,7 @@ namespace GXml {
domnode = this.node_dict.lookup (xmlnode);
if (domnode == null) {
- // If we don't have a cached the appropriate XNode for a given Xml.Node* yet, create it (type matters)
+ // If we don't have a cached the appropriate DomNode for a given Xml.Node* yet, create it (type matters)
// TODO: see if we can attach logic to the enum {} to handle this
switch ((NodeType)xmlnode->type) {
case NodeType.ELEMENT:
@@ -529,7 +529,7 @@ namespace GXml {
return str;
}
- /*** XNode methods ***/
+ /*** DomNode methods ***/
/**
* Appends new_child to this document. A document can
@@ -538,7 +538,7 @@ namespace GXml {
*
* @return The newly added child.
*/
- public override XNode? append_child (XNode new_child) throws DomError {
+ public override DomNode? append_child (DomNode new_child) throws DomError {
if (new_child.node_type == NodeType.ELEMENT) {
if (xmldoc->get_root_element () == null) {
xmldoc->set_root_element (((Element)new_child).node);
diff --git a/gxml/DocumentType.vala b/gxml/DocumentType.vala
index 0d9dee0..56ef13b 100644
--- a/gxml/DocumentType.vala
+++ b/gxml/DocumentType.vala
@@ -4,7 +4,7 @@ namespace GXml {
* Defines a Document, such as the entities that it can use.
* For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-412266927]]
*/
- public class DocumentType : XNode {
+ public class DocumentType : DomNode {
private Xml.Dtd *int_subset;
private Xml.Dtd *ext_subset;
diff --git a/gxml/XNode.vala b/gxml/DomNode.vala
similarity index 88%
rename from gxml/XNode.vala
rename to gxml/DomNode.vala
index 2e25f1b..417e568 100644
--- a/gxml/XNode.vala
+++ b/gxml/DomNode.vala
@@ -6,12 +6,12 @@ namespace GXml {
* Represents an XML Node. Documents are nodes, and are
* composed of a tree of nodes. See [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-1950641247]]
*/
- public class XNode : GLib.Object {
- internal XNode (NodeType type, Document owner) {
+ public class DomNode : GLib.Object {
+ internal DomNode (NodeType type, Document owner) {
this.node_type = type;
this.owner_document = owner;
}
- internal XNode.for_document () {
+ internal DomNode.for_document () {
this.node_name = "#document";
this.node_type = NodeType.DOCUMENT;
}
@@ -21,7 +21,7 @@ namespace GXml {
message (" ns (prefix: %s, uri: %s)", this.prefix, this.namespace_uri);
if (this.attributes != null) {
message (" attributes:");
- foreach (XNode attr in this.attributes.get_values ()) {
+ foreach (DomNode attr in this.attributes.get_values ()) {
message (" %s", attr.node_name);
}
}
@@ -31,7 +31,7 @@ namespace GXml {
// and instead returning empty collections
// No, probably don't want that, as nodes which don't
// support them really do just want to return null ala spec
- foreach (XNode child in this.child_nodes) {
+ foreach (DomNode child in this.child_nodes) {
message (" %s", child.node_name);
}
}
@@ -141,7 +141,7 @@ namespace GXml {
* with elements, the immediate, outer element is the parent.
* <parent><child></child></parent>
*/
- public virtual XNode? parent_node {
+ public virtual DomNode? parent_node {
get { return null; }
internal set {}
}
@@ -166,7 +166,7 @@ namespace GXml {
* Links to the first child. If there are no
* children, it returns null.
*/
- public virtual XNode? first_child {
+ public virtual DomNode? first_child {
get { return null; }
internal set {}
}
@@ -174,7 +174,7 @@ namespace GXml {
* Links to the last child. If there are no
* children, it returns null.
*/
- public virtual XNode? last_child {
+ public virtual DomNode? last_child {
get { return null; }
internal set {}
}
@@ -183,7 +183,7 @@ namespace GXml {
* are no previous siblings, it returns null. Note
* that the children of a node are ordered.
*/
- public virtual XNode? previous_sibling {
+ public virtual DomNode? previous_sibling {
get { return null; }
internal set {}
}
@@ -192,7 +192,7 @@ namespace GXml {
* next sibling, it returns null. Note that the
* children of a node are ordered.
*/
- public virtual XNode? next_sibling {
+ public virtual DomNode? next_sibling {
get { return null; }
internal set {}
}
@@ -218,7 +218,7 @@ namespace GXml {
* @throws DomError.NOT_FOUND if ref_child is not a valid child.
*/
// #todo: want to throw other relevant errors
- public virtual XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
+ public virtual DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
return null;
}
/**
@@ -228,7 +228,7 @@ namespace GXml {
*
* @throws DomError.NOT_FOUND if ref_child is not a valid child.
*/
- public virtual XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ public virtual DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
return null;
}
/**
@@ -239,7 +239,7 @@ namespace GXml {
* @throws DomError.NOT_FOUND if old_child is not a valid child.
* #todo: make @throws claim true
*/
- public virtual XNode? remove_child (XNode old_child) throws DomError {
+ public virtual DomNode? remove_child (DomNode old_child) throws DomError {
return null;
}
/**
@@ -247,7 +247,7 @@ namespace GXml {
*
* @return The newly added child.
*/
- public virtual XNode? append_child (XNode new_child) throws DomError {
+ public virtual DomNode? append_child (DomNode new_child) throws DomError {
return null;
}
/**
@@ -264,7 +264,7 @@ namespace GXml {
*
* @return A parentless clone of this node.
*/
- public virtual XNode? clone_nodes (bool deep) {
+ public virtual DomNode? clone_nodes (bool deep) {
return null;
}
@@ -279,7 +279,7 @@ namespace GXml {
*/
// TODO: need to investigate how to activate format
public virtual string to_string (bool format = false, int level = 0) {
- _str = "XNode(%d:%s)".printf (this.node_type, this.node_name);
+ _str = "DomNode(%d:%s)".printf (this.node_type, this.node_name);
return _str;
}
}
diff --git a/gxml/Element.vala b/gxml/Element.vala
index c7554e9..0745eaa 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -6,7 +6,7 @@ namespace GXml {
* Represent an XML Element node. These can have child nodes
* of various types including other Elements. Elements can
* have Attr attributes associated with them. Elements have
- * tag names. In addition to methods inherited from XNode,
+ * tag names. In addition to methods inherited from DomNode,
* Elements have additional methods for manipulating
* attributes, as an alternative to manipulating the
* attributes HashMap directly. For more, see:
@@ -264,7 +264,7 @@ namespace GXml {
}
// TODO: consider making the life of TagNameNodeLists optional, and dead by default, at the Document level
- private void check_add_tag_name (Element basenode, XNode child) {
+ private void check_add_tag_name (Element basenode, DomNode child) {
// TODO: make sure there aren't any other NodeTypes that could have elements as children
if (child.node_type == NodeType.ELEMENT || child.node_type == NodeType.DOCUMENT_FRAGMENT) {
// the one we're examining is an element, and might need to be added
@@ -273,7 +273,7 @@ namespace GXml {
}
// if we're adding an element with descendants, or a document fragment, they might contain nodes that should go into a tag name node list for an ancestor node
- foreach (XNode grand_child in child.child_nodes) {
+ foreach (DomNode grand_child in child.child_nodes) {
check_add_tag_name (basenode, grand_child);
}
}
@@ -283,38 +283,38 @@ namespace GXml {
* are elements. If they are, we check the basenode and its ancestors to see
* whether they're keeping that node in a TagNameNodeList, so we can remove it.
*/
- private void check_remove_tag_name (Element basenode, XNode child) {
+ private void check_remove_tag_name (Element basenode, DomNode child) {
// TODO: make sure there aren't any other NodeTypes that could have elements as children
if (child.node_type == NodeType.ELEMENT) {
// the one we're examining is an element, and might need to be removed from a tag name node list
basenode.on_remove_descendant_with_tag_name ((Element)child);
// if we're removing an element with descendants, it might contain nodes that should also be removed from a tag name node list for an ancestor node
- foreach (XNode grand_child in child.child_nodes) {
+ foreach (DomNode grand_child in child.child_nodes) {
check_remove_tag_name (basenode, grand_child);
}
}
}
- /* ** XNode methods ** */
- public override XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
- XNode ret = base.insert_before (new_child, ref_child);
+ /* ** DomNode methods ** */
+ public override DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
+ DomNode ret = base.insert_before (new_child, ref_child);
check_add_tag_name (this, new_child);
return ret;
}
- public override XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ public override DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
check_remove_tag_name (this, old_child);
- XNode ret = base.replace_child (new_child, old_child);
+ DomNode ret = base.replace_child (new_child, old_child);
check_add_tag_name (this, new_child);
return ret;
}
- public override XNode? remove_child (XNode old_child) throws DomError {
+ public override DomNode? remove_child (DomNode old_child) throws DomError {
check_remove_tag_name (this, old_child);
- XNode ret = base.remove_child (old_child);
+ DomNode ret = base.remove_child (old_child);
return ret;
}
- public override XNode? append_child (XNode new_child) throws DomError {
- XNode ret = base.append_child (new_child);
+ public override DomNode? append_child (DomNode new_child) throws DomError {
+ DomNode ret = base.append_child (new_child);
check_add_tag_name (this, new_child);
return ret;
}
@@ -368,7 +368,7 @@ namespace GXml {
private void on_remove_descendant_with_tag_name (Element elem) {
foreach (TagNameNodeList list in tag_name_lists) {
if (elem.tag_name == list.tag_name) {
- foreach (XNode tag_elem in list) {
+ foreach (DomNode tag_elem in list) {
if (((Element)tag_elem) == elem) {
list.remove_child (tag_elem);
break;
@@ -397,7 +397,7 @@ namespace GXml {
*/
public NodeList get_elements_by_tag_name (string tag_name) {
TagNameNodeList tagged = new TagNameNodeList (tag_name, this, this.owner_document);
- //List<XNode> tagged = new List<XNode> ();
+ //List<DomNode> tagged = new List<DomNode> ();
Queue<Xml.Node*> tocheck = new Queue<Xml.Node*> ();
/* TODO: find out whether we are supposed to include this element,
@@ -435,7 +435,7 @@ namespace GXml {
// STUB
- foreach (XNode child in this.child_nodes) {
+ foreach (DomNode child in this.child_nodes) {
switch (child.node_type) {
case NodeType.ELEMENT:
((Element)child).normalize ();
diff --git a/gxml/Entity.vala b/gxml/Entity.vala
index dce795b..fe1836d 100644
--- a/gxml/Entity.vala
+++ b/gxml/Entity.vala
@@ -5,7 +5,7 @@ namespace GXml {
* in a DocumentType.
* For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-11C98490]]
*/
- public class Entity : XNode {
+ public class Entity : DomNode {
private Xml.Entity *entity;
/**
@@ -64,7 +64,7 @@ namespace GXml {
}
- public override XNode? parent_node {
+ public override DomNode? parent_node {
get {
return this.owner_document.doctype;
// TODO: could this be differen tfrom this.entity->parent?
@@ -85,22 +85,22 @@ namespace GXml {
}
/* Public methods (Node-specific) */
- public override XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
+ public override DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
return this.child_nodes.insert_before (new_child, ref_child);
}
- public override XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ public override DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
return this.child_nodes.replace_child (new_child, old_child);
}
- public override XNode? remove_child (XNode old_child) throws DomError {
+ public override DomNode? remove_child (DomNode old_child) throws DomError {
return this.child_nodes.remove_child (old_child);
}
- public override XNode? append_child (XNode new_child) throws DomError {
+ public override DomNode? append_child (DomNode new_child) throws DomError {
return this.child_nodes.append_child (new_child);
}
public override bool has_child_nodes () {
return (this.child_nodes.length > 0);
}
- public override XNode? clone_nodes (bool deep) {
+ public override DomNode? clone_nodes (bool deep) {
return this; // STUB
}
diff --git a/gxml/EntityReference.vala b/gxml/EntityReference.vala
index 1375cdf..27721c4 100644
--- a/gxml/EntityReference.vala
+++ b/gxml/EntityReference.vala
@@ -10,7 +10,7 @@ namespace GXml {
* For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-11C98490]]
*/
// TODO: make sure that character entity references (like the one used in the example above, are valid
- public class EntityReference : XNode {
+ public class EntityReference : DomNode {
internal EntityReference (string refname, Document doc) {
// TODO: may want to handle refname differently
base (NodeType.ENTITY_REFERENCE, doc); // TODO: what should we pass up?
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index b36509b..571d4d0 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -43,6 +43,7 @@ libgxml_la_VALASOURCES = \
Document.vala \
DocumentFragment.vala \
DocumentType.vala \
+ DomNode.vala \
DomError.vala \
Element.vala \
Entity.vala \
@@ -56,7 +57,6 @@ libgxml_la_VALASOURCES = \
Text.vala \
Serializable.vala \
Serialization.vala \
- XNode.vala \
$(NULL)
libgxml_0_2_la_SOURCES = \
diff --git a/gxml/NamespaceAttr.vala b/gxml/NamespaceAttr.vala
index c726aa6..e4476b2 100644
--- a/gxml/NamespaceAttr.vala
+++ b/gxml/NamespaceAttr.vala
@@ -5,7 +5,7 @@ namespace GXml {
* prefix=uri pairs that define namespaces for XML Elements
* and Attrs.
*/
- public class NamespaceAttr : XNode {
+ public class NamespaceAttr : DomNode {
/** Private properties */
private Xml.Ns *node;
diff --git a/gxml/NodeList.vala b/gxml/NodeList.vala
index e08d0bf..194938e 100644
--- a/gxml/NodeList.vala
+++ b/gxml/NodeList.vala
@@ -7,7 +7,7 @@ namespace GXml {
* The NodeList is a live list used to store nodes, often the
* children of a node, or a list of nodes matching a tag name.
*/
- public interface NodeList : Gee.Iterable<XNode> {
+ public interface NodeList : Gee.Iterable<DomNode> {
public abstract ulong length {
get; private set;
}
@@ -22,7 +22,7 @@ namespace GXml {
* Access the idx'th item in the list.
*/
// TODO: this should throw invalid index or something
- public abstract XNode item (ulong idx);
+ public abstract DomNode item (ulong idx);
/* NOTE: children should implement
* public ulong length;
* TODO: figure out how to require this as a property; maybe have to make it into a method
@@ -34,51 +34,51 @@ namespace GXml {
/**
* Call the provided func on each item of the list.
*/
- public abstract void foreach (Func<XNode> func);
+ public abstract void foreach (Func<DomNode> func);
// TODO: add hints for performance below, perhaps
/**
* Retrieve the first node in the list.
*/
- public abstract XNode first ();
+ public abstract DomNode first ();
/**
* Retrieve the last node in the list.
*/
- public abstract XNode last ();
+ public abstract DomNode last ();
/**
* Obtain the n'th item in the list. Used for compatibility with GLib.List.
*/
- public abstract XNode? nth (ulong n);
+ public abstract DomNode? nth (ulong n);
/**
* Obtain the n'th item in the list. Used for compatibility with GLib.List.
*/
- public abstract XNode? nth_data (ulong n);
+ public abstract DomNode? nth_data (ulong n);
/**
* Obtain the item n places before pivot in the list.
*/
- public abstract XNode? nth_prev (XNode pivot, ulong n);
+ public abstract DomNode? nth_prev (DomNode pivot, ulong n);
/**
* Obtain index for node target in the list.
*/
- public abstract int find (XNode target);
+ public abstract int find (DomNode target);
/**
* Obtain index for node target in the list, using CompareFunc to compare.
*/
- public abstract int find_custom (XNode target, CompareFunc<XNode> cmp);
+ public abstract int find_custom (DomNode target, CompareFunc<DomNode> cmp);
/**
* Obtain index for node target in the list.
*/
- public abstract int position (XNode target);
+ public abstract int position (DomNode target);
/**
* Obtain index for node target in the list.
*/
- public abstract int index (XNode target);
+ public abstract int index (DomNode target);
// TODO: wow, lots of those GList compatibility methods are the same in a case like this.
/* These exist to support management of a node's children */
- internal abstract XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError;
- internal abstract XNode? replace_child (XNode new_child, XNode old_child) throws DomError;
- internal abstract XNode? remove_child (XNode old_child) /*throws DomError*/;
- internal abstract XNode? append_child (XNode new_child) /*throws DomError*/;
+ internal abstract DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError;
+ internal abstract DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError;
+ internal abstract DomNode? remove_child (DomNode old_child) /*throws DomError*/;
+ internal abstract DomNode? append_child (DomNode new_child) /*throws DomError*/;
/**
* Creates an XML string representation of the nodes in the list.
@@ -93,17 +93,17 @@ namespace GXml {
/**
* This provides a NodeList that is backed by a GLib.List of
- * XNodes. A root XNode is specified, which is usually the
+ * DomNodes. A root DomNode is specified, which is usually the
* owner/parent of the list's contents (children of the
* parent).
*/
- internal class GListNodeList : Gee.Traversable<XNode>, Gee.Iterable<XNode>, NodeList, GLib.Object {
- internal XNode root;
- internal GLib.List<XNode> nodes;
+ internal class GListNodeList : Gee.Traversable<DomNode>, Gee.Iterable<DomNode>, NodeList, GLib.Object {
+ internal DomNode root;
+ internal GLib.List<DomNode> nodes;
- internal GListNodeList (XNode root) {
+ internal GListNodeList (DomNode root) {
this.root = root;
- this.nodes = new GLib.List<XNode> ();
+ this.nodes = new GLib.List<DomNode> ();
}
public ulong length {
@@ -117,87 +117,87 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public XNode item (ulong idx) {
+ public DomNode item (ulong idx) {
return this.nth_data (idx);
}
/**
* { inheritDoc}
*/
- public void foreach (Func<XNode> func) {
+ public void foreach (Func<DomNode> func) {
this.nodes.foreach (func);
}
/**
* { inheritDoc}
*/
- public XNode first () {
+ public DomNode first () {
return this.nodes.first ().data;
}
/**
* { inheritDoc}
*/
- public XNode last () {
+ public DomNode last () {
return this.nodes.last ().data;
}
/**
* { inheritDoc}
*/
- public XNode? nth (ulong n) {
+ public DomNode? nth (ulong n) {
return this.nth_data (n);
}
/**
* { inheritDoc}
*/
- public XNode? nth_data (ulong n) {
+ public DomNode? nth_data (ulong n) {
return this.nodes.nth_data ((uint)n);
}
/**
* { inheritDoc}
*/
- public XNode? nth_prev (XNode pivot, ulong n) {
- unowned GLib.List<XNode> list_pivot = this.nodes.find (pivot);
+ public DomNode? nth_prev (DomNode pivot, ulong n) {
+ unowned GLib.List<DomNode> list_pivot = this.nodes.find (pivot);
return list_pivot.nth_prev ((uint)n).data;
}
/**
* { inheritDoc}
*/
- public int find (XNode target) {
+ public int find (DomNode target) {
return this.index (target);
}
/**
* { inheritDoc}
*/
- public int find_custom (XNode target, CompareFunc<XNode> cmp) {
- unowned GLib.List<XNode> list_pt = this.nodes.find_custom (target, cmp);
+ public int find_custom (DomNode target, CompareFunc<DomNode> cmp) {
+ unowned GLib.List<DomNode> list_pt = this.nodes.find_custom (target, cmp);
return this.index (list_pt.data);
}
/**
* { inheritDoc}
*/
- public int position (XNode target) {
+ public int position (DomNode target) {
return this.index (target);
}
/**
* { inheritDoc}
*/
- public int index (XNode target) {
+ public int index (DomNode target) {
return this.nodes.index (target);
}
- internal XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
+ internal DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
this.nodes.insert_before (this.nodes.find (ref_child), new_child);
return new_child;
}
- internal XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ internal DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
int pos = this.index (old_child);
this.remove_child (old_child);
this.nodes.insert (new_child, pos);
return old_child;
}
- internal XNode? remove_child (XNode old_child) /*throws DomError*/ {
+ internal DomNode? remove_child (DomNode old_child) /*throws DomError*/ {
this.nodes.remove (old_child);
return old_child;
}
- internal XNode? append_child (XNode new_child) /*throws DomError*/ {
+ internal DomNode? append_child (DomNode new_child) /*throws DomError*/ {
this.nodes.append (new_child);
return new_child;
}
@@ -205,7 +205,7 @@ namespace GXml {
public string to_string (bool in_line) {
string str = "";
- foreach (XNode node in this.nodes) {
+ foreach (DomNode node in this.nodes) {
str += node.to_string ();
}
@@ -215,27 +215,27 @@ namespace GXml {
/*** Traversable methods ***/
/* TODO: Verify that relying on these *_impl methods is appropriate */
- public Iterator<XNode> chop (int offset, int length = -1) {
- return Gee.Traversable.chop_impl<XNode> (this, offset, length);
+ public Iterator<DomNode> chop (int offset, int length = -1) {
+ return Gee.Traversable.chop_impl<DomNode> (this, offset, length);
}
- public Iterator<XNode> filter (owned Predicate<XNode> f) {
+ public Iterator<DomNode> filter (owned Predicate<DomNode> f) {
// TODO: ask what Traversable delegate wants with this; it complains about how I shouldn't copy a delegate :)
- return Gee.Traversable.filter_impl<XNode> (this, f);
+ return Gee.Traversable.filter_impl<DomNode> (this, f);
}
- public Iterator<A> stream<A> (owned StreamFunc<XNode,A> f) {
+ public Iterator<A> stream<A> (owned StreamFunc<DomNode,A> f) {
// TODO: is it appropriate to use Iterator.stream_impl for an Iterable implementer?
- return Iterator.stream_impl<XNode, A> (this.iterator (), f);
+ return Iterator.stream_impl<DomNode, A> (this.iterator (), f);
}
/*** Iterable methods ***/
public GLib.Type element_type {
get {
- return typeof (XNode);
+ return typeof (DomNode);
}
}
- public Gee.Iterator<XNode> iterator () {
+ public Gee.Iterator<DomNode> iterator () {
return new NodeListIterator (this);
}
@@ -256,9 +256,9 @@ namespace GXml {
* remove () always fails (does nothing)
*/
- private unowned GLib.List<XNode> cur;
- private unowned GLib.List<XNode> first_node;
- private unowned GLib.List<XNode> next_node;
+ private unowned GLib.List<DomNode> cur;
+ private unowned GLib.List<DomNode> first_node;
+ private unowned GLib.List<DomNode> next_node;
public NodeListIterator (GListNodeList list) {
this.cur = null;
@@ -266,7 +266,7 @@ namespace GXml {
this.next_node = list.nodes;
}
- protected override XNode get_current () {
+ protected override DomNode get_current () {
return this.cur.data;
}
@@ -282,7 +282,7 @@ namespace GXml {
/*** Traversable methods ***/
- public override void foreach (ForallFunc<XNode> f) {
+ public override void foreach (ForallFunc<DomNode> f) {
/* TODO: we need to iterate over the items in the iterator,
we are the iterator
but now that Iterator doesn't have a first () to reset with,
@@ -292,7 +292,7 @@ namespace GXml {
and then proceed through our list to the end?
Do we move our cursor along?
Should we just start foreach-ing from wherever our cursor already is? */
- for (unowned GLib.List<XNode> cur2 = this.first_node; cur2 != null; cur2 = cur2.next) {
+ for (unowned GLib.List<DomNode> cur2 = this.first_node; cur2 != null; cur2 = cur2.next) {
f (cur2.data);
}
}
@@ -303,7 +303,7 @@ namespace GXml {
internal class TagNameNodeList : GListNodeList {
internal string tag_name;
- internal TagNameNodeList (string tag_name, XNode root, Document owner) {
+ internal TagNameNodeList (string tag_name, DomNode root, Document owner) {
base (root);
this.tag_name = tag_name;
}
@@ -312,7 +312,7 @@ namespace GXml {
/* TODO: warning: this list should NOT be edited :(
we need a new, better live AttrNodeList :| */
internal class AttrNodeList : GListNodeList {
- internal AttrNodeList (XNode root, Document owner) {
+ internal AttrNodeList (DomNode root, Document owner) {
base (root);
base.nodes = root.attributes.get_values ();
}
@@ -417,7 +417,7 @@ namespace GXml {
// TODO: Desperately want to extend List or implement relevant interfaces to make iterable
// TODO: remember that the order of interfaces that you're listing as implemented matters
- internal abstract class ChildNodeList : Gee.Traversable<XNode>, Gee.Iterable<XNode>, NodeList, GLib.Object {
+ internal abstract class ChildNodeList : Gee.Traversable<DomNode>, Gee.Iterable<DomNode>, NodeList, GLib.Object {
/* TODO: must be live
if this reflects children of a node, then must always be current
same with nodes from GetElementByTagName, made need separate impls for each */
@@ -440,17 +440,17 @@ namespace GXml {
private set { }
}
- XNode item (ulong idx) {
+ DomNode item (ulong idx) {
return this.nth (idx);
}
/** Iterable methods **/
public GLib.Type element_type { // TODO: should we need to use the override keyword when implementing interfaces
get {
- return typeof(XNode);
+ return typeof(DomNode);
}
}
- public Gee.Iterator<XNode> iterator () {
+ public Gee.Iterator<DomNode> iterator () {
return new NodeListIterator (this);
}
@@ -458,35 +458,35 @@ namespace GXml {
/** GNOME List conventions
** Probably don't want to keep all of them since they're not all relevant.
**/
- public void foreach (Func<XNode> func) {
- XNode node;
+ public void foreach (Func<DomNode> func) {
+ DomNode node;
for (Xml.Node *cur = head; cur != null; cur = cur->next) {
node = this.owner.lookup_node (cur);
func (node);
}
}
- public XNode first () {
+ public DomNode first () {
return this.owner.lookup_node (head);
}
- public XNode last () {
+ public DomNode last () {
Xml.Node *cur = head;
while (cur != null && cur->next != null) {
cur = cur->next;
}
return this.owner.lookup_node (cur); // TODO :check for nulls?
}
- public XNode? nth (ulong n) {
+ public DomNode? nth (ulong n) {
Xml.Node *cur = head;
for (int i = 0; i < n && cur != null; i++) {
cur = cur->next;
}
return this.owner.lookup_node (cur);
}
- public XNode? nth_data (ulong n) {
+ public DomNode? nth_data (ulong n) {
return nth (n);
}
- public XNode? nth_prev (XNode pivot, ulong n) {
+ public DomNode? nth_prev (DomNode pivot, ulong n) {
Xml.Node *cur;
for (cur = head; cur != null && this.owner.lookup_node (cur) != pivot; cur = cur->next) {
}
@@ -498,7 +498,7 @@ namespace GXml {
}
return this.owner.lookup_node (cur);
}
- public int find (XNode target) {
+ public int find (DomNode target) {
int pos = 0;
Xml.Node *cur;
for (cur = head; cur != null && this.owner.lookup_node (cur) != target; cur = cur->next) {
@@ -510,7 +510,7 @@ namespace GXml {
return pos;
}
}
- public int find_custom (XNode target, CompareFunc<XNode> cmp) {
+ public int find_custom (DomNode target, CompareFunc<DomNode> cmp) {
int pos = 0;
Xml.Node *cur;
for (cur = head; cur != null && cmp (this.owner.lookup_node (cur), target) != 0; cur = cur->next) {
@@ -522,15 +522,15 @@ namespace GXml {
return pos;
}
}
- public int position (XNode target) {
+ public int position (DomNode target) {
return find (target);
}
- public int index (XNode target) {
+ public int index (DomNode target) {
return find (target);
}
/** Node's child methods, implemented here **/
- internal new XNode? insert_before (XNode new_child, XNode? ref_child) throws DomError {
+ internal new DomNode? insert_before (DomNode new_child, DomNode? ref_child) throws DomError {
Xml.Node *child = head;
if (ref_child == null) {
@@ -545,7 +545,7 @@ namespace GXml {
// TODO: provide a more useful description of ref_child, but there are so many different types
} else {
if (new_child.node_type == NodeType.DOCUMENT_FRAGMENT) {
- foreach (XNode new_grand_child in new_child.child_nodes) {
+ foreach (DomNode new_grand_child in new_child.child_nodes) {
child->add_prev_sibling (((BackedNode)new_grand_child).node);
}
} else {
@@ -555,13 +555,13 @@ namespace GXml {
return new_child;
}
- internal new XNode? replace_child (XNode new_child, XNode old_child) throws DomError {
+ internal new DomNode? replace_child (DomNode new_child, DomNode old_child) throws DomError {
// TODO: verify that libxml2 already removes
// new_child first if it is found elsewhere in
// the tree.
// TODO: nuts, if Node as an iface can't have properties,
- // then I have to cast these to XNodes, ugh.
+ // then I have to cast these to DomNodes, ugh.
// TODO: need to handle errors?
// TODO: want to do a 'find_child' function
@@ -586,20 +586,20 @@ namespace GXml {
return old_child;
}
- internal new XNode? remove_child (XNode old_child) /* throws DomError */ {
+ internal new DomNode? remove_child (DomNode old_child) /* throws DomError */ {
// TODO: verify that old_child is a valid child here and then unlink
((BackedNode)old_child).node->unlink (); // TODO: do we need to free libxml2 stuff manually?
return old_child;
}
- internal virtual XNode? append_child (XNode new_child) /* throws DomError */ {
+ internal virtual DomNode? append_child (DomNode new_child) /* throws DomError */ {
// TODO: verify that libxml2 will first remove
// new_child if it already exists elsewhere in
// the tree.
if (new_child.node_type == NodeType.DOCUMENT_FRAGMENT) {
- foreach (XNode grand_child in new_child.child_nodes) {
+ foreach (DomNode grand_child in new_child.child_nodes) {
parent_as_xmlnode->add_child (((BackedNode)grand_child).node);
}
} else {
@@ -612,7 +612,7 @@ namespace GXml {
private string _str;
public string to_string (bool in_line = true) {
_str = "";
- foreach (XNode node in this) {
+ foreach (DomNode node in this) {
_str += node.to_string ();
}
return _str;
@@ -621,17 +621,17 @@ namespace GXml {
/*** Traversable methods ***/
/* TODO: Verify that relying on these *_impl methods is appropriate */
- public Iterator<XNode> chop (int offset, int length = -1) {
- return Gee.Traversable.chop_impl<XNode> (this, offset, length);
+ public Iterator<DomNode> chop (int offset, int length = -1) {
+ return Gee.Traversable.chop_impl<DomNode> (this, offset, length);
}
- public Iterator<XNode> filter (owned Predicate<XNode> f) {
- return Gee.Traversable.filter_impl<XNode> (this, f);
+ public Iterator<DomNode> filter (owned Predicate<DomNode> f) {
+ return Gee.Traversable.filter_impl<DomNode> (this, f);
}
- public Iterator<A> stream<A> (owned StreamFunc<XNode,A> f) {
+ public Iterator<A> stream<A> (owned StreamFunc<DomNode,A> f) {
// TODO: is it appropriate to use Iterator.stream_impl for an Iterable implementer?
- return Iterator.stream_impl<XNode, A> (this.iterator (), f);
+ return Iterator.stream_impl<DomNode, A> (this.iterator (), f);
}
/*** NodeListIterator ***/
@@ -653,7 +653,7 @@ namespace GXml {
/*** model-specific methods ***/
- protected override XNode get_current () {
+ protected override DomNode get_current () {
return this.doc.lookup_node (this.cur);
}
@@ -668,7 +668,7 @@ namespace GXml {
/*** Traversable methods ***/
- public override void foreach (ForallFunc<XNode> f) {
+ public override void foreach (ForallFunc<DomNode> f) {
/* TODO: we need to iterate over the items in the iterator,
we are the iterator
but now that Iterator doesn't have a first () to reset with,
@@ -685,53 +685,53 @@ namespace GXml {
}
}
- public abstract class GenericNodeListIterator : Gee.Traversable<XNode>, Gee.Iterator<XNode>, GLib.Object {
- protected abstract XNode get_current ();
+ public abstract class GenericNodeListIterator : Gee.Traversable<DomNode>, Gee.Iterator<DomNode>, GLib.Object {
+ protected abstract DomNode get_current ();
protected abstract bool is_empty ();
protected abstract void advance ();
/*** Traversable methods ***/
- public Gee.Iterator<XNode> chop (int offset, int length = -1) {
+ public Gee.Iterator<DomNode> chop (int offset, int length = -1) {
/* TODO: is this how the *_impl static methods in Iterator and
Traversable are supposed to be used? */
- return Gee.Traversable.chop_impl<XNode> (this, offset, length);
+ return Gee.Traversable.chop_impl<DomNode> (this, offset, length);
}
- public Gee.Iterator<XNode> filter (owned Predicate<XNode> f) {
+ public Gee.Iterator<DomNode> filter (owned Predicate<DomNode> f) {
/* TODO: is this a valid approach? */
- return Gee.Traversable.filter_impl<XNode> (this, f);
+ return Gee.Traversable.filter_impl<DomNode> (this, f);
}
- public Iterator<A> stream<A> (owned StreamFunc<XNode,A> f) {
+ public Iterator<A> stream<A> (owned StreamFunc<DomNode,A> f) {
/* TODO: I hope we can do this
What do we want to put there instead of A? Anything?
We don't need to know A, that's why it's a generic type on the function identifier: the caller names it */
- return Gee.Iterator.stream_impl<XNode,A> (this, f);
+ return Gee.Iterator.stream_impl<DomNode,A> (this, f);
}
- public abstract void foreach (ForallFunc<XNode> f);
+ public abstract void foreach (ForallFunc<DomNode> f);
/*** Iterator methods ***/
/**
- * Obtain the current XNode in the iteration.
+ * Obtain the current DomNode in the iteration.
* Returns null if there is none, which occurs
* if the list is empty or if iteration has
* not started (next () has never been
* called).
*/
- public new XNode get () {
+ public new DomNode get () {
if (this.valid) {
return this.get_current ();
} else {
- // TODO: file bug, Iterator wants XNode, not XNode?, but it wants us to be able to return null.
+ // TODO: file bug, Iterator wants DomNode, not DomNode?, but it wants us to be able to return null.
return null;
}
}
/**
- * Advance to the next XNode in the list
+ * Advance to the next DomNode in the list
*/
public bool next () {
if (this.is_empty ()) {
@@ -744,7 +744,7 @@ namespace GXml {
}
/**
- * Checks whether there is a next XNode in the list.
+ * Checks whether there is a next DomNode in the list.
*/
public bool has_next () {
return (! this.is_empty ());
diff --git a/gxml/Notation.vala b/gxml/Notation.vala
index 1b585a9..cd6ca32 100644
--- a/gxml/Notation.vala
+++ b/gxml/Notation.vala
@@ -7,7 +7,7 @@ namespace GXml {
* ProcessingInstruction targets.
* For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-5431D1B9]]
*/
- public class Notation : XNode {
+ public class Notation : DomNode {
// private Xml.Notation *notation; // TODO: wrap libxml's xmlNotation
/**
diff --git a/gxml/ProcessingInstruction.vala b/gxml/ProcessingInstruction.vala
index 5e72855..5d66a5f 100644
--- a/gxml/ProcessingInstruction.vala
+++ b/gxml/ProcessingInstruction.vala
@@ -12,7 +12,7 @@ namespace GXml {
* {{{<?pi_target processing instruction data?>}}}
* For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-1004215813]]
*/
- public class ProcessingInstruction : XNode {
+ public class ProcessingInstruction : DomNode {
internal ProcessingInstruction (string target, string data, Document doc) {
base (NodeType.PROCESSING_INSTRUCTION, doc); // TODO: want to pass a real Xml.Node* ?
this.target = target;
diff --git a/gxml/Serializable.vala b/gxml/Serializable.vala
index 3ccd9e4..56c6581 100644
--- a/gxml/Serializable.vala
+++ b/gxml/Serializable.vala
@@ -35,14 +35,14 @@ namespace GXml {
and false elsewise (in which case, XmlSerializable will try to deserialize
it). */
/** OBSOLETENOTE: Return the deserialized value in GLib.Value (even if it's a GLib.Boxed type) because Serializer is going to set the property after calling this, and if you just set it yourself within, it will be overwritten */
- public virtual bool deserialize_property (string property_name, /* out GLib.Value value,*/ GLib.ParamSpec spec, GXml.XNode property_node) {
+ public virtual bool deserialize_property (string property_name, /* out GLib.Value value,*/ GLib.ParamSpec spec, GXml.DomNode property_node) {
return false; // default deserialize_property gets used
}
// TODO: just added ? to these, do we really want to allow nulls for them?
// TODO: value and property_name are kind of redundant: eliminate? property_name from spec.property_name and value from the object itself :)
/** Serialized properties should have the XML structure <Property pname="PropertyName">...</Property> */
// TODO: perhaps we should provide that base structure
- public virtual GXml.XNode? serialize_property (string property_name, /*GLib.Value value, */ GLib.ParamSpec spec, GXml.Document doc) {
+ public virtual GXml.DomNode? serialize_property (string property_name, /*GLib.Value value, */ GLib.ParamSpec spec, GXml.Document doc) {
return null; // default serialize_property gets used
}
diff --git a/gxml/Serialization.vala b/gxml/Serialization.vala
index c00c24c..ff0fe90 100644
--- a/gxml/Serialization.vala
+++ b/gxml/Serialization.vala
@@ -19,7 +19,7 @@ namespace GXml {
* @image: library.png
*
* GXmlSerialization provides functions to serialize and
- * deserialize GObjects into and from GXmlXNodes
+ * deserialize GObjects into and from GXmlDomNodes
*/
public class Serialization : GLib.Object {
private static void print_debug (GXml.Document doc, GLib.Object object) {
@@ -43,10 +43,12 @@ namespace GXml {
}
}
- private static GXml.XNode serialize_property (GLib.Object object, ParamSpec prop_spec, GXml.Document doc) throws SerializationError, DomError {
+ // public delegate void GetProperty (GLib.ParamSpec spec, ref GLib.Value value);
+
+ private static GXml.DomNode serialize_property (GLib.Object object, ParamSpec prop_spec, GXml.Document doc) throws SerializationError, DomError {
Type type;
Value value;
- XNode value_node;
+ DomNode value_node;
type = prop_spec.value_type;
@@ -94,13 +96,13 @@ namespace GXml {
/* TODO: so it seems we can get property information from GObjectClass
but that's about it. Need to definitely use introspection for anything
tastier */
- public static GXml.XNode serialize_object (GLib.Object object) throws SerializationError {
+ public static GXml.DomNode serialize_object (GLib.Object object) throws SerializationError {
Document doc;
Element root;
ParamSpec[] prop_specs;
Element prop;
Serializable serializable = null;
- XNode value_prop = null;
+ DomNode value_prop = null;
if (object.get_type ().is_a (typeof (Serializable))) {
serializable = (Serializable)object;
@@ -189,7 +191,7 @@ namespace GXml {
}
// } else if (type.is_a (typeof (Gee.Collection))) {
} else if (type.is_a (typeof (GLib.Object))) {
- GXml.XNode prop_elem_child;
+ GXml.DomNode prop_elem_child;
Object property_object;
try {
@@ -209,7 +211,7 @@ namespace GXml {
}
}
- public static GLib.Object deserialize_object (XNode node) throws SerializationError {
+ public static GLib.Object deserialize_object (DomNode node) throws SerializationError {
Element obj_elem;
string otype;
@@ -244,7 +246,7 @@ namespace GXml {
specs = obj_class.list_properties ();
}
- foreach (XNode child_node in obj_elem.child_nodes) {
+ foreach (DomNode child_node in obj_elem.child_nodes) {
if (child_node.node_name == "Property") {
Element prop_elem;
string pname;
diff --git a/gxml/libgxml-0.2.pc.in b/gxml/libgxml.pc.in
similarity index 100%
rename from gxml/libgxml-0.2.pc.in
rename to gxml/libgxml.pc.in
diff --git a/test/AttrTest.vala b/test/AttrTest.vala
index 92f8513..9785ef4 100644
--- a/test/AttrTest.vala
+++ b/test/AttrTest.vala
@@ -1,12 +1,12 @@
/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-using GXmlDom;
+using GXml;
class AttrTest : GXmlTest {
public static void add_tests () {
Test.add_func ("/gxml/element/namespace_uri", () => {
try {
Document doc = new Document.from_string ("<Wands xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\" wands:shell=\"oak\"/></Wands>");
- XNode root = doc.document_element;
+ DomNode root = doc.document_element;
Element node = (Element)root.child_nodes.item (0);
Attr core = node.get_attribute_node ("core");
@@ -24,7 +24,7 @@ class AttrTest : GXmlTest {
Test.add_func ("/gxml/element/prefix", () => {
try {
Document doc = new Document.from_string ("<Wands xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\" wands:shell=\"oak\"/></Wands>");
- XNode root = doc.document_element;
+ DomNode root = doc.document_element;
Element node = (Element)root.child_nodes.item (0);
Attr core = node.get_attribute_node ("core");
@@ -42,7 +42,7 @@ class AttrTest : GXmlTest {
Test.add_func ("/gxml/element/local_name", () => {
try {
Document doc = new Document.from_string ("<Wands xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\" wands:shell=\"oak\"/></Wands>");
- XNode root = doc.document_element;
+ DomNode root = doc.document_element;
Element node = (Element)root.child_nodes.item (0);
Attr core = node.get_attribute_node ("core");
diff --git a/test/DocumentTest.vala b/test/DocumentTest.vala
index f2eb5f7..682e1af 100644
--- a/test/DocumentTest.vala
+++ b/test/DocumentTest.vala
@@ -73,7 +73,7 @@ class DocumentTest : GXmlTest {
string xml = "<Fruits><Apple></Apple><Orange></Orange></Fruits>";
Document doc = new Document.from_string (xml);
- XNode root = doc.document_element;
+ DomNode root = doc.document_element;
assert (root.node_name == "Fruits");
assert (root.has_child_nodes () == true);
assert (root.first_child.node_name == "Apple");
@@ -366,8 +366,8 @@ class DocumentTest : GXmlTest {
");
}
- public static void print_node (XNode node) {
- List<GXmlDom.XNode> children = (List<GXmlDom.XNode>)node.child_nodes;
+ public static void print_node (DomNode node) {
+ List<GXml.DomNode> children = (List<GXml.DomNode>)node.child_nodes;
if (node.node_type != 3)
GLib.stdout.printf ("<%s", node.node_name);
@@ -380,7 +380,7 @@ class DocumentTest : GXmlTest {
GLib.stdout.printf (">");
if (node.node_value != null)
GLib.stdout.printf ("%s", node.node_value);
- foreach (GXmlDom.XNode child in children) {
+ foreach (GXml.DomNode child in children) {
// TODO: want a stringification method for Nodes?
print_node (child);
}
diff --git a/test/XNodeTest.vala b/test/DomNodeTest.vala
similarity index 100%
rename from test/XNodeTest.vala
rename to test/DomNodeTest.vala
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index a89e0b1..b63d7ae 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -33,8 +33,8 @@ class ElementTest : GXmlTest {
xmlroot->add_child (xmlnode);
Document doc = new Document.from_libxml2 (xmldoc);
- XNode root = doc.document_element;
- XNode node = root.child_nodes.item (0);
+ DomNode root = doc.document_element;
+ DomNode node = root.child_nodes.item (0);
assert (node.namespace_uri == null);
assert (node.prefix == null);
@@ -52,8 +52,8 @@ class ElementTest : GXmlTest {
try {
// TODO: wanted to use TestElement but CAN'T because Vala won't let me access the internal constructor of Element?
Document doc = new Document.from_string ("<Potions><magic:Potion xmlns:magic=\"http://hogwarts.co.uk/magic\" xmlns:products=\"http://diagonalley.co.uk/products\"/></Potions>");
- XNode root = doc.document_element;
- XNode node = root.child_nodes.item (0);
+ DomNode root = doc.document_element;
+ DomNode node = root.child_nodes.item (0);
assert (node.namespace_uri == "http://hogwarts.co.uk/magic");
} catch (GXmlDom.DomError e) {
@@ -65,8 +65,8 @@ class ElementTest : GXmlTest {
try {
// TODO: wanted to use TestElement but CAN'T because Vala won't let me access the internal constructor of Element?
Document doc = new Document.from_string ("<Potions><magic:Potion xmlns:magic=\"http://hogwarts.co.uk/magic\" xmlns:products=\"http://diagonalley.co.uk/products\"><products:Ingredient /></magic:Potion></Potions>");
- XNode root = doc.document_element;
- XNode node = root.child_nodes.item (0);
+ DomNode root = doc.document_element;
+ DomNode node = root.child_nodes.item (0);
// root.dbg_inspect ();
// node.dbg_inspect ();
@@ -87,8 +87,8 @@ class ElementTest : GXmlTest {
Test.add_func ("/gxml/element/prefix", () => {
try {
Document doc = new Document.from_string ("<Potions><magic:Potion xmlns:magic=\"http://hogwarts.co.uk/magic\" xmlns:products=\"http://diagonalley.co.uk/products\"/></Potions>");
- XNode root = doc.document_element;
- XNode node = root.child_nodes.item (0);
+ DomNode root = doc.document_element;
+ DomNode node = root.child_nodes.item (0);
assert (node.prefix == "magic");
} catch (GXmlDom.DomError e) {
@@ -99,8 +99,8 @@ class ElementTest : GXmlTest {
Test.add_func ("/gxml/element/local_name", () => {
try {
Document doc = new Document.from_string ("<Potions><magic:Potion xmlns:magic=\"http://hogwarts.co.uk/magic\" xmlns:products=\"http://diagonalley.co.uk/products\"/></Potions>");
- XNode root = doc.document_element;
- XNode node = root.child_nodes.item (0);
+ DomNode root = doc.document_element;
+ DomNode node = root.child_nodes.item (0);
assert (node.local_name == "Potion");
} catch (GXmlDom.DomError e) {
@@ -111,8 +111,8 @@ class ElementTest : GXmlTest {
Test.add_func ("/gxml/element/namespace_definitions", () => {
try {
Document doc = new Document.from_string ("<Potions><magic:Potion xmlns:magic=\"http://hogwarts.co.uk/magic\" xmlns:products=\"http://diagonalley.co.uk/products\"/></Potions>");
- XNode root = doc.document_element;
- XNode node = root.child_nodes.item (0);
+ DomNode root = doc.document_element;
+ DomNode node = root.child_nodes.item (0);
NodeList namespaces = node.namespace_definitions;
@@ -180,8 +180,8 @@ class ElementTest : GXmlTest {
try {
Document doc = new Document.from_string ("<?xml version='1.0' encoding='UTF-8'?><entry><link rel='http://schemas.google.com/contacts/2008/rel#photo'/></entry>");
- XNode root = doc.document_element;
- foreach (XNode child in root.child_nodes) {
+ DomNode root = doc.document_element;
+ foreach (DomNode child in root.child_nodes) {
attrs = child.attributes;
}
@@ -283,7 +283,7 @@ class ElementTest : GXmlTest {
Test.add_func ("/gxml/element/get_elements_by_tag_name", () => {
try {
Document doc;
- XNode root;
+ DomNode root;
Element elem;
NodeList emails;
Element email;
@@ -356,10 +356,10 @@ class ElementTest : GXmlTest {
</A>";
doc = new Document.from_string (xml);
- XNode a = doc.document_element;
- XNode bs = a.child_nodes.item (3);
- XNode b3 = bs.child_nodes.item (7);
- XNode t1, t2;
+ DomNode a = doc.document_element;
+ DomNode bs = a.child_nodes.item (3);
+ DomNode b3 = bs.child_nodes.item (7);
+ DomNode t1, t2;
NodeList ts = ((Element)bs).get_elements_by_tag_name ("t");
assert (ts.length == 5);
@@ -373,8 +373,8 @@ class ElementTest : GXmlTest {
assert (ts.length == 7);
// Test situation where we add a node tree
- XNode b4;
- XNode d, d2;
+ DomNode b4;
+ DomNode d, d2;
b4 = doc.create_element ("B");
b4.append_child (doc.create_element ("t"));
diff --git a/test/GXmlTest.vala b/test/GXmlTest.vala
index ef5003b..74ceb1a 100644
--- a/test/GXmlTest.vala
+++ b/test/GXmlTest.vala
@@ -5,7 +5,7 @@ class GXmlTest {
public static int main (string[] args) {
Test.init (ref args); // TODO: why ref? what if I just pass args?
DocumentTest.add_tests ();
- XNodeTest.add_tests ();
+ DomNodeTest.add_tests ();
ElementTest.add_tests ();
AttrTest.add_tests ();
NodeListTest.add_tests ();
diff --git a/test/Makefile.am b/test/Makefile.am
index d4eea37..0ff7188 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,7 +61,7 @@ gxml_test_VALASOURCES = \
TextTest.vala \
ValaLibxml2Test.vala \
XmlSerializableTest.vala \
- XNodeTest.vala \
+ DomNodeTest.vala \
$(NULL)
gxml_test_SOURCES = \
diff --git a/test/TextTest.vala b/test/TextTest.vala
index 6077b1b..0bf560b 100644
--- a/test/TextTest.vala
+++ b/test/TextTest.vala
@@ -3,7 +3,7 @@ using GXmlDom;
class TextTest : GXmlTest {
public static void add_tests () {
- /* NOTE: Node name and node value behaviour tested by XNodeTest */
+ /* NOTE: Node name and node value behaviour tested by DomNodeTest */
Test.add_func ("/gxml/text/split_text", () => {
try {
diff --git a/test/XmlSerializableTest.vala b/test/XmlSerializableTest.vala
index ca7da9a..b9c2170 100644
--- a/test/XmlSerializableTest.vala
+++ b/test/XmlSerializableTest.vala
@@ -79,13 +79,13 @@ public class SerializableCapsicum : GLib.Object, GXmlDom.Serializable {
Perhaps these shouldn't be object methods, perhaps they should be static?
Can't have static methods in an interface :(, right? */
public bool deserialize_property (string property_name, /* out GLib.Value value, */
- GLib.ParamSpec spec, GXmlDom.XNode property_node) {
+ GLib.ParamSpec spec, GXmlDom.DomNode property_node) {
GLib.Value outvalue = GLib.Value (typeof (int));
switch (property_name) {
case "ratings":
this.ratings = new GLib.List<int> ();
- foreach (GXmlDom.XNode rating in property_node.child_nodes) {
+ foreach (GXmlDom.DomNode rating in property_node.child_nodes) {
int64.try_parse (((GXmlDom.Element)rating).content, out outvalue);
this.ratings.append ((int)outvalue.get_int64 ());
}
@@ -100,7 +100,7 @@ public class SerializableCapsicum : GLib.Object, GXmlDom.Serializable {
return false;
}
- public GXmlDom.XNode? serialize_property (string property_name, /*GLib.Value value,*/ GLib.ParamSpec spec, GXmlDom.Document doc) {
+ public GXmlDom.DomNode? serialize_property (string property_name, /*GLib.Value value,*/ GLib.ParamSpec spec, GXmlDom.Document doc) {
GXmlDom.Element c_prop;
GXmlDom.Element rating;
@@ -404,7 +404,7 @@ class XmlSerializableTest : GXmlTest {
public static GLib.Object test_serialization_deserialization (GLib.Object object, string name, EqualFunc equals, StringifyFunc stringify) {
string xml_filename;
- GXmlDom.XNode node;
+ GXmlDom.DomNode node;
GXmlDom.Document doc;
GLib.Object object_new = null;
@@ -436,7 +436,7 @@ class XmlSerializableTest : GXmlTest {
public static void add_tests () {
Test.add_func ("/gxml/domnode/xml_serialize", () => {
Fruit fruit;
- GXmlDom.XNode fruit_xml;
+ GXmlDom.DomNode fruit_xml;
fruit = new Fruit ();
fruit.name = "fish";
@@ -461,7 +461,7 @@ class XmlSerializableTest : GXmlTest {
/* NOTE: We expect this one to fail right now */
Fruit fruit;
- GXmlDom.XNode fruit_xml;
+ GXmlDom.DomNode fruit_xml;
fruit = new Fruit ();
fruit.set_all ("blue", 11, "fish", 3);
@@ -659,7 +659,7 @@ class XmlSerializableTest : GXmlTest {
test_serialization_deserialization (tomato, "interface_defaults", (GLib.EqualFunc)SerializableTomato.equals, (StringifyFunc)SerializableTomato.to_string);
});
Test.add_func ("/gxml/serialization/interface_overrides_and_list", () => {
- GXmlDom.XNode node;
+ GXmlDom.DomNode node;
SerializableCapsicum capsicum;
SerializableCapsicum capsicum_new;
string expected;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]