Commit 700dacec authored by Jonas Waeber's avatar Jonas Waeber

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

parent c3b58fa8
Pipeline #21411 passed with stages
in 4 minutes and 17 seconds
......@@ -165,17 +165,17 @@ class SAXContentHandler(
}
if (innerElements.isEmpty()) {
if (currentElementContent.isNotEmpty()) {
when (val item = jsonResult[currentElementTag]){
when (val item = jsonResult[currentElementTag]) {
null -> jsonResult[currentElementTag] = currentElementContent
is JsonArray<*> -> jsonResult[currentElementTag] = item + currentElementContent
else -> jsonResult[currentElementTag] = JsonArray(item, currentElementContent)
is List<*> -> jsonResult[currentElementTag] = item + listOf(currentElementContent)
else -> jsonResult[currentElementTag] = listOf(item, currentElementContent)
}
}
} else {
when (val item = jsonResult[currentElementTag]) {
null -> jsonResult[currentElementTag] = innerElements.toMap()
is JsonArray<*> -> jsonResult[currentElementTag] = item + innerElements.toMap()
else -> jsonResult[currentElementTag] = JsonArray(item, innerElements.toMap())
is List<*> -> jsonResult[currentElementTag] = item + listOf(innerElements.toMap())
else -> jsonResult[currentElementTag] = listOf(item, innerElements.toMap())
}
innerElements.clear()
}
......
......@@ -39,7 +39,6 @@ class LocalTestRun {
"identifierMain",
0, 0, 0, 0
)
@Test
@Disabled
fun `test single item`() {
......@@ -47,9 +46,8 @@ class LocalTestRun {
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\"}"
"{\"format\" : \"XML\", \"path\" : \"/home/jonas/memobase/data/snp-001/info%3Afedora%2Fmemobase%3AFonoteca-18BD1012%5FB3.xml\"}"
val message = Message.fromJson(input)[0]
val items = transformer.applyXSLT(
......
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