If I understand XML::Parser, the ExternEnt handler is used for entities that refer to external files, but I don'think there is any built-in way to get to the DTD, and to the info inside it.

Actually if I read the code in XML::Twig properly (I wrote it quite a while ago), it just parses the DTD with a dummy document, gets the entity info, and uses it later when parsing the main document. And "I don't like to do that, but it solves my problem" ;--(

About entities in attributes: the Default handler is properly called when an entity is found in an attribute value, but the problem is that you can't do much at this point, and when the Start handler is called, the entity has disapeared from the attribute value that gets passed to it. Which is really annoying, especially as the default entities ('&', '<', '>'...) get properly replaced.

For example this is scary, and shows that there isn't much that can be done that will work in all cases:

#!/usr/bin/perl -w use strict; use XML::Parser; XML::Parser->new( Handlers => { Start => sub { print "att: '$_[3]'\n" +} }) ->parse( '<!DOCTYPE doc SYSTEM "dummy"><doc att="an &ent; a +nd an &amp;ent;"/>'); # prints att: 'an and an &ent;'

In reply to Re^3: XML::Parser::Expat Question by mirod
in thread XML::Parser::Expat Question by dobrozam

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.