Created
June 3, 2010 01:34
-
-
Save osima/423299 to your computer and use it in GitHub Desktop.
XML文書をコンパクト形式に変換
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// [使い方] | |
// groovy -c UTF-8 -i src.xml -o compact.xml | |
// | |
// [機能] | |
// src.xml のインデント・改行等を削除してコンパクト形式に変換する/Pretty形式にも変換可能 | |
// | |
// [依存] | |
// - jdom.jar | |
// - CmdProc.groovy | |
// | |
import org.jdom.input.* | |
import org.jdom.output.* | |
def ENC = 'UTF-8' | |
def cmdp = new CmdProc(args) | |
def doc = new SAXBuilder().build( cmdp.inputFile ) | |
def w = cmdp.outputFile.newWriter('UTF-8') | |
//def xmlout = new XMLOutputter( Format.getPrettyFormat() ) | |
def xmlout = new XMLOutputter( Format.getCompactFormat() ) | |
xmlout.output(doc,w) | |
w.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment