Ticket

Collection

Here we describe the process of collecting possible target objects, that are in some way connected to a given object. In general, there's a collector that manages a pool of collectors or sources, that implement the specific collection method.

Notation collection

The code here handles the collection of notations that should be applied in the rendering of a mathematical object.

NotationSource

List<Element> getNotations(Element mobj) throws Exception;

NotationCollector: the SD (default) and B (bundled) sources which are included by default should be factored out from here, and maybe add them to the collector automatically in the RenderingFactory.

Notations sources:

  • SD - default source, in org.omdoc.jomdoc.ntn.coll.ntn/default.ntn
  • B - bundled notations, files in org.omdoc.jomdoc.ntn.coll.ntn.ntns
  • F - file containing notations, all notation elements from the specified file are collected
  • Doc - collect notations from the input document, but only those that are before and left of the element specified for rendering
  • EC - the notations to be collected are computed from the ec attribute of the element to be rendered. The effective EC is computed as a combination of all the parent's ec attributes. @ec contains a white space separated URIs to:
    • specific elements in this document (#id)
    • specific elements in another document (docURI#id)
    • all elements in a document (docURI)
  • CD - collect notations from content dictionaries (CDs). The URI to the respective CD is constructed from the cdbase and cd attributes. @cdbase is computed from the input element and it's parents, @cd is taken from the input element.
  • D - collect notations from the theory in which the given element is found, and all the additional imported theories.

Context Collection

Collection of contextual information is handled here. The collected context is later used to fine-tune the sorting of collected target elements.

ContextSource

Context getContext(Element mobj)

ContextCollector: no special cases

Context sources:

  • IC - collect intensional context attached to the input node with the ic attribute. The IC is represented as key-value pairs, in the form key=value;key=value;..
  • GC - global context, specified in a separate file, with each key-value pair in a separate line
key=value
key=value
...
  • MD - extract context from any available metadata. This available data include
    • a combination of attached metadata elements to the input element or its parents
    • a file containing metadata key-value pairs, with each key-value pair in a separate line (as for GC)
  • CCF - denotes collection from cascading context files, which are analogous to cascading style sheets (CSS).

Tag Collection

Besides contextual information, tags can be used for further refining the sorting of collected targets.

TagSource

void filterRenderings(Element mobj, List<Pair<Integer, Element>> renderings)

TODO: change this to only collect tags. The sorting/filtering should be done at a later stage, together with the context processing. It should look like:

List<Tag> getTags(Element mobj)

TagCollector: no special cases

Tag sources:

  • F - collect all tag elements from a specified file.
  • Doc - collect tags from the input document. Note: this is simply a shortcut for F(inputDoc), thus to simplify maybe it should be left out.

Element collection

This part concerns collection of element for replacing a variant in the variant contraction process.

ElementSource

List<Element> getElements(Element e, Context c);

TODO: the context parameter is not needed here, so this is equivalent to the other sources.

ElementCollector: the context collector and variant sorter should be factored out from here into VariantContractor. ElementCollector should only collect elements and nothing more.

Element sources:

  • F - collect all elements from a specified file.
  • Doc - collect elements from the input document, but only those that are before and left of the variant element.
  • V - collect elements inside the variant element.
  • EC - collect referenced elements in the ec attribute of the input element. This works in the same way as in the notation collection.

Refactoring

  • org.omdoc.jomdoc.ntn.coll has changed to org.omdoc.jomdoc.coll
  • NotationCollector is simply a list of sources (so there are the usual list methods, e.g. add instead of addNotationSource).
  • The sources have been renamed to have meaningful names, e.g. F -> NotationFile, Doc -> InputDocument, D -> ImportsAware, etc.

Sorting

Here we cover the sorting of collected objects according to various additional parameters (context and tags).

Rendering sorting

List<Element> renderings(List<Element> renderings, Context lambda, Element mobj)

The tags collector is set as a field in the RenderingCollector.

Variant sorting

The VariantSorter simply extends the RenderingCollector and reimplements the renderings methods with some specifics to the variants.

Refactoring

  1. The most generic functionality will go into AbstractSorter, which will define as abstract the method
    List<Element> sort(List<Element> collectedObjects, Element object)
    

and the specific Element/Rendering? Sorters implement the specific collection and sorting.

  1. In order to setup everything and get a working Renderer/VariantContractor, The Notation/Element?, Context and Tag Collectors should just be set to the RendererFactory/VariantContractor, everything else will be done automatically.

Public API changes

Most important public changes:

  • org.omdoc.jomdoc.ntn.coll has changed to org.omdoc.jomdoc.coll
  • NotationCollector is simply a list of sources (so there are the usual list methods, e.g. add instead of addNotationSource).
  • The sources have been renamed to have meaningful names, e.g. F -> NotationFile, Doc -> InputDocument, D -> ImportsAware, etc.