Add required LoC resources to repository

This commit is contained in:
Arved Solth 2022-11-26 21:20:16 +01:00
parent 0c6e6f6e12
commit cc164ea846
6 changed files with 7540 additions and 31 deletions

View File

@ -69,27 +69,7 @@
</filesets>
</configuration>
</plugin>
<plugin>
<!--Download xsd for mets-->
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>mets</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://www.loc.gov/standards/mets/version111/mets.xsd</url>
<outputFileName>mets.xsd</outputFileName>
<outputDirectory>${project.build.directory}/downloaded-sources/xsd</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--copy kitodo xsd to target folder-->
<!--copy XML schema definitions to target folder-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- METS XLink Schema, v. 2, Nov. 15, 2004 -->
<schema targetNamespace="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" elementFormDefault="qualified">
<!-- global attributes -->
<attribute name="href" type="anyURI"/>
<attribute name="role" type="string"/>
<attribute name="arcrole" type="string"/>
<attribute name="title" type="string" />
<attribute name="show">
<simpleType>
<restriction base="string">
<enumeration value="new" />
<enumeration value="replace" />
<enumeration value="embed" />
<enumeration value="other" />
<enumeration value="none" />
</restriction>
</simpleType>
</attribute>
<attribute name="actuate">
<simpleType>
<restriction base="string">
<enumeration value="onLoad" />
<enumeration value="onRequest" />
<enumeration value="other" />
<enumeration value="none" />
</restriction>
</simpleType>
</attribute>
<attribute name="label" type="string" />
<attribute name="from" type="string" />
<attribute name="to" type="string" />
<attributeGroup name="simpleLink">
<attribute name="type" type="string" fixed="simple" form="qualified" />
<attribute ref="xlink:href" use="optional" />
<attribute ref="xlink:role" use="optional" />
<attribute ref="xlink:arcrole" use="optional" />
<attribute ref="xlink:title" use="optional" />
<attribute ref="xlink:show" use="optional" />
<attribute ref="xlink:actuate" use="optional" />
</attributeGroup>
<attributeGroup name="extendedLink">
<attribute name="type" type="string" fixed="extended" form="qualified" />
<attribute ref="xlink:role" use="optional" />
<attribute ref="xlink:title" use="optional" />
</attributeGroup>
<attributeGroup name="locatorLink">
<attribute name="type" type="string" fixed="locator" form="qualified" />
<attribute ref="xlink:href" use="required" />
<attribute ref="xlink:role" use="optional" />
<attribute ref="xlink:title" use="optional" />
<attribute ref="xlink:label" use="optional" />
</attributeGroup>
<attributeGroup name="arcLink">
<attribute name="type" type="string" fixed="arc" form="qualified" />
<attribute ref="xlink:arcrole" use="optional" />
<attribute ref="xlink:title" use="optional" />
<attribute ref="xlink:show" use="optional" />
<attribute ref="xlink:actuate" use="optional" />
<attribute ref="xlink:from" use="optional" />
<attribute ref="xlink:to" use="optional" />
</attributeGroup>
<attributeGroup name="resourceLink">
<attribute name="type" type="string" fixed="resource" form="qualified" />
<attribute ref="xlink:role" use="optional" />
<attribute ref="xlink:title" use="optional" />
<attribute ref="xlink:label" use="optional" />
</attributeGroup>
<attributeGroup name="titleLink">
<attribute name="type" type="string" fixed="title" form="qualified" />
</attributeGroup>
<attributeGroup name="emptyLink">
<attribute name="type" type="string" fixed="none" form="qualified" />
</attributeGroup>
</schema>

View File

@ -0,0 +1,188 @@
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- 08/08/08: tmee added corrected chopPunctuation templates for 260c -->
<!-- 08/19/04: ntra added "marc:" prefix to datafield element -->
<!-- 12/14/07: ntra added url encoding template -->
<!-- url encoding -->
<xsl:variable name="ascii">
<xsl:text> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text>
</xsl:variable>
<xsl:variable name="latin1">
<xsl:text> ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ</xsl:text>
</xsl:variable>
<!-- Characters that usually don't need to be escaped -->
<xsl:variable name="safe">
<xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text>
</xsl:variable>
<xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
<xsl:template name="datafield">
<xsl:param name="tag"/>
<xsl:param name="ind1">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:param name="ind2">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:param name="subfields"/>
<xsl:element name="marc:datafield">
<xsl:attribute name="tag">
<xsl:value-of select="$tag"/>
</xsl:attribute>
<xsl:attribute name="ind1">
<xsl:value-of select="$ind1"/>
</xsl:attribute>
<xsl:attribute name="ind2">
<xsl:value-of select="$ind2"/>
</xsl:attribute>
<xsl:copy-of select="$subfields"/>
</xsl:element>
</xsl:template>
<xsl:template name="subfieldSelect">
<xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
<xsl:param name="delimeter">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:variable name="str">
<xsl:for-each select="marc:subfield">
<xsl:if test="contains($codes, @code)">
<xsl:value-of select="text()"/>
<xsl:value-of select="$delimeter"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
</xsl:template>
<xsl:template name="buildSpaces">
<xsl:param name="spaces"/>
<xsl:param name="char">
<xsl:text> </xsl:text>
</xsl:param>
<xsl:if test="$spaces>0">
<xsl:value-of select="$char"/>
<xsl:call-template name="buildSpaces">
<xsl:with-param name="spaces" select="$spaces - 1"/>
<xsl:with-param name="char" select="$char"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="chopPunctuation">
<xsl:param name="chopString"/>
<xsl:param name="punctuation">
<xsl:text>.:,;/ </xsl:text>
</xsl:param>
<xsl:variable name="length" select="string-length($chopString)"/>
<xsl:choose>
<xsl:when test="$length=0"/>
<xsl:when test="contains($punctuation, substring($chopString,$length,1))">
<xsl:call-template name="chopPunctuation">
<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
<xsl:with-param name="punctuation" select="$punctuation"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not($chopString)"/>
<xsl:otherwise>
<xsl:value-of select="$chopString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="chopPunctuationFront">
<xsl:param name="chopString"/>
<xsl:variable name="length" select="string-length($chopString)"/>
<xsl:choose>
<xsl:when test="$length=0"/>
<xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
<xsl:call-template name="chopPunctuationFront">
<xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"
/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not($chopString)"/>
<xsl:otherwise>
<xsl:value-of select="$chopString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="chopPunctuationBack">
<xsl:param name="chopString"/>
<xsl:param name="punctuation">
<xsl:text>.:,;/] </xsl:text>
</xsl:param>
<xsl:variable name="length" select="string-length($chopString)"/>
<xsl:choose>
<xsl:when test="$length=0"/>
<xsl:when test="contains($punctuation, substring($chopString,$length,1))">
<xsl:call-template name="chopPunctuation">
<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
<xsl:with-param name="punctuation" select="$punctuation"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not($chopString)"/>
<xsl:otherwise>
<xsl:value-of select="$chopString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- nate added 12/14/2007 for lccn.loc.gov: url encode ampersand, etc. -->
<xsl:template name="url-encode">
<xsl:param name="str"/>
<xsl:if test="$str">
<xsl:variable name="first-char" select="substring($str,1,1)"/>
<xsl:choose>
<xsl:when test="contains($safe,$first-char)">
<xsl:value-of select="$first-char"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="codepoint">
<xsl:choose>
<xsl:when test="contains($ascii,$first-char)">
<xsl:value-of
select="string-length(substring-before($ascii,$first-char)) + 32"
/>
</xsl:when>
<xsl:when test="contains($latin1,$first-char)">
<xsl:value-of
select="string-length(substring-before($latin1,$first-char)) + 160"/>
<!-- was 160 -->
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="no">Warning: string contains a character
that is out of range! Substituting "?".</xsl:message>
<xsl:text>63</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="hex-digit1"
select="substring($hex,floor($codepoint div 16) + 1,1)"/>
<xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
<!-- <xsl:value-of select="concat('%',$hex-digit2)"/> -->
<xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="string-length($str) &gt; 1">
<xsl:call-template name="url-encode">
<xsl:with-param name="str" select="substring($str,2)"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
<metaInformation>
<scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
@ -32,7 +31,6 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.kitodo.api.schemaconverter.DataRecord;
@ -52,14 +50,6 @@ public class XmlSchemaConverterTest {
private static final String MODS_TEST_FILE_PATH = "src/test/resources/modsXmlTestRecord.xml";
private static final String MARC_TEST_FILE_PATH = "src/test/resources/marcXmlTestRecord.xml";
@AfterClass
public static void tearDown() {
File xslt = new File ("src/main/resources/xslt/marc21slim2mods.xsl");
if (xslt.exists()) {
xslt.delete();
}
}
@Test
public void shouldConvertModsToInternalFormat() throws IOException, ParserConfigurationException, SAXException,
URISyntaxException {