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
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:InputXSLT="function.inputxslt.application"
exclude-result-prefixes="dyn xalan InputXSLT"
>
<xsl:output
method="xml"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="no"
/>
<xsl:include href="../utility/datasource.xsl"/>
<xsl:variable name="source" select="$root/meta/source"/>
<xsl:variable name="target" select="$root/meta/target"/>
<xsl:template name="construct_level">
<xsl:param name="node"/>
<xsl:param name="path"/>
<level>
<node>
<xsl:copy-of select="$node"/>
</node>
<path>
<xsl:value-of select="$path"/>
</path>
</level>
</xsl:template>
<xsl:template match="node/file[@extension = '.xsl']">
<xsl:variable name="base_path" select="../../path"/>
<task type="generate">
<meta>
<datasource_prefix>
<xsl:value-of select="$target"/>
</datasource_prefix>
</meta>
<source>
<xsl:value-of select="concat($source, '/', $base_path, '/', @name, @extension)"/>
</source>
<target>
<xsl:value-of select="concat($target, '/', $base_path)"/>
</target>
</task>
</xsl:template>
<xsl:template match="node/file[@extension = '.css']">
<xsl:variable name="base_path" select="../../path"/>
<task type="link">
<from>
<xsl:value-of select="concat($target, '/', $base_path, '/', @name, @extension)"/>
</from>
<to>
<xsl:value-of select="concat($source, '/', $base_path, '/', @name, @extension)"/>
</to>
</task>
</xsl:template>
<xsl:template match="node/directory[.//file/@extension = '.xsl']">
<xsl:variable name="base_path" select="../../path"/>
<xsl:variable name="new_level">
<xsl:call-template name="construct_level">
<xsl:with-param name="path" select="concat($base_path, '/', @name)"/>
<xsl:with-param name="node" select="./node()"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="xalan:nodeset($new_level)/level"/>
</xsl:template>
<xsl:template match="node/directory[not(.//file/@extension = '.xsl')]">
<xsl:variable name="base_path" select="../../path"/>
<task type="link">
<from>
<xsl:value-of select="concat($target, '/', $base_path, '/', @name)"/>
</from>
<to>
<xsl:value-of select="concat($source, '/', $base_path, '/', @name)"/>
</to>
</task>
</xsl:template>
<xsl:template match="level[count(node/file | node/directory) > 0]">
<task type="directory">
<path>
<xsl:value-of select="concat($target, '/', path)"/>
</path>
</task>
<xsl:apply-templates select="node/file | node/directory"/>
</xsl:template>
<xsl:template match="datasource">
<xsl:copy-of select="source"/>
<xsl:copy-of select="meta"/>
<xsl:variable name="new_level">
<xsl:call-template name="construct_level">
<xsl:with-param name="node" select="source/node()"/>
</xsl:call-template>
</xsl:variable>
<tasks>
<task type="clean">
<path>
<xsl:value-of select="meta/target"/>
</path>
</task>
<xsl:apply-templates select="xalan:nodeset($new_level)/level"/>
</tasks>
</xsl:template>
</xsl:stylesheet>
|