Hallo PerlMonks,

Just found perlmonks.org when googling for a solution to a special problem. I'm not an experienced Perl programmer and english is not my native language, so please have mercy on me...

My Problem: I've got large XML files (about 10MB each) which I'd like to split into smaller chunks and later merge back to big ones.

xml_split fom module XML::Twig does a good job when used with option -c (condition), but due to the structure of some of my XML files this sometimes gives me thousands of small chunks, which is far too much.

Options -s (chunk size) or -g (group certain tags) seem to be the best choice, but unfortunately all text nodes are then lost after xml_split is finished with my data. Just XML tags are left over.

The reason for that seems to be that xml_split does not use XML::Twig when options -s and -g are active. Instead it uses XML::Parser directly. In this case, XML::Parser neither calls text handlers nor default handlers, but why? It seems to just delete or skip all text for some strange reason.

I can hardly believe that noone else has stumbled upon or even solved this problem so far.

So: Does anyone know about a solution for this or perhaps about some different XML splitting tool/module I could use? I've been searching for quite a while but only found that "xml_split".

Thanks for any help,
donp


In reply to Tool "xml_split" from XML::Twig removes all text by donp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.