Click here to Skip to main content
Click here to Skip to main content

Tagged as

External Description Data Structure

, 26 Aug 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Xsd2Struct is a software for the creation and run-time processing of an external description data structure.

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:

  1. Reading Xml-files, filled by the User, for editing binary data in accordance with the needed XSD.
  2. 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.

generalpage.jpg

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.

generalpage.jpg

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:

<?xml version="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 comment     -->
   <Template name="POINT">
<!--     x comment     -->
      <Item name="x" type="int"/>
      <Item name="y" type="int"/>
      <Item_enum name="pen" type="COLOR" nrepetitions="2"/>
   </Template>
<!--    RECTANGLE comment    -->
   <Template name="RECTANGLE">
<!--    Structure name="point" comment    -->
      <Structure name="point" type="POINT"/>
   </Template>
<!--    z comment    -->
   <Item name="z" type="int" nrepetitions="2"/>
   <Item name="array" type="char" nrepetitions="10" visibility="0"/>
<!--    coord comment    -->
   <Structure name="coord" type="RECTANGLE" nrepetitions="3"/>
</Schema>

Generated include-file for this schema:

//schema3.h

#ifndef __SCHEMA3__
#define __SCHEMA3__
// id=1

typedef enum
{
   red=1,
   green=2,
   blue=3,
   white=4,
   black=5
} COLOR;
 
//--- size of structure = 16
/*
    Template name=POINT comment     
*/
typedef struct
{
/*
     x comment     
*/
   int x;
   int y;
   COLOR pen[2];
} POINT;
 
//--- size of structure = 16
/*
    RECTANGLE comment    
*/
typedef struct
{
/*
    Structure name="point" comment    
*/
   POINT point;
} RECTANGLE;
 
//--- size of structure = 66
typedef struct
{
/*
    z comment    
*/
    int z[2];
    char array[10];
/*
    coord comment    
*/
    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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ion_tichy
Software Developer (Senior)
Israel Israel
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141216.1 | Last Updated 26 Aug 2011
Article Copyright 2011 by Ion_tichy
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid