diff options
author | Adrian Kummerlaender | 2014-10-18 16:42:30 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-10-18 16:42:30 +0200 |
commit | a5b9f0faee9efdb950aa0558bb68cb320a9e72a4 (patch) | |
tree | 0c9f8762f4ad46a236fcd7d0de2a80ebb31ac204 | |
parent | 6384ffbd42f34b3639d36623e27889a2781408c1 (diff) | |
download | StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.tar StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.tar.gz StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.tar.bz2 StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.tar.lz StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.tar.xz StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.tar.zst StaticXSLT-a5b9f0faee9efdb950aa0558bb68cb320a9e72a4.zip |
Introduced new "directory" task type
* tasks of this type expect a path node providing the directory tree to be created
** the path is passed to `mkdir --parents $path` which does the actual work
* this addition was introduced to fix failing `create_link` calls in cases where the link is created before the actual directory is created as a side-effect of `InputXSLT:generate`
** this side-effect causes `InputXSLT:generate` to be impure and should be elimniated in InputXSLT if possible
*** the current hindrance preventing me from doing just that are the `xpath` target declarations which depend on this behaviour
-rw-r--r-- | src/steps/plan.xsl | 52 | ||||
-rw-r--r-- | src/steps/process.xsl | 19 |
2 files changed, 49 insertions, 22 deletions
diff --git a/src/steps/plan.xsl b/src/steps/plan.xsl index 653a9ca..88ecbdb 100644 --- a/src/steps/plan.xsl +++ b/src/steps/plan.xsl @@ -23,28 +23,13 @@ <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:if test="count($node/file | $node/directory) > 0"> + <task type="directory"> + <path> + <xsl:value-of select="concat($target, '/', $path)"/> + </path> + </task> + </xsl:if> <xsl:for-each select="$node/file"> <xsl:choose> @@ -75,6 +60,29 @@ </xsl:when> </xsl:choose> </xsl:for-each> + + <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:template> <xsl:template match="datasource"> diff --git a/src/steps/process.xsl b/src/steps/process.xsl index 29599f4..67c7f24 100644 --- a/src/steps/process.xsl +++ b/src/steps/process.xsl @@ -28,6 +28,14 @@ )/self::command/@result"/> </xsl:template> +<xsl:template name="create_directory"> + <xsl:param name="path"/> + + <xsl:value-of select="InputXSLT:external-command( + concat('mkdir --parents ./', $path) + )/self::command/@result"/> +</xsl:template> + <xsl:template name="clean"> <xsl:param name="path"/> @@ -268,4 +276,15 @@ </xsl:copy> </xsl:template> +<xsl:template match="task[@type = 'directory']"> + <xsl:copy> + <xsl:attribute name="result"> + <xsl:call-template name="create_directory"> + <xsl:with-param name="path" select="path"/> + </xsl:call-template> + </xsl:attribute> + <xsl:copy-of select="@* | node()"/> + </xsl:copy> +</xsl:template> + </xsl:stylesheet> |