#!/bin/sh
: ; exec klone $0 "$@"
; The above line finds the klone executable in the $PATH
;;(kdb t)
(setq args (getopts "USAGE: xmlpp [options] [xml_file]
pretty-prints the XML file or stdin on stdout"
("-t" N indent-by "indents one level by N spaces (default: 2)")
("-p" tag preserved-tags "do not reindent these tags,
eg: -t pre -t PRE"
:multiple t
)
("-w" width width "try to wrap at column width (default to 78)")
("-iso" () iso "force encoding to be ISO-8859-1 (otherwise keep the same)")
("-utf8" () utf8 "force encoding to be UTF-8 (otherwise keep the same)")
("-kxf" () kxf-output "outputs in KXF (Koala XML Form)")
("-nh" () noheader "do not print the XML header PI")
))
(if args (setq in (open (0 args))) (setq in *standard-input*))
(setq out *standard-output*)
(if width (setq sxp:width (Int width)))
(setq indent-by (if indent-by (Int indent-by) 2))
(setq sxp:print-indent-string (make-string indent-by))
(defun main (&aux trees)
(kxf:parse-hook t)
(setq trees (sxp:parse in :keep-comments t :keep-PIs t :keep-DTD t
:whitespace-keeping-tags preserved-tags :ignore-entities t :forest t
))
(if kxf-output
(kxf:print trees out :forest t)
(sxp:print trees out
:encoding (if iso "ISO-8859-1" utf8 "UTF-8" sxp:encoding)
:ignore-entities t :standalone sxp:standalone
:raw noheader :forest t
))
)
(main)
;;; EMACS MODES
;;; Local Variables: ***
;;; mode:lisp ***
;;; End: ***
syntax highlighted by Code2HTML, v. 0.9.1