Git Product home page Git Product logo

libxml-ruby's People

Contributors

abrasive avatar amatsuda avatar blackwinter avatar brettg avatar carpodaster avatar cbarton avatar cfis avatar cfisoi avatar cjheath avatar d-hansen avatar dbussink avatar dudleyf avatar esasse avatar hainesr avatar jarl-dk avatar jcsahnwaldt avatar julp avatar msp-greg avatar nikitug avatar nkriege avatar raorn avatar richardkmichael avatar sergiodj avatar stevenwilliamson avatar tmm1 avatar trans avatar utilum avatar webgago avatar y-yagi avatar yeban avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libxml-ruby's Issues

Any plans for malformed XML handling?

I was wondering if there are any plans to make (via configuration) the sax parser more tolerant to common errors (not closed tag, not opened tag etc) in order to use it to parse HTML?

Segmentation fault

I apologize in advance shall you consider this issue in no direct connection with libxml-ruby, but it seems to me it might.

I'm using libxml 2.9.0 on Ubuntu 12.10 with Ruby 1.9.3p385 and nokogiri-1.5.9. I've both tried to use a repository version of libxml and compiled it from source on different servers. Though I'm constantly getting the following error.

It mostly happens when I run it through Sidekiq (which is built on top of Celluloid), but it might not be very accurate as it just runs its tasks hundreds of times more than the app server. I haven't found anything useful in the document it fails on which seems quite correct. The roadie gem which inlines CSS in ActionMailer emails is also halting on this. I'm running thousands of tasks every day and this happens in about 1 to 50.

I'd really appreciate your expertise on tracking this problem down. Thank you!

/home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/nokogiri-1.5.9/lib/nokogiri/xml/node_set.rb:238: [BUG] Segmentation fault
ruby 1.9.3p385 (2013-02-06) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0047 p:---- s:0194 b:0194 l:000193 d:000193 CFUNC  :length
c:0046 p:0013 s:0191 b:0190 l:000189 d:000189 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/nokogiri-1.5.9/lib/nokogiri/xml/node_set.rb:238
c:0045 p:0153 s:0186 b:0186 l:001488 d:002640 BLOCK  /home/deployer/apps/leveltravel/current/app/operator_apis/modules/samo_operator.rb:93
c:0044 p:---- s:0181 b:0181 l:000180 d:000180 FINISH
c:0043 p:---- s:0179 b:0179 l:000178 d:000178 CFUNC  :each
c:0042 p:0018 s:0176 b:0176 l:001488 d:001488 METHOD /home/deployer/apps/leveltravel/current/app/operator_apis/modules/samo_operator.rb:85
c:0041 p:0013 s:0171 b:0171 l:000170 d:000170 METHOD /home/deployer/apps/leveltravel/current/app/operator_apis/anex_tour.rb:40
c:0040 p:0049 s:0167 b:0167 l:000166 d:000166 METHOD /home/deployer/apps/leveltravel/current/app/operator_apis/abstract_operator.rb:43
c:0039 p:0252 s:0161 b:0161 l:000160 d:000160 METHOD /home/deployer/apps/leveltravel/current/app/operator_apis/abstract_operator.rb:68
c:0038 p:0187 s:0155 b:0155 l:000154 d:000154 METHOD /home/deployer/apps/leveltravel/current/app/actors/operator_search_request_base.rb:25
c:0037 p:0035 s:0147 b:0147 l:000eb0 d:000146 BLOCK  /home/deployer/apps/leveltravel/current/app/workers/stats_updater.rb:50
c:0036 p:---- s:0143 b:0143 l:000142 d:000142 FINISH
c:0035 p:---- s:0141 b:0141 l:000140 d:000140 CFUNC  :each
c:0034 p:0023 s:0138 b:0138 l:000137 d:000137 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/relation/delegation.rb:6
c:0033 p:0164 s:0133 b:0133 l:000eb0 d:000eb0 METHOD /home/deployer/apps/leveltravel/current/app/workers/stats_updater.rb:47
c:0032 p:0025 s:0121 b:0121 l:002520 d:000120 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/processor.rb:49
c:0031 p:---- s:0119 b:0119 l:000118 d:000118 FINISH
c:0030 p:---- s:0117 b:0117 l:000116 d:000116 CFUNC  :call
c:0029 p:0024 s:0114 b:0114 l:002148 d:000113 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/chain.rb:109
c:0028 p:0005 s:0112 b:0112 l:001370 d:000111 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/server/timeout.rb:11
c:0027 p:0111 s:0110 b:0110 l:001480 d:001480 METHOD /usr/local/lib/ruby/1.9.1/timeout.rb:68
c:0026 p:0061 s:0098 b:0098 l:001370 d:001370 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/server/timeout.rb:10
c:0025 p:0049 s:0092 b:0092 l:002148 d:000091 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/chain.rb:111
c:0024 p:0007 s:0090 b:0090 l:000089 d:000089 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/server/active_record.rb:6
c:0023 p:0049 s:0086 b:0086 l:002148 d:000085 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/chain.rb:111
c:0022 p:0007 s:0084 b:0084 l:000083 d:000083 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/server/retry_jobs.rb:50
c:0021 p:0049 s:0072 b:0072 l:002148 d:000071 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/chain.rb:111
c:0020 p:0041 s:0070 b:0070 l:0012c0 d:002270 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/server/logging.rb:11
c:0019 p:0037 s:0067 b:0067 l:000066 d:000066 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/logging.rb:22
c:0018 p:0045 s:0063 b:0063 l:0012c0 d:0012c0 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/server/logging.rb:7
c:0017 p:0049 s:0057 b:0057 l:002148 d:000056 LAMBDA /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/chain.rb:111
c:0016 p:---- s:0055 b:0055 l:000054 d:000054 FINISH
c:0015 p:---- s:0053 b:0053 l:000052 d:000052 CFUNC  :call
c:0014 p:0040 s:0050 b:0050 l:002148 d:002148 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/middleware/chain.rb:114
c:0013 p:0030 s:0043 b:0043 l:002520 d:001448 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/processor.rb:48
c:0012 p:0021 s:0041 b:0041 l:000730 d:000730 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/processor.rb:87
c:0011 p:0110 s:0035 b:0035 l:002520 d:001578 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/sidekiq-2.9.0/lib/sidekiq/processor.rb:47
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 FINISH
c:0009 p:---- s:0027 b:0027 l:000026 d:000026 CFUNC  :call
c:0008 p:---- s:0025 b:0025 l:000024 d:000024 CFUNC  :public_send
c:0007 p:0021 s:0021 b:0021 l:000020 d:000020 METHOD /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23
c:0006 p:0016 s:0015 b:0015 l:002678 d:000014 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/future.rb:18
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :call
c:0003 p:0021 s:0008 b:0008 l:002488 d:000007 BLOCK  /home/deployer/apps/leveltravel/shared/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP   

Error: version `LIBXML2_2.9.0' not found

Hi.
I use nokogiri at Gentoo linux x86-64.
and I has had next version libxml2:

dev-libs/libxml2
Available versions: (2) *2.8.0-r3 2.9.0-r2 ~2.9.1 2.9.1-r1
{debug doc examples icu ipv6 lzma python readline static-libs test PYTHON_TARGETS="python2_5 python2_6 python2_7 python3_1 python3_2 python3_3"}
Installed versions: 2.9.1-r1(2)(13:34:43 13.07.2013)(icu ipv6 python readline -debug -examples -lzma -static-libs -test PYTHON_TARGETS="python2_7 -python2_5 -python2_6 -python3_1 -python3_2 -python3_3")

But I get next error: https://gist.github.com/JohnBat26/6003246
Why?

Failure to load an external XSD schema leads to segmentation fault

When an external XSD file fails to load, an error messages is emitted - good!
But the returned LibXML::XML::Document has a NULL pointer for xschema.
When this member is accessed using XML::Schema.document(), any reference
to it causes a segmentation fault and coredump.

See the example chapter05ord.xsd from the ZIP file downloaded from here:
http://www.datypic.com/books/defxmlschema/examples.html

The problem is in ext/libxml/ruby_xml_schema.c, method rxml_schema_init_from_document
and I'm sending a pull request with the fix.

encoding question

My test case is as follows:

Preparing stream for libxml:
gz=Zlib::GzipReader.open(@params[:report][:file_name])
input = StringIO.new(gz.read)

Checking if encoding is right:
(rdb:1) e input

StringIO:0x007fdf962986a0

(rdb:1) e input.string.encoding

Encoding:UTF-8

Out stuff to SaxParser:
@p=LibXML::XML::SaxParser.io(input, :encoding => LibXML::XML::Encoding::UTF_8)
@p.callbacks=@callback
@p.parse

Catching attributes in callback:
def callback_start(element,attributes)
debugger

Output of attributes:
(rdb:1) e attributes['keyword']
"saint jude's children C\xC3\xA1ncer cure"
(rdb:1) e attributes['keyword'].encoding

Encoding:ASCII-8BIT

My question here is, why strings are return as ASCII-8BIT if I wanted UTF-8?

Does library support stream XML builder like java XMLStreamWriter

Hello!

-1.Thank you very much for library, I am using it and like it!
-2.I am sorry if I put a question into wrong place, I wasn't able to find any forum that is more suitable. This is not problem, this is question (or request for some extra info at documentation) that I wasn't able to find at www.
-3.I need a build a huge xml document, that is larger that available memory. I am expecting a stream builder like http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLStreamWriter.html. Does library provide any services (classes) for this tasks? If yes, could you direct me for documentations, tutorials or examples? There are other people that need to resolve the same tasks, for example: http://stackoverflow.com/questions/4940584/how-can-i-use-nokogiri-to-write-a-huge-xml-file

Sincerely yours,
Artem Rufanov

P.S.
Have a good day!

Build fails with "xmlNs has no member named context"

Installation fails under Centos 5.6 which has libxml2 2.6.26 installed.

This release of libxml2 does not have the 'context' field defined in the xmlNs structure.

Consequently the build fails with the following error messages;

ruby_xml_namespace.c: In function ‘rxml_namespace_href_get’:
ruby_xml_namespace.c:101: error: ‘xmlNs’ has no member named ‘context’
ruby_xml_namespace.c:101: error: ‘xmlNs’ has no member named ‘context’
ruby_xml_namespace.c: In function ‘rxml_namespace_prefix_get’:
ruby_xml_namespace.c:136: error: ‘xmlNs’ has no member named ‘context’
ruby_xml_namespace.c:136: error: ‘xmlNs’ has no member named ‘context’

ruby_xml_namespace.c should probably have some conditional statements which test the libxml2 version before referring to "ns->context" in the call statements on lines 101 and 136.

osx/ubuntu auto prefixing nodes

on OSX i get the following output:

<TARGET id="target" type="FACEBOOK_PLATFORM">

on ubuntu I get

<default:TARGET xmlns="myNameSpace" id="target" type="FACEBOOK_PLATFORM">

using gem 2.2.2

This is simplified version of my large xml file, all nodes have the above xmlns and prefix added.

The version of libxml is different on each platform: osx = 2.7.3 and ubuntu = 2.7.7

Segmentation fault accessing attributes of expanded nodes

The following code causes a segmentation fault on my system with the latest release of libxml-ruby (2.0.2).

The problem appears to be that rxml_reader_expand calls xmlCopyNode, which leaves the document pointer of the returned node as null, but this is not checked in rxml_attr_value_get. Given the encoding support which has been added to the reader, it would seem that the document needs to be copied also - possibly using xmlDocCopyNode as is done in the equivalent PHP extension - although I'm not sure whether that should be a copied document or the existing document.

require 'rubygems'
gem 'libxml-ruby', '=2.0.2'
require 'xml/libxml'

doc = XML::Document.new
doc.root = XML::Node.new "foo"
elem = XML::Node.new "elem"
elem["id"] = "1234"
doc.root << elem

str = doc.to_s
puts "== document to be read =="
puts str

reader = XML::Reader.string(str)
while reader.name != "elem"
  reader.read
end
puts "== expanding elem =="
read_elem = reader.expand

puts "== accessing reader attribute =="
# segmentation fault happens on next line
puts read_elem['id']

puts "== all done =="

Here's a very basic unit test to add to test/tc_reader.rb:

def test_expanded_attr
  reader = XML::Reader.string('<foo id="1"/>')
  reader.read
  node = reader.expand
  reader.close
  GC.start

  assert_equal('foo', node.name)
  assert_equal('1', node['id'])
end

Many thanks.

segfault in Reader on ISO-8859-1 encoded document in ruby 1.9.2

Using the Reader to parse xml which indicates encoding="ISO-8859-1" causes the following segmentation fault in ruby 1.9.2.

libxml_segfault.rb:17: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

-- control frame ----------
c:0004 p:0080 s:0012 b:0011 l:000010 d:000010 METHOD libxml_segfault.rb:17
c:0003 p:0064 s:0006 b:0006 l:0010a8 d:001fa8 EVAL   libxml_segfault.rb:25
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0010a8 d:0010a8 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
libxml_segfault.rb:25:in `<main>'
libxml_segfault.rb:17:in `parse_iso8859_xml'

-- C level backtrace information -------------------------------------------
ruby1.9.2(rb_vm_bugreport+0x9e) [0x52381e]
ruby1.9.2() [0x564f58]
ruby1.9.2(rb_bug+0xb1) [0x5650f1]
ruby1.9.2() [0x4b2878]
/lib/libpthread.so.0(+0xf8f0) [0x7f19cc04d8f0]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted

The following code demonstrates the problem.

require 'rubygems'
gem 'libxml-ruby', "=2.0.5"
require 'libxml'

def parse_iso8859_xml
  data = <<-END_OF_XML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<Result></Result>
  END_OF_XML

  reader = LibXML::XML::Reader.string(data)

  while reader.read
    if reader.node_type == LibXML::XML::Reader::TYPE_ELEMENT

      # The following line will segfault in ruby 1.9.2
      case reader.name
      when "Result"
        puts "Got Result element"
      end
    end
  end
end

parse_iso8859_xml

How can I add an attribute with namespace?

Hello,

I'm working on http://lpod-project.org/ and I need to be able to manage attributes linked to a namespace.

So, here is my question:

Given a node, a prefix, a uri, an attribute name and a value, what code should I write so that the following condition is true?

node.attributes.get_attribute_ns(uri, name).value == value

Thanks in advance for your answer.

xml file stays opened after reading

After opening a xml file with XML::Document.file I can't delete the opened file until ruby exits. A function for closing the file after the read process would solve the problem.

can't install libxml-ruby (2.4.0 and 2.4.6)

Hello! I am use bitnami stack redmine and want install libxml-ruby gem.

I run this command gem install -p -f libxml-ruby and get this error:

ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

    /usr/local/redmine/ruby/bin/ruby extconf.rb

checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... yes
checking for atan() in -lm... no
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... no
checking for libxml/xmlversion.h in /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/redmine/ruby/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-socketlib
--without-socketlib
--with-nsllib
--without-nsllib
--with-mlib
--without-mlib
--with-mlib
--without-mlib
--with-zlib
--without-zlib
--with-iconvlib
--without-iconvlib
--with-xml2-config
--without-xml2-config
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xml2lib
--without-xml2lib
extconf failure: need libxml2.

Install the library or try one of the following options to extconf.rb:

  --with-xml2-config=/path/to/xml2-config
  --with-xml2-dir=/path/to/libxml2
  --with-xml2-lib=/path/to/libxml2/lib
  --with-xml2-include=/path/to/libxml2/include

Gem files will remain installed in /usr/local/redmine/ruby/lib/ruby/gems/1.8/gems/libxml-ruby-2.4.0 for inspection.
Results logged to /usr/local/redmine/ruby/lib/ruby/gems/1.8/gems/libxml-ruby-2.4.0/ext/libxml/gem_make.out

How can i resolve this problem?
Thanks!

Segfault accessing attributes

This was previously reported here: http://rubyforge.org/tracker/?func=detail&atid=1971&aid=29140&group_id=494

I get regular segfaults always while accessing node attributes. I'm running libxml-ruby 2.0.9 (from gems) on top of libxml 2.7.8 (compiled from source).

The stack trace from this crash is included below.

And here's the code being run there:

70  WEBrick::HTTPAuth.basic_auth req, resp, "Config console" do |user, pass|
71      if user then
72          role = config.find_first "role[@name=#{xp user}]"
73          expect = role.attributes["password-crypt"]
74          salt = expect.split("$")[2]
75          crypt = pass.crypt "$6$#{salt}$"
76          if crypt == expect
77              req.attributes[:user] = user
78              true
79          else
80              false
81          end
82      else
83          false
84      end
85  end

I have seen similar crashes occur in other parts of the code, but I think it's always been in an attribute access. I am using ruby 1.9.1 and this is an application with a built in webrick server. It is multi threaded but I understand that should not be an issue because ruby isolates all native libraries to prevent any problems.

Here's the trace:

/alchemy-hq/ruby/mandar/console/home.rb:14: [BUG] Segmentation fault
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]

-- control frame ----------
c:0019 p:---- s:0089 b:0089 l:000088 d:000088 CFUNC  :[]
c:0018 p:0017 s:0085 b:0083 l:000074 d:000082 BLOCK  /alchemy-hq/ruby/mandar/console/home.rb:14
c:0017 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0016 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC  :select
c:0015 p:0051 s:0075 b:0075 l:000074 d:000074 METHOD /alchemy-hq/ruby/mandar/console/home.rb:14
c:0014 p:0200 s:0069 b:0069 l:000068 d:000068 METHOD /alchemy-hq/ruby/mandar/console/consolehandler.rb:10
c:0013 p:0077 s:0062 b:0062 l:000e68 d:000061 BLOCK  /alchemy-hq/ruby/mandar/console/server.rb:103
c:0012 p:---- s:0059 b:0059 l:000058 d:000058 FINISH
c:0011 p:---- s:0057 b:0057 l:000056 d:000056 CFUNC  :catch
c:0010 p:0148 s:0053 b:0053 l:000e68 d:002440 BLOCK  /alchemy-hq/ruby/mandar/console/server.rb:97
c:0009 p:---- s:0048 b:0048 l:000047 d:000047 FINISH
c:0008 p:---- s:0046 b:0046 l:000045 d:000045 CFUNC  :call
c:0007 p:0016 s:0041 b:0041 l:000040 d:000040 METHOD /alchemy-hq/ruby/mandar/console/server.rb:16
c:0006 p:0055 s:0036 b:0036 l:000035 d:000035 METHOD /usr/lib/ruby/1.9.1/webrick/httpservlet/abstract.rb:35
c:0005 p:0256 s:0030 b:0030 l:000029 d:000029 METHOD /usr/lib/ruby/1.9.1/webrick/httpserver.rb:111
c:0004 p:0382 s:0020 b:0020 l:000019 d:000019 METHOD /usr/lib/ruby/1.9.1/webrick/httpserver.rb:70
c:0003 p:0123 s:0009 b:0009 l:000fac d:000008 BLOCK  /usr/lib/ruby/1.9.1/webrick/server.rb:183
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP   
---------------------------
-- Ruby level backtrace information-----------------------------------------
/alchemy-hq/ruby/mandar/console/home.rb:14:in `[]'
/alchemy-hq/ruby/mandar/console/home.rb:14:in `block in handle'
/alchemy-hq/ruby/mandar/console/home.rb:14:in `select'
/alchemy-hq/ruby/mandar/console/home.rb:14:in `handle'
/alchemy-hq/ruby/mandar/console/consolehandler.rb:10:in `handle'
/alchemy-hq/ruby/mandar/console/server.rb:103:in `block (2 levels) in run'
/alchemy-hq/ruby/mandar/console/server.rb:97:in `catch'
/alchemy-hq/ruby/mandar/console/server.rb:97:in `block in run'
/alchemy-hq/ruby/mandar/console/server.rb:16:in `call'
/alchemy-hq/ruby/mandar/console/server.rb:16:in `do_GET'
/usr/lib/ruby/1.9.1/webrick/httpservlet/abstract.rb:35:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

-- C level backtrace information -------------------------------------------
0xb775c929 /usr/lib/libruby-1.9.1.so.1.9(rb_vm_bugreport+0x69) [0xb775c929]
0xb767592f /usr/lib/libruby-1.9.1.so.1.9(+0x4692f) [0xb767592f]
0xb76759ca /usr/lib/libruby-1.9.1.so.1.9(rb_bug+0x3a) [0xb76759ca]
0xb77029c4 /usr/lib/libruby-1.9.1.so.1.9(+0xd39c4) [0xb77029c4]
0xb77ca40c [0xb77ca40c]
0xb77357bd /usr/lib/libruby-1.9.1.so.1.9(rb_class_path+0x1d) [0xb77357bd]
0xb7735915 /usr/lib/libruby-1.9.1.so.1.9(rb_class_name+0x25) [0xb7735915]
0xb7735942 /usr/lib/libruby-1.9.1.so.1.9(rb_class2name+0x22) [0xb7735942]
0xb7736511 /usr/lib/libruby-1.9.1.so.1.9(rb_obj_classname+0x31) [0xb7736511]
0xb7675f99 /usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0x149) [0xb7675f99]
0xb70ef84d /var/lib/gems/1.9.1/gems/libxml-ruby-2.0.9/lib/libxml_ruby.so(rxml_attr_value_get+0x2d) [0xb70ef84d]
0xb70f0788 /var/lib/gems/1.9.1/gems/libxml-ruby-2.0.9/lib/libxml_ruby.so(rxml_attributes_attribute_get+0x38) [0xb70f0788]
0xb7749af3 /usr/lib/libruby-1.9.1.so.1.9(+0x11aaf3) [0xb7749af3]
0xb7749e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7749e84]
0xb775617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb775617c]
0xb774fedf /usr/lib/libruby-1.9.1.so.1.9(+0x120edf) [0xb774fedf]
0xb7753b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7753b46]
0xb7756b00 /usr/lib/libruby-1.9.1.so.1.9(rb_yield+0x1e0) [0xb7756b00]
0xb76562c1 /usr/lib/libruby-1.9.1.so.1.9(+0x272c1) [0xb76562c1]
0xb7749afd /usr/lib/libruby-1.9.1.so.1.9(+0x11aafd) [0xb7749afd]
0xb7749e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7749e84]
0xb775617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb775617c]
0xb7750673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7750673]
0xb7753b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7753b46]
0xb7754146 /usr/lib/libruby-1.9.1.so.1.9(+0x125146) [0xb7754146]
0xb7754912 /usr/lib/libruby-1.9.1.so.1.9(+0x125912) [0xb7754912]
0xb7749b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0xb7749b18]
0xb7749e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7749e84]
0xb775617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb775617c]
0xb7750673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7750673]
0xb7753b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7753b46]
0xb7755ca8 /usr/lib/libruby-1.9.1.so.1.9(rb_vm_invoke_proc+0x278) [0xb7755ca8]
0xb767c693 /usr/lib/libruby-1.9.1.so.1.9(+0x4d693) [0xb767c693]
0xb7749b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0xb7749b18]
0xb7749e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0xb7749e84]
0xb775617c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0xb775617c]
0xb7750673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0xb7750673]
0xb7753b46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0xb7753b46]
0xb7755ca8 /usr/lib/libruby-1.9.1.so.1.9(rb_vm_invoke_proc+0x278) [0xb7755ca8]
0xb7761824 /usr/lib/libruby-1.9.1.so.1.9(+0x132824) [0xb7761824]
0xb7761941 /usr/lib/libruby-1.9.1.so.1.9(+0x132941) [0xb7761941]
0xb761b985 /lib/tls/i686/nosegneg/libpthread.so.0(+0x5985) [0xb761b985]
0xb752213e /lib/tls/i686/nosegneg/libc.so.6(clone+0x5e) [0xb752213e]

[NOTE]
You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

libxml 2.6.0 fails test_quote_char

With ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux] and libxml2-2.9.0 I'm seeing the following test failure:

  1) Failure:
test_quote_char(TestWriter) [/var/tmp/portage/dev-ruby/libxml-2.6.0/work/ruby19/libxml-2.6.0/test/tc_writer.rb:253]:
<"<?xml version='1.0'?>\n<root abc='def'/>"> expected but was
<"<?xml version=\"1.0\"?>\n<root><child abc='def'>ghi</child></root>">.

2.3.0 fails to compile on OS X

libxml2 (2.7.8) is installed via homebrew

gem install libxml-ruby -v '2.3.0'
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
    ERROR: Failed to build gem native extension.

        /Users/jan/.rvm/rubies/ree-1.8.7-2012.01/bin/ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... no
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... yes
creating extconf.h
creating Makefile

make
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c libxml.c
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c ruby_xml.c
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c ruby_xml_attr.c
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c ruby_xml_attr_decl.c
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c ruby_xml_attributes.c
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c ruby_xml_cbg.c
/usr/bin/gcc-4.2  -I. -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -g -O2  -pipe -fno-common  -I/usr/include/libxml2 -I/opt/local/include -I. -I/Users/jan/.rvm/rubies/ree-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.3.0 -I. -I/usr/local/include  -c ruby_xml_document.c
ruby_xml_document.c: In function ‘rxml_document_canonicalize’:
ruby_xml_document.c:202: error: ‘XML_C14N_1_0’ undeclared (first use in this function)
ruby_xml_document.c:202: error: (Each undeclared identifier is reported only once
ruby_xml_document.c:202: error: for each function it appears in.)
ruby_xml_document.c:328: warning: passing argument 4 of ‘xmlC14NDocDumpMemory’ from incompatible pointer type
ruby_xml_document.c: In function ‘rxml_init_document’:
ruby_xml_document.c:1100: error: ‘XML_C14N_1_0’ undeclared (first use in this function)
ruby_xml_document.c:1102: error: ‘XML_C14N_EXCLUSIVE_1_0’ undeclared (first use in this function)
make: *** [ruby_xml_document.o] Error 1

Unable to call schema_validate on XML::Reader

I have a large XML document that I want to validate against an XML Schema without having to load the entire document tree.

Looking at the docs, XML::Reader.schema_validate seems to fit the bill, but when I try to use it I get an error "TypeError: can't convert LibXML::XML::Schema into String".

If I try XML::Document.validate_schema, then it works fine. Here's an example of what I'm trying in irb:

ruby-1.8.7-p330 :001 > require 'libxml'
=> true
ruby-1.8.7-p330 :002 > include LibXML
=> Object
ruby-1.8.7-p330 :003 > reader = LibXML::XML::Reader.file('example.xml', :encoding => XML::Encoding::UTF_8)
=> #LibXML::XML::Reader:0x101314708
ruby-1.8.7-p330 :004 > document = LibXML::XML::Document.file('example.xml', :encoding => XML::Encoding::UTF_8)
=> ...
ruby-1.8.7-p330 :005 > schema = LibXML::XML::Schema.document(XML::Document.file('schema.xsd'))
ruby-1.8.7-p330 :006 > document.validate_schema(schema)
=> true
ruby-1.8.7-p330 :007 > reader.schema_validate(schema)
TypeError: can't convert LibXML::XML::Schema into String
from (irb):7:in `schema_validate'
from (irb):7

Is validate_schema not applicable for XML::Reader?

If I use backticks and call xmllint with --stream and --schema options then validation works fine.

Regards,

Mezza

test errors with Ruby1.8 (uninitialized constant Float::INFINITY)

Hi,

Your gemspec file indicates that the supported Ruby version is 1.8.6. However, two tests from tc_schema.rb (l. 119 and 124) give an error:

NameError: uninitialized constant Float::INFINITY

with Ruby 1.8.7.
It seems that the introduction of Float::INFINITY for ruby1.8 in ext/libxml/ruby_xml_schema_type.rb line 242 does not work.

Cheers,

Cédric

Broken when used as a Rails gem (and probably in other rubygem contexts)

When using libxml-ruby with rails as such:

config.gem "libxml-ruby", :version => "~> 2.2.2"

An error is thrown:

no such file to load -- libxml-ruby

This can be corrected by adding a file at lib/libxml-ruby.rb that contains:

require 'libxml'

The long way around would be to rename everything according to rubygem patterns. If you're interested in this option I could create a fork and rename, preserving the 'xml' and 'libxml' imports. Then again, you could just rename the gem as libxml. :)

Ping.

Testing issues feed.

Multithreading instability

I've gotten a report or two of people seeing instability when using libxml with Sidekiq, e.g sidekiq/sidekiq#857. I looked through the docs and noticed that it says the library should call xmlInitParser when initializing the library but don't see that called anywhere in libxml-ruby.

