def test_element_parser_with_child(): class TestElement(ElementParser): tag = Tag("test") foo = TextElement(Tag("foo")) parser = TestElement() el = etree.Element(str(Tag("test"))) child = etree.Element(str(Tag("foo"))) child.text = "bar" el.append(child) parser.start(el) parser.start(child) parser.end(child) parser.end(el) assert parser.data == {"foo": "bar"}
def test_element_parser_with_partially_loaded_element(): """ If we use a streaming XML parser, the API will return start events for XML events before all/any of their children have been loaded. For this reason, we can't use any algorithm which looks at children as part of start events. """ class Foo(ElementParser): tag = Tag("foo") class TestElement(ElementParser): tag = Tag("test") foo = Foo(many=True) parser = TestElement() el = etree.Element(str(Tag("test"))) children = [ etree.Element(str(Tag("foo")), {"id": str(i)}) for i in range(3) ] parser.start(el) # with no children for child in children: el.extend([child]) parser.start(child) parser.end(child) parser.end(el) assert parser.data == { "foo": [ { "id": "0" }, { "id": "1" }, { "id": "2" }, ], }
class MeasurementUnitParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="measurement.unit" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="measurement.unit.code" type="MeasurementUnitCode"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("measurement.unit") code = TextElement(Tag("measurement.unit.code"))
class ValidityMixin: """Parse validity start and end dates.""" _additional_components = { TextElement(Tag("validity.start.date")): "valid_between_lower", TextElement(Tag("validity.end.date")): "valid_between_upper", } def clean(self): super().clean() valid_between = {} if "valid_between_lower" in self.data: valid_between["lower"] = self.data.pop("valid_between_lower") if "valid_between_upper" in self.data: valid_between["upper"] = self.data.pop("valid_between_upper") if valid_between: self.data["valid_between"] = valid_between
class RegulationGroupParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="regulation.group" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="regulation.group.id" type="RegulationGroupId"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("regulation.group") group_id = TextElement(Tag("regulation.group.id"))
class CertificateTypeParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="certificate.type" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="certificate.type.code" type="CertificateTypeCode"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("certificate.type") sid = TextElement(Tag("certificate.type.code"))
class RegulationGroupDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="regulation.group.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="regulation.group.id" type="RegulationGroupId"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("regulation.group.description") group_id = TextElement(Tag("regulation.group.id")) description = TextElement(Tag("description"))
class AdditionalCodeTypeDescriptionParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="additional.code.type.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="additional.code.type.id" type="AdditionalCodeTypeId"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("additional.code.type.description") sid = TextElement(Tag("additional.code.type.id")) description = TextElement(Tag("description"))
class EnvelopeParser(ElementParser): tag = Tag("envelope", prefix=ENVELOPE) transaction = TransactionParser(many=True) def __init__( self, workbasket_id: str, workbasket_status=None, partition_scheme: TransactionPartitionScheme = None, tamato_username=None, record_group: Sequence[str] = None, save: bool = True, **kwargs, ): super().__init__(**kwargs) self.last_transaction_id = -1 self.workbasket_id = workbasket_id self.workbasket_status = workbasket_status or WorkflowStatus.PUBLISHED.value self.tamato_username = tamato_username or settings.DATA_IMPORT_USERNAME self.record_group = record_group self.save = save self.envelope: Optional[Envelope] = None self.workbasket: Optional[WorkBasket] = None self.partition_scheme = partition_scheme def start(self, element: etree.Element, parent: ElementParser = None): super().start(element, parent) if element.tag == self.tag: self.envelope_id = element.get("id") if self.workbasket_id is None: user = get_user_model().objects.get(username=self.tamato_username) self.workbasket, _ = WorkBasket.objects.get_or_create( title=f"Data Import {self.envelope_id}", author=user, approver=user, status=self.workbasket_status, ) else: self.workbasket = WorkBasket.objects.get(pk=self.workbasket_id) self.envelope, _ = Envelope.objects.get_or_create( envelope_id=self.envelope_id, ) def end(self, element): super().end(element) if element.tag == self.tag: nursery = get_nursery() logger.info("cache size: %d", len(nursery.cache.keys())) nursery.clear_cache()
class CertificateTypeDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="certificate.type.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="certificate.type.code" type="CertificateTypeCode"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("certificate.type.description") sid = TextElement(Tag("certificate.type.code")) description = TextElement(Tag("description"))
class MeasurementUnitDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="measurement.unit.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="measurement.unit.code" type="MeasurementUnitCode"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("measurement.unit.description") code = TextElement(Tag("measurement.unit.code")) description = TextElement(Tag("description"))
class DutyExpressionDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="duty.expression.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="duty.expression.id" type="DutyExpressionId"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("duty.expression.description") sid = IntElement(Tag("duty.expression.id")) description = TextElement(Tag("description"))
class FootnoteAssociationAdditionalCodeParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block: XML <xs:element name="footnote.association.additional.code" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="additional.code.sid" type="SID"/> <xs:element name="footnote.type.id" type="FootnoteTypeId"/> <xs:element name="footnote.id" type="FootnoteId"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> <xs:element name="additional.code.type.id" type="AdditionalCodeTypeId"/> <xs:element name="additional.code" type="AdditionalCode"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "245" subrecord_code = "15" tag = Tag("footnote.association.additional.code") additional_code__sid = TextElement(Tag("additional.code.sid")) associated_footnote__footnote_type__sid = TextElement( Tag("footnote.type.id")) associated_footnote__footnote_id = TextElement(Tag("footnote.id")) valid_between_lower = ValidityMixin.valid_between_lower valid_between_upper = ValidityMixin.valid_between_upper additional_code__type__sid = TextElement(Tag("additional.code.type.id")) additional_code__code = TextElement(Tag("additional.code"))
class GoodsNomenclatureOriginParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="goods.nomenclature.origin" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="goods.nomenclature.sid" type="SID"/> <xs:element name="derived.goods.nomenclature.item.id" type="GoodsNomenclatureItemId"/> <xs:element name="derived.productline.suffix" type="ProductLineSuffix"/> <xs:element name="goods.nomenclature.item.id" type="GoodsNomenclatureItemId"/> <xs:element name="productline.suffix" type="ProductLineSuffix"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "400" subrecord_code = "35" tag = Tag("goods.nomenclature.origin") new_goods_nomenclature__sid = TextElement(Tag("goods.nomenclature.sid")) derived_from_goods_nomenclature__item_id = TextElement( Tag("derived.goods.nomenclature.item.id"), ) derived_from_goods_nomenclature__suffix = TextElement( Tag("derived.productline.suffix"), ) new_goods_nomenclature__item_id = TextElement( Tag("goods.nomenclature.item.id"), ) new_goods_nomenclature__suffix = TextElement(Tag("productline.suffix"))
class AdditionalCodeDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="additional.code.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="additional.code.description.period.sid" type="SID"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="additional.code.sid" type="SID"/> <xs:element name="additional.code.type.id" type="AdditionalCodeTypeId"/> <xs:element name="additional.code" type="AdditionalCode"/> <xs:element name="description" type="LongDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("additional.code.description") sid = TextElement(Tag("additional.code.description.period.sid")) described_additionalcode__sid = TextElement(Tag("additional.code.sid")) described_additionalcode__type__sid = TextElement(Tag("additional.code.type.id")) described_additionalcode__code = TextElement(Tag("additional.code")) description = TextElement(Tag("description"))
class AdditionalCodeDescriptionPeriodParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="additional.code.description.period" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="additional.code.description.period.sid" type="SID"/> <xs:element name="additional.code.sid" type="SID"/> <xs:element name="additional.code.type.id" type="AdditionalCodeTypeId"/> <xs:element name="additional.code" type="AdditionalCode"/> <xs:element name="validity.start.date" type="Date"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("additional.code.description.period") sid = TextElement(Tag("additional.code.description.period.sid")) additional_code_sid = TextElement(Tag("additional.code.sid")) additional_code_type_id = TextElement(Tag("additional.code.type.id")) additional_code = TextElement(Tag("additional.code")) valid_between_lower = TextElement(Tag("validity.start.date"))
class AdditionalCodeParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="additional.code" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="additional.code.sid" type="SID"/> <xs:element name="additional.code.type.id" type="AdditionalCodeTypeId"/> <xs:element name="additional.code" type="AdditionalCode"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("additional.code") sid = IntElement(Tag("additional.code.sid")) type__sid = TextElement(Tag("additional.code.type.id")) code = TextElement(Tag("additional.code")) valid_between_lower = TextElement(Tag("validity.start.date")) valid_between_upper = TextElement(Tag("validity.end.date"))
class QuotaSuspensionParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="quota.suspension.period" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="quota.suspension.period.sid" type="SID"/> <xs:element name="quota.definition.sid" type="SID"/> <xs:element name="suspension.start.date" type="Date"/> <xs:element name="suspension.end.date" type="Date"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "370" subrecord_code = "15" tag = Tag("quota.suspension.period") sid = IntElement(Tag("quota.suspension.period.sid")) quota_definition__sid = IntElement(Tag("quota.definition.sid")) valid_between_lower = RangeLowerElement(Tag("suspension.start.date")) valid_between_upper = RangeUpperElement(Tag("suspension.end.date")) description = TextElement(Tag("description"))
class MeasureConditionComponentParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="measure.condition.component" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="measure.condition.sid" type="SID"/> <xs:element name="duty.expression.id" type="DutyExpressionId"/> <xs:element name="duty.amount" type="DutyAmount" minOccurs="0"/> <xs:element name="monetary.unit.code" type="MonetaryUnitCode" minOccurs="0"/> <xs:element name="measurement.unit.code" type="MeasurementUnitCode" minOccurs="0"/> <xs:element name="measurement.unit.qualifier.code" type="MeasurementUnitQualifierCode" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "430" subrecord_code = "11" tag = Tag("measure.condition.component") condition__sid = TextElement(Tag("measure.condition.sid")) duty_expression__sid = DutyExpressionParser.sid duty_amount = TextElement(Tag("duty.amount")) monetary_unit__code = TextElement(Tag("monetary.unit.code")) component_measurement__measurement_unit__code = TextElement( Tag("measurement.unit.code"), ) component_measurement__measurement_unit_qualifier__code = TextElement( Tag("measurement.unit.qualifier.code"), )
class GeographicalAreaDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="geographical.area.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="geographical.area.description.period.sid" type="SID"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="geographical.area.sid" type="SID"/> <xs:element name="geographical.area.id" type="GeographicalAreaId"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "250" subrecord_code = "10" tag = Tag("geographical.area.description") sid = IntElement(Tag("geographical.area.description.period.sid")) language_id = ConstantElement(Tag("language.id"), value="EN") described_geographicalarea__sid = TextElement(Tag("geographical.area.sid")) described_geographicalarea__area_id = TextElement( Tag("geographical.area.id")) description = TextElement(Tag("description"))
class GoodsNomenclatureIndentParser(ValidityStartMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="goods.nomenclature.indents" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="goods.nomenclature.indent.sid" type="SID"/> <xs:element name="goods.nomenclature.sid" type="SID"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="number.indents" type="NumberOf"/> <xs:element name="goods.nomenclature.item.id" type="GoodsNomenclatureItemId"/> <xs:element name="productline.suffix" type="ProductLineSuffix"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "400" subrecord_code = "05" tag = Tag("goods.nomenclature.indents") sid = TextElement(Tag("goods.nomenclature.indent.sid")) indented_goods_nomenclature__sid = TextElement( Tag("goods.nomenclature.sid")) validity_start = ValidityStartMixin.validity_start indent = IntElement(Tag("number.indents"), format="FM00") indented_goods_nomenclature__item_id = TextElement( Tag("goods.nomenclature.item.id"), ) indented_goods_nomenclature__suffix = TextElement( Tag("productline.suffix"))
class CertificateDescriptionParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="certificate.description" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="certificate.description.period.sid" type="SID"/> <xs:element name="language.id" type="LanguageId"/> <xs:element name="certificate.type.code" type="CertificateTypeCode"/> <xs:element name="certificate.code" type="CertificateCode"/> <xs:element name="description" type="ShortDescription" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "205" subrecord_code = "10" tag = Tag("certificate.description") sid = IntElement(Tag("certificate.description.period.sid")) language_id = ConstantElement(Tag("language.id"), value="EN") described_certificate__certificate_type__sid = TextElement( Tag("certificate.type.code"), ) described_certificate__sid = TextElement(Tag("certificate.code")) description = TextElement(Tag("description"))
class GoodsNomenclatureSuccessorParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="goods.nomenclature.successor" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="goods.nomenclature.sid" type="SID"/> <xs:element name="absorbed.goods.nomenclature.item.id" type="GoodsNomenclatureItemId"/> <xs:element name="absorbed.productline.suffix" type="ProductLineSuffix"/> <xs:element name="goods.nomenclature.item.id" type="GoodsNomenclatureItemId"/> <xs:element name="productline.suffix" type="ProductLineSuffix"/> </xs:sequence> </xs:complexType> </xs:element> """ record_code = "400" subrecord_code = "40" tag = Tag("goods.nomenclature.successor") replaced_goods_nomenclature__sid = TextElement( Tag("goods.nomenclature.sid")) absorbed_into_goods_nomenclature__item_id = TextElement( Tag("absorbed.goods.nomenclature.item.id"), ) absorbed_into_goods_nomenclature__suffix = TextElement( Tag("absorbed.productline.suffix"), ) replaced_goods_nomenclature__item_id = TextElement( Tag("goods.nomenclature.item.id"), ) replaced_goods_nomenclature__suffix = TextElement( Tag("productline.suffix"))
class RecordParser(ElementParser): """Parser for TARIC3 `record` element.""" tag = Tag("record") transaction_id = TextElement(Tag("transaction.id")) record_code = TextElement(Tag("record.code")) subrecord_code = TextElement(Tag("subrecord.code")) sequence_number = TextElement(Tag("record.sequence.number")) update_type = TextElement(Tag("update.type")) def save(self, data: Mapping[str, Any], transaction_id: int): """ Save the Record to the database. :param data: A dict of the parsed element, mapping field names to values :param transaction_id: The primary key of the transaction to add the record to """ method_name = { str(UpdateType.UPDATE): "update", str(UpdateType.DELETE): "delete", str(UpdateType.CREATE): "create", }[data["update_type"]] for parser, field_name in self._field_lookup.items(): record_data = data.get(field_name) if record_data and hasattr(parser, method_name): getattr(parser, method_name)(record_data, transaction_id)
class FullTemporaryStopRegulationParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="full.temporary.stop.regulation" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="full.temporary.stop.regulation.role" type="RegulationRoleTypeId"/> <xs:element name="full.temporary.stop.regulation.id" type="RegulationId"/> <xs:element name="published.date" type="Date" minOccurs="0"/> <xs:element name="officialjournal.number" type="OfficialJournalNumber" minOccurs="0"/> <xs:element name="officialjournal.page" type="OfficialJournalPage" minOccurs="0"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> <xs:element name="effective.enddate" type="Date" minOccurs="0"/> <xs:element name="complete.abrogation.regulation.role" type="RegulationRoleTypeId" minOccurs="0"/> <xs:element name="complete.abrogation.regulation.id" type="RegulationId" minOccurs="0"/> <xs:element name="explicit.abrogation.regulation.role" type="RegulationRoleTypeId" minOccurs="0"/> <xs:element name="explicit.abrogation.regulation.id" type="RegulationId" minOccurs="0"/> <xs:element name="replacement.indicator" type="ReplacementIndicator"/> <xs:element name="information.text" type="ShortDescription" minOccurs="0"/> <xs:element name="approved.flag" type="ApprovedFlag"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("full.temporary.stop.regulation") role_type = IntElement(Tag("full.temporary.stop.regulation.role")) regulation_id = TextElement(Tag("full.temporary.stop.regulation.id")) published_at = TextElement(Tag("published.date")) official_journal_number = TextElement(Tag("officialjournal.number")) official_journal_page = IntElement(Tag("officialjournal.page")) effective_end_date = TextElement(Tag("effective.enddate")) replacement_indicator = IntElement(Tag("replacement.indicator")) information_text = TextElement(Tag("information.text")) approved = TextElement(Tag("approved.flag"))
class GeographicalAreaMembershipParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="geographical.area.membership" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="geographical.area.sid" type="SID"/> <xs:element name="geographical.area.group.sid" type="SID"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("geographical.area.membership") member__sid = IntElement(Tag("geographical.area.sid")) geo_group__sid = IntElement(Tag("geographical.area.group.sid"))
class FootnoteParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="footnote" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="footnote.type.id" type="FootnoteTypeId"/> <xs:element name="footnote.id" type="FootnoteId"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("footnote") footnote_type__footnote_type_id = TextElement(Tag("footnote.type.id")) footnote_id = TextElement(Tag("footnote.id"))
class MeasureTypeSeriesParser(ValidityMixin, Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="measure.type.series" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="measure.type.series.id" type="MeasureTypeSeriesId"/> <xs:element name="validity.start.date" type="Date"/> <xs:element name="validity.end.date" type="Date" minOccurs="0"/> <xs:element name="measure.type.combination" type="MeasureTypeCombination"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("measure.type.series") sid = TextElement(Tag("measure.type.series.id")) measure_type_combination = IntElement(Tag("measure.type.combination"))
class FootnoteAssociationMeasureParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="footnote.association.measure" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="measure.sid" type="SID"/> <xs:element name="footnote.type.id" type="FootnoteTypeId"/> <xs:element name="footnote.id" type="FootnoteId"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("footnote.association.measure") footnoted_measure__sid = TextElement(Tag("measure.sid")) associated_footnote__footnote_type__footnote_type_id = TextElement( Tag("footnote.type.id"), ) associated_footnote__footnote_id = TextElement(Tag("footnote.id"))
class MeasureExcludedGeographicalAreaParser(Writable, ElementParser): """ Example XML: .. code-block:: XML <xs:element name="measure.excluded.geographical.area" substitutionGroup="abstract.record"> <xs:complexType> <xs:sequence> <xs:element name="measure.sid" type="SID"/> <xs:element name="excluded.geographical.area" type="GeographicalAreaId"/> <xs:element name="geographical.area.sid" type="SID"/> </xs:sequence> </xs:complexType> </xs:element> """ tag = Tag("measure.excluded.geographical.area") modified_measure__sid = TextElement(Tag("measure.sid")) excluded_geographical_area__area_id = TextElement( Tag("excluded.geographical.area")) excluded_geographical_area__sid = TextElement(Tag("geographical.area.sid"))