shuttle
shuttle

Reputation: 153

Anti-XML scala hides xml attribute

Anti-xml will be the successor xml library in Scala. But I have found something that quirks.

Input

package com.twitter.sample
import com.codecommit.antixml._

object ReadingNamespaceXml extends Application{

  val xml = <tra:route xmlns:tra="trace">
              <spo:id xmlnls:spo="sport">23232322</spo:id>
              <tra:service ref="go" xsi:type="ref:manualService" xmlns:ref="ServiceRef"/>
            </tra:route>.convert

  val route =  xml \ "route"
  Console println route.unselect
}

Output:

  <tra:route>
  <spo:id xmlnls:spo="sport">23232322</spo:id>
  <tra:service xsi:type="ref:manualService" ref="go"/>
  </tra:route>

So, the input xml and the output are not the same. Why?

Upvotes: 2

Views: 284

Answers (1)

Travis Brown
Travis Brown

Reputation: 139048

The answer is just that this is a bug.

Fortunately there's an easy fix. I don't know the full story on Anti-XML, but Daniel Spiewak no longer seems to be maintaining it—his repo hasn't been touched in years and is still on Scala 2.9.1. There is however a fork (by a company called Arktekk) that fixes this bug, has builds for 2.10, etc. It's also available from Maven Central. I know nothing about Arktekk, but I've been happily using this fork for a while.

To prove that it works, here's a reduced example using the old 0.3 release:

scala> import com.codecommit.antixml._
import com.codecommit.antixml._

scala> <foo ref="bar" xmlns:ref="baz"/>.convert
res0: com.codecommit.antixml.Elem = <foo ref="bar"/>

And now with Arktekk's 0.5.1:

scala> import com.codecommit.antixml._
import com.codecommit.antixml._

scala> <foo ref="bar" xmlns:ref="baz"/>.convert
res0: com.codecommit.antixml.Elem = <foo xmlns:ref="baz" ref="bar"/>

Which is what you'd expect.

Upvotes: 5

Related Questions