Author: hibou
Date: Mon Feb 22 22:22:44 2010
New Revision: 915092
URL: http://svn.apache.org/viewvc?rev=915092&view=rev
Log:
transform a condition of a fail task into a groovy if
Modified:
ant/sandbox/groovyfront/xml2groovy.xsl
Modified: ant/sandbox/groovyfront/xml2groovy.xsl
URL:
http://svn.apache.org/viewvc/ant/sandbox/groovyfront/xml2groovy.xsl?rev=915092&r1=915091&r2=915092&view=diff
==============================================================================
--- ant/sandbox/groovyfront/xml2groovy.xsl (original)
+++ ant/sandbox/groovyfront/xml2groovy.xsl Mon Feb 22 22:22:44 2010
@@ -129,8 +129,23 @@
<apply-templates select="." />
</template>
+ <!-- transform a condition of a fail task into a groovy if -->
+ <template match="*[local-name() = 'fail' and count(condition) != 0]">
+ <text>if (</text>
+ <apply-templates select="condition/*" mode="condition" />
+ <text>) {
+</text>
+ <value-of select="local-name()" />
+ <text>(</text>
+ <call-template name="process-args" />
+ <call-template name="process-text-content" />
+ <text>)
+}</text>
+ </template>
+
<!-- generic xml to groovy transformer -->
<template match="*">
+ <param name="recursive" select="'true'" />
<!-- if there is some namespace, append the use of the grooyns -->
<variable name="nsPrefix" select="substring-before(name(), ':')" />
@@ -157,8 +172,20 @@
</choose>
<text>(</text>
+ <call-template name="process-args" />
+ <call-template name="process-text-content" />
+ <text>)</text>
- <!-- process the XML attributes -->
+ <!-- process the children recursively -->
+ <if test="$recursive and count(child::*) != 0">
+ <text> {</text>
+ <apply-templates select="child::node()" />
+ <text>}</text>
+ </if>
+ </template>
+
+ <!-- process the XML attributes -->
+ <template name="process-args">
<for-each select="@*">
<value-of select="local-name()" />
<text>: '</text>
@@ -180,8 +207,10 @@
<text>, </text>
</if>
</for-each>
+ </template>
- <!-- process the content in the XML element if not only spaces -->
+ <!-- process the content in the XML element if not only spaces -->
+ <template name="process-text-content">
<if test="string-length(normalize-space(node())) != 0">
<if test="count(@*) != 0">
<text>, </text>
@@ -204,15 +233,6 @@
</otherwise>
</choose>
</if>
-
- <text>)</text>
-
- <!-- process the children by recursively -->
- <if test="count(child::*) != 0">
- <text> {</text>
- <apply-templates select="child::node()" />
- <text>}</text>
- </if>
</template>
<!-- escape simple quote to be output in attributes (always surrounded by
simple quotes) -->