]> Pierre Choffet | Git repositories - banq_wikidata.git/commitdiff
Add stylesheet to identify missing authorities
authorPierre Choffet <peuc@wanadoo.fr>
Tue, 8 Jul 2025 14:49:11 +0000 (10:49 -0400)
committerPierre Choffet <peuc@wanadoo.fr>
Tue, 8 Jul 2025 14:49:11 +0000 (10:49 -0400)
README
identify_missing_authorities.xslt [new file with mode: 0644]

diff --git a/README b/README
index 3c72c5c8ce00b400db1171900b39d801b01c9ef7..6a99073dc0d3aa48e7c0e8f042caaacce896e2e9 100644 (file)
--- a/README
+++ b/README
@@ -12,6 +12,10 @@ L’environnement d’utilisation nécessite la disponibilité des outils suivan
 
 
 Les outils disponibles sont les suivants :
+  - identify_missing_authorities.xslt
+    Liste les zones des notices bibliographiques faisant référence à des notices
+    d’autorité absentes du fichier MARCXML.
+  
   - merge_marcxml.xslt
     Fusionner deux fichiers au format MARCXML en supprimant les entrées
     présentes en plusieurs exemplaires.
diff --git a/identify_missing_authorities.xslt b/identify_missing_authorities.xslt
new file mode 100644 (file)
index 0000000..889b1da
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim"
+                xmlns:xml="http://www.w3.org/XML/1998/namespace"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <!-- identify_missing_authorities.xslt - Report broken foreign keys in MARCXML file
+    Copyright (C) 2025  Pierre Choffet
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of version 3 of the GNU General Public License as
+    published by the Free Software Foundation.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+    -->
+    
+       <xsl:output method="text" encoding="utf-8" />
+       
+       <xsl:template match="text()" />
+       
+       <xsl:key name="authority-person" match="/marc:collection/marc:record[substring(marc:leader, 7, 1) = 'z' and marc:datafield[@tag='100']]" use="concat(marc:datafield[@tag='100']/marc:subfield[@code='a'], marc:datafield[@tag='100']/marc:subfield[@code='b'], marc:datafield[@tag='100']/marc:subfield[@code='c'], marc:datafield[@tag='100']/marc:subfield[@code='d'], marc:datafield[@tag='100']/marc:subfield[@code='q'])" />
+       <xsl:key name="authority-corporate" match="/marc:collection/marc:record[substring(marc:leader, 7, 1) = 'z' and marc:datafield[@tag='110']]" use="concat(marc:datafield[@tag='110']/marc:subfield[@code='a'], marc:datafield[@tag='110']/marc:subfield[@code='b'], marc:datafield[@tag='110']/marc:subfield[@code='c'], marc:datafield[@tag='110']/marc:subfield[@code='d'])" />
+       <xsl:key name="authority-meeting" match="/marc:collection/marc:record[substring(marc:leader, 7, 1) = 'z' and marc:datafield[@tag='111']]" use="concat(marc:datafield[@tag='111']/marc:subfield[@code='a'], marc:datafield[@tag='111']/marc:subfield[@code='b'], marc:datafield[@tag='111']/marc:subfield[@code='n'], marc:datafield[@tag='111']/marc:subfield[@code='d'], marc:datafield[@tag='111']/marc:subfield[@code='c'])" />
+       
+       <xsl:template match="/marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='100'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='600'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='700'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='800']">
+               <xsl:variable name="person-fk">
+                       <xsl:value-of select="marc:subfield[@code='a']" />
+                       <xsl:value-of select="marc:subfield[@code='b']" />
+                       <xsl:value-of select="marc:subfield[@code='c']" />
+                       <xsl:value-of select="marc:subfield[@code='d']" />
+                       <xsl:value-of select="marc:subfield[@code='q']" />
+               </xsl:variable>
+               
+               <xsl:if test="not(key('authority-person', $person-fk))">
+                       <xsl:text>Notice bibliographique « </xsl:text>
+                       <xsl:value-of select="../marc:controlfield[@tag='001']" />
+                       <xsl:text> », zone </xsl:text>
+                       <xsl:value-of select="@tag" />
+                       <xsl:text>: notice d’autorité de personne « </xsl:text>
+                       <xsl:value-of select="$person-fk" />
+                       <xsl:text> » manquante.</xsl:text>
+                       <xsl:text>&#10;</xsl:text>
+               </xsl:if>
+       </xsl:template>
+       
+       <xsl:template match="/marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='110'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='610'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='710'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='810']">
+               <xsl:variable name="corporate-fk">
+                       <xsl:value-of select="marc:subfield[@code='a']" />
+                       <xsl:value-of select="marc:subfield[@code='b']" />
+                       <xsl:value-of select="marc:subfield[@code='c']" />
+                       <xsl:value-of select="marc:subfield[@code='d']" />
+               </xsl:variable>
+               
+               <xsl:if test="not(key('authority-corporate', $corporate-fk))">
+                       <xsl:text>Notice bibliographique « </xsl:text>
+                       <xsl:value-of select="../marc:controlfield[@tag='001']" />
+                       <xsl:text> », zone </xsl:text>
+                       <xsl:value-of select="@tag" />
+                       <xsl:text> : notice d’autorité de collectivité « </xsl:text>
+                       <xsl:value-of select="$corporate-fk" />
+                       <xsl:text> » manquante.</xsl:text>
+                       <xsl:text>&#10;</xsl:text>
+               </xsl:if>
+       </xsl:template>
+       
+       <xsl:template match="/marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='111'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='611'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='711'] |
+                            /marc:collection/marc:record[substring(marc:leader, 7, 1) = 'a']/marc:datafield[@tag='811']">
+               <xsl:variable name="meeting-fk">
+                       <xsl:value-of select="marc:subfield[@code='a']" />
+                       <xsl:value-of select="marc:subfield[@code='b']" />
+                       <xsl:value-of select="marc:subfield[@code='n']" />
+                       <xsl:value-of select="marc:subfield[@code='d']" />
+                       <xsl:value-of select="marc:subfield[@code='c']" />
+               </xsl:variable>
+               
+               <xsl:if test="not(key('authority-meeting', $meeting-fk))">
+                       <xsl:text>Notice bibliographique « </xsl:text>
+                       <xsl:value-of select="../marc:controlfield[@tag='001']" />
+                       <xsl:text> », zone </xsl:text>
+                       <xsl:value-of select="@tag" />
+                       <xsl:text> : notice d’autorité de réunion « </xsl:text>
+                       <xsl:value-of select="$meeting-fk" />
+                       <xsl:text> » manquante.</xsl:text>
+                       <xsl:text>&#10;</xsl:text>
+               </xsl:if>
+       </xsl:template>
+</xsl:stylesheet>