Oooh, i see i was unclear.

Thou shalt not pollute thy namespace with auto-generated, out-of-control aka user-supplied names

Indeed! i meant to imply the case where the coder has already written the packages; the handler would create a new object of the appropriate type, not a new class.

of course, you have to know what the classes are called for each element; i was thinking along the lines of:

my $handler = new XML::PerlSAX::Handler::Sanctum( # assume all packages are named "Publish::$element" baseclass => 'Publisher', # prefer "Publish::$parent::$element" # over "Publish::$element", to allow a book title # to be a different object than a chapter title. heirarchic => 'preferred', ); my $otherhandler = new XML::PerlSAX::Handler::Sanctum( dictionary => { # clear cases... BOOK => 'Publish::Book', CHAPTER => 'Publish::Chapter', PARAGRAPH => 'Publish::Paragraph', # <BOOK><TITLE></TITLE></BOOK> gets treated differently # than <CHAPTER><TITLE>... or <PARAGRAPH><TITLE>... 'BOOK TITLE' => 'Publish::Book::Title', 'CHAPTER TITLE' => 'Publish::Chapter::Title', TITLE => 'Publish::SectionHeading', } );

honestly, it had occurred to me to create the classes if they couldn't be found, but i decided that i'd only do that if the user told me to do so, and even then only if they didn't already exist. and maybe not even then; let the user auto-create their objects if they want.

thanks for the pointer to mirod's work, as well.

.


In reply to Re: Re: handling my PerlSAX handler by Vynce
in thread handling my PerlSAX handler by Vynce

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.