aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-26 20:13:11 +0200
committerAdrian Kummerländer2014-05-26 20:13:11 +0200
commit6efa3385ae0fab5f7b6e3a113d1da18cfbed8591 (patch)
tree043220ff989ef5e17b04286e510b9c6984e96ae5
parent86f8e73299e86b65affc1a71610dd061fa13bf5c (diff)
downloadInputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.tar
InputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.tar.gz
InputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.tar.bz2
InputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.tar.lz
InputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.tar.xz
InputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.tar.zst
InputXSLT-6efa3385ae0fab5f7b6e3a113d1da18cfbed8591.zip
Added "external-text-formatter" test case
* test case requires markdown.pl formatter to be available in "/usr/bin/" * updated README.md to mention "external-text-formatter" instead of "execute" * updated "read-directory" test case reference file * included library resolution test into "read-file" and "read-xml-file" test cases
-rw-r--r--README.md2
-rw-r--r--test/external_text_formatter/reference.xml33
-rw-r--r--test/external_text_formatter/test.md28
-rw-r--r--test/external_text_formatter/transformation.xsl32
-rw-r--r--test/read_directory/reference.xml1
-rw-r--r--test/read_file/transformation.xsl2
-rw-r--r--test/read_xml_file/transformation.xsl2
7 files changed, 97 insertions, 3 deletions
diff --git a/README.md b/README.md
index e051979..6c36e06 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Contrary to popular opinion I actually like XSLT as a content transformation lan
- external `read-xml-file` function for read-only access to XML files
- external `read-directory` function for read-only directory traversal
- external `transform` function for executing transformations inside transformations
-- external `execute` function for executing external applications and capturing their output
+- external `external-text-formatter` function for executing text formatters and capturing their XML output
## Requirements:
diff --git a/test/external_text_formatter/reference.xml b/test/external_text_formatter/reference.xml
new file mode 100644
index 0000000..a98b3d8
--- /dev/null
+++ b/test/external_text_formatter/reference.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test_case>
+<h1>Markdown Test</h1>
+<p>
+<strong>Lorem ipsum</strong> dolor sit amet, <em>consectetur</em> adipisicing elit, sed do <code>eiusmod</code> tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
+<blockquote>
+ <p>Duis aute irure dolor in reprehenderit in voluptate
+velit esse cillum dolore eu fugiat nulla pariatur.</p>
+</blockquote>
+<p>Excepteur sint <strong>occaecat</strong> cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+<ul>
+<li>Test 1</li>
+<li>Test 2</li>
+<li>Test 3</li>
+<li>Test 4</li>
+</ul>
+<p>Test Test Test</p>
+<pre>
+<code>template &lt;
+ typename Target,
+ std::size_t Index = 0,
+ typename Current = std::tuple&lt;&gt;,
+ enable_if&lt;Index == std::tuple_size&lt;Target&gt;::value&gt; = 0
+&gt;
+inline Target construct(
+ const xalan::XPathExecutionContext::XObjectArgVectorType&amp;,
+ Current&amp;&amp; current
+) {
+ return current;
+}
+</code>
+</pre>
+</test_case>
diff --git a/test/external_text_formatter/test.md b/test/external_text_formatter/test.md
new file mode 100644
index 0000000..9402e4f
--- /dev/null
+++ b/test/external_text_formatter/test.md
@@ -0,0 +1,28 @@
+# Markdown Test
+
+__Lorem ipsum__ dolor sit amet, _consectetur_ adipisicing elit, sed do `eiusmod` tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+
+> Duis aute irure dolor in reprehenderit in voluptate
+> velit esse cillum dolore eu fugiat nulla pariatur.
+
+Excepteur sint **occaecat** cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+* Test 1
+* Test 2
+* Test 3
+* Test 4
+
+Test Test Test
+
+ template <
+ typename Target,
+ std::size_t Index = 0,
+ typename Current = std::tuple<>,
+ enable_if<Index == std::tuple_size<Target>::value> = 0
+ >
+ inline Target construct(
+ const xalan::XPathExecutionContext::XObjectArgVectorType&,
+ Current&& current
+ ) {
+ return current;
+ }
diff --git a/test/external_text_formatter/transformation.xsl b/test/external_text_formatter/transformation.xsl
new file mode 100644
index 0000000..00fe3b3
--- /dev/null
+++ b/test/external_text_formatter/transformation.xsl
@@ -0,0 +1,32 @@
+<?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:include href="[testcase.xsl]"/>
+
+<xsl:template name="formatter">
+ <xsl:param name="source"/>
+
+ <xsl:variable name="command">
+ InputXSLT:external-text-formatter(
+ '/usr/bin/markdown',
+ $source
+ )
+ </xsl:variable>
+
+ <xsl:copy-of select="dyn:evaluate($command)/output/*"/>
+</xsl:template>
+
+<xsl:template name="implementation">
+ <xsl:call-template name="formatter">
+ <xsl:with-param name="source" select="InputXSLT:read-file('test.md')"/>
+ </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml
index a7192ea..94e639e 100644
--- a/test/read_directory/reference.xml
+++ b/test/read_directory/reference.xml
@@ -2,6 +2,7 @@
<test_case>
<item>common</item>
<item>default_params</item>
+<item>external_text_formatter</item>
<item>read_directory</item>
<item>read_file</item>
<item>read_xml_file</item>
diff --git a/test/read_file/transformation.xsl b/test/read_file/transformation.xsl
index e17734e..f773e0e 100644
--- a/test/read_file/transformation.xsl
+++ b/test/read_file/transformation.xsl
@@ -9,7 +9,7 @@
<xsl:include href="[testcase.xsl]"/>
<xsl:template name="implementation">
- <xsl:value-of select="InputXSLT:read-file('../common/test.txt')"/>
+ <xsl:value-of select="InputXSLT:read-file('test.txt')"/>
</xsl:template>
</xsl:stylesheet>
diff --git a/test/read_xml_file/transformation.xsl b/test/read_xml_file/transformation.xsl
index e0a3794..2a6c5e5 100644
--- a/test/read_xml_file/transformation.xsl
+++ b/test/read_xml_file/transformation.xsl
@@ -9,7 +9,7 @@
<xsl:include href="[testcase.xsl]"/>
<xsl:template name="implementation">
- <xsl:for-each select="InputXSLT:read-xml-file('../common/test.txt')/tester/eintrag">
+ <xsl:for-each select="InputXSLT:read-xml-file('test.txt')/tester/eintrag">
<item><xsl:value-of select="."/></item>
</xsl:for-each>
</xsl:template>