aboutsummaryrefslogtreecommitdiff
path: root/test/transform
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-06-26 20:26:32 +0200
committerAdrian Kummerlaender2014-06-26 20:26:32 +0200
commit266b408ee53b9bc7db2b1a5c92e62adfd2af6def (patch)
treeb84551406742ba892824a5770ae8fb8ec3a6a510 /test/transform
parent7b872121000d4db4026d0c90fcb95a10f1e43694 (diff)
downloadInputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.tar
InputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.tar.gz
InputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.tar.bz2
InputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.tar.lz
InputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.tar.xz
InputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.tar.zst
InputXSLT-266b408ee53b9bc7db2b1a5c92e62adfd2af6def.zip
Implemented basic external "write-file" function
* accepts a path parameter and the content to be written * removed target parameter form FunctionTransform ** transformation result is now returned as a string *** nodeset return value is planned ** e.g. writing the result to the fs is optional and has to be achieved using FunctionWriteFile * changed "transform" test case accordingly * this marks a paradigm shift and is the continuation of the changes described in 741a70f ** InputXSLT now also implements a output function * added basic io error handling to FunctionReadFile
Diffstat (limited to 'test/transform')
-rw-r--r--test/transform/transformation.xsl56
1 files changed, 48 insertions, 8 deletions
diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl
index 1cd424b..99933ba 100644
--- a/test/transform/transformation.xsl
+++ b/test/transform/transformation.xsl
@@ -12,23 +12,63 @@
<xsl:template name="transformer">
<xsl:param name="transformation"/>
+ <xsl:param name="parameters"/>
+
+ <xsl:variable name="stylesheet" select="
+ InputXSLT:read-file(string($transformation))
+ "/>
+
+ <xsl:choose>
+ <xsl:when test="$stylesheet/self::file/@result = 'success'">
+ <transformation result="success">
+ <xsl:copy-of select="
+ InputXSLT:transform(
+ $stylesheet/self::file/*,
+ xalan:nodeset($parameters)
+ )/self::transformation/text()
+ "/>
+ </transformation>
+ </xsl:when>
+ <xsl:otherwise>
+ <transformation result="error">
+ <xsl:copy-of select="$stylesheet/self::file/*"/>
+ </transformation>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="generator">
+ <xsl:param name="transformation"/>
<xsl:param name="target"/>
<xsl:param name="parameters"/>
- <xsl:variable name="command">
- InputXSLT:transform(
- string($transformation),
- string($target),
- xalan:nodeset($parameters)
- )
+ <xsl:variable name="result">
+ <xsl:call-template name="transformer">
+ <xsl:with-param name="transformation" select="$transformation"/>
+ <xsl:with-param name="parameters" select="$parameters"/>
+ </xsl:call-template>
</xsl:variable>
- <xsl:copy-of select="dyn:evaluate($command)"/>
+ <xsl:choose>
+ <xsl:when test="xalan:nodeset($result)/transformation/@result = 'success'">
+ <xsl:variable name="writeResult" select="
+ InputXSLT:write-file(
+ string($target),
+ xalan:nodeset($result)/transformation/text()
+ )
+ "/>
+
+ <transformation result="success" target="{$target}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <transformation result="error" target="{$target}"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template name="implementation">
<xsl:variable name="result">
- <xsl:call-template name="transformer">
+ <xsl:call-template name="generator">
<xsl:with-param name="transformation">test.xsl</xsl:with-param>
<xsl:with-param name="target">test_actual.xml</xsl:with-param>
<xsl:with-param name="parameters">