Examples of Modular Vocabularies

1 trivelt.mv

The MV trivelt.mv is a simple example MV file that reads a structured list of elements and outputs an XML document-fragment. It has two modes: main, to make the root mv:document-fragment node of the output; and elt,to make the child elements. It is run with the command gloss -mv trivelt.mv, and on input

apple orange
  pear
  banana
    kumquat
    clementine
  satsuma
lemon

it produces

<apple>
  <orange/>
  <pear/>
  <banana>
    <kumquat/>
    <clementine/>
  </banana>
  <satsuma/>
</apple>
<lemon/>

(Indentation of output added here for clarity.)

2 testchildren.mv

The MV testchildren.mv is a modification of trivelt.mv to test the children features available in MV files. It defines element one to have at most one child normally, two to have at most two children, any child one-more to be in addition to the normal number of children, one-less to reduce the normal number of children by 1, child at-most-one to force the parent to have at most one child, and child two-left to force the parent to have at most two children remaining. It is run with the command gloss -mv testchildren.mv, and on input

one
  two
    apple
    pear
    orange
  one
    one-more
    one-more
    kumquat
  two
    one-less
    banana
    peach
  two
    at-most-one
    pineapple
  two
    pineapple
    two-left
    grape
    quince
    strawberry

it produces

<one>
  <two>
    <apple/>
    <pear/>
  </two>
</one>
<orange/>
<one>
  <one-more/>
  <one-more/>
  <kumquat/>
</one>
<two>
  <one-less/>
</two>
<banana/>
<peach/>
<two>
  <at-most-one/>
</two>
<pineapple/>
<two>
  <pineapple/>
  <two-left/>
  <grape/>
  <quince/>
</two>
<strawberry/>

(Indentation of output added here for clarity, as before.)

This page is copyright. Web page design and creation by GLOSS.