forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From addi <a...@rocktreesky.com>
Subject Re: Automated formatting of XML files
Date Tue, 30 Aug 2005 00:45:54 GMT
On Monday August 29 2005 6:33 pm, Diwaker Gupta wrote:
> > So do we all want to work with the same editor for cleaning or do we
> > want to use a cleaning tool and give up our blank lines in XML files?
>
> Many of us are sensitive to our development environments (atleast I
> am!), and forcing a particular choice of editor would not be a good
> idea IMHO :-)

Yes, I agree.  I actually didn't get to fully think out and write what I 
wanted to say because I realised I was late for my train so I just signed and 
hit send. :p
>
> The reason I don't want to use any IDE for this cleanup task, and
> instead a tool like Tidy, is that things can be automated much more
> easily. We can schedule clean-ups periodically, add targets to the
> build process to do it automatically -- there's a lot of flexibility
> in how we go about it.
>
> Using an XSL transform for cleanup is attractive because we don't need
> any external utility; Forrest is all about XML processing anyywas :-)
>
> So I'm +1 on either Tidy or XSL (personally, I prefer Tidy since in my
> experience its much smarter and faster). -0 on jEdit plugins and such.

I would say that I am +1 on XSL, +0 on Tidy and -0 on any IDE/editor.  I am 
doing more research to see if I can come up with a solution that leaves the 
blank lines in.  Turns out that Tidy has a config option vertical-spacing, 
but that puts a blank line after every element closing tag so it ends up 
looking pretty weird and adding lots of lines we wouldn't want.  You can try 
it out by adding "vertical-spacing=yes" to your config.txt file.  I am mainly 
not so keen on tidy at the moment because I am having trouble with it not 
wanting to process due to errors that need to be resolved and it is giving me 
a headache to figure out what the hell it wants from me, whereas the XSL just 
works and stays "native" to Forrest, as it were.

I wish there was a way in the xsl to preserve-space a blank line.  Any xml 
experts out there have any ideas?  I don't know diddly about xsl.

Here is the basic XSL for cleanup:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xalan="http://xml.apache.org/xalan"
                version="1.0">

  <xsl:output method="xml"
              indent="yes"
              xalan:indent-amount="2"/>

  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
    <xsl:copy-of select="."/>
  </xsl:template>

</xsl:stylesheet>

- Addi

Mime
View raw message