in reply to XML::Twig Stream root children

Will xml_split help?

Replies are listed 'Best First'.
Re^2: XML::Twig Stream root children
by Herkum (Parson) on Oct 02, 2009 at 20:28 UTC

    xml_split does not create valid xml documents. It is appears mainly to allow you break apart the document and then put it back together with xml_merge.

    I guess I could modify the resulting document after running it. If I don't have any other solutions.

      xml_split does not create valid xml documents.

      Sure it does. Observe

      $$ echo THIS IS THE SAME AS xml_split -v Herkum.xml $$ xml_split -v -c "level(1)" Herkum.xml generating main file Herkum-00.xml generating Herkum-01.xml generating Herkum-02.xml $$ cat Herkum-00.xml && echo <root> <?merge subdocs = 0 :Herkum-01.xml?> <?merge subdocs = 0 :Herkum-02.xml?> </root> $$ cat Herkum-01.xml && echo <a> <b>Test</b> </a> $$ cat Herkum-02.xml && echo <aa> <b>Test</b> </aa>
      You can use "level(1)" with twig_handlers
        You can even do xml_split -l 1

      Would you care to explain? I tried to make it output well-formed fragments. About the only thing I can think of that would trip xml_split would be DTDs with entities, and if you have an example, I would be glad to make it work for you.

      Thanks

        Unless I'm overlooking something, a new feature could be to have an option to omit the merge file (00) and instead have the root wrapped around each output file, ie foo.xml
        <root> <a> <b>Test</b> </a> <aa> <b>Test</b> </aa> </root>
        becomes 2 files, foo-01.xml
        <root> <a> <b>Test</b> </a> </root>
        and foo-02.xml
        <root> <aa> <b>Test</b> </aa> </root>