List of articles   Terminology   Choose language


Input and output of data


Format of input and output data

SQL4 itself make HTTP-connection. Input data is XML-text (with so indulgence, that if xml-element has not enclosed elements, then he can have no sign slash before closing angular bracket), output data is XML-text. Client gets picture from database by its URL and separately from XML-data.

Input of data

Actions at appearance of data

DBMS execute the following after getting of input data:

How xml-tree is written into database

Success of writing of xml-trees into database depends of, is scheme of database corresponds to entering tree (some xml-sub-trees are ignored at discrepancy). It's possible to provide congruence by determination in xml-tree in disputable cases. It's supposed in example below, that all primary keys have sequences, values from which are entered into these keys by default.

enter into DBMS DDL entered
<formdata>
  <a        data=12.3>
    <b      data=23.4>
    <b      data=34.5>
    <b      data=45.6>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  data float
);
create table b (
  id   num      primary key,
  ref  num      references a(id),
  data float
);
insert into formdata values (1);
insert into a        values (10,   1, 12.3);
insert into b        values (101, 10, 23.4);
insert into b        values (102, 10, 34.5);
insert into b        values (103, 10, 45.6);

-- section "b" is set
<formdata>
  <a        data=12.3>
    <b      data=23.4>
    <b      data=34.5>
    <b      data=45.6>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  data float
);
create table b (
  id   num      primary key,
  ref1 num      references a(id),
  ref2 num      references a(id),
  data float
);
insert into formdata values (1);
insert into a        values (10,   1, 12.3);
<formdata>
  <a/ref1   data=12.3>
    <b      data=23.4>
    <b      data=34.5>
    <b      data=45.6>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  data float
);
create table b (
  id   num      primary key,
  ref1 num      references a(id),
  ref2 num      references a(id),
  data float
);
insert into formdata values (1);
insert into a        values (10,   1,       12.3);
insert into b        values (101, 10, null, 23.4);
insert into b        values (102, 10, null, 34.5);
insert into b        values (103, 10, null, 45.6);


<formdata>
  <a        data=12.3>
    <b      data=23.4>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  ref  num      references b(id),
  data float
);
create table b (
  id   num      primary key,
  data float
);
insert into formdata values (1);
insert into a        values (10,  1, 100, 12.3);
insert into b        values (100,         23.4);

-- section "b" is relay-race
<formdata>
  <a        data=12.3>
    <b      data=23.4>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  ref1 num      references b(id),
  ref2 num      references b(id),
  data float
);
create table b (
  id   num      primary key,
  data float
);
insert into formdata values (1);
insert into a        values (10,  1, null, null, 12.3);
<formdata>
  <a        data=12.3>
    <b/ref1 data=23.4>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  ref1 num      references b(id),
  ref2 num      references b(id),
  data float
);
create table b (
  id   num      primary key,
  data float
);
insert into formdata values (1);
insert into a        values (10,  1, 100, null, 12.3);
insert into b        values (100,               23.4);
<formdata>
  <a        data=12.3>
    <b      data=23.4>
    <b      data=34.5>
    <b      data=45.6>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  ref  num      references b(id),
  data float
);
create table b (
  id   num      primary key,
  data float
);
insert into formdata values (1);
insert into a        values (10, 1, null, 12.3);

-- section "b" is not entered (all tags together!),
-- because scheme of database contain
-- no set and no list for it


<formdata>
  <a        data=12.3>
    <b      data=23.4>
    <b      data=34.5>
    <b      data=45.6>
  </a>
</formdata>
create table a (
  id   num      primary key,
  srv  num      references formdata,
  ref  num      references b(id),
  data float
);
create table b (
  id   num      primary key,
  ref  num      references b(id),
  data float
);
insert into formdata values (1);
insert into a        values (10,  1, 101, 12.3);
insert into b        values (101,    102, 23.4);
insert into b        values (102,    103, 34.5);
insert into b        values (103,   null, 45.6);

-- section "b" is list

Output of data

Hiding of records and fields

It's necessary to put sign "#" before names of some tables and fields to prevent output of them.

a[data10.1].#b.c[#data] ;
<a   id=1   data=10.1>
  <c id=100 />
  <c id=101 />
  <c id=200 />
  <c id=201 />
  <c id=200 />
