1XML_PP(1)             User Contributed Perl Documentation            XML_PP(1)
2
3
4

NAME

6       xml_pp - xml pretty-printer
7

SYNOPSYS

9       xml_pp [options] [<files>]
10

DESCRIPTION

12       XML pretty printer using XML::Twig
13

OPTIONS

15       -i[<extension>]
16           edits the file(s) in place, if an extension is provided (no space
17           between "-i" and the extension) then the original file is backed-up
18           with that extension
19
20           The rules for the extension are the same as Perl's (see perldoc
21           perlrun): if the extension includes no "*" then it is appended to
22           the original file name, If the extension does contain one or more
23           "*" characters, then each "*" is replaced with the current
24           filename.
25
26       -s <style>
27           the style to use for pretty printing: none, nsgmls, nice, indented,
28           record, or record_c (see XML::Twig docs for the exact description
29           of those styles), 'indented' by default
30
31       -p <tag(s)>
32           preserves white spaces in tags. You can use several "-p" options or
33           quote the tags if you need more than one
34
35       -e <encoding>
36           use XML::Twig output_encoding (based on Text::Iconv or
37           Unicode::Map8 and Unicode::String) to set the output encoding. By
38           default the original encoding is preserved.
39
40           If this option is used the XML declaration is updated (and created
41           if there was none).
42
43           Make sure that the encoding is supported by the parser you use if
44           you want to be able to process the pretty_printed file (XML::Parser
45           does not support 'latin1' for example, you have to use
46           'iso-8859-1')
47
48       -l  loads the documents in memory instead of outputing them as they are
49           being parsed.
50
51           This prevents a bug (see BUGS) but uses more memory
52
53       -f <file>
54           read the list of files to process from <file>, one per line
55
56       -v  verbose (list the current file being processed)
57
58       --  stop argument processing (to process files that start with -)
59
60       -h  display help
61

EXAMPLES

63         xml_pp foo.xml > foo_pp.xml           # pretty print foo.xml
64         xml_pp < foo.xml > foo_pp.xml         # pretty print from standard input
65
66         xml_pp -v -i.bak *.xml                # pretty print .xml files, with backups
67         xml_pp -v -i'orig_*' *.xml            # backups are named orig_<filename>
68
69         xml_pp -i -p pre foo.xhtml            # preserve spaces in pre tags
70
71         xml_pp -i.bak -p 'pre code' foo.xml   # preserve spaces in pre and code tags
72         xml_pp -i.bak -p pre -p code foo.xml  # same
73
74         xml_pp -i -s record mydb_export.xml   # pretty print using the record style
75
76         xml_pp -e utf8 -i foo.xml             # output will be in utf8
77         xml_pp -e iso-8859-1 -i foo.xml       # output will be in iso-8859-1
78
79         xml_pp -v -i.bak -f lof               # pretty print in place files from lof
80
81         xml_pp -- -i.xml                      # pretty print the -i.xml file
82
83         xml_pp -l foo.xml                     # loads the entire file in memory
84                                               # before pretty printing it
85
86         xml_pp -h                             # display help
87

BUGS

89       Elements with mixed content that start with an embedded element get an
90       extra \n
91
92         <elt><b>b</b>toto<b>bold</b></elt>
93
94       will be output as
95
96         <elt>
97           <b>b</b>toto<b>bold</b></elt>
98
99       Using the "-l" option solves this bug (but uses more memory)
100

TODO

102       update XML::Twig to use Encode with perl 5.8.0
103

AUTHOR

105       Michel Rodriguez <mirod@xmltwig.com>
106
107
108
109perl v5.12.0                      2009-09-22                         XML_PP(1)
Impressum