diff --git a/src/app/app.config.ts b/src/app/app.config.ts index e4a46b42b..e7537548d 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -148,6 +148,7 @@ export interface EditionConfig { organizations: NamedEntitiesListsConfig; relations: NamedEntitiesListsConfig; events: NamedEntitiesListsConfig; + objects: NamedEntitiesListsConfig; }>; entitiesSelectItems: EntitiesSelectItemGroup[]; notSignificantVariants: string[]; diff --git a/src/app/components/global-lists/global-lists.component.ts b/src/app/components/global-lists/global-lists.component.ts index 8c31274b4..5ababbaef 100644 --- a/src/app/components/global-lists/global-lists.component.ts +++ b/src/app/components/global-lists/global-lists.component.ts @@ -17,7 +17,7 @@ interface GlobalList extends NamedEntitiesList { }) export class GlobalListsComponent { lists$: Observable = this.evtModelService.namedEntities$.pipe( - map((ne) => (ne.persons.lists.concat(ne.places.lists, ne.organizations.lists, ne.events.lists))), + map((ne) => (ne.persons.lists.concat(ne.places.lists, ne.organizations.lists, ne.events.lists, ne.objects.lists))), map((lists) => (lists.map((list) => ({ ...list, icon: this.listsIcons[list.namedEntityType] || 'list', diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index 54e3f77c5..2452e63e3 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -85,6 +85,10 @@ export interface NamedEntities { lists: NamedEntitiesList[]; entities: NamedEntity[]; }; + objects: { + lists: NamedEntitiesList[]; + entities: NamedEntity[]; + }; } export interface Attributes { [key: string]: string; } @@ -93,7 +97,7 @@ export interface OriginalEncoding { originalEncoding: OriginalEncodingNodeType; } -export type NamedEntityType = 'person' | 'place' | 'org' | 'relation' | 'event' | 'generic'; +export type NamedEntityType = 'person' | 'place' | 'org' | 'relation' | 'event' | 'object' | 'generic'; export class NamedEntitiesList extends GenericElement { id: string; label: string; diff --git a/src/app/services/evt-model.service.ts b/src/app/services/evt-model.service.ts index cc561048c..823d3eb31 100644 --- a/src/app/services/evt-model.service.ts +++ b/src/app/services/evt-model.service.ts @@ -2,15 +2,15 @@ import { Injectable } from '@angular/core'; import { combineLatest, Observable } from 'rxjs'; import { combineLatestWith, map, shareReplay, switchMap } from 'rxjs/operators'; import { - ChangeLayerData, - Facsimile, - NamedEntities, - NamedEntityOccurrence, - OriginalEncodingNodeType, - Page, - XMLImagesValues, - ZoneHotSpot, - ZoneLine, + ChangeLayerData, + Facsimile, + NamedEntities, + NamedEntityOccurrence, + OriginalEncodingNodeType, + Page, + XMLImagesValues, + ZoneHotSpot, + ZoneLine, } from '../models/evt-models'; import { Map } from '../utils/js-utils'; import { EditionDataService } from './edition-data.service'; @@ -30,358 +30,364 @@ import { BibliographicEntriesParserService } from './xml-parsers/bibliographic-e import { ModParserService } from './xml-parsers/mod-parser.service'; @Injectable({ - providedIn: 'root', + providedIn: 'root', }) export class EVTModelService { - public readonly editionSource$: Observable = this.editionDataService.parsedEditionSource$ - .pipe( - shareReplay(1), - ); - - public readonly title$ = this.editionSource$.pipe( - map((source) => this.prefatoryMatterParser.parseEditionTitle(source)), - shareReplay(1), - ); - - public readonly projectInfo$ = this.prefatoryMatterParser.projectInfo$.pipe( - shareReplay(1), - ); - - public readonly styleDefaults$ = this.prefatoryMatterParser.projectInfo$.pipe( - map((projectInfo) => projectInfo?.encodingDesc?.styleDefDecl), - shareReplay(1), - ); - - public readonly pages$: Observable = this.editionSource$.pipe( - map((source) => this.editionStructureParser.parsePages(source).pages), - shareReplay(1), - ); - - // NAMED ENTITIES - public readonly parsedLists$ = this.editionSource$.pipe( - map((source) => this.namedEntitiesParser.parseLists(source)), - shareReplay(1), - ); - - public readonly persons$ = this.parsedLists$.pipe( - map(({ lists, entities }) => (this.namedEntitiesParser.getResultsByType(lists, entities, ['person', 'personGrp']))), - ); - - public readonly places$ = this.parsedLists$.pipe( - map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['place'])), - ); - - public readonly organizations$ = this.parsedLists$.pipe( - map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['org'])), - ); - - public readonly relations$ = this.parsedLists$.pipe( - map(({ relations }) => relations), - ); - - public readonly events$ = this.parsedLists$.pipe( - map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['event'])), - ); - - public readonly verses$ = this.editionSource$.pipe( - map((source) => this.linesVersesParser.parseVerses(source)), - shareReplay(1), - ); - - public readonly lines$ = this.editionSource$.pipe( - map((source) => this.linesVersesParser.parseLines(source)), - shareReplay(1), - ); - - public readonly namedEntities$: Observable = combineLatest([ - this.persons$, - this.places$, - this.organizations$, - this.relations$, - this.events$, - ]).pipe( - map(([persons, places, organizations, relations, events]) => ({ - all: { - lists: [...persons.lists, ...places.lists, ...organizations.lists, ...events.lists], - entities: [...persons.entities, ...places.entities, ...organizations.entities, ...events.entities], - }, - persons, - places, - organizations, - relations, - events, - })), - shareReplay(1), - ); - - public entitiesOccurrences$: Observable> = this.pages$.pipe( - map((pages) => this.namedEntitiesParser.parseNamedEntitiesOccurrences(pages)), - shareReplay(1), - ); - - // WITNESSES - public readonly witnessesData$ = this.editionSource$.pipe( - map((source) => this.witnessesParser.parseWitnessesData(source)), - shareReplay(1), - ); - - public readonly witnesses$ = this.witnessesData$.pipe( - map(({ witnesses }) => witnesses), - shareReplay(1), - ); - - public readonly groups$ = this.witnessesData$.pipe( - map(({ groups }) => groups), - shareReplay(1), - ); - - // CHANGES - public changeData$: Observable = this.editionSource$.pipe( - map((source) => this.modParser.buildChangeList(source)), - shareReplay(1), - ); - - // APPARATUS ENTRIES - public readonly appEntries$ = this.editionSource$.pipe( - map((source) => this.apparatusParser.parseAppEntries(source)), - shareReplay(1), - ); - - public readonly significantReadings$ = this.appEntries$.pipe( - map((appEntries) => this.apparatusParser.getSignificantReadings(appEntries)), - shareReplay(1), - ); - - public readonly significantReadingsNumber$ = this.significantReadings$.pipe( - map((signRdgs) => this.apparatusParser.getSignificantReadingsNumber(signRdgs)), - shareReplay(1), - ); - - public readonly appVariance$ = this.witnesses$.pipe( - switchMap((witList) => this.significantReadingsNumber$.pipe( - map((signRdgsNum) => this.apparatusParser.getAppVariance(signRdgsNum, witList)), - )), - shareReplay(1), - ); - - //QUOTED SOURCES - public readonly sourceEntries$ = this.editionSource$.pipe( - map((source) => this.sourceParser.parseSourceEntries(source)), - shareReplay(1), - ); - - // PARALLEL PASSAGES - public readonly analogueEntries$ = this.editionSource$.pipe( - map((source) => this.analogueParser.parseAnaloguesEntries(source)), - shareReplay(1), - ); - - // FACSIMILE - public readonly facsimile$ : Observable = this.editionSource$.pipe( - map((source) => this.facsimileParser.parseFacsimile(source)), - shareReplay(1), - ); - - public readonly facsimileImageDouble$: Observable = this.facsimile$.pipe( - map((facSimiles)=>{ - const fcRendDouble = facSimiles.find((fs) => fs.attributes['rend'] === 'double'); - if (fcRendDouble) {return fcRendDouble;} - - const fcWithSurfacesGrp = facSimiles.find((fs)=> fs.surfaceGrps?.length > 0); - if (fcWithSurfacesGrp) {return fcWithSurfacesGrp;} - - return undefined; - }), - ); - - public readonly imageDoublePages$: Observable = this.facsimileImageDouble$.pipe( - combineLatestWith(this.pages$), - map(([ facsSimile, pages])=>{ - if (facsSimile?.graphics?.length > 0){ - // Qui abbiamo i graphics - return facsSimile.graphics.map((_g, index)=>{ - const p : Page={ - url: '', - parsedContent: undefined, - originalContent: undefined, - label: _g.attributes['n'], - id: index.toString(), - facsUrl: '', - facs: '', - }; - - return p; - }); - } - - return facsSimile?.surfaceGrps.map((sGrp)=> { - const titleName = sGrp.surfaces.reduce((pv, cv) => { - const fp: Page = pages.find((p)=>p.id === cv.corresp); - if (pv.length === 0) { - - if (fp){ - return pv + fp.label; - } - - return pv + cv.corresp.replace('#', ''); - } - if (fp){ - return pv + ' ' + fp.label; - } + public readonly editionSource$: Observable = this.editionDataService.parsedEditionSource$ + .pipe( + shareReplay(1), + ); + + public readonly title$ = this.editionSource$.pipe( + map((source) => this.prefatoryMatterParser.parseEditionTitle(source)), + shareReplay(1), + ); + + public readonly projectInfo$ = this.prefatoryMatterParser.projectInfo$.pipe( + shareReplay(1), + ); + + public readonly styleDefaults$ = this.prefatoryMatterParser.projectInfo$.pipe( + map((projectInfo) => projectInfo?.encodingDesc?.styleDefDecl), + shareReplay(1), + ); + + public readonly pages$: Observable = this.editionSource$.pipe( + map((source) => this.editionStructureParser.parsePages(source).pages), + shareReplay(1), + ); + + // NAMED ENTITIES + public readonly parsedLists$ = this.editionSource$.pipe( + map((source) => this.namedEntitiesParser.parseLists(source)), + shareReplay(1), + ); + + public readonly persons$ = this.parsedLists$.pipe( + map(({ lists, entities }) => (this.namedEntitiesParser.getResultsByType(lists, entities, ['person', 'personGrp']))), + ); + + public readonly places$ = this.parsedLists$.pipe( + map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['place'])), + ); - return pv + ' ' + cv.corresp.replace('#', ''); + public readonly organizations$ = this.parsedLists$.pipe( + map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['org'])), + ); + + public readonly relations$ = this.parsedLists$.pipe( + map(({ relations }) => relations), + ); + + public readonly events$ = this.parsedLists$.pipe( + map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['event'])), + ); - }, ''); - const id = sGrp.surfaces.reduce((pv, cv) => { - if (pv.length === 0) { - return pv + cv.corresp.replace('#', ''); + public readonly objects$ = this.parsedLists$.pipe( + map(({ lists, entities }) => this.namedEntitiesParser.getResultsByType(lists, entities, ['object'])), + ); + + public readonly verses$ = this.editionSource$.pipe( + map((source) => this.linesVersesParser.parseVerses(source)), + shareReplay(1), + ); + + public readonly lines$ = this.editionSource$.pipe( + map((source) => this.linesVersesParser.parseLines(source)), + shareReplay(1), + ); + + public readonly namedEntities$: Observable = combineLatest([ + this.persons$, + this.places$, + this.organizations$, + this.relations$, + this.events$, + this.objects$, + ]).pipe( + map(([persons, places, organizations, relations, events, objects]) => ({ + all: { + lists: [...persons.lists, ...places.lists, ...organizations.lists, ...events.lists, ...objects.lists], + entities: [...persons.entities, ...places.entities, ...organizations.entities, ...events.entities, ...objects.entities], + }, + persons, + places, + organizations, + relations, + events, + objects, + })), + shareReplay(1), + ); + + public entitiesOccurrences$: Observable> = this.pages$.pipe( + map((pages) => this.namedEntitiesParser.parseNamedEntitiesOccurrences(pages)), + shareReplay(1), + ); + + // WITNESSES + public readonly witnessesData$ = this.editionSource$.pipe( + map((source) => this.witnessesParser.parseWitnessesData(source)), + shareReplay(1), + ); + + public readonly witnesses$ = this.witnessesData$.pipe( + map(({ witnesses }) => witnesses), + shareReplay(1), + ); + + public readonly groups$ = this.witnessesData$.pipe( + map(({ groups }) => groups), + shareReplay(1), + ); + + // CHANGES + public changeData$: Observable = this.editionSource$.pipe( + map((source) => this.modParser.buildChangeList(source)), + shareReplay(1), + ); + + // APPARATUS ENTRIES + public readonly appEntries$ = this.editionSource$.pipe( + map((source) => this.apparatusParser.parseAppEntries(source)), + shareReplay(1), + ); + + public readonly significantReadings$ = this.appEntries$.pipe( + map((appEntries) => this.apparatusParser.getSignificantReadings(appEntries)), + shareReplay(1), + ); + + public readonly significantReadingsNumber$ = this.significantReadings$.pipe( + map((signRdgs) => this.apparatusParser.getSignificantReadingsNumber(signRdgs)), + shareReplay(1), + ); + + public readonly appVariance$ = this.witnesses$.pipe( + switchMap((witList) => this.significantReadingsNumber$.pipe( + map((signRdgsNum) => this.apparatusParser.getAppVariance(signRdgsNum, witList)), + )), + shareReplay(1), + ); + + //QUOTED SOURCES + public readonly sourceEntries$ = this.editionSource$.pipe( + map((source) => this.sourceParser.parseSourceEntries(source)), + shareReplay(1), + ); + + // PARALLEL PASSAGES + public readonly analogueEntries$ = this.editionSource$.pipe( + map((source) => this.analogueParser.parseAnaloguesEntries(source)), + shareReplay(1), + ); + + // FACSIMILE + public readonly facsimile$: Observable = this.editionSource$.pipe( + map((source) => this.facsimileParser.parseFacsimile(source)), + shareReplay(1), + ); + + public readonly facsimileImageDouble$: Observable = this.facsimile$.pipe( + map((facSimiles) => { + const fcRendDouble = facSimiles.find((fs) => fs.attributes['rend'] === 'double'); + if (fcRendDouble) { return fcRendDouble; } + + const fcWithSurfacesGrp = facSimiles.find((fs) => fs.surfaceGrps?.length > 0); + if (fcWithSurfacesGrp) { return fcWithSurfacesGrp; } + + return undefined; + }), + ); + + public readonly imageDoublePages$: Observable = this.facsimileImageDouble$.pipe( + combineLatestWith(this.pages$), + map(([facsSimile, pages]) => { + if (facsSimile?.graphics?.length > 0) { + // Qui abbiamo i graphics + return facsSimile.graphics.map((_g, index) => { + const p: Page = { + url: '', + parsedContent: undefined, + originalContent: undefined, + label: _g.attributes['n'], + id: index.toString(), + facsUrl: '', + facs: '', + }; + + return p; + }); } - return pv + '-' + cv.corresp.replace('#', ''); - }, ''); - - const p : Page={ - url: '', - parsedContent: undefined, - originalContent: undefined, - label: titleName, - id: id, - facsUrl: '', - facs: '', - }; - - return p; - }); - - - }), - ); - - public readonly imageDouble$: Observable<{ type: string, value:{ xmlImages:XMLImagesValues[]}} | undefined > = - this.facsimileImageDouble$.pipe( - map((fs)=> { - if (fs?.graphics?.length > 0){ - //const editionImages = AppConfig.evtSettings.files.editionImagesSource; - const result: XMLImagesValues[] = fs.graphics.map((g) => { - - const fileName = g.url; - - const imagesFolderUrl = AppConfig.evtSettings.files.imagesFolderUrls.double; - const url = `${imagesFolderUrl}${fileName}`; - const r: XMLImagesValues = { - url: url, - width: g.width?parseInt(g.width) : 910, - height: g.height?parseInt(g.height) : 720, + return facsSimile?.surfaceGrps.map((sGrp) => { + const titleName = sGrp.surfaces.reduce((pv, cv) => { + const fp: Page = pages.find((p) => p.id === cv.corresp); + if (pv.length === 0) { + + if (fp) { + return pv + fp.label; + } + + return pv + cv.corresp.replace('#', ''); + } + if (fp) { + return pv + ' ' + fp.label; + } + + return pv + ' ' + cv.corresp.replace('#', ''); + + }, ''); + const id = sGrp.surfaces.reduce((pv, cv) => { + if (pv.length === 0) { + return pv + cv.corresp.replace('#', ''); + } + + return pv + '-' + cv.corresp.replace('#', ''); + }, ''); + + const p: Page = { + url: '', + parsedContent: undefined, + originalContent: undefined, + label: titleName, + id: id, + facsUrl: '', + facs: '', }; - return r; - }); + return p; + }); - return { - type: 'default', - value: { - xmlImages: result, - }, - }; - } else if (fs?.surfaceGrps?.length > 0) { - const editionImages = AppConfig.evtSettings.files.editionImagesSource; - console.log(editionImages); - - const result: XMLImagesValues[] = fs.surfaceGrps.map((sGrp) => { - - const fileName = sGrp.surfaces.reduce((pv, cv) => { - if (pv.length === 0) { - return pv + cv.corresp.replace('#', ''); - } - - return pv + '-' + cv.corresp.replace('#', ''); - }, ''); - - const imagesFolderUrl = AppConfig.evtSettings.files.imagesFolderUrls.double; - const url = `${imagesFolderUrl}${fileName}.jpg`; - const r: XMLImagesValues = { - url: url, - width: 910, - height: 720, - }; - - return r; - }); - - return { - type: 'default', - value: { - xmlImages: result, - }, - }; - } - - return undefined; - }), - ); - - public readonly surfaces$ = this.editionSource$.pipe( - map((source) => this.facsimileParser.parseSurfaces(source)), - shareReplay(1), - ); - - public readonly hsLines$ = this.surfaces$.pipe( - map((surfaces) => surfaces.reduce((x: ZoneLine[], y) => x.concat(y.zones.lines), [])), - shareReplay(1), - ); - - public readonly hotspots$ = this.surfaces$.pipe( - map((surfaces) => surfaces.reduce((x: ZoneHotSpot[], y) => x.concat(y.zones.hotspots), [])), - shareReplay(1), - ); - - // CHAR DECL - public readonly characters$ = this.editionSource$.pipe( - map((source) => this.characterDeclarationsParser.parseChars(source)), - shareReplay(1), - ); - - public readonly glyphs$ = this.editionSource$.pipe( - map((source) => this.characterDeclarationsParser.parseGlyphs(source)), - shareReplay(1), - ); - - public readonly specialChars$ = combineLatest([ - this.characters$, - this.glyphs$, + + }), + ); + + public readonly imageDouble$: Observable<{ type: string, value: { xmlImages: XMLImagesValues[] } } | undefined> = + this.facsimileImageDouble$.pipe( + map((fs) => { + if (fs?.graphics?.length > 0) { + //const editionImages = AppConfig.evtSettings.files.editionImagesSource; + const result: XMLImagesValues[] = fs.graphics.map((g) => { + + const fileName = g.url; + + const imagesFolderUrl = AppConfig.evtSettings.files.imagesFolderUrls.double; + const url = `${imagesFolderUrl}${fileName}`; + const r: XMLImagesValues = { + url: url, + width: g.width ? parseInt(g.width) : 910, + height: g.height ? parseInt(g.height) : 720, + }; + + return r; + }); + + return { + type: 'default', + value: { + xmlImages: result, + }, + }; + } else if (fs?.surfaceGrps?.length > 0) { + const editionImages = AppConfig.evtSettings.files.editionImagesSource; + console.log(editionImages); + + const result: XMLImagesValues[] = fs.surfaceGrps.map((sGrp) => { + + const fileName = sGrp.surfaces.reduce((pv, cv) => { + if (pv.length === 0) { + return pv + cv.corresp.replace('#', ''); + } + + return pv + '-' + cv.corresp.replace('#', ''); + }, ''); + + const imagesFolderUrl = AppConfig.evtSettings.files.imagesFolderUrls.double; + const url = `${imagesFolderUrl}${fileName}.jpg`; + const r: XMLImagesValues = { + url: url, + width: 910, + height: 720, + }; + + return r; + }); + + return { + type: 'default', + value: { + xmlImages: result, + }, + }; + } + + return undefined; + }), + ); + + public readonly surfaces$ = this.editionSource$.pipe( + map((source) => this.facsimileParser.parseSurfaces(source)), + shareReplay(1), + ); + + public readonly hsLines$ = this.surfaces$.pipe( + map((surfaces) => surfaces.reduce((x: ZoneLine[], y) => x.concat(y.zones.lines), [])), + shareReplay(1), + ); + + public readonly hotspots$ = this.surfaces$.pipe( + map((surfaces) => surfaces.reduce((x: ZoneHotSpot[], y) => x.concat(y.zones.hotspots), [])), + shareReplay(1), + ); + + // CHAR DECL + public readonly characters$ = this.editionSource$.pipe( + map((source) => this.characterDeclarationsParser.parseChars(source)), + shareReplay(1), + ); + + public readonly glyphs$ = this.editionSource$.pipe( + map((source) => this.characterDeclarationsParser.parseGlyphs(source)), + shareReplay(1), + ); + + public readonly specialChars$ = combineLatest([ + this.characters$, + this.glyphs$, ]).pipe( - map(([chars, glyphs]) => chars.concat(glyphs)), - ); - - public readonly msDesc$ = this.editionSource$.pipe( - map((source) => this.msDescParser.parseMsDesc(source)), - shareReplay(1), - ); - - public readonly bibliographicEntries$ = this.editionSource$.pipe( - map((source) => this.bibliographicEntriesParser.parseBibliographicEntries(source)), - shareReplay(1), - ) - - constructor( - private analogueParser: AnalogueEntriesParserService, - private editionDataService: EditionDataService, - private editionStructureParser: StructureXmlParserService, - private namedEntitiesParser: NamedEntitiesParserService, - private prefatoryMatterParser: PrefatoryMatterParserService, - private witnessesParser: WitnessesParserService, - private apparatusParser: ApparatusEntriesParserService, - private facsimileParser: FacsimileParserService, - private characterDeclarationsParser: CharacterDeclarationsParserService, - private linesVersesParser: LinesVersesParserService, - private msDescParser: MsDescParserService, - private sourceParser: SourceEntriesParserService, - private bibliographicEntriesParser: BibliographicEntriesParserService, - private modParser: ModParserService, - ) { - } - - getPage(pageId: string): Observable { - return this.pages$.pipe(map((pages) => pages.find((page) => page.id === pageId))); - } + map(([chars, glyphs]) => chars.concat(glyphs)), + ); + + public readonly msDesc$ = this.editionSource$.pipe( + map((source) => this.msDescParser.parseMsDesc(source)), + shareReplay(1), + ); + + public readonly bibliographicEntries$ = this.editionSource$.pipe( + map((source) => this.bibliographicEntriesParser.parseBibliographicEntries(source)), + shareReplay(1), + ) + + constructor( + private analogueParser: AnalogueEntriesParserService, + private editionDataService: EditionDataService, + private editionStructureParser: StructureXmlParserService, + private namedEntitiesParser: NamedEntitiesParserService, + private prefatoryMatterParser: PrefatoryMatterParserService, + private witnessesParser: WitnessesParserService, + private apparatusParser: ApparatusEntriesParserService, + private facsimileParser: FacsimileParserService, + private characterDeclarationsParser: CharacterDeclarationsParserService, + private linesVersesParser: LinesVersesParserService, + private msDescParser: MsDescParserService, + private sourceParser: SourceEntriesParserService, + private bibliographicEntriesParser: BibliographicEntriesParserService, + private modParser: ModParserService, + ) { + } + + getPage(pageId: string): Observable { + return this.pages$.pipe(map((pages) => pages.find((page) => page.id === pageId))); + } } diff --git a/src/app/services/xml-parsers/header-parser.ts b/src/app/services/xml-parsers/header-parser.ts index 98c8de1eb..c39fc6ce4 100644 --- a/src/app/services/xml-parsers/header-parser.ts +++ b/src/app/services/xml-parsers/header-parser.ts @@ -2,16 +2,16 @@ import { isNestedInElem } from 'src/app/utils/dom-utils'; import { isBoolString } from 'src/app/utils/js-utils'; import { xmlParser } from '.'; import { - Abstract, Calendar, CalendarDesc, CatRef, Change, Channel, ChannelMode, ClassCode, Constitution, - Correction, CorrectionMethod, CorrectionStatus, CorrespAction, CorrespActionType, CorrespContext, CorrespDesc, Creation, CRefPattern, - Degree, Derivation, Description, Domain, EditionStmt, EditorialDecl, EncodingDesc, Extent, Factuality, FileDesc, GenericElement, - HandNote, HandNotes, HandNoteScope, Hyphenation, HyphenationEol, Interaction, Interpretation, - Keywords, Language, LangUsage, ListChange, ListTranspose, MsDesc, NamedEntitiesList, NamedEntityRef, Namespace, Normalization, - NormalizationMethod, Note, NotesStmt, Paragraph, ParticDesc, Preparedness, ProfileDesc, ProjectDesc, Ptr, PublicationStmt, - Punctuation, PunctuationMarks, PunctuationPlacement, - Purpose, Quotation, QuotationMarks, RefsDecl, RefState, Rendition, RenditionScope, Resp, RespStmt, RevisionDesc, - SamplingDecl, Scheme, Segmentation, SeriesStmt, Setting, SettingDesc, SourceDesc, Status, StdVals, - StyleDefDecl, TagsDecl, TagUsage, Term, TextClass, TextDesc, TitleStmt, Transpose, XMLElement, + Abstract, Calendar, CalendarDesc, CatRef, Change, Channel, ChannelMode, ClassCode, Constitution, + Correction, CorrectionMethod, CorrectionStatus, CorrespAction, CorrespActionType, CorrespContext, CorrespDesc, Creation, CRefPattern, + Degree, Derivation, Description, Domain, EditionStmt, EditorialDecl, EncodingDesc, Extent, Factuality, FileDesc, GenericElement, + HandNote, HandNotes, HandNoteScope, Hyphenation, HyphenationEol, Interaction, Interpretation, + Keywords, Language, LangUsage, ListChange, ListTranspose, MsDesc, NamedEntitiesList, NamedEntityRef, Namespace, Normalization, + NormalizationMethod, Note, NotesStmt, Paragraph, ParticDesc, Preparedness, ProfileDesc, ProjectDesc, Ptr, PublicationStmt, + Punctuation, PunctuationMarks, PunctuationPlacement, + Purpose, Quotation, QuotationMarks, RefsDecl, RefState, Rendition, RenditionScope, Resp, RespStmt, RevisionDesc, + SamplingDecl, Scheme, Segmentation, SeriesStmt, Setting, SettingDesc, SourceDesc, Status, StdVals, + StyleDefDecl, TagsDecl, TagUsage, Term, TextClass, TextDesc, TitleStmt, Transpose, XMLElement, } from '../../models/evt-models'; import { GenericElemParser, GenericParser, parseElement, queryAndParseElement, queryAndParseElements } from './basic-parsers'; import { NamedEntityRefParser } from './named-entity-parsers'; @@ -19,867 +19,869 @@ import { complexElements, createParser, getDefaultAttr, getID, Parser } from './ @xmlParser('resp', RespParser) export class RespParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Resp { - const { ref, when } = this.attributeParser.parse(xml); - const normalizedResp = ref?.indexOf('http://') < 0 && ref?.indexOf('https://') < 0 ? `http://${ref}` : ref ?? ''; + parse(xml: XMLElement): Resp { + const { ref, when } = this.attributeParser.parse(xml); + const normalizedResp = ref?.indexOf('http://') < 0 && ref?.indexOf('https://') < 0 ? `http://${ref}` : ref ?? ''; - return { - ...super.parse(xml), - type: Resp, - normalizedResp, - date: when || '', - }; - } + return { + ...super.parse(xml), + type: Resp, + normalizedResp, + date: when || '', + }; + } } @xmlParser('respStmt', RespStmtParser) export class RespStmtParser extends GenericElemParser implements Parser { - private namedEntityRefParser = createParser(NamedEntityRefParser, this.genericParse); + private namedEntityRefParser = createParser(NamedEntityRefParser, this.genericParse); - parse(xml: XMLElement): RespStmt { - const people = Array.from(xml.querySelectorAll(':scope > name, :scope > orgName, :scope > persName')) - .map((p) => { - if (['orgName', 'persName'].includes(p.tagName)) { - return this.namedEntityRefParser.parse(p) as NamedEntityRef; - } + parse(xml: XMLElement): RespStmt { + const people = Array.from(xml.querySelectorAll(':scope > name, :scope > orgName, :scope > persName')) + .map((p) => { + if (['orgName', 'persName'].includes(p.tagName)) { + return this.namedEntityRefParser.parse(p) as NamedEntityRef; + } - return this.genericParse(p) as GenericElement; - }); + return this.genericParse(p) as GenericElement; + }); - return { - ...super.parse(xml), - type: RespStmt, - responsibility: queryAndParseElement(xml, 'resp'), - notes: queryAndParseElements(xml, 'note'), - people, - }; - } + return { + ...super.parse(xml), + type: RespStmt, + responsibility: queryAndParseElement(xml, 'resp'), + notes: queryAndParseElements(xml, 'note'), + people, + }; + } } @xmlParser('titleStmt', TitleStmtParser) export class TitleStmtParser extends GenericParser implements Parser { - parse(xml: XMLElement): TitleStmt { - const title = queryAndParseElements(xml, 'title[type="main"]'); - - return { - ...super.parse(xml), - type: TitleStmt, - titles: title.length > 0 ? title : queryAndParseElements(xml, 'title:not([type="sub"])'), - subtitles: queryAndParseElements(xml, 'title[type="sub"]'), - authors: queryAndParseElements(xml, 'author'), - editors: queryAndParseElements(xml, 'editor'), - sponsors: queryAndParseElements(xml, 'sponsor'), - funders: queryAndParseElements(xml, 'funder'), - principals: queryAndParseElements(xml, 'principal'), - respStmts: queryAndParseElements(xml, 'respStmt'), - }; - } + parse(xml: XMLElement): TitleStmt { + const title = queryAndParseElements(xml, 'title[type="main"]'); + + return { + ...super.parse(xml), + type: TitleStmt, + titles: title.length > 0 ? title : queryAndParseElements(xml, 'title:not([type="sub"])'), + subtitles: queryAndParseElements(xml, 'title[type="sub"]'), + authors: queryAndParseElements(xml, 'author'), + editors: queryAndParseElements(xml, 'editor'), + sponsors: queryAndParseElements(xml, 'sponsor'), + funders: queryAndParseElements(xml, 'funder'), + principals: queryAndParseElements(xml, 'principal'), + respStmts: queryAndParseElements(xml, 'respStmt'), + }; + } } @xmlParser('editionStmt', EditionStmtParser) export class EditionStmtParser extends GenericParser implements Parser { - parse(xml: XMLElement): EditionStmt { - return { - ...super.parse(xml), - type: EditionStmt, - edition: queryAndParseElements(xml, 'edition'), - respStmt: queryAndParseElements(xml, 'respStmt'), - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - }; - } + parse(xml: XMLElement): EditionStmt { + return { + ...super.parse(xml), + type: EditionStmt, + edition: queryAndParseElements(xml, 'edition'), + respStmt: queryAndParseElements(xml, 'respStmt'), + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + }; + } } @xmlParser('publicationStmt', PublicationStmtParser) export class PublicationStmtParser extends GenericParser implements Parser { - parse(xml: XMLElement): PublicationStmt { - return { - ...super.parse(xml), - type: PublicationStmt, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - publisher: queryAndParseElements(xml, 'publisher'), - distributor: queryAndParseElements(xml, 'distributor'), - authority: queryAndParseElements(xml, 'authority'), - pubPlace: queryAndParseElements(xml, 'pubPlace'), - address: queryAndParseElements(xml, 'address'), - idno: queryAndParseElements(xml, 'idno'), - availability: queryAndParseElements(xml, 'availability'), - date: queryAndParseElements(xml, 'date'), - licence: queryAndParseElements(xml, 'licence'), - }; - } + parse(xml: XMLElement): PublicationStmt { + return { + ...super.parse(xml), + type: PublicationStmt, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + publisher: queryAndParseElements(xml, 'publisher'), + distributor: queryAndParseElements(xml, 'distributor'), + authority: queryAndParseElements(xml, 'authority'), + pubPlace: queryAndParseElements(xml, 'pubPlace'), + address: queryAndParseElements(xml, 'address'), + idno: queryAndParseElements(xml, 'idno'), + availability: queryAndParseElements(xml, 'availability'), + date: queryAndParseElements(xml, 'date'), + licence: queryAndParseElements(xml, 'licence'), + }; + } } @xmlParser('seriesStmt', SeriesStmtParser) export class SeriesStmtParser extends GenericParser implements Parser { - parse(xml: XMLElement): SeriesStmt { - return { - ...super.parse(xml), - type: SeriesStmt, - structuredData: Array.from(xml.querySelectorAll(':scope > p')).length === 0, - title: queryAndParseElements(xml, 'title'), - idno: queryAndParseElements(xml, 'idno'), - respStmt: queryAndParseElements(xml, 'respStmt'), - editor: queryAndParseElements(xml, 'editor'), - biblScope: queryAndParseElements(xml, 'biblScope'), - }; - } + parse(xml: XMLElement): SeriesStmt { + return { + ...super.parse(xml), + type: SeriesStmt, + structuredData: Array.from(xml.querySelectorAll(':scope > p')).length === 0, + title: queryAndParseElements(xml, 'title'), + idno: queryAndParseElements(xml, 'idno'), + respStmt: queryAndParseElements(xml, 'respStmt'), + editor: queryAndParseElements(xml, 'editor'), + biblScope: queryAndParseElements(xml, 'biblScope'), + }; + } } @xmlParser('notesStmt', NotesStmtParser) export class NotesStmtParser extends GenericParser implements Parser { - parse(xml: XMLElement): NotesStmt { - return { - ...super.parse(xml), - type: NotesStmt, - notes: queryAndParseElements(xml, 'note').map((el) => ({ - ...el, - noteLayout: 'plain-text', - })), - relatedItems: queryAndParseElements(xml, 'relatedItem'), - }; - } + parse(xml: XMLElement): NotesStmt { + return { + ...super.parse(xml), + type: NotesStmt, + notes: queryAndParseElements(xml, 'note').map((el) => ({ + ...el, + noteLayout: 'plain-text', + })), + relatedItems: queryAndParseElements(xml, 'relatedItem'), + }; + } } @xmlParser('sourceDesc', SourceDescParser) export class SourceDescParser extends GenericParser implements Parser { - parse(xml: XMLElement): SourceDesc { - return { - ...super.parse(xml), - type: SourceDesc, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - msDescs: queryAndParseElements(xml, 'msDesc'), - bibl: queryAndParseElements(xml, 'bibl'), - biblFull: queryAndParseElements(xml, 'biblFull'), - biblStruct: queryAndParseElements(xml, 'biblStruct'), - recordingStmt: queryAndParseElements(xml, 'recordingStmt'), - scriptStmt: queryAndParseElements(xml, 'scriptStmt'), - }; - } + parse(xml: XMLElement): SourceDesc { + return { + ...super.parse(xml), + type: SourceDesc, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + msDescs: queryAndParseElements(xml, 'msDesc'), + bibl: queryAndParseElements(xml, 'bibl'), + biblFull: queryAndParseElements(xml, 'biblFull'), + biblStruct: queryAndParseElements(xml, 'biblStruct'), + recordingStmt: queryAndParseElements(xml, 'recordingStmt'), + scriptStmt: queryAndParseElements(xml, 'scriptStmt'), + }; + } } @xmlParser('extent', ExtentParser) export class ExtentParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Extent { - return { - ...super.parse(xml), - type: Extent, - }; - } + parse(xml: XMLElement): Extent { + return { + ...super.parse(xml), + type: Extent, + }; + } } @xmlParser('fileDesc', FileDescParser) export class FileDescParser extends GenericElemParser implements Parser { - private excludeFromParsing = [ - 'listBibl', - 'listEvent', - 'listOrg', - 'listPerson', - 'listPlace', - 'listWit', - 'sourceDesc list', - ]; - - parse(xml: XMLElement): FileDesc { - xml = xml.cloneNode(true) as XMLElement; - Array.from(xml.querySelectorAll(this.excludeFromParsing.toString())) - .filter((list) => !isNestedInElem(list, list.tagName)) - .forEach((el) => el.remove()); - - return { - ...super.parse(xml), - type: FileDesc, - titleStmt: queryAndParseElement(xml, 'titleStmt'), - editionStmt: queryAndParseElement(xml, 'editionStmt'), - publicationStmt: queryAndParseElement(xml, 'publicationStmt'), - sourceDesc: queryAndParseElement(xml, 'sourceDesc'), - extent: queryAndParseElement(xml, 'extent'), - notesStmt: queryAndParseElement(xml, 'notesStmt'), - seriesStmt: queryAndParseElement(xml, 'seriesStmt'), - }; - } + private excludeFromParsing = [ + 'listBibl', + 'listEvent', + 'listOrg', + 'listPerson', + 'listPlace', + 'listWit', + 'listObject', + 'sourceDesc list', + ]; + + parse(xml: XMLElement): FileDesc { + xml = xml.cloneNode(true) as XMLElement; + Array.from(xml.querySelectorAll(this.excludeFromParsing.toString())) + .filter((list) => !isNestedInElem(list, list.tagName)) + .forEach((el) => el.remove()); + + return { + ...super.parse(xml), + type: FileDesc, + titleStmt: queryAndParseElement(xml, 'titleStmt'), + editionStmt: queryAndParseElement(xml, 'editionStmt'), + publicationStmt: queryAndParseElement(xml, 'publicationStmt'), + sourceDesc: queryAndParseElement(xml, 'sourceDesc'), + extent: queryAndParseElement(xml, 'extent'), + notesStmt: queryAndParseElement(xml, 'notesStmt'), + seriesStmt: queryAndParseElement(xml, 'seriesStmt'), + }; + } } @xmlParser('projectDesc', ProjectDescParser) export class ProjectDescParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): ProjectDesc { - return { - ...super.parse(xml), - type: ProjectDesc, - content: queryAndParseElements(xml, 'p'), - }; - } + parse(xml: XMLElement): ProjectDesc { + return { + ...super.parse(xml), + type: ProjectDesc, + content: queryAndParseElements(xml, 'p'), + }; + } } @xmlParser('samplingDecl', SamplingDeclParser) export class SamplingDeclParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): SamplingDecl { - return { - ...super.parse(xml), - type: SamplingDecl, - content: queryAndParseElements(xml, 'p'), - }; - } + parse(xml: XMLElement): SamplingDecl { + return { + ...super.parse(xml), + type: SamplingDecl, + content: queryAndParseElements(xml, 'p'), + }; + } } @xmlParser('correction', CorrectionParser) export class CorrectionParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Correction { - return { - ...super.parse(xml), - type: Correction, - content: queryAndParseElements(xml, 'p'), - status: xml.getAttribute('status') as CorrectionStatus, - method: xml.getAttribute('method') as CorrectionMethod || 'silent', - }; - } + parse(xml: XMLElement): Correction { + return { + ...super.parse(xml), + type: Correction, + content: queryAndParseElements(xml, 'p'), + status: xml.getAttribute('status') as CorrectionStatus, + method: xml.getAttribute('method') as CorrectionMethod || 'silent', + }; + } } @xmlParser('normalization', NormalizationParser) export class NormalizationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Normalization { - return { - ...super.parse(xml), - type: Normalization, - content: queryAndParseElements(xml, 'p'), - sources: xml.getAttribute('source')?.split(' ') || [], - method: xml.getAttribute('method') as NormalizationMethod || 'silent', - }; - } + parse(xml: XMLElement): Normalization { + return { + ...super.parse(xml), + type: Normalization, + content: queryAndParseElements(xml, 'p'), + sources: xml.getAttribute('source')?.split(' ') || [], + method: xml.getAttribute('method') as NormalizationMethod || 'silent', + }; + } } @xmlParser('punctuation', PunctuationParser) export class PunctuationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Punctuation { - return { - ...super.parse(xml), - type: Punctuation, - content: queryAndParseElements(xml, 'p'), - marks: xml.getAttribute('marks') as PunctuationMarks, - placement: xml.getAttribute('placement') as PunctuationPlacement, - }; - } + parse(xml: XMLElement): Punctuation { + return { + ...super.parse(xml), + type: Punctuation, + content: queryAndParseElements(xml, 'p'), + marks: xml.getAttribute('marks') as PunctuationMarks, + placement: xml.getAttribute('placement') as PunctuationPlacement, + }; + } } @xmlParser('quotation', QuotationParser) export class QuotationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Quotation { - return { - ...super.parse(xml), - type: Quotation, - content: queryAndParseElements(xml, 'p'), - marks: xml.getAttribute('marks') as QuotationMarks, - }; - } + parse(xml: XMLElement): Quotation { + return { + ...super.parse(xml), + type: Quotation, + content: queryAndParseElements(xml, 'p'), + marks: xml.getAttribute('marks') as QuotationMarks, + }; + } } @xmlParser('hyphenation', HyphenationParser) export class HyphenationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Hyphenation { - return { - ...super.parse(xml), - type: Hyphenation, - content: queryAndParseElements(xml, 'p'), - eol: xml.getAttribute('eol') as HyphenationEol, - }; - } + parse(xml: XMLElement): Hyphenation { + return { + ...super.parse(xml), + type: Hyphenation, + content: queryAndParseElements(xml, 'p'), + eol: xml.getAttribute('eol') as HyphenationEol, + }; + } } @xmlParser('segmentation', SegmentationParser) export class SegmentationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Segmentation { - return { - ...super.parse(xml), - type: Segmentation, - content: queryAndParseElements(xml, 'p'), - }; - } + parse(xml: XMLElement): Segmentation { + return { + ...super.parse(xml), + type: Segmentation, + content: queryAndParseElements(xml, 'p'), + }; + } } @xmlParser('stdVals', StdValsParser) export class StdValsParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): StdVals { - return { - ...super.parse(xml), - type: StdVals, - content: queryAndParseElements(xml, 'p'), - }; - } + parse(xml: XMLElement): StdVals { + return { + ...super.parse(xml), + type: StdVals, + content: queryAndParseElements(xml, 'p'), + }; + } } @xmlParser('interpretation', InterpretationParser) export class InterpretationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Interpretation { - return { - ...super.parse(xml), - type: Interpretation, - content: queryAndParseElements(xml, 'p'), - }; - } + parse(xml: XMLElement): Interpretation { + return { + ...super.parse(xml), + type: Interpretation, + content: queryAndParseElements(xml, 'p'), + }; + } } @xmlParser('editorialDecl', EditorialDeclParser) export class EditorialDeclParser extends GenericParser implements Parser { - parse(xml: XMLElement): EditorialDecl { - return { - ...super.parse(xml), - type: EditorialDecl, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - correction: queryAndParseElements(xml, 'correction'), - hyphenation: queryAndParseElements(xml, 'hyphenation'), - interpretation: queryAndParseElements(xml, 'interpretation'), - normalization: queryAndParseElements(xml, 'normalization'), - punctuation: queryAndParseElements(xml, 'punctuation'), - quotation: queryAndParseElements(xml, 'quotation'), - segmentation: queryAndParseElements(xml, 'segmentation'), - stdVals: queryAndParseElements(xml, 'stdVals'), - }; - } + parse(xml: XMLElement): EditorialDecl { + return { + ...super.parse(xml), + type: EditorialDecl, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + correction: queryAndParseElements(xml, 'correction'), + hyphenation: queryAndParseElements(xml, 'hyphenation'), + interpretation: queryAndParseElements(xml, 'interpretation'), + normalization: queryAndParseElements(xml, 'normalization'), + punctuation: queryAndParseElements(xml, 'punctuation'), + quotation: queryAndParseElements(xml, 'quotation'), + segmentation: queryAndParseElements(xml, 'segmentation'), + stdVals: queryAndParseElements(xml, 'stdVals'), + }; + } } @xmlParser('rendition', RenditionParser) export class RenditionParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Rendition { - return { - ...super.parse(xml), - type: Rendition, - id: getID(xml), - scope: xml.getAttribute('scope') as RenditionScope || '', - selector: xml.getAttribute('selector') || '', - scheme: xml.getAttribute('scheme') as Scheme || undefined, - schemeVersion: xml.getAttribute('schemeVersion') || '', - }; - } + parse(xml: XMLElement): Rendition { + return { + ...super.parse(xml), + type: Rendition, + id: getID(xml), + scope: xml.getAttribute('scope') as RenditionScope || '', + selector: xml.getAttribute('selector') || '', + scheme: xml.getAttribute('scheme') as Scheme || undefined, + schemeVersion: xml.getAttribute('schemeVersion') || '', + }; + } } @xmlParser('tagUsage', TagUsageParser) export class TagUsageParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): TagUsage { - return { - ...super.parse(xml), - type: TagUsage, - gi: xml.getAttribute('gi'), - occurs: parseInt(xml.getAttribute('occurs'), 10) || undefined, - withId: parseInt(xml.getAttribute('withId'), 10) || undefined, - }; - } + parse(xml: XMLElement): TagUsage { + return { + ...super.parse(xml), + type: TagUsage, + gi: xml.getAttribute('gi'), + occurs: parseInt(xml.getAttribute('occurs'), 10) || undefined, + withId: parseInt(xml.getAttribute('withId'), 10) || undefined, + }; + } } @xmlParser('namespace', NamespaceParser) export class NamespaceParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Namespace { - return { - ...super.parse(xml), - type: Namespace, - name: xml.getAttribute('name') || '', - tagUsage: queryAndParseElements(xml, 'tagUsage'), - }; - } + parse(xml: XMLElement): Namespace { + return { + ...super.parse(xml), + type: Namespace, + name: xml.getAttribute('name') || '', + tagUsage: queryAndParseElements(xml, 'tagUsage'), + }; + } } @xmlParser('tagsDecl', TagsDeclParser) export class TagsDeclParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): TagsDecl { - return { - ...super.parse(xml), - type: TagsDecl, - rendition: queryAndParseElements(xml, 'rendition'), - namespace: queryAndParseElements(xml, 'namespace'), - }; - } + parse(xml: XMLElement): TagsDecl { + return { + ...super.parse(xml), + type: TagsDecl, + rendition: queryAndParseElements(xml, 'rendition'), + namespace: queryAndParseElements(xml, 'namespace'), + }; + } } @xmlParser('styleDefDecl', StyleDefDeclParser) export class StyleDefDeclParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): StyleDefDecl { - return { - ...super.parse(xml), - type: TagsDecl, - scheme: xml.getAttribute('scheme'), - schemeVersion: xml.getAttribute('schemeVersion'), - }; - } + parse(xml: XMLElement): StyleDefDecl { + return { + ...super.parse(xml), + type: TagsDecl, + scheme: xml.getAttribute('scheme'), + schemeVersion: xml.getAttribute('schemeVersion'), + }; + } } @xmlParser('cRefPattern', CRefPatternParser) export class CRefPatternParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): CRefPattern { - return { - ...super.parse(xml), - type: CRefPattern, - matchPattern: xml.getAttribute('matchPattern'), - replacementPattern: xml.getAttribute('replacementPattern'), - }; - } + parse(xml: XMLElement): CRefPattern { + return { + ...super.parse(xml), + type: CRefPattern, + matchPattern: xml.getAttribute('matchPattern'), + replacementPattern: xml.getAttribute('replacementPattern'), + }; + } } @xmlParser('refState', RefStateParser) export class RefStateParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): RefState { - return { - ...super.parse(xml), - type: RefState, - ed: xml.getAttribute('ed'), - unit: xml.getAttribute('unit'), - length: parseInt(xml.getAttribute('length'), 10) || 0, - delim: xml.getAttribute('delim'), - }; - } + parse(xml: XMLElement): RefState { + return { + ...super.parse(xml), + type: RefState, + ed: xml.getAttribute('ed'), + unit: xml.getAttribute('unit'), + length: parseInt(xml.getAttribute('length'), 10) || 0, + delim: xml.getAttribute('delim'), + }; + } } @xmlParser('refsDecl', RefsDeclParser) export class RefsDeclParser extends GenericElemParser implements Parser { - cRefPatternParser = createParser(CRefPatternParser, this.genericParse); - refStateParser = createParser(RefStateParser, this.genericParse); + cRefPatternParser = createParser(CRefPatternParser, this.genericParse); + refStateParser = createParser(RefStateParser, this.genericParse); - parse(xml: XMLElement): RefsDecl { - return { - ...super.parse(xml), - type: RefsDecl, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - cRefPattern: queryAndParseElements(xml, 'cRefPattern'), - refState: queryAndParseElements(xml, 'refState'), - }; - } + parse(xml: XMLElement): RefsDecl { + return { + ...super.parse(xml), + type: RefsDecl, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + cRefPattern: queryAndParseElements(xml, 'cRefPattern'), + refState: queryAndParseElements(xml, 'refState'), + }; + } } @xmlParser('encodingDesc', EncodingDescParser) export class EncodingDescParser extends GenericParser implements Parser { - parse(xml: XMLElement): EncodingDesc { - return { - ...super.parse(xml), - type: EncodingDesc, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - projectDesc: queryAndParseElements(xml, 'projectDesc'), - samplingDecl: queryAndParseElements(xml, 'samplingDecl'), - editorialDecl: queryAndParseElements(xml, 'editorialDecl'), - tagsDecl: queryAndParseElements(xml, 'tagsDecl'), - styleDefDecl: queryAndParseElement(xml, 'styleDefDecl'), - refsDecl: queryAndParseElements(xml, 'refsDecl'), - classDecl: queryAndParseElements(xml, 'classDecl'), - geoDecl: queryAndParseElements(xml, 'geoDecl'), - unitDecl: queryAndParseElements(xml, 'unitDecl'), - schemaSpec: queryAndParseElements(xml, 'schemaSpec'), - schemaRef: queryAndParseElements(xml, 'schemaRef'), - }; - } + parse(xml: XMLElement): EncodingDesc { + return { + ...super.parse(xml), + type: EncodingDesc, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + projectDesc: queryAndParseElements(xml, 'projectDesc'), + samplingDecl: queryAndParseElements(xml, 'samplingDecl'), + editorialDecl: queryAndParseElements(xml, 'editorialDecl'), + tagsDecl: queryAndParseElements(xml, 'tagsDecl'), + styleDefDecl: queryAndParseElement(xml, 'styleDefDecl'), + refsDecl: queryAndParseElements(xml, 'refsDecl'), + classDecl: queryAndParseElements(xml, 'classDecl'), + geoDecl: queryAndParseElements(xml, 'geoDecl'), + unitDecl: queryAndParseElements(xml, 'unitDecl'), + schemaSpec: queryAndParseElements(xml, 'schemaSpec'), + schemaRef: queryAndParseElements(xml, 'schemaRef'), + }; + } } @xmlParser('abstract', AbstractParser) export class AbstractParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Abstract { - return { - ...super.parse(xml), - type: Abstract, - resp: xml.getAttribute('resp'), - lang: xml.getAttribute('xml:lang'), - }; - } + parse(xml: XMLElement): Abstract { + return { + ...super.parse(xml), + type: Abstract, + resp: xml.getAttribute('resp'), + lang: xml.getAttribute('xml:lang'), + }; + } } @xmlParser('calendar', CalendarParser) export class CalendarParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Calendar { - return { - ...super.parse(xml), - type: Calendar, - id: xml.getAttribute('xml:id'), - target: xml.getAttribute('target'), - }; - } + parse(xml: XMLElement): Calendar { + return { + ...super.parse(xml), + type: Calendar, + id: xml.getAttribute('xml:id'), + target: xml.getAttribute('target'), + }; + } } @xmlParser('calendarDesc', CalendarDescParser) export class CalendarDescParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): CalendarDesc { - return { - ...super.parse(xml), - type: CalendarDesc, - calendars: queryAndParseElements(xml, 'calendar'), - }; - } + parse(xml: XMLElement): CalendarDesc { + return { + ...super.parse(xml), + type: CalendarDesc, + calendars: queryAndParseElements(xml, 'calendar'), + }; + } } @xmlParser('correspAction', CorrespActionParser) export class CorrespActionParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): CorrespAction { - return { - ...super.parse(xml), - type: CorrespAction, - actionType: xml.getAttribute('type') as CorrespActionType, - }; - } + parse(xml: XMLElement): CorrespAction { + return { + ...super.parse(xml), + type: CorrespAction, + actionType: xml.getAttribute('type') as CorrespActionType, + }; + } } @xmlParser('correspContext', CorrespContextParser) export class CorrespContextParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): CorrespContext { - return { - ...super.parse(xml), - type: CorrespContext, - }; - } + parse(xml: XMLElement): CorrespContext { + return { + ...super.parse(xml), + type: CorrespContext, + }; + } } @xmlParser('correspDesc', CorrespDescParser) export class CorrespDescParser extends GenericParser implements Parser { - parse(xml: XMLElement): CorrespDesc { - return { - ...super.parse(xml), - type: CorrespDesc, - content: queryAndParseElements(xml, 'correspAction, correspContext, note, p'), - }; - } + parse(xml: XMLElement): CorrespDesc { + return { + ...super.parse(xml), + type: CorrespDesc, + content: queryAndParseElements(xml, 'correspAction, correspContext, note, p'), + }; + } } @xmlParser('creation', CreationParser) export class CreationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Creation { - return { - ...super.parse(xml), - type: Creation, - }; - } + parse(xml: XMLElement): Creation { + return { + ...super.parse(xml), + type: Creation, + }; + } } @xmlParser('language', LanguageParser) export class LanguageParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Language { - return { - ...super.parse(xml), - type: Language, - ident: xml.getAttribute('ident'), - usage: parseInt(xml.getAttribute('usage'), 10) || undefined, - }; - } + parse(xml: XMLElement): Language { + return { + ...super.parse(xml), + type: Language, + ident: xml.getAttribute('ident'), + usage: parseInt(xml.getAttribute('usage'), 10) || undefined, + }; + } } @xmlParser('langUsage', LangUsageParser) export class LangUsageParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): LangUsage { - return { - ...super.parse(xml), - type: LangUsage, - structuredData: Array.from(xml.querySelectorAll(':scope > p')).length > 0, - languages: queryAndParseElements(xml, 'language'), - }; - } + parse(xml: XMLElement): LangUsage { + return { + ...super.parse(xml), + type: LangUsage, + structuredData: Array.from(xml.querySelectorAll(':scope > p')).length > 0, + languages: queryAndParseElements(xml, 'language'), + }; + } } @xmlParser('classCode', ClassCodeParser) export class ClassCodeParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): ClassCode { - return { - ...super.parse(xml), - type: ClassCode, - scheme: xml.getAttribute('scheme'), - }; - } + parse(xml: XMLElement): ClassCode { + return { + ...super.parse(xml), + type: ClassCode, + scheme: xml.getAttribute('scheme'), + }; + } } @xmlParser('catRef', CatRefParser) export class CatRefParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): CatRef { - return { - ...super.parse(xml), - type: CatRef, - scheme: xml.getAttribute('scheme'), - target: xml.getAttribute('target'), - }; - } + parse(xml: XMLElement): CatRef { + return { + ...super.parse(xml), + type: CatRef, + scheme: xml.getAttribute('scheme'), + target: xml.getAttribute('target'), + }; + } } @xmlParser('keywords', KeywordsParser) export class KeywordsParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Keywords { - return { - ...super.parse(xml), - type: Keywords, - scheme: xml.getAttribute('scheme'), - terms: queryAndParseElements(xml, 'term'), - }; - } + parse(xml: XMLElement): Keywords { + return { + ...super.parse(xml), + type: Keywords, + scheme: xml.getAttribute('scheme'), + terms: queryAndParseElements(xml, 'term'), + }; + } } @xmlParser('textClass', TextClassParser) export class TextClassParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): TextClass { - return { - ...super.parse(xml), - type: TextClass, - keywords: queryAndParseElements(xml, 'keywords'), - catRef: queryAndParseElements(xml, 'catRef'), - classCode: queryAndParseElements(xml, 'classCode'), - }; - } + parse(xml: XMLElement): TextClass { + return { + ...super.parse(xml), + type: TextClass, + keywords: queryAndParseElements(xml, 'keywords'), + catRef: queryAndParseElements(xml, 'catRef'), + classCode: queryAndParseElements(xml, 'classCode'), + }; + } } @xmlParser('handNote', HandNoteParser) export class HandNoteParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): HandNote { - return { - ...super.parse(xml), - type: HandNote, - id: getID(xml), - scribe: xml.getAttribute('scribe'), - scribeRef: xml.getAttribute('scribeRef'), - script: xml.getAttribute('script'), - scriptRef: xml.getAttribute('scriptRef'), - medium: xml.getAttribute('medium'), - scope: xml.getAttribute('scope') as HandNoteScope, - }; - } + parse(xml: XMLElement): HandNote { + return { + ...super.parse(xml), + type: HandNote, + id: getID(xml), + scribe: xml.getAttribute('scribe'), + scribeRef: xml.getAttribute('scribeRef'), + script: xml.getAttribute('script'), + scriptRef: xml.getAttribute('scriptRef'), + medium: xml.getAttribute('medium'), + scope: xml.getAttribute('scope') as HandNoteScope, + }; + } } @xmlParser('handNotes', HandNotesParser) export class HandNotesParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): HandNotes { - return { - ...super.parse(xml), - type: HandNotes, - content: queryAndParseElements(xml, 'keywords'), - }; - } + parse(xml: XMLElement): HandNotes { + return { + ...super.parse(xml), + type: HandNotes, + content: queryAndParseElements(xml, 'keywords'), + }; + } } @xmlParser('transpose', TransposeParser) export class TransposeParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Transpose { - return { - ...super.parse(xml), - type: Transpose, - content: queryAndParseElements(xml, 'ptr'), - }; - } + parse(xml: XMLElement): Transpose { + return { + ...super.parse(xml), + type: Transpose, + content: queryAndParseElements(xml, 'ptr'), + }; + } } @xmlParser('listTranspose', ListTransposeParser) export class ListTransposeParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): ListTranspose { - return { - ...super.parse(xml), - type: ListTranspose, - description: queryAndParseElements(xml, 'desc'), - transposes: queryAndParseElements(xml, 'transpose'), - }; - } + parse(xml: XMLElement): ListTranspose { + return { + ...super.parse(xml), + type: ListTranspose, + description: queryAndParseElements(xml, 'desc'), + transposes: queryAndParseElements(xml, 'transpose'), + }; + } } @xmlParser('channel', ChannelParser) export class ChannelParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Channel { - return { - ...super.parse(xml), - type: Channel, - mode: xml.getAttribute('mode') as ChannelMode, - }; - } + parse(xml: XMLElement): Channel { + return { + ...super.parse(xml), + type: Channel, + mode: xml.getAttribute('mode') as ChannelMode, + }; + } } @xmlParser('constitution', ConstitutionParser) export class ConstitutionParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Constitution { - return { - ...super.parse(xml), - type: Constitution, - constitutionType: xml.getAttribute('type'), - }; - } + parse(xml: XMLElement): Constitution { + return { + ...super.parse(xml), + type: Constitution, + constitutionType: xml.getAttribute('type'), + }; + } } @xmlParser('derivation', DerivationParser) export class DerivationParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Derivation { - return { - ...super.parse(xml), - type: Derivation, - derivationType: xml.getAttribute('type'), - }; - } + parse(xml: XMLElement): Derivation { + return { + ...super.parse(xml), + type: Derivation, + derivationType: xml.getAttribute('type'), + }; + } } @xmlParser('domain', DomainParser) export class DomainParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Domain { - return { - ...super.parse(xml), - type: Domain, - domainType: xml.getAttribute('type'), - }; - } + parse(xml: XMLElement): Domain { + return { + ...super.parse(xml), + type: Domain, + domainType: xml.getAttribute('type'), + }; + } } @xmlParser('factuality', FactualityParser) export class FactualityParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Factuality { - return { - ...super.parse(xml), - type: Factuality, - factualityType: xml.getAttribute('type'), - }; - } + parse(xml: XMLElement): Factuality { + return { + ...super.parse(xml), + type: Factuality, + factualityType: xml.getAttribute('type'), + }; + } } @xmlParser('interaction', InteractionParser) export class InteractionParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Interaction { - return { - ...super.parse(xml), - type: Interaction, - interactionType: xml.getAttribute('type'), - active: xml.getAttribute('type'), - passive: xml.getAttribute('type'), - }; - } + parse(xml: XMLElement): Interaction { + return { + ...super.parse(xml), + type: Interaction, + interactionType: xml.getAttribute('type'), + active: xml.getAttribute('type'), + passive: xml.getAttribute('type'), + }; + } } @xmlParser('preparedness', PreparednessParser) export class PreparednessParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Preparedness { - return { - ...super.parse(xml), - type: Preparedness, - preparednessType: xml.getAttribute('type'), - }; - } + parse(xml: XMLElement): Preparedness { + return { + ...super.parse(xml), + type: Preparedness, + preparednessType: xml.getAttribute('type'), + }; + } } @xmlParser('purpose', PurposeParser) export class PurposeParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Purpose { - return { - ...super.parse(xml), - type: Purpose, - purposeType: xml.getAttribute('type'), - degree: xml.getAttribute('degree') as Degree, - }; - } + parse(xml: XMLElement): Purpose { + return { + ...super.parse(xml), + type: Purpose, + purposeType: xml.getAttribute('type'), + degree: xml.getAttribute('degree') as Degree, + }; + } } @xmlParser('change', ChangeParser) export class ChangeParser extends GenericParser implements Parser { - parse(xml: XMLElement): Change { - return { - ...super.parse(xml), - type: Change, - id: getID(xml), - who: getDefaultAttr(xml.getAttribute('who')).replace('#', ''), - status: xml.getAttribute('status') as Status, - when: xml.getAttribute('when'), - notBefore: xml.getAttribute('notBefore'), - notAfter: xml.getAttribute('notAfter'), - targets: getDefaultAttr(xml.getAttribute('target')).split(' ').map((t) => t.replace('#', '')), - }; - } + parse(xml: XMLElement): Change { + return { + ...super.parse(xml), + type: Change, + id: getID(xml), + who: getDefaultAttr(xml.getAttribute('who')).replace('#', ''), + status: xml.getAttribute('status') as Status, + when: xml.getAttribute('when'), + notBefore: xml.getAttribute('notBefore'), + notAfter: xml.getAttribute('notAfter'), + targets: getDefaultAttr(xml.getAttribute('target')).split(' ').map((t) => t.replace('#', '')), + }; + } } @xmlParser('textDesc', TextDescParser) export class TextDescParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): TextDesc { - return { - ...super.parse(xml), - type: TextDesc, - channel: queryAndParseElements(xml, 'channel'), - constitution: queryAndParseElements(xml, 'constitution'), - derivation: queryAndParseElements(xml, 'derivation'), - domain: queryAndParseElements(xml, 'domain'), - factuality: queryAndParseElements(xml, 'factuality'), - interaction: queryAndParseElements(xml, 'interaction'), - preparedness: queryAndParseElements(xml, 'preparedness'), - purpose: queryAndParseElements(xml, 'purpose'), - }; - } + parse(xml: XMLElement): TextDesc { + return { + ...super.parse(xml), + type: TextDesc, + channel: queryAndParseElements(xml, 'channel'), + constitution: queryAndParseElements(xml, 'constitution'), + derivation: queryAndParseElements(xml, 'derivation'), + domain: queryAndParseElements(xml, 'domain'), + factuality: queryAndParseElements(xml, 'factuality'), + interaction: queryAndParseElements(xml, 'interaction'), + preparedness: queryAndParseElements(xml, 'preparedness'), + purpose: queryAndParseElements(xml, 'purpose'), + }; + } } @xmlParser('particDesc', ParticDescParser) export class ParticDescParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): ParticDesc { - return { - ...super.parse(xml), - type: ParticDesc, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - participants: queryAndParseElements(xml, 'listPerson').concat(queryAndParseElements(xml, 'listOrg')), - }; - } + parse(xml: XMLElement): ParticDesc { + return { + ...super.parse(xml), + type: ParticDesc, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + participants: queryAndParseElements(xml, 'listPerson').concat(queryAndParseElements(xml, 'listOrg')), + }; + } } @xmlParser('setting', SettingParser) export class SettingParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): Setting { - const names = queryAndParseElements(xml, 'name'); - const orgNames = queryAndParseElements(xml, 'orgName'); - const persNames = queryAndParseElements(xml, 'persName'); - const placeNames = queryAndParseElements(xml, 'placeName'); - - return { - ...super.parse(xml), - type: Setting, - who: xml.getAttribute('who'), - name: names.concat(orgNames).concat(persNames).concat(placeNames), - date: queryAndParseElements(xml, 'date'), - time: queryAndParseElements(xml, 'time'), - locale: queryAndParseElements(xml, 'locale'), - activity: queryAndParseElements(xml, 'activity'), - }; - } + parse(xml: XMLElement): Setting { + const names = queryAndParseElements(xml, 'name'); + const orgNames = queryAndParseElements(xml, 'orgName'); + const persNames = queryAndParseElements(xml, 'persName'); + const placeNames = queryAndParseElements(xml, 'placeName'); + const objectNames = queryAndParseElements(xml, 'objectName'); + + return { + ...super.parse(xml), + type: Setting, + who: xml.getAttribute('who'), + name: names.concat(orgNames).concat(persNames).concat(placeNames).concat(objectNames), + date: queryAndParseElements(xml, 'date'), + time: queryAndParseElements(xml, 'time'), + locale: queryAndParseElements(xml, 'locale'), + activity: queryAndParseElements(xml, 'activity'), + }; + } } @xmlParser('settingDesc', SettingDescParser) export class SettingDescParser extends GenericElemParser implements Parser { - parse(xml: XMLElement): SettingDesc { - return { - ...super.parse(xml), - type: SettingDesc, - structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, - settings: queryAndParseElements(xml, 'setting'), - places: queryAndParseElements(xml, 'listPlace'), - }; - } + parse(xml: XMLElement): SettingDesc { + return { + ...super.parse(xml), + type: SettingDesc, + structuredData: Array.from(xml.children).filter((el) => el.tagName === 'p').length !== xml.children.length, + settings: queryAndParseElements(xml, 'setting'), + places: queryAndParseElements(xml, 'listPlace'), + }; + } } @xmlParser('listChange', ListChangeParser) export class ListChangeParser extends GenericParser implements Parser { - parse(xml: XMLElement): ListChange { - return { - ...super.parse(xml), - type: ListChange, - content: complexElements(xml.childNodes, true).filter((child: XMLElement) => child.tagName !== 'desc') - .map((child) => parseElement(child as XMLElement)), - description: queryAndParseElement(xml, 'desc'), - id: getID(xml), - ordered: isBoolString(xml.getAttribute('ordered')), - }; - } + parse(xml: XMLElement): ListChange { + return { + ...super.parse(xml), + type: ListChange, + content: complexElements(xml.childNodes, true).filter((child: XMLElement) => child.tagName !== 'desc') + .map((child) => parseElement(child as XMLElement)), + description: queryAndParseElement(xml, 'desc'), + id: getID(xml), + ordered: isBoolString(xml.getAttribute('ordered')), + }; + } } @xmlParser('profileDesc', ProfileDescParser) export class ProfileDescParser extends GenericParser implements Parser { - parse(xml: XMLElement): ProfileDesc { - return { - ...super.parse(xml), - type: ProfileDesc, - abstract: queryAndParseElements(xml, 'abstract'), - calendarDesc: queryAndParseElements(xml, 'calendarDesc'), - correspDesc: queryAndParseElements(xml, 'correspDesc'), - creation: queryAndParseElements(xml, 'creation'), - handNotes: queryAndParseElements(xml, 'handNotes'), - langUsage: queryAndParseElements(xml, 'langUsage'), - listTranspose: queryAndParseElements(xml, 'listTranspose'), - particDesc: queryAndParseElements(xml, 'particDesc'), - settingDesc: queryAndParseElements(xml, 'settingDesc'), - textClass: queryAndParseElements(xml, 'textClass'), - textDesc: queryAndParseElements(xml, 'textDesc'), - }; - } + parse(xml: XMLElement): ProfileDesc { + return { + ...super.parse(xml), + type: ProfileDesc, + abstract: queryAndParseElements(xml, 'abstract'), + calendarDesc: queryAndParseElements(xml, 'calendarDesc'), + correspDesc: queryAndParseElements(xml, 'correspDesc'), + creation: queryAndParseElements(xml, 'creation'), + handNotes: queryAndParseElements(xml, 'handNotes'), + langUsage: queryAndParseElements(xml, 'langUsage'), + listTranspose: queryAndParseElements(xml, 'listTranspose'), + particDesc: queryAndParseElements(xml, 'particDesc'), + settingDesc: queryAndParseElements(xml, 'settingDesc'), + textClass: queryAndParseElements(xml, 'textClass'), + textDesc: queryAndParseElements(xml, 'textDesc'), + }; + } } @xmlParser('revisionDesc', RevisionDescParser) export class RevisionDescParser extends GenericParser implements Parser { - parse(xml: XMLElement): RevisionDesc { - return { - ...super.parse(xml), - type: RevisionDesc, - content: complexElements(xml.childNodes, true).map((child) => parseElement(child as XMLElement)), - status: xml.getAttribute('status') as Status, - }; - } + parse(xml: XMLElement): RevisionDesc { + return { + ...super.parse(xml), + type: RevisionDesc, + content: complexElements(xml.childNodes, true).map((child) => parseElement(child as XMLElement)), + status: xml.getAttribute('status') as Status, + }; + } } diff --git a/src/app/services/xml-parsers/index.ts b/src/app/services/xml-parsers/index.ts index 4bd2d22ea..bd5b87ec2 100644 --- a/src/app/services/xml-parsers/index.ts +++ b/src/app/services/xml-parsers/index.ts @@ -19,11 +19,11 @@ export class ParserRegister { } private static mapName(tagName) { - const nes = ['event', 'geogname', 'orgname', 'persname', 'placename']; + const nes = ['event', 'geogname', 'orgname', 'persname', 'placename', 'objectname' ]; if (nes.includes(tagName)) { return 'evt-named-entity-parser'; } - const nels = ['listPerson', 'listPlace', 'listOrg', 'listEvent']; + const nels = ['listPerson', 'listPlace', 'listOrg', 'listEvent', 'listObject']; if (nels.includes(tagName)) { return 'evt-named-entities-list-parser'; } diff --git a/src/app/services/xml-parsers/named-entity-parsers.ts b/src/app/services/xml-parsers/named-entity-parsers.ts index b72239562..9d33194a2 100644 --- a/src/app/services/xml-parsers/named-entity-parsers.ts +++ b/src/app/services/xml-parsers/named-entity-parsers.ts @@ -14,7 +14,8 @@ export const namedEntitiesListsTagNamesMap: { [key: string]: string } = { places: 'listPlace', organizations: 'listOrg', events: 'listEvent', - occurrences: 'persName[ref], placeName[ref], orgName[ref], geogName[ref], event[ref]', + objects: 'listObject', + occurrences: 'persName[ref], placeName[ref], orgName[ref], geogName[ref], event[ref], objectName[ref]', }; export function getListType(tagName): NamedEntityType { @@ -101,6 +102,7 @@ export class NamedEntityRefParser extends EmptyParser implements Parser { attributeParsers = createParser(AttributeParser, this.genericParse); parse(xml: XMLElement): NamedEntityInfo { diff --git a/src/app/services/xml-parsers/xml-parsers.ts b/src/app/services/xml-parsers/xml-parsers.ts index 333529255..25c66282d 100644 --- a/src/app/services/xml-parsers/xml-parsers.ts +++ b/src/app/services/xml-parsers/xml-parsers.ts @@ -36,7 +36,7 @@ import { } from './msdesc-parser'; import { NamedEntitiesListParser, NamedEntityRefParser, OrganizationParser, - PersonGroupParser, PersonParser, PlaceParser, RelationParser, + PersonGroupParser, PersonParser, PlaceParser, RelationParser, ObjectParser, } from './named-entity-parsers'; import { QuoteParser } from './quotes-parser'; import { AnalogueParser } from './analogue-parser'; @@ -154,6 +154,7 @@ export function ParsersDecl(declarations: Array>) { NotesStmtParser, ObjectDescParser, OrganizationParser, + ObjectParser, OrigDateParser, OriginParser, OrigPlaceParser, diff --git a/src/assets/config/edition_config.json b/src/assets/config/edition_config.json index 7be4141d9..72271782d 100644 --- a/src/assets/config/edition_config.json +++ b/src/assets/config/edition_config.json @@ -49,6 +49,10 @@ "events": { "defaultLabel": "Events", "enable": true + }, + "objects": { + "defaultLabel": "Objects", + "enable": true } }, "showLists": true,