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( ...@@ -144,7 +144,6 @@ class SAXContentHandler(
} }
if (recordTag == localName) if (recordTag == localName)
return return
if (currentElementTag == "") { if (currentElementTag == "") {
currentElementTag = localName currentElementTag = localName
...@@ -168,14 +167,14 @@ class SAXContentHandler( ...@@ -168,14 +167,14 @@ class SAXContentHandler(
if (currentElementContent.isNotEmpty()) { if (currentElementContent.isNotEmpty()) {
when (val item = jsonResult[currentElementTag]){ when (val item = jsonResult[currentElementTag]){
null -> jsonResult[currentElementTag] = currentElementContent null -> jsonResult[currentElementTag] = currentElementContent
is JsonArray<*> -> item + currentElementContent is JsonArray<*> -> jsonResult[currentElementTag] = item + currentElementContent
else -> jsonResult[currentElementTag] = JsonArray(item, currentElementContent) else -> jsonResult[currentElementTag] = JsonArray(item, currentElementContent)
} }
} }
} else { } else {
when (val item = jsonResult[currentElementTag]) { when (val item = jsonResult[currentElementTag]) {
null -> jsonResult[currentElementTag] = innerElements.toMap() null -> jsonResult[currentElementTag] = innerElements.toMap()
is JsonArray<*> -> item + innerElements.toMap() is JsonArray<*> -> jsonResult[currentElementTag] = item + innerElements.toMap()
else -> jsonResult[currentElementTag] = JsonArray(item, innerElements.toMap()) else -> jsonResult[currentElementTag] = JsonArray(item, innerElements.toMap())
} }
innerElements.clear() innerElements.clear()
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
package org.memobase.test package org.memobase.test
import ch.memobase.settings.HeaderMetadata import ch.memobase.settings.HeaderMetadata
import com.beust.klaxon.Klaxon
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Disabled
...@@ -41,6 +40,28 @@ class LocalTestRun { ...@@ -41,6 +40,28 @@ class LocalTestRun {
0, 0, 0, 0 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 @Test
@Disabled @Disabled
fun `test local folder`() { fun `test local folder`() {
...@@ -74,4 +95,4 @@ class LocalTestRun { ...@@ -74,4 +95,4 @@ class LocalTestRun {
} }
} }
} }
} }
\ No newline at end of file
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