-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlom2mods.xsl
105 lines (100 loc) · 3.44 KB
/
lom2mods.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:vcard="http://schemas.vivaldi.ru/xsl/vcard/v1.0"
xmlns:lom="http://ltsc.ieee.org/xsd/LOM"
xmlns:rl="http://spec.edu.ru/xsd/RUS_LOM"
xmlns:v="http://schemas.vivaldi.ru/mods/v1"
xmlns="http://www.loc.gov/mods/v3"
exclude-result-prefixes="msxsl lom rl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="lom:lom">
<mods version="3.0">
<xsl:apply-templates select="lom:general/lom:title" />
<xsl:apply-templates select="lom:general/lom:description" />
<xsl:apply-templates select="lom:lifeCycle/lom:contribute" />
<xsl:if test="lom:lifeCycle/rl:placeOfPublication">
<xsl:call-template name="originInfo" />
</xsl:if>
<typeOfResource>text</typeOfResource>
</mods>
</xsl:template>
<xsl:template match="lom:description">
<abstract>
<xsl:value-of select="lom:string[1]" />
</abstract>
</xsl:template>
<xsl:template match="lom:title">
<titleInfo>
<title>
<xsl:value-of select="lom:string[1]" />
</title>
</titleInfo>
<extension>
<v:collections>
<v:collection>all</v:collection>
</v:collections>
</extension>
</xsl:template>
<xsl:template match="lom:contribute">
<!--<xsl:analyze-string select="entity" regex=".">
<xsl:matching-substring></xsl:matching-substring>
</xsl:analyze-string>-->
<name type="personal">
<namePart>
<xsl:value-of select="vcard:name(lom:entity)" />
</namePart>
<affiliation>
<xsl:value-of select="vcard:org(lom:entity)"/>
</affiliation>
<role>
<roleTerm type="text">
<xsl:value-of select="lom:role/lom:value"/>
</roleTerm>
</role>
</name>
</xsl:template>
<xsl:template name="originInfo">
<xsl:if test="//rl:placeOfPublication or //rl:publishingHouse or //rl:yearOfPublication">
<originInfo>
<place>
<placeTerm type="text">
<xsl:value-of select="//rl:placeOfPublication/lom:string" />
</placeTerm>
</place>
<publisher>
<xsl:value-of select="//rl:publishingHouse/lom:string" />
</publisher>
<dateIssued keyDate="yes" encoding="w3cdtf">
<xsl:value-of select="//rl:yearOfPublication/lom:dateTime"/>
</dateIssued>
</originInfo>
</xsl:if>
</xsl:template>
<msxsl:script implements-prefix='vcard' language='CSharp'>
<![CDATA[
public string name(string vcard)
{
Regex regex = new Regex("(?m)^N.*?:(?<text>.*)$");
Match match = regex.Match(vcard);
if (!match.Success)
return "no";
return match.Groups["text"].Value;
}
public string org(string vcard)
{
return field(vcard, "N");
}
public string field(string vcard, string fieldName)
{
Regex regex = new Regex(String.Format("(?m)^{0}.*?:(?<text>.*)$", fieldName));
Match match = regex.Match(vcard);
if (!match.Success)
return "no";
return match.Groups["text"].Value;
}
]]>
</msxsl:script>
</xsl:stylesheet>