aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-06-28 18:09:48 +0200
committerAdrian Kummerlaender2014-06-28 18:09:48 +0200
commit299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e (patch)
tree6612a030c8d866da3613973b2dd0aa9811d039ae /test
parentcd2a6c17ab1108e2bf01125b65292014c002db95 (diff)
downloadInputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.tar
InputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.tar.gz
InputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.tar.bz2
InputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.tar.lz
InputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.tar.xz
InputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.tar.zst
InputXSLT-299d0f6fa3fbd1bfd8d1d6d452e9d055973d0e0e.zip
Added input parameter to FunctionTransform
* the external "transform" function now expects a input document as its first parameter ** this input parameter is resolved and passed as input to the transformation ** changed and expanded test case accordingly * because of xalan internal problem this currently only supports input DOMs loaded directly from the fs ** passing result trees or node sets analog to how the transformation may be passed into the function leads to parsing and assert failures ** parsing node-based input DOMs using xalanc::XalanTransformer::parseSource produces errors concerning base entity resolution ** if the error capacitor instance is temporarily disabled it works correctly as long as one doesn't try to access the input document *** this causes a assert failure in the XPath implementation (seems to be related to XALANC-540)
Diffstat (limited to 'test')
-rw-r--r--test/common/test.xml12
-rw-r--r--test/read_xml_file/transformation.xsl2
-rw-r--r--test/transform/reference.xml6
-rw-r--r--test/transform/test.xsl7
-rw-r--r--test/transform/transformation.xsl74
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/*
"/>