aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-23 21:08:33 +0200
committerAdrian Kummerlaender2014-08-23 21:08:33 +0200
commit451df2a01502ef04ef32973f4a80d90195d47b3d (patch)
treecf53737bb5a6b73ca1869c527454143e69c6ea7f
parentb942f8ed534e789495b74cc87fd155b0bd2dab0b (diff)
downloadblog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.tar
blog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.tar.gz
blog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.tar.bz2
blog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.tar.lz
blog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.tar.xz
blog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.tar.zst
blog.kummerlaender.eu-451df2a01502ef04ef32973f4a80d90195d47b3d.zip
Separated task planning and processing into separate transformations
* "plan.xsl" traverses the file-tree provided by "list.xsl" and determines the tasks to be executed * "process.xsl" executes the tasks planned by "plan.xsl" in a sensible order * this change was implemented to be able to e.g. schedule the linkage tasks for last ** performing them in tree-order caused problems when the generator tried to create symlinks inside non-existing directories ** additionally this further modularizes the processing chain
-rw-r--r--make.xsl35
-rw-r--r--plan.xsl89
-rw-r--r--process.xsl (renamed from traverse.xsl)75
-rw-r--r--source/99_result/stream.xsl1
4 files changed, 131 insertions, 69 deletions
diff --git a/make.xsl b/make.xsl
index a62a017..159e232 100644
--- a/make.xsl
+++ b/make.xsl
@@ -32,26 +32,31 @@
<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: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: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:with-param name="transformation">plan.xsl</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
- <xsl:with-param name="transformation">traverse.xsl</xsl:with-param>
+ <xsl:with-param name="transformation">process.xsl</xsl:with-param>
</xsl:call-template>
</xsl:template>
diff --git a/plan.xsl b/plan.xsl
new file mode 100644
index 0000000..6754d14
--- /dev/null
+++ b/plan.xsl
@@ -0,0 +1,89 @@
+<?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="yes"
+/>
+
+<xsl:include href="utility/datasource.xsl"/>
+
+<xsl:template name="traverse">
+ <xsl:param name="source"/>
+ <xsl:param name="target"/>
+ <xsl:param name="path"/>
+ <xsl:param name="node"/>
+
+ <xsl:for-each select="$node/directory">
+ <xsl:choose>
+ <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="node" select="."/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <task type="link">
+ <from>
+ <xsl:value-of select="concat($target, '/', $path, '/', @name)"/>
+ </from>
+ <to>
+ <xsl:value-of select="concat($source, '/', $path, '/', @name)"/>
+ </to>
+ </task>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+
+ <xsl:for-each select="$node/file">
+ <xsl:choose>
+ <xsl:when test="@extension = '.xsl'">
+ <task type="generate">
+ <source>
+ <xsl:value-of select="concat($source, '/', $path, '/', @name, @extension)"/>
+ </source>
+ <target>
+ <xsl:value-of select="concat($target, '/', $path)"/>
+ </target>
+ </task>
+ </xsl:when>
+ <xsl:when test="@extension = '.css'">
+ <task type="link">
+ <from>
+ <xsl:value-of select="concat($target, '/', $path, '/', @name, @extension)"/>
+ </from>
+ <to>
+ <xsl:value-of select="concat($source, '/', $path, '/', @name, @extension)"/>
+ </to>
+ </task>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template match="datasource">
+ <task type="clean">
+ <path>
+ <xsl:value-of select="meta/target"/>
+ </path>
+ </task>
+
+ <xsl:call-template name="traverse">
+ <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>
+
+</xsl:stylesheet>
diff --git a/traverse.xsl b/process.xsl
index 6814312..d8f2aab 100644
--- a/traverse.xsl
+++ b/process.xsl
@@ -8,8 +8,6 @@
exclude-result-prefixes="dyn xalan InputXSLT"
>
-<xsl:import href="utility/helper.xsl"/>
-
<xsl:output
method="xml"
omit-xml-declaration="yes"
@@ -17,7 +15,7 @@
indent="yes"
/>
-<xsl:variable name="root" select="/datasource"/>
+<xsl:include href="utility/helper.xsl"/>
<xsl:template name="generate">
<xsl:param name="input"/>
@@ -35,8 +33,8 @@
<xsl:param name="from"/>
<xsl:param name="to"/>
- <linkage from="{$from}" to="{$to}" result="{InputXSLT:external-command(
- concat('ln -sr ', $to, ' ', $from)
+ <linkage from="./{$from}" to="./{$to}" result="{InputXSLT:external-command(
+ concat('ln -sr ./', $to, ' ./', $from)
)/self::command/@result}"/>
</xsl:template>
@@ -159,59 +157,30 @@
</xsl:choose>
</xsl:template>
-<xsl:template name="traverse">
- <xsl:param name="source"/>
- <xsl:param name="target"/>
- <xsl:param name="path"/>
- <xsl:param name="node"/>
-
- <xsl:for-each select="$node/directory">
- <xsl:choose>
- <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="node" select="."/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <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: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 match="task[@type = 'clean']">
+ <xsl:call-template name="cleaner">
+ <xsl:with-param name="path" select="path"/>
+ </xsl:call-template>
</xsl:template>
-<xsl:template match="datasource">
- <xsl:call-template name="cleaner">
- <xsl:with-param name="path" select="meta/target"/>
+<xsl:template match="task[@type = 'generate']">
+ <xsl:call-template name="process">
+ <xsl:with-param name="source" select="source"/>
+ <xsl:with-param name="target" select="target"/>
</xsl:call-template>
+</xsl:template>
- <xsl:call-template name="traverse">
- <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:template match="task[@type = 'link']">
+ <xsl:call-template name="linker">
+ <xsl:with-param name="from" select="from"/>
+ <xsl:with-param name="to" select="to"/>
</xsl:call-template>
</xsl:template>
+<xsl:template match="datasource">
+ <xsl:apply-templates select="task[@type = 'clean']"/>
+ <xsl:apply-templates select="task[@type = 'generate']"/>
+ <xsl:apply-templates select="task[@type = 'link']"/>
+</xsl:template>
+
</xsl:stylesheet>
diff --git a/source/99_result/stream.xsl b/source/99_result/stream.xsl
index 355314c..526b8db 100644
--- a/source/99_result/stream.xsl
+++ b/source/99_result/stream.xsl
@@ -47,7 +47,6 @@
<a href="{$url}/tag/{.}">
<xsl:value-of select="."/>
</a>
- <xsl:text> </xsl:text>
</xsl:for-each>
<xsl:text> | Adrian Kummerländer</xsl:text>
</p>