next up previous contents
Next: Handling of Latency and Up: Representing Fieldbus Data and Previous: Identifying XML Data by   Contents

Encoding Fieldbus Data in SOAP Messages

Fieldbus data has to be encoded in some way when it is transported in XML documents. Most data will remain of the same type, therefore appropriate XML Schemas can be created that define the data encoding.

However, there are exceptions where the encoding cannot be defined clearly: Fieldbus nodes may contain values which are of different data types77, as depicted in figure 32. These values with different encoding have to be transported in the same XML document as shown in Listing 23.

Figure 32: Different Data Types on Fieldbus Nodes
\begin{figure}\centering
\includegraphics[scale=0.7]{graphics/value_encoding.eps}\end{figure}

language=XML
\begin{lstlisting}[caption={Datapoint Values Embedded in XML Code}
,label=ex_xm...
...value>
</item>
<item id=''Sensor2''>
<value>On</value>
</item>
\end{lstlisting}

In this case, no fixed XML Schema for the ``value'' element may be used as the data type varies over different XML code, which represent different datapoints. In order to validate and decode the XML code, the XML parser and de-serializer have to be somehow informed about the data type of the values. The following solutions to this problem may be used:

1. Specified by Element:
This way, certain XML elements are defined in XML Schema that identify the data types. To give an example, a XML element <real> may then contain only data of type ``real''. An example XML code is shown in listing 24. This encoding style is used by [OBIX] and works well but has the major drawback that the human legibility is greatly reduced as the XML code does not outline that the encoded data is a ``value''.

language=XML
\begin{lstlisting}[caption={Data Type Specified by Element}
,label=ex_xml_encod...
...oat>
</item>
<item id=''Sensor2''>
<string>On</string>
</item>
\end{lstlisting}

2. Inline XML Schema:
Inline XML Schema is another way of directly assigning data types to elements. An example listing is depicted in 25. This method is used by [OPCXMLDA] and is a decent solution to the encoding problem.

language=XML
\begin{lstlisting}[caption={Inline XML Schema}
,label=ex_xml_encoding_inline]
<...
...''Sensor2''>
<value xsi:type=''xsd:string''>On</value>
</item>
\end{lstlisting}

3. Defining outside of XML:
Another way is not to inform the XML parser and the de-serializer at all and transmit the data as strings and leave the validation and de-serialization to the application. Nevertheless, the XML code has to give the application a hint as to what data type it has to expect. This may be done by XML attributes, as depicted in listing 26. This encoding style is used by [BACNET/WS]78

language=XML
\begin{lstlisting}[caption={Datapoint Values Embedded in XML Code}
,label=ex_xm...
...item id=''Sensor2''>
<value type=''string''>On</value>
</item>
\end{lstlisting}

All three encoding methods are appropriate solutions. However, the last solution forces the software developer to implement code for validation/de-serialization into the application which is not needed by the first two methods.


next up previous contents
Next: Handling of Latency and Up: Representing Fieldbus Data and Previous: Identifying XML Data by   Contents
Hermann Himmelbauer 2006-09-27