aboutsummaryrefslogtreecommitdiff
path: root/test/external_text_formatter/transformation.xsl
blob: 2026302f890c66757122f0c07531df81993ffa41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?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="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)"/>
</xsl:template>

<xsl:template name="implementation">
	<xsl:variable name="result">
		<xsl:call-template name="formatter">
			<xsl:with-param name="source" select="InputXSLT:read-file('[test.md]')"/>
		</xsl:call-template>
	</xsl:variable>

	<xsl:choose>
		<xsl:when test="xalan:nodeset($result)/output/@result = 'success'">
			<xsl:copy-of select="xalan:nodeset($result)/output/*"/>
		</xsl:when>
		<xsl:otherwise>
			Failure during external text formatting
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

</xsl:stylesheet>