Re: XML::LibXML::DocumentFragment

Tom Metro <[email protected]> Thu, 17 Feb 2011 21:31:44 -0500
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Bjoern Hoehrmann wrote:
> The W3C Document Object Model specfifications define a document fragment
> thus; 

You mean:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-B63ED1A3

where I see it says:

  DocumentFragment is a "lightweight" or "minimal" Document object. ...
  It is desirable to have an object which can hold such fragments and it
  is quite natural to use a Node for this purpose.

  IDL Definition

    interface DocumentFragment : Node {
    };

So I guess LibXML is adhering to the spec by subclassing a node.

I find it a bit unusual the way the W3C spec justifies the existence of
the DocumentFragment class not on the basis of functionality ("it is
true that a Document object could fulfill this role"), but on
performance ("a Document object can potentially be a heavyweight object,
depending on the underlying implementation"). That's just it...it
depends on the implementation. I'm sure there are many object systems
where an instantiated, but minimally populated Document object would
consume no more resources than a DocumentFragment.


> ...a document fragment is no document intuitively to me either, so
> you seem to have a very different idea of what a "document fragment" is.

I'm not sure if you are agreeing or disagreeing with my expectations for
a DocumentFragment.

The name, to me, suggests something that should provide the full
functionality of a Document, less the outer container.

However the W3C seemed to use DocumentFragment to be just another name
for Node. That's a misnomer in my opinion.

But thanks for the pointer that answered my question.

I'd like to see a documentation patch to XML::LibXML that points out
that DocumentFragment derives from Node and not Document. (A link to the
W3C spec would be good, too.)

 -Tom

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs