[gxml] Added XPathContext and XPathObject interfaces
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Added XPathContext and XPathObject interfaces
- Date: Thu, 29 Sep 2016 18:41:31 +0000 (UTC)
commit 66270bf75332b5ba052cfc9859148d42981e63fa
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Sep 29 12:39:29 2016 -0500
Added XPathContext and XPathObject interfaces
* Fixes bug #772195
* Now GElement implements XPathContext
* Added new class GXPathObject implementing XPathObject
* Moved new method for XPath in DomElement to XPathContext
gxml/DomElement.vala | 9 ---------
gxml/GXmlElement.vala | 18 ++++++++++++------
gxml/Makefile.am | 1 +
3 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/gxml/DomElement.vala b/gxml/DomElement.vala
index bae3d8d..f28da7b 100644
--- a/gxml/DomElement.vala
+++ b/gxml/DomElement.vala
@@ -56,15 +56,6 @@ public interface GXml.DomElement : GLib.Object,
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 class_names);
-
- /**
- * Evaluate XPath expression.
- *
- * This method evaluates provided expression, registers provided namespaces in resolver and returns an
{@link GXml.XPath.Object}.
- *
- * Throw {@link GXml.XPath.Error} if one of provided namespaces is invalid.
- */
- public abstract GXml.XPath.Object evaluate (string expression, Gee.List<GXml.Namespace>? resolver = null)
throws GXml.XPath.Error;
}
public class GXml.DomElementList : Gee.ArrayList<DomElement>, GXml.DomHTMLCollection {
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index 1a2211c..11c0c26 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -2,6 +2,7 @@
/* GElement.vala
*
* Copyright (C) 2016 Daniel Espinosa <esodan gmail com>
+ * Copyright (C) 2016 Yannick Inizan <inizan yannick gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,7 +28,9 @@ using Gee;
*/
public class GXml.GElement : GXml.GNonDocumentChildNode,
GXml.DomParentNode,
- GXml.DomElement, GXml.Element
+ GXml.DomElement,
+ GXml.Element,
+ GXml.XPathContext
{
public GElement (GDocument doc, Xml.Node *node) {
_node = node;
@@ -316,11 +319,14 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
// FIXME:
throw new DomError.SYNTAX_ERROR (_("DomElement query_selector_all is not implemented"));
}
-
+ // XPathContext implementation
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
- public GXml.XPath.Object evaluate (string expression, Gee.List<GXml.Namespace>? resolver = null) throws
GXml.XPath.Error {
+ public GXml.XPathObject evaluate (string expression,
+ Gee.List<GXml.Namespace>? resolver = null)
+ throws GXml.XPathError
+ {
if (!(this is GXml.Node))
return null;
string data = (this as GXml.Node).to_string();
@@ -331,12 +337,12 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
resolver.foreach (ns => {
int res = context.register_ns (ns.prefix, ns.uri);
if (res != 0) {
- var err = new GXml.XPath.Error.EXPRESSION_OK ("invalid namespace.");
+ var err = new GXml.XPathError.EXPRESSION_OK ("invalid namespace.");
err.code = res;
throw err;
}
return true;
});
- return new GXml.XPath.Object (gdoc, context.eval (expression));
+ return new GXml.GXPathObject (gdoc, context.eval (expression));
}
}
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index f708ccf..06863af 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -110,6 +110,7 @@ sources = \
DomNode.vala \
DomRange.vala \
XPath.vala \
+ GXPathObject.vala \
$(NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]