I am trying to remove an attribute with prefix in Scala using a RuleTransformer.
While the following works with unprefixed attributes:
val xml = <foo><bar attr="attval">content</bar></foo>
val rw1 = new RewriteRule {
override def transform(n: Node) = n match {
case Elem(null, "bar", a, s, children @ _*) =>
Elem(null, "bar", a.remove("attr"), TopScope, children: _*)
case x => x
}
}
val rt = new RuleTransformer(rw1)
rt(xml)
I do not succeed doing this with a prefixed attribute (note that attribute "attr" of the "bar" element has the prefix "pre"):
val xml = <foo><bar pre:attr="attval">content</bar></foo>
val rw1 = new RewriteRule {
override def transform(n: Node) = n match {
case Elem(null, "bar", a, s, children @ _*) =>
Elem(null, "bar", a.remove("attr"), TopScope, children: _*)
case x => x
}
}
val rt = new RuleTransformer(rw1)
rt(xml)
I was trying to use
a.remove("pref",TopScope,"attr")
as defined by
MetaData.remove(namespace: String, scope: NamespaceBinding, key: String)
without any success.
I am a Scala beginner, so bear with me if this is a trivial issue.