Home > database >  Correct way to create TransformerFactory.newInstance().newTransformer() using Gradle Kotlin DSL
Correct way to create TransformerFactory.newInstance().newTransformer() using Gradle Kotlin DSL

Time:09-26

How do I resolve this error?

Transformer -> 2 type arguments expected for interface Transformer<OUT : Any!, IN : Any!>

Code:

..
var liquibaseChangelog: File = File("${project.rootProject.projectDir}/src/main/resources/config/liquibase/changelog/changelog-root.xml")

val source: Source = DOMSource(doc)
val result = StreamResult(FileWriter(liquibaseChangelog))

val transformer: Transformer = TransformerFactory.newInstance().newTransformer() // Error on `Transformer`
transformer.setOutputProperty(OutputKeys.INDENT, "yes")
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2")

CodePudding user response:

Split across lines:

val transformerFactory = TransformerFactory.newInstance()
val transformer = transformerFactory.newTransformer()
  • Related