개요
xml 파일을 schema validation 해주고 정렬해 주고 예쁘게 포맷팅 해주는 cmd 기반 유틸리티이다. (astyle 는 xml 파일을 처리 못함)
설치
RHEL/CentOS
yum install libxml2
Windows
https://code.google.com/p/xmllint/downloads/list 에서 다운로드
사용
cmd 에서 사용
--format --recover 옵션을 추가한다.
xmllint --format --recover pom.xml > new-pom.xml
vim 에 연결
.vimrc 에 다음 내용을 추가하면 .xml 파일 로딩시 자동으로 xmllint formatting 을 수행한다.
au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null"
bash 의 function 으로 추가
Qxmllint a.xml 을 실행하면 자동으로 포맷팅 수행
function Qxmllint { if [ $# != 1 ]; then echo "parameter need!"; else cp $1 ${1}.org /usr/bin/xmllint --format --recover ${1}.org > ${1} fi;
See Also
- Artistic Style - Source code Indenter, Formatter, and Beautifier, 각종 소스 파일을 들여쓰기, 포맷팅, 예쁘게 만들어 주기
- Online SQL formatting, indenting service
- online json beautifier site 비교
Ref