-
Notifications
You must be signed in to change notification settings - Fork 2
/
nexml-isatab.xsl
141 lines (121 loc) · 6.43 KB
/
nexml-isatab.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?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:local="local.uri" xmlns:isa="http://www.ebi.ac.uk/bii/isatab_configuration#"
exclude-result-prefixes="xs" xpath-default-namespace="http://www.nexml.org/2009" version="2.0">
<xsl:import href="template.xsl"/>
<xsl:import href="mappings.xsl"/>
<xsl:template name="config-print">
<xsl:param name="table-name"/>
<xsl:param name="prefix"/>
<xsl:param name="position"/>
<xsl:param name="id"/>
<xsl:variable name="current-config">
<xsl:copy-of select="collection('config')[/isa:isatab-config-file/isa:isatab-configuration/@table-name=$table-name]"/>
</xsl:variable>
<xsl:choose>
<!-- Investigation -->
<xsl:when test="$table-name='investigation'">
<xsl:variable name="filename" select="concat($filebase, '/', $prefix, '_', $filebase, '_', $position, '.txt')"/>
<xsl:result-document href="{$filename}">
<xsl:for-each-group select="$current-config/isa:isatab-config-file/isa:isatab-configuration/isa:field" group-by="@section">
<xsl:value-of select="current-grouping-key()"/>
<xsl:value-of select="$line"/>
<xsl:for-each select="current-group()">
<xsl:value-of select="@header"/>
<xsl:value-of select="$tab"/>
<xsl:value-of select="local:investigation-map(@header)"/>
<xsl:value-of select="$line"/>
</xsl:for-each>
</xsl:for-each-group>
</xsl:result-document>
</xsl:when>
<!-- Study - Matrices -->
<xsl:when test="$table-name='matrix'">
<xsl:variable name="filename" select="concat($filebase, '/', $prefix, '_', $filebase, '_', $position, '.txt')"/>
<xsl:result-document href="{$filename}">
<xsl:for-each select="$current-config/isa:isatab-config-file/isa:isatab-configuration/isa:field/@header">
<xsl:value-of select="local:enquote(.)"/>
</xsl:for-each>
<xsl:value-of select="$line"/>
<xsl:for-each select="$characters[@id=$id]/matrix/row">
<xsl:variable name="row-id" select="@id"/>
<xsl:for-each select="$current-config/isa:isatab-config-file/isa:isatab-configuration/isa:field/@header">
<xsl:value-of select="local:matrix-map(.,$row-id, $position, $id)"/>
</xsl:for-each>
<xsl:value-of select="$line"/>
</xsl:for-each>
</xsl:result-document>
</xsl:when>
<!-- Assay - Trees -->
<xsl:when test="$table-name='tree-inference'">
<xsl:variable name="filename" select="concat($filebase, '/', $prefix, '_', $filebase, '_', $position, '.txt')"/>
<xsl:result-document href="{$filename}">
<xsl:for-each select="$current-config/isa:isatab-config-file/isa:isatab-configuration/isa:field/@header">
<xsl:value-of select="local:enquote(.)"/>
</xsl:for-each>
<xsl:value-of select="$line"/>
<xsl:for-each select="$trees[@id=$id]/tree">
<xsl:variable name="treeid" select="@id"/>
<xsl:for-each select="$current-config/isa:isatab-config-file/isa:isatab-configuration/isa:field/@header">
<xsl:value-of select="local:tree-map(.,$position,$treeid,$id)"/>
</xsl:for-each>
</xsl:for-each>
</xsl:result-document>
</xsl:when>
<xsl:otherwise>
<xsl:text>ERROR: Unrecognized table-name passed to local:config-print</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="$nexml">
<xsl:call-template name="config-print">
<xsl:with-param name="table-name">
<xsl:value-of select="'investigation'"/>
</xsl:with-param>
<xsl:with-param name="prefix">
<xsl:value-of select="'i'"/>
</xsl:with-param>
<xsl:with-param name="position">
<xsl:value-of select="position()"/>
</xsl:with-param>
<xsl:with-param name="id">
<xsl:value-of select="@id"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="$characters">
<xsl:variable name="matrixid" select="@id"/>
<xsl:call-template name="config-print">
<xsl:with-param name="table-name">
<xsl:value-of select="'matrix'"/>
</xsl:with-param>
<xsl:with-param name="prefix">
<xsl:value-of select="'s'"/>
</xsl:with-param>
<xsl:with-param name="position">
<xsl:value-of select="position()"/>
</xsl:with-param>
<xsl:with-param name="id">
<xsl:value-of select="$matrixid"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="$trees">
<xsl:variable name="treeid" select="@id"/>
<xsl:call-template name="config-print">
<xsl:with-param name="table-name">
<xsl:value-of select="'tree-inference'"/>
</xsl:with-param>
<xsl:with-param name="prefix">
<xsl:value-of select="'a'"/>
</xsl:with-param>
<xsl:with-param name="position">
<xsl:value-of select="position()"/>
</xsl:with-param>
<xsl:with-param name="id">
<xsl:value-of select="$treeid"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>