forked from faustedition/faust-gen-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetadata-html.xpl
208 lines (172 loc) · 8.83 KB
/
metadata-html.xpl
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:f="http://www.faustedition.net/ns"
xmlns:pxf="http://exproc.org/proposed/steps/file"
xmlns:l="http://xproc.org/library" type="f:metadata-html" name="main" version="1.0">
<p:input port="source"><p:empty/></p:input>
<p:input port="parameters" kind="parameter"/>
<p:output port="result" sequence="true"/>
<p:import href="http://xproc.org/library/recursive-directory-list.xpl"/>
<p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl"/>
<!-- Parameter laden -->
<p:parameters name="config">
<p:input port="parameters">
<p:document href="config.xml"/>
<p:pipe port="parameters" step="main"></p:pipe>
</p:input>
</p:parameters>
<p:group>
<p:variable name="metahtml" select="//c:param[@name='metahtml']/@value"><p:pipe port="result" step="config"></p:pipe></p:variable>
<p:variable name="source" select="//c:param[@name='source']/@value"><p:pipe port="result" step="config"/></p:variable>
<p:variable name="debug" select="//c:param[@name='debug']/@value"><p:pipe port="result" step="config"/></p:variable>
<p:variable name="builddir" select="resolve-uri(//c:param[@name='builddir']/@value)"><p:pipe port="result" step="config"/></p:variable>
<cx:message log="info">
<p:input port="source"><p:pipe port="source" step="main"></p:pipe></p:input>
<p:with-option name="message" select="concat('Transforming metadata from ', $source)"/>
</cx:message>
<l:recursive-directory-list name="list">
<p:with-option name="path" select="concat($source, '/document')"/>
</l:recursive-directory-list>
<p:for-each name="convert-metadata">
<p:iteration-source select="//c:file[$debug or not(ends-with(@name, 'test.xml'))]"/>
<p:variable name="filename" select="p:resolve-uri(/c:file/@name)"/>
<p:variable name="basename" select="replace(replace($filename, '.*/', ''), '.xml$', '')"/>
<p:variable name="outfile" select="concat($metahtml, $basename, '.html')"/>
<p:load>
<p:with-option name="href" select="$filename"/>
</p:load>
<!--<cx:message log="info">
<p:with-option name="message" select="concat('Rendering metadata of ', //f:idno[@type='faustedition'], ' (', $filename, ') to HTML ...')"/>
</cx:message>-->
<p:xslt name="generate-html">
<p:input port="stylesheet"><p:document href="xslt/faust-metadata.xsl"/></p:input>
<p:with-param name="builddir-resolved" select="$builddir"/>
<p:input port="parameters"><p:pipe port="result" step="config"/></p:input>
</p:xslt>
<p:store encoding="utf-8" method="xhtml" include-content-type="false" indent="true">
<p:with-option name="href" select="$outfile"/>
</p:store>
<p:xslt>
<p:input port="source"><p:pipe port="result" step="generate-html"/></p:input>
<p:input port="parameters"><p:pipe port="result" step="config"/></p:input>
<p:with-param name="from" select="replace($filename, concat('^', $source), 'faust://xml/')"/>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xpath-default-namespace="http://www.w3.org/1999/xhtml">
<xsl:param name="from"/>
<xsl:template match="/">
<f:citations>
<xsl:for-each select="//*/@data-bib-uri">
<xsl:for-each select="tokenize(., '\s+')">
<f:citation from="{$from}"><xsl:value-of select="."/></f:citation>
</xsl:for-each>
</xsl:for-each>
</f:citations>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
</p:xslt>
</p:for-each>
<p:identity name="converted-metadata"/>
<p:identity><p:input port="source"><p:pipe port="result" step="list"/></p:input></p:identity>
<cx:message message="Generating watermark table ..."/>
<p:for-each name="list-wm">
<p:iteration-source select="//c:file[$debug or not(ends-with(@name, 'test.xml'))]"/>
<p:variable name="filename" select="p:resolve-uri(/c:file/@name)"/>
<p:load>
<p:with-option name="href" select="$filename"/>
</p:load>
<p:add-attribute match="/*" attribute-name="faust-uri">
<p:with-option name="attribute-value" select="replace($filename, concat('^', $source), 'faust://xml/')"/>
</p:add-attribute>
</p:for-each>
<p:wrap-sequence wrapper="f:documents"/>
<p:xslt>
<p:input port="stylesheet"><p:document href="xslt/watermark-table.xsl"/></p:input>
<p:input port="parameters"><p:pipe port="result" step="config"/></p:input>
</p:xslt>
<p:store indent="true" method="xhtml">
<p:with-option name="href" select="resolve-uri('www/watermark-table.html', $builddir)"/>
</p:store>
<p:identity>
<p:input port="source"><p:pipe port="result" step="list"></p:pipe></p:input>
</p:identity>
<p:for-each name="list-headnotes">
<p:iteration-source select="//c:file[$debug or not(ends-with(@name, 'test.xml'))]"/>
<p:variable name="filename" select="p:resolve-uri(/c:file/@name)"/>
<p:load>
<p:with-option name="href" select="$filename"/>
</p:load>
<p:xslt>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="xslt/bibliography.xsl"/>
<xsl:template match="/">
<xsl:for-each select="(//f:metadata)[1]">
<xsl:variable name="sigil" select="f:idno[@type='faustedition']"/>
<xsl:variable name="sigil_n" select="replace(lower-case($sigil), '[ .*]', '')"/>
<div data-sigil="{$sigil}">
<h3 class="sigil"><xsl:value-of select="f:idno[@type='faustedition']"/>
<span class="headnote"><xsl:value-of select="f:headNote"/></span>
<a id="{$sigil_n}" href="#{$sigil_n}">§</a>
</h3>
<p class="first-note"><xsl:for-each select="f:headNote/following-sibling::f:note[1]">
<xsl:call-template name="parse-for-bib"/>
</xsl:for-each></p>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
<p:with-param name="builddir-resolved" select="$builddir"/>
</p:xslt>
</p:for-each>
<p:wrap-sequence wrapper="f:doc" />
<p:xslt>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns="http://www.w3.org/1999/xhtml" xpath-default-namespace="http://www.w3.org/1999/xhtml">
<xsl:import href="xslt/utils.xsl"/>
<!--<xsl:import href="xslt/html-frame.xsl"/>-->
<xsl:template match="/">
<!-- <xsl:call-template name="html-frame">
<xsl:with-param name="content">
-->
<html>
<head>
<title>Die ersten notes nach der headNote</title>
<style>
.headnote {
font-weight: normal;
margin-left: 2em;
color: gray;
}
</style>
</head>
<body>
<xsl:for-each select="//div">
<xsl:sort select="f:splitSigil(@data-sigil)[1]" stable="yes"/>
<xsl:sort select="f:splitSigil(@data-sigil)[2]" data-type="number"/>
<xsl:sort select="f:splitSigil(@data-sigil)[3]"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</body>
</html>
<!--</xsl:with-param>
</xsl:call-template>-->
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
</p:xslt>
<p:store method="xhtml">
<p:with-option name="href" select="concat($metahtml, 'first-notes.html')"/>
</p:store>
<p:identity name="metadata-citations">
<p:input port="source"><p:pipe port="result" step="converted-metadata"/></p:input>
</p:identity>
</p:group>
</p:declare-step>