TaxonomyElem

sealed abstract class TaxonomyElem extends CanBeTaxonomyDocumentChild with AnyTaxonomyElem with Elem with ScopedElemLike with SubtypeAwareElemLike

Any element in a taxonomy schema or linkbase document. The classes in this class hierarchy offer the yaidom query API, in particular the ScopedElemApi and SubtypeAwareElemApi query API.

Any element in a taxonomy schema or linkbase document. The classes in this class hierarchy offer the yaidom query API, in particular the ScopedElemApi and SubtypeAwareElemApi query API.

==Usage==

Suppose we have an eu.cdevreeze.tqa.base.dom.XsdSchema called schema. Then we can find all global element declarations in this schema as follows:

import scala.reflect.classTag
import eu.cdevreeze.tqa.ENames
import eu.cdevreeze.tqa.base.dom.GlobalElementDeclaration

// Low level yaidom query, returning the result XML elements as TaxonomyElem elements
val globalElemDecls1 = schema.filterChildElems(_.resolvedName == ENames.XsElementEName)

// Higher level yaidom query, querying for the type GlobalElementDeclaration
// Prefer this to the lower level yaidom query above
val globalElemDecls2 = schema.findAllChildElemsOfType(classTag[GlobalElementDeclaration])

// The following query would have given the same result, because all global element declarations
// are child elements of the schema root. Instead of child elements, we now query for all
// descendant-or-self elements that are global element declarations
val globalElemDecls3 = schema.findAllElemsOrSelfOfType(classTag[GlobalElementDeclaration])

// We can query the schema for global element declarations directly, so let's do that
val globalElemDecls4 = schema.findAllGlobalElementDeclarations

==Leniency==

The classes in this type hierarchy have been designed to be very '''lenient when instantiating''' them, even for schema-invalid content. The few builder methods that may throw exceptions have been clearly documented to potentially do so. For schema-invalid taxonomy content, the resulting object may be something like OtherElemInXsdNamespace, OtherElemInLinkNamespace or OtherNonXLinkElem. For example, an element named xs:element with both a name and ref attribute cannot be both an element declaration and element reference, and will be instantiated as an OtherElemInXsdNamespace. A non-standard XLink arc, whether a known generic arc or some unknown and potentially erroneous arc, becomes an instance of NonStandardArc or one of its sub-types, etc.

Some '''instance methods''' may fail, however, if taxonomy content is invalid, and if it is '''schema-invalid''' in particular. All instance methods must not fail on schema-valid content, unless mentioned otherwise.

Typical instance methods that may fail on schema-invalid content are:

  • methods that query for one mandatory attribute (as far as the schema is concerned)

  • methods that query for one mandatory child element (as far as the schema is concerned)

  • methods that query for values of specific types (enumerations, integers etc.)

It is important to keep this in mind. Schema-invalid taxonomies will be instantiated successfully, but after instantiation the API user should fall back to (defensive) yaidom level query methods when needed. This is indeed the responsibility of the API user.

==Other remarks==

The type hierarchy for taxonomy elements is not a strict hierarchy. There are mixin traits for XLink content, "root elements", elements in the xs and link namespaces, etc. Some element types mix in more than one of these traits.

See http://www.datypic.com/sc/xsd/s-xmlschema.xsd.html for schema content in general (as opposed to taxonomy schema content in particular).

It is perfectly fine to embed linkbase content in schema content, and such an element tree will be instantiated correctly.

The underlying backing elements can be any backing element implementation, including BackingNodes.Elem wrappers around Saxon tiny trees! Hence, this taxonomy DOM API is flexible in that it is not bound to one specific backing element implementation.

Authors

Chris de Vreeze

Companion
object
trait SubtypeAwareElemLike
trait SubtypeAwareElemApi
trait ScopedElemLike
trait ClarkElemLike
trait IsNavigable
trait ElemLike
trait Elem
trait ScopedElemApi
trait HasScopeApi
trait HasQNameApi
trait Elem
trait HasChildNodesApi
trait AnyElemNodeApi
trait ClarkElemApi
trait IsNavigableApi
trait ElemApi
trait AnyElemApi
trait Elem
trait CanBeDocumentChild
trait CanBeDocumentChild
trait CanBeDocumentChild
trait Node
trait Node
trait Node
class Object
trait Matchable
class Any
class Appinfo
class Linkbase
class RoleRef
class RoleType
class SchemaRef
class LabelArc
class LabelLink
class UsedOn
trait Content
class Import
class Include
trait Particle
trait Reference
class Extension
class XsdSchema
trait XLinkElem
trait XLinkArc
trait XLinkLink

Type members

Value members

Concrete methods

final override def attribute(expandedName: EName): String
Definition Classes
ClarkElemLike -> ClarkElemApi
final override def attributeAsQName(expandedName: EName): QName
Definition Classes
ScopedElemLike -> ScopedElemApi
final override def attributeAsQNameOption(expandedName: EName): Option[QName]
Definition Classes
ScopedElemLike -> ScopedElemApi
final override def attributeAsResolvedQName(expandedName: EName): EName
Definition Classes
ScopedElemLike -> ScopedElemApi
final override def attributeAsResolvedQNameOption(expandedName: EName): Option[EName]
Definition Classes
ScopedElemLike -> ScopedElemApi
override def attributeOption(expandedName: EName): Option[String]
Definition Classes
ClarkElemLike -> ClarkElemApi
final def attributes: IndexedSeq[(QName, String)]
final def baseUri: URI
final def baseUriOption: Option[URI]
final def children: IndexedSeq[TaxonomyNode]
final def docUri: URI
final override def equals(obj: Any): Boolean
Definition Classes
Any
final def findAllChildElems: IndexedSeq[TaxonomyElem]

