aboutsummaryrefslogtreecommitdiff
path: root/process.xsl
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-29 23:35:16 +0200
committerAdrian Kummerlaender2014-08-29 23:35:16 +0200
commit9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6 (patch)
tree4f9ea668d3ea840dc83c211d4e50daee59533ee5 /process.xsl
parentdc7c9280dabd9d2a512ddd4a1b00213367f81c3d (diff)
downloadblog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.tar
blog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.tar.gz
blog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.tar.bz2
blog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.tar.lz
blog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.tar.xz
blog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.tar.zst
blog.kummerlaender.eu-9c8d55ae5ee4b4d2dd8b5d69c4a635ac1b1236c6.zip
Removed need for prefixing datasource source attribute
* transformations contain one or more "datasource" meta nodes ** these nodes define the required datasources ** up until now it was required to define the whole path to the file to be loaded * the implementation of directory linkage in b942f8e removed the underlying need for providing the source / target prefix ** this commit now updates the generation transformations to match this change *** this simplifies the datasource definition process for the end-user *** additionally it makes the target / source directories easier to maintain * changed cleanage task implementation to remove the whole directory and recreate it from scratch ** otherwise directory linkage and in turn the whole generation failed when the target directory did not exist in the first place * removed task reordering in the process transformation ** tasks are now processed exactly as they were scheduled ** this was changed so that e.g. the "00_content" directory is linked before the first datasource is required
Diffstat (limited to 'process.xsl')
-rw-r--r--process.xsl58
1 files changed, 31 insertions, 27 deletions
diff --git a/process.xsl b/process.xsl
index 29efc0e..595d617 100644
--- a/process.xsl
+++ b/process.xsl
@@ -30,7 +30,7 @@
<xsl:param name="path"/>
<xsl:value-of select="InputXSLT:external-command(
- concat('rm -r ./', $path, '/*')
+ concat('rm -r ./', $path, '; mkdir ./', $path)
)/self::command/@result"/>
</xsl:template>
@@ -87,13 +87,16 @@
</xsl:template>
<xsl:template name="resolve_datasource">
+ <xsl:param name="prefix"/>
<xsl:param name="datasource"/>
<xsl:for-each select="$datasource">
<xsl:element name="{@target}">
<xsl:choose>
<xsl:when test="@mode = 'full'">
- <xsl:copy-of select="InputXSLT:read-file(@source)/self::file/*/*"/>
+ <xsl:copy-of select="InputXSLT:read-file(
+ concat($prefix, '/', @source)
+ )/self::file/*/*"/>
</xsl:when>
</xsl:choose>
</xsl:element>
@@ -104,6 +107,7 @@
<xsl:param name="main"/>
<xsl:param name="support"/>
<xsl:param name="transformation"/>
+ <xsl:param name="datasource_prefix"/>
<xsl:param name="target_prefix"/>
<xsl:param name="target"/>
@@ -112,6 +116,7 @@
<xsl:with-param name="main" select="$main"/>
<xsl:with-param name="support">
<xsl:call-template name="resolve_datasource">
+ <xsl:with-param name="prefix" select="$datasource_prefix"/>
<xsl:with-param name="datasource" select="$support"/>
</xsl:call-template>
</xsl:with-param>
@@ -134,10 +139,9 @@
</xsl:template>
<xsl:template name="process">
- <xsl:param name="source"/>
- <xsl:param name="target"/>
+ <xsl:param name="task"/>
- <xsl:variable name="transformation" select="InputXSLT:read-file($source)/self::file/node()"/>
+ <xsl:variable name="transformation" select="InputXSLT:read-file($task/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']"/>
@@ -147,36 +151,43 @@
<xsl:call-template name="compile">
<xsl:with-param name="main">
<xsl:element name="{$main_source/@target}">
- <xsl:copy-of select="InputXSLT:read-file($main_source/@source)/self::file/*/*"/>
+ <xsl:copy-of select="InputXSLT:read-file(
+ concat($task/meta/datasource_prefix, '/', $main_source/@source)
+ )/self::file/*/*"/>
</xsl:element>
</xsl:with-param>
- <xsl:with-param name="support" select="$support_source"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target_prefix" select="$target"/>
- <xsl:with-param name="target" select="$meta/target"/>
+ <xsl:with-param name="support" select="$support_source"/>
+ <xsl:with-param name="transformation" select="$transformation"/>
+ <xsl:with-param name="datasource_prefix" select="$task/meta/datasource_prefix"/>
+ <xsl:with-param name="target_prefix" select="$task/target"/>
+ <xsl:with-param name="target" select="$meta/target"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$main_source/@mode = 'iterate'">
- <xsl:for-each select="InputXSLT:read-file($main_source/@source)/self::file/*/entry">
+ <xsl:for-each select="InputXSLT:read-file(
+ concat($task/meta/datasource_prefix, '/', $main_source/@source)
+ )/self::file/*/entry">
<xsl:call-template name="compile">
<xsl:with-param name="main">
<xsl:element name="{$main_source/@target}">
<xsl:copy-of select="."/>
</xsl:element>
</xsl:with-param>
- <xsl:with-param name="support" select="$support_source"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target_prefix" select="$target"/>
- <xsl:with-param name="target" select="$meta/target"/>
+ <xsl:with-param name="support" select="$support_source"/>
+ <xsl:with-param name="transformation" select="$transformation"/>
+ <xsl:with-param name="datasource_prefix" select="$task/meta/datasource_prefix"/>
+ <xsl:with-param name="target_prefix" select="$task/target"/>
+ <xsl:with-param name="target" select="$meta/target"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="compile">
- <xsl:with-param name="support" select="$support_source"/>
- <xsl:with-param name="transformation" select="$transformation"/>
- <xsl:with-param name="target_prefix" select="$target"/>
- <xsl:with-param name="target" select="$meta/target"/>
+ <xsl:with-param name="support" select="$support_source"/>
+ <xsl:with-param name="transformation" select="$transformation"/>
+ <xsl:with-param name="datasource_prefix" select="$task/meta/datasource_prefix"/>
+ <xsl:with-param name="target_prefix" select="$task/target"/>
+ <xsl:with-param name="target" select="$meta/target"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
@@ -196,8 +207,7 @@
<xsl:template match="task[@type = 'generate']">
<xsl:variable name="results">
<xsl:call-template name="process">
- <xsl:with-param name="source" select="source"/>
- <xsl:with-param name="target" select="target"/>
+ <xsl:with-param name="task" select="."/>
</xsl:call-template>
</xsl:variable>
@@ -232,10 +242,4 @@
</xsl:copy>
</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>