Skip to content

Instantly share code, notes, and snippets.

@dmj
Created March 3, 2022 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmj/be97a65c9f47250ba1c465e2affc4457 to your computer and use it in GitHub Desktop.
Save dmj/be97a65c9f47250ba1c465e2affc4457 to your computer and use it in GitHub Desktop.
<p:declare-step version="3.0"
xmlns:edm="http://www.europeana.eu/schemas/edm/"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<p:output port="result" sequence="true"/>
<p:load href="fix-metadata.html"/>
<p:for-each>
<p:with-input select="//html:tr[normalize-space(html:td[5])][normalize-space(html:td[6])]"/>
<p:variable as="xs:string" name="hansId" select="html:tr/html:td[5]"/>
<p:variable as="xs:string" name="type" select="html:tr/html:td[3]"/>
<p:variable as="xs:string" name="name" select="string(html:tr/html:td[4])"/>
<p:variable as="xs:string" name="uri" select="string(html:tr/html:td[6])"/>
<p:variable as="xs:string" name="metadataUri" select="resolve-uri('daten/brief/' || $hansId || '/metadata.rdf', static-base-uri())"/>
<p:load href="{$metadataUri}" content-type="application/rdf+xml"/>
<p:choose>
<p:when test="$type = 'Person'">
<p:variable name="match" as="xs:string" select="'foaf:Person[foaf:name = &quot;' || $name || '&quot;]'"/>
<p:delete match="{$match}/owl:sameAs"/>
<p:insert match="{$match}" position="first-child">
<p:with-input port="insertion">
<p:inline>
<owl:sameAs rdf:resource="{$uri}"/>
</p:inline>
</p:with-input>
</p:insert>
</p:when>
<p:when test="$type = 'Ort'">
<p:variable name="match" as="xs:string" select="'edm:Place[skos:prefLabel = &quot;' || $name || '&quot;]'"/>
<p:delete match="{$match}/owl:sameAs"/>
<p:insert match="{$match}" position="first-child">
<p:with-input port="insertion">
<p:inline>
<owl:sameAs rdf:resource="{$uri}"/>
</p:inline>
</p:with-input>
</p:insert>
</p:when>
</p:choose>
<p:store href="{$metadataUri}"/>
</p:for-each>
</p:declare-step>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment