MCPcopy Create free account
hub / github.com/sissaschool/xmlschema / _parse

Method _parse

xmlschema/validators/groups.py:497–573  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

495 self.__dict__.pop('elements', None)
496
497 def _parse(self) -> None:
498 self._group.clear()
499 self.__dict__.pop('elements', None)
500 self._parse_particle(self.elem)
501
502 if self.parent is not None and self.parent.mixed:
503 self.mixed = self.parent.mixed
504
505 if self.elem.tag != nm.XSD_GROUP:
506 # Local group (sequence|all|choice)
507 if 'name' in self.elem.attrib:
508 msg = _("attribute 'name' not allowed in a local group")
509 self.parse_error(msg)
510 self._parse_content_model(self.elem)
511
512 elif self._parse_reference():
513 assert self.name is not None
514 try:
515 xsd_group = self.maps.groups[self.name]
516 except KeyError:
517 self.parse_error(_("missing group %r") % self.prefixed_name)
518 self._any_content_group_fallback()
519 except XMLSchemaCircularityError as err:
520 # Circular definition, substituted with any content group.
521 self.parse_error(err, err.elem)
522 self._any_content_group_fallback()
523 else:
524 self.model = xsd_group.model
525 if self.model == 'all':
526 if self.max_occurs != 1:
527 msg = _("maxOccurs must be 1 for 'all' model groups")
528 self.parse_error(msg)
529 if self.min_occurs not in (0, 1):
530 msg = _("minOccurs must be (0 | 1) for 'all' model groups")
531 self.parse_error(msg)
532 if self.xsd_version == '1.0' and isinstance(self.parent, XsdGroup):
533 msg = _("in XSD 1.0 an 'all' model group cannot be nested")
534 self.parse_error(msg)
535 self._group.append(xsd_group)
536 self.ref = xsd_group
537 self.target_namespace = xsd_group.target_namespace
538 self.content = xsd_group.content
539
540 else:
541 attrib = self.elem.attrib
542 try:
543 self.name = get_qname(self.target_namespace, attrib['name'])
544 except KeyError:
545 pass
546 else:
547 if self.parent is not None:
548 msg = _("attribute 'name' not allowed in a local group")
549 self.parse_error(msg)
550 else:
551 if 'minOccurs' in attrib:
552 msg = _("attribute 'minOccurs' not allowed in a global group")
553 self.parse_error(msg)
554 if 'maxOccurs' in attrib:

Callers 1

Calls 8

_parse_content_modelMethod · 0.95
get_qnameFunction · 0.90
_parse_particleMethod · 0.80
clearMethod · 0.45
parse_errorMethod · 0.45
_parse_referenceMethod · 0.45

Tested by 1