LMNL Object Model

Introduction

This document describes the core of the LMNL object model or LOM. This API is designed to enable you to access information from a LMNL data model and to provide the core functionality on which other LOM modules can be based.

Last modified 8 Oct 2002 by Jeni Tennison.

LOMString

sequence<unsigned short>

As in the DOM, a LOMString is used to ensure interoperability between implementations by specifying the encoding used to represent sequences of characters. LOMString uses UTF-16 encoding; in addition the contents of a LOMString must be Unicode normalized according to Unicode Normalization Form NFC.

valuetype LOMString sequence<unsigned short>;

ExpandedName

An ExpandedName represents a expanded name.

interface ExpandedName {
 
  readonly attribute LOMString namespaceName;
  readonly attribute LOMString localPart;
 
  boolean equals(in ExpandedName name);
}

Attributes

Attribute Notes
namespaceName

The namespace name of the expanded name. If the expanded name “has no namespace” then this returns an empty string.

localPart

The local part of the expanded name.

Methods

Method Notes
equals(ExpandedName name)

Returns true if this ExpandedName's namespaceName is equal to the argument ExpandedName's namespaceName and this ExpandedName's localPart is equal to the argument ExpandedName's localPart.

LOMImplementation

The LOMImplementation provides features for setting properties that are not related to a particular Document.

interface LOMImplementation {
 
  boolean hasFeature(in LOMString feature);
}

Methods

Method Notes
hasFeature(LOMString feature)

Returns true if this LOMImplementation has the named feature. Each LOM module may specify one or more features, which should be URIs.

Item

Item is to LOM what Node is to DOM. It's the basic interface for all objects in the model.

interface Item {
  const attribute unsigned short RANGE;
  const attribute unsigned short ANNOTATION;
  const attribute unsigned short LAYER;
  const attribute unsigned short DOCUMENT;
 
  readonly attribute unsigned short itemType;
  readonly attribute Document document;
  readonly attribute ExpandedName name;
  readonly attribute Sequence annotations;
  readonly attribute LOMString value;
 
}

Constants

Constant Notes
RANGE

The Item is a Range.

ANNOTATION

The Item is an Annotation.

LAYER

The Item is a Layer.

DOCUMENT

The Item is a Document.

Attributes

Attribute Notes
itemType

The type of the Item; one of the constants listed above.

document

The Document to which the item belongs.

name

The ExpandedName representing the name of the range or name of the annotation represented by this Item. If the Item is a Layer (which covers Documents), the name is null.

annotations

A Sequence of Annotations representing the annotations of the range or annotations of the annotation represented by this Item. If the Item is a Layer (which covers Documents), then annotations is null.

value

A LOMString giving the value of the Item. If the Item is a Layer whose content is null, this returns the content of the text layer. If the Item is a Range whose valueSequence is null, then this returns the value of the range. If the Item is a Annotation then this returns the content of the value of the annotation. Otherwise, this returns null.

Sequence

A Sequence holds a sequence of Items. Sequences are live; they will update if the document changes.

interface Sequence {
 
  readonly attribute unsigned short itemType;
  readonly attribute unsigned long length;
 
  Item item(in unsigned long index);
  Sequence getItemsNamed(in LOMString namespaceName, in LOMString localPart);
  Sequence getItemsInNamespace(in LOMString namespace);
}

Attributes

Attribute Notes
itemType

The type of the Items in the Sequence; one of the item type constants listed above.

length

The number of Items in the Sequence.

Methods

Method Notes
item( unsigned long index)

Returns the Item at the index passed as the argument, or null if that is not a valid index; counting starts from 0.

getItemsNamed(LOMString namespaceName, LOMString localPart)

Returns a Sequence holding all the items in the sequence whose name's namespace name is equal to the first argument and whose name's local part is equal to the second argument, or an empty Sequence if there are no such items.

getItemsInNamespace(LOMString namespace)

