All,

I have an XML document with an external parameter entity in the doctype. When I use toString on the XML::LibXML document object, this entity is being expanded in the doctype. Is there any way to turn expansion off on such entities? I am alreadying turning off the expand_entities option, and it works throughout the rest of the document, but this seems not to impact the the doctype tag.

Here is some sample XML, demonstrating what I am talking about:

<?xml version="1.0" standalone="no"?> <!DOCTYPE student [ <!ENTITY % student SYSTEM "http://www.university.com/student.dtd"> %student; ]>

Using the provided example, "%student;" is being replaced by the contents of the entity when I print out the document. I would like to be able to print the doctype tag in the same format that it was provided (i.e. unexpanded).

Here are the parameters that I am passing to the LibXML parser:

$parser->line_numbers(1); $parser->validation(0); $parser->load_ext_dtd(1); $parser->expand_entities(0);

Please let me know if there is any other information that I could provide that would prove useful, and thanks for your consideration.


In reply to Suppressing XML::LibXML External Parameter Entity Expansion by scotth

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.