-
Notifications
You must be signed in to change notification settings - Fork 7
/
list-msIDnums.xsl
38 lines (33 loc) · 1.58 KB
/
list-msIDnums.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
<?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"
xmlns:jc="http://james.blushingbunny.net/ns.html"
xmlns="http://www.tei-c.org/ns/1.0"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="text"/>
<!-- files and recurse parameters defaulting to '*.xml' and 'no' respectively -->
<xsl:param name="files" select="'*.xml'"/>
<xsl:param name="recurse" select="'yes'"/>
<!-- The main template, everything happens here. -->
<xsl:template name="main">
<!-- create path from params -->
<xsl:variable name="path">
<xsl:value-of
select="concat('./?select=', $files,';on-error=warning;recurse=',$recurse)"/>
</xsl:variable>
<!-- the main collection of all the documents we are dealing with -->
<xsl:variable name="doc" select="collection($path)"/>
<xsl:variable name="msDesc" select="$doc//msDesc"/>
<xsl:for-each select="$msDesc">
<xsl:text>"</xsl:text><xsl:value-of select="jc:csvEscapeDoubleQuotes(msIdentifier/idno)"/><xsl:text>", "</xsl:text><xsl:value-of select="jc:csvEscapeDoubleQuotes(@xml:id)"/><xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<!-- CSV doesn't like spare double quotes lying around. So you escape them by putting two double quotes instead -->
<xsl:function name="jc:csvEscapeDoubleQuotes" as="xs:string">
<xsl:param name="string"/>
<xsl:value-of select="replace($string, '"', '""')"/>
</xsl:function>
</xsl:stylesheet>