diff options
author | Adrian Kummerlaender | 2014-06-27 21:35:46 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-06-27 21:35:46 +0200 |
commit | a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6 (patch) | |
tree | 17ccde0cd5fa5a4f632aec7a0ff11ed954e2b93f /test | |
parent | 266b408ee53b9bc7db2b1a5c92e62adfd2af6def (diff) | |
download | InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.tar InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.tar.gz InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.tar.bz2 InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.tar.lz InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.tar.xz InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.tar.zst InputXSLT-a8be7f7dde5cf0d51026de0e6bc4d0f59f41c4b6.zip |
Updated README.md and added "write-file" test case
* slightly improved FunctionTransform test case utility templates
Diffstat (limited to 'test')
-rw-r--r-- | test/read_directory/reference.xml | 3 | ||||
-rw-r--r-- | test/transform/transformation.xsl | 14 | ||||
-rw-r--r-- | test/write_file/reference.xml | 3 | ||||
-rw-r--r-- | test/write_file/transformation.xsl | 26 |
4 files changed, 38 insertions, 8 deletions
diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml index 4c1000b..b2eac35 100644 --- a/test/read_directory/reference.xml +++ b/test/read_directory/reference.xml @@ -28,4 +28,7 @@ <item type="directory"> <name>transform</name> </item> +<item type="directory"> +<name>write_file</name> +</item> </test_case> diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl index 99933ba..ba17981 100644 --- a/test/transform/transformation.xsl +++ b/test/transform/transformation.xsl @@ -14,9 +14,7 @@ <xsl:param name="transformation"/> <xsl:param name="parameters"/> - <xsl:variable name="stylesheet" select=" - InputXSLT:read-file(string($transformation)) - "/> + <xsl:variable name="stylesheet" select="InputXSLT:read-file($transformation)"/> <xsl:choose> <xsl:when test="$stylesheet/self::file/@result = 'success'"> @@ -53,15 +51,15 @@ <xsl:when test="xalan:nodeset($result)/transformation/@result = 'success'"> <xsl:variable name="writeResult" select=" InputXSLT:write-file( - string($target), + $target, xalan:nodeset($result)/transformation/text() ) "/> - <transformation result="success" target="{$target}"/> + <generator result="success" target="{$target}"/> </xsl:when> <xsl:otherwise> - <transformation result="error" target="{$target}"/> + <generator result="error" target="{$target}"/> </xsl:otherwise> </xsl:choose> </xsl:template> @@ -78,13 +76,13 @@ </xsl:variable> <xsl:choose> - <xsl:when test="xalan:nodeset($result)/transformation/@result = 'success'"> + <xsl:when test="xalan:nodeset($result)/generator/@result = 'success'"> <xsl:copy-of select=" InputXSLT:read-file('test_actual.xml')/test_case/transform_test/* "/> </xsl:when> <xsl:otherwise> - <xsl:copy-of select="xalan:nodeset($result)/transformation/*"/> + <xsl:copy-of select="xalan:nodeset($result)/generator/*"/> </xsl:otherwise> </xsl:choose> </xsl:template> diff --git a/test/write_file/reference.xml b/test/write_file/reference.xml new file mode 100644 index 0000000..ba10cf5 --- /dev/null +++ b/test/write_file/reference.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<test_case>Hello world! +</test_case> diff --git a/test/write_file/transformation.xsl b/test/write_file/transformation.xsl new file mode 100644 index 0000000..f65e62d --- /dev/null +++ b/test/write_file/transformation.xsl @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xalan="http://xml.apache.org/xalan" + xmlns:InputXSLT="function.inputxslt.application" + exclude-result-prefixes="InputXSLT xalan" +> + +<xsl:import href="[testcase.xsl]"/> + +<xsl:template name="implementation"> + <xsl:variable name="result" select="InputXSLT:write-file('test.txt', 'Hello world!')"/> + <xsl:variable name="content" select="InputXSLT:read-file('test.txt')"/> + + <xsl:choose> + <xsl:when test="$content/self::file/@result = 'success'"> + <xsl:value-of select="$content/self::file/text()"/> + </xsl:when> + <xsl:otherwise> + Error during file io + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> |