next up previous contents
: Communication model of OpenXM : Design and Implementation of : CMO Primitive object   目次

A formal expression of CMO

In the previous section, we have explained the format of CMO's in the Primitive group. In this section, we will introduce CMOexpression which is like the bracket expression of Lisp. We again explain a standard encoding method of CMO, which we have already explained in the previous section, but the explanation is more formal.

Let us define CMOexpression by the extended BNF expression. Symbols in the type writer fonts mean terminals. ``:'' means a definition. ``$\vert$'' means ''or''. { X } is a repetition of X of more than or equal to 0 times. [ x ] stands for X or nothing. By using this notation, CMOexpression is defined as follows.

\begin{eqnarray*}
\mbox{CMOexpression}
&:& \quad
\mbox{\tt (} \mbox{\tt cmo\_ta...
...\
& &\vert\ \mbox{\tt string} \\
& &\vert\ \mbox{\tt byte} \\
\end{eqnarray*}

Terminal int32 is signed 32 bit integer. Terminal string is a byte array which usually expresses a string. Terminal byte is 8 bit data.

The comma (,) may be used to separate each element in CMOexpressions. cmo_tag is a constant that starts with CMO_.

Let us describe CMO's in the Primitive group. In order to explain the meaning of objects, we may also put variable names to CMOexpressions. The start of comments are denoted by ``--''.

By using this notation, let us define formally CMObjects in the group Primitive.

Group CMObject/Primitive requires nothing.
Error2, Null, Integer32, Datum, Cstring, Mathcap, List $\in$ CMObject/Primitive.
Document of CMObject/Primitive is at http://www.math.kobe-u.ac.jp/OpenXM (in English and Japanese)

\begin{eqnarray*}
\mbox{Error2}&:& ({\tt CMO\_ERROR2}, {\sl CMObject}\, \mbox{ob...
...ct}\, ob[m-1])} \\
& & \mbox{--- m is the length of the list.}
\end{eqnarray*}

In the definition of ``Cstring'', if we decompose ``string s'' into bytes, then ``Cstring'' should be defined as

\begin{eqnarray*}
\mbox{Cstring}&:& ({\tt CMO\_STRING},{\sl int32}\, \mbox{ n},
{\sl byte}\, \mbox{s[0]},
\ldots, {\sl byte}\ \mbox{s[n-1]})
\end{eqnarray*}

``Group CMObject/Primitive requires nothing'' means that there is no super group to define CMO's in the group Primitive. ``Error2, Null, Integer32, Datum, Cstring, Mathcap, List $\in$ CMObject/Primitive'' means that Error2, Null, Integer32, Datum, Cstring are members of the group CMObject/Primitive.

Let us see examples. 32 bit integer 1234 is expressed as

(CMO_INT32, 1234)

The string ``Hello'' is expressed as

(CMO_STRING, 5, "Hello")

CMO's are expressed by XML like Open Math ([4]). See example below.

<cmo>
 <cmo_int32>
   <int32> 1234 </int32>
 </cmo_int32>

 <cmo_string>
   <int32 for="length"> 5 </int32>
   <string> "Hello" </string>
 </cmo_string>
</cmo>

cmo_string may be expressed as follows.

<cmo>
 <cmo_string>
   <int32 for="length"> 5 </int32>
   <byte> 'H' </byte> <byte> 'e' </byte>    <byte> 'l' </byte>
   <byte> 'l' </byte> <byte> 'o' </byte>
 </cmo_string>
</cmo>

In this case, the DTD for cmo_string is as follows;
<!ELEMENT cmo_string (int32, byte*)>

Let us explain the standard encoding method. All int32 data are encoded into network byte order 32 bit integers and byte data are encoded as it is.

When we are using a high speed network, the translation from the internal expression of 32 bit integers to network byte order may become a bottle neck. There are experimental data which presents that 90 percents of the transmission time are used for the translation to the network byte order to send CMO_ZZ of size 12M bytes. We used a 100Mbps network. In a later section 8.3, we will discuss a protocol to avoid the translation.

The translation between the standard encoding and CMOexpression is easy. For example,

int32 CMO_INT32 int32 1234

is the encoding of the CMOexpression

(CMO_INT32, 1234)

(Experimental) CMO and OX packets are complient to XML specification [10]. In order to encode ``Attribute'' in XML in our binary format, we have a tag:

#define CMO_ATTRIBUTE_LIST (LARGEID+3)

For example, the attibute font="Times-Roman" is encoded as

 (CMO_ATTRIBUTE (CMO_LIST 
                  (CMO_LIST (CMO_STRING,"font") (CMO_STRING, "Times-Roman"))))

All tags except this special CMO tag CMO_ATTRIBUTE_LIST are XML tags in the CMO/XML expression.

CMO/XML attributes such as comment, for are not encoded in the CMO binary expression.


next up previous contents
: Communication model of OpenXM : Design and Implementation of : CMO Primitive object   目次
Nobuki Takayama 平成15年5月13日