diff options
Diffstat (limited to 'ocda-model.md')
| -rw-r--r-- | ocda-model.md | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/ocda-model.md b/ocda-model.md index f4bf245..065677a 100644 --- a/ocda-model.md +++ b/ocda-model.md @@ -39,9 +39,12 @@ the document is made of and the unit it is cited by. Every object carries: - an **object citation number** (OCN), section 3; +- an **identifier**, section 3.1; - a **kind** and a **type**, section 2.1; - its **place in the structure**: parent, ancestors, and for a heading its children and its last descendant, section 4; +- the **segment** it is in, and for a heading an **anchor**, sections 7 + and 7.1; - its **text**, in spine's internal representation; - a **digest** of that text. @@ -108,6 +111,24 @@ otherwise: its verses share one; `through_the_looking_glass` has 21 such cases. Key on position within a section when one row is wanted. +### 3.1 The identifier + +Every object also carries an **identifier**: the name by which an output +refers to it. An HTML anchor, a LaTeX `\hypertarget`, a link from a book +index entry to the object it indexes, are all written from the identifier. + +**The identifier of an object with a non-zero OCN is its OCN**, written as +text. That is the ordinary case and it is the reason a citation to object +42 can be turned into a link without consulting anything. + +An object with OCN `0` has no OCN to take an identifier from, so one is +assigned: `a1`, `a2`, `a3`, ... in document order over the objects that +need one. There are few of them, eleven in a book, and they are the +generated furniture of section 3. + +**A reader must arrive at the identifier whether or not the serialisation +wrote it down**; see section 9. + ## 4. Levels A document has **eight heading levels**, in two groups of four: @@ -188,6 +209,21 @@ both separately because the answers differ: Without the second, a reader cannot say where a paragraph belongs. The search database reads the second. +### 7.1 The anchor + +A heading carries an **anchor**: the name an output links to in order to +arrive at that heading. It is what a table of contents entry and a +cross reference point at. + +**An object's anchor is its segment name**, in the ordinary case, because a +heading that opens a segment is arrived at by arriving at the segment. It +differs only where a heading is not the opening of the segment it sits in: +69 of the 72 anchors in one reference document equal their segment and 3 do +not. + +**A reader must arrive at the anchor whether or not the serialisation wrote +it down**; see section 9. + ## 8. Digests The model is checkable at four levels, and the chain is what lets an @@ -203,7 +239,49 @@ each image ──> a digest of the image file, with its size in bytes and pixels An object's digest is over its text alone, so a change to one paragraph moves one digest and no other. -## 9. What the model does not hold +## 9. Derived values, and why a reader must derive them + +Two of the values above are **derived**: the identifier from the OCN +(section 3.1), and the anchor from the segment name (section 7.1). The +model holds them; a serialisation need not, and the text form does not. + +**A serialisation may omit a value it can compute.** The `.ssp` writes a +property only when it carries information, so it omits `.identifier` where +the identifier is the OCN and `.anchor` where the anchor is the segment +name. The `.ocda.db` is columns rather than lines and writes both +unconditionally. + +Both are conforming. What is **not** conforming is a reader that takes the +text form literally and hands on a model with those fields empty, because +that model is not the same model the database gives, and a writer over it +will produce different output from the two serialisations of one document. + +The size of the difference is easy to underestimate. In +`free_culture.lawrence_lessig` the `.ssp` omits **1,314 identifiers and 69 +anchors** that the `.ocda.db` states, which is nearly every object in the +document. + +So, on loading: + +| field | when absent | take | +|-------|-------------|------| +| identifier | OCN is non-zero | the OCN as text | +| identifier | OCN is `0` | whatever the serialisation gave; there is nothing to derive from | +| anchor | the object has a segment | the segment name | + +**This is a property of the model, not of either format**, which is why it +is stated here and not only in the two format specifications. It is stated +here *because* two readers written independently from these documents +disagreed for want of it: the rule was implied by the `.ssp`'s emission +conditions and nowhere asserted. + +It is also what **spine's own reader** does, and always did, which is why +the `.ocda.db` carries the derived values: the database is written from the +`.ssp` read straight back, and the reading fills both in. So this section +documents existing behaviour rather than prescribing new. It should have +been written down first. + +## 10. What the model does not hold - **The markup.** The model is what the markup produced, not the markup itself. An artefact that carries both is the `.ocda.db`, which carries |