This is what I'm referencing:

http://xmlsoft.org/threads.html

Any other possible threading issues my users should know about?

"gem build" is not working

$ gem build libxml-ruby.gemspec
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Specification::FileList

Reader#expand leaking memory?

Hi,

I'm trying to use libxml-ruby to parse ~250MB XML files. The files contain list of similar elements, so I'm iterating
over each element doing reader.expand on it.

The problem is that even if I run GC.start after expanding each element, the script eats up all available memory and
eventually dies.

It seems that the memory is freed up only on reader.close.

Here's small test case - https://gist.github.com/3d3270abf62370317809

There are 3 scripts: the first one generates 2 XML files with list of nodes - shorter file (~100KB) has only one element
in the list, longer one (~100MB) has 1000 elements.

The second script parses short XML file 1000 times and uses constant amount of memory.

The third script parses long XML file only once and uses up all available memory.

Sax Parser Crashes on exceptions with process destroying on 1.1.3

Sax Parser crashes on non valid xmls and destroys the running process

Platform - Ubuntu 9.04 Linux (32), Ruby MRI 1.8.7
Libxml-ruby ver 1.1.3

Code:

class SAXParserCallbacks include LibXML::XML::SaxParser::Callbacks end parser = LibXML::XML::SaxParser.io( data_io ) parser.callbacks = SAXParserCallbacks.new( {:header => header} ) parser.parse
I couldn't add that xml cos it breaks the markup.

This bug was earlier opened by cthulhu on cfis/libxml-ruby repository.

Segfault, possibly due to xmlDeregisterNodeDefault() callback and GC

With the following ruby version:

$ ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]

This script segfaults or raises an exception:

require 'xml'

loop do
  doc = XML::Document.string('<foo><bar/><baz/></foo>')
  node = doc.root.first.remove!
  doc.root.last.next = node
end

