Node

object Node

This singleton object contains a DSL to easily create deeply nested Elems. It looks a lot like the DSL for NodeBuilders, using the same method names (so a local import for Node singleton object members may be needed).

This singleton object contains a DSL to easily create deeply nested Elems. It looks a lot like the DSL for NodeBuilders, using the same method names (so a local import for Node singleton object members may be needed).

There is a catch, though. When using this DSL, scopes must be passed throughout the tree. These Scopes should typically be the same (or parent element scopes should be subscopes of child element scopes), because otherwise the corresponding XML may contain a lot of namespace undeclarations.

Another thing to watch out for is that the "tree representations" conform to the NodeBuilder DSL, not to this one.

In summary, the NodeBuilder DSL does have the advantage over this DSL that scopes do not have to be passed around. On the other hand, this Node DSL has the advantage that exceptions due to missing scope data are thrown immediately instead of later (when calling the build method, in the case of the NodeBuilder DSL).

For example:

import Node._

val scope = Scope.from("dbclass" -> "http://www.db-class.org")

elem(
 qname = QName("dbclass:Magazine"),
 attributes = Vector(QName("Month") -> "February", QName("Year") -> "2009"),
 scope = scope,
 children = Vector(
   elem(
     qname = QName("dbclass:Title"),
     scope = scope,
     children = Vector(text("Newsweek")))))

The latter expression could also be written as follows:

elem(
 qname = QName("dbclass:Magazine"),
 attributes = Vector(QName("Month") -> "February", QName("Year") -> "2009"),
 scope = scope,
 children = Vector(
   textElem(QName("dbclass:Title"), scope, "Newsweek")))
Companion
class
class Object
trait Matchable
class Any

Value members

Concrete methods

def cdata(textValue: String): Text
def comment(textValue: String): Comment
def elem(qname: QName, scope: Scope, children: IndexedSeq[Node]): Elem
def elem(qname: QName, attributes: IndexedSeq[(QName, String)], scope: Scope, children: IndexedSeq[Node]): Elem
def emptyElem(qname: QName, scope: Scope): Elem
def emptyElem(qname: QName, attributes: IndexedSeq[(QName, String)], scope: Scope): Elem
def entityRef(entity: String): EntityRef
def from(n: Node): Node

Converts any element, text, comment, PI or entity reference ScopedNodes.Node to a "simple" Node.

Converts any element, text, comment, PI or entity reference ScopedNodes.Node to a "simple" Node.

def from(node: Node, scope: Scope): Node

Converts any element, text, comment, PI or entity reference ClarkNodes.Node to a "simple" Node, given a Scope needed for computing QNames from ENames (of elements and attributes). The passed Scope must not contain the default namespace.

Converts any element, text, comment, PI or entity reference ClarkNodes.Node to a "simple" Node, given a Scope needed for computing QNames from ENames (of elements and attributes). The passed Scope must not contain the default namespace.

Preferably the passed Scope is invertible.

def processingInstruction(target: String, data: String): ProcessingInstruction
def text(textValue: String): Text
def textElem(qname: QName, scope: Scope, txt: String): Elem
def textElem(qname: QName, attributes: IndexedSeq[(QName, String)], scope: Scope, txt: String): Elem