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 | module XSD { | |
9 | ||
10 | import from UsefulTtcn3Types all; | |
11 | ||
12 | //These constants are used in the XSD date/time type definitions | |
13 | const charstring | |
14 | dash := "-", | |
15 | cln := ":", | |
3f84031e | 16 | year := "[0-9]#4", |
970ed795 EL |
17 | yearExpansion := "(-([1-9][0-9]#(0,))#(,1))#(,1)", |
18 | month := "(0[1-9]|1[0-2])", | |
19 | dayOfMonth := "(0[1-9]|[12][0-9]|3[01])", | |
20 | hour := "([01][0-9]|2[0-3])", | |
21 | minute := "([0-5][0-9])", | |
22 | second := "([0-5][0-9])", | |
23 | sFraction := "(.[0-9]#(1,))#(,1)", | |
24 | endOfDayExt := "24:00:00(.0#(1,))#(,1)", | |
25 | nums := "[0-9]#(1,)", | |
26 | ZorTimeZoneExt := "(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))#(,1)", | |
27 | durTime := "(T[0-9]#(1,)"& | |
28 | "(H([0-9]#(1,)(M([0-9]#(1,)(S|.[0-9]#(1,)S))#(,1)|.[0-9]#(1,)S|S))#(,1)|"& | |
29 | "M([0-9]#(1,)(S|.[0-9]#(1,)S)|.[0-9]#(1,)M)#(,1)|"& | |
30 | "S|"& | |
31 | ".[0-9]#(1,)S))" | |
32 | ||
33 | //anySimpleType | |
34 | ||
35 | type XMLCompatibleString AnySimpleType | |
36 | with { | |
37 | variant "XSD:anySimpleType"; | |
38 | }; | |
39 | ||
40 | //anyType; | |
41 | ||
42 | type record AnyType | |
43 | { | |
3f84031e | 44 | record of String embed_values optional, |
45 | record of String attr optional, | |
970ed795 EL |
46 | record of String elem_list |
47 | } | |
48 | with { | |
49 | variant "XSD:anyType"; | |
3f84031e | 50 | variant "embedValues"; |
970ed795 EL |
51 | variant (attr) "anyAttributes"; |
52 | variant (elem_list) "anyElement"; | |
53 | }; | |
54 | // String types | |
55 | ||
56 | type XMLCompatibleString String | |
57 | with { | |
58 | variant "XSD:string"; | |
59 | }; | |
60 | ||
61 | type XMLStringWithNoCRLFHT NormalizedString | |
62 | with { | |
63 | variant "XSD:normalizedString"; | |
64 | }; | |
65 | ||
66 | type NormalizedString Token | |
67 | with { | |
68 | variant "XSD:token"; | |
69 | }; | |
70 | ||
71 | type XMLStringWithNoWhitespace Name | |
72 | with { | |
73 | variant "XSD:Name"; | |
74 | }; | |
75 | ||
76 | type XMLStringWithNoWhitespace NMTOKEN | |
77 | with { | |
78 | variant "XSD:NMTOKEN"; | |
79 | }; | |
80 | ||
81 | type Name NCName | |
82 | with { | |
83 | variant "XSD:NCName"; | |
84 | }; | |
85 | ||
86 | type NCName ID | |
87 | with { | |
88 | variant "XSD:ID"; | |
89 | }; | |
90 | ||
91 | type NCName IDREF | |
92 | with { | |
93 | variant "XSD:IDREF"; | |
94 | }; | |
95 | ||
96 | type NCName ENTITY | |
97 | with { | |
98 | variant "XSD:ENTITY"; | |
99 | }; | |
100 | ||
101 | type octetstring HexBinary | |
102 | with { | |
103 | variant "XSD:hexBinary"; | |
104 | }; | |
105 | ||
106 | type octetstring Base64Binary | |
107 | with { | |
108 | variant "XSD:base64Binary"; | |
109 | }; | |
110 | ||
111 | type XMLStringWithNoCRLFHT AnyURI | |
112 | with { | |
113 | variant "XSD:anyURI"; | |
114 | }; | |
115 | ||
116 | type charstring Language (pattern "[a-zA-Z]#(1,8)(-\w#(1,8))#(0,)") | |
117 | with { | |
118 | variant "XSD:language"; | |
119 | }; | |
120 | // Integer types | |
121 | ||
122 | type integer Integer | |
123 | with { | |
124 | variant "XSD:integer"; | |
125 | }; | |
126 | ||
127 | type integer PositiveInteger (1 .. infinity) | |
128 | with { | |
129 | variant "XSD:positiveInteger"; | |
130 | }; | |
131 | ||
132 | type integer NonPositiveInteger (-infinity .. 0) | |
133 | with { | |
134 | variant "XSD:nonPositiveInteger"; | |
135 | }; | |
136 | ||
137 | type integer NegativeInteger (-infinity .. -1) | |
138 | with { | |
139 | variant "XSD:negativeInteger"; | |
140 | }; | |
141 | ||
142 | type integer NonNegativeInteger (0 .. infinity) | |
143 | with { | |
144 | variant "XSD:nonNegativeInteger"; | |
145 | }; | |
146 | ||
147 | type longlong Long | |
148 | with { | |
149 | variant "XSD:long"; | |
150 | }; | |
151 | ||
152 | type unsignedlonglong UnsignedLong | |
153 | with { | |
154 | variant "XSD:unsignedLong"; | |
155 | }; | |
156 | ||
157 | type long Int | |
158 | with { | |
159 | variant "XSD:int"; | |
160 | }; | |
161 | ||
162 | type unsignedlong UnsignedInt | |
163 | with { | |
164 | variant "XSD:unsignedInt"; | |
165 | }; | |
166 | ||
167 | type short Short | |
168 | with { | |
169 | variant "XSD:short"; | |
170 | }; | |
171 | ||
172 | type unsignedshort UnsignedShort | |
173 | with { | |
174 | variant "XSD:unsignedShort"; | |
175 | }; | |
176 | ||
177 | type byte Byte | |
178 | with { | |
179 | variant "XSD:byte"; | |
180 | }; | |
181 | ||
182 | type unsignedbyte UnsignedByte | |
183 | with { | |
184 | variant "XSD:unsignedByte"; | |
185 | }; | |
186 | ||
187 | // Float types | |
188 | ||
189 | type float Decimal | |
190 | with { | |
191 | variant "XSD:decimal"; | |
192 | }; | |
193 | ||
194 | type IEEE754float Float | |
195 | with { | |
196 | variant "XSD:float"; | |
197 | }; | |
198 | ||
199 | type IEEE754double Double | |
200 | with { | |
201 | variant "XSD:double"; | |
202 | }; | |
203 | ||
204 | // Time types | |
205 | ||
206 | type charstring Duration (pattern | |
207 | "{dash}#(,1)P({nums}(Y({nums}(M({nums}D{durTime}#(,1)|{durTime}#(,1))|D{durTime}#(,1))|" & | |
208 | "{durTime}#(,1))|M({nums}D{durTime}#(,1)|{durTime}#(,1))|D{durTime}#(,1))|{durTime})") | |
209 | with { | |
210 | variant "XSD:duration"; | |
211 | }; | |
212 | ||
213 | type charstring DateTime (pattern | |
214 | "{yearExpansion}{year}{dash}{month}{dash}{dayOfMonth}T({hour}{cln}{minute}{cln}{second}" & | |
215 | "{sFraction}|{endOfDayExt}){ZorTimeZoneExt}" ) | |
216 | with { | |
217 | variant "XSD:dateTime"; | |
218 | }; | |
219 | ||
220 | type charstring Time (pattern | |
221 | "({hour}{cln}{minute}{cln}{second}{sFraction}|{endOfDayExt}){ZorTimeZoneExt}" ) | |
222 | with { | |
223 | variant "XSD:time"; | |
224 | }; | |
225 | ||
226 | type charstring Date (pattern | |
227 | "{yearExpansion}{year}{dash}{month}{dash}{dayOfMonth}{ZorTimeZoneExt}" ) | |
228 | with { | |
229 | variant "XSD:date"; | |
230 | }; | |
231 | ||
232 | type charstring GYearMonth (pattern | |
233 | "{yearExpansion}{year}{dash}{month}{ZorTimeZoneExt}" ) | |
234 | with { | |
235 | variant "XSD:gYearMonth"; | |
236 | }; | |
237 | ||
238 | type charstring GYear (pattern | |
239 | "{yearExpansion}{year}{ZorTimeZoneExt}" ) | |
240 | with { | |
241 | variant "XSD:gYear"; | |
242 | }; | |
243 | ||
244 | type charstring GMonthDay (pattern | |
245 | "{dash}{dash}{month}{dash}{dayOfMonth}{ZorTimeZoneExt}" ) | |
246 | with { | |
247 | variant "XSD:gMonthDay"; | |
248 | }; | |
249 | ||
250 | type charstring GDay (pattern | |
251 | "{dash}{dash}{dash}{dayOfMonth}{ZorTimeZoneExt}" ) | |
252 | with { | |
253 | variant "XSD:gDay"; | |
254 | }; | |
255 | ||
256 | type charstring GMonth (pattern | |
257 | "{dash}{dash}{month}{ZorTimeZoneExt}" ) | |
258 | with { | |
259 | variant "XSD:gMonth"; | |
260 | }; | |
261 | ||
262 | // Sequence types | |
263 | ||
264 | type record of NMTOKEN NMTOKENS | |
265 | with { | |
266 | variant "XSD:NMTOKENS"; | |
267 | }; | |
268 | ||
269 | type record of IDREF IDREFS | |
270 | with { | |
271 | variant "XSD:IDREFS"; | |
272 | }; | |
273 | ||
274 | type record of ENTITY ENTITIES | |
275 | with { | |
276 | variant "XSD:ENTITIES"; | |
277 | }; | |
278 | ||
279 | type record QName | |
280 | { | |
281 | AnyURI uri optional, | |
282 | NCName name | |
283 | } | |
284 | with { | |
285 | variant "XSD:QName"; | |
286 | }; | |
287 | ||
288 | // Boolean type | |
289 | ||
290 | type boolean Boolean | |
291 | with { | |
292 | variant "XSD:boolean"; | |
293 | }; | |
294 | ||
295 | //TTCN-3 type definitions supporting the mapping of W3C XML Schema built-in datatypes | |
296 | ||
297 | type utf8string XMLCompatibleString | |
298 | ( | |
299 | char(0,0,0,9)..char(0,0,0,9), | |
300 | char(0,0,0,10)..char(0,0,0,10), | |
301 | char(0,0,0,12)..char(0,0,0,12), | |
302 | char(0,0,0,32)..char(0,0,215,255), | |
303 | char(0,0,224,0)..char(0,0,255,253), | |
304 | char(0,1,0,0)..char(0,16,255,253) | |
305 | ) | |
306 | ||
307 | type utf8string XMLStringWithNoWhitespace | |
308 | ( | |
309 | char(0,0,0,33)..char(0,0,215,255), | |
310 | char(0,0,224,0)..char(0,0,255,253), | |
311 | char(0,1,0,0)..char(0,16,255,253) | |
312 | ) | |
313 | ||
314 | type utf8string XMLStringWithNoCRLFHT | |
315 | ( | |
316 | char(0,0,0,32)..char(0,0,215,255), | |
317 | char(0,0,224,0)..char(0,0,255,253), | |
318 | char(0,1,0,0)..char(0,16,255,253) | |
319 | ) | |
320 | ||
321 | } | |
322 | with{ | |
323 | encode "XML" | |
324 | } |