I suspect that the segfault is due to libxml-ruby's xmlDeregisterNodeDefault() callback. I suspect the following happens:

  1. libxml-ruby creates node A
    • VALUE pointer A is stored in the _private field
  2. GC mark phase is invoked
    • node A is unreachable
  3. Ruby object B is created, and re-uses VALUE pointer from A
  4. GC sweep phase is invoked
    • rxml_document_free() is called
    • xmlFreeDoc() is called
    • rxml_node_deregisterNode() is called on node A
    • The _private field now points to Ruby object B
    • Memory corruption occurs

I haven't yet stepped through the code to confirm.

Here is a similar issue on Nokogiri:
sparklemotion/nokogiri#881 (comment)

Document::file and "too many open files"

When I run Document.file a lot I get a too many open files error. Obviously it's not clearing up after itself.

Test script:

require "xml"
require "tempfile"
temp = Tempfile.new "too-many-files-"
temp.puts "<whatever/>"
temp.flush
count = 0
begin
    while true
        XML::Document.file temp.path
        count += 1
    end
rescue => e
    puts e
    puts e.backtrace
end
puts "failed after #{count} loops"

Output:

james@simba:~/desktop$ ruby1.9.1 too-many-files.rb 
Error: Too many open files.
Error: Too many open files.
Warning: failed to load external entity "/tmp/too-many-files-20110805-2406-5m37pj".
Warning: failed to load external entity "/tmp/too-many-files-20110805-2406-5m37pj".
/var/lib/gems/1.9.1/gems/libxml-ruby-2.1.1/lib/libxml/parser.rb:35:in `file'
/var/lib/gems/1.9.1/gems/libxml-ruby-2.1.1/lib/libxml/parser.rb:35:in `file'
/var/lib/gems/1.9.1/gems/libxml-ruby-2.1.1/lib/libxml/document.rb:34:in `file'
too-many-files.rb:11:in `'
failed after 1617 loops
james@simba:~/desktop$ 

I was interested in trying to fix this myself as I'm sure it's pretty simple but I am having trouble getting the tests etc to run. I get errors about "uninitialized constant Rake::DSL". I would appreciate any help getting this set up as this is a very important library to me.

A workaround for this problem is to load the file myself and use Document.string instead. In fact, Document.string(File.read(filename)) works fine. So it's more of an annoyance than anything else.

Sub Document Canonicalization

Looking at the source for canonicalize(), I noticed that the libxml2 library method "xmlC14NDocDumpMemory" is being called with the node argument defaulted to NULL. Is there any way to get access to the node argument via the canonicalize method? This is greatly needed for signing SOAP requests.

build failure against libxml2-2.9.0

Heads up!

When Fedora 18 is released, you're probably going to get a lot of people tripping over the libxml-ruby. That Fedora release looks set to ship with libxml2-2.9.0. When building libruby-xml-2.3.3 native extensions with that version of libxml2 installed, you get:

...
gcc -I. -I. -I/home/sheldonh/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/x86_64-linux -I. -I/usr/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -O2 -fno-tree-dce -fno-optimize-sibling-calls -fPIC -I. -I/home/sheldonh/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/x86_64-linux -I. -I/usr/include/libxml2 -I/usr/local/include -c ruby_xml_node.c
ruby_xml_node.c: In function ‘rxml_node_to_s’:
ruby_xml_node.c:622:54: error: dereferencing pointer to incomplete type
ruby_xml_node.c:624:56: error: dereferencing pointer to incomplete type
make: *** [ruby_xml_node.o] Error 1

Tested with ruby-1.8.7-p371 and ruby-1.9.3-p327 (using rvm), on a fresh Fedora 18 Beta x86_64 box with libxml2-2.9.0-3.fc18 and libxml2-devel-2.9.0-3.fc18 installed.

Hope that helps.

Ciao,
Sheldon.

document.canonicalize(comments) only supports XML_C14N_1_1

libxml-ruby only supports XML_C14N_1_1 canonicalization mode. libxml2 also supports XML_C14N_1_0 and XML_C14N_EXCLUSIVE_1_0. I need XML_C14N_EXCLUSIVE_1_0 support and would like to add it. It seems like a small fix should be enough to fix this.

I need help to figure out how to run the test suite. When I run "rake test", I get the following error:

