Introduction
Aim of the project - the creation of the interpreter which processes the description of data structure on XML Schema(XSD). The interpreter may perform the folowing functions:
- Reading Xml-files, filled by the User, for editing binary data in accordance with the needed XSD.
- Creating Xml-files from binary data in accordance with the needed XSD. It is very convenient for control binary data, transmitted through communication channels, instead of ordinary sniffers,which present binary data in hexadecimal format only.
S/W includes the following:
Xsd2StructBuilder.exe — a dialog utility for creation of XML Schemas, similar to include files for C-language, empty XML-files and files with a list of data structure full named variables.
Xsd2Struct.exe - a console utility.
This utility reads XML Schemas, created by Xsd2StructBuilder.exe or any text editor and may be used as a separate Server, connected via TCP/IP for receiving and sending binary data, which structures are described by the XML Schemas. This utility also creates similar include files for C-language, empty XML-files and files with list of data structure full named variables, such as Xsd2StructBuilder.exe. In case the utility receives binary data via a TCP/IP channel, it creates an xml-file with values of data structure variables.
Demo.exe – a console application works as a client with the server of Xsd2Struct.exe.
It receives binary data from Xsd2Struct.exe and sends binary data to it. The User may test the Trial version of Xsd2Struct.exe by Demo.exe. Demo.zip contains a sample of using the communication protocol between a client of User's Application and the server of Xsd2Struct.exe. Rules for Schemas creation are described in Table 1 and Table 2.
Elements | Mandatory Attributes | Optionally Attributes | Included Elements |
Schema | name
id
| | Enum
Template
Structure
Item_enum
Item
|
Enum | name | | Item |
Template | name | | Structure
Item_enum
Item
|
Structure | name
type
| nrepetitions | Structure
Item_enum
Item
|
Item_enum | name
type
| nrepetitions | |
Item | name | type
nrepetitions
visibility
| |
Table 1. Elements, their attributes and included elements
Certain Elements have special types. These are shown in Table 2.
Elements with types | Type values |
Structure | One of previous designed Template names |
Item_enum | One of previous designed Enum names |
Item | char
int //(default)
int16
int64
unsigned
unsigned16
unsigned64
float
double
bool |
Table 2. Type values
Values of attributes name
and id
for Schema
Element must be unique and will be used for selecting the necessary schema.
Background
TCP/IP Communication,C++,XML.
Using the Code
The User's Application may connect with Xsd2Struct.exe server via a TCP/IP channel. The User's Application can get binary data from Xsd2Struct.exe server or send binary data to it. Received binary data will be printed in accordance with their schema. This output will include the list of full-name variables and their values.
Sample of schema:
="1.0"
<Schema name="schema3" id="1">
<Enum name="COLOR">
<Item name="red" id="1"/>
<Item name="green" id="2"/>
<Item name="blue" id="3"/>
<Item name="white" id="4"/>
<Item name="black" id="5"/>
</Enum>
<Template name="POINT">
<Item name="x" type="int"/>
<Item name="y" type="int"/>
<Item_enum name="pen" type="COLOR" nrepetitions="2"/>
</Template>
<Template name="RECTANGLE">
<Structure name="point" type="POINT"/>
</Template>
<Item name="z" type="int" nrepetitions="2"/>
<Item name="array" type="char" nrepetitions="10" visibility="0"/>
<Structure name="coord" type="RECTANGLE" nrepetitions="3"/>
</Schema>
Generated include-file for this schema:
#ifndef __SCHEMA3__
#define __SCHEMA3__
typedef enum
{
red=1,
green=2,
blue=3,
white=4,
black=5
} COLOR;
typedef struct
{
int x;
int y;
COLOR pen[2];
} POINT;
typedef struct
{
POINT point;
} RECTANGLE;
typedef struct
{
int z[2];
char array[10];
RECTANGLE coord[3];
} SCHEMA3;
#endif //__SCHEMA3__
Detailed information may be found on the site http://www.x2st.com.
Used languages - C++, XML.
Points of Interest
In order to prepare documentation for this project, I used "Doxygen" .
History
This is a first version.