aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-07-12 16:15:42 +0200
committerAdrian Kummerlaender2014-07-12 16:15:42 +0200
commit086779c6d3d40f244b6aafd6d402fd29b921a735 (patch)
treec606a54c92f9b638797a95437adfe0a6fee05030 /test
parent141725d681dd69f77e993c3d59d613d1ad7014f9 (diff)
downloadInputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.tar
InputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.tar.gz
InputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.tar.bz2
InputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.tar.lz
InputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.tar.xz
InputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.tar.zst
InputXSLT-086779c6d3d40f244b6aafd6d402fd29b921a735.zip
Implemented external "generate" function
* this function essentially provides the same functionality as FunctionTransform with the addition of directly committing the result to the filesystem ** this is needed if one wants to generate doctype-containing transformations from inside a transformation as "write-file" is not able to infer the doctype of a given xalan::XalanNode pointer ** this is a integral limitation of (at least) XSLT 1.0 as implemented in Apache Xalan *** a document can of course only have a single document type *** e.g. we can not include a doctype node in the result tree of FunctionTransform * implemented test case for FunctionGenerate * transformation "test.xsl" is shared between the FunctionTransform and FunctionGenerate test cases * modified README.md accordingly
Diffstat (limited to 'test')
-rw-r--r--test/common/test.xsl (renamed from test/transform/test.xsl)0
-rw-r--r--test/generate/reference.xml10
-rw-r--r--test/generate/transformation.xsl58
-rw-r--r--test/read_directory/reference.xml3
-rw-r--r--test/transform/transformation.xsl2
5 files changed, 72 insertions, 1 deletions
diff --git a/test/transform/test.xsl b/test/common/test.xsl
index a9f04a5..a9f04a5 100644
--- a/test/transform/test.xsl
+++ b/test/common/test.xsl
diff --git a/test/generate/reference.xml b/test/generate/reference.xml
new file mode 100644
index 0000000..1c702e8
--- /dev/null
+++ b/test/generate/reference.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test_case>
+<input_entries>
+<entry>Hello 1</entry>
+<entry>Hello 2</entry>
+<entry>Hello 3</entry>
+<entry>Hello 4</entry>
+</input_entries>
+<parameter_value>42</parameter_value>
+</test_case>
diff --git a/test/generate/transformation.xsl b/test/generate/transformation.xsl
new file mode 100644
index 0000000..6e3d88b
--- /dev/null
+++ b/test/generate/transformation.xsl
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:dyn="http://exslt.org/dynamic"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:InputXSLT="function.inputxslt.application"
+ exclude-result-prefixes="dyn xalan InputXSLT"
+>
+
+<xsl:import href="[testcase.xsl]"/>
+
+<xsl:template name="generator">
+ <xsl:param name="input"/>
+ <xsl:param name="transformation"/>
+ <xsl:param name="target"/>
+
+ <xsl:copy-of select="InputXSLT:generate(
+ $input,
+ string($transformation),
+ string($target)
+ )"/>
+</xsl:template>
+
+<xsl:template name="implementation">
+ <xsl:variable name="result">
+ <xsl:call-template name="generator">
+ <xsl:with-param name="input">
+ <test>
+ <entries>
+ <entry>Hello 1</entry>
+ <entry>Hello 2</entry>
+ <entry>Hello 3</entry>
+ <entry>Hello 4</entry>
+ </entries>
+ <parameter>
+ <test>21</test>
+ </parameter>
+ </test>
+ </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:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="generation" select="xalan:nodeset($result)/generation"/>
+
+ <xsl:choose>
+ <xsl:when test="$generation/@result = 'success'">
+ <xsl:copy-of select="InputXSLT:read-file('test_actual.xml')/test_case/transform_test/*"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$generation/*"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml
index 7d63a85..d2d9d1b 100644
--- a/test/read_directory/reference.xml
+++ b/test/read_directory/reference.xml
@@ -14,6 +14,9 @@
<name>external_text_formatter</name>
</item>
<item type="directory">
+<name>generate</name>
+</item>
+<item type="directory">
<name>read_directory</name>
</item>
<item type="directory">
diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl
index 7cfb8f9..247a4c6 100644
--- a/test/transform/transformation.xsl
+++ b/test/transform/transformation.xsl
@@ -36,7 +36,7 @@
</parameter>
</test>
</xsl:with-param>
- <xsl:with-param name="transformation">test.xsl</xsl:with-param>
+ <xsl:with-param name="transformation">[test.xsl]</xsl:with-param>
</xsl:call-template>
</xsl:variable>