asciidoctor / docbookrx

(An early version of) a DocBook to AsciiDoc converter written in Ruby.
MIT License
22 stars 49 forks source link

Fixing possible nil in proces_table #40

Closed mrietveld closed 8 years ago

mrietveld commented 8 years ago

I ran into the following exception: this PR fixes that.

/home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:846:in `block in process_table': undefined method `name' for nil:NilClass (NoMethodError)
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:844:in `times'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:844:in `process_table'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:828:in `visit_table'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:127:in `visit'
    from /home/mrietvel/.gem/ruby/2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node.rb:595:in `accept'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:138:in `block in traverse_children'
    from /home/mrietvel/.gem/ruby/2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
    from /home/mrietvel/.gem/ruby/2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
    from /home/mrietvel/.gem/ruby/2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `each'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:137:in `traverse_children'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:462:in `process_section'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx/docbook_visitor.rb:127:in `visit'
    from /home/mrietvel/.gem/ruby/2.3.0/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node.rb:595:in `accept'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx.rb:12:in `convert'
    from /home/mrietvel/Workspace/references/docbookrx/lib/docbookrx.rb:24:in `convert_file'
    from /home/mrietvel/Workspace/references/docbookrx/bin/docbookrx:32:in `<main>'
mojavelinux commented 8 years ago

Thanks!

Could you provide the snippet of DocBook that triggered this error. I'd like to add a test for it so that it doesn't break in the future.

mrietveld commented 8 years ago

Here's the snippet: once I tracked it down, the problem became obvious: there's a "mistake" in the docbook.

numcols is declared as 5, but only 4 columns are being used. The code expects a 5th <entry> element that isn't there.

<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0"
         xsi:schemaLocation="http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"
         xml:base="../" xmlns="http://docbook.org/ns/docbook" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink"
         xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ns="http://docbook.org/ns/docbook">
  <title>Configuration</title>
    <para>There are several control parameters available to alter engine default behavior. This allows to fine tune the
    execution for the environment needs and actual requirements. All of these parameters are set as JVM system properties,
    usually with -D when starting program e.g. application server.</para>

    <table>
    <title>Control parameters</title>
      <tgroup cols="5">
        <thead>
          <row>
            <entry>Name</entry>
            <entry>Possible values</entry>
            <entry>Default value</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>jbpm.ut.jndi.lookup</entry>
            <entry>String</entry>
            <entry></entry>
            <entry>Alternative JNDI name to be used when there is no access to the default one (java:comp/UserTransaction)</entry>
          </row>
        </tbody>
      </tgroup>
    </table>    
</section>
mrietveld commented 8 years ago

Merged: https://github.com/asciidoctor/docbookrx/commit/8b209816c89a3767b6cb03f23b0747a4ba477516