This page is no longer maintained — Please continue to the home page at

XML design, part 1: compiler integration

No replies
Jürgen Purtz
Joined: 2009-12-03,
User offline. Last seen 1 year 44 weeks ago.

There is a close relationship between Scala compiler and XML literals. The
compiler recognise type and content of literals in the phase of value assignment
and during pattern matching. The XML vocabulary is widley understood by the

Literals for value assignment:
- XML declaration (<?xml ... ?>) is recognised as a processing instruction.
This compiles, but leads to a runtime error.
- Elements, attributes and namespaces are recognised. Ok.
- Start of CDATA: ok; End of CDATA: if missing, no error message.
- Well-formedness is recognised. Ok.
- Comments are recognised. Ok.
- Processing instructions are recognised. Ok.
- Entities are recognised. Ok.

Literals for pattern within match construct:
- XML declaration will not compile.
- Elements and namespaces are recognised. Ok. There are discussions about
correctness of namespace evaluation, see bug #2156.
- Attributes will not compile: see bug #2156
- CDATA: will not compile: Ok.
- Well-formedness is recognised. Ok.
- Comments will not compile.
- Processing instructions will not compile.
- Entities are recognised in compilation phase, but leads to wrong results
during execution.

One additional note: The "\" and "\\" operators are methodes of
scala.xml.NodeSeq. It's not a compiler feature.

My feeling is that the actual state (2.7.7) of the XML support of Scala compiler
is not perfect, but good enough for the near and mid future. In combination with
the "\" and "\\" operators many people can easily solve simple tasks.

Cheers, Jürgen

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland