From percival at umamibud.com Sun Aug 9 14:24:19 2009 From: percival at umamibud.com (Brian Percival) Date: Sun, 9 Aug 2009 11:24:19 -0700 Subject: [libxml-devel] 1.1.3 not passing unit tests (run via gem check)? Message-ID: Hello, I've just installed libxml-ruby 1.1.3 via gem install with no errors/warnings. I then try to run gem check -t libxml-ruby and all hell breaks loose with deprecation warnings, errors and finally some malloc free errors (see below). Is this 'expected' behavior, or does it look like I missing something critical? i've got: libxml2 v. 2.6.32_1, installed via macports, though i see another libxml2 in /usr/lib (how do i check which is being used?) libm in /usr/lib libz (1.2.3) in /usr/lib libiconv (2.4.0) in /usr/lib Mac OS X 10.5 Here's what I get when I try to run unit tests via gem (and I notice the failed to load external entity error when I try to parse my own XML document): > gem check -t libxml-ruby Node#child_add is deprecated. Use Node#<< instead. Error: Element 'invalid': This element is not expected. Expected is ( item ).. Warning: failed to load external entity "i_dont_exist.xml". Fatal error: Premature end of data in tag Results line 1 at :2. Warning: xmlParsePITarget: invalid name prefix 'xml' at :2. Node#child_add is deprecated. Use Node#<< instead. Error: Did not expect element invalid there. set_error_handler is deprecated. Use Error.set_handler instead set_error_handler is deprecated. Use Error.set_handler instead reset_error_handler is deprecated. Use Error.reset_handler instead Node#properties is deprecated. Use Node#attributes instead. Node#properties is deprecated. Use Node#attributes instead. ./test/tc_parser.rb:289: warning: Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead. XML::Parser#document= is deprecated. Use XML::Parser.document= instead Error: test_fd_gc(TestParser): LibXML::XML::Error: Warning: failed to load external entity "./test/model/rubynet.xml". /opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3/lib/libxml/parser.rb:33:in `file' /opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3/lib/libxml/parser.rb:33:in `file' ./test/tc_parser.rb:233:in `test_fd_gc' ./test/tc_parser.rb:232:in `times' ./test/tc_parser.rb:232:in `test_fd_gc' Node#base is deprecated. Use Node#base_uri. Node#base is deprecated. Use Node#base_uri. ./test/tc_parser.rb:300: warning: Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead. XML::Parser#file is deprecated. Use XML::Parser.file instead ./test/tc_parser.rb:309: warning: Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead. XML::Parser#io is deprecated. Use XML::Parser.io instead ./test/tc_parser.rb:322: warning: Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead. XML::Parser#string is deprecated. Use XML::Parser.string instead Node#base is deprecated. Use Node#base_uri. ELEMENT bands [more document elements..] Node#child_add is deprecated. Use Node#<< instead. Node#child_add is deprecated. Use Node#<< instead. Node#base is deprecated. Use Node#base_uri. Parser.register_error_handler is deprecated. Use Error.set_handler instead Failure: test_double_parse(TestError) [./test/tc_error.rb:116]: exception expected but was Class: Message: <"Fatal error: Document is empty at :1."> ---Backtrace--- ./test/tc_error.rb:118:in `parse' ./test/tc_error.rb:118:in `test_double_parse' ./test/tc_error.rb:116:in `test_double_parse' --------------- Error: test_handler(TestError): ArgumentError: wrong number of arguments (1 for 0) ./test/tc_error.rb:19:in `initialize' ./test/tc_error.rb:19:in `new' ./test/tc_error.rb:19:in `test_handler' ./test/tc_error.rb:125: warning: Passing no parameters to XML::Parser.new is deprecated. Pass an instance of XML::Parser::Context instead. XML::Parser#string is deprecated. Use XML::Parser.string instead XML::Parser#string is deprecated. Use XML::Parser.string instead Error: test_libxml_parser_empty_string(TestError): ArgumentError: Must specify a string with one or more characters /opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3/lib/libxml/parser.rb:126:in `string' /opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3/lib/libxml/parser.rb:126:in `string=' ./test/tc_error.rb:131:in `test_libxml_parser_empty_string' ./test/tc_error.rb:70: warning: already initialized constant STDERR ./test/tc_error.rb:76: warning: already initialized constant STDERR Error: test_parse_error(TestError): NameError: uninitialized constant LibXML::XML::Error::XML_FROM_PARSER ./test/tc_error.rb:88:in `test_parse_error' Error: test_reset_handler(TestError): ArgumentError: wrong number of arguments (1 for 0) ./test/tc_error.rb:45:in `initialize' ./test/tc_error.rb:45:in `new' ./test/tc_error.rb:45:in `test_reset_handler' ./test/tc_error.rb:54: warning: already initialized constant STDERR ./test/tc_error.rb:60: warning: already initialized constant STDERR Error: Invalid predicate. xmlXPathEval: evaluation failed Failure: test_xpath_error(TestError) [./test/tc_error.rb:103]: <"Error: Invalid predicate at :0."> expected but was <"Error: Invalid predicate.">. Failure: test_external_dtd(TestDtd) [./test/tc_dtd.rb:110]: <1> expected but was <0>. Node#child_add is deprecated. Use Node#<< instead. Failure: test_invalid(TestDtd) [./test/tc_dtd.rb:68]: exception expected but was Class: Message: <"method `respond_to?' called on terminated object (0xa05ac690)"> ---Backtrace--- ./test/tc_dtd.rb:69:in `validate' ./test/tc_dtd.rb:69:in `test_invalid' ./test/tc_dtd.rb:68:in `test_invalid' --------------- DOCUMENT version=1.0 encoding=utf-8 URL=./test/model/bands.xml standalone=true ELEMENT bands [more document elements...] Failure: test_save_iso_8859_1(TestDocumentWrite) [./test/tc_document_write.rb:96]: <"\n\n An American heavy metal band formed in Los Angeles, California in 1981.\n British heavy metal band formed in 1975.\n\n"> expected but was <"\037\213\b\000\000\000\000\000\000\003}\217\273\n\302@\020E\373|\3050\265\257-\304\004\222\225h%\b\026~\200\254\311\230\f\356\316\302n\024\363\343V\026\306T\251\254\017\367\034n\276}9\vO\n\221\275\024\250\026+\004\222\312\327,M\201\207\363i\236\246\353l\256p\253\223\374j\244\216\320\220\004*\320Qg,\352\004 w\357\316R\177\251\302\207\240\362\017\351B_\340#\242.\005JG\201+#\320\222y\3660\256\340'\202\233\017\216j`\201\243\217PJC\226\342\f\366\306\362\200\204\315\017\251,U\213|9)\214E\016^.\316pM2)\336Q\357\002w\034\333\1775\225m\326\203r\242\030\256-\307o:\371\002o\213d#\020\001\000\000">. Failure: test_save_iso_8859_1_no_indent(TestDocumentWrite) [./test/tc_document_write.rb:108]: [similar 'expected X but was Y' error msg] Failure: test_save_utf8(TestDocumentWrite) [./test/tc_document_write.rb:71]: [similar 'expected X but was Y' error msg] Failure: test_save_utf8_no_indents(TestDocumentWrite) [./test/tc_document_write.rb:84]: [similar 'expected X but was Y' error msg] Node#properties is deprecated. Use Node#[] instead. The XML::NS class is deprecated. Use XML::Namespace instead. ruby(6664) malloc: *** error for object 0x8bb000: double free *** set a breakpoint in malloc_error_break to debug ruby(6664) malloc: *** error for object 0xc0a92913: Non-aligned pointer being freed *** set a breakpoint in malloc_error_break to debug ruby(6664) malloc: *** error for object 0x2a4bfe0: double free *** set a breakpoint in malloc_error_break to debug ruby(6664) malloc: *** error for object 0x2a4c250: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug ruby(6664) malloc: *** error for object 0x4: Non-aligned pointer being freed *** set a breakpoint in malloc_error_break to debug ruby(6664) malloc: *** error for object 0x2a4bfe0: double free *** set a breakpoint in malloc_error_break to debug ruby(6664) malloc: *** error for object 0x2a4bfe0: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug Failure: test_register_default_ns(TestXPath) [./test/tc_xpath.rb:98]: exception expected but was Class: Message: <"method `respond_to?' called on terminated object (0xa05ac690)"> ---Backtrace--- /opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3/lib/libxml/document.rb:119:in `find' /opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3/lib/libxml/document.rb:119:in `find' ./test/tc_xpath.rb:99:in `test_register_default_ns' ./test/tc_xpath.rb:98:in `test_register_default_ns' --------------- ERROR: 305 tests, 1284 assertions, 9 failures, 5 errors Anything obvious? Thanks, bp From tolsen at limelabs.com Wed Aug 19 11:10:20 2009 From: tolsen at limelabs.com (Tim Olsen) Date: Wed, 19 Aug 2009 11:10:20 -0400 Subject: [libxml-devel] Node#inner_xml() with all namespaces declared? Message-ID: <4A8C15DC.3060803@limelabs.com> Hello, I am trying to call Node#inner_xml() and have all namespaces referenced in the inner xml be spit out as well, so that the returned string can be parsed again. For example, take the following xml: Phil Bogle's Contacts I would like to be able to call inner_xml() on the feed node, and get: Phil Bogle's Contacts Notice the namespace declaration now on the title node. I couldn't find an option to pass to inner_xml() (or to_s()) to do this. I was thinking maybe I could modify what Namespaces#definitions() returns but I couldn't find a method to modify the definitions. Any idea how to achieve this? Thanks, Tim From tolsen at limelabs.com Wed Aug 19 15:52:57 2009 From: tolsen at limelabs.com (Tim Olsen) Date: Wed, 19 Aug 2009 15:52:57 -0400 Subject: [libxml-devel] Node#inner_xml() with all namespaces declared? In-Reply-To: <4A8C15DC.3060803@limelabs.com> References: <4A8C15DC.3060803@limelabs.com> Message-ID: <4A8C5819.4060500@limelabs.com> I've found a workaround. If I copy(true) a node, then the required namespaces will be declared on the node. Here is a method that does what I want: # creates a copy of each child before doing to_s # so that namespaces are properly declared def inner_xml_copy node, options = {} return (node.map { |n| n.copy(true).to_s options }.join '') end Tim Tim Olsen wrote: > Hello, > > I am trying to call Node#inner_xml() and have all namespaces referenced > in the inner xml be spit out as well, so that the returned string can be > parsed again. > > For example, take the following xml: > > > Phil Bogle's Contacts > > > I would like to be able to call inner_xml() on the feed node, and get: > > Phil > Bogle's Contacts > > Notice the namespace declaration now on the title node. > > I couldn't find an option to pass to inner_xml() (or to_s()) to do this. > I was thinking maybe I could modify what Namespaces#definitions() > returns but I couldn't find a method to modify the definitions. > > Any idea how to achieve this? > > Thanks, > Tim > _______________________________________________ > libxml-devel mailing list > libxml-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/libxml-devel From sean at chittenden.org Fri Aug 28 12:45:38 2009 From: sean at chittenden.org (Sean Chittenden) Date: Fri, 28 Aug 2009 09:45:38 -0700 Subject: [libxml-devel] entity encoding In-Reply-To: <9EB68AF0-84CB-4A85-933F-C8CE0E685888@research.att.com> References: <9EB68AF0-84CB-4A85-933F-C8CE0E685888@research.att.com> Message-ID: <6D98B536-318C-4B70-929B-C7F0E1E0B267@chittenden.org> node.content returns a string, which is 'AT&T' iirc, you want to assign a node, not the content of a node. I believe it's quite deliberate that it doesn't escape string input (try and construct an HTML or RSS feed). It's easier to escape on assign than have a magic escape in these situations, not in these situations, type of semantics. Am punting on the rest for someone else to pick up. -sc On Aug 28, 2009, at 4:53 AM, Andrew Hume wrote: > xml: > > AT&T > > i parse this using > > doc = LibXML::XML::Document.file('foo.xml') > > if node points to this element, then > node.content == 'AT&T' > > all well and good. if i want to now create a new document, > then i do > > newnode = LibXML::XML::Node.new('Company') > newnode.content = node.content > > and this assignment has the error 'unterminated entity reference' > (which could be fair given that it is literally an unterminated > entity reference). > the question is should assignment of content automatically do teh > conversion > or should teh user be responsible? > and if so, is there a convenient method for doing so? > > (meta-question: is this documented anywhere, and if so, where?) > > > ------------------ > Andrew Hume (best -> Telework) +1 732-886-1886 > andrew at research.att.com (Work) +1 973-360-8651 > AT&T Labs - Research; member of USENIX and LOPSA > > > > _______________________________________________ > libxml-devel mailing list > libxml-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/libxml-devel -- Sean Chittenden sean at chittenden.org