Commit c3b58fa8 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix issue where elements beyond number three were not added properly.

parent 3eb9c8f7
Pipeline #21399 passed with stages
in 4 minutes and 57 seconds
......@@ -144,7 +144,6 @@ class SAXContentHandler(
}
if (recordTag == localName)
return
if (currentElementTag == "") {
currentElementTag = localName
......@@ -168,14 +167,14 @@ class SAXContentHandler(
if (currentElementContent.isNotEmpty()) {
when (val item = jsonResult[currentElementTag]){
null -> jsonResult[currentElementTag] = currentElementContent
is JsonArray<*> -> item + currentElementContent
is JsonArray<*> -> jsonResult[currentElementTag] = item + currentElementContent
else -> jsonResult[currentElementTag] = JsonArray(item, currentElementContent)
}
}
} else {
when (val item = jsonResult[currentElementTag]) {
null -> jsonResult[currentElementTag] = innerElements.toMap()
is JsonArray<*> -> item + innerElements.toMap()
is JsonArray<*> -> jsonResult[currentElementTag] = item + innerElements.toMap()
else -> jsonResult[currentElementTag] = JsonArray(item, innerElements.toMap())
}
innerElements.clear()
......
......@@ -18,7 +18,6 @@
package org.memobase.test
import ch.memobase.settings.HeaderMetadata
import com.beust.klaxon.Klaxon
import java.io.File
import java.io.FileOutputStream
import org.junit.jupiter.api.Disabled
......@@ -41,6 +40,28 @@ class LocalTestRun {
0, 0, 0, 0
)
@Test
@Disabled
fun `test single item`() {
val folder = "/home/jonas/memobase/data/snp-001"
val transformFile = "/config/transform.xslt"
val xslt = File(folder + transformFile).readBytes()
val transformer = XMLTransformer()
val input =
"{\"format\" : \"XML\", \"path\" : \"/home/jonas/memobase/data/snp-001/info%3Afedora%2Fmemobase%3AFonoteca-18BD1047%5FA29.xml\"}"
val message = Message.fromJson(input)[0]
val items = transformer.applyXSLT(
"",
headerMetadata,
File(message.path).inputStream(),
xslt
)
val output = items.second.output
println(output)
}
@Test
@Disabled
fun `test local folder`() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment