diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/common/test.xml | 12 | ||||
-rw-r--r-- | test/read_xml_file/transformation.xsl | 2 | ||||
-rw-r--r-- | test/transform/reference.xml | 6 | ||||
-rw-r--r-- | test/transform/test.xsl | 7 | ||||
-rw-r--r-- | test/transform/transformation.xsl | 74 |
5 files changed, 55 insertions, 46 deletions
diff --git a/test/common/test.xml b/test/common/test.xml index 046a6ef..f2739af 100644 --- a/test/common/test.xml +++ b/test/common/test.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> -<tester> - <eintrag>Hello 1</eintrag> - <eintrag>Hello 2</eintrag> - <eintrag>Hello 3</eintrag> - <eintrag>Hello 4</eintrag> -</tester> +<test> + <entry>Hello 1</entry> + <entry>Hello 2</entry> + <entry>Hello 3</entry> + <entry>Hello 4</entry> +</test> diff --git a/test/read_xml_file/transformation.xsl b/test/read_xml_file/transformation.xsl index cd06c46..083cb12 100644 --- a/test/read_xml_file/transformation.xsl +++ b/test/read_xml_file/transformation.xsl @@ -14,7 +14,7 @@ <xsl:choose> <xsl:when test="$result/self::file/@result = 'success'"> - <xsl:for-each select="$result/self::file/tester/eintrag"> + <xsl:for-each select="$result/self::file/test/entry"> <item><xsl:value-of select="."/></item> </xsl:for-each> </xsl:when> 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/* "/> |