aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-24 23:20:54 +0200
committerAdrian Kummerlaender2014-08-24 23:20:54 +0200
commit8aca155ea840cb3064d58b78508195be3bbcfdb3 (patch)
treedebadd89dc44eb5ab8b04be4806ebc8787325942
parent095905fbc32c971b8847bf5c3dd32f3409c9b46b (diff)
downloadblog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.tar
blog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.tar.gz
blog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.tar.bz2
blog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.tar.lz
blog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.tar.xz
blog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.tar.zst
blog.kummerlaender.eu-8aca155ea840cb3064d58b78508195be3bbcfdb3.zip
Implemented basic generation summary
* "summarize.xsl" processes the result-tree of "process.xsl" and outputs a basic plain-text summary ** the plain-text summary is returned as the sole result of calling "make.xsl" * this approach should be easily extensible into i.e. a verbose version in the future * unraveled "make.xsl" structure into separate variables
-rw-r--r--make.xsl63
-rw-r--r--plan.xsl2
-rw-r--r--process.xsl14
-rw-r--r--summarize.xsl37
-rw-r--r--utility/helper.xsl10
5 files changed, 85 insertions, 41 deletions
diff --git a/make.xsl b/make.xsl
index 159e232..f073910 100644
--- a/make.xsl
+++ b/make.xsl
@@ -11,11 +11,9 @@
method="xml"
omit-xml-declaration="yes"
encoding="UTF-8"
- indent="yes"
+ indent="no"
/>
-<xsl:include href="utility/helper.xsl"/>
-
<xsl:template name="generate">
<xsl:param name="input"/>
<xsl:param name="transformation"/>
@@ -30,33 +28,42 @@
<xsl:variable name="source">source</xsl:variable>
<xsl:variable name="target">target</xsl:variable>
- <xsl:call-template name="generate">
- <xsl:with-param name="input">
+ <xsl:variable name="list_source">
+ <datasource>
+ <xsl:value-of select="$source"/>
+ </datasource>
+ </xsl:variable>
+
+ <xsl:variable name="plan_source">
+ <datasource>
<xsl:call-template name="generate">
- <xsl:with-param name="input">
- <xsl:call-template name="merge_datasource">
- <xsl:with-param name="main">
- <xsl:call-template name="generate">
- <xsl:with-param name="input">
- <datasource>
- <xsl:value-of select="$source"/>
- </datasource>
- </xsl:with-param>
- <xsl:with-param name="transformation">list.xsl</xsl:with-param>
- </xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="support">
- <meta>
- <source><xsl:value-of select="$source"/></source>
- <target><xsl:value-of select="$target"/></target>
- </meta>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="transformation">plan.xsl</xsl:with-param>
+ <xsl:with-param name="input" select="$list_source"/>
+ <xsl:with-param name="transformation">list.xsl</xsl:with-param>
</xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="transformation">process.xsl</xsl:with-param>
+ <meta>
+ <source><xsl:value-of select="$source"/></source>
+ <target><xsl:value-of select="$target"/></target>
+ </meta>
+ </datasource>
+ </xsl:variable>
+
+ <xsl:variable name="process_source">
+ <xsl:call-template name="generate">
+ <xsl:with-param name="input" select="$plan_source"/>
+ <xsl:with-param name="transformation">plan.xsl</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="summarize_source">
+ <xsl:call-template name="generate">
+ <xsl:with-param name="input" select="$process_source"/>
+ <xsl:with-param name="transformation">process.xsl</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:call-template name="generate">
+ <xsl:with-param name="input" select="$summarize_source"/>
+ <xsl:with-param name="transformation">summarize.xsl</xsl:with-param>
</xsl:call-template>
</xsl:template>
diff --git a/plan.xsl b/plan.xsl
index 6754d14..2401019 100644
--- a/plan.xsl
+++ b/plan.xsl
@@ -12,7 +12,7 @@
method="xml"
omit-xml-declaration="yes"
encoding="UTF-8"
- indent="yes"
+ indent="no"
/>
<xsl:include href="utility/datasource.xsl"/>
diff --git a/process.xsl b/process.xsl
index a054965..a0c1895 100644
--- a/process.xsl
+++ b/process.xsl
@@ -12,10 +12,10 @@
method="xml"
omit-xml-declaration="yes"
encoding="UTF-8"
- indent="yes"
+ indent="no"
/>
-<xsl:include href="utility/helper.xsl"/>
+<xsl:include href="utility/datasource.xsl"/>
<xsl:template name="create_link">
<xsl:param name="from"/>
@@ -53,6 +53,16 @@
</subtask>
</xsl:template>
+<xsl:template name="merge_datasource">
+ <xsl:param name="main"/>
+ <xsl:param name="support"/>
+
+ <datasource>
+ <xsl:copy-of select="$main"/>
+ <xsl:copy-of select="$support"/>
+ </datasource>
+</xsl:template>
+
<xsl:template name="resolve_target">
<xsl:param name="prefix"/>
<xsl:param name="target"/>
diff --git a/summarize.xsl b/summarize.xsl
new file mode 100644
index 0000000..78f89fd
--- /dev/null
+++ b/summarize.xsl
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output
+ method="xml"
+ omit-xml-declaration="yes"
+ encoding="UTF-8"
+ indent="no"
+/>
+
+<xsl:template match="datasource">
+ <xsl:variable name="total_count" select="count(task)"/>
+ <xsl:variable name="success_count" select="count(task[@result = 'success'])"/>
+
+ <xsl:text>Tasks processed: </xsl:text>
+ <xsl:value-of select="$total_count"/>
+ <xsl:text>&#xa;</xsl:text>
+ <xsl:text>Tasks successful: </xsl:text>
+ <xsl:value-of select="$success_count"/>
+ <xsl:text>&#xa;</xsl:text>
+
+ <xsl:text>▶ Generation </xsl:text>
+ <xsl:choose>
+ <xsl:when test="$total_count = $success_count">
+ <xsl:text>successful</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>failed</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>.&#xa;</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/utility/helper.xsl b/utility/helper.xsl
index 0ebc15d..84b6b31 100644
--- a/utility/helper.xsl
+++ b/utility/helper.xsl
@@ -7,16 +7,6 @@
exclude-result-prefixes="xalan InputXSLT"
>
-<xsl:template name="merge_datasource">
- <xsl:param name="main"/>
- <xsl:param name="support"/>
-
- <datasource>
- <xsl:copy-of select="$main"/>
- <xsl:copy-of select="$support"/>
- </datasource>
-</xsl:template>
-
<xsl:template name="formatter">
<xsl:param name="format"/>
<xsl:param name="source"/>