[gxml] Namespace: removed deprecated interface
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Namespace: removed deprecated interface
- Date: Fri, 5 Jul 2019 19:08:29 +0000 (UTC)
commit cdc83984660dd198178090bb8367d3b2dab7b4f9
Author: Daniel Espinosa <esodan gmail com>
Date: Fri Jul 5 14:06:22 2019 -0500
Namespace: removed deprecated interface
gxml/Namespace.vala | 49 --------------
gxml/XDocument.vala | 4 +-
gxml/XElement.vala | 19 +++---
gxml/XListNamespaces.vala | 160 ----------------------------------------------
gxml/XNamespace.vala | 45 -------------
gxml/XPath.vala | 14 +++-
gxml/meson.build | 3 -
7 files changed, 23 insertions(+), 271 deletions(-)
---
diff --git a/gxml/XDocument.vala b/gxml/XDocument.vala
index 623d845..888970b 100644
--- a/gxml/XDocument.vala
+++ b/gxml/XDocument.vala
@@ -358,8 +358,8 @@ public class GXml.XDocument : GXml.XNode,
* {@link XPathContext} implementation.
*/
public GXml.XPathObject evaluate (string expression,
- Gee.List<GXml.Namespace>? resolver = null)
- throws GXml.XPathError
+ Gee.Map<string,string>? resolver = null)
+ throws GXml.XPathObjectError
{
XPathObject nullobj = null;
if (document_element == null)
diff --git a/gxml/XElement.vala b/gxml/XElement.vala
index b4da56c..ff8ee19 100644
--- a/gxml/XElement.vala
+++ b/gxml/XElement.vala
@@ -330,8 +330,8 @@ public class GXml.XElement : GXml.XNonDocumentChildNode,
* {@inheritDoc}
*/
public GXml.XPathObject evaluate (string expression,
- Gee.List<GXml.Namespace>? resolver = null)
- throws GXml.XPathError
+ Gee.Map<string,string>? resolver = null)
+ throws GXml.XPathObjectError
{
GXml.XPathObject nullobj = null;
if (!(this is GXml.DomNode))
@@ -340,14 +340,15 @@ public class GXml.XElement : GXml.XNonDocumentChildNode,
var ndoc = Xml.Parser.read_memory (data, data.length);
var gdoc = new GXml.XDocument.from_doc (ndoc);
var context = new Xml.XPath.Context (ndoc);
- if (resolver != null)
- resolver.foreach (ns => {
- int res = context.register_ns (ns.prefix, ns.uri);
- if (res != 0) {
- GLib.warning (_("invalid namespace. Code: ")+res.to_string ());
+ if (resolver != null) {
+ foreach (string prefix in resolver.keys) {
+ var uri = resolver.get (prefix);
+ int res = context.register_ns (prefix, uri);
+ if (res != 0) {
+ throw new XPathObjectError.INVALID_NAMESPACE_ERROR (_("invalid namespace. Code: %s"),
res.to_string ());
+ }
}
- return true;
- });
+ }
return new GXml.LXPathObject (gdoc, context.eval (expression));
}
}
diff --git a/gxml/XPath.vala b/gxml/XPath.vala
index 23d897c..e95e15b 100644
--- a/gxml/XPath.vala
+++ b/gxml/XPath.vala
@@ -71,14 +71,22 @@ public interface GXml.XPathContext : GLib.Object {
/**
* Evaluate XPath expression.
*
- * This method evaluates provided expression, registers provided namespaces in resolver and returns an
{@link GXml.XPathObject}.
+ * This method evaluates provided expression, registers provided namespaces
+ * in resolver and returns an {@link GXml.XPathObject}.
+ *
+ * Resolver is a map where its key is the namespace's prefix and
+ * its value is the namespace's URI
*
* Throw {@link GXml.XPathError} if one of provided namespaces is invalid.
*/
public abstract GXml.XPathObject evaluate (string expression,
- Gee.List<GXml.Namespace>? resolver = null)
- throws GXml.XPathError;
+ Gee.Map<string,string>? resolver = null)
+ throws GXml.XPathObjectError;
+
+}
+public errordomain GXml.XPathObjectError {
+ INVALID_NAMESPACE_ERROR
}
public interface GXml.XPathObject : GLib.Object {
diff --git a/gxml/meson.build b/gxml/meson.build
index 52da5f8..ca3d78b 100644
--- a/gxml/meson.build
+++ b/gxml/meson.build
@@ -68,7 +68,6 @@ valasources = files ([
'gxml-init.vala',
'HTMLCollection.vala',
'LXPathObject.vala',
- 'Namespace.vala',
'NodeType.vala',
'Parser.vala',
'SettableTokenList.vala',
@@ -84,8 +83,6 @@ valasources = files ([
'XHashMapAttr.vala',
'XHtmlDocument.vala',
'XListChildren.vala',
- 'XListNamespaces.vala',
- 'XNamespace.vala',
'XNode.vala',
'XParser.vala',
'XPath.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]