gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated (f3ad293 -> ed63109)


From: gnunet
Subject: [libeufin] branch master updated (f3ad293 -> ed63109)
Date: Thu, 26 Mar 2020 09:10:29 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository libeufin.

    from f3ad293  cli requests c53 transactions collection
     new 6f1d7f3  Simple XPath test case.
     new ed63109  Solve XPath problem with namespaces.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nexus/src/test/kotlin/XPathTest.kt | 44 ++++++++++++++++++++++++++++++++++++++
 util/src/main/kotlin/XMLUtil.kt    |  4 ++--
 2 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 nexus/src/test/kotlin/XPathTest.kt

diff --git a/nexus/src/test/kotlin/XPathTest.kt 
b/nexus/src/test/kotlin/XPathTest.kt
new file mode 100644
index 0000000..2e796fa
--- /dev/null
+++ b/nexus/src/test/kotlin/XPathTest.kt
@@ -0,0 +1,44 @@
+package tech.libeufin.nexus
+
+import org.junit.Test
+import org.w3c.dom.Document
+import org.w3c.dom.Node
+import tech.libeufin.util.XMLUtil
+
+
+class XPathTest {
+
+    @Test
+    fun pickDataFromSimpleXml() {
+        val xml = """
+            <root xmlns="foo">
+              <node>lorem ipsum</node>
+            </root>""".trimIndent()
+        val doc: Document = XMLUtil.parseStringIntoDom(xml)
+        val node = XMLUtil.evalXpath(doc, "/*[local-name()='root']")
+        assert(node != null)
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/util/src/main/kotlin/XMLUtil.kt b/util/src/main/kotlin/XMLUtil.kt
index d7e1563..7ce6a3b 100644
--- a/util/src/main/kotlin/XMLUtil.kt
+++ b/util/src/main/kotlin/XMLUtil.kt
@@ -409,9 +409,9 @@ class XMLUtil private constructor() {
             return valResult
         }
 
-        fun getStringViaXpath(doc: Document, query: String): String {
+        fun evalXpath(doc: Document, query: String): Node? {
             val xpath = XPathFactory.newInstance().newXPath()
-            return xpath.compile(query).evaluate(doc, 
XPathConstants.STRING).toString()
+            return xpath.evaluate(query, doc, XPathConstants.NODE) as Node
         }
     }
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]