Skip to content

Commit

Permalink
There may be more than one taxonomy in classDecl
Browse files Browse the repository at this point in the history
  • Loading branch information
simar0at committed Jan 14, 2025
1 parent f3692ba commit bae7858
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion composables/use-tei-headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
Person,
RespStmt,
simpleTEIMetadata,
Taxonomy,
TEI,
TeiCorpus,
TeiHeader,
Expand Down Expand Up @@ -140,7 +141,14 @@ const extractMetadata = function (
? item.teiHeader.profileDesc.textClass.catRef["@target"]
: "";

const category = corpusMetadata.encodingDesc.classDecl?.taxonomy.categories?.find(
const mergedTaxonomies: Taxonomy = {
categories: [],
};
corpusMetadata.encodingDesc.classDecl?.taxonomies.forEach((t) => {
mergedTaxonomies.categories = mergedTaxonomies.categories?.concat(t.categories!);
return mergedTaxonomies;
});
const category = mergedTaxonomies.categories?.find(
(cat) => cat["@id"] === categoryId?.replace("corpus:", ""),
);

Expand Down
2 changes: 1 addition & 1 deletion types/teiCorpus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export type Funder = {
};

export type ClassDecl = {
taxonomy: Taxonomy;
taxonomies: Array<Taxonomy>;
};

export type StandOff = {
Expand Down

0 comments on commit bae7858

Please sign in to comment.