[gxml: 7/7] Added new set_namespace() method to Node
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml: 7/7] Added new set_namespace() method to Node
- Date: Fri, 6 Feb 2015 05:43:07 +0000 (UTC)
commit 5d21e9d810d7ef1d3cd01ac3877aa879b5abc45c
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Feb 5 23:42:27 2015 -0600
Added new set_namespace() method to Node
gxml/BackedNode.vala | 20 ++++++++++++++++++++
gxml/Node.vala | 10 ++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gxml/BackedNode.vala b/gxml/BackedNode.vala
index a880c60..d0e0dc5 100644
--- a/gxml/BackedNode.vala
+++ b/gxml/BackedNode.vala
@@ -100,6 +100,26 @@ namespace GXml {
/**
* { inheritDoc}
*/
+ public virtual bool set_namespace (string uri, string prefix)
+ {
+ for (Xml.Ns *cur = node->ns_def; cur != null; cur = cur->next) {
+ if ((string) cur->prefix == prefix && (string) cur->href == uri) {
+ this.node->ns = cur;
+ return true;
+ }
+ }
+ // Not found in this node, searching on root element
+ 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) {
+ this.node->ns = cur;
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
+ * { inheritDoc}
+ */
public override string? prefix {
get {
if (this.node->ns == null) {
diff --git a/gxml/Node.vala b/gxml/Node.vala
index 9cf703d..0a0e324 100644
--- a/gxml/Node.vala
+++ b/gxml/Node.vala
@@ -135,6 +135,16 @@ namespace GXml {
{
return null;
}
+
+ /**
+ * Set namespace to this { link GXml.Node}
+ *
+ * Returns: { link true} if namespace exists.
+ */
+ public virtual bool set_namespace (string uri, string prefix)
+ {
+ return false;
+ }
/**
* Stores the namespace prefix for the node. This
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]