Returns a Sequence holding all the items in the sequence whose name's namespaceName is equal to the LOMString passed as the argument, or an empty Sequence if there are no such items.

Layer

A Layer represents a layer in the data model. Its itemType is Item.LAYER and its name and annotations are both null.

interface Layer : Item {
 
  readonly attribute Layer base;
  readonly attribute Sequence content;
  readonly attribute Sequence overlays;
 
}

Attributes

Attribute Notes
base

The base of the layer. Returns null if the layer has no base (i.e. if the layer is a text layer).

content

The Sequence of Ranges in the content of the layer. Returns null if the layer is a text layer (which covers Documents as well), in which case the value of the Layer holds the layer's (textual) content.

overlays

The Sequence of Layers that are overlays of this layer. Returns a Sequence with length 0 if the layer has no overlays.

Document

A Document is a kind of Layer that represents a document. Its itemType is Item.DOCUMENT; its value is the content of the document, as a LOMString; its document, name, annotations, base and content are all null.

interface Document : Layer {
 
  readonly attribute LOMImplementation implementation;
 
}

Attributes

Attribute Notes
implementation

The LOMImplementation that handles the Document.

Range

A Range is an Item that represents a range. Its itemType is Item.RANGE.

The start and end of a range are not exposed through this API, but they are used by a LOM implementation to construct the Sequences of Ranges.

interface Range : Item {
 
  readonly attribute Layer ownerLayer;
  readonly attribute Sequence valueSequence;
  readonly attribute Sequence clones;
  readonly attribute Sequence closestEnclosing;
  readonly attribute Sequence closestEnclosed;
  readonly attribute Sequence lastPreceding;
  readonly attribute Sequence firstFollowing;
  readonly attribute Sequence startOverlaps;
  readonly attribute Sequence endOverlaps;
 
  boolean isClone(in Range range);
  boolean isWithin(in Range range);
  boolean encloses(in Range range);
  boolean follows(in Range range);
  boolean precedes(in Range range);
  boolean overlapsStart(in Range range);
  boolean overlapsEnd(in Range range);
}

Attributes

Attribute Notes
ownerLayer

The owner-layer of the range as a Layer.

valueSequence

The value of the range as a Sequence of Ranges. If the range's value is a sequence of characters (i.e. the range belongs to a overlay of a text layer), this returns null and instead the value of the Range holds this sequence of characters.

clones

A Sequence of Ranges that are clones of this one.

closestEnclosing

A Sequence of Ranges that are the closest enclosing ranges of this one.

closestEnclosed

A Sequence of Ranges that are the closest enclosed ranges of this one.

lastPreceding

A Sequence of Ranges representing ranges that precede this one and whose ends are greater than or equal to all the other preceding ranges.

firstFollowing

A Sequence of Ranges representing ranges that follow this one and whose start is less than or equal to all the other following ranges.

startOverlaps

A Sequence of Ranges that that overlap the start of this one.

endOverlaps

A Sequence of Ranges that that overlap the end of this one.

Methods

Method Notes
isClone(Range range)

Returns true if the argument Range is a clone of this Range.

isWithin(Range range)

Returns true if this Range is within the argument Range.

encloses(Range range)

Returns true if this Range encloses the argument Range.

follows(Range range)

Returns true if this Range follows the argument Range.

precedes(Range range)

Returns true if this Range precedes the argument Range.

overlapsStart(Range range)

Returns true if this Range overlaps the start of the argument Range.

overlapsEnd(Range range)

Returns true if this Range overlaps the end of the argument Range.

Annotation

A Annotation is an Item that represents a annotation. Its itemType is Item.ANNOTATION.

interface Annotation : Item {
 
  readonly attribute Item owner;
  readonly attribute Layer valueLayer;
 
}

Attributes

Attribute Notes
owner

The Item (a Range or Annotation) that represents the owner of the annotation.

valueLayer

The Layer (a text layer) that represents the value of the annotation.