@@ -562,17 +562,26 @@ export function gg2rdf(
562
562
563
563
authority = normalizeAuthority ( authority ) ;
564
564
if ( baseAuthority ) {
565
+ // ensures the baseAuthority is not present twice
565
566
authority = authority . replaceAll (
566
567
new RegExp ( `\\(?${ baseAuthority } \\)?[,:;\\s]*` , "g" ) ,
567
568
"" ,
568
569
) ;
569
570
}
570
571
}
571
572
if ( baseAuthority && authority ) {
572
- s . addProperty (
573
- "dwc:scientificNameAuthorship" ,
574
- STR ( baseAuthority + " " + authority ) ,
575
- ) ;
573
+ // Animalia has baseAuthority only in this case, all other Kingdoms get both.
574
+ if ( getKingdom ( cTaxon ) === "Animalia" ) {
575
+ s . addProperty (
576
+ "dwc:scientificNameAuthorship" ,
577
+ STR ( baseAuthority ) ,
578
+ ) ;
579
+ } else {
580
+ s . addProperty (
581
+ "dwc:scientificNameAuthorship" ,
582
+ STR ( baseAuthority + " " + authority ) ,
583
+ ) ;
584
+ }
576
585
} else if ( baseAuthority ) {
577
586
s . addProperty (
578
587
"dwc:scientificNameAuthorship" ,
@@ -1241,13 +1250,19 @@ export function gg2rdf(
1241
1250
) ;
1242
1251
}
1243
1252
1253
+ /** Get kingdom of taxonName
1254
+ *
1255
+ * If `taxonName.getAttribute("kingdom")` is falsy (e.g. null or empty), returns "Animalia".
1256
+ */
1257
+ function getKingdom ( taxonName : Element ) {
1258
+ return taxonName . getAttribute ( "kingdom" ) || "Animalia" ;
1259
+ }
1260
+
1244
1261
/** returns plain uri
1245
1262
*
1246
1263
* replaces <xsl:call-template name="taxonConceptBaseURI"> */
1247
1264
function taxonConceptBaseURI ( { kingdom } : { kingdom : string } ) {
1248
- return `http://taxon-concept.plazi.org/id/${
1249
- kingdom ? partialURI ( kingdom ) : "Animalia"
1250
- } `;
1265
+ return `http://taxon-concept.plazi.org/id/${ kingdom } ` ;
1251
1266
}
1252
1267
1253
1268
/** returns valid turtle uri
@@ -1260,7 +1275,7 @@ export function gg2rdf(
1260
1275
} ,
1261
1276
) {
1262
1277
return URI (
1263
- taxonConceptBaseURI ( { kingdom : taxonName . getAttribute ( "kingdom" ) } ) +
1278
+ taxonConceptBaseURI ( { kingdom : getKingdom ( taxonName ) } ) +
1264
1279
taxonNameForURI ( taxonName ) + taxonAuthority ,
1265
1280
) ;
1266
1281
}
0 commit comments