Skip to content

Commit

Permalink
Quick fix for pb fix on issue 228, improve syntax in an analogue pars…
Browse files Browse the repository at this point in the history
…er's utility function
  • Loading branch information
davivcu committed May 25, 2024
1 parent 93e91f4 commit 8f47327
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/app/services/xml-parsers/analogue-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ export class AnalogueParser extends BasicParser implements Parser<XMLElement> {
}

private getQuotedTextFromElements(sources: BibliographicEntry[], elements: XMLElement[]): [{id: string, quote: string}] {
// eslint-disable-next-line prefer-const
let quotesInSources = this.getQuotedTextFromSources(sources);
const notDisplayedInText = ['Note','BibliographicList','BibliographicEntry','BibliographicStructEntry','Analogue','MsDesc'];
elements.forEach((el: XMLElement) => { if (!notDisplayedInText.includes(el['type'])) { quotesInSources.push( { id: el.id, quote: el })} });
elements.forEach((el: XMLElement) => {
if (!notDisplayedInText.includes(el['type'])) {
quotesInSources.push( { id: el.id, quote: el })
}
});

return quotesInSources;
}
Expand Down
11 changes: 9 additions & 2 deletions src/app/services/xml-parsers/structure-xml-parser.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { AppConfig } from '../../app.config';
import { EditionStructure, GenericElement, OriginalEncodingNodeType, Page, XMLElement } from '../../models/evt-models';
import { createNsResolver, getElementsBetweenTreeNode, isNestedInElem } from '../../utils/dom-utils';
import { getElementsBetweenTreeNode, isNestedInElem } from '../../utils/dom-utils';
import { GenericParserService } from './generic-parser.service';
import { getID, ParseResult } from './parser-models';

Expand Down Expand Up @@ -99,7 +99,12 @@ export class StructureXmlParserService {
return pageContent
.map((node) => {

const origEl = getEditionOrigNode(node, doc);
//const origEl = getEditionOrigNode(node, doc);
// issue #228
// the original line is commented because this function causes the node to be revered at its original state
// before the pb division, see issue #228 details for further info.
// for now this quick fix allows a proper text division but we need to investigate exceptions and particular cases
const origEl = node;

if (origEl.nodeName === this.frontTagName || isNestedInElem(origEl, this.frontTagName)) {
if (this.hasOriginalContent(origEl)) {
Expand Down Expand Up @@ -135,6 +140,7 @@ export class StructureXmlParserService {
}
}

/* this function is only momentarily commented, waiting for issue #228 to be better addressed
function getEditionOrigNode(el: XMLElement, doc: Document) {
if (el.getAttribute && el.getAttribute('xpath')) {
const path = doc.documentElement.namespaceURI ? el.getAttribute('xpath').replace(/\//g, '/ns:') : el.getAttribute('xpath');
Expand All @@ -145,3 +151,4 @@ function getEditionOrigNode(el: XMLElement, doc: Document) {
return el;
}
*/

0 comments on commit 8f47327

Please sign in to comment.