aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/function/transform.cc2
-rw-r--r--src/function/transform.h2
-rw-r--r--src/transformation_facade.h2
-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
8 files changed, 59 insertions, 48 deletions
diff --git a/src/function/transform.cc b/src/function/transform.cc
index 9cf806f..bc71125 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -31,6 +31,7 @@ inline std::function<void(const ErrorCapacitor::error_cache&)> handleErrors(
namespace InputXSLT {
xercesc::DOMDocument* FunctionTransform::constructDocument(
+ xalan::XSLTInputSource inputSource,
xalan::XSLTInputSource transformationSource,
xalan::XObjectPtr parameterObject
) {
@@ -50,6 +51,7 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
if ( auto transformation = TransformationFacade::try_create(
handleErrors(result),
+ inputSource,
transformationSource,
this->include_resolver_
) ) {
diff --git a/src/function/transform.h b/src/function/transform.h
index ee88529..cda5502 100644
--- a/src/function/transform.h
+++ b/src/function/transform.h
@@ -12,6 +12,7 @@ namespace InputXSLT {
class FunctionTransform : public FunctionBase<
FunctionTransform,
xalan::XSLTInputSource,
+ xalan::XSLTInputSource,
xalan::XObjectPtr
> {
public:
@@ -22,6 +23,7 @@ class FunctionTransform : public FunctionBase<
xercesc::DOMDocument* constructDocument(
xalan::XSLTInputSource,
+ xalan::XSLTInputSource,
xalan::XObjectPtr
);
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index 00a5785..eb134cd 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -20,8 +20,6 @@ class TransformationFacade {
public:
typedef std::unique_ptr<TransformationFacade> ptr;
- class input;
-
template <typename... Arguments>
static ptr try_create(
const std::function<void(const ErrorCapacitor::error_cache&)>&,
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/*
"/>