$ rake test
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
/usr/local/lib/ruby/1.9.1/rdoc/task.rb:30: warning: already initialized constant Task
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Grancher::Task#desc called at /usr/local/lib/ruby/gems/1.9.1/gems/grancher-0.1.5/lib/grancher/task.rb:21:in define_task' WARNING: DSL method Grancher::Task#task called at /usr/local/lib/ruby/gems/1.9.1/gems/grancher-0.1.5/lib/grancher/task.rb:22:indefine_task'
/usr/local/bin/ruby -I"lib:test" -I"/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib" "/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader.rb" "test/test*.rb"
internal:lib/rubygems/custom_require:29:in require': no such file to load -- libxml_ruby (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire'
from /home/ec2-user/libxml-ruby/lib/libxml.rb:8:in rescue in <top (required)>' from /home/ec2-user/libxml-ruby/lib/libxml.rb:4:in<top (required)>'
from internal:lib/rubygems/custom_require:29:in require' from <internal:lib/rubygems/custom_require>:29:inrequire'
from /home/ec2-user/libxml-ruby/lib/xml.rb:13:in <top (required)>' from <internal:lib/rubygems/custom_require>:29:inrequire'
from internal:lib/rubygems/custom_require:29:in require' from /home/ec2-user/libxml-ruby/test/test_helper.rb:13:in<top (required)>'
from internal:lib/rubygems/custom_require:29:in require' from <internal:lib/rubygems/custom_require>:29:inrequire'
from /home/ec2-user/libxml-ruby/test/tc_attr.rb:3:in <top (required)>' from <internal:lib/rubygems/custom_require>:29:inrequire'
from internal:lib/rubygems/custom_require:29:in require' from /home/ec2-user/libxml-ruby/test/test_suite.rb:8:in<top (required)>'
from internal:lib/rubygems/custom_require:29:in require' from <internal:lib/rubygems/custom_require>:29:inrequire'
from /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9:in block (2 levels) in <main>' from /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9:ineach'
from /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:9:in block in <main>' from /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:5:ineach'
from /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:5:in `

'
rake aborted!
Command failed with status (1): [/usr/local/bin/ruby -I"lib:test" -I"/usr/l...]

Tasks: TOP => test
(See full trace by running task with --trace)

$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]

Thanks,
Peder

A node got with expand becomes invalid after the Reader is advanced

The simple program below yields "This node has already been freed. (RuntimeError)". When a node is fetched from a Reader object via Reader#expand, it becomes unavailable after the reader is advanced beyond the node.

This worked fine with libxml-ruby (1.1.4), but it doesn't work with libxml-ruby (2.1.1). Is it a regression, or it should always have worked like this?

#!/usr/bin/ruby
require 'rubygems'
require 'xml'
doc = XML::Reader.string "<one/>"
doc.next
element = doc.expand
# This works well
puts element

doc.next

# Runtime error here
puts element

segfault with invalid xpath expression

applying an invalid xpath expression segfaults after a previous error. this is caused by xmlGenericErrorContext set to stderr after the first error (libxml2/error.c:75) and structuredErrorFunc trying to call the on_error handler on that "object" on the second error (ruby_xml_error.c:153). the offending change to structuredErrorFunc has been introduced in ba2365f.

reproduce:

d = LibXML::XML::Document.string('<a></a>')
d.find('//a/') resuce nil  # invalid expression, OK
d.find('//a/') resuce nil  # BOOM!

tested with:

  • ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
  • ruby 1.9.2p136 (2010-12-25 revision 30363) [x86_64-linux]
  • libxml-ruby 1.1.4 (current master)
  • libxml2 2.7.6
  • libxml2 2.7.8

backtrace (ruby 1.8.7, libxml2 2.7.8):

0  0x0000000000493756 in st_lookup (table=0x50fc200000000000, key=4135, value=0x7fffffffb978) at st.c:250
1  0x0000000000410911 in search_method (klass=140737342666979, id=4135, origin=0x7fffffffb9c8) at eval.c:486
2  0x000000000041097b in rb_get_method_body (klassp=0x7fffffffb9f8, idp=0x7fffffffb9f0, noexp=0x7fffffffba0c) at eval.c:507
3  0x0000000000410bf3 in rb_method_node (klass=140737342666979, id=4135) at eval.c:563
4  0x000000000041a9a7 in rb_obj_respond_to (obj=140737342666848, id=11289, priv=0) at eval.c:4244
5  0x000000000041aa64 in rb_respond_to (obj=140737342666848, id=11289) at eval.c:4261
6  0x00007ffff6d52899 in structuredErrorFunc (userData=0x7ffff750f860, xerror=0x7ffff6d48600) at ruby_xml_error.c:153
7  0x00007ffff69c06bb in __xmlRaiseError (schannel=0x7ffff6d527f2 <structuredErrorFunc>, 
   channel=0x7ffff69bef84 <xmlGenericErrorDefaultFunc>, data=0x7ffff750f860, ctx=0x0, nod=0x0, domain=12, code=1207, 
   level=XML_ERR_ERROR, file=0x0, line=0, str1=0x780ee0 "//a/", str2=0x0, str3=0x0, int1=4, col=0, msg=0x7ffff6b0b421 "%s")
   at error.c:614
8  0x00007ffff6a322de in xmlXPathErr__internal_alias (ctxt=0x7dea40, error=7) at xpath.c:366
9  0x00007ffff6a46412 in xmlXPathCompNodeTest (ctxt=0x7dea40, test=0x7fffffffbda4, type=0x7fffffffbd9c, prefix=0x7fffffffbd88, 
   name=0x0) at xpath.c:11003
10 0x00007ffff6a47032 in xmlXPathCompStep (ctxt=0x7dea40) at xpath.c:11278
11 0x00007ffff6a475a5 in xmlXPathCompRelativeLocationPath (ctxt=0x7dea40) at xpath.c:11372
12 0x00007ffff6a4778e in xmlXPathCompLocationPath (ctxt=0x7dea40) at xpath.c:11411
13 0x00007ffff6a44c13 in xmlXPathCompPathExpr (ctxt=0x7dea40) at xpath.c:10607
14 0x00007ffff6a44e02 in xmlXPathCompUnionExpr (ctxt=0x7dea40) at xpath.c:10639
15 0x00007ffff6a45128 in xmlXPathCompUnaryExpr (ctxt=0x7dea40) at xpath.c:10679
16 0x00007ffff6a45201 in xmlXPathCompMultiplicativeExpr (ctxt=0x7dea40) at xpath.c:10704
17 0x00007ffff6a454c5 in xmlXPathCompAdditiveExpr (ctxt=0x7dea40) at xpath.c:10745
18 0x00007ffff6a456db in xmlXPathCompRelationalExpr (ctxt=0x7dea40) at xpath.c:10783
19 0x00007ffff6a45981 in xmlXPathCompEqualityExpr (ctxt=0x7dea40) at xpath.c:10825
20 0x00007ffff6a45bcf in xmlXPathCompAndExpr (ctxt=0x7dea40) at xpath.c:10856
21 0x00007ffff6a45dce in xmlXPathCompileExpr (ctxt=0x7dea40, sort=1) at xpath.c:10882
22 0x00007ffff6a4f156 in xmlXPathEvalExpr__internal_alias (ctxt=0x7dea40) at xpath.c:14853
23 0x00007ffff6a4f2fe in xmlXPathEval__internal_alias (str=0x780ee0 "//a/", ctx=0x7c9cd0) at xpath.c:14895
24 0x00007ffff6d5df8c in rxml_xpath_context_find (self=140737353425600, xpath_expr=140737353425720) at ruby_xml_xpath_context.c:273
25 0x000000000041e31a in call_cfunc (func=0x7ffff6d5df23 <rxml_xpath_context_find>, recv=140737353425600, len=1, argc=1, 
   argv=0x7fffffffc760) at eval.c:5784
26 0x000000000041f0d3 in rb_call0 (klass=140737353748560, recv=140737353425600, id=3737, oid=3737, argc=1, argv=0x7fffffffc760, 
   body=0x7ffff7fa0da8, flags=0) at eval.c:5928
27 0x0000000000420024 in rb_call (klass=140737353748560, recv=140737353425600, mid=3737, argc=1, argv=0x7fffffffc760, scope=0, 
   self=140737353427360) at eval.c:6176
28 0x00000000004177ca in rb_eval (self=140737353427360, n=0x7ffff7f86660) at eval.c:3506
29 0x000000000041fa50 in rb_call0 (klass=140737353754480, recv=140737353427360, id=3737, oid=3737, argc=0, argv=0x7fffffffd178, 
   body=0x7ffff7f86660, flags=0) at eval.c:6079
30 0x0000000000420024 in rb_call (klass=140737353754480, recv=140737353427360, mid=3737, argc=1, argv=0x7fffffffd170, scope=0, 
   self=140737353925280) at eval.c:6176
31 0x00000000004177ca in rb_eval (self=140737353925280, n=0x7ffff7fa9c78) at eval.c:3506
32 0x00000000004169d3 in rb_eval (self=140737353925280, n=0x7ffff7faa948) at eval.c:3322
33 0x00000000004121fc in eval_node (self=140737353925280, node=0x7ffff7faa948) at eval.c:1449
34 0x00000000004128e6 in ruby_exec_internal () at eval.c:1654
35 0x000000000041293b in ruby_exec () at eval.c:1674
36 0x000000000041295e in ruby_run () at eval.c:1684
37 0x00000000004100ae in main (argc=3, argv=0x7fffffffe128, envp=0x7fffffffe148) at main.c:48

possible workaround:

diff --git a/ext/libxml/ruby_xml_error.c b/ext/libxml/ruby_xml_error.c
index 4520697..b35b296 100644
--- a/ext/libxml/ruby_xml_error.c
+++ b/ext/libxml/ruby_xml_error.c
@@ -147,7 +147,7 @@ static void structuredErrorFunc(void *userData, xmlErrorPtr xerror)
   /* If the target has an on_error method call it.  This
    gets around a bug in libxml where a sax's structured
    error handler is overriden by the global error handler. */
-  if (userData)
+  if (userData && userData != stderr)
   {  
     VALUE target = (VALUE) userData;
     if (!NIL_P(target) && rb_respond_to(target, ON_ERROR_METHOD))

however, i'm not sure what a real fix should look like. and this is also not a production-critical problem (yet). it just occurs from time to time when testing xpath expressions in irb. nonetheless, an official fix would be appreciated.

cheers,
jens

libxml-ruby installation error: dereferencing pointer to incomplete type

Hi,

I have an issue when installing libxml-ruby gem.

System is CentOS 5.8

libxml2-devel is installed:
libxml2-devel.i386 2.6.26-2.1.15.el5_8.2 installed
libxml2-devel.x86_64 2.6.26-2.1.15.el5_8.2 installed

Zlib is also installed:
zlib.i386 1.2.3-4.el5 installed
zlib.x86_64 1.2.3-4.el5 installed
zlib-devel.i386 1.2.3-4.el5 installed
zlib-devel.x86_64 1.2.3-4.el5 installed

As I know libm and libiconv come with glibc, right?

I get the following output:

gem install libxml-ruby -v '2.3.2'

Building native extensions. This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby extconf.rb

checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... yes
checking for atan() in -lm... no
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -llibiconv... no
checking for iconv_open() in -llibiconv... no
checking for iconv_open() in -lc... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... no
checking for libxml/xmlversion.h in /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... yes
creating extconf.h
creating Makefile

make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_reader.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_xpath.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_attr_decl.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_attributes.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_schema.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_relaxng.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_html_parser_options.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_parser_options.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c libxml.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_html_parser_context.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_parser.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_cbg.c
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -DRUBY_EXTCONF_H="extconf.h" -fPIC -g -O2 -I. -I/usr/ocal/lib/ruby/1.8/x86_64-linux -I. -I/usr/local/include/libxml2 -I/usr/local/include -c ruby_xml_node.c
ruby_xml_node.c: In function ‘rxml_node_to_s’:
ruby_xml_node.c:622: error: dereferencing pointer to incomplete type
ruby_xml_node.c:624: error: dereferencing pointer to incomplete type
make: *** [ruby_xml_node.o] Error 1

Any help will be appreciated!

Thank you!
Eugene

ruby-head (1.9.3dev) install issue

Is anyone else having trouble installing libxml-ruby on ruby-head? (ruby 1.9.3dev (2011-06-05 trunk 31927) [x86_64-darwin10.7.0])

Installing libxml-ruby (2.0.6) with native extensions /Users/cdunn/.rvm/rubies/ruby-head/lib/ruby/1.9.1/rubygems/installer.rb:557:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

    /Users/cdunn/.rvm/rubies/ruby-head/bin/ruby extconf.rb 

extconf.rb:6: stack level too deep (SystemStackError)

Can't install ox gem

Hello! I can't install ox gem( I try different versions from (1.9.2 to 2.0.0).

gem install ox

ERROR: Error installing ox:
ERROR: Failed to build gem native extension.

    /usr/local/redmine/ruby/bin/ruby extconf.rb

Creating Makefile for ruby version 1.9.3 on x86_64-linux <<<<<
creating Makefile
extconf.rb:62:in ``': No such file or directory - make clean (Errno::ENOENT)
from extconf.rb:62:in`

