REXML::XPath results out of sort order ?

Discussion in 'Ruby' started by Peter Fitzgibbons, Oct 21, 2005.

  1. ------=_Part_19521_23874415.1129902870318
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Hello,
    I need a reality check here,
    given this xml : http://rafb.net/paste/results/iziEQI77.html

    this test :
    mi =3D XPath.match(@xml, '//HomesiteTree/Builder/Division/Workflow/Mileston=
    e')
    assert_equal '10', mi[0].elements['MsMilestoneId'].text

    fails with :
    2) Failure:
    test_enrollmentMilestones(EnrollmentTest)
    [C:/ruby/dev/BuildviewExtractor/test/functional/enrollment_test.rb:64]:
    <"10"> expected but was
    <"80">.


    Is XPath.match returning results out of order ?

    Am I missing something ?

    Thanks for your advice.

    Peter Fitzgibbons

    ------=_Part_19521_23874415.1129902870318--
    Peter Fitzgibbons, Oct 21, 2005
    #1
    1. Advertising

  2. Peter Fitzgibbons

    daz Guest

    Peter Fitzgibbons wrote:
    > Hello,
    > I need a reality check here,
    > given this xml : http://rafb.net/paste/results/iziEQI77.html
    >
    > this test :
    > mi = XPath.match(@xml, '//HomesiteTree/Builder/Division/Workflow/Milestone')
    > assert_equal '10', mi[0].elements['MsMilestoneId'].text
    >
    > fails with :
    > 2) Failure:
    > test_enrollmentMilestones(EnrollmentTest)
    > [C:/ruby/dev/BuildviewExtractor/test/functional/enrollment_test.rb:64]:
    > <"10"> expected but was <"80">.
    >
    >
    > Is XPath.match returning results out of order ?
    >
    > Am I missing something ?
    >


    Sean has made lots of changes in the later version (see this post):
    http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/154866?154714-156516


    My quick test came up empty using this snippet on your data -
    (maybe I got something wrong):

    require 'rexml/document'
    p REXML::Version #-> "3.1.3"
    xml = REXML::Document.new('D:\ruby\DfB\TEMP\clruby\___test.xml')
    mi = REXML::XPath.match(xml, '//HomesiteTree/Builder/Division/Workflow/Milestone')

    p mi #-> []


    > Thanks for your advice.
    >
    > Peter Fitzgibbons



    Hope it's useful ...

    daz
    daz, Oct 21, 2005
    #2
    1. Advertising

  3. ------=_Part_1159_30386941.1129911430342
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    On 10/21/05, daz <> wrote:
    >
    >
    > Peter Fitzgibbons wrote:
    > > Hello,
    > > I need a reality check here,
    > > given this xml : http://rafb.net/paste/results/iziEQI77.html
    > >
    > > this test :
    > > mi =3D XPath.match(@xml,

    > '//HomesiteTree/Builder/Division/Workflow/Milestone')
    > > assert_equal '10', mi[0].elements['MsMilestoneId'].text
    > >
    > > fails with :
    > > 2) Failure:
    > > test_enrollmentMilestones(EnrollmentTest)
    > > [C:/ruby/dev/BuildviewExtractor/test/functional/enrollment_test.rb:64]:
    > > <"10"> expected but was <"80">.
    > >
    > >
    > > Is XPath.match returning results out of order ?
    > >
    > > Am I missing something ?
    > >

    >
    > Sean has made lots of changes in the later version (see this post):
    >
    > http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/154866?1547=

    14-156516
    >
    >
    > My quick test came up empty using this snippet on your data -
    > (maybe I got something wrong):
    >
    > require 'rexml/document'
    > p REXML::Version #-> "3.1.3"
    > xml =3D REXML::Document.new('D:\ruby\DfB\TEMP\clruby\___test.xml')
    > mi =3D REXML::XPath.match(xml,
    > '//HomesiteTree/Builder/Division/Workflow/Milestone')
    >
    > p mi #-> []
    >
    >
    > > Thanks for your advice.
    > >
    > > Peter Fitzgibbons

    >
    >
    > Hope it's useful ...
    >
    > daz
    >
    >
    >
    >
    > You have to File.open the file... Document.new doesn't know how to open

    the stream.. only how to read it.

    please try :

    xml =3D REXML::Document.new(File.open('D:\ruby\DfB\TEMP\clruby\__
    >
    > _test.xml') )


    ------=_Part_1159_30386941.1129911430342--
    Peter Fitzgibbons, Oct 21, 2005
    #3
  4. Peter Fitzgibbons

    daz Guest

    Peter Fitzgibbons wrote:
    >
    > You have to File.open the file... Document.new doesn't know how to open
    >the stream.. only how to read it.
    >
    > please try :
    >
    > xml = REXML::Document.new(File.open('D:\ruby\DfB\TEMP\clruby\___test.xml') )



    Gosh, that makes *such* a difference :)) <blush>

    I would have known that if I was doing it myself.


    Version 3.1.3 gives the correct result:

    p mi[0].elements['MsMilestoneId'].text #-> "10"


    daz
    daz, Oct 21, 2005
    #4
  5. ------=_Part_3059_26451485.1129919876261
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    On 10/21/05, daz <> wrote:
    >
    >
    > Peter Fitzgibbons wrote:
    > >
    > > You have to File.open the file... Document.new doesn't know how to open
    > >the stream.. only how to read it.
    > >
    > > please try :
    > >
    > > xml =3D REXML::Document.new(File.open('D:\ruby\DfB\TEMP\clruby\___test.=

    xml')
    > )
    >
    >
    > Gosh, that makes *such* a difference :)) <blush>
    >
    > I would have known that if I was doing it myself.
    >
    >
    > Version 3.1.3 gives the correct result:
    >
    > p mi[0].elements['MsMilestoneId'].text #-> "10"
    >
    >
    > daz
    >
    >
    >
    >
    > How do I find my current REXML version ? I'm using the default lib

    installed with one-click 1.8.15

    ------=_Part_3059_26451485.1129919876261--
    Peter Fitzgibbons, Oct 21, 2005
    #5
  6. ------=_Part_3099_19942736.1129919978851
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    On 10/21/05, Peter Fitzgibbons <> wrote:
    >
    >
    >
    > On 10/21/05, daz <> wrote:
    > >
    > >
    > > Peter Fitzgibbons wrote:
    > > >
    > > > You have to File.open the file... Document.new doesn't know how to

    > > open
    > > >the stream.. only how to read it.
    > > >
    > > > please try :
    > > >
    > > > xml =3D REXML::Document.new (File.open('D:\ruby\DfB\TEMP\clruby\___te=

    st.xml')
    > > )
    > >
    > >
    > > Gosh, that makes *such* a difference :)) <blush>
    > >
    > > I would have known that if I was doing it myself.
    > >
    > >
    > > Version 3.1.3 gives the correct result:
    > >
    > > p mi[0].elements['MsMilestoneId'].text #-> "10"
    > >
    > >
    > > daz
    > >
    > >
    > >
    > >
    > > How do I find my current REXML version ? I'm using the default lib

    > installed with one-click 1.8.15
    >
    > Oh, yes, I'm using 3.1.3.

    So what's different then ?

    ------=_Part_3099_19942736.1129919978851--
    Peter Fitzgibbons, Oct 21, 2005
    #6
  7. Peter Fitzgibbons

    daz Guest

    Peter Fitzgibbons wrote:
    > Peter Fitzgibbons wrote:
    > >
    > > How do I find my current REXML version ? I'm using the default lib
    > >installed with one-click 1.8.15

    >
    > Oh, yes, I'm using 3.1.3.



    There's a contradiction, somewhere (?)

    "One-click" 1.8.2-15 Stable Release (April 20, 2005) has REXML 3.1.2.1
    in Ruby 1.8.2 final (2004-12-25).


    require 'rexml/document'
    puts 'ruby %s (%s) [%s]' % [RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM]
    puts REXML::Version

    xml = REXML::Document.new(File.read('D:\ruby\DfB\TEMP\clruby\___test.xml'))
    mi = REXML::XPath.match(xml, '//HomesiteTree/Builder/Division/Workflow/Milestone')

    mi.each { |e| print ' ', e.elements['MsMilestoneId'].text }; puts

    #------------------------------------------

    #-> ruby 1.8.2 (2004-12-25) [i386-mswin32]
    #-> 3.1.2.1
    #-> 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 270 280 290 10 20

    #------------------------------------------

    #-> ruby 1.8.3 (2005-07-22) [i386-mswin32]
    #-> 3.1.3
    #-> 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 270 280 290

    #------------------------------------------


    > So what's different then ?


    I *know* I'm using 3.1.3 :)

    It fixes several bugs relating to XPath result ordering.
    The REXML tracker is down as I write, otherwise I'd give a link.

    If you're sure you're getting incorrect results using 3.1.3,
    please submit a bug report to:
    http://www.germane-software.com/projects/rexml/

    As you can see from my tests - the 2nd result array is in order.

    The disorder of the 1st result seems to be different from yours
    (first element of <80>) but maybe there's a random factor
    associated with the bug in 3.1.2.1 (?)


    daz
    daz, Oct 22, 2005
    #7
    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. nobody
    Replies:
    0
    Views:
    530
    nobody
    Jun 1, 2004
  2. Damphyr
    Replies:
    2
    Views:
    131
    Damphyr
    Jul 16, 2003
  3. Daniel Berger

    rexml error - REXML::Validation

    Daniel Berger, Oct 12, 2004, in forum: Ruby
    Replies:
    2
    Views:
    145
    Henrik Horneber
    Oct 12, 2004
  4. Replies:
    0
    Views:
    98
  5. Phlip
    Replies:
    0
    Views:
    135
    Phlip
    Jan 15, 2008
Loading...

Share This Page