hello, I get segmentation fault when add the cloned/copied node to other node, script to problem reproduction below,
segv appears when use clone and copy methods, what's interesting, with clone segv is thrown in div1.child_add(c) line (see script) but when use copy I get it in printf root statement, moreover copy seems to work wrong only for text nodes, when use 't3' div everything works fine I get this error on 0.5.2.0, 0.5.2.1 and 0.5.2.2 (latest svn) version it looks like fix is required in ruby-libxml code, BTW. it looks also like ruby_xml_node_copy() in ruby_xml_node.c calls xmlCopyNode() with wrong attributes, it should be 2 for shallow copy and 1 for deep copy regards, Piotrek -------------------- SCRIPT --------------------- require 'xml/libxml' str = <<-STR <html> <body> <div class="textarea" id="t1" style="STATIC">werwerwerwerwer </div> <div class="textarea" id="t2" style="STATIC"> Quisque et diam dapibus nisi bibendum blandit. </div> <div class="textarea" id="t3" style="STATIC"> <p>aaaaaaaaa</p> </div> </body> </html> STR XML::Parser.default_keep_blanks = false xp = XML::Parser.new xp.string = str doc = xp.parse xpath = "//[EMAIL PROTECTED]'t1']" div1 = doc.find(xpath).to_a[0] printf "xxx div1: #{div1}\n" xpath = "//[EMAIL PROTECTED]'t2']" div2 = doc.find(xpath).to_a[0] printf "xxx div2: #{div2}\n" div2.each do |child| #c = child.clone c = child.copy(false) div1.child_add(c) end printf "xxx root: #{doc.root}\n" _______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel