[libxml-devel] parsing document containing doctype with saxparser causes null pointer given

Charlie Savage cfis at savagexi.com
Fri Jul 25 23:05:57 EDT 2008


> I'm having the same issue.  It seems the issue manifest itself when 
> callbacks is set.  Below is an example; if I remove DOCTYPE tag, the 
> problem is gone.  Any ideas on solutions or workarounds?
> 
> class Handler
>   include XML::SaxParser::Callbacks
>   def on_start_element(element, attributes)
>     puts element
>   end
> end
> 
> xp = XML::SaxParser.new
> xp.callbacks = Handler.new
> xp.string = <<-EOS
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Results SYSTEM "results.dtd">
> <Results>
> <a>a1</a>
> </Results>
>   EOS
> xp.parse

Works here.  See the last test case in tc_sax_parser.rb (from the 
original bug report).

To be sure, I did this:

   class DocTypeCallback
     include XML::SaxParser::Callbacks
     def on_start_element(element, attributes)
       puts element
     end
   end

   def test_doctype
     @xp.callbacks = DocTypeCallback.new
     @xp.string = <<-EOS
       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE Results SYSTEM "results.dtd">
       <Results>
         <a>a1</a>
       </Results>
     EOS
     doc = @xp.parse
     assert_not_nil(doc)
   end


And it works fine.  So...let's make sure we are all using the same 
versions.  Libxml_ruby version?  libxml version?  Operating system?  Etc.

Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://rubyforge.org/pipermail/libxml-devel/attachments/20080725/7453aed1/attachment.bin>


More information about the libxml-devel mailing list