📄 rfc3072.txt
字号:
Network Working Group M. Wildgrube
Request for Comments: 3072 March 2001
Category: Informational
Structured Data Exchange Format (SDXF)
Status of this Memo
This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2001). All Rights Reserved.
IESG Note
This document specifies a data exchange format and, partially, an API
that can be used for creating and parsing such a format. The IESG
notes that the same problem space can be addressed using formats that
the IETF normally uses including ASN.1 and XML. The document reader
is strongly encouraged to carefully read section 13 before choosing
SDXF over ASN.1 or XML. Further, when storing text in SDXF, the user
is encourage to use the datatype for UTF-8, specified in section 2.5.
Abstract
This specification describes an all-purpose interchange format for
use as a file format or for net-working. Data is organized in chunks
which can be ordered in hierarchical structures. This format is
self-describing and CPU-independent.
Table of Contents
1. Introduction ................................................. 2
2. Description of the SDXF data format .......................... 3
3. Introduction to the SDXF functions ........................... 5
3.1 General remarks .............................................. 5
3.2 Writing a SDXF buffer ........................................ 5
3.3 Reading a SDXF buffer ........................................ 6
3.4 Example ...................................................... 6
4. Platform independence ........................................ 8
5. Compression .................................................. 9
6. Encryption ...................................................11
7. Arrays........................................................11
8. Description of the SDXF functions ............................12
Wildgrube Informational [Page 1]
RFC 3072 Structured Data Exchange Format March 2001
8.1 Introduction .................................................12
8.2 Basic definitions ............................................13
8.3 Definitions for C++ ..........................................15
8.4 Common Definitions ...........................................16
8.5 Special functions ............................................17
9. 'Support' of UTF-8 ...........................................19
10. Security Considerations .....................................19
11. Some general hints ..........................................20
12. IANA Considerations .........................................20
13. Discussion ..................................................21
13.1 SDXF vs. ASN.1 ..............................................21
13.2 SDXF vs. XML ................................................22
14. Author's Address ............................................24
15. Acknowledgements ............................................24
16. References ..................................................24
17. Full Copyright Statement ....................................26
1. Introduction
The purpose of the Structured Data eXchange Format (SDXF) is to
permit the interchange of an arbitrary structured data block with
different kinds of data (numerical, text, bitstrings). Because data
is normalized to an abstract computer architecture independent
"network format", SDXF is usable as a network interchange data
format.
This data format is not limited to any application, the demand for
this format is that it is usable as a text format for word-
processing, as a picture format, a sound format, for remote procedure
calls with complex parameters, suitable for document formats, for
interchanging business data, etc.
SDXF is self-describing, every program can unpack every SDXF-data
without knowing the meaning of the individual data elements.
Together with the description of the data format a set of functions
will be introduced. With the help of these functions one can create
and access the data elements of SDXF. The idea is that a programmer
should only use these functions instead of maintaining the structure
by himself on the level of bits and bytes. (In the speech of
object-oriented programming these functions are methods of an object
which works as a handle for a given SDXF data block.)
SDXF is not limited to a specific platform, along with a correct
preparation of the SDXF functions the SDXF data can be interchanged
(via network or data carrier) across the boundaries of different
architectures (specified by the character code like ASCII, ANSI or
EBCDIC and the byte order for binary data).
Wildgrube Informational [Page 2]
RFC 3072 Structured Data Exchange Format March 2001
SDXF is also prepared to compress and encrypt parts or the whole
block of SDXF data.
2. Description of SDXF data format.
2.1 First we introduce the term "chunk". A chunk is a data structure
with a fixed set of components. A chunk may be "elementary" or
"structured". The latter one contains itself one or more other
chunks.
A chunk consists of a header and the data body (content):
+----------+-----+-------+-----------------------------------+
| Name | Pos.| Length| Description |
+----------+-----+-------+-----------------------------------+
| chunk-ID | 1 | 2 | ID of the chunk (unsigned short) |
| flags | 3 | 1 | type and properties of this chunk |
| length | 4 | 3 | length of the following data |
| content | 7 | *) | net data or a list of of chunks |
+----------+-----+-------+-----------------------------------+
(* as stated in "length". total length of chunk is length+6. The
chunk ID is a non-zero positive number.
or more visually:
+----+----+----+----+----+----+----+----+----+-...
| chunkID | fl | length | content
+----+----+----+----+----+----+----+----+----+-...
or in ASN.1 syntax:
chunk ::= SEQUENCE
{
chunkID INTEGER (1..65535),
flags BIT STRING,
length OCTET STRING SIZE 3, -- or: INTEGER (0..16777215)
content OCTET STRING
}
2.2 Structured chunk.
A structured chunk is marked as such by the flag byte (see 2.5).
Opposed to an elementary chunk its content consists of a list of
chunks (elementary or structured):
Wildgrube Informational [Page 3]
RFC 3072 Structured Data Exchange Format March 2001
+----+-+---+-------+-------+-------+-----+-------+
| id |f|len| chunk | chunk | chunk | ... | chunk |
+----+-+---+-------+-------+-------+-----+-------+
With the help of this concept you can reproduce every hierarchically
structured data into a SDXF chunk.
2.3 Some Remarks about the internal representation of the chunk's
elements:
Binary values are always in high-order-first (big endian) format,
like the binary values in the IP header (network format). A length
of 300 (=256 + 32 + 12) is stored as
+----+----+----+----+----+----+----+----+----+--
| | | 00 01 2C | content
+----+----+----+----+----+----+----+----+----+--
in hexadecimal notation.
This is also valid for the chunk-ID.
2.4 Character values in the content portion are also an object of
adaptation: see chapter 4.
2.5 Meaning of the flag-bits: Let us represent the flag byte in this
manner:
+-+-+-+-+-+-+-+-+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
| | | | | | | |
| | | | | | | +-- reserved
| | | | | | +---- array
| | | | | +------ short chunk
| | | | +-------- encrypted chunk
| | | +---------- compressed chunk
| | |
+-+-+------------ data type (0..7)
data types are:
0 -- pending structure (chunk is inconsistent, see also 11.1)
1 -- structure
2 -- bit string
3 -- numeric
4 -- character
5 -- float (ANSI/IEEE 754-1985)
Wildgrube Informational [Page 4]
RFC 3072 Structured Data Exchange Format March 2001
6 -- UTF-8
7 -- reserved
2.6 A short chunk has no data body. The 3 byte Length field is used as
data bytes instead. This is used in order to save space when there
are many small chunks.
2.7 Compressed and encrypted chunks are explained in chapter 5 and 6.
2.8 Arrays are explained in chapter 7.
2.9 Handling of UTF-8 is explained in chapter 9.
2.10 Not all combinations of bits are allowed or reasonable:
- the flags 'array' and 'short' are mutually exclusive.
- 'short' is not applicable for data type 'structure' and 'float'.
- 'array' is not applicable for data type 'structure'.
3. Introduction to the SDXF functions
3.1 General remarks
The functionality of the SDXF concept is not bounded to any
programming language, but of course the functions themselves must be
coded in a particular language. I discuss these functions in C and
C++, because in the meanwhile these languages are available on almost
all platforms.
All these functions for reading and writing SDXF chunks uses only one
parameter, a parameter structure. In C++ this parameter structure is
part of the "SDXF class" and the SDXF functions are methods of this
class.
An exact description of the interface is given in chapter 8.
3.2 Writing a SDXF buffer
For to write SDXF chunks, there are following functions:
init -- initialize the parameter structure
create -- create a new chunk
leave -- "close" a structured chunk
Wildgrube Informational [Page 5]
RFC 3072 Structured Data Exchange Format March 2001
3.3 Reading a SDXF buffer
For to read SDXF chunks, there are following functions:
init -- initialize the parameter structure
enter -- "go into" a structured chunk
next -- "go to" the next chunk inside a structured chunk
extract -- extract the content of an elementary chunk into
user's data area
leave -- "go out" off a structured chunk
3.4 Example:
3.4.1 Writing:
For demonstration we use a reduced (outlined) C++ Form of these
functions with polymorph definitions:
void create (short chunkID); // opens a new structure,
void create (short chunkID, char *string);
// creates a new chunk with dataType character, etc.)
The sequence:
SDXF x(new); // create the SDXF object "x" for a new chunk
// includes the "init"
x.create (3301); // opens a new structure
x.create (3302, "first chunk");
x.create (3303, "second chunk");
x.create (3304); // opens a new structure
x.create (3305, "chunk in a structure");
x.create (3306, "next chunk in a structure");
x.leave (); // closes the inner structure
x.create (3307, "third chunk");
x.leave (); // closes the outer structure
Wildgrube Informational [Page 6]
RFC 3072 Structured Data Exchange Format March 2001
creates a chunk which we can show graphically like:
3301
|
+--- 3302 = "first chunk"
|
+--- 3303 = "second chunk"
|
+--- 3304
| |
| +--- 3305 = "chunk in a structure"
| |
| +--- 3306 = "next chunk in a structure"
|
+--- 3307 = "last chunk"
3.4.2 Reading
A typically access to a structured SDXF chunk is a selection inside
a loop:
SDXF x(old); // defines a SDXF object "x" for an old chunk
x.enter (); // enters the structure
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -