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

NAME

6         xml_split - cut a big XML file into smaller chunks
7

DESCRIPTION

9       "xml_split" takes a (presumably big) XML file and split it in several
10       smaller files. The memory used is the memory needed for the biggest
11       chunk (ie memory is reused for each new chunk).
12
13       It can split at a given level in the tree (the default, splits children
14       of the root), or on a condition (using the subset of XPath understood
15       by XML::Twig, so "section" or "/doc/section").
16
17       Each generated file is replaced by a processing instruction that will
18       allow "xml_merge" to rebuild the original document. The processing
19       instruction format is "<?merge subdocs=[01] :<filename> ?>"
20
21       File names are <file>-<nb>.xml, with <file>-00.xml holding the main
22       document.
23

OPTIONS

25       -l <level>
26           level to cut at: 1 generates a file for each child of the root, 2
27           for each grand child
28
29           defaults to 1
30
31       -c <condition>
32           generate a file for each element that passes the condition
33
34           xml_split -c <section> will put each "section" element in its own
35           file (nested sections are handled too)
36
37           Note that at the moment this option is a lot slower than using "-l"
38
39       -s <size>
40           generates files of (approximately) <size>. The content of each file
41           is enclosed in a new element ("xml_split::root"), so it's well-
42           formed XML.  The size can be given in bytes, Kb, Mb or Gb.
43
44       -g <nb>
45           groups <nb> elements in a single file. The content of each file is
46           enclosed in a new element ("xml_split::root"), so it's well-formed
47           XML.
48
49       -b <name>
50           base name for the output, files will be named <base>-<nb><.ext>
51
52           <nb> is a sequence number, see below "--nb_digits" <ext> is an
53           extension, see below "--extension"
54
55           defaults to the original file name (if available) or "out" (if
56           input comes from the standard input)
57
58       -n <nb>
59           number of digits in the sequence number for each file
60
61           if more digits than <nb> are needed, then they are used: if
62           "--nb_digits 2" is used and 112 files are generated they will be
63           named "<file>-01.xml" to "<file>-112.xml"
64
65           defaults to 2
66
67       -e <ext>
68           extension to use for generated files
69
70           defaults to the original file extension or ".xml"
71
72       -i  use XInclude elements instead of Processing Instructions to mark
73           where sub files need to be included
74
75       -v  verbose output
76
77           Note that this option can slow down processing considerably (by an
78           order of magnitude) when generating lots of small documents
79
80       -V  outputs version and exit
81
82       -h  short help
83
84       -m  man (requires pod2text to be in the path)
85

EXAMPLES

87         xml_split foo.xml             # split at level 1
88         xml_split -l 2 foo.xml        # split at level 2
89         xml_split -c section foo.xml  # a file is generated for each section element
90                                       # nested sections are split properly
91

SEE ALSO

93       XML::Twig, xml_merge
94

TODO

96       optimize the code
97           any idea welcome! I have already implemented most of what I thought
98           would improve performances.
99
100       provide other methods that PIs to keep merge information
101           XInclude is a good candidate (alpha support added in 0.04).
102
103           using entities, which would seem the natural way to do it, doesn't
104           work, as they make it impossible to have both the main document and
105           the sub docs to be well-formed if the sub docs include sub-sub docs
106           (you can't have entity declarations in an entity)
107

AUTHOR

109       Michel Rodriguez <mirod@cpan.org>
110

LICENSE

112       This tool is free software; you can redistribute it and/or modify it
113       under the same terms as Perl itself.
114
115
116
117perl v5.10.1                      2009-10-11                      XML_SPLIT(1)
Impressum