summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2020-03-26 09:17:13 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2020-03-26 09:17:13 +0100
commitf974215e759a3ecf9d5b65a3f396696aa03e548c (patch)
treeedae0a46be9b29191da5f0380de7132fc8165912 /util
parented631099da00ece0d1ddf058f06d753200748470 (diff)
downloadlibeufin-f974215e759a3ecf9d5b65a3f396696aa03e548c.tar.gz
libeufin-f974215e759a3ecf9d5b65a3f396696aa03e548c.tar.bz2
libeufin-f974215e759a3ecf9d5b65a3f396696aa03e548c.zip
String-picking XPath helper.
Diffstat (limited to 'util')
-rw-r--r--util/src/main/kotlin/XMLUtil.kt13
1 files changed, 8 insertions, 5 deletions
diff --git a/util/src/main/kotlin/XMLUtil.kt b/util/src/main/kotlin/XMLUtil.kt
index 7ce6a3b3..1e095869 100644
--- a/util/src/main/kotlin/XMLUtil.kt
+++ b/util/src/main/kotlin/XMLUtil.kt
@@ -90,9 +90,7 @@ class XMLUtil private constructor() {
throw Exception("invalid EBICS XML signature URI: '${myRef.uri}'")
val xp: XPath = XPathFactory.newInstance().newXPath()
val nodeSet = xp.compile("//*[@authenticate='true']/descendant-or-self::node()").evaluate(
- myRef.here
- .ownerDocument, XPathConstants
- .NODESET
+ myRef.here.ownerDocument, XPathConstants.NODESET
)
if (nodeSet !is NodeList)
throw Exception("invalid type")
@@ -409,9 +407,14 @@ class XMLUtil private constructor() {
return valResult
}
- fun evalXpath(doc: Document, query: String): Node? {
+ fun getNodeFromXpath(doc: Document, query: String): Node? {
val xpath = XPathFactory.newInstance().newXPath()
- return xpath.evaluate(query, doc, XPathConstants.NODE) as Node
+ return xpath.evaluate(query, doc, XPathConstants.NODE) as Node?
+ }
+
+ fun getStringFromXpath(doc: Document, query: String): String? {
+ val xpath = XPathFactory.newInstance().newXPath()
+ return xpath.evaluate(query, doc, XPathConstants.STRING) as String?
}
}
}