REXML 3.1.6 has a XPath parser problem

Discussion in 'Ruby' started by Kouhei Sutou, Jan 6, 2007.

  1. Kouhei Sutou

    Kouhei Sutou Guest

    Hi,

    XPath parser of REXML 3.1.6 has a problem related white
    space. We can meet the problem by function call with string
    which starts with "\nALPHABET".

    The following is patch and test case:

    diff -ru rexml_3.1.6.orig/src/rexml/parsers/xpathparser.rb rexml_3.1.6/src/rexml/parsers/xpathparser.rb
    --- rexml_3.1.6.orig/src/rexml/parsers/xpathparser.rb 2006-11-28 22:54:57.000000000 +0900
    +++ rexml_3.1.6/src/rexml/parsers/xpathparser.rb 2007-01-06 15:52:41.000000000 +0900
    @@ -551,7 +551,7 @@
    end
    end
    #puts "BEFORE WITH '#{rest}'"
    - rest = LocationPath(rest, n) if rest =~ /^[\/\.\@\[\w_*]/
    + rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w_*]/
    parsed.concat(n)
    return rest
    end
    diff -ru rexml_3.1.6.orig/test/functions.rb rexml_3.1.6/test/functions.rb
    --- rexml_3.1.6.orig/test/functions.rb 2006-11-28 22:54:56.000000000 +0900
    +++ rexml_3.1.6/test/functions.rb 2007-01-06 15:53:40.000000000 +0900
    @@ -212,4 +212,12 @@
    assert_equal( "A", REXML::XPath.first(document, '//b[.="A"]').text )
    assert_equal( "1", REXML::XPath.first(document, '//b[.="1"]').text )
    end
    +
    + def test_normalize_space
    + source = "<a><!--COMMENT A--><b><!-- COMMENT A --></b></a>"
    + doc = REXML::Document.new(source)
    + predicate = "string(.)=normalize_space('\nCOMMENT \n A \n\n ')"
    + m = REXML::XPath.match(doc, "//comment()[#{predicate}]")
    + assert_equal( [REXML::Comment.new("COMMENT A")], m )
    + end
    end


    Thanks,
    --
    kou
    Kouhei Sutou, Jan 6, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Damphyr
    Replies:
    2
    Views:
    137
    Damphyr
    Jul 16, 2003
  2. Han Holl

    Rexml xpath question

    Han Holl, Feb 22, 2004, in forum: Ruby
    Replies:
    7
    Views:
    138
    Han Holl
    Mar 6, 2004
  3. Daniel Berger

    rexml error - REXML::Validation

    Daniel Berger, Oct 12, 2004, in forum: Ruby
    Replies:
    2
    Views:
    151
    Henrik Horneber
    Oct 12, 2004
  4. Kouhei Sutou

    REXML 3.1.6 has XPath problems

    Kouhei Sutou, Dec 30, 2006, in forum: Ruby
    Replies:
    3
    Views:
    136
    vasudevram
    Jan 2, 2007
  5. Phlip
    Replies:
    0
    Views:
    140
    Phlip
    Jan 15, 2008
Loading...

Share This Page