0
|
1 /*
|
|
2 schema.h
|
|
3
|
|
4 XSD binding schema interface
|
|
5
|
|
6 --------------------------------------------------------------------------------
|
|
7 gSOAP XML Web services tools
|
|
8 Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved.
|
|
9 This software is released under one of the following licenses:
|
|
10 GPL or Genivia's license for commercial use.
|
|
11 --------------------------------------------------------------------------------
|
|
12 GPL license.
|
|
13
|
|
14 This program is free software; you can redistribute it and/or modify it under
|
|
15 the terms of the GNU General Public License as published by the Free Software
|
|
16 Foundation; either version 2 of the License, or (at your option) any later
|
|
17 version.
|
|
18
|
|
19 This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
21 PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
22
|
|
23 You should have received a copy of the GNU General Public License along with
|
|
24 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
25 Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26
|
|
27 Author contact information:
|
|
28 engelen@genivia.com / engelen@acm.org
|
|
29 --------------------------------------------------------------------------------
|
|
30 A commercial use license is available from Genivia, Inc., contact@genivia.com
|
|
31 --------------------------------------------------------------------------------
|
|
32
|
|
33 */
|
|
34
|
|
35 //gsoap xs schema documentation: XSD binding schema
|
|
36 //gsoap xs schema namespace: http://www.w3.org/2001/XMLSchema
|
|
37 //gsoap xs schema elementForm: qualified
|
|
38 //gsoap xs schema attributeForm: unqualified
|
|
39
|
|
40 /* For the wsdl:arrayType attribute to support old style SOAP arrays: */
|
|
41 //gsoap wsdl schema namespace: http://schemas.xmlsoap.org/wsdl/
|
|
42
|
|
43 #import "imports.h"
|
|
44
|
|
45 class xs__schema; // forward declaration
|
|
46 class xs__simpleType; // forward declaration
|
|
47 class xs__complexType; // forward declaration
|
|
48 class xs__extension; // forward declaration
|
|
49 class xs__restriction; // forward declaration
|
|
50 class xs__seqchoice; // forward declaration
|
|
51 class xs__group; // forward declaration
|
|
52 class xs__list; // forward declaration
|
|
53 class xs__union; // forward declaration
|
|
54
|
|
55 class xs__annotation
|
|
56 { public:
|
|
57 char *documentation;
|
|
58 };
|
|
59
|
|
60 enum xs__formChoice { unqualified, qualified };
|
|
61
|
|
62 class xs__element
|
|
63 { public:
|
|
64 // @xsd__ID id;
|
|
65 @xsd__NCName name;
|
|
66 @xsd__QName ref;
|
|
67 @xsd__QName type;
|
|
68 @xsd__string default_;
|
|
69 @xsd__QName default__; // also get QName value if element type is QName
|
|
70 @xsd__string fixed;
|
|
71 @xsd__QName fixed_; // also get QName value if element type is QName
|
|
72 @enum xs__formChoice *form;
|
|
73 @xsd__boolean nillable = false;
|
|
74 @xsd__boolean abstract = false;
|
|
75 @xsd__QName substitutionGroup;
|
|
76 @xsd__string minOccurs; // xsd:nonNegativeInteger
|
|
77 @xsd__string maxOccurs; // xsd:nonNegativeInteger|unbounded
|
|
78 @xsd__string xmime__expectedContentTypes;
|
|
79 xs__annotation *annotation;
|
|
80 xs__simpleType *simpleType; // choice
|
|
81 xs__complexType *complexType; // choice
|
|
82 xsd__string unique; // dummy, not used
|
|
83 private:
|
|
84 xs__schema *schemaRef; // schema to which this belongs
|
|
85 xs__element *elementRef; // traverse() finds ref
|
|
86 xs__simpleType *simpleTypeRef; // traverse() finds type or = simpleType above
|
|
87 xs__complexType *complexTypeRef; // traverse() finds type or = complexType above
|
|
88 std::vector<xs__element*> substitutions; // traverse() finds substitutionGroup elements for this abstract element
|
|
89 public:
|
|
90 xs__element();
|
|
91 int traverse(xs__schema&);
|
|
92 void schemaPtr(xs__schema*);
|
|
93 void elementPtr(xs__element*);
|
|
94 void simpleTypePtr(xs__simpleType*);
|
|
95 void complexTypePtr(xs__complexType*);
|
|
96 xs__schema *schemaPtr() const;
|
|
97 xs__element *elementPtr() const;
|
|
98 xs__simpleType *simpleTypePtr() const;
|
|
99 xs__complexType *complexTypePtr() const;
|
|
100 const std::vector<xs__element*> *substitutionsPtr() const;
|
|
101 };
|
|
102
|
|
103 enum xs__attribute_use { optional, prohibited, required, default_, fixed_ };
|
|
104
|
|
105 class xs__attribute
|
|
106 { public:
|
|
107 @xsd__NCName name;
|
|
108 @xsd__QName ref;
|
|
109 @xsd__QName type;
|
|
110 @enum xs__attribute_use use = optional;
|
|
111 @xsd__string default_;
|
|
112 @xsd__QName default__; // also get QName value if attribute type is QName
|
|
113 @xsd__string fixed;
|
|
114 @xsd__QName fixed_; // also get QName value if attribute type is QName
|
|
115 @enum xs__formChoice *form;
|
|
116 @xsd__QName wsdl__arrayType; // extensibility attribute added to simplify WSDL parsing
|
|
117 xs__annotation *annotation;
|
|
118 xs__simpleType *simpleType;
|
|
119 private:
|
|
120 xs__schema *schemaRef; // schema to which this belongs
|
|
121 xs__attribute *attributeRef; // traverse() finds ref
|
|
122 xs__simpleType *simpleTypeRef; // traverse() finds type or = simpleType above
|
|
123 public:
|
|
124 xs__attribute();
|
|
125 int traverse(xs__schema&);
|
|
126 void schemaPtr(xs__schema*);
|
|
127 void attributePtr(xs__attribute*);
|
|
128 void simpleTypePtr(xs__simpleType*);
|
|
129 xs__schema *schemaPtr() const;
|
|
130 xs__attribute *attributePtr() const;
|
|
131 xs__simpleType *simpleTypePtr() const;
|
|
132 };
|
|
133
|
|
134 class xs__all
|
|
135 { public:
|
|
136 std::vector<xs__element> element;
|
|
137 public:
|
|
138 int traverse(xs__schema&);
|
|
139 };
|
|
140
|
|
141 enum xs__processContents { strict, skip, lax };
|
|
142
|
|
143 typedef char *xs__namespaceList; // "##any" or "##other" or list of URI, "##targetNamespace", "##local"
|
|
144
|
|
145 class xs__any
|
|
146 { public:
|
|
147 @xs__namespaceList namespace_ = "##any";
|
|
148 @enum xs__processContents processContents = strict;
|
|
149 @xsd__string minOccurs; // xsd:nonNegativeInteger
|
|
150 @xsd__string maxOccurs; // xsd:nonNegativeInteger|unbounded
|
|
151 std::vector<xs__element> element;
|
|
152 public:
|
|
153 int traverse(xs__schema&);
|
|
154 };
|
|
155
|
|
156 class xs__contents
|
|
157 { public:
|
|
158 $int __union;
|
|
159 union xs__union_content
|
|
160 { xs__element *element;
|
|
161 xs__group *group;
|
|
162 xs__seqchoice *choice;
|
|
163 xs__seqchoice *sequence;
|
|
164 xs__any *any;
|
|
165 } __content;
|
|
166 public:
|
|
167 int traverse(xs__schema&);
|
|
168 };
|
|
169
|
|
170 class xs__seqchoice
|
|
171 { public:
|
|
172 @xsd__string minOccurs; // xsd:nonNegativeInteger
|
|
173 @xsd__string maxOccurs; // xsd:nonNegativeInteger|unbounded
|
|
174 xs__annotation *annotation;
|
|
175 std::vector<xs__contents> __contents;
|
|
176 private:
|
|
177 xs__schema *schemaRef; // schema to which this belongs
|
|
178 public:
|
|
179 xs__seqchoice();
|
|
180 int traverse(xs__schema&);
|
|
181 void schemaPtr(xs__schema*);
|
|
182 xs__schema *schemaPtr() const;
|
|
183 };
|
|
184
|
|
185 class xs__group
|
|
186 { public:
|
|
187 @xsd__NCName name;
|
|
188 @xsd__QName ref;
|
|
189 @xsd__string minOccurs; // xsd:nonNegativeInteger
|
|
190 @xsd__string maxOccurs; // xsd:nonNegativeInteger|unbounded
|
|
191 xs__annotation *annotation;
|
|
192 xs__all *all;
|
|
193 xs__seqchoice *choice;
|
|
194 xs__seqchoice *sequence;
|
|
195 private:
|
|
196 xs__schema *schemaRef; // schema to which this belongs
|
|
197 xs__group *groupRef; // traverse() finds ref
|
|
198 public:
|
|
199 xs__group();
|
|
200 int traverse(xs__schema&);
|
|
201 void schemaPtr(xs__schema*);
|
|
202 void groupPtr(xs__group*);
|
|
203 xs__schema *schemaPtr() const;
|
|
204 xs__group *groupPtr() const;
|
|
205 };
|
|
206
|
|
207 class xs__anyAttribute
|
|
208 { public:
|
|
209 @xs__namespaceList namespace_ = "##any";
|
|
210 @enum xs__processContents processContents = strict;
|
|
211 };
|
|
212
|
|
213 class xs__attributeGroup
|
|
214 { public:
|
|
215 @xsd__NCName name;
|
|
216 @xsd__QName ref;
|
|
217 xs__annotation *annotation;
|
|
218 std::vector<xs__attribute> attribute;
|
|
219 std::vector<xs__attributeGroup> attributeGroup;
|
|
220 xs__anyAttribute *anyAttribute;
|
|
221 private:
|
|
222 xs__schema *schemaRef;
|
|
223 xs__attributeGroup *attributeGroupRef;
|
|
224 public:
|
|
225 xs__attributeGroup();
|
|
226 int traverse(xs__schema&);
|
|
227 void schemaPtr(xs__schema*);
|
|
228 void attributeGroupPtr(xs__attributeGroup*);
|
|
229 xs__schema *schemaPtr() const;
|
|
230 xs__attributeGroup *attributeGroupPtr() const;
|
|
231 };
|
|
232
|
|
233 class xs__enumeration
|
|
234 { public:
|
|
235 @xsd__string value;
|
|
236 @xsd__QName value_; // also get QName value if base type is QName
|
|
237 xs__annotation *annotation;
|
|
238 public:
|
|
239 int traverse(xs__schema&);
|
|
240 };
|
|
241
|
|
242 class xs__pattern
|
|
243 { public:
|
|
244 @xsd__string value;
|
|
245 public:
|
|
246 int traverse(xs__schema&);
|
|
247 };
|
|
248
|
|
249 class xs__simpleContent
|
|
250 { public:
|
|
251 xs__extension *extension; // choice
|
|
252 xs__restriction *restriction; // choice
|
|
253 public:
|
|
254 int traverse(xs__schema&);
|
|
255 };
|
|
256
|
|
257 class xs__simpleType
|
|
258 { public:
|
|
259 @xsd__NMTOKEN name;
|
|
260 xs__annotation *annotation;
|
|
261 xs__restriction *restriction; // choice
|
|
262 xs__list *list; // choice
|
|
263 xs__union *union_; // choice
|
|
264 private:
|
|
265 xs__schema *schemaRef;
|
|
266 int level;
|
|
267 public:
|
|
268 xs__simpleType();
|
|
269 int traverse(xs__schema&);
|
|
270 void schemaPtr(xs__schema*);
|
|
271 xs__schema *schemaPtr() const;
|
|
272 int baseLevel();
|
|
273 };
|
|
274
|
|
275 class xs__extension
|
|
276 { public:
|
|
277 @xsd__QName base;
|
|
278 xs__group *group;
|
|
279 xs__all *all;
|
|
280 xs__seqchoice *choice;
|
|
281 xs__seqchoice *sequence;
|
|
282 std::vector<xs__attribute> attribute;
|
|
283 std::vector<xs__attributeGroup> attributeGroup;
|
|
284 xs__anyAttribute *anyAttribute;
|
|
285 private:
|
|
286 xs__simpleType *simpleTypeRef; // traverse() finds type
|
|
287 xs__complexType *complexTypeRef; // traverse() finds type
|
|
288 public:
|
|
289 xs__extension();
|
|
290 int traverse(xs__schema&);
|
|
291 void simpleTypePtr(xs__simpleType*);
|
|
292 void complexTypePtr(xs__complexType*);
|
|
293 xs__simpleType *simpleTypePtr() const;
|
|
294 xs__complexType *complexTypePtr() const;
|
|
295 };
|
|
296
|
|
297 class xs__length
|
|
298 { public:
|
|
299 @xsd__string value;
|
|
300 @xsd__boolean fixed;
|
|
301 xs__annotation *annotation;
|
|
302 };
|
|
303
|
|
304 class xs__whiteSpace
|
|
305 { public:
|
|
306 @xsd__string value;
|
|
307 };
|
|
308
|
|
309 class xs__restriction
|
|
310 { public:
|
|
311 @xsd__QName base;
|
|
312 xs__simpleType *simpleType; // used in <simpleType><restriction>
|
|
313 xs__attributeGroup *attributeGroup;// not used in <simpleType><restriction>
|
|
314 xs__group *group; // not used in <simpleType><restriction>
|
|
315 xs__all *all; // not used in <simpleType><restriction>
|
|
316 xs__seqchoice *choice; // not used in <simpleType><restriction>
|
|
317 xs__seqchoice *sequence; // not used in <simpleType><restriction>
|
|
318 std::vector<xs__attribute> attribute; // not used in <simpleType><restriction>
|
|
319 xs__anyAttribute *anyAttribute; // not used in <simpleType><restriction>
|
|
320 std::vector<xs__enumeration> enumeration;
|
|
321 std::vector<xs__pattern> pattern;
|
|
322 xs__whiteSpace *whiteSpace;
|
|
323 xs__length *length;
|
|
324 xs__length *minLength;
|
|
325 xs__length *maxLength;
|
|
326 xs__length *precision; // 2000 schema
|
|
327 xs__length *scale; // 2000 schema
|
|
328 xs__length *totalDigits; // 2001 schema
|
|
329 xs__length *fractionDigits; // 2001 schema
|
|
330 xs__length *minInclusive;
|
|
331 xs__length *maxInclusive;
|
|
332 xs__length *minExclusive;
|
|
333 xs__length *maxExclusive;
|
|
334 xs__annotation *annotation;
|
|
335 private:
|
|
336 xs__simpleType *simpleTypeRef; // traverse() finds type
|
|
337 xs__complexType *complexTypeRef; // traverse() finds type
|
|
338 public:
|
|
339 xs__restriction();
|
|
340 int traverse(xs__schema&);
|
|
341 void simpleTypePtr(xs__simpleType*);
|
|
342 void complexTypePtr(xs__complexType*);
|
|
343 xs__simpleType *simpleTypePtr() const;
|
|
344 xs__complexType *complexTypePtr() const;
|
|
345 };
|
|
346
|
|
347 class xs__list
|
|
348 { public:
|
|
349 @xsd__QName itemType;
|
|
350 xs__restriction *restriction; // choice
|
|
351 std::vector<xs__simpleType> simpleType; // choice
|
|
352 private:
|
|
353 xs__simpleType *itemTypeRef;
|
|
354 public:
|
|
355 xs__list();
|
|
356 int traverse(xs__schema&);
|
|
357 void itemTypePtr(xs__simpleType*);
|
|
358 xs__simpleType *itemTypePtr() const;
|
|
359 };
|
|
360
|
|
361 class xs__union
|
|
362 { public:
|
|
363 @xsd__NMTOKENS memberTypes; // check if NMTOKENS is ok???
|
|
364 std::vector<xs__simpleType> simpleType;
|
|
365 public:
|
|
366 int traverse(xs__schema&);
|
|
367 };
|
|
368
|
|
369 class xs__complexContent
|
|
370 { public:
|
|
371 @xsd__boolean mixed = false;
|
|
372 xs__extension *extension;
|
|
373 xs__restriction *restriction;
|
|
374 public:
|
|
375 int traverse(xs__schema&);
|
|
376 };
|
|
377
|
|
378 class xs__complexType
|
|
379 { public:
|
|
380 @xsd__NMTOKEN name;
|
|
381 @xsd__boolean abstract = false;
|
|
382 @xsd__boolean mixed = false;
|
|
383 xs__annotation *annotation;
|
|
384 xs__simpleContent *simpleContent;
|
|
385 xs__complexContent *complexContent;
|
|
386 xs__all *all;
|
|
387 xs__seqchoice *choice;
|
|
388 xs__seqchoice *sequence;
|
|
389 xs__any *any;
|
|
390 std::vector<xs__attribute> attribute;
|
|
391 std::vector<xs__attributeGroup> attributeGroup;
|
|
392 xs__anyAttribute *anyAttribute;
|
|
393 private:
|
|
394 xs__schema *schemaRef;
|
|
395 int level;
|
|
396 public:
|
|
397 xs__complexType();
|
|
398 int traverse(xs__schema&);
|
|
399 void schemaPtr(xs__schema*);
|
|
400 xs__schema *schemaPtr() const;
|
|
401 int baseLevel();
|
|
402 };
|
|
403
|
|
404 class xs__import
|
|
405 { public:
|
|
406 @xsd__anyURI namespace_;
|
|
407 @xsd__anyURI schemaLocation;
|
|
408 private:
|
|
409 xs__schema *schemaRef; // set by WSDL parser or via schemaLocation
|
|
410 public:
|
|
411 xs__import();
|
|
412 int traverse(xs__schema&);
|
|
413 void schemaPtr(xs__schema*);
|
|
414 xs__schema *schemaPtr() const;
|
|
415 };
|
|
416
|
|
417 class xs__include
|
|
418 { public:
|
|
419 @xsd__anyURI schemaLocation;
|
|
420 private:
|
|
421 xs__schema *schemaRef;
|
|
422 public:
|
|
423 xs__include();
|
|
424 int preprocess(xs__schema&);
|
|
425 int traverse(xs__schema&);
|
|
426 void schemaPtr(xs__schema*);
|
|
427 xs__schema *schemaPtr() const;
|
|
428 };
|
|
429
|
|
430 class xs__redefine
|
|
431 { public:
|
|
432 @xsd__anyURI schemaLocation;
|
|
433 std::vector<xs__group> group;
|
|
434 std::vector<xs__attributeGroup> attributeGroup;
|
|
435 std::vector<xs__simpleType> simpleType;
|
|
436 std::vector<xs__complexType> complexType;
|
|
437 private:
|
|
438 xs__schema *schemaRef;
|
|
439 public:
|
|
440 xs__redefine();
|
|
441 int preprocess(xs__schema&);
|
|
442 int traverse(xs__schema&);
|
|
443 void schemaPtr(xs__schema*);
|
|
444 xs__schema *schemaPtr() const;
|
|
445 };
|
|
446
|
|
447 class xs__schema
|
|
448 { public:
|
|
449 @xsd__anyURI targetNamespace = "";
|
|
450 @xsd__string version;
|
|
451 @enum xs__formChoice attributeFormDefault = unqualified;
|
|
452 @enum xs__formChoice elementFormDefault = unqualified;
|
|
453 xs__annotation *annotation;
|
|
454 std::vector<xs__include> include;
|
|
455 std::vector<xs__redefine> redefine;
|
|
456 std::vector<xs__import> import;
|
|
457 std::vector<xs__attribute> attribute;
|
|
458 std::vector<xs__element> element;
|
|
459 std::vector<xs__group> group;
|
|
460 std::vector<xs__attributeGroup> attributeGroup;
|
|
461 std::vector<xs__simpleType> simpleType;
|
|
462 std::vector<xs__complexType> complexType;
|
|
463 struct soap *soap;
|
|
464 private:
|
|
465 bool updated;
|
|
466 char* location;
|
|
467 int redirs;
|
|
468 SetOfString builtinTypeSet;
|
|
469 SetOfString builtinElementSet;
|
|
470 SetOfString builtinAttributeSet;
|
|
471 public:
|
|
472 xs__schema();
|
|
473 xs__schema(struct soap*);
|
|
474 xs__schema(struct soap*, const char*, const char*);
|
|
475 virtual ~xs__schema();
|
|
476 int get(struct soap*); // gSOAP getter is triggered after parsing
|
|
477 int preprocess();
|
|
478 int insert(xs__schema&);
|
|
479 int traverse();
|
|
480 int read(const char*, const char*);
|
|
481 void sourceLocation(const char*);
|
|
482 const char* sourceLocation();
|
|
483 int error();
|
|
484 void print_fault();
|
|
485 void builtinType(const char*);
|
|
486 void builtinElement(const char*);
|
|
487 void builtinAttribute(const char*);
|
|
488 const SetOfString& builtinTypes() const;
|
|
489 const SetOfString& builtinElements() const;
|
|
490 const SetOfString& builtinAttributes() const;
|
|
491 bool empty() const;
|
|
492 friend ostream& operator<<(ostream&, const xs__schema&);
|
|
493 friend istream& operator>>(istream&, xs__schema&);
|
|
494 };
|
|
495
|
|
496 extern ostream &operator<<(ostream &o, const xs__schema &e);
|
|
497 extern istream &operator>>(istream &i, xs__schema &e);
|
|
498
|