'

Is it possible resolve this problem? Thank's for watching!

Test failure with all libxml versions when using libxml2 2.8.0

I just noticed that libxml-2.3.3 fails a test with ruby 1.8.7 (2012-06-29 patchlevel 370) [x86_64-linux] and libxml2 2.8.0.

  1) Failure:
test_invalid_encoding(TestReader) [./tc_reader.rb:331]:
<LibXML::XML::Error> exception expected but none was thrown.

typo in rdoc

Explanation of LibXML::XML::Node#doctype? is "Specifies if this is an docbook node".
I think this is wrong.

malloc error in v1.1.3 on OS X Leopard

I'm getting the following error when using v1.1.3 on OS X Leopard. I can reproduce it consistently. I know that it wont
happen when I turn off garbage collection or if the script never reaches a point where garbage collection is needed.
I also tried running the same code against v1.1.2 and did not receive the error.

ruby(74165) malloc: *** error for object 0x1808910: incorrect checksum for freed object - object was probably modified
after being freed.
*** set a breakpoint in malloc_error_break to debug
ruby(74165) malloc: *** error for object 0x17affe0: incorrect checksum for freed object - object was probably modified
after being freed.
*** set a breakpoint in malloc_error_break to debug
ruby(74165) malloc: *** error for object 0x17a7e70: incorrect checksum for freed object - object was probably modified
after being freed.
*** set a breakpoint in malloc_error_break to debug

This happens when I run the test suite for Blather. The code for doing so is below:

git clone git://github.com/sprsquish/blather.git
cd blather
rake build
rake

--Jeff

64-bit machine segfault on document.validate(schema)

Running code shown at: http://codeidol.com/other/rubyckbk/XML-and-HTML/Validating-an-XML-Document/ using libxml-ruby 2.0.5 on ruby 1.9.2-head produces segmentation fault on 64-bit machines. The same code works fine on 32-bit architectures.

complete irb session:

bash-/~$ irb
Loaded /home/sdownie/.irbrc successfully!
Switch to inspect mode.
ruby-1.9.2-head :001 > require 'xml/libxml'
require 'xml/libxml'
=> true
ruby-1.9.2-head :002 > dtd = XML::Dtd.new(%{
dtd = XML::Dtd.new(%{
ruby-1.9.2-head :003">

ruby-1.9.2-head :004">

ruby-1.9.2-head :005">

ruby-1.9.2-head :006">

ruby-1.9.2-head :007">

ruby-1.9.2-head :008"> })

})

=> #LibXML::XML::Dtd:0x000000014a00a0
ruby-1.9.2-head :009 > open('cookbook.xml', 'w') do |f|
open('cookbook.xml', 'w') do |f|
ruby-1.9.2-head :010 > f.write %{
f.write %{
ruby-1.9.2-head :011">

ruby-1.9.2-head :012">

ruby-1.9.2-head :013"> <title>A recipe</title>

<title>A recipe</title> ruby-1.9.2-head :014"> A difficult/common problem A difficult/common problem ruby-1.9.2-head :015"> A smart solution A smart solution ruby-1.9.2-head :016"> A deep solution A deep solution ruby-1.9.2-head :017"> Pointers Pointers ruby-1.9.2-head :018"> ruby-1.9.2-head :019"> ruby-1.9.2-head :020"> } } ruby-1.9.2-head :021?> end end => 266 ruby-1.9.2-head :022 > document = XML::Document.file('cookbook.xml') document = XML::Document.file('cookbook.xml') => <title>A recipe</title> A difficult/common problem A smart solution A deep solution Pointers

ruby-1.9.2-head :023 > document.validate(dtd)
document.validate(dtd)
=> true
ruby-1.9.2-head :024 > schema = XML::Schema.from_string %{
schema = XML::Schema.from_string %{
ruby-1.9.2-head :025">

ruby-1.9.2-head :026"> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
ruby-1.9.2-head :027"> <xsd:element name="recipe" type="recipeType"/>
<xsd:element name="recipe" type="recipeType"/>
ruby-1.9.2-head :028">

ruby-1.9.2-head :029"> <xsd:element name="rubycookbook" type="rubycookbookType"/>
<xsd:element name="rubycookbook" type="rubycookbookType"/>
ruby-1.9.2-head :030">

ruby-1.9.2-head :031"> <xsd:element name="title" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
ruby-1.9.2-head :032"> <xsd:element name="problem" type="xsd:string"/>
<xsd:element name="problem" type="xsd:string"/>
ruby-1.9.2-head :033"> <xsd:element name="solution" type="xsd:string"/>
<xsd:element name="solution" type="xsd:string"/>
ruby-1.9.2-head :034"> <xsd:element name="discussion" type="xsd:string"/>
<xsd:element name="discussion" type="xsd:string"/>
ruby-1.9.2-head :035"> <xsd:element name="seealso" type="xsd:string"/>
<xsd:element name="seealso" type="xsd:string"/>
ruby-1.9.2-head :036">

ruby-1.9.2-head :037"> <xsd:complexType name="rubycookbookType">
<xsd:complexType name="rubycookbookType">
ruby-1.9.2-head :038"> xsd:sequence
xsd:sequence
ruby-1.9.2-head :039"> <xsd:element ref="recipe"/>
<xsd:element ref="recipe"/>
ruby-1.9.2-head :040"> /xsd:sequence
/xsd:sequence
ruby-1.9.2-head :041"> /xsd:complexType
/xsd:complexType
ruby-1.9.2-head :042"> <xsd:complexType name="recipeType">
<xsd:complexType name="recipeType">
ruby-1.9.2-head :043"> xsd:sequence
xsd:sequence
ruby-1.9.2-head :044"> <xsd:element ref="title"/>
<xsd:element ref="title"/>
ruby-1.9.2-head :045"> <xsd:element ref="problem"/>
<xsd:element ref="problem"/>
ruby-1.9.2-head :046"> <xsd:element ref="solution"/>
<xsd:element ref="solution"/>
ruby-1.9.2-head :047"> <xsd:element ref="discussion"/>
<xsd:element ref="discussion"/>
ruby-1.9.2-head :048"> <xsd:element ref="seealso"/>
<xsd:element ref="seealso"/>
ruby-1.9.2-head :049"> /xsd:sequence
/xsd:sequence
ruby-1.9.2-head :050"> /xsd:complexType
/xsd:complexType
ruby-1.9.2-head :051">

ruby-1.9.2-head :052"> /xsd:schema
/xsd:schema
ruby-1.9.2-head :053"> }
}
=> #LibXML::XML::Schema:0x00000001619710
ruby-1.9.2-head :054 >

ruby-1.9.2-head :055 > document.validate(schema)
document.validate(schema)
(irb):55: [BUG] Segmentation fault
ruby 1.9.2dev (2010-05-20 revision 27928) [x86_64-linux]

-- control frame ----------
c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC :validate
c:0023 p:0014 s:0082 b:0082 l:0017a8 d:000081 EVAL (irb):55
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/context.rb:254
c:0018 p:0031 s:0058 b:0058 l:001f88 d:000057 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:159
c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:273
c:0016 p:0011 s:0045 b:0045 l:001f88 d:000044 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:156
c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:243
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:228
c:0008 p:0046 s:0022 b:0022 l:001f88 d:001f88 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:155
c:0007 p:0011 s:0019 b:0019 l:0009f8 d:000018 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch
c:0004 p:0183 s:0011 b:0011 l:0009f8 d:0009f8 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0177 s:0006 b:0006 l:001508 d:002458 EVAL /home/sdownie/.rvm/rubies/ruby-1.9.2-head/bin/irb:17
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH

c:0001 p:0000 s:0002 b:0002 l:001508 d:001508 TOP

-- Ruby level backtrace information ----------------------------------------
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/bin/irb:17:in <main>' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:69:instart'
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:69:in catch' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:70:inblock in start'
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:155:in eval_input' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/context.rb:254:inevaluate'
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/workspace.rb:80:in evaluate' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/workspace.rb:80:ineval'
(irb):55:in irb_binding' (irb):55:invalidate'

-- C level backtrace information -------------------------------------------
irb(rb_vm_bugreport+0xa9) [0x518e59]
irb() [0x5599a6]
irb(rb_bug+0xb1) [0x559b41]
irb() [0x4aaf40]
/lib64/libpthread.so.0() [0x327aa0f4a0]
/usr/lib64/libxml2.so.2(xmlValidateOneElement+0x23e) [0x3f8e26ccde]
/usr/lib64/libxml2.so.2(xmlValidateElement+0x6a) [0x3f8e26d8da]
/usr/lib64/libxml2.so.2(xmlValidateDtd+0x9a) [0x3f8e26dc6a]
/home/sdownie/.rvm/gems/ruby-1.9.2-head/gems/libxml-ruby-2.0.5/lib/libxml_ruby.so(+0xffc8) [0x7f50e59dcfc8]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x515eb2]
irb(rb_f_eval+0xd6) [0x516466]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x517ca9]
irb(rb_rescue2+0x15b) [0x41789b]
irb() [0x5040f9]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x5167ee]
irb(rb_catch_obj+0xbe) [0x502d5e]
irb() [0x50401a]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x5167ee]
irb(rb_catch_obj+0xbe) [0x502d5e]
irb() [0x50401a]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb(rb_iseq_eval_main+0x28a) [0x51587a]
irb() [0x417c12]
irb(ruby_run_node+0x36) [0x419826]
irb(main+0x49) [0x416e19]
/lib64/libc.so.6(__libc_start_main+0xfd) [0x327a21ec5d]
irb() [0x416d09]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)


