scala xml rewrite rule (or, simple pattern help)

Posted by williamstw on Stack Overflow See other posts from Stack Overflow or by williamstw
Published on 2010-05-29T14:21:22Z Indexed on 2010/05/29 14:22 UTC
Read the original article Hit count: 197

Filed under:
|

I'm missing some fairly simple syntax I gather. I'm trying to rewrite an element label to something else and keep everything else intact.

object htmlRule extends RewriteRule {
 override def transform(n: Node): Seq[Node] = n match {
   case Elem(prefix, "document", attribs, scope, child@_*)  =>
     Elem(prefix, "html", attribs, scope, child)
   case other => other
 }
}

Now, I ask for an explanation of two things:

1) What exactly does "child@_*" mean in plain English?

2) How can I capture the value of "child@_*" and just let it pass right through to the new element? Currently, I get the following error, which makes sense.

[error]  found   : Seq[scala.xml.Node]
[error]  required: scala.xml.Node
[error]       Elem(prefix, "html", attribs, scope, child)

I'm not wedded to this either, so if there's a better way to simply change the element name of a specific node, let's here it...

Thanks, --tim

© Stack Overflow or respective owner

Related posts about Xml

Related posts about scala