1XML_SPLIT(1) User Contributed Perl Documentation XML_SPLIT(1)
2
3
4
6 xml_split - cut a big XML file into smaller chunks
7
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
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 -b <name>
40 base name for the output, files will be named <base>-<nb><.ext>
41
42 <nb> is a sequence number, see below "--nb_digits" <ext> is an
43 extension, see below "--extension"
44
45 defaults to the original file name (if available) or "out" (if
46 input comes from the standard input)
47
48 -n <nb>
49 number of digits in the sequence number for each file
50
51 if more digits than <nb> are needed, then they are used: if
52 "--nb_digits 2" is used and 112 files are generated they will be
53 named "<file>-01.xml" to "<file>-112.xml"
54
55 defaults to 2
56
57 -e <ext>
58 extension to use for generated files
59
60 defaults to the original file extension or ".xml"
61
62 -i use XInclude elements instead of Processing Instructions to mark
63 where sub files need to be included
64
65 -v verbose output
66
67 Note that this option can slow down processing considerably (by an
68 order of magnitude) when generating lots of small documents
69
70 -V outputs version and exit
71
72 -h short help
73
74 -m man (requires pod2text to be in the path)
75
77 xml_split foo.xml # split at level 1
78 xml_split -l 2 foo.xml # split at level 2
79 xml_split -c section foo.xml # a file is generated for each section element
80 # nested sections are split properly
81
83 XML::Twig, xml_merge
84
86 test
87 At the moment this is really alpha code, tested only on small, sim‐
88 ple documents.
89
90 It would be a good idea to first check that indeed the whole docu‐
91 ment is not loaded in memory!
92
93 optimize the code
94 any idea welcome! I have already implemented most of what I thought
95 would improve performances.
96
97 provide other methods that PIs to keep merge information
98 XInclude is a good candidate (alpha support added in 0.04).
99
100 using entities, which would seem the natural way to do it, doesn't
101 work, as they make it impossible to have both the main document and
102 the sub docs to be well-formed if the sub docs include sub-sub docs
103 (you cant have entity declarations in an entity)
104
106 Michel Rodriguez <mirod@cpan.org>
107
109 This tool is free software; you can redistribute it and/or modify it
110 under the same terms as Perl itself.
111
112
113
114perl v5.8.8 2007-01-21 XML_SPLIT(1)