ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant Reddy <prash...@pramati.com>
Subject RE: Formatter for ant scripts ?
Date Mon, 09 Jul 2007 12:42:32 GMT
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@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message