Ticket #112 (closed defect: worksforme)

Opened 15 months ago

Last modified 4 months ago

getting local-name using xpath results in error

Reported by: geersing Owned by: ser
Priority: normal Milestone: 3.1.8
Component: XPath Version: 3.1.4
Severity: normal Keywords:
Cc: Ruby version: 1.8.5
Operating system: Linux

Description

Trying the following code:

>> xml="<Inspiratiepost xmlns=\"test\"><Publiek/></Inspiratiepost>"
=> "<Inspiratiepost xmlns=\"test\"><Publiek/></Inspiratiepost>"
>> doc = REXML::Document.new(xml)
=> <UNDEFINED> ... </>
>> REXML::XPath.match(doc.root,"local-name(//Publiek/ancestor::*)")

Result in error:

NoMethodError: undefined method `namespace' for [<Inspiratiepost xmlns='test'> ... </>]:Array
        from /usr/local/lib/ruby/1.8/rexml/functions.rb:70:in `get_namespace'
        from /usr/local/lib/ruby/1.8/rexml/functions.rb:50:in `local_name'
        from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:447:in `expr'
        from (irb):34:in `each_with_index'
        from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:434:in `expr'
        from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:125:in `match'
        from /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:56:in `parse'
        from /usr/local/lib/ruby/1.8/rexml/xpath.rb:63:in `match'
        from (irb):34

Should return:

=> ["Inspiratiepost"]

Change History

Changed 14 months ago by ser

  • milestone set to 3.1.8

Changed 14 months ago by ser

  • status changed from new to closed
  • resolution set to worksforme

I am unable to replicate this in any version back to REXML 3.1.4, including the version shipping with Ruby 1.8.5. I've added the following unit test:

  def test_ticket_112
    xml="<Inspiratiepost xmlns=\"test\"><Publiek/></Inspiratiepost>"
    doc = REXML::Document.new(xml)
    m = REXML::XPath.match(doc.root,"local-name(//Publiek/ancestor::*)")
    assert_equal( 1, m.size )
    assert_equal( "Inspiratiepost", m[0] )
  end

Can you provide any more information?

Note: See TracTickets for help on using tickets.