I noticed that it scala.xml.Atomaccepts a type parameter A, although all its subclasses extend Atom[String], and the documentation says: "The Atom class provides an XML node for text (PCDATA)."
Are there any legitimate use cases for an Atom instance with a type parameter other than a string?
More specifically, I am interested in using the Scala XML literal to define a kind of DSL to define the structure of a tree-based document in which many of the nodes will exist in the Scala class. It would be nice to use <document>{new JButton("Hi")}</document>and access non-textual data Atom[JButton]without having to define an XML serialization scheme for each existing class.
Is this a legitimate use case, or am I abusing the current implementation of the Scala XML library?
source
share