</a>
It's necessary to put sign "#" before field's brackets and to mention printable fields to prevent output of all fields except several necessary fields (fields go to output in order of listing).
a[data10.1].#b.c#[id] ;
<a   id=1   data=10.1>
  <c id=100 />
  <c id=101 />
  <c id=200 />
  <c id=201 />
  <c id=200 />
</a>

Sorting of records

If section is list, then it's possible to sort output of its elements (records) by increasing or decreasing of values of some fields. For this purpose, it's necessary to put integer and mark "" before names of these fields (we shall name this number as factor. Factor may not be equal to zero). Fields will be used for sorting in sequence, in which modules of their factors grow. Positive factor means sorting by increasing, negative factor - by decreasing. Thus TML-expression

m[30m1  10m2  -20m3]
is equivalent to DML-expression
order by m2 asc, m3 desc, m1 asc
Output is transformed so:
a.b.c ;
<a     id=1   data=12.3>
  <b   id=10  data=23.4>
    <c id=100 data=56.7/>
    <c id=101 data=67.8/>
  </b>
  <b   id=20  data=34.5>
    <c id=200 data=78.9/>
    <c id=201 data=89.1/>
  </b>
  <b   id=30  data=45.6>
    <c id=200 data=91.2/>
  </b>
</a>
a.b[-1data].c[-1data] ;
<a     id=1   data=12.3>
  <b   id=30  data=45.6>
    <c id=200 data=91.2/>
  </b>
  <b   id=20  data=34.5>
    <c id=201 data=89.1/>
    <c id=200 data=78.9/>
  </b>
  <b   id=10  data=23.4>
    <c id=101 data=67.8/>
    <c id=100 data=56.7/>
  </b>
</a>

Starting of records

It's possible to request no all unsorted records, but only records, beginning from some certain record, about which we know values of all its fields. For this purpose, it's necessary to put mark "" before names of all fields, and sign "=" and value of field after names. Thus TML-expression

m[m1=100 m2=null m3='string']
is equivalent to
DML-expression
start by m1=100 m2=null m3='string'

It's possible to request no all sorted records, but only records, beginning from some certain record - it's necessary to apply simultaneously sorting and starting for this. Thus TML-expression

m[30m1=100 10m2=null -20m3='string']
is equivalent to DML-expression
order by m2 asc, m3 desc, m1 asc
start by m1=100 m2=null m3='string'

Output of picture

Picture can be value of database field, but its URL is sent as value of field instead of it at TML-request for separate HTTP-request of browser. In HTML4 browser can use this attribute (field) only if its name is "src" and it is in tag (table) "IMG". In HTML5 browser can use it in attribute "src" of any tag, it last has property "display: img".

x ;
<x id="10"
   data1="Larry"
   data2="http://distination.org/?file_id=6382503452">

Output of arbitrary text

It's possible to send any text

'<?xml-stylesheet type="text/xsl" href="a.xsl"?>' ;
<?xml-stylesheet type="text/xsl" href="a.xsl"?>
'text' ;
text
'<anytag>' ;
<anytag>
'</anytag>' ;
</anytag>
and data of database: if expression, making output, changes values of fields, then these new values are not written into a database, but exist only in senting data; refering fields, used in request, are not go into xml-text.
a[data10.1].b.c ;
<a     id=1   data=10.1>
  <b   id=10  data=23.4>
    <c id=100 data=56.7/>
    <c id=101 data=67.8/>
  </b>
  <b   id=20  data=34.5>
    <c id=200 data=78.9/>
    <c id=201 data=89.1/>
  </b>
  <b   id=30  data=45.6>
    <c id=200 data=91.2/>
  </b>
</a>

Changing address of receiver

Data is send to destination, which is specified in fields ral and ru of table sys at moment of sending. These values point to browser, sent request, at start of trigger of table 'formdata', but it's possible to change them in any moment (thus database itself can make request into other databases to create answer for browser).

If you want to duplicate a tree in a database, then send it to youself - ran=0 for that.



Dmitry Turin



List of articles   Terminology   Choose language


Сайт управляется системой uCoz