
com.mle.appbundler.XmlWriter.scala Maven / Gradle / Ivy
The newest version!
package com.mle.appbundler
import java.nio.file.Path
import com.mle.file.FileUtilities
import com.mle.util.Log
import scala.xml.{Node, PrettyPrinter}
/**
* @author Michael
*/
trait XmlWriter extends Log{
def prefix: String = decl()
def decl(enc: String = "UTF-8") = s"\n"
def writePretty(xml: Node, dest: Path) = FileUtilities.writerTo(dest)(w => {
w.println(stringify(xml))
log info s"Wrote $dest"
})
def stringify(xml: Node): String = {
val printer = new PrettyPrinter(1000, 2)
val payload = printer format xml
prefix + payload
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy