3
-- Copyright (C) 2004 Laurent Mazet
5
-- This program is free software; you can redistribute it and/or modify
6
-- it under the terms of the GNU General Public License as published by
7
-- the Free Software Foundation; either version 2 of the License, or
8
-- (at your option) any later version.
10
-- This program is distributed in the hope that it will be useful,
11
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
-- GNU General Public License for more details.
15
-- You should have received a copy of the GNU General Public License
16
-- along with this program; if not, see <http://www.gnu.org/licenses/>.
23
<!DOCTYPE actions SYSTEM "flexml-act.dtd">
35
#define warning perror
44
<start tag='octave'><![CDATA[
46
root->def_value = value_data;
47
current = &(root->child);
49
lastlist = new_list(lastlist);
50
lastlist->root = current;
53
<end tag='octave'><![CDATA[
54
current = lastlist->root;
55
lastlist = pop_list(lastlist);
56
current = &((*current)->next);
61
<start tag='scalar'><![CDATA[
62
*current = new_element();
65
(*current)->name = (char *) malloc(strlen({name})+1);
66
strcpy ((*current)->name, {name});
69
(*current)->def_value = value_scalar;
71
case {value=true}: (*current)->const_value = const_true; break;
72
case {value=false}: (*current)->const_value = const_false; break;
73
case {value=inf}: (*current)->const_value = const_inf; break;
74
case {value=neginf}: (*current)->const_value = const_neginf; break;
75
case {value=nan}: (*current)->const_value = const_nan; break;
76
case {value=na}: (*current)->const_value = const_na; break;
77
default: (*current)->const_value = const_undef;
81
<end tag='scalar'><![CDATA[
82
if (((*current)->const_value == const_undef) && ({#PCDATA}))
83
(*current)->scalar_value = strtod ({#PCDATA}, NULL);
85
(*(lastlist->root))->nb_elements++;
87
current = &((*current)->next);
92
<start tag='string'><![CDATA[
93
*current = new_element();
96
(*current)->name = (char *) malloc(strlen({name})+1);
97
strcpy ((*current)->name, {name});
101
(*current)->length = strtol ({length}, NULL, 10);
103
(*current)->def_value = value_string;
106
<end tag='string'><![CDATA[
109
int len = strlen({#PCDATA});
110
/* check length parameter */
111
if ((*current)->length != len) {
112
warning("incorrect length parameter for string\n");
113
(*current)->length = len;
116
(*current)->string_value = (char *) malloc ((len+1) * sizeof(char));
117
strcpy((*current)->string_value, {#PCDATA});
120
(*(lastlist->root))->nb_elements++;
122
current = &((*current)->next);
127
<start tag='complex'><![CDATA[
128
*current = new_element();
131
(*current)->name = (char *) malloc(strlen({name})+1);
132
strcpy ((*current)->name, {name});
135
(*current)->def_value = value_complex;
137
lastlist = new_list(lastlist);
138
lastlist->root = current;
139
current = &((*current)->child);
142
<end tag='complex'><![CDATA[
143
current = lastlist->root;
144
lastlist = pop_list(lastlist);
146
(*(lastlist->root))->nb_elements++;
148
current = &((*current)->next);
153
<start tag='array'><![CDATA[
154
*current = new_element();
157
(*current)->name = (char *) malloc(strlen({name})+1);
158
strcpy ((*current)->name, {name});
162
(*current)->rows = strtol ({rows}, NULL, 10);
164
(*current)->def_value = value_array;
166
lastlist = new_list(lastlist);
167
lastlist->root = current;
168
current = &((*current)->child);
171
<end tag='array'><![CDATA[
172
/* check rows parameter */
173
if ((*(lastlist->root))->rows != (*(lastlist->root))->nb_elements) {
174
warning("incorrect length parameter for array\n");
175
(*(lastlist->root))->rows = (*(lastlist->root))->nb_elements;
178
current = lastlist->root;
179
lastlist = pop_list(lastlist);
181
(*(lastlist->root))->nb_elements++;
183
current = &((*current)->next);
188
<start tag='matrix'><![CDATA[
189
*current = new_element();
192
(*current)->name = (char *) malloc(strlen({name})+1);
193
strcpy ((*current)->name, {name});
197
(*current)->rows = strtol ({rows}, NULL, 10);
200
(*current)->columns = strtol ({columns}, NULL, 10);
202
(*current)->def_value = value_matrix;
204
lastlist = new_list(lastlist);
205
lastlist->root = current;
206
current = &((*current)->child);
209
<end tag='matrix'><![CDATA[
210
/* check (rows, columns) parameters */
211
if ((*(lastlist->root))->rows * (*(lastlist->root))->columns !=
212
(*(lastlist->root))->nb_elements) {
213
warning("incorrect (rows, columns) parameters for matrix: reshaping matrix into vector\n");
214
(*(lastlist->root))->rows = 1;
215
(*(lastlist->root))->columns = (*(lastlist->root))->nb_elements;
218
current = lastlist->root;
219
lastlist = pop_list(lastlist);
221
(*(lastlist->root))->nb_elements++;
223
current = &((*current)->next);
228
<start tag='structure'><![CDATA[
229
*current = new_element();
232
(*current)->name = (char *) malloc(strlen({name})+1);
233
strcpy ((*current)->name, {name});
236
(*current)->def_value = value_structure;
238
lastlist = new_list(lastlist);
239
lastlist->root = current;
240
current = &((*current)->child);
243
<end tag='structure'><![CDATA[
244
/* no check possible (sic) */
246
current = lastlist->root;
247
lastlist = pop_list(lastlist);
249
(*(lastlist->root))->nb_elements++;
251
current = &((*current)->next);
256
<start tag='list'><![CDATA[
257
*current = new_element();
260
(*current)->name = (char *) malloc(strlen({name})+1);
261
strcpy ((*current)->name, {name});
265
(*current)->length = strtol ({length}, NULL, 10);
267
(*current)->def_value = value_list;
269
lastlist = new_list(lastlist);
270
lastlist->root = current;
271
current = &((*current)->child);
274
<end tag='list'><![CDATA[
275
/* check length parameter */
276
if ((*(lastlist->root))->length != (*(lastlist->root))->nb_elements) {
277
warning("incorrect length parameter for list\n");
278
(*(lastlist->root))->length = (*(lastlist->root))->nb_elements;
281
current = lastlist->root;
282
lastlist = pop_list(lastlist);
284
(*(lastlist->root))->nb_elements++;
286
current = &((*current)->next);
291
<start tag='cell'><![CDATA[
292
*current = new_element();
295
(*current)->name = (char *) malloc(strlen({name})+1);
296
strcpy ((*current)->name, {name});
300
(*current)->rows = strtol ({rows}, NULL, 10);
303
(*current)->columns = strtol ({columns}, NULL, 10);
305
(*current)->def_value = value_cell;
307
lastlist = new_list(lastlist);
308
lastlist->root = current;
309
current = &((*current)->child);
312
<end tag='cell'><![CDATA[
313
/* check (rows, columns) parameters */
314
if ((*(lastlist->root))->rows * (*(lastlist->root))->columns !=
315
(*(lastlist->root))->nb_elements) {
316
warning("incorrect (rows, columns) parameters for cell: reshaping cell into list\n");
317
(*(lastlist->root))->def_value = value_list;
318
(*(lastlist->root))->length = (*(lastlist->root))->nb_elements;
321
current = lastlist->root;
322
lastlist = pop_list(lastlist);
324
(*(lastlist->root))->nb_elements++;
326
current = &((*current)->next);
332
element *read_xmltree (const char *file) {
338
xml_in = fopen(file, "r");
340
perror("can't open file\n");