Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Formatter for ant scripts ?

Formatter for ant scripts ?

2007-07-09       - By Prashant Reddy
Reply:     <<     11  

On Mon, 2007-07-09 at 13:48 +0200, Rebhan, Gilbert wrote:
> Beside that, there maybe a solution with xslt, but i'm no specialist
> for xslt !?
>

I have used the following xsl successfully to pretty print a XML.

It should not hard to hook this XSL up with xslt task.

Hope this helps

<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" indent="yes"/>
   <xsl:param name="indent-increment" select="'   '"/>

   <xsl:template match="*">
       <xsl:param name="indent" select="'&#xA;'"/>

       <xsl:value-of select="$indent" />
       <xsl:copy>
           <xsl:copy-of select="@*"/>
           <xsl:apply-templates>
               <xsl:with-param name="indent"
                   select="concat($indent, $indent-increment)"/>
           </xsl:apply-templates>
           <xsl:if test="*">
               <xsl:value-of select="$indent"/>
           </xsl:if>
       </xsl:copy>
   </xsl:template>

   <xsl:template match="comment()|processing-instruction()">
       <xsl:copy/>
   </xsl:template>

   <!-- WARNING: this is dangerous. Handle with care -->
   <xsl:template match="text()[normalize-space(.)='']"/>

</xsl:stylesheet>
--

-Prashant

Don't upload, just share : www.dekoh.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.