Skip to content
Aaron S. Hawley edited this page Sep 5, 2018 · 6 revisions

These are frequently asked questions about the Scala XML library that aren't already in the Introduction to Scala XML and the Getting started guide.

How long has Scala supported XML?

From the beginning, Scala has supported XML literals, pattern matching and queries as early as 2004 to 2006 in the 1.x series of Scala.

How long has the XML library been separate from the compiler?

Since version 2.11.0 of the Scala compiler, the Scala XML library has been developed and published separately from the compiler.

Why is the XML library no longer part of the compiler?

To make the compiler less monolithic and more modular, various components that had been developed alongside the compiler were separated out for 2.11 and called "modules". This included the XML library, but also included the Scala Swing, Scala continuations and Scala parser combinators. At the time, making them optional modules helped reduce the size of the Scala library's JAR file by 20%.

Why does the Scala compiler still depend on the Scala XML library?

The Scaladoc feature in the compiler still requires the Scala XML library, even though it is developed and published separately.

In Scala 2.12 and earlier, regardless of whether you included scala-xml as a dependency or not, you could use scala-xml from the console in sbt. This was fixed in Scala 2.13, but was also fixed in sbt 1.1.2 and later for all version of Scala (2.11 and later).

Can I use a different version of Scala XML from the Scala compiler?

Yes, a library or any Scala program can use a different version of Scala XML from the version that the Scala compiler depends on.

As of July 2018, any version of scala-xml up to 1.1.0 is still source-compatible to Scala 2.11. The compiler doesn't bother changing its version of scala-xml after the first release in the major version series. Scala 2.11 depends on 1.0.5, but you can use a later version. Scala 2.12 depends on 1.0.6, but you can use a later (or earlier) version.

What will be changing for XML in Scala 3 (code named "Dotty")?

As of July 2018, Scala 3 will provide XML string interpolation via a scala-xml-quote module.

Will Scala 3 (code named "Dotty") support XML literals?

No, to simplify the Scala parser and compiler and the language definition, the XML literal support will be dropped in Scala 3. As of June 2018, XML literals are still not removed from the Dotty code base.

What will happen with scala-xml in Scala 3 ("Dotty")?

There will no longer be possible for scala-xml to provide XML literal "support" in Scala 3.x. The proposed XML string interpolation will be an optional module in Scala 3.x to provide type checked XML strings as an alternative to XML literals in Scala 2.x. As of July 2018, the XML string interpolation module still has a dependency on the scala-xml library. As of July 2018, the scala-xml library is still a direct dependency in the Dotty compiler code base, as well, but it will be ripped out any day now.

Clone this wiki locally