Merge pull request #61 from BenceJanosSzabo/master
[deliverable/titan.core.git] / xsdconvert / XMLParser.cc
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom 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 * Balasko, Jeno
10 * Godar, Marton
11 * Kovacs, Ferenc
12 * Raduly, Csaba
13 * Szabo, Bence Janos
14 *
15 ******************************************************************************/
16 #include "XMLParser.hh"
17 #include "TTCN3Module.hh"
18 #include "SimpleType.hh"
19 #include "ComplexType.hh"
20
21 #include "GeneralFunctions.hh"
22
23 #include <cstring> // for using "memset" function
24 #include <cstdio>
25 #include <cerrno>
26 #include <climits>
27 #ifndef ULLONG_MAX
28 #define ULLONG_MAX 18446744073709551615ULL
29 #endif
30 #ifndef LLONG_MIN
31 #define LLONG_MIN -9223372036854775808LL
32 #endif
33 #ifndef LLONG_MAX
34 #define LLONG_MAX 9223372036854775807LL
35 #endif
36
37 extern bool V_flag_used;
38 extern bool w_flag_used;
39 extern bool x_flag_used;
40
41 bool XMLParser::suspended = false;
42 unsigned int XMLParser::num_errors = 0;
43 unsigned int XMLParser::num_warnings = 0;
44
45 XMLParser::XMLParser(const char * a_filename)
46 : module(NULL) // get value with 'connectWithModule()' method
47 , filename(a_filename) // includes the path of the file
48 , parser(NULL)
49 , context(NULL)
50 , parserCheckingXML(NULL)
51 , contextCheckingXML(NULL)
52 , contextCheckingXSD(NULL)
53 , actualDepth(0)
54 , actualTagName(n_NOTSET)
55 , actualTagAttributes(this)
56 , parentTagNames()
57 , inside_annotation(){
58 xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
59
60 parserCheckingXML = (xmlSAXHandler *) malloc(sizeof (xmlSAXHandler));
61 memset(parserCheckingXML, 0, sizeof (xmlSAXHandler));
62 parserCheckingXML->initialized = XML_SAX2_MAGIC;
63 parserCheckingXML->warning = warningHandler;
64 parserCheckingXML->error = errorHandler;
65 contextCheckingXML = xmlCreateFileParserCtxt(a_filename);
66 if (!contextCheckingXML) {
67 fprintf(stderr,
68 "ERROR:\n"
69 "Creating XML syntax checker has failed.\n");
70 ++num_errors;
71 return;
72 }
73 contextCheckingXML->sax = parserCheckingXML;
74
75 if (!x_flag_used) {
76 contextCheckingXSD = xmlSchemaNewParserCtxt(a_filename);
77 if (!contextCheckingXSD) {
78 fprintf(stderr,
79 "ERROR:\n"
80 "Creating XSD validator has failed.\n");
81 ++num_errors;
82 return;
83 }
84 xmlSchemaSetParserErrors(contextCheckingXSD, errorHandler, warningHandler, 0);
85 }
86
87 parser = (xmlSAXHandler *) malloc(sizeof (xmlSAXHandler));
88 memset(parser, 0, sizeof (xmlSAXHandler));
89 parser->initialized = XML_SAX2_MAGIC;
90 parser->startElementNs = (startElementNsSAX2Func) wrapper_to_call_startelement_h;
91 parser->endElementNs = (endElementNsSAX2Func) wrapper_to_call_endelement_h;
92 parser->characters = (charactersSAXFunc) wrapper_to_call_characterdata_h;
93 parser->comment = (commentSAXFunc) wrapper_to_call_comment_h;
94
95 context = xmlCreateFileParserCtxt(filename.c_str());
96 if (!context) {
97 fprintf(stderr,
98 "ERROR:\n"
99 "Creating parser for file '%s' has failed.\n", filename.c_str());
100 ++num_errors;
101 return;
102 }
103 context->sax = parser;
104 context->userData = this;
105 }
106
107 XMLParser::~XMLParser() {
108 context->sax = NULL;
109 xmlFreeDoc(context->myDoc);
110 contextCheckingXML->sax = NULL;
111 free(parser);
112 free(parserCheckingXML);
113 if (context) {
114 xmlFreeParserCtxt(context);
115 }
116 if (contextCheckingXML) {
117 xmlFreeParserCtxt(contextCheckingXML);
118 }
119 if (contextCheckingXSD) {
120 xmlSchemaFreeParserCtxt(contextCheckingXSD);
121 }
122 }
123
124 void XMLParser::checkSyntax() {
125 xmlParseDocument(contextCheckingXML);
126 }
127
128 void XMLParser::validate() {
129 if (!x_flag_used) {
130 xmlSchemaPtr schema = xmlSchemaParse(contextCheckingXSD);
131 if (schema) {
132 xmlSchemaValidCtxtPtr validator = xmlSchemaNewValidCtxt(schema);
133 if (validator) {
134 // do not use this->context!
135 xmlParserCtxtPtr newcontext = xmlNewParserCtxt();
136 xmlDocPtr doc = xmlCtxtReadFile(newcontext, filename.c_str(), NULL, 0);
137 if (doc) {
138 // Don't try this, it always fails
139 //int result = xmlSchemaValidateDoc(validator, doc);
140 //(void)result; // 0=ok, errorcode > 0, intrnal error == -1
141 xmlFreeDoc(doc);
142 }
143 xmlSchemaFreeValidCtxt(validator);
144 xmlFreeParserCtxt(newcontext);
145 }
146 xmlSchemaFree(schema);
147 }
148 }
149 }
150
151 void XMLParser::startConversion(TTCN3Module * a_module) {
152 module = a_module;
153 xmlParseDocument(context);
154 }
155
156 void XMLParser::wrapper_to_call_startelement_h(XMLParser *self, const xmlChar * localname, const xmlChar *, const xmlChar *,
157 int nb_namespaces, const xmlChar ** namespaces, const int nb_attributes, int, const xmlChar ** attributes) {
158 self->startelementHandler(localname, nb_namespaces, namespaces, nb_attributes, attributes);
159 }
160
161 void XMLParser::wrapper_to_call_endelement_h(XMLParser *self, const xmlChar * localname, const xmlChar *, const xmlChar *) {
162 self->endelementHandler(localname);
163 }
164
165 void XMLParser::wrapper_to_call_comment_h(XMLParser *self, const xmlChar * value) {
166 self->commentHandler(value);
167 }
168
169 void XMLParser::wrapper_to_call_characterdata_h(XMLParser *self, const xmlChar * ch, int len) {
170 self->characterdataHandler(ch, len);
171 }
172
173 void XMLParser::warningHandler(void *, const char *, ...) {
174 if (w_flag_used) {
175 return;
176 }
177
178 xmlErrorPtr error = xmlGetLastError();
179
180 if (error->file == NULL) {
181 fprintf(stderr,
182 "WARNING:\n"
183 "%s",
184 error->message);
185 } else {
186 fprintf(stderr,
187 "WARNING:\n"
188 "%s (in line %d): "
189 "%s",
190 error->file,
191 error->line,
192 error->message);
193 ++num_warnings;
194 }
195 }
196
197 void XMLParser::errorHandler(void *, const char *, ...) {
198 xmlErrorPtr error = xmlGetLastError();
199
200 if (error->code == XML_SCHEMAP_SRC_RESOLVE) {
201 return;
202 }
203 if (error->code == XML_SCHEMAP_COS_ALL_LIMITED) {
204 return;
205 }
206
207 switch (error->level) {
208 case XML_ERR_ERROR:
209 fputs("ERROR:\n", stderr);
210 break;
211 case XML_ERR_FATAL:
212 fputs("FATAL ERROR:\n", stderr);
213 break;
214 default: // warning or no error, can't happen (famous last words)
215 break;
216 }
217
218 if (error->file != NULL) {
219 fprintf(stderr, "%s (in line %d): ", error->file, error->line);
220 }
221
222 fputs(error->message, stderr); // libxml2 supplies a trailing \n
223 ++num_errors;
224 }
225
226 void XMLParser::startelementHandler(const xmlChar * localname,
227 int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, const xmlChar ** attributes) {
228 fillUpActualTagName((const char *) localname, startElement);
229 fillUpActualTagAttributes((const char **) attributes, nb_attributes);
230
231 switch (module->getActualXsdConstruct()) {
232 case c_unknown:
233 {
234 switch (actualTagName) {
235 case n_schema:
236 {
237 module->setActualXsdConstruct(c_schema);
238
239 module->loadValuesFromXMLDeclaration((const char *) context->version,
240 (const char *) context->encoding, context->standalone);
241
242 List<NamespaceType> declaredNamespaces;
243 for (int i = 0; i < nb_namespaces * 2; i = i + 2) {
244 NamespaceType tmp_ns_pair;
245
246 if (namespaces[i] != NULL) {
247 tmp_ns_pair.prefix = (const char*) namespaces[i];
248 }
249 // else leave it as empty string
250
251 if (namespaces[i + 1] != NULL) {
252 tmp_ns_pair.uri = (const char*) namespaces[i + 1];
253 }
254 // else leave it as empty string
255
256 declaredNamespaces.push_back(tmp_ns_pair);
257 }
258
259 module->loadValuesFromSchemaTag(actualTagAttributes.targetNamespace, declaredNamespaces,
260 actualTagAttributes.elementFormDefault, actualTagAttributes.attributeFormDefault,
261 actualTagAttributes.blockDefault);
262 break;
263 }
264 default:
265 break;
266 }
267 break;
268 }
269
270 case c_schema:
271 {
272 switch (actualTagName) {
273 case n_simpleType:
274 module->addMainType(c_simpleType);
275 break;
276 case n_element:
277 module->addMainType(c_element);
278 break;
279 case n_attribute:
280 module->addMainType(c_attribute);
281 break;
282 case n_complexType:
283 module->addMainType(c_complexType);
284 break;
285 case n_group:
286 module->addMainType(c_group);
287 break;
288 case n_attributeGroup:
289 module->addMainType(c_attributeGroup);
290 break;
291 case n_include:
292 module->addMainType(c_include);
293 break;
294 case n_import:
295 module->addMainType(c_import);
296 break;
297 default:
298 break;
299 }
300 break;
301 }
302
303 default:
304 if (module->hasDefinedMainType()) {
305 if(actualTagName == n_annotation ||
306 actualTagName == n_appinfo ||
307 actualTagName == n_documentation){
308 inside_annotation.push_back(actualTagName);
309 module->getLastMainType().loadWithValues();
310 }else if(inside_annotation.empty()){
311 module->getLastMainType().loadWithValues();
312 }
313 }
314 break;
315 }
316
317 //Standard section 7.1.1
318 if (!actualTagAttributes.id.empty()) {
319 ConstructType type = module->getActualXsdConstruct();
320 module->addMainType(c_idattrib);
321 module->setActualXsdConstruct(type);
322 }
323
324 ++actualDepth;
325 parentTagNames.push_back(actualTagName);
326 }
327
328 void XMLParser::endelementHandler(const xmlChar * localname) {
329 fillUpActualTagName((const char *) localname, endElement);
330
331 bool modify = false;
332 TagName tag = parentTagNames.back();
333 //After some tags there is no need to call modifyValues
334 if (tag == n_element ||
335 tag == n_all ||
336 tag == n_choice ||
337 tag == n_group ||
338 tag == n_attributeGroup ||
339 tag == n_extension ||
340 tag == n_simpleType ||
341 tag == n_simpleContent ||
342 tag == n_sequence ||
343 tag == n_complexType ||
344 tag == n_complexContent ||
345 tag == n_attribute ||
346 tag == n_anyAttribute
347 ) {
348 modify = true;
349 }
350
351 if(tag == n_annotation ||
352 tag == n_appinfo ||
353 tag == n_documentation){
354 inside_annotation.pop_back();
355 }
356
357
358 --actualDepth;
359 if (actualDepth == 0 || actualDepth == 1) {
360 module->setActualXsdConstruct(c_schema);
361 }
362
363 if (module->hasDefinedMainType() && modify) {
364 module->getLastMainType().modifyValues();
365 }
366 parentTagNames.pop_back();
367 }
368
369 void XMLParser::commentHandler(const xmlChar * text) {
370 Mstring comment((const char *) text);
371 comment.removeWSfromBegin();
372 comment.removeWSfromEnd();
373 if (comment.empty()) {
374 return;
375 }
376
377 if (module->getActualXsdConstruct() == c_schema) {
378 module->addMainType(c_annotation);
379 module->setActualXsdConstruct(c_schema); // actualXsdConstruct was set to c_annotation
380 }
381
382 if (module->hasDefinedMainType()) {
383 module->getLastMainType().addComment(comment);
384 }
385 }
386
387 void XMLParser::characterdataHandler(const xmlChar * text, const int length) {
388 if (suspended) {
389 return;
390 }
391
392 char * temp = (char *) Malloc(length + 1);
393 memcpy(temp, text, length);
394 temp[length] = '\0';
395 Mstring comment(temp);
396 Free(temp);
397
398 comment.removeWSfromBegin();
399 comment.removeWSfromEnd();
400 if (comment.empty()) {
401 return;
402 }
403
404 if (module->getActualXsdConstruct() == c_schema) {
405 module->addMainType(c_annotation);
406 }
407 if (module->hasDefinedMainType()) {
408 module->getLastMainType().addComment(comment);
409 }
410 }
411
412 void XMLParser::fillUpActualTagName(const char * localname, const tagMode mode) {
413 Mstring name_s(localname);
414
415 if (name_s == "all")
416 actualTagName = n_all;
417 else if (name_s == "annotation")
418 actualTagName = n_annotation;
419 else if (name_s == "any")
420 actualTagName = n_any;
421 else if (name_s == "anyAttribute")
422 actualTagName = n_anyAttribute;
423 else if (name_s == "appinfo") {
424 actualTagName = n_appinfo;
425 switch (mode) {
426 case startElement:
427 suspended = true;
428 break;
429 case endElement:
430 suspended = false;
431 break;
432 default:
433 break;
434 }
435 } else if (name_s == "attribute")
436 actualTagName = n_attribute;
437 else if (name_s == "attributeGroup")
438 actualTagName = n_attributeGroup;
439 else if (name_s == "choice")
440 actualTagName = n_choice;
441 else if (name_s == "complexContent")
442 actualTagName = n_complexContent;
443 else if (name_s == "complexType")
444 actualTagName = n_complexType;
445 else if (name_s == "definition")
446 actualTagName = n_definition;
447 else if (name_s == "documentation")
448 actualTagName = n_documentation;
449 else if (name_s == "element")
450 actualTagName = n_element;
451 else if (name_s == "enumeration")
452 actualTagName = n_enumeration;
453 else if (name_s == "extension")
454 actualTagName = n_extension;
455 else if (name_s == "field") {
456 actualTagName = n_field;
457 if (mode == startElement) {
458 printWarning(filename, xmlSAX2GetLineNumber(context),
459 Mstring("The 'field' tag is ignored by the standard."));
460 ++num_warnings;
461 }
462 } else if (name_s == "fractionDigits") {
463 actualTagName = n_fractionDigits;
464 if (mode == startElement) {
465 printWarning(filename, xmlSAX2GetLineNumber(context),
466 Mstring("The 'fractionDigits' tag is currently not supported."));
467 ++num_warnings;
468 }
469 } else if (name_s == "group")
470 actualTagName = n_group;
471 else if (name_s == "import")
472 actualTagName = n_import;
473 else if (name_s == "include")
474 actualTagName = n_include;
475 else if (name_s == "key") {
476 actualTagName = n_key;
477 if (mode == startElement) {
478 printWarning(filename, xmlSAX2GetLineNumber(context),
479 Mstring("The 'key' tag is ignored by the standard."));
480 ++num_warnings;
481 }
482 } else if (name_s == "keyref") {
483 actualTagName = n_keyref;
484 if (mode == startElement) {
485 printWarning(filename, xmlSAX2GetLineNumber(context),
486 Mstring("The 'keyref' tag ignored by the standard."));
487 ++num_warnings;
488 }
489 } else if (name_s == "length")
490 actualTagName = n_length;
491 else if (name_s == "label")
492 actualTagName = n_label;
493 else if (name_s == "list")
494 actualTagName = n_list;
495 else if (name_s == "maxExclusive")
496 actualTagName = n_maxExclusive;
497 else if (name_s == "maxInclusive")
498 actualTagName = n_maxInclusive;
499 else if (name_s == "maxLength")
500 actualTagName = n_maxLength;
501 else if (name_s == "minExclusive")
502 actualTagName = n_minExclusive;
503 else if (name_s == "minInclusive")
504 actualTagName = n_minInclusive;
505 else if (name_s == "minLength")
506 actualTagName = n_minLength;
507 else if (name_s == "notation")
508 ;
509 else if (name_s == "pattern")
510 actualTagName = n_pattern;
511 else if (name_s == "redefine")
512 actualTagName = n_redefine;
513 else if (name_s == "restriction")
514 actualTagName = n_restriction;
515 else if (name_s == "schema")
516 actualTagName = n_schema;
517 else if (name_s == "selector") {
518 actualTagName = n_selector;
519 if (mode == startElement) {
520 printWarning(filename, xmlSAX2GetLineNumber(context),
521 Mstring("The 'selector' tag ignored by the standard."));
522 ++num_warnings;
523 }
524 } else if (name_s == "sequence")
525 actualTagName = n_sequence;
526 else if (name_s == "simpleContent")
527 actualTagName = n_simpleContent;
528 else if (name_s == "simpleType")
529 actualTagName = n_simpleType;
530 else if (name_s == "totalDigits")
531 actualTagName = n_totalDigits;
532 else if (name_s == "union")
533 actualTagName = n_union;
534 else if (name_s == "unique") {
535 actualTagName = n_unique;
536 if (mode == startElement) {
537 printWarning(filename, xmlSAX2GetLineNumber(context),
538 Mstring("The 'unique' tag ignored by the standard."));
539 ++num_warnings;
540 }
541 } else if (name_s == "whiteSpace")
542 actualTagName = n_whiteSpace;
543 }
544
545 void XMLParser::fillUpActualTagAttributes(const char ** attributes, const int att_count) {
546
547 struct attribute_data {
548 const char * name;
549 const char * prefix;
550 const char * uri;
551 const char * value_start;
552 const char * value_end;
553 };
554 attribute_data * ad = (attribute_data *) attributes;
555
556 Mstring * att_name_s = new Mstring[att_count];
557 Mstring * att_value_s = new Mstring[att_count];
558 TagAttributeName * att_name_e = new TagAttributeName[att_count];
559
560 for (int i = 0; i != att_count; ++i) {
561 att_name_s[i] = ad[i].name;
562 att_value_s[i] = Mstring(ad[i].value_end - ad[i].value_start, ad[i].value_start);
563
564 att_name_e[i] = a_NOTSET;
565 if (att_name_s[i] == "abstract") {
566 att_name_e[i] = a_abstract;
567 } else if (att_name_s[i] == "attributeFormDefault")
568 att_name_e[i] = a_attributeFormDefault;
569 else if (att_name_s[i] == "base")
570 att_name_e[i] = a_base;
571 else if (att_name_s[i] == "block") {
572 att_name_e[i] = a_block;
573 } else if (att_name_s[i] == "blockDefault"){
574 att_name_e[i] = a_blockDefault;
575 } else if (att_name_s[i] == "default")
576 att_name_e[i] = a_default;
577 else if (att_name_s[i] == "elementFormDefault")
578 att_name_e[i] = a_elementFormDefault;
579 else if (att_name_s[i] == "final") {
580 att_name_e[i] = a_final; // no effect on the output
581 } else if (att_name_s[i] == "finalDefault")
582 ;
583 else if (att_name_s[i] == "fixed")
584 att_name_e[i] = a_fixed;
585 else if (att_name_s[i] == "form")
586 att_name_e[i] = a_form;
587 else if (att_name_s[i] == "id")
588 att_name_e[i] = a_id;
589 else if (att_name_s[i] == "itemType")
590 att_name_e[i] = a_itemType;
591 else if (att_name_s[i] == "lang")
592 ;
593 else if (att_name_s[i] == "maxOccurs")
594 att_name_e[i] = a_maxOccurs;
595 else if (att_name_s[i] == "memberTypes")
596 att_name_e[i] = a_memberTypes;
597 else if (att_name_s[i] == "minOccurs")
598 att_name_e[i] = a_minOccurs;
599 else if (att_name_s[i] == "mixed")
600 att_name_e[i] = a_mixed;
601 else if (att_name_s[i] == "name")
602 att_name_e[i] = a_name;
603 else if (att_name_s[i] == "namespace")
604 att_name_e[i] = a_namespace;
605 else if (att_name_s[i] == "nillable")
606 att_name_e[i] = a_nillable;
607 else if (att_name_s[i] == "processContents") {
608 att_name_e[i] = a_processContents;
609 // silently ignored
610 } else if (att_name_s[i] == "ref")
611 att_name_e[i] = a_ref;
612 else if (att_name_s[i] == "schemaLocation")
613 att_name_e[i] = a_schemaLocation;
614 else if (att_name_s[i] == "substitutionGroup") {
615 att_name_e[i] = a_substitutionGroup;
616 } else if (att_name_s[i] == "targetNamespace")
617 att_name_e[i] = a_targetNamespace;
618 else if (att_name_s[i] == "type")
619 att_name_e[i] = a_type;
620 else if (att_name_s[i] == "use")
621 att_name_e[i] = a_use;
622 else if (att_name_s[i] == "value")
623 att_name_e[i] = a_value;
624 else if (att_name_s[i] == "version") {
625 }
626 }
627 actualTagAttributes.fillUp(att_name_e, att_value_s, att_count);
628 delete [] att_name_s;
629 delete [] att_value_s;
630 delete [] att_name_e;
631 }
632
633 XMLParser::TagAttributes::TagAttributes(XMLParser * withThisParser)
634 : parser(withThisParser)
635 , attributeFormDefault(notset)
636 , base()
637 , default_()
638 , elementFormDefault(notset)
639 , fixed()
640 , form(notset)
641 , id()
642 , itemType()
643 , maxOccurs(1)
644 , memberTypes()
645 , minOccurs(1)
646 , mixed(false)
647 , name()
648 , namespace_()
649 , nillable(false)
650 , ref()
651 , schemaLocation()
652 , source()
653 , targetNamespace()
654 , type()
655 , use(optional)
656 , value() {
657 }
658
659 void XMLParser::TagAttributes::fillUp(TagAttributeName * att_name_e, Mstring * att_value_s, const int att_count) {
660 /**
661 * Reset
662 */
663 abstract = false;
664 attributeFormDefault = notset;
665 base.clear();
666 block = not_set,
667 blockDefault = not_set,
668 default_.clear();
669 elementFormDefault = notset;
670 fixed.clear();
671 form = notset;
672 id.clear();
673 itemType.clear();
674 maxOccurs = 1;
675 memberTypes.clear();
676 minOccurs = 1;
677 mixed = false;
678 name.clear();
679 namespace_.clear();
680 nillable = false;
681 ref.clear();
682 schemaLocation.clear();
683 source.clear();
684 substitionGroup = empty_string;
685 targetNamespace.clear();
686 type.clear();
687 use = optional;
688 value.clear();
689 /**
690 * Upload
691 */
692 for (int i = 0; i != att_count; ++i) {
693 switch (att_name_e[i]) {
694 case a_abstract: // Not supported by now
695 if (att_value_s[i] == "true") {
696 abstract = true;
697 } else if (att_value_s[i] == "false") {
698 abstract = false;
699 }
700 case a_attributeFormDefault: // qualified | unqualified
701 if (att_value_s[i] == "qualified") {
702 attributeFormDefault = qualified;
703 } else if (att_value_s[i] == "unqualified") {
704 attributeFormDefault = unqualified;
705 }
706 break;
707 case a_base: // QName = anyURI + NCName
708 base = att_value_s[i];
709 break;
710 case a_block: // Not supported by now
711 if(att_value_s[i] == "#all"){
712 block = all;
713 }else if(att_value_s[i] == "substitution"){
714 block = substitution;
715 }else if(att_value_s[i] == "restriction"){
716 block = restriction;
717 }else if(att_value_s[i] == "extension"){
718 block = extension;
719 }
720 break;
721 case a_blockDefault: // Not supported by now
722 if(att_value_s[i] == "#all"){
723 blockDefault = all;
724 }else if(att_value_s[i] == "substitution"){
725 blockDefault = substitution;
726 }else if(att_value_s[i] == "restriction"){
727 blockDefault = restriction;
728 }else if(att_value_s[i] == "extension"){
729 blockDefault = extension;
730 }
731 break;
732 case a_default: // string
733 default_ = att_value_s[i];
734 break;
735 case a_elementFormDefault:
736 if (att_value_s[i] == "qualified") {
737 elementFormDefault = qualified;
738 } else if (att_value_s[i] == "unqualified") {
739 elementFormDefault = unqualified;
740 }
741 break;
742 case a_final: // Not supported by now
743 break;
744 case a_finalDefault: // Not supported by now
745 break;
746 case a_fixed: // string
747 fixed = att_value_s[i];
748 break;
749 case a_form: // qualified | unqualified
750 if (att_value_s[i] == "qualified") {
751 form = qualified;
752 } else if (att_value_s[i] == "unqualified") {
753 form = unqualified;
754 }
755 break;
756 case a_lang:
757 break;
758 case a_id: // ID = NCName
759 id = att_value_s[i];
760 break;
761 case a_itemType: // QName = anyURI + NCName /- used in 'list' tag only
762 itemType = att_value_s[i];
763 break;
764 case a_maxOccurs: // nonNegativeinteger or 'unbounded'
765 if (att_value_s[i] == "unbounded") {
766 maxOccurs = ULLONG_MAX;
767 } else {
768 maxOccurs = strtoull(att_value_s[i].c_str(), NULL, 0);
769 }
770 break;
771 case a_memberTypes: // list of QNames - used in 'union' tag only
772 memberTypes = att_value_s[i];
773 break;
774 case a_minOccurs: // nonNegativeInteger
775 minOccurs = strtoull(att_value_s[i].c_str(), NULL, 0);
776 break;
777 case a_mixed: // true | false
778 if (att_value_s[i] == "true") {
779 mixed = true;
780 } else if (att_value_s[i] == "false") {
781 mixed = false;
782 }
783 break;
784 case a_name: // NCName
785 name = att_value_s[i];
786 break;
787 case a_namespace: // anyURI
788 namespace_ = att_value_s[i];
789 break;
790 case a_nillable: // true | false
791 if (att_value_s[i] == "true") {
792 nillable = true;
793 } else if (att_value_s[i] == "false") {
794 nillable = false;
795 }
796 break;
797 case a_processContents: // Not supported by now
798 break;
799 case a_ref: // QName = anyURI + NCName
800 ref = att_value_s[i];
801 break;
802 case a_schemaLocation: // anyURI
803 schemaLocation = att_value_s[i];
804 break;
805 case a_substitutionGroup:
806 substitionGroup = att_value_s[i];
807 break;
808 case a_targetNamespace: // anyURI
809 targetNamespace = att_value_s[i];
810 break;
811 case a_type: // QName = anyURI + NCName
812 type = att_value_s[i];
813 break;
814 case a_use: // optional | prohibited | required - used in 'use' tag only
815 if (att_value_s[i] == "optional") {
816 use = optional;
817 } else if (att_value_s[i] == "prohibited") {
818 use = prohibited;
819 } else if (att_value_s[i] == "required") {
820 use = required;
821 }
822 break;
823 case a_value: // value of FACETS
824 value = att_value_s[i];
825 break;
826 case a_source:
827 case a_xpath:
828 case a_version: // Not supported by now
829 break;
830 case a_NOTSET:
831 break;
832 default:
833 fprintf(stderr, "Unknown TagAttributeName %d\n", att_name_e[i]);
834 abort();
835 break;
836 }
837 }
838 }
This page took 0.07678 seconds and 5 git commands to generate.