Skip to content

Commit 6b3feb8

Browse files
committed
Standardize URI generation in 6XX fields.
Generate a URI for all 6XX fields except for 653. Resolves #61.
1 parent 1d12588 commit 6b3feb8

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

test/ConvSpec-648-662.xspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<x:scenario label="656 - INDEX TERM--OCCUPATION">
5252
<x:context href="data/ConvSpec-648-662/marc.xml"/>
5353
<x:expect label="656 creates a subject/Topic property of the work" test="count(//bf:Work[1]/bf:subject/bf:Topic) = 3"/>
54+
<x:expect label="...with a URI (not a blank node)" test="//bf:Work[1]/bf:subject[5]/bf:Topic/@rdf:about = 'http://example.org/1#Topic656-7'"/>
5455
<x:expect label="...with rdf:type of madsrdf:ComplexSubject" test="//bf:Work[1]/bf:subject[5]/bf:Topic/rdf:type/@rdf:resource = 'http://www.loc.gov/mads/rdf/v1#ComplexSubject'"/>
5556
<x:expect label="$akvxyz creates an rdfs:label property of the Topic" test="//bf:Work[1]/bf:subject[5]/bf:Topic/rdfs:label = 'Chauffeurs--France.'"/>
5657
<x:expect label="...and become components in the madsrdf:componentList of the Topic" test="//bf:Work[1]/bf:subject[5]/bf:Topic/madsrdf:componentList/madsrdf:Occupation/rdfs:label = 'Chauffeurs'"/>
@@ -60,6 +61,7 @@
6061
<x:scenario label="662 - SUBJECT ADDED ENTRY--HIERARCHICAL PLACE NAME">
6162
<x:context href="data/ConvSpec-648-662/marc.xml"/>
6263
<x:expect label="662 creates a subject/Place property of the work" test="count(//bf:Work[1]/bf:subject/bf:Place) = 2"/>
64+
<x:expect label="...with a URI (not a blank node)" test="//bf:Work[1]/bf:subject[6]/bf:Place/@rdf:about = 'http://example.org/1#Place662-8'"/>
6365
<x:expect label="...with rdf:type of madsrdf:HierarchicalGeographic" test="//bf:Work[1]/bf:subject[6]/bf:Place/rdf:type/@rdf:resource = 'http://www.loc.gov/mads/rdf/v1#HierarchicalGeographic'"/>
6466
<x:expect label="$abcdfgh creates an rdfs:label property of the Topic" test="//bf:Work[1]/bf:subject[6]/bf:Place/rdfs:label = 'Japan--Hokkaido--Asahi-dake.'"/>
6567
<x:expect label="...and become components in the madsrdf:componentList of the Topic" test="//bf:Work[1]/bf:subject[6]/bf:Place/madsrdf:componentList/*[3]/rdfs:label = 'Asahi-dake'"/>

xsl/ConvSpec-648-662.xsl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<xsl:when test="@tag='648'">
2323
<xsl:value-of select="$recordid"/>#Temporal<xsl:value-of select="@tag"/>-<xsl:value-of select="position()"/>
2424
</xsl:when>
25+
<xsl:when test="@tag='651'">
26+
<xsl:value-of select="$recordid"/>#Place<xsl:value-of select="@tag"/>-<xsl:value-of select="position()"/>
27+
</xsl:when>
2528
<xsl:when test="@tag='655'">
2629
<xsl:value-of select="$recordid"/>#GenreForm<xsl:value-of select="@tag"/>-<xsl:value-of select="position()"/>
2730
</xsl:when>
@@ -291,14 +294,20 @@
291294
</xsl:template>
292295

293296
<xsl:template match="marc:datafield[@tag='656']" mode="work">
297+
<xsl:param name="recordid"/>
294298
<xsl:param name="serialization" select="'rdfxml'"/>
299+
<xsl:variable name="vDefaultUri">
300+
<xsl:value-of select="$recordid"/>#Topic<xsl:value-of select="@tag"/>-<xsl:value-of select="position()"/>
301+
</xsl:variable>
295302
<xsl:apply-templates select="." mode="work656">
296303
<xsl:with-param name="serialization" select="$serialization"/>
304+
<xsl:with-param name="pDefaultUri" select="$vDefaultUri"/>
297305
</xsl:apply-templates>
298306
</xsl:template>
299307

