Commit | Line | Data |
---|---|---|
970ed795 | 1 | /////////////////////////////////////////////////////////////////////////////// |
3abe9331 | 2 | // Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
3 | // All rights reserved. This program and the accompanying materials |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | /** | |
9 | * Predefined and standardized TTCN-3 modules | |
10 | * containing mappings of XSD element from the http://www.w3.org/2001/XMLSchema namespace | |
11 | * | |
12 | * Modules are generated always when conversion is called | |
13 | * | |
14 | */ | |
3abe9331 | 15 | const char * moduleUsefulTtcn3Types = { |
970ed795 EL |
16 | "module UsefulTtcn3Types {\n\n\n" |
17 | ||
18 | ||
19 | " type integer byte (-128 .. 127) with { variant \"/* 8 bit */\" };\n\n" | |
20 | ||
21 | " type integer unsignedbyte (0 .. 255) with { variant \"/*unsigned 8 bit*/\" };\n\n" | |
22 | ||
23 | " type integer short (-32768 .. 32767) with { variant \"/*16 bit*/\" };\n\n" | |
24 | ||
25 | " type integer unsignedshort (0 .. 65535) with { variant \"/*unsigned 16 bit*/\" };\n\n" | |
26 | ||
27 | " type integer long (-2147483648 .. 2147483647) with { variant \"/*32 bit*/\" };\n\n" | |
28 | ||
29 | " type integer unsignedlong (0 .. 4294967295) with { variant \"/*unsigned 32 bit*/\" };\n\n" | |
30 | ||
31 | " type integer longlong /* ( -9223372036854775808 .. 9223372036854775807 ) */ with { variant \"/*64 bit*/\" };\n\n" | |
32 | ||
33 | " type integer unsignedlonglong /* ( 0 .. 18446744073709551615 ) */ with { variant \"/*unsigned 64 bit*/\" };\n\n" | |
34 | ||
35 | " type float IEEE754float with { variant \"/*IEEE754 float*/\" };\n\n" | |
36 | ||
37 | " type float IEEE754double with { variant \"/*IEEE754 double*/\" };\n\n" | |
38 | ||
39 | " type float IEEE754extfloat with { variant \"/*IEEE754 extended float*/\" };\n\n" | |
40 | ||
41 | " type float IEEE754extdouble with { variant \"/*IEEE754 extended double*/\" };\n\n" | |
42 | ||
43 | " type universal charstring utf8string with { variant \"/*UTF-8*/\" };\n\n" | |
44 | ||
45 | " type universal charstring bmpstring ( char ( 0,0,0,0 ) .. char ( 0,0,255,255) ) with { variant \"/*UCS-2*/\" };\n\n" | |
46 | ||
47 | " type universal charstring utf16string ( char ( 0,0,0,0 ) .. char ( 0,16,255,255) ) with { variant \"/*UTF-16*/\" };\n\n" | |
48 | ||
49 | " type universal charstring iso8859string ( char ( 0,0,0,0 ) .. char ( 0,0,0,255) ) with { variant \"/*8 bit*/\" };\n\n" | |
50 | ||
51 | " type record IDLfixed\n" | |
52 | " {\n" | |
53 | " unsignedshort digits,\n" | |
54 | " short scale,\n" | |
55 | " charstring value_\n" | |
56 | " }\n" | |
57 | " with {\n" | |
58 | " variant \"/*IDL:fixed FORMAL/01-12-01 v.2.6*/\";\n" | |
59 | " };\n\n" | |
60 | ||
61 | " /*\n" | |
62 | " type charstring char length (1);\n\n" | |
63 | ||
64 | " NOTE 1: The name of this useful type is the same as the TTCN-3 keyword used to denote universal\n" | |
65 | " charstring values in the quadraple form. In general it is disallowed to use TTCN-3 keywords as\n" | |
66 | " identifiers. The \"char\" useful type is a solitary exception and allowed only for backward compatibility\n" | |
67 | " with previous versions of the TTCN-3 standard. (except Titan doesn't)\n\n" | |
68 | ||
69 | " NOTE 2: The special string \"8 bit\" defined in clause 28.2.3 may be used with this type to specify a given encoding\n" | |
70 | " for its values. Also, other properties of the base type can be changed by using attribute mechanisms.\n" | |
71 | " */\n\n" | |
72 | ||
73 | " type universal charstring uchar length (1);\n\n" | |
74 | ||
75 | " /*\n" | |
76 | " NOTE: Special strings defined in clause 28.2.3 except \"8 bit\" may be used with this type to specify a given\n" | |
77 | " encoding for its values. Also, other properties of the base type can be changed by using attribute\n" | |
78 | " mechanisms.\n" | |
79 | " */\n\n" | |
80 | ||
81 | " type bitstring bit length (1);\n\n" | |
82 | ||
83 | " type hexstring hex length (1);\n\n" | |
84 | ||
85 | " type octetstring octet length (1);\n\n" | |
86 | ||
87 | "}\n" | |
88 | "with {\n" | |
89 | "encode \"XML\";\n" | |
90 | "}\n" | |
91 | ||
92 | }; | |
93 | ||
3abe9331 | 94 | const char * moduleXSD = { |
970ed795 EL |
95 | |
96 | "module XSD {\n\n" | |
97 | ||
98 | "import from UsefulTtcn3Types all;\n\n" | |
99 | ||
100 | "//These constants are used in the XSD date/time type definitions\n" | |
101 | "const charstring\n" | |
102 | " dash := \"-\",\n" | |
103 | " cln := \":\",\n" | |
3abe9331 | 104 | " year := \"[0-9]#4\",\n" |
970ed795 EL |
105 | " yearExpansion := \"(-([1-9][0-9]#(0,))#(,1))#(,1)\",\n" |
106 | " month := \"(0[1-9]|1[0-2])\",\n" | |
107 | " dayOfMonth := \"(0[1-9]|[12][0-9]|3[01])\",\n" | |
108 | " hour := \"([01][0-9]|2[0-3])\",\n" | |
109 | " minute := \"([0-5][0-9])\",\n" | |
110 | " second := \"([0-5][0-9])\",\n" | |
111 | " sFraction := \"(.[0-9]#(1,))#(,1)\",\n" | |
112 | " endOfDayExt := \"24:00:00(.0#(1,))#(,1)\",\n" | |
113 | " nums := \"[0-9]#(1,)\",\n" | |
114 | " ZorTimeZoneExt := \"(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))#(,1)\",\n" | |
115 | " durTime := \"(T[0-9]#(1,)\"&\n" | |
116 | " \"(H([0-9]#(1,)(M([0-9]#(1,)(S|.[0-9]#(1,)S))#(,1)|.[0-9]#(1,)S|S))#(,1)|\"&\n" | |
117 | " \"M([0-9]#(1,)(S|.[0-9]#(1,)S)|.[0-9]#(1,)M)#(,1)|\"&\n" | |
118 | " \"S|\"&\n" | |
119 | " \".[0-9]#(1,)S))\"\n\n" | |
120 | ||
121 | "//anySimpleType\n\n" | |
122 | ||
123 | "type XMLCompatibleString AnySimpleType\n" | |
124 | "with {\n" | |
125 | "variant \"XSD:anySimpleType\";\n" | |
126 | "};\n\n" | |
127 | ||
128 | "//anyType;\n\n" | |
129 | ||
130 | "type record AnyType\n" | |
131 | "{\n" | |
3f84031e | 132 | " record of String embed_values optional,\n" |
133 | " record of String attr optional,\n" | |
970ed795 EL |
134 | " record of String elem_list\n" |
135 | "}\n" | |
136 | "with {\n" | |
137 | "variant \"XSD:anyType\";\n" | |
3f84031e | 138 | "variant \"embedValues\";\n" |
970ed795 EL |
139 | "variant (attr) \"anyAttributes\";\n" |
140 | "variant (elem_list) \"anyElement\";\n" | |
141 | "};\n" | |
142 | ||
143 | "// String types\n\n" | |
144 | ||
145 | "type XMLCompatibleString String\n" | |
146 | "with {\n" | |
147 | "variant \"XSD:string\";\n" | |
148 | "};\n\n" | |
149 | ||
150 | "type XMLStringWithNoCRLFHT NormalizedString\n" | |
151 | "with {\n" | |
152 | "variant \"XSD:normalizedString\";\n" | |
153 | "};\n\n" | |
154 | ||
155 | "type NormalizedString Token\n" | |
156 | "with {\n" | |
157 | "variant \"XSD:token\";\n" | |
158 | "};\n\n" | |
159 | ||
160 | "type XMLStringWithNoWhitespace Name\n" | |
161 | "with {\n" | |
162 | "variant \"XSD:Name\";\n" | |
163 | "};\n\n" | |
164 | ||
165 | "type XMLStringWithNoWhitespace NMTOKEN\n" | |
166 | "with {\n" | |
167 | "variant \"XSD:NMTOKEN\";\n" | |
168 | "};\n\n" | |
169 | ||
170 | "type Name NCName\n" | |
171 | "with {\n" | |
172 | "variant \"XSD:NCName\";\n" | |
173 | "};\n\n" | |
174 | ||
175 | "type NCName ID\n" | |
176 | "with {\n" | |
177 | "variant \"XSD:ID\";\n" | |
178 | "};\n\n" | |
179 | ||
180 | "type NCName IDREF\n" | |
181 | "with {\n" | |
182 | "variant \"XSD:IDREF\";\n" | |
183 | "};\n\n" | |
184 | ||
185 | "type NCName ENTITY\n" | |
186 | "with {\n" | |
187 | "variant \"XSD:ENTITY\";\n" | |
188 | "};\n\n" | |
189 | ||
190 | "type octetstring HexBinary\n" | |
191 | "with {\n" | |
192 | "variant \"XSD:hexBinary\";\n" | |
193 | "};\n\n" | |
194 | ||
195 | "type octetstring Base64Binary\n" | |
196 | "with {\n" | |
197 | "variant \"XSD:base64Binary\";\n" | |
198 | "};\n\n" | |
199 | ||
200 | "type XMLStringWithNoCRLFHT AnyURI\n" | |
201 | "with {\n" | |
202 | "variant \"XSD:anyURI\";\n" | |
203 | "};\n\n" | |
204 | ||
205 | "type charstring Language (pattern \"[a-zA-Z]#(1,8)(-\\w#(1,8))#(0,)\")\n" | |
206 | "with {\n" | |
207 | "variant \"XSD:language\";\n" | |
208 | "};\n" | |
209 | ||
210 | "// Integer types\n\n" | |
211 | ||
212 | "type integer Integer\n" | |
213 | "with {\n" | |
214 | "variant \"XSD:integer\";\n" | |
215 | "};\n\n" | |
216 | ||
217 | "type integer PositiveInteger (1 .. infinity)\n" | |
218 | "with {\n" | |
219 | "variant \"XSD:positiveInteger\";\n" | |
220 | "};\n\n" | |
221 | ||
222 | "type integer NonPositiveInteger (-infinity .. 0)\n" | |
223 | "with {\n" | |
224 | "variant \"XSD:nonPositiveInteger\";\n" | |
225 | "};\n\n" | |
226 | ||
227 | "type integer NegativeInteger (-infinity .. -1)\n" | |
228 | "with {\n" | |
229 | "variant \"XSD:negativeInteger\";\n" | |
230 | "};\n\n" | |
231 | ||
232 | "type integer NonNegativeInteger (0 .. infinity)\n" | |
233 | "with {\n" | |
234 | "variant \"XSD:nonNegativeInteger\";\n" | |
235 | "};\n\n" | |
236 | ||
237 | "type longlong Long\n" | |
238 | "with {\n" | |
239 | "variant \"XSD:long\";\n" | |
240 | "};\n\n" | |
241 | ||
242 | "type unsignedlonglong UnsignedLong\n" | |
243 | "with {\n" | |
244 | "variant \"XSD:unsignedLong\";\n" | |
245 | "};\n\n" | |
246 | ||
247 | "type long Int\n" | |
248 | "with {\n" | |
249 | "variant \"XSD:int\";\n" | |
250 | "};\n\n" | |
251 | ||
252 | "type unsignedlong UnsignedInt\n" | |
253 | "with {\n" | |
254 | "variant \"XSD:unsignedInt\";\n" | |
255 | "};\n\n" | |
256 | ||
257 | "type short Short\n" | |
258 | "with {\n" | |
259 | "variant \"XSD:short\";\n" | |
260 | "};\n\n" | |
261 | ||
262 | "type unsignedshort UnsignedShort\n" | |
263 | "with {\n" | |
264 | "variant \"XSD:unsignedShort\";\n" | |
265 | "};\n\n" | |
266 | ||
267 | "type byte Byte\n" | |
268 | "with {\n" | |
269 | "variant \"XSD:byte\";\n" | |
270 | "};\n\n" | |
271 | ||
272 | "type unsignedbyte UnsignedByte\n" | |
273 | "with {\n" | |
274 | "variant \"XSD:unsignedByte\";\n" | |
275 | "};\n\n" | |
276 | ||
277 | "// Float types\n\n" | |
278 | ||
279 | "type float Decimal\n" | |
280 | "with {\n" | |
281 | "variant \"XSD:decimal\";\n" | |
282 | "};\n\n" | |
283 | ||
284 | "type IEEE754float Float\n" | |
285 | "with {\n" | |
286 | "variant \"XSD:float\";\n" | |
287 | "};\n\n" | |
288 | ||
289 | "type IEEE754double Double\n" | |
290 | "with {\n" | |
291 | "variant \"XSD:double\";\n" | |
292 | "};\n\n" | |
293 | ||
294 | "// Time types\n\n" | |
295 | ||
296 | ||
297 | "type charstring Duration (pattern\n" | |
298 | " \"{dash}#(,1)P({nums}(Y({nums}(M({nums}D{durTime}#(,1)|{durTime}#(,1))|D{durTime}#(,1))|\" &\n" | |
299 | " \"{durTime}#(,1))|M({nums}D{durTime}#(,1)|{durTime}#(,1))|D{durTime}#(,1))|{durTime})\")\n" | |
300 | "with {\n" | |
301 | "variant \"XSD:duration\";\n" | |
302 | "};\n\n" | |
303 | ||
304 | "type charstring DateTime (pattern\n" | |
305 | " \"{yearExpansion}{year}{dash}{month}{dash}{dayOfMonth}T({hour}{cln}{minute}{cln}{second}\" &\n" | |
306 | " \"{sFraction}|{endOfDayExt}){ZorTimeZoneExt}\" )\n" | |
307 | "with {\n" | |
308 | "variant \"XSD:dateTime\";\n" | |
309 | "};\n\n" | |
310 | ||
311 | "type charstring Time (pattern\n" | |
312 | " \"({hour}{cln}{minute}{cln}{second}{sFraction}|{endOfDayExt}){ZorTimeZoneExt}\" )\n" | |
313 | "with {\n" | |
314 | "variant \"XSD:time\";\n" | |
315 | "};\n\n" | |
316 | ||
317 | "type charstring Date (pattern\n" | |
318 | " \"{yearExpansion}{year}{dash}{month}{dash}{dayOfMonth}{ZorTimeZoneExt}\" )\n" | |
319 | "with {\n" | |
320 | "variant \"XSD:date\";\n" | |
321 | "};\n\n" | |
322 | ||
323 | "type charstring GYearMonth (pattern\n" | |
324 | " \"{yearExpansion}{year}{dash}{month}{ZorTimeZoneExt}\" )\n" | |
325 | "with {\n" | |
326 | "variant \"XSD:gYearMonth\";\n" | |
327 | "};\n\n" | |
328 | ||
329 | "type charstring GYear (pattern\n" | |
330 | " \"{yearExpansion}{year}{ZorTimeZoneExt}\" )\n" | |
331 | "with {\n" | |
332 | "variant \"XSD:gYear\";\n" | |
333 | "};\n\n" | |
334 | ||
335 | "type charstring GMonthDay (pattern\n" | |
336 | " \"{dash}{dash}{month}{dash}{dayOfMonth}{ZorTimeZoneExt}\" )\n" | |
337 | "with {\n" | |
338 | "variant \"XSD:gMonthDay\";\n" | |
339 | "};\n\n" | |
340 | ||
341 | "type charstring GDay (pattern\n" | |
342 | " \"{dash}{dash}{dash}{dayOfMonth}{ZorTimeZoneExt}\" )\n" | |
343 | "with {\n" | |
344 | "variant \"XSD:gDay\";\n" | |
345 | "};\n\n" | |
346 | ||
347 | "type charstring GMonth (pattern\n" | |
348 | " \"{dash}{dash}{month}{ZorTimeZoneExt}\" )\n" | |
349 | "with {\n" | |
350 | "variant \"XSD:gMonth\";\n" | |
351 | "};\n\n" | |
352 | ||
353 | "// Sequence types\n\n" | |
354 | ||
355 | "type record of NMTOKEN NMTOKENS\n" | |
356 | "with {\n" | |
357 | "variant \"XSD:NMTOKENS\";\n" | |
358 | "};\n\n" | |
359 | ||
360 | "type record of IDREF IDREFS\n" | |
361 | "with {\n" | |
362 | "variant \"XSD:IDREFS\";\n" | |
363 | "};\n\n" | |
364 | ||
365 | "type record of ENTITY ENTITIES\n" | |
366 | "with {\n" | |
367 | "variant \"XSD:ENTITIES\";\n" | |
368 | "};\n\n" | |
369 | ||
370 | "type record QName\n" | |
371 | "{\n" | |
372 | " AnyURI uri optional,\n" | |
373 | " NCName name\n" | |
374 | "}\n" | |
375 | "with {\n" | |
376 | "variant \"XSD:QName\";\n" | |
377 | "};\n\n" | |
378 | ||
379 | "// Boolean type\n\n" | |
380 | ||
381 | "type boolean Boolean\n" | |
382 | "with {\n" | |
383 | "variant \"XSD:boolean\";\n" | |
384 | "};\n\n" | |
385 | ||
386 | "//TTCN-3 type definitions supporting the mapping of W3C XML Schema built-in datatypes\n\n" | |
387 | ||
388 | "type utf8string XMLCompatibleString\n" | |
389 | "(\n" | |
390 | " char(0,0,0,9)..char(0,0,0,9),\n" | |
391 | " char(0,0,0,10)..char(0,0,0,10),\n" | |
392 | " char(0,0,0,12)..char(0,0,0,12),\n" | |
393 | " char(0,0,0,32)..char(0,0,215,255),\n" | |
394 | " char(0,0,224,0)..char(0,0,255,253),\n" | |
395 | " char(0,1,0,0)..char(0,16,255,253)\n" | |
396 | ")\n\n" | |
397 | ||
398 | "type utf8string XMLStringWithNoWhitespace\n" | |
399 | "(\n" | |
400 | " char(0,0,0,33)..char(0,0,215,255),\n" | |
401 | " char(0,0,224,0)..char(0,0,255,253),\n" | |
402 | " char(0,1,0,0)..char(0,16,255,253)\n" | |
403 | ")\n\n" | |
404 | ||
405 | "type utf8string XMLStringWithNoCRLFHT\n" | |
406 | "(\n" | |
407 | " char(0,0,0,32)..char(0,0,215,255),\n" | |
408 | " char(0,0,224,0)..char(0,0,255,253),\n" | |
409 | " char(0,1,0,0)..char(0,16,255,253)\n" | |
410 | ")\n\n" | |
411 | ||
412 | "}\n" | |
413 | "with{\n" | |
414 | "encode \"XML\"\n" | |
415 | "}\n" | |
416 | ||
417 | }; |