Trait/Object

eu.cdevreeze.yaidom.simple

NodeBuilder

Related Docs: object NodeBuilder | package simple

Permalink

sealed trait NodeBuilder extends Immutable with Serializable

DSL to build Elems (or Documents) without having to pass parent Scopes around. For example:

import NodeBuilder._

elem(
  qname = QName("dbclass:Magazine"),
  attributes = Vector(QName("Month") -> "February", QName("Year") -> "2009"),
  namespaces = Declarations.from("dbclass" -> "http://www.db-class.org"),
  children = Vector(
    elem(
      qname = QName("dbclass:Title"),
      children = Vector(text("Newsweek"))))).build()

The latter expression could also be written as follows:

elem(
  qname = QName("dbclass:Magazine"),
  attributes = Vector(QName("Month") -> "February", QName("Year") -> "2009"),
  namespaces = Declarations.from("dbclass" -> "http://www.db-class.org"),
  children = Vector(
    textElem(QName("dbclass:Title"), "Newsweek"))).build()

There is an impedance mismatch between XML's scoping rules (which are top-down, from root to leaves) and "functional trees" (which are built bottom-up, from leaves to root). In the context of the Anti-XML library, Daniel Spiewak explained this impedance mismatch in https://github.com/djspiewak/anti-xml/issues/78. In yaidom, however, this impedance mismatch is far less severe. Yaidom distinguishes between eu.cdevreeze.yaidom.simple.Node and eu.cdevreeze.yaidom.simple.NodeBuilder, and eu.cdevreeze.yaidom.simple.Elem and eu.cdevreeze.yaidom.simple.ElemBuilder in particular. Elems have (fixed, resolved) Scopes, but ElemBuilders do not. Using NodeBuilders, Scope determination is postponed. Only ElemBuilders can have unbound prefixes, but only Elems have (resolved) scopes. Instead of a eu.cdevreeze.yaidom.core.Scope, an ElemBuilder has a eu.cdevreeze.yaidom.core.Declarations.

Another reason that the above-mentioned impedance mismatch is less of a problem in practice is that typically the XML trees (as NodeBuilders or directly as Nodes) are built in a top-down manner. The eu.cdevreeze.yaidom.simple.ConverterToDocuments in package convert recursively build Elems in a top-down manner, possibly creating an Elem instance (for each element) twice (first without children, and finally as a copy with children added).

When using NodeBuilders to create a Document, this Document typically contains no "ignorable whitespace". This may cause the Document not to be pretty-printed when using a (default) eu.cdevreeze.yaidom.print.DocumentPrinter to convert the Document to an XML string. See also the classes in package eu.cdevreeze.yaidom.print.

Linear Supertypes
Serializable, Serializable, Immutable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NodeBuilder
  2. Serializable
  3. Serializable
  4. Immutable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type NodeType <: Node

    Permalink

Abstract Value Members

  1. abstract def build(parentScope: Scope): NodeType

    Permalink

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. final def build(): NodeType

    Permalink

    Returns build(Scope.Empty)

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  17. final def toString(): String

    Permalink

    Returns toTreeRepr.

    Returns toTreeRepr.

    Definition Classes
    NodeBuilder → AnyRef → Any
  18. final def toTreeRepr(parentScope: Scope): String

    Permalink

    Returns the tree representation.

    Returns the tree representation. See the corresponding method in eu.cdevreeze.yaidom.simple.Node.

  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Immutable

Inherited from AnyRef

Inherited from Any

Ungrouped