300308
<xsl:template match="marc:datafield" mode="work656">
301309
<xsl:param name="serialization" select="'rdfxml'"/>
310+
<xsl:param name="pDefaultUri"/>
302311
<xsl:variable name="vTag">
303312
<xsl:choose>
304313
<xsl:when test="@tag='880'"><xsl:value-of select="substring(marc:subfield[@code='6'],1,3)"/></xsl:when>
@@ -317,7 +326,9 @@
317326
</xsl:call-template>
318327
</xsl:variable>
319328
<xsl:variable name="vTopicUri">
320-
<xsl:apply-templates mode="generateUri" select="."/>
329+
<xsl:apply-templates mode="generateUri" select=".">
330+
<xsl:with-param name="pDefaultUri" select="$pDefaultUri"/>
331+
</xsl:apply-templates>
321332
</xsl:variable>
322333
<xsl:choose>
323334
<xsl:when test="$serialization='rdfxml'">
@@ -369,14 +380,20 @@
369380
</xsl:template>
370381

371382
<xsl:template match="marc:datafield[@tag='662']" mode="work">
383+
<xsl:param name="recordid"/>
372384
<xsl:param name="serialization" select="'rdfxml'"/>
385+
<xsl:variable name="vDefaultUri">
386+
<xsl:value-of select="$recordid"/>#Place<xsl:value-of select="@tag"/>-<xsl:value-of select="position()"/>
387+
</xsl:variable>
373388
<xsl:apply-templates select="." mode="work662">
374389
<xsl:with-param name="serialization" select="$serialization"/>
390+
<xsl:with-param name="pDefaultUri" select="$vDefaultUri"/>
375391
</xsl:apply-templates>
376392
</xsl:template>
377393

378394
<xsl:template match="marc:datafield" mode="work662">
379395
<xsl:param name="serialization" select="'rdfxml'"/>
396+
<xsl:param name="pDefaultUri"/>
380397
<xsl:variable name="vXmlLang"><xsl:apply-templates select="." mode="xmllang"/></xsl:variable>
381398
<xsl:variable name="vLabel">
382399
<xsl:call-template name="chopPunctuation">
@@ -389,7 +406,9 @@
389406
</xsl:call-template>
390407
</xsl:variable>
391408
<xsl:variable name="vPlaceUri">
392-
<xsl:apply-templates mode="generateUri" select="."/>
409+
<xsl:apply-templates mode="generateUri" select=".">
410+
<xsl:with-param name="pDefaultUri" select="$pDefaultUri"/>
411+
</xsl:apply-templates>
393412
</xsl:variable>
394413
<xsl:choose>
395414
<xsl:when test="$serialization='rdfxml'">

xsl/ConvSpec-880.xsl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@
174174
<xsl:when test="($tag='648' or $tag='650' or $tag='651') or ($tag='655' and @ind1=' ')">
175175
<xsl:variable name="vTopicUri">
176176
<xsl:choose>
177+
<xsl:when test="$tag='648'">
178+
<xsl:value-of select="$recordid"/>#Temporal880-<xsl:value-of select="position()"/>
179+
</xsl:when>
180+
<xsl:when test="$tag='651'">
181+
<xsl:value-of select="$recordid"/>#Place880-<xsl:value-of select="position()"/>
182+
</xsl:when>
177183
<xsl:when test="$tag='655'">
178184
<xsl:value-of select="$recordid"/>#GenreForm880-<xsl:value-of select="position()"/>
179185
</xsl:when>
@@ -194,12 +200,20 @@
194200
</xsl:apply-templates>
195201
</xsl:when>
196202
<xsl:when test="$tag='656'">
203+
<xsl:variable name="vDefaultUri">
204+
<xsl:value-of select="$recordid"/>#Topic880-<xsl:value-of select="position()"/>
205+
</xsl:variable>
197206
<xsl:apply-templates select="." mode="work656">
207+
<xsl:with-param name="pDefaultUri" select="$vDefaultUri"/>
198208
<xsl:with-param name="serialization" select="$serialization"/>
199209
</xsl:apply-templates>
200210
</xsl:when>
201211
<xsl:when test="$tag='662'">
212+
<xsl:variable name="vDefaultUri">
213+
<xsl:value-of select="$recordid"/>#Place880-<xsl:value-of select="position()"/>
214+
</xsl:variable>
202215
<xsl:apply-templates select="." mode="work662">
216+
<xsl:with-param name="pDefaultUri" select="$vDefaultUri"/>
203217
<xsl:with-param name="serialization" select="$serialization"/>
204218
</xsl:apply-templates>
205219
</xsl:when>

0 commit comments

Comments
 (0)