This package contains element representations that contain the "context" of the element. That is, the elements
in this package are pairs of a root element and an element path (to the actual element itself).
An example of where such a representation can be useful is XML Schema. After all, to interpret an element definition
in an XML schema, we need context of the element definition to determine the target namespace, or to determine whether the
element definition is top level, etc.
Below follows a simple example query, using the uniform query API:
// Note the import of package indexed, and not of its members. That is indeed a best practice!import eu.cdevreeze.yaidom.indexed
val indexedBookstoreElem = indexed.Elem(bookstoreElem)
val scalaBookAuthors =
for {
bookElem <- indexedBookstoreElem \ EName("{http://bookstore/book}Book")
if (bookElem \@ EName("ISBN")) == Some("978-0981531649")
authorElem <- bookElem \\ EName("{http://bookstore/author}Author")
} yield authorElem
The query for Scala book authors would have been exactly the same if normal Elems had been used instead of indexed.Elems
(replacing indexedBookstoreElem by bookstoreElem)!
This package contains element representations that contain the "context" of the element. That is, the elements in this package are pairs of a root element and an element path (to the actual element itself).
An example of where such a representation can be useful is XML Schema. After all, to interpret an element definition in an XML schema, we need context of the element definition to determine the target namespace, or to determine whether the element definition is top level, etc.
Below follows a simple example query, using the uniform query API:
The query for Scala book authors would have been exactly the same if normal
Elem
s had been used instead ofindexed.Elem
s (replacingindexedBookstoreElem
bybookstoreElem
)!