indentation in citation styles

A bit of a technical question, but I figured might as well ask it here.
Citation styles usually are hierarchically indented to make the xml easier to read.
Those indentations can get messed up for a number of reasons, especially when the style is edited in the test panel.

The question is, what's the fastest way to get the indentation back?
The only way I'm currently able to do that is in emacs nxml mode to go line by line and press tab. That seems very inefficient and silly - there has got to be a better way? Tips, tools, commandlines?
  • I'm a vim person, but there you can do =G with the cursor at the top of the file.
  • Google for "xml tidy" (there are a lot of apps that do this, many with similar names that you can use either online or in your text editor or as a standalone executable).
  • edited February 16, 2011
    thanks, exactly what i was looking for. I have that working well from the comandline with
    cat ugly.csl |tidy -utf8 -xml -w 255 -i -c -q -asxml > pretty.csl

    I'm still fighting with the gedit plugin

    edit: If anyone cares: I've gotten a nice and workable solution by using the external tools plugin for gedit, and assigning a shortcut to
    tidy -utf8 -xml -w 255 -i -c -q -asxml
    the tidy plugin for html is useless.
  • OK - last one (hopefully).
    The above strips out all spaces before quotation marks - quite unfortunate for Zotero.
    tidy -utf8 -xml -i -q -w --literal-attributes true
    seems to do it.
  • edited February 22, 2011
    Or even easier (and probably more correct, since it's an xml tool):

    $ xmllint --format foo.csl
    See also this blog post for an nxml mode tweak (though I've not used it).

This is an old discussion that has not been active in a long time. Instead of commenting here, you should start a new discussion. If you think the content of this discussion is still relevant, you can link to it from your new discussion.