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