Packages

class XMLToScala extends AnyRef

This class uses Scala reflection to parse XML into user-defined case classes.

The effect is that the classes encode the XML grammar, and the parser picks the corresponding class for each XML tag. This is kind of the opposite of generating a parser, where the grammar is fixed and the classes are generated.

Source
XMLToScala.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. XMLToScala
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new XMLToScala(pkg: String)

    pkg

    the full name of the package in which the case classes are declared An XML node is parsed into a case class instance as follows * the case class whose name is the tag name is used except that * XML - is treated as Scala _ * XML names that are Scala reserved words are prefixed by 'XML' in Scala * the arguments to the class (technically: the single apply method of the companion object) are computed as follows: * k: String: the value of the attribute with key s, or the content of the child with tag k, ("" if neither present) * k: Int: accordingly * k: Boolean: accordingly (false if not present) * t: A where A is one the case classes: recursive call on the single child of the child with tag t * t: Option[A]: accordingly, but the child may be absent * t: List[A]: accordingly but the child may have any number of children * t: G <: Group: All arguments of G are computed and an instance of G constructed. * _a: A, Option[A], List[A] (where A may be a subtype of Group): like the t-cases above but taking the next available child(ren) of type A Effectively, all fields of G are imported into the current case class. The type A does not have to be a case class, e.g., the elements in a list can have the tags of subclasses of A.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply(node: Node): Any

    parse a Node

  5. def apply(file: File): Any

    read and parse a file

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. def scalaName(s: String): String

    convert xml tag/key names to Scala id names

  18. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  23. def xmlName(s: String): String

    convert Scala id names to xml tag/key names

Inherited from AnyRef

Inherited from Any

Ungrouped