final class Document extends DocumentApi with Immutable with Serializable
Document
. Although at first sight the document root element seems to be the root node, this is not entirely true.
For example, there may be comments at top level, outside the document root element.
The document is itself not a Node
. This choice has the following advantages:
- Documents are indeed prevented (at compile-time) from occurring as "child nodes"
- The API is cleaner. For example, (unlike "elements") document methods like
toTreeRepr
should not be passed a parent scope. By not considering a Document a Node, it is more visible that parent scopes are irrelevant for Documents, unlike for "elements".
A Document
is constructed from an optional URI, an optional XML declaration, a document element (as Elem
), top-level processing instructions,
if any, and top-level comments, if any.
Note that class Document
does not have any query methods for Elem
instances. In particular, the ElemApi
does not
apply to documents. Therefore, given a document, querying for elements (other than the document element itself) always goes
via the document element.
- Annotations
- @SerialVersionUID()
- Alphabetic
- By Inheritance
- Document
- Serializable
- Serializable
- Immutable
- DocumentApi
- AnyDocumentApi
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Document(uriOption: Option[URI], xmlDeclarationOption: Option[XmlDeclaration], children: IndexedSeq[CanBeDocumentChild])
Type Members
-
type
DocElemType = Elem
The type of the document element.
The type of the document element.
- Definition Classes
- Document → AnyDocumentApi
-
type
ThisDoc = Document
The document type itself.
The document type itself. It must be restricted to a sub-type of the document API trait in question.
Concrete document classes will restrict this type to that document class itself.
- Definition Classes
- Document → DocumentApi → AnyDocumentApi
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
allComments: IndexedSeq[Comment]
Expensive method to obtain all comments, throughout the tree
-
def
allProcessingInstructions: IndexedSeq[ProcessingInstruction]
Expensive method to obtain all processing instructions, throughout the tree
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- val children: IndexedSeq[CanBeDocumentChild]
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- def comments: IndexedSeq[Comment]
-
val
documentElement: Elem
- Definition Classes
- Document → DocumentApi
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- def processingInstructions: IndexedSeq[ProcessingInstruction]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
Returns the tree representation string corresponding to this element, that is,
toTreeRepr
.Returns the tree representation string corresponding to this element, that is,
toTreeRepr
. Possibly expensive!- Definition Classes
- Document → AnyRef → Any
- def toTreeRepr(): String
-
def
transformElemsOrSelf(f: (Elem) ⇒ Elem): Document
Returns
withDocumentElement(this.documentElement.transformElemsOrSelf(f))
-
def
transformElemsToNodeSeq(f: (Elem) ⇒ IndexedSeq[Node]): Document
Returns
withDocumentElement(this.documentElement.transformElemsToNodeSeq(f))
-
def
updateElemOrSelf(path: Path, newElem: Elem): Document
Returns
withDocumentElement(this.documentElement.updateElemOrSelf(path, newElem))
-
def
updateElemOrSelf(path: Path)(f: (Elem) ⇒ Elem): Document
Returns
withDocumentElement(this.documentElement.updateElemOrSelf(path)(f))
. -
def
updateElemWithNodeSeq(path: Path, newNodes: IndexedSeq[Node]): Document
Returns
withDocumentElement(this.documentElement.updateElemWithNodeSeq(path, newNodes))
-
def
updateElemWithNodeSeq(path: Path)(f: (Elem) ⇒ IndexedSeq[Node]): Document
Returns
withDocumentElement(this.documentElement.updateElemWithNodeSeq(path)(f))
-
def
updateElemsOrSelf(paths: Set[Path])(f: (Elem, Path) ⇒ Elem): Document
Returns
withDocumentElement(this.documentElement.updateElemsOrSelf(paths)(f))
-
def
updateElemsWithNodeSeq(paths: Set[Path])(f: (Elem, Path) ⇒ IndexedSeq[Node]): Document
Returns
withDocumentElement(this.documentElement.updateElemsWithNodeSeq(paths)(f))
-
def
updateTopmostElemsOrSelf(f: (Elem, Path) ⇒ Option[Elem]): Document
Returns
withDocumentElement(this.documentElement.updateTopmostElemsOrSelf(f))
-
def
updateTopmostElemsWithNodeSeq(f: (Elem, Path) ⇒ Option[IndexedSeq[Node]]): Document
Returns
withDocumentElement(this.documentElement.updateTopmostElemsWithNodeSeq(f))
-
val
uriOption: Option[URI]
- Definition Classes
- Document → DocumentApi
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
withDocumentElement(newRoot: Elem): Document
Creates a copy, but with the new documentElement passed as parameter newRoot
-
def
withUriOption(newUriOption: Option[URI]): Document
Creates a copy, but with the new uriOption passed as parameter newUriOption
-
def
withXmlDeclarationOption(newXmlDeclarationOption: Option[XmlDeclaration]): Document
Creates a copy, but with the new xmlDeclarationOption passed as parameter newXmlDeclarationOption
- val xmlDeclarationOption: Option[XmlDeclaration]