Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions examples/business-document.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Worked instance for Annex E (application to business document
# interchange): a purchase order expressed as a base BasicDocument.
# Trade identifiers ride the attribute register with ISO 6523 scheme
# keys; line items and totals are tables, with computed cells carried
# as formula blocks. A revision round against this document is shown
# by the twin ChangeSet examples/table-changes.{xml,yaml}.
# Validated against the LML model by `rake fixtures:yaml`.
document:
class: BasicDocument
attributes:
- key: class
value: [purchase-order]
- key: supplier-id
scheme: iso-6523
value: "0060:9876543210"
- key: buyer-id
scheme: iso-6523
value: "0060:4182738170"
- key: currency
value: EUR
identifier:
class: UniqueIdentifier
value: basicdoc-business-fixtures-1
bibdata:
class: BibData
ext:
class: BibDataExtensionType
doctype: [document]
sections:
- class: ContentSection
id: po-header
title: [{ text: Purchase order }]
blocks:
- class: ParagraphBlock
id: po-p1
contents:
- text: "Purchase order "
- class: ReferenceToVariable
name: po-number
- text: " issued on "
- class: ReferenceToVariable
name: issue-date
- text: " for delivery per "
- class: ReferenceToVariable
name: incoterm
- class: ContentSection
id: po-terms
title: [{ text: Terms }]
blocks:
- class: ParagraphBlock
id: po-p2
contents:
- text: "The supplier shall deliver in accordance with the "
- class: EmphasisElement
content: [{ text: agreed schedule }]
- text: ", subject to the tolerances below."
- class: AdmonitionBlock
id: po-note
type: note
contents:
- class: ParagraphBlock
id: po-notep1
contents:
- text: Quantities may vary within 5% of the ordered amounts.
- class: ContentSection
id: po-lines
title: [{ text: Line items }]
blocks:
- class: TableBlock
id: po-lines-t1
name: [{ text: Ordered items }]
head:
- class: TextTableRow
th:
- class: TextTableCell
content: [{ text: Item }]
- class: TextTableCell
content: [{ text: Quantity }]
- class: TextTableCell
content: [{ text: Unit price }]
- class: TextTableCell
content: [{ text: Total }]
body:
- class: TextTableRow
td:
- class: TextTableCell
content: [{ text: Widget W1 }]
- class: TextTableCell
content: [{ text: "12" }]
- class: TextTableCell
content: [{ text: "9.50" }]
- class: ParagraphTableCell
content:
- class: FormulaBlock
id: po-lines-t1-f1
stem:
class: StemElement
stemType: AsciiML
stemValue:
class: AsciiML
value: B2 * C2
- class: TextTableRow
td:
- class: TextTableCell
content: [{ text: Gear G7 }]
- class: TextTableCell
content: [{ text: "3" }]
- class: TextTableCell
content: [{ text: "41.00" }]
- class: ParagraphTableCell
content:
- class: FormulaBlock
id: po-lines-t1-f2
stem:
class: StemElement
stemType: AsciiML
stemValue:
class: AsciiML
value: B3 * C3
foot:
- class: TextTableRow
td:
- class: TextTableCell
colspan: 3
content: [{ text: Total }]
- class: ParagraphTableCell
content:
- class: FormulaBlock
id: po-lines-t1-f3
stem:
class: StemElement
stemType: AsciiML
stemValue:
class: AsciiML
value: SUM(D2, D3)
100 changes: 100 additions & 0 deletions examples/table-changes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!--
Twin reference instance of the change model: a ChangeSet applied to the
line-item table (li1t1) of document.xml, exercising every change
operation — node insert/delete/move (with explicit position), content
and attribute modification, row insert/delete/move, column
insert/delete/move, cell update, cell merge and cell split — including
a computed cell (a formula block inside a table cell).
Twin of: table-changes.yaml
-->
<changeset document="basicdoc-fixtures-1">

<!-- add a line-item row -->
<change target="li1t1" id="chg-01">
<row-insert area="body" position="1">
<tr><td>inline</td><td>BasicElement</td></tr>
</row-insert>
</change>

<!-- append a column; every row gains an empty cell -->
<change target="li1t1" id="chg-02" parent="chg-01">
<column-insert position="2"/>
</change>

<!-- header cell for the new column -->
<change target="li1t1" id="chg-03" parent="chg-02">
<cell-update row="0" column="2">
<th>Tier</th>
</cell-update>
</change>

<!-- computed cell: a formula block inside a table cell -->
<change target="li1t1" id="chg-04" parent="chg-03">
<cell-update row="2" column="2">
<td>
<formula id="li1t1f1"><stem type="AsciiMath"><asciimath>count(body rows)</asciimath></stem></formula>
</td>
</cell-update>
</change>

<!-- merge the units header across both columns -->
<change target="li1t1" id="chg-05" parent="chg-04">
<cell-merge>
<from row="1" column="0"/>
<to row="1" column="1"/>
</cell-merge>
</change>

<!-- split it back -->
<change target="li1t1" id="chg-06" parent="chg-05">
<cell-split row="1" column="0"/>
</change>

<!-- promote a body row to the footer -->
<change target="li1t1" id="chg-07" parent="chg-06">
<row-move old-area="body" old-position="2" new-area="foot" new-position="0"/>
</change>

<!-- move the Tier column before the Construct column -->
<change target="li1t1" id="chg-08" parent="chg-07">
<column-move old-position="2" new-position="1"/>
</change>

<!-- drop a body row -->
<change target="li1t1" id="chg-09" parent="chg-08">
<row-delete area="body" position="0"/>
</change>

<!-- node insert at an explicit position -->
<change target="li1" id="chg-10" parent="chg-09">
<node-insert>
<position parent="li1" index="2"/>
<bookmark id="chg-bm1"/>
</node-insert>
</change>

<!-- node delete with integrity check -->
<change target="tdp1" id="chg-11" parent="chg-10">
<node-delete hash="sha-256:2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"/>
</change>

<!-- node move -->
<change target="tdli1p1" id="chg-12" parent="chg-11">
<node-move old-parent="tdli1" new-parent="li1"/>
</change>

<!-- text edit by cursor range -->
<change target="li1p1" id="chg-13" parent="chg-12">
<content-modify>
<action type="insert" from="39" to="39" length="10"> (revised)</action>
</content-modify>
</change>

<!-- register entry update by cursor range -->
<change target="li1t1" id="chg-14" parent="chg-13">
<attribute-modify>
<action key="class" type="insert" from="0" to="0" length="6">priced</action>
</attribute-modify>
</change>

</changeset>
143 changes: 143 additions & 0 deletions examples/table-changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Twin reference instance of the change model: a ChangeSet applied to the
# line-item table (li1t1) of document.yaml, exercising every change
# operation — node insert/delete/move (with explicit position), content
# and attribute modification, row insert/delete/move, column
# insert/delete/move, cell update, cell merge and cell split — including
# a computed cell (a formula block inside a table cell).
# Twin of: table-changes.xml
class: ChangeSet
documentIdentifier:
class: UniqueIdentifier
value: basicdoc-fixtures-1
changes:
# add a line-item row
- class: RowInsert
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-01 }
area: body
position: 1
row:
class: TextTableRow
td:
- class: TextTableCell
content: [{ text: inline }]
- class: TextTableCell
content: [{ text: BasicElement }]
# append a column; every row gains an empty cell
- class: ColumnInsert
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-02 }
parentIdentifier: { class: UniqueIdentifier, value: chg-01 }
position: 2
# header cell for the new column
- class: CellUpdate
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-03 }
parentIdentifier: { class: UniqueIdentifier, value: chg-02 }
row: 0
column: 2
cell:
class: TextTableCell
content: [{ text: Tier }]
# computed cell: a formula block inside a table cell
- class: CellUpdate
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-04 }
parentIdentifier: { class: UniqueIdentifier, value: chg-03 }
row: 2
column: 2
cell:
class: ParagraphTableCell
content:
- class: FormulaBlock
id: li1t1f1
stem:
class: StemElement
stemType: AsciiML
stemValue:
class: AsciiML
value: count(body rows)
# merge the units header across both columns
- class: CellMerge
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-05 }
parentIdentifier: { class: UniqueIdentifier, value: chg-04 }
from: { class: CellCoordinate, row: 1, column: 0 }
to: { class: CellCoordinate, row: 1, column: 1 }
# split it back
- class: CellSplit
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-06 }
parentIdentifier: { class: UniqueIdentifier, value: chg-05 }
at: { class: CellCoordinate, row: 1, column: 0 }
# promote a body row to the footer
- class: RowMove
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-07 }
parentIdentifier: { class: UniqueIdentifier, value: chg-06 }
areaOld: body
positionOld: 2
areaNew: foot
positionNew: 0
# move the Tier column before the Construct column
- class: ColumnMove
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-08 }
parentIdentifier: { class: UniqueIdentifier, value: chg-07 }
positionOld: 2
positionNew: 1
# drop a body row
- class: RowDelete
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-09 }
parentIdentifier: { class: UniqueIdentifier, value: chg-08 }
area: body
position: 0
# node insert at an explicit position
- class: NodeInsert
target: { class: ReferenceToIdElement, target: li1 }
identifier: { class: UniqueIdentifier, value: chg-10 }
parentIdentifier: { class: UniqueIdentifier, value: chg-09 }
position:
class: NodePosition
parent: { class: ReferenceToIdElement, target: li1 }
index: 2
content: { class: Bookmark, id: chg-bm1 }
# node delete with integrity check
- class: NodeDelete
target: { class: ReferenceToIdElement, target: tdp1 }
identifier: { class: UniqueIdentifier, value: chg-11 }
parentIdentifier: { class: UniqueIdentifier, value: chg-10 }
hashValue: sha-256:2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
# node move
- class: NodeMove
target: { class: ReferenceToIdElement, target: tdli1p1 }
identifier: { class: UniqueIdentifier, value: chg-12 }
parentIdentifier: { class: UniqueIdentifier, value: chg-11 }
positionOld: { class: ReferenceToIdElement, target: tdli1 }
positionNew: { class: ReferenceToIdElement, target: li1 }
# text edit by cursor range
- class: ContentModify
target: { class: ReferenceToIdElement, target: li1p1 }
identifier: { class: UniqueIdentifier, value: chg-13 }
parentIdentifier: { class: UniqueIdentifier, value: chg-12 }
actions:
- class: ContentChangeAction
action: insert
from: 39
to: 39
text: " (revised)"
length: 10
# register entry update by cursor range
- class: AttributeModify
target: { class: ReferenceToIdElement, target: li1t1 }
identifier: { class: UniqueIdentifier, value: chg-14 }
parentIdentifier: { class: UniqueIdentifier, value: chg-13 }
actions:
- class: AttributeChangeAction
attributeId: class
action: insert
from: 0
to: 0
text: priced
length: 6
2 changes: 1 addition & 1 deletion grammars/basicdoc-compile.rnc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
grammar {
include "../vendor/relaton-models/relaton/grammars/biblio.rnc" { }
include "basicdoc.rnc" { }
start = document
start = document | changeset
}
Loading
Loading