Let me know if additional information is required.

HTH,

-- Steve

Specified module could not be found (Windows)

Using either the binary version or building the gem myself, I get the following error when trying to use 2.3.3:

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require':
126: The specified module could not be found. - C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.3.3/lib/libxml_ruby.so (LoadError)
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in 'require'from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.3.3/lib/libxml.rb:8:in 'rescue in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.3.3/lib/libxml.rb:4:in '<top (required)>'from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'rescue in require'from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in 'require'
` from blah.rb:1:in '

'

I've tried with the 1.9.x version of both railsinstaller and rubyinstaller with the same result. It looks like it has something to do with the require "#{$1}/libxml_ruby" statement in lib/libxml.rb, but I'm unsure what the fix should be for this.

Nodes returned by Reader#expand raise errors on Node#find

When I call Node#find on any nodes that I get via Reader#expand, an exception is raised with the message "Document is not accessible to Ruby (hint - did you call Reader#expand?)."

My assumption is that the LibXML::XML::Node objects returned by Reader#expand are no longer associated with a Document object and hence the XPath find methods are not applicable. I understand that this was change from 1.1.4 in order to fix the memory leaks with Reader#expand.

If my understanding is correct, I think that this should be mentioned in the documentation.

I was using #find in the returned node, and I had difficulty finding the cause.

LibXML::XML::Error , without any message or error code

Hi

I dont know if it is a bug or something, but when I try to do something like this:

document = XML::Document.new()
document.root = XML::Node.new("root_element")

XML::Namespace.new(document.root,  "foo", "bar")
XML::Namespace.new(document.root,  "foo", "bar")
XML::Namespace.new(document.root,  "foo", "bar")

all I get is this:

test.rb:76:in `initialize':  LibXML::XML::Error. (LibXML::XML::Error)
    from test.rb:76:in `new'
    from test.rb:76:in `<main>'

without any descriptive error message or the error code, which makes tracking errors very difficult

is this some sort of a bug or is it correct ?

Branch Merge -- metadata

I just pushed up a branch called 'metadata'. The changes modernize the project's layout and metadata files. If looks good, please apply to master as soon as possible, so others can fork from there.

There are tweaks still to be made to finish this off. For instance, a rake task should be made that updates the ext/libxml/ruby_xml_version.h file based on what is in the VERSION file. Also the publish task needs to be redone now that we are using GitHub. Be sure to check out Grancher to copy the web/ directory to the gh-pages branch (I can do this if you need me too). Please! Do not edit the gh-pages branch by hand (those git people are crazy ;-).

2.0.3 fails to compile on OS X

I just tried installing 2.0.3 and got the following results. I then tried with --version=2.0.2 and it installed without a problem. Any thoughts?

InternetMachine:~ pete$ gem install libxml-ruby --no-ri --no-rdoc
Fetching: libxml-ruby-2.0.3.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
    ERROR: Failed to build gem native extension.

        /Users/pete/.rvm/rubies/ruby-1.8.7-p330/bin/ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... no
checking for atan() in -lm... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for libxml/xmlversion.h... yes
creating extconf.h
creating Makefile

make
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c libxml.c
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c ruby_xml.c
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c ruby_xml_attr.c
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c ruby_xml_attr_decl.c
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c ruby_xml_attributes.c
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c ruby_xml_cbg.c
gcc -I. -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include -DRUBY_EXTCONF_H=\"extconf.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64  -fno-common -pipe -fno-common  -I/usr/include/libxml2 -I. -I/Users/pete/.rvm/rubies/ruby-1.8.7-p330/lib/ruby/1.8/x86_64-darwin10.6.0 -I. -I/usr/local/include  -c ruby_xml_document.c
ruby_xml_document.c: In function ‘rxml_document_canonicalize’:
ruby_xml_document.c:146: error: ‘XML_C14N_1_1’ undeclared (first use in this function)
ruby_xml_document.c:146: error: (Each undeclared identifier is reported only once
ruby_xml_document.c:146: error: for each function it appears in.)
make: *** [ruby_xml_document.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.