File: rdf_net.sql

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (171 lines) | stat: -rw-r--r-- 3,973 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
--
--  $Id$
--
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--
--  Copyright (C) 1998-2012 OpenLink Software
--
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--

-- SERVER

DB.DBA.VHOST_REMOVE (lpath=>'/rdf_net')
;

DB.DBA.VHOST_DEFINE (lpath=>'/rdf_net', ppath=>'/rdf_net')
;

-- use RDF_NET
-- ;

--create procedure RDF_NET.RDF_NET.rdf_net ()  __SOAP_HTTP 'text/html'
create procedure rdf_net ()  __SOAP_HTTP 'text/html'
{
  ;
}
;

grant execute on DB.DBA.rdf_net to public
;

create procedure DB.DBA.HTTP_RDF_NET (in _q any)
{
  declare res, mdta, dta any;
  declare state, msg, _check any;
  declare ses any;

  _q := trim (_q);

  if (_q= '') return;

  _check := sql_parse (_q);
  if (_check [0] <> 100)
	 signal ('rdf_net', 'Error in query.');

  res := exec (_q,   state, msg, vector (), 0, mdta, dta);

  DB.DBA.rdf_net_make_struct (mdta, dta);

  return mdta;
}
;


create procedure
rdf_net_format_mdta (inout mdta any)
{
   declare idx, _line, _name, temp any;

   temp := mdta[0];

   for (idx := 0; idx < length (temp); idx := idx + 1)
     {
	_line := temp[idx];
	_name := temp[idx][0];
	_name := replace (_name, ' ', '_');
	aset (_line, 0, _name);
	aset (temp, idx, _line);
     }

    aset (mdta, 0, temp);
}
;



create procedure
rdf_net_make_xml (inout dta any, inout mdta any)
{
  declare i, l, idx int;
  declare ses any;
  declare xsd varchar;

  ses := string_output ();
  http ('<?xml version="1.0" ?>\n', ses);
  http ('<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns="http://example.org/book/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns="http://example.org/ns#">\n', ses);
  i := 0; l := length (dta);
  while (i < l)
    {
      declare _name, _row, _line varchar;
      declare _type, _type_name, nill int;
      _row := dta[i];
      for (idx := 2; idx < length (_row); idx := idx + 2)
	 {
	    _type := _row[idx];
	    _name := _row[idx + 1];
	    _type := cast (_type as varchar);
	    _name := cast (_name as varchar);
--	    http (sprintf ('<rdf:Description rdf:about="row">\n'), ses);
	    http (sprintf ('<rdf:Description>\n'), ses);
	    http (sprintf ('<%s>%s</%s>\n', _type, _name, _type), ses);
	    http ('</rdf:Description>\n', ses);
	 }
      i := i + 1;
    }
  http ('</rdf:RDF>', ses);
  xsd := string_output_string (ses);
  mdta := xsd;
  return;
}
;


create procedure
rdf_net_make_element (in mdta any, in dta any)
{
  declare res any;
  declare i, l, i1, i2 int;
  i := 0; l := length (mdta); i1 := 2; i2 := 3;
  res := make_array (2 + (l*2), 'any');
  while (i < l)
    {
      aset (res, i1, mdta[i][0]);
      if (mdta[i][1] = 131 and not isblob(dta[i]))
	 aset (res, i2, cast (dta[i] as varbinary));
      else
         aset (res, i2, dta[i]);
      i := i + 1;
      i1 := i1 + 2;
      i2 := i1 + 1;
    }
  return res;
}
;


create procedure rdf_net_make_struct (inout mdta any, inout dta any)
{
  declare res any;
  declare i, l int;
  mdta := mdta[0];
  i := 0; l := length (dta);
  res := make_array (l, 'any');
  while (i < l)
    {
      aset (res, i, rdf_net_make_element (mdta, dta[i]));
      i := i + 1;
    }
  dta := res;
  rdf_net_make_xml (dta, mdta);
}
;

grant execute on DB.DBA.HTTP_RDF_NET to public
;
-- CLIENT

--use DB;