XML-free Scala

by Stephane Micheloud, September 2011

[Home]
[Back]

In this article we report on the removal of the native XML support from the official Scala software distribution; the XML-free distribution is available for versions 2.8.2.final, 2.9.1.final and revision rdev-4107-2012-01-02-g008a781 of the Scala source repository.

We initiated this project on the behalf of an internet company based in California who uses Scala for software development and is not interested in native XML support. Martin Odersky, the creator of the language Scala, confides himself about that features in a recent TechWorld interview on the roots of Scala.

Scala and XML

XML literals can appear anywhere in Scala code where an expression is valid. The XML content is introduced by a start tag and is terminated by the corresponding end tag (XML tags trigger the Scala compiler to enter/exit the XML-input mode).

For illustration we list here a few operations on XML expressions (SLS Ch.10):

Note: Scala does not support XML declarations, CDATA sections or processing instructions (SLS Ch.10).

For further reading on XML support in Scala see either the articles:

or read the related chapters of the following Scala books:

XML-Free Distribution

The XML-free software distribution was generated from the SVN project scala-noxml (more details at the end of this article). It differs from the original Scala software distribution as follows:

Version Archives Checksums
2.8.2.final scala-noxml-2.8.2.final.tgz 16 MB .md5
scala-noxml-2.8.2.final.zip 16 MB .md5
scala-noxml-2.8.2.final-devel-docs.tgz 12 MB .md5
2.9.1.final scala-noxml-2.9.1.final.tgz 20 MB .md5
scala-noxml-2.9.1.final.zip 20 MB .md5
scala-noxml-2.9.1.final-devel-docs.tgz 17 MB .md5
SVN trunk scala-noxml-2.10.0.rdev-4107-2012-01-02-g008a781.tgz 22 MB .md5
scala-noxml-2.10.0.rdev-4107-2012-01-02-g008a781.zip 22 MB .md5
scala-noxml-2.10.0.rdev-4107-2012-01-02-g008a781-devel-docs.tgz 18 MB .md5

Please send your feedback or report issues directly to the author and not to the Scala project team.

References

  1. The Scala Language Specification (SLS), Version 2.8
    Martin Odersky, November 2010

About the Author

Stephane's Picture
Stéphane Micheloud is a senior software engineer. He holds a Ph.D in computer science from EPFL and a M.Sc in computer science from ETHZ. At EPFL he worked on distributed programming and advanced compiler techniques and participated for over six years to the Scala project. Previously he was professor in computer science at HES-SO // Valais in Sierre, Switzerland.
[Top]

Other Articles

[Top]

Technical Notes

In part 1 we give an overview of the project modifications/additions and in part 2 we briefly present the build process.

  1. Two parts of the Scala source repository actually rely on the native XML support: []

    • the 3 tools scaladoc, compiler-plugin and partest.
    • ~70 test cases of the Scala test suite

    The Scala documentation tool (aka. scaladoc) heavily rely on the native XML support of Scala and it would be a challenging task to build the official Scala software distribution without it; for that reason we delegate the generation of the HTML documentation to the so-called STARR compiler.

    The scaladoc tool is thus removed from the XML-free software distribution and test cases using XML are simply excluded from the test suite.

    We enumerate here only the main modifications/additions (see also changes in the SVN project scala-noxml).

    • We delimit source code regions relying on native XML support with special marker comments and provide alternative code (based on the Java package org.w3c.dom) where required.
    • We duplicate the original Ant build script and slightly modify it to generate an XML-free Scala software distribution.
    • We provide auxiliary files containing the Scala source files to be excluded resp. filtered (compiler, library and test suite) before starting the build.

    The additional project files are:

    2.9.x/build-noxml.xml
    2.9.x/src/build/noxml/compiler.excludes
    2.9.x/src/build/noxml/compiler.filters
    2.9.x/src/build/noxml/jvmtests.excludes
    2.9.x/src/build/noxml/library.excludes
    2.9.x/src/build/noxml/library.filters
    2.9.x/src/build/noxml/negtests.excludes
    2.9.x/src/build/noxml/pack-noxml.xml
    2.9.x/src/build/noxml/partest.filters
    2.9.x/src/build/noxml/postests.excludes
    2.9.x/src/build/noxml/runtests.excludes

    The above list contains two Ant scripts:

    • build-noxml.xml adds the two targets enable.xml and disable.xml to toggle on/off the XML-specific marker comments in the Scala source files.
    • pack-noxml.xml simply drops the command scripts for the scaladoc tool.
  2. The above project configuration makes it possible to build either the official Scala distribution or the XML-free Scala distribution using the same code base.

    • Full Scala distribution

      [2.9.x]$ ant dist-opt distpack-opt
    • Scala distribution with no XML support

      [2.9.x]$ ant -f build-noxml.xml disable.xml
      [2.9.x]$ ant -f build-noxml.xml dist-opt distpack-opt
      [2.9.x]$ ant -f build-noxml.xml enable.xml

    The build process takes 25-30 minutes depending on your hardware configuration and the generated archive files (.tgz, .zip, etc.) can be found in the output directory dists/archives.