An additional feature of text processing in the GLOSS-xml
system is the ability to push
back in to element-mode from
text-mode with a further [.
The idea is that, when typing a section of mixed data it is often convenient to think of simple markup such as <dfn>...</dfn> or <q>...</q> to be part of the text than as stopping the text, starting something else, then restarting the text again. So [ pushes back into element mode for a while, a subsequent ] pops back to text mode, and so on. The [ ] must balance, and elements cannot straddle [ ], so [ ] behaves a bit like { } as well.
XML doesn't have such a feature of nested modes, so GLOSS has to simulate it by ending text and then re-starting more text, but conceptually and structurally this feature of GLOSS-xml is very useful, easy to type, and remarkably legible.
For example,
text [The fruit we shall consider are [i[kumquats]], [b[bananas]] and [a @href[http://www.mysite/pears][pears]].]
which yields
<text>The fruit we shall consider are <i>kumquats</i>, <b>bananas</b> and <a href="http://www.mysite/pears">pears</a>.</text>
The inner text can also have pushed
element sections too,
and so on. (Of course, care is needed that brackets match.)
The form [i[kumquats]] is common when writing
HTML for italicising text. It seems a little lengthy because of the
double brackets (though a touch better than <i>kumquats</i>),
but it turns out to be very quick to type in practice as the
square bracket symbols are usually very conveniently located on
the keyboard and much more easily accessed than < >.
To insert a comment in the input text, just use the ; sign. The comment lasts to the end of the line. Thus
root element ; the ; and all text to the right of it will be ignored child ; and so will this
yields
<root><element><child/></element></root>
If you want your output XML file to contain comments, not just your
input file, then clearly a different mechanism is required. Instead use
the pseudo tag name
!
just like you would an xml element
name and make its content a text block. Thus:
root ! [pear orange \[lemon\] \{peach\} cherry]
yields
<root><!-- pear orange [lemon] {peach} cherry --></root>
The sequence of characters -- is not allowed in comment text. If you try to do this your text is modified to something appropriate. Thus
root ! [--pear - -- --- ---- ----- -\\- -\\\\- -\\\\\\- orange--]
yields
<root><!-- --pear - -- --- ---- ----- -\- -\- -\\- orange-- --></root>
The encoding used currently is to replace any -- by --.
CDATA sections also textual input as described above.
To define a CDATA section use the pseudo tag name
!CDATA
in
the same way as you used !
for comments. Thus:
root !CDATA [pear orange \[lemon\] \{peach\} cherry]
yields
<root><![CDATA[pear orange [lemon] {peach} cherry]]></root>
All the same rules apply as for comments. In particular just because
the output will be CDATA doesn't mean the rule of escaping
[, ], {, } and \ is relaxed. (If you think about it you will realise that
they can't be.) But note that CDATA
sections have different forbidden text
. In the case of CDATA
it is ]]>
that may not appear in a CDATA section. This
is handled as follows:
root !CDATA [pear orange <!\[CDATA\[ ... \]\]> cherry]
yields
<root><![CDATA[pear orange <![CDATA[ ... ]]]]><![CDATA[> cherry]]></root>
LITERAL sections also use text as described above, and
are provided as a last-ditch resort to place literal text in the
output. Do not use these unless there really is no alternative!
It works just like CDATA with the pseudo tag name !LITERAL
.
root !LITERAL [playing dangerously with <xml>, <!\[CDATA\[, <!-- and stuff]
yields the non-well-formed
<root>playing dangerously with <xml>, <![CDATA[, <!-- and stuff</root>
We have seen that !CDATA, !LITERAL and even ! are useful as special elements. Any other elements of the form !name may be used too. In fact, the normal behavious is that these are converted to normal elements. This
!apples !peaches and !pears
yields
<apples><peaches><and><pears/></and></peaches></apples>
For other applications, xtending GLOSS-xml, it is useful to have two separate sets of elements. Thus in GLOSS-xsl the !name forms generate xsl commands, and normal forms generate normal elements. Similarly in GLOSS-mv the !name forms generate gloss mv commands.
This page is copyright. Web page design and creation by GLOSS.