in reply to Inherit XML::DOM::Document?

It's not obvious from the documentation that you can't inherit from XML::DOM::Document. What leads you to think that that is the case?

What are you trying to achieve that you think such inheritance would help with?


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Inherit XML::DOM::Document?
by braden (Novice) on Apr 06, 2006 at 08:50 UTC
    use XML::DOM; @ISA = qw( XML::DOM::Document );
    yields:
    Global symbol "@ISA" requires explicit package name at lib/Literally +/Document.pm
    and
    use XML::DOM::Document; @ISA = qw( XML::DOM::Document );
    yields:
    Can't locate XML/DOM/Document.pm in @INC
    I'd like to do the normal thing for which one uses inheritance: extend existing functionality. The particular problem I'm trying to solve involves creating a DOM tree from scratch; while that's not directly related to my desire to use inheritance, it is another thing that the XML::DOM documentation doesn't make obvious (rather, it focuses on operating on a DOM tree constructed with the parser).
      Howdy!

      The error message from your first snippet simply means that 'strict vars' is in effect, and you haven't told it that @ISA is ok.

      use vars qw ( @ISA ); use XML::DOM; @ISA = qw(XML::DOM::Document);
      should compile fine. The current package will now be a subclass of XML::DOM::Document. Whether that acutally does what you want is a separate problem.

      yours,
      Michael
        Ah, thanks. Presumably that would get me as far as the other problem: that I simply cannot inherit XML::DOM::Document.
      Looking at XML-DOM, XML::DOM::Document is a documentation module, consisting of POD only. You cannot inherit anything from in. Try XML::DOM as base class instead.

        Aha. I suspected something along those lines.

        I don't think inheriting from XML::DOM is what I want; the package I'm writing has the semantics of being a document. I probably don't want to use inheritance at all; and instead just contain a XML::DOM::Document.

        Thanks.