blob: bd57c403e2bf36c4667704ef96276ecc5f40d210 (
plain)
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
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:InputXSLT="function.inputxslt.application"
exclude-result-prefixes="xalan InputXSLT"
>
<xsl:output
method="xml"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="no"
/>
<xsl:template name="generate">
<xsl:param name="input"/>
<xsl:param name="transformation"/>
<xsl:copy-of select="InputXSLT:generate(
xalan:nodeset($input),
InputXSLT:read-file(string($transformation))/self::file/node()
)/self::generation/node()"/>
</xsl:template>
<xsl:template name="generate_chain">
<xsl:param name="input"/>
<xsl:param name="head"/>
<xsl:param name="tail"/>
<xsl:choose>
<xsl:when test="count($tail) > 0">
<xsl:call-template name="generate">
<xsl:with-param name="input">
<xsl:call-template name="generate_chain">
<xsl:with-param name="input" select="$input"/>
<xsl:with-param name="head" select="$tail[1]"/>
<xsl:with-param name="tail" select="$tail[position() > 1]"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="transformation" select="$head/text()"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="generate">
<xsl:with-param name="input" select="$input"/>
<xsl:with-param name="transformation" select="$head/text()"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="task[@type = 'generate']">
<xsl:variable name="input">
<xsl:choose>
<xsl:when test="input/@mode = 'embedded'">
<xsl:copy-of select="input/node()"/>
</xsl:when>
<xsl:when test="input/@mode = 'file'">
<xsl:copy-of select="InputXSLT:read-file(input/text())/self::file/node()"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="transformation/@mode = 'chain'">
<xsl:variable name="chain">
<xsl:for-each select="transformation/link">
<xsl:sort select="position()" data-type="number" order="descending"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="generate_chain">
<xsl:with-param name="input" select="$input"/>
<xsl:with-param name="head" select="xalan:nodeset($chain)/link[1]"/>
<xsl:with-param name="tail" select="xalan:nodeset($chain)/link[position() > 1]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="transformation/@mode = 'file'">
<xsl:call-template name="generate">
<xsl:with-param name="input" select="$input"/>
<xsl:with-param name="transformation" select="transformation/text()"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|