diff options
Diffstat (limited to 'test/transform')
-rw-r--r-- | test/transform/reference.xml | 6 | ||||
-rw-r--r-- | test/transform/test.xsl | 7 | ||||
-rw-r--r-- | test/transform/transformation.xsl | 74 |
3 files changed, 48 insertions, 39 deletions
diff --git a/test/transform/reference.xml b/test/transform/reference.xml index bef43e4..e537bbc 100644 --- a/test/transform/reference.xml +++ b/test/transform/reference.xml @@ -1,4 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <test_case> +<input_tree> +<entry>Hello 1</entry> +<entry>Hello 2</entry> +<entry>Hello 3</entry> +<entry>Hello 4</entry> +</input_tree> <parameter_value>42</parameter_value> </test_case> diff --git a/test/transform/test.xsl b/test/transform/test.xsl index 7d4cac0..7469f92 100644 --- a/test/transform/test.xsl +++ b/test/transform/test.xsl @@ -16,11 +16,14 @@ <xsl:param name="parameters"/> -<xsl:template match="/"> +<xsl:template match="test"> <test_case> <transform_test> + <input_tree> + <xsl:copy-of select="./entry"/> + </input_tree> <parameter_value> - <xsl:value-of select="$parameters/test * 2"/> + <xsl:copy-of select="$parameters/test * 2"/> </parameter_value> </transform_test> </test_case> diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl index ba17981..3582527 100644 --- a/test/transform/transformation.xsl +++ b/test/transform/transformation.xsl @@ -10,63 +10,59 @@ <xsl:import href="[testcase.xsl]"/> +<xsl:template name="writer"> + <xsl:param name="file"/> + <xsl:param name="content"/> + + <xsl:copy-of select="InputXSLT:write-file( + $file, + $content + )"/> +</xsl:template> + <xsl:template name="transformer"> + <xsl:param name="input"/> <xsl:param name="transformation"/> <xsl:param name="parameters"/> - <xsl:variable name="stylesheet" select="InputXSLT:read-file($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:copy-of select="InputXSLT:transform( + $input, + $transformation, + $parameters + )"/> </xsl:template> <xsl:template name="generator"> + <xsl:param name="input"/> <xsl:param name="transformation"/> <xsl:param name="target"/> <xsl:param name="parameters"/> - <xsl:variable name="result"> + <xsl:variable name="transformerResult"> <xsl:call-template name="transformer"> - <xsl:with-param name="transformation" select="$transformation"/> - <xsl:with-param name="parameters" select="$parameters"/> + <xsl:with-param name="input" select="string($input)"/> + <xsl:with-param name="transformation" select="string($transformation)"/> + <xsl:with-param name="parameters" select="xalan:nodeset($parameters)"/> </xsl:call-template> </xsl:variable> - <xsl:choose> - <xsl:when test="xalan:nodeset($result)/transformation/@result = 'success'"> - <xsl:variable name="writeResult" select=" - InputXSLT:write-file( - $target, - xalan:nodeset($result)/transformation/text() - ) - "/> + <xsl:variable name="writerResult"> + <xsl:call-template name="writer"> + <xsl:with-param name="file" select="string($target)"/> + <xsl:with-param name="content" select="xalan:nodeset($transformerResult)/transformation/text()"/> + </xsl:call-template> + </xsl:variable> - <generator result="success" target="{$target}"/> - </xsl:when> - <xsl:otherwise> - <generator result="error" target="{$target}"/> - </xsl:otherwise> - </xsl:choose> + <generator transformation="{$transformation}" target="{$target}"> + <xsl:copy-of select="$transformerResult"/> + <xsl:copy-of select="$writerResult"/> + </generator> </xsl:template> <xsl:template name="implementation"> <xsl:variable name="result"> <xsl:call-template name="generator"> + <xsl:with-param name="input">[test.xml]</xsl:with-param> <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"> @@ -75,8 +71,12 @@ </xsl:call-template> </xsl:variable> + <xsl:variable name="generator" select="xalan:nodeset($result)/generator"/> + <xsl:variable name="transformation" select="$generator/transformation/@result"/> + <xsl:variable name="write" select="$generator/file/@result"/> + <xsl:choose> - <xsl:when test="xalan:nodeset($result)/generator/@result = 'success'"> + <xsl:when test="$transformation = 'success' and $write = 'success'"> <xsl:copy-of select=" InputXSLT:read-file('test_actual.xml')/test_case/transform_test/* "/> |