This question is a follow-on to a question I asked recently about parsing an XML file that does not have a DOCTYPE line specifying a dtd file, but does contain entity references. It turns out that the XML file that I was working with was defined as an entity in a sort of master XML file, and it was in that file that the dtd file was specified. The master file looks sort of like this:
<!DOCTYPE allfiles SYSTEM "allfiles.dtd" [<!ELEMENT file1 SYSTEM "file1.xml"> <!ELEMENT file2 SYSTEM "file2.xml"> ....]> <alldata> &file1; &file2; .... </alldata>
I wrote this code example from memory, so I hope I didn't add any syntax errors. I would like to use an XML parser that parses each of the nested XML files when it encounters the entity references for them. So far, I have been using XML::Parser, and it does call the ExternEnt handler function when it gets to an entity like &file1;, but it doesn't open the file, and I don't know what to do to get it to parse those nested files within the scope of the dtd file, so that entity references, etc., within those nested files are interpreted correctly. I assume I can't invoke the parser recursively from within the ExternEnt handler function, and the parser settings that I played around with to try to get different behavior (NoExpand, ParseParamEnt) did not seem to make a difference in how these entity references were dealt with. Does anyone have any suggestions?

In reply to Parsing nested XML files by moleary

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.