]> Pierre Choffet | Git repositories - banq_wikidata.git/commitdiff
Add stylesheet to fix BAnQ MARCXML exports
authorPierre Choffet <peuc@wanadoo.fr>
Tue, 8 Jul 2025 15:25:12 +0000 (11:25 -0400)
committerPierre Choffet <peuc@wanadoo.fr>
Tue, 8 Jul 2025 15:34:17 +0000 (11:34 -0400)
README
fix_marcxml.xslt [new file with mode: 0644]

diff --git a/README b/README
index 6a99073dc0d3aa48e7c0e8f042caaacce896e2e9..5d3770da25d598b44f2deb0a0f6cb6337acb0867 100644 (file)
--- a/README
+++ b/README
@@ -15,6 +15,10 @@ 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.
+
+  - fix_marcxml.xslt
+    Corrige les erreurs connues des fichiers MARCXML exportés de la base de
+    données de BAnQ pour qu’ils soient valides au regard du schéma officiel.
   
   - merge_marcxml.xslt
     Fusionner deux fichiers au format MARCXML en supprimant les entrées
diff --git a/fix_marcxml.xslt b/fix_marcxml.xslt
new file mode 100644 (file)
index 0000000..c94c8df
--- /dev/null
@@ -0,0 +1,42 @@
+<?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">
+  <!-- fix_marcxml.xslt - Fix files from BAnQ so it becomes valid according to
+                          MARCXML conformance checker.
+    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 indent="yes" method="xml" encoding="utf-8" />
+       
+       <xsl:template match="node()|@*">
+               <xsl:copy>
+                       <xsl:apply-templates select="node()|@*" />
+               </xsl:copy>
+       </xsl:template>
+       
+       <xsl:template match="@ind1">
+               <xsl:choose>
+                       <xsl:when test=". = '@'">
+                               <xsl:attribute name="ind1">
+                                       <xsl:text> </xsl:text>
+                               </xsl:attribute>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:copy-of select="." />
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+</xsl:stylesheet>