(filename)=>
let
Источник = Xml.Tables(File.Contents(filename)),
#"Измененный тип" = Table.TransformColumnTypes(Источник,{{"status", type text}}),
#"Развернутый элемент room_record" = Table.ExpandTableColumn(#"Измененный тип", "room_record", {"record_info", "object", "cad_links", "params", "address_room", "location_in_build", "cost"}, {"room_record.record_info", "room_record.object", "room_record.cad_links", "room_record.params", "room_record.address_room", "room_record.location_in_build", "room_record.cost"}),
#"Развернутый элемент room_record.params" = Table.ExpandTableColumn(#"Развернутый элемент room_record", "room_record.params", {"area", "name", "purpose", "type"}, {"room_record.params.area", "room_record.params.name", "room_record.params.purpose", "room_record.params.type"}),
#"Удаленные столбцы" = Table.RemoveColumns(#"Развернутый элемент room_record.params",{"room_record.cad_links", "room_record.object", "room_record.record_info", "details_statement", "details_request"}),
#"Развернутый элемент room_record.params.purpose" = Table.ExpandTableColumn(#"Удаленные столбцы", "room_record.params.purpose", {"code", "value"}, {"room_record.params.purpose.code", "room_record.params.purpose.value"}),
#"Удаленные столбцы1" = Table.RemoveColumns(#"Развернутый элемент room_record.params.purpose",{"room_record.params.purpose.code", "room_record.params.purpose.value"}),
#"Развернутый элемент room_record.params.type" = Table.ExpandTableColumn(#"Удаленные столбцы1", "room_record.params.type", {"value"}, {"room_record.params.type.value"}),
#"Развернутый элемент room_record.address_room" = Table.ExpandTableColumn(#"Развернутый элемент room_record.params.type", "room_record.address_room", {"address"}, {"room_record.address_room.address"}),
#"Развернутый элемент room_record.address_room.address" = Table.ExpandTableColumn(#"Развернутый элемент room_record.address_room", "room_record.address_room.address", {"address", "location"}, {"room_record.address_room.address.address", "room_record.address_room.address.location"}),
#"Развернутый элемент room_record.address_room.address.address" = Table.ExpandTableColumn(#"Развернутый элемент room_record.address_room.address", "room_record.address_room.address.address", {"address_fias", "readable_address"}, {"room_record.address_room.address.address.address_fias", "room_record.address_room.address.address.readable_address"}),
#"Удаленные столбцы2" = Table.RemoveColumns(#"Развернутый элемент room_record.address_room.address.address",{"room_record.address_room.address.address.address_fias", "room_record.address_room.address.location", "room_record.location_in_build", "room_record.cost"}),
#"Развернутый элемент right_records" = Table.ExpandTableColumn(#"Удаленные столбцы2", "right_records", {"right_record"}, {"right_records.right_record"}),
#"Развернутый элемент right_records.right_record" = Table.ExpandTableColumn(#"Развернутый элемент right_records", "right_records.right_record", {"right_holders"}, {"right_records.right_record.right_holders"}),
#"Развернутый элемент right_records.right_record.right_holders" = Table.ExpandTableColumn(#"Развернутый элемент right_records.right_record", "right_records.right_record.right_holders", {"right_holder"}, {"right_records.right_record.right_holders.right_holder"}),
#"Развернутый элемент right_records.right_record.right_holders.right_holder" = Table.ExpandTableColumn(#"Развернутый элемент right_records.right_record.right_holders", "right_records.right_record.right_holders.right_holder", {"individual"}, {"right_records.right_record.right_holders.right_holder.individual"}),
#"Развернутый элемент right_records.right_record.right_holders.right_holder.individual" = Table.ExpandTableColumn(#"Развернутый элемент right_records.right_record.right_holders.right_holder", "right_records.right_record.right_holders.right_holder.individual", {"surname", "name", "patronymic", "birth_date", "birth_place", "citizenship", "snils", "identity_doc"}, {"right_records.right_record.right_holders.right_holder.individual.surname", "right_records.right_record.right_holders.right_holder.individual.name", "right_records.right_record.right_holders.right_holder.individual.patronymic", "right_records.right_record.right_holders.right_holder.individual.birth_date", "right_records.right_record.right_holders.right_holder.individual.birth_place", "right_records.right_record.right_holders.right_holder.individual.citizenship", "right_records.right_record.right_holders.right_holder.individual.snils", "right_records.right_record.right_holders.right_holder.individual.identity_doc"}),
#"Удаленные столбцы3" = Table.RemoveColumns(#"Развернутый элемент right_records.right_record.right_holders.right_holder.individual",{"right_records.right_record.right_holders.right_holder.individual.citizenship"}),
#"Развернутый элемент right_records.right_record.right_holders.right_holder.individual.identity_doc" = Table.ExpandTableColumn(#"Удаленные столбцы3", "right_records.right_record.right_holders.right_holder.individual.identity_doc", {"document_code", "document_series", "document_number", "document_date", "document_issuer"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc.do", "right_records.right_record.right_holders.right_holder.individual.identity_doc..1", "right_records.right_record.right_holders.right_holder.individual.identity_doc..2", "right_records.right_record.right_holders.right_holder.individual.identity_doc..3", "right_records.right_record.right_holders.right_holder.individual.identity_doc..4"}),
#"Развернутый элемент right_records.right_record.right_holders.right_holder.individual.identity_doc.do" = Table.ExpandTableColumn(#"Развернутый элемент right_records.right_record.right_holders.right_holder.individual.identity_doc", "right_records.right_record.right_holders.right_holder.individual.identity_doc.do", {"code", "value"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc..5", "right_records.right_record.right_holders.right_holder.individual.identity_doc..6"}),
#"Удаленные столбцы4" = Table.RemoveColumns(#"Развернутый элемент right_records.right_record.right_holders.right_holder.individual.identity_doc.do",{"right_records.right_record.right_holders.right_holder.individual.identity_doc..5"}),
#"Переупорядоченные столбцы" = Table.ReorderColumns(#"Удаленные столбцы4",{"room_record.address_room.address.address.readable_address", "room_record.params.area", "room_record.params.name", "room_record.params.type.value", "right_records.right_record.right_holders.right_holder.individual.surname", "right_records.right_record.right_holders.right_holder.individual.name", "right_records.right_record.right_holders.right_holder.individual.patronymic", "right_records.right_record.right_holders.right_holder.individual.birth_date", "right_records.right_record.right_holders.right_holder.individual.birth_place", "right_records.right_record.right_holders.right_holder.individual.snils", "right_records.right_record.right_holders.right_holder.individual.identity_doc..6", "right_records.right_record.right_holders.right_holder.individual.identity_doc..1", "right_records.right_record.right_holders.right_holder.individual.identity_doc..2", "right_records.right_record.right_holders.right_holder.individual.identity_doc..3", "right_records.right_record.right_holders.right_holder.individual.identity_doc..4", "status"}),
#"Переименованные столбцы" = Table.RenameColumns(#"Переупорядоченные столбцы",{{"room_record.address_room.address.address.readable_address", "адрес"}, {"room_record.params.area", "площадь"}, {"room_record.params.name", "тип"}, {"room_record.params.type.value", "назначение"}, {"right_records.right_record.right_holders.right_holder.individual.surname", "фамилия"}, {"right_records.right_record.right_holders.right_holder.individual.name", "имя"}, {"right_records.right_record.right_holders.right_holder.individual.patronymic", "отчество"}, {"right_records.right_record.right_holders.right_holder.individual.birth_date", "дата рожд"}, {"right_records.right_record.right_holders.right_holder.individual.birth_place", "место рожд"}, {"right_records.right_record.right_holders.right_holder.individual.snils", "снилс"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc..6", "вид документа"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc..1", "серия"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc..2", "номер"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc..3", "дата выдачи"}, {"right_records.right_record.right_holders.right_holder.individual.identity_doc..4", "кем выдан"}, {"status", "статус сведений"}})
in
#"Переименованные столбцы |