Is there are more functional way to transform XML than using RewriteRule and RuleTransformer?

Skip to first unread message

Joerg Schmuecker

Jul 27, 2016, 5:13:26 PM7/27/16
to scala-language
I looked at some examples on how to transform XML on a node by node level and ended up looking at

I find this a very boiler plate heavy and rather object oriented way of doing this. I would prefer to have something more functional. For example, I can imagine that there is a function defined on scala.xml.Node called tmap that takes a f : ( Node ) => Seq[Node] and applies across the whole tree under the original node.

val n = <a><b>Text</b></a>

{ case Elem(ns, "a", attribs, scope, kids @ _*) =>  
{ features map { d => <feature id={d}/> } }

case other => other

Similar we could implement foldDF for a depth first fold and other functors.
Reply all
Reply to author
0 new messages