[gxml] Renamed xNode.prefix to xNode.namespace_prefix
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Renamed xNode.prefix to xNode.namespace_prefix
- Date: Wed, 15 Apr 2015 00:35:51 +0000 (UTC)
commit 7f12facc7d0cc4dff4c528e75c2521924a4c1601
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Apr 14 14:35:19 2015 -0500
Renamed xNode.prefix to xNode.namespace_prefix
* This avoids conflicts with Namespace interface implementation
gxml/libxml-BackedNode.vala | 21 +++++++++++++--------
gxml/libxml-NamespaceAttr.vala | 9 +++++++--
gxml/libxml-Node.vala | 8 ++++----
test/AttrTest.vala | 10 +++++-----
test/ElementTest.vala | 12 ++++++------
5 files changed, 35 insertions(+), 25 deletions(-)
---
diff --git a/gxml/libxml-BackedNode.vala b/gxml/libxml-BackedNode.vala
index 916b8ed..ad26b2c 100644
--- a/gxml/libxml-BackedNode.vala
+++ b/gxml/libxml-BackedNode.vala
@@ -88,10 +88,10 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override NamespaceAttr? add_namespace_attr (string uri, string prefix)
+ public override NamespaceAttr? add_namespace_attr (string uri, string namespace_prefix)
{
//stdout.printf ("BackedNode: Before add new Namespace\n");
- var ns = this.node->new_ns (uri, prefix);
+ var ns = this.node->new_ns (uri, namespace_prefix);
if (ns == null)
return null;
else
@@ -100,12 +100,12 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override bool set_namespace (string uri, string prefix)
+ public override bool set_namespace (string uri, string namespace_prefix)
{
if (node == null) return false;
if (node->ns_def != null) {
for (Xml.Ns *cur = node->ns_def; cur != null; cur = cur->next) {
- if ((string) cur->prefix == prefix && (string) cur->href == uri) {
+ if ((string) cur->prefix == namespace_prefix && (string) cur->href ==
uri) {
node->set_ns (cur);
return true;
}
@@ -114,7 +114,7 @@ namespace GXml {
// Not found search on parent
if (node->parent != null) {
for (Xml.Ns *cur = node->parent->ns_def; cur != null; cur = cur->next) {
- if ((string) cur->prefix == prefix && (string) cur->href == uri) {
+ if ((string) cur->prefix == namespace_prefix && (string) cur->href ==
uri) {
this.node->set_ns (cur);
return true;
}
@@ -126,7 +126,7 @@ namespace GXml {
if (owner_document.document_element.node == null) return false;
if (owner_document.document_element.node->ns_def == null) return false;
for (Xml.Ns *cur = owner_document.document_element.node->ns_def; cur != null; cur =
cur->next) {
- if ((string) cur->prefix == prefix && (string) cur->href == uri) {
+ if ((string) cur->prefix == namespace_prefix && (string) cur->href == uri) {
this.node->set_ns (cur);
return true;
}
@@ -136,7 +136,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override string? prefix {
+ public override string? namespace_prefix {
get {
if (this.node->ns == null) {
return null;
@@ -365,7 +365,12 @@ namespace GXml {
}
// GXml.Node interface implementations
/*
- public Gee.LinkedList<GXml.Namespace> namespaces { get; }
+ public Gee.LinkedList<GXml.Namespace> namespaces
+ {
+ get {
+ return _namespace_definitions;
+ }
+ }
public Gee.LinkedList<GXml.Node> childs { get; }
public Gee.Map<string,GXml.Node> attrs { get; }
public string name { get; construct set; }
diff --git a/gxml/libxml-NamespaceAttr.vala b/gxml/libxml-NamespaceAttr.vala
index db4f0a0..47c5792 100644
--- a/gxml/libxml-NamespaceAttr.vala
+++ b/gxml/libxml-NamespaceAttr.vala
@@ -1,4 +1,4 @@
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/* NamespaceAttr.vala
*
* Copyright (C) 2011-2013 Richard Schwarting <aquarichy gmail com>
@@ -84,7 +84,7 @@ namespace GXml {
/**
* { inheritDoc}
*/
- public override string? prefix {
+ public override string? namespace_prefix {
get {
return "xmlns";
}
@@ -121,5 +121,10 @@ namespace GXml {
internal set {
}
}
+ // GXml.Namespace interface implementations
+ /*
+ public abstract string uri { get; set; }
+ public abstract string prefix { get; set; }
+ */
}
}
diff --git a/gxml/libxml-Node.vala b/gxml/libxml-Node.vala
index 20383b3..b855bbe 100644
--- a/gxml/libxml-Node.vala
+++ b/gxml/libxml-Node.vala
@@ -73,7 +73,7 @@ namespace GXml {
internal void dbg_inspect () {
message ("node: %s", this.node_name);
- message (" ns (prefix: %s, uri: %s)", this.prefix, this.namespace_uri);
+ message (" ns (namespace_prefix: %s, uri: %s)", this.namespace_prefix,
this.namespace_uri);
if (this.attributes != null) {
message (" attributes:");
for (int i = 0; i < this.attributes.length; i++) {
@@ -131,7 +131,7 @@ namespace GXml {
/**
* Add a new namespace to this { link GXml.xNode}
*/
- public virtual NamespaceAttr? add_namespace_attr (string uri, string prefix)
+ public virtual NamespaceAttr? add_namespace_attr (string uri, string namespace_prefix)
{
return null;
}
@@ -141,7 +141,7 @@ namespace GXml {
*
* Returns: { link true} if namespace exists.
*/
- public virtual bool set_namespace (string uri, string prefix)
+ public virtual bool set_namespace (string uri, string namespace_prefix)
{
return false;
}
@@ -157,7 +157,7 @@ namespace GXml {
* Version: DOM Level 2 Core<<BR>>
* URL: [[http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-NodeNSPrefix]]
*/
- public virtual string? prefix {
+ public virtual string? namespace_prefix {
get {
return null;
}
diff --git a/test/AttrTest.vala b/test/AttrTest.vala
index 47836c0..3463da8 100644
--- a/test/AttrTest.vala
+++ b/test/AttrTest.vala
@@ -1,4 +1,4 @@
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/* Notation.vala
*
* Copyright (C) 2011-2013 Richard Schwarting <aquarichy gmail com>
@@ -40,7 +40,7 @@ class AttrTest : GXmlTest {
assert (shell.namespace_uri == "http://mom.co.uk/wands");
assert (price.namespace_uri == null);
});
- Test.add_func ("/gxml/element/prefix", () => {
+ Test.add_func ("/gxml/element/namespace_prefix", () => {
xDocument doc = new xDocument.from_string ("<Wands
xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\"
wands:shell=\"oak\"/></Wands>");
GXml.xNode root = doc.document_element;
xElement node = (xElement)root.child_nodes.item (0);
@@ -49,9 +49,9 @@ class AttrTest : GXmlTest {
Attr shell = node.get_attribute_node ("shell");
Attr price = node.get_attribute_node ("price");
- assert (core.prefix == "wands");
- assert (shell.prefix == "wands");
- assert (price.prefix == null);
+ assert (core.namespace_prefix == "wands");
+ assert (shell.namespace_prefix == "wands");
+ assert (price.namespace_prefix == null);
});
Test.add_func ("/gxml/element/local_name", () => {
xDocument doc = new xDocument.from_string ("<Wands
xmlns:wands=\"http://mom.co.uk/wands\"><Wand price=\"43.56\" wands:core=\"dragon heart cord\"
wands:shell=\"oak\"/></Wands>");
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index 5c0a26b..c3dddab 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -59,10 +59,10 @@ class ElementTest : GXmlTest {
GXml.xNode node = root.child_nodes.item (0);
assert (node.namespace_uri == null);
- assert (node.prefix == null);
+ assert (node.namespace_prefix == null);
xmlnode->set_ns (ns_magic);
assert (node.namespace_uri == "http://hogwarts.co.uk/magic");
- assert (node.prefix == "magic");
+ assert (node.namespace_prefix == "magic");
assert (node.local_name == "Potion");
assert (node.node_name == "Potion");
});
@@ -92,12 +92,12 @@ class ElementTest : GXmlTest {
// message ("attrkey: %s, value: %s", attr.node_name, attr.node_value);
// }
});
- Test.add_func ("/gxml/element/prefix", () => {
+ Test.add_func ("/gxml/element/namespace_prefix", () => {
xDocument doc = new xDocument.from_string ("<Potions><magic:Potion
xmlns:magic=\"http://hogwarts.co.uk/magic\"
xmlns:products=\"http://diagonalley.co.uk/products\"/></Potions>");
GXml.xNode root = doc.document_element;
GXml.xNode node = root.child_nodes.item (0);
- assert (node.prefix == "magic");
+ assert (node.namespace_prefix == "magic");
});
Test.add_func ("/gxml/element/local_name", () => {
xDocument doc = new xDocument.from_string ("<Potions><magic:Potion
xmlns:magic=\"http://hogwarts.co.uk/magic\"
xmlns:products=\"http://diagonalley.co.uk/products\"/></Potions>");
@@ -115,10 +115,10 @@ class ElementTest : GXmlTest {
assert (namespaces.length == 2);
- assert (namespaces.item (0).prefix == "xmlns");
+ assert (namespaces.item (0).namespace_prefix == "xmlns");
assert (namespaces.item (0).node_name == "magic");
assert (namespaces.item (0).node_value == "http://hogwarts.co.uk/magic");
- assert (namespaces.item (1).prefix == "xmlns");
+ assert (namespaces.item (1).namespace_prefix == "xmlns");
assert (namespaces.item (1).node_name == "products");
assert (namespaces.item (1).node_value ==
"http://diagonalley.co.uk/products");
assert (node.local_name == "Potion");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]