# File lib/nokogiri/xml/document_fragment.rb, line 10
      def initialize document, tags = nil, ctx = nil
        return self unless tags

        children = if ctx
                     # Fix for issue#490
                     if Nokogiri.jruby?
                       # fix for issue #770
                       ctx.parse("<root #{namespace_declarations(ctx)}>#{tags}</root>").children
                     else
                       ctx.parse(tags)
                     end
                   else
                     XML::Document.parse("<root>#{tags}</root>") \
                       .xpath("/root/node()")
                   end
        children.each { |child| child.parent = self }
      end