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.
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).
<a>Sounds
<tag/> good</a>.text
evaluates to "Sounds good
".
<a><b>Hi!</b></a> \
"b" text
evaluates to "Hi!
".
<employee
name="Tom"> \ "@name"
evaluates to "Tom
".
<a>Sounds
<tag/> {str}</a>.text
evaluates to "Sounds bad
"
where val
str = "bad"
.
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:
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:
scalac
, the Scala compiler, has no XML support.
scaladoc
, the Scala documentation tool, is not available anymore.
scala.xml
, the XML library package, is not available anymore.
scala.actors
, the Actor library package, is made available
separately in file scala-actors.jar
.
sbaz
-ready.
Please send your feedback or report issues directly to the author and not to the Scala project team.
In part 1 we give an overview of the project modifications/additions and in part 2 we briefly present the build process.
Two parts of the Scala source repository actually rely on the native XML support: [↑]
scaladoc
, compiler-plugin
and partest
.
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
).
org.w3c.dom
) where required.
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.
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
.