Appends a given relative Path
to this Path
.
Appends a given relative Path
to this Path
. Alias for append(other)
.
Returns the ancestor-or-self paths, starting with this path, then the parent (if any), and ending with the root path
Returns the ancestor paths, starting with the parent path (if any), and ending with the root path
Appends a given relative Path
to this Path
Appends a given Entry
to this Path
Convenience method returning true if at least one entry has the given element name
Returns the element name (as EName) of the last path entry, if any, wrapped in an Option
Convenience method returning true if the last entry (if any) has the given element name
Returns ancestorOrSelfPaths find { path => p(path) }
Returns ancestorPaths find { path => p(path) }
Returns the first entry, if any, and throws an exception otherwise
Returns the first entry, if any, wrapped in an Option
Returns true if this is the root Path
, so if it has no entries
Returns the last entry, if any, and throws an exception otherwise
Returns the last entry, if any, wrapped in an Option
Like parentPathOption
, but unwrapping the result (or throwing an exception otherwise)
Gets the parent path (if any, because the root path has no parent) wrapped in an Option
.
Gets the parent path (if any, because the root path has no parent) wrapped in an Option
.
This method shows much of the reason why class Path
exists. If we know an element's Path
, and therefore its
parent Path
(using this method), then we can obtain the parent element by following the parent path from the
root of the tree.
Prepends a given Path
to this Path
Prepends a given Entry
to this Path
Convenience method returning true if the first entry (if any) has the given element name
Given an invertible Scope
, returns the corresponding canonical XPath, but modified for the root element (which is unknown in the Path
).
Given an invertible Scope
, returns the corresponding canonical XPath, but modified for the root element (which is unknown in the Path
).
The modification is that the root element is written as a slash followed by an asterisk.
See http://ns.inria.org/active-tags/glossary/glossary.html#canonical-path.
Like withoutFirstEntryOption
, but unwrapping the result (or throwing an exception otherwise)
Returns the Path
with the first path entry (if any) removed, wrapped in an Option
.
Unique identification of a descendant (or self)
Elem
given a rootElem
. It represents a unique path to an element, given a root element, independent of other types of nodes, as if the XML tree only consists of elements.In other words, a
Path
is a sequence of instructions, each of them stating how to get to a specific child element. Each such instruction is aPath.Entry
. So Paths do not contain the root element, and we can talk about Paths in isolation, without referring to any specific DOM-like tree.For example, consider the following XML:
Then the last name of the first author of the Scala book (viz. Odersky) has the following path:
or:
Path
instances are useful when navigating (see eu.cdevreeze.yaidom.queryapi.IsNavigable), and in "functional updates" (see eu.cdevreeze.yaidom.queryapi.UpdatableElemLike).An eu.cdevreeze.yaidom.core.Path corresponds to one and only one canonical path of the element (modulo prefix names), which is the corresponding (canonical) XPath expression. See http://ns.inria.org/active-tags/glossary/glossary.html#canonical-path. There is one catch, though. The
Path
does not know the root element name, so that is not a part of the corresponding canonical XPath expression. See the documentation of methodtoCanonicalXPath
.The
Path
contains anIndexedSeq
of path entries for a specific child element, grandchild element etc., but the (root) element itself is referred to by an empty list of path entries.As an alternative to class
Path
, each element in a tree could be uniquely identified by "path entries" that only contained a child index instead of an element name plus element child index (of element children with the given name). Yet that would be far less easy to use. HencePath.Entry
instances each contain an element name plus index.