Returns all child elements, and returns them extremely fast. This is important for fast querying, at the expense of more expensive recursive creation.

Returns all child elements, and returns them extremely fast. This is important for fast querying, at the expense of more expensive recursive creation.

override def findAttributeByLocalName(localName: String): Option[String]
Definition Classes
ClarkElemLike -> ClarkElemApi
final override def hashCode: Int
Definition Classes
Any
final def idOption: Option[String]
final def key: XmlFragmentKey

Returns backingElem.key, or its equivalent.

Returns backingElem.key, or its equivalent.

final override def localName: String
Definition Classes
ClarkElemLike -> ClarkElemApi
final override def normalizedText: String
Definition Classes
ClarkElemLike -> ClarkElemApi
final def path: Path

Returns key.path, or its equivalent backingElem.path.

Returns key.path, or its equivalent backingElem.path.

final def qname: QName
final def resolvedAttributes: IndexedSeq[(EName, String)]
final def resolvedName: EName
final def scope: Scope
final override def text: String
Definition Classes
ClarkElemApi
final override def textAsQName: QName
Definition Classes
ScopedElemLike -> ScopedElemApi
final override def textAsResolvedQName: EName
Definition Classes
ScopedElemLike -> ScopedElemApi
final def thisElem: ThisElem
final override def trimmedText: String
Definition Classes
ClarkElemLike -> ClarkElemApi

Inherited methods

def \(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def \@(expandedName: EName): Option[String]

Shorthand for attributeOption(expandedName).

Shorthand for attributeOption(expandedName).

Inherited from
ClarkElemLike
def \\(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def \\!(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def filterChildElems(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def filterChildElemsOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def filterElems(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def filterElemsOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def filterElemsOrSelf(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def filterElemsOrSelfOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def findAllChildElemsOfType[B <: ThisElem](subType: ClassTag[B]): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
override def findAllChildElemsWithPathEntries: IndexedSeq[(ThisElem, Entry)]

Returns all child elements paired with their path entries.

Returns all child elements paired with their path entries.

This method is final, so more efficient implementations for sub-types are not supported. This implementation is only efficient if finding all child elements as well as computing their resolved names is efficient. That is not the case for DOM wrappers or Scala XML Elem wrappers (due to their expensive Scope computations). On the other hand, those wrapper element implementations are convenient, but not intended for heavy use in production. Hence, this method should typically be fast enough.

Definition Classes
ClarkElemLike -> IsNavigable -> IsNavigableApi
Inherited from
ClarkElemLike
def findAllElems: IndexedSeq[ThisElem]
Inherited from
ElemLike
def findAllElemsOfType[B <: ThisElem](subType: ClassTag[B]): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def findAllElemsOrSelf: IndexedSeq[ThisElem]
Inherited from
ElemLike
def findAllElemsOrSelfOfType[B <: ThisElem](subType: ClassTag[B]): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def findChildElem(p: ThisElem => Boolean): Option[ThisElem]
Inherited from
ElemLike
override def findChildElemByPathEntry(entry: Entry): Option[ThisElem]

Finds the child element with the given Path.Entry (where this element is the root), if any, wrapped in an Option.

Finds the child element with the given Path.Entry (where this element is the root), if any, wrapped in an Option.

This method is final, so more efficient implementations for sub-types are not supported. This implementation is only efficient if finding all child elements as well as computing their resolved names is efficient. That is not the case for DOM wrappers or Scala XML Elem wrappers (due to their expensive Scope computations). On the other hand, those wrapper element implementations are convenient, but not intended for heavy use in production. Hence, this method should typically be fast enough.

Definition Classes
ClarkElemLike -> IsNavigable -> IsNavigableApi
Inherited from
ClarkElemLike
def findChildElemOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): Option[B]
Inherited from
SubtypeAwareElemLike
def findElem(p: ThisElem => Boolean): Option[ThisElem]
Inherited from
ElemLike
def findElemOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): Option[B]
Inherited from
SubtypeAwareElemLike
def findElemOrSelf(p: ThisElem => Boolean): Option[ThisElem]
Inherited from
ElemLike
def findElemOrSelfByPath(path: Path): Option[ThisElem]
Inherited from
IsNavigable
def findElemOrSelfOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): Option[B]
Inherited from
SubtypeAwareElemLike
def findReverseAncestryOrSelfByPath(path: Path): Option[IndexedSeq[ThisElem]]
Inherited from
IsNavigable
def findTopmostElems(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def findTopmostElemsOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def findTopmostElemsOrSelf(p: ThisElem => Boolean): IndexedSeq[ThisElem]
Inherited from
ElemLike
def findTopmostElemsOrSelfOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): IndexedSeq[B]
Inherited from
SubtypeAwareElemLike
def getChildElem(p: ThisElem => Boolean): ThisElem
Inherited from
ElemLike
def getChildElemByPathEntry(entry: Entry): ThisElem
Inherited from
IsNavigable
def getChildElemOfType[B <: ThisElem](subType: ClassTag[B])(p: B => Boolean): B
Inherited from
SubtypeAwareElemLike
def getElemOrSelfByPath(path: Path): ThisElem
Inherited from
IsNavigable
def getReverseAncestryOrSelfByPath(path: Path): IndexedSeq[ThisElem]
Inherited from
IsNavigable
final def nodeKind: NodeKind
Inherited from
Elem

Concrete fields

val backingElem: Elem
val childElems: IndexedSeq[TaxonomyElem]