-
Notifications
You must be signed in to change notification settings - Fork 0
/
step2_bt_rearranger.xsl
58 lines (48 loc) · 2.59 KB
/
step2_bt_rearranger.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xpath-default-namespace=""
exclude-result-prefixes="#all" version="2.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="iteration" select="'unspecified'"/>
<!-- User specify an iteration or level number -->
<xsl:variable name="output_filename" select="concat($iteration, '-2_bt_list.xml')"/>
<xsl:template match="LC_lookups">
<!-- Send output to a document -->
<xsl:result-document href="{$output_filename}">
<bt_list>
<!--
- Rearrange the fetched broader term entries:
- If the BT has subdivisions, reduce to the root and remove the subdivided terms
- If no BTs found, mark the LC_subject heading as terminus value="true"
- For each BT fetched, create a broader term entry with a copy of the LC_subject heading from the previous iteration's topic model.
- Validate for LCSH by omitting any terms with no URI
-->
<xsl:for-each select="LC_subject">
<xsl:choose>
<xsl:when test="not(broader_terms/term)">
<broader_term>
<xsl:copy-of select="label | occurrences | narrower_terms"/>
<terminus value="true"/>
</broader_term>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="broader_terms/term[not(uri = '')]">
<broader_term>
<label>
<xsl:value-of select="label"/>
</label>
<reference>
<xsl:copy-of
select="ancestor::LC_subject/*[not(name() = 'broader_terms')][not(name() = 'uri')]"
/>
</reference>
</broader_term>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</bt_list>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>