Joerg Schmuecker
2016-07-27 21:13:26 UTC
I looked at some examples on how to transform XML on a node by node level
and ended up looking at https://gist.github.com/zentrope/728034.
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>
n.tmap
{ case Elem(ns, "a", attribs, scope, kids @ _*) =>
<features>
{ features map { d => <feature id={d}/> } }
</features>
case other => other
}
Similar we could implement foldDF for a depth first fold and other functors.
and ended up looking at https://gist.github.com/zentrope/728034.
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>
n.tmap
{ case Elem(ns, "a", attribs, scope, kids @ _*) =>
<features>
{ features map { d => <feature id={d}/> } }
</features>
case other => other
}
Similar we could implement foldDF for a depth first fold and other functors.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.