diff options
-rw-r--r-- | list.xsl | 43 | ||||
-rw-r--r-- | make.xsl | 58 | ||||
-rw-r--r-- | source/99_result/media/bottom.png | bin | 0 -> 1527 bytes | |||
-rw-r--r-- | source/99_result/media/single.png | bin | 0 -> 263 bytes | |||
-rw-r--r-- | source/99_result/media/top.png | bin | 0 -> 1481 bytes | |||
-rw-r--r-- | traverse.xsl (renamed from generate.xsl) | 92 | ||||
-rw-r--r-- | utility/helper.xsl | 26 |
7 files changed, 163 insertions, 56 deletions
diff --git a/list.xsl b/list.xsl new file mode 100644 index 0000000..7eba255 --- /dev/null +++ b/list.xsl @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:InputXSLT="function.inputxslt.application" + exclude-result-prefixes="InputXSLT" +> + +<xsl:output + method="xml" + omit-xml-declaration="yes" + encoding="UTF-8" + indent="no" +/> + +<xsl:template name="list"> + <xsl:param name="base"/> + + <xsl:for-each select="InputXSLT:read-directory($base)/entry"> + <xsl:choose> + <xsl:when test="@type = 'directory'"> + <directory name="{./name}"> + <xsl:call-template name="list"> + <xsl:with-param name="base" select="./full"/> + </xsl:call-template> + </directory> + </xsl:when> + <xsl:otherwise> + <file name="{./name}" extension="{./extension}"/> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> +</xsl:template> + +<xsl:template match="datasource"> + <source> + <xsl:call-template name="list"> + <xsl:with-param name="base" select="."/> + </xsl:call-template> + </source> +</xsl:template> + +</xsl:stylesheet> diff --git a/make.xsl b/make.xsl new file mode 100644 index 0000000..a62a017 --- /dev/null +++ b/make.xsl @@ -0,0 +1,58 @@ +<?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="yes" +/> + +<xsl:include href="utility/helper.xsl"/> + +<xsl:template name="generate"> + <xsl:param name="input"/> + <xsl:param name="transformation"/> + + <xsl:copy-of select="InputXSLT:generate( + $input, + string($transformation) + )/self::generation/node()"/> +</xsl:template> + +<xsl:template match="/"> + <xsl:variable name="source">source</xsl:variable> + <xsl:variable name="target">target</xsl:variable> + + <xsl:call-template name="generate"> + <xsl:with-param name="input"> + <xsl:call-template name="merge_datasource"> + <xsl:with-param name="main"> + <xsl:call-template name="generate"> + <xsl:with-param name="input"> + <datasource> + <xsl:value-of select="$source"/> + </datasource> + </xsl:with-param> + <xsl:with-param name="transformation">list.xsl</xsl:with-param> + </xsl:call-template> + </xsl:with-param> + <xsl:with-param name="support"> + <meta> + <source><xsl:value-of select="$source"/></source> + <target><xsl:value-of select="$target"/></target> + </meta> + </xsl:with-param> + </xsl:call-template> + </xsl:with-param> + <xsl:with-param name="transformation">traverse.xsl</xsl:with-param> + </xsl:call-template> +</xsl:template> + +</xsl:stylesheet> diff --git a/source/99_result/media/bottom.png b/source/99_result/media/bottom.png Binary files differnew file mode 100644 index 0000000..ff2afa7 --- /dev/null +++ b/source/99_result/media/bottom.png diff --git a/source/99_result/media/single.png b/source/99_result/media/single.png Binary files differnew file mode 100644 index 0000000..514d39a --- /dev/null +++ b/source/99_result/media/single.png diff --git a/source/99_result/media/top.png b/source/99_result/media/top.png Binary files differnew file mode 100644 index 0000000..ca71f84 --- /dev/null +++ b/source/99_result/media/top.png diff --git a/generate.xsl b/traverse.xsl index bac0288..6814312 100644 --- a/generate.xsl +++ b/traverse.xsl @@ -17,6 +17,8 @@ indent="yes" /> +<xsl:variable name="root" select="/datasource"/> + <xsl:template name="generate"> <xsl:param name="input"/> <xsl:param name="transformation"/> @@ -29,24 +31,31 @@ )/self::generation"/> </xsl:template> -<xsl:template name="merge_datasource"> - <xsl:param name="main"/> - <xsl:param name="support"/> +<xsl:template name="linker"> + <xsl:param name="from"/> + <xsl:param name="to"/> + + <linkage from="{$from}" to="{$to}" result="{InputXSLT:external-command( + concat('ln -sr ', $to, ' ', $from) + )/self::command/@result}"/> +</xsl:template> - <datasource> - <xsl:copy-of select="$main"/> - <xsl:copy-of select="$support"/> - </datasource> +<xsl:template name="cleaner"> + <xsl:param name="path"/> + + <cleaning path="./{$path}" result="{InputXSLT:external-command( + concat('rm -r ./', $path, '/*') + )/self::command/@result}"/> </xsl:template> <xsl:template name="resolve_datasource"> <xsl:param name="datasource"/> <xsl:for-each select="$datasource"> - <xsl:element name="{./@target}"> + <xsl:element name="{@target}"> <xsl:choose> - <xsl:when test="./@mode = 'full'"> - <xsl:copy-of select="InputXSLT:read-file(./@source)/self::file/*/*"/> + <xsl:when test="@mode = 'full'"> + <xsl:copy-of select="InputXSLT:read-file(@source)/self::file/*/*"/> </xsl:when> </xsl:choose> </xsl:element> @@ -102,10 +111,10 @@ </xsl:template> <xsl:template name="process"> - <xsl:param name="file"/> + <xsl:param name="source"/> <xsl:param name="target"/> - <xsl:variable name="transformation" select="InputXSLT:read-file($file/full)/self::file/*"/> + <xsl:variable name="transformation" select="InputXSLT:read-file($source)/self::file/node()"/> <xsl:variable name="meta" select="$transformation/self::*[name() = 'xsl:stylesheet']/*[name() = 'xsl:variable' and @name = 'meta']"/> <xsl:variable name="main_source" select="$meta/datasource[@type = 'main']"/> <xsl:variable name="support_source" select="$meta/datasource[@type = 'support']"/> @@ -154,51 +163,54 @@ <xsl:param name="source"/> <xsl:param name="target"/> <xsl:param name="path"/> + <xsl:param name="node"/> - <xsl:variable name="entries" select="InputXSLT:read-directory( - concat($source, '/', $path) - )/entry"/> - - <xsl:for-each select="$entries"> + <xsl:for-each select="$node/directory"> <xsl:choose> - <xsl:when test="@type = 'directory'"> + <xsl:when test=".//file/@extension = '.xsl'"> <xsl:call-template name="traverse"> <xsl:with-param name="source" select="$source"/> <xsl:with-param name="target" select="$target"/> - <xsl:with-param name="path" select="concat($path, '/', ./name)"/> + <xsl:with-param name="path" select="concat($path, '/', @name)"/> + <xsl:with-param name="node" select="."/> </xsl:call-template> </xsl:when> <xsl:otherwise> - <xsl:choose> - <xsl:when test="./extension = '.xsl'"> - <xsl:call-template name="process"> - <xsl:with-param name="file" select="."/> - <xsl:with-param name="target" select="concat($target, '/', $path)"/> - </xsl:call-template> - </xsl:when> - <xsl:when test="./extension = '.css'"> - <xsl:call-template name="linker"> - <xsl:with-param name="from" select="./full"/> - <xsl:with-param name="to" select="concat($target, '/', $path, '/', ./name, ./extension)"/> - </xsl:call-template> - </xsl:when> - </xsl:choose> + <xsl:call-template name="linker"> + <xsl:with-param name="from" select="concat($target, '/', $path, '/', @name)"/> + <xsl:with-param name="to" select="concat($source, '/', $path, '/', @name)"/> + </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:for-each> -</xsl:template> -<xsl:template match="/"> - <xsl:variable name="source">source</xsl:variable> - <xsl:variable name="target">target</xsl:variable> + <xsl:for-each select="$node/file"> + <xsl:choose> + <xsl:when test="@extension = '.xsl'"> + <xsl:call-template name="process"> + <xsl:with-param name="source" select="concat($source, '/', $path, '/', @name, @extension)"/> + <xsl:with-param name="target" select="concat($target, '/', $path)"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="@extension = '.css'"> + <xsl:call-template name="linker"> + <xsl:with-param name="from" select="concat($target, '/', $path, '/', @name, @extension)"/> + <xsl:with-param name="to" select="concat($source, '/', $path, '/', @name, @extension)"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> + </xsl:for-each> +</xsl:template> +<xsl:template match="datasource"> <xsl:call-template name="cleaner"> - <xsl:with-param name="path" select="$target"/> + <xsl:with-param name="path" select="meta/target"/> </xsl:call-template> <xsl:call-template name="traverse"> - <xsl:with-param name="source" select="$source"/> - <xsl:with-param name="target" select="$target"/> + <xsl:with-param name="source" select="$root/meta/source"/> + <xsl:with-param name="target" select="$root/meta/target"/> + <xsl:with-param name="node" select="source"/> </xsl:call-template> </xsl:template> diff --git a/utility/helper.xsl b/utility/helper.xsl index cf3d7ba..0ebc15d 100644 --- a/utility/helper.xsl +++ b/utility/helper.xsl @@ -7,6 +7,16 @@ exclude-result-prefixes="xalan InputXSLT" > +<xsl:template name="merge_datasource"> + <xsl:param name="main"/> + <xsl:param name="support"/> + + <datasource> + <xsl:copy-of select="$main"/> + <xsl:copy-of select="$support"/> + </datasource> +</xsl:template> + <xsl:template name="formatter"> <xsl:param name="format"/> <xsl:param name="source"/> @@ -17,20 +27,4 @@ )/self::command/node()"/> </xsl:template> -<xsl:template name="cleaner"> - <xsl:param name="path"/> - - <cleaning path="./{$path}" result="{InputXSLT:external-command( - concat('rm -r ./', $path, '/*') - )/self::command/@result}"/> -</xsl:template> - -<xsl:template name="linker"> - <xsl:param name="from"/> - <xsl:param name="to"/> - - <linkage from="{$from}" to="{$to}" result="{InputXSLT:external-command( - concat('ln -s ', $from, ' ./', $to) - )/self::command/@result}"/> -</xsl:template> </xsl:stylesheet> |