如何保存Scala RuleTransformer的Seq [Node]结果?

时间:2016-07-29 19:04:17

标签: xml scala

我有一些RewriteRules,这个RuleTransformer非常适用。但是,RuleTransformer返回Seq [Node],scala.xml.XML.save需要Node类型。如何解决?

  // load transformers for content type
  val transformer = Articles.getTransformer()

  // apply transformation
  val newXml = transformer.transform(xml)

  // save modified xml
  val filenamelNormalized = arg.replaceFirst(".xml", "_normalized.xml")
  scala.xml.XML.save(filenamelNormalized, newXml, "utf-8", true)

编译器输出:

4. Waiting for source changes... (press enter to interrupt)
[info] Compiling 1 Scala source to /sites/tools/janssenXmlNormalizer/target/scala-2.11/classes...
[error] /sites/tools/janssenXmlNormalizer/src/main/scala/com/mcl/janssen/Normalizer.scala:34: type mismatch;
[error]  found   : Seq[scala.xml.Node]
[error]  required: scala.xml.Node
[error]       scala.xml.XML.save(filenamelNormalized, newXml, "utf-8", true)
[error]                                               ^

0 个答案:

没有答案