Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nokogiri parse xml produces different output on Windows #866

Closed
jamlen opened this issue Mar 19, 2013 · 8 comments
Closed

Nokogiri parse xml produces different output on Windows #866

jamlen opened this issue Mar 19, 2013 · 8 comments

Comments

@jamlen
Copy link

jamlen commented Mar 19, 2013

I have found that Nokogiri seems to produce different output for the same test code when run on Windows compared to running on Linux. On Linux Nokogiri includes the original namespace prefix from the message, but on Windows this is stripped off.

My guess is that the Windows output is correct since the snippet of XML which is being loaded into Nokogiri does not have the namespaces defined and therefore b:Geobounds is meaningless.

see https://gist.github.com/jamlen/5195661

Windows output:

c:\src\messagelogparser>bundle exec rspec spec\test_spec.rb
<?xml version="1.0"?>
<Geobounds xmlns:c="http://services.sample.com/models">
  <c:MaxLatitude>23.860175641661968</c:MaxLatitude>
  <c:MaxLongitude>120.91450520111084</c:MaxLongitude>
  <c:MinLatitude>23.84243451256043</c:MinLatitude>
  <c:MinLongitude>120.88480778289797</c:MinLongitude>
</Geobounds>
{:Geobounds=>{:MaxLatitude=>"23.860175641661968", :MaxLongitude=>"120.91450520111084", :MinLatitude=>"23.84243451256043", :MinLongitude=>"120.88480778289797"}}
.

Finished in 0.01562 seconds
1 example, 0 failures

Linux output:

jallen@~/dev/projects/messagelogparser$ rspec spec/test_spec.rb 
<?xml version="1.0"?>
<b:Geobounds xmlns:c="http://services.sample.com/models">
  <c:MaxLatitude>23.860175641661968</c:MaxLatitude>
  <c:MaxLongitude>120.91450520111084</c:MaxLongitude>
  <c:MinLatitude>23.84243451256043</c:MinLatitude>
  <c:MinLongitude>120.88480778289797</c:MinLongitude>
</b:Geobounds>
{:"b:Geobounds"=>{:MaxLatitude=>"23.860175641661968", :MaxLongitude=>"120.91450520111084", :MinLatitude=>"23.84243451256043", :MinLongitude=>"120.88480778289797"}}
F

Failures:

  1) for Geobound requests should fail in Linux but pass in Windows
     Failure/Error: actual.should have_key :Geobounds
       expected #has_key?(:Geobounds) to return true, got false
     # ./spec/test_spec.rb:22:in `block (2 levels) in <top (required)>'

Finished in 0.00919 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/test_spec.rb:21 # for Geobound requests should fail in Linux but pass in Windows
@flavorjones
Copy link
Member

Hi! This is most likely because of differing versions of libxml2, and not because of Nokogiri.

Nokogiri's windows gems package libxml 2.7.7 (as of v1.5.7), and whatever version you're running on your Linux machine is different from that.

I'd be interested in knowing if this is the case, but in the meantime I'm closing this ticket.

@jamlen
Copy link
Author

jamlen commented Mar 20, 2013

How do I know what version of libxml2 I have installed on my Linux?

@jamlen
Copy link
Author

jamlen commented Mar 20, 2013

I think that I have 2.8.0:

jallen@~$ dpkg -l | grep libxml2
ii  libxml2:amd64                                                            2.8.0+dfsg1-5ubuntu2.1                        amd64        GNOME XML library
ii  libxml2:i386                                                             2.8.0+dfsg1-5ubuntu2.1                        i386         GNOME XML library
ii  libxml2-dev:amd64                                                        2.8.0+dfsg1-5ubuntu2.1                        amd64        Development files for the GNOME XML library

@flavorjones
Copy link
Member

It's probably also worth understanding what versions of Nokogiri you're running on the two platforms; 1.5.7 and 1.5.8 have slightly different (fixed and buggy) namespace behavior wrt attributes than earlier releases on the 1.5 branch.

See #865, #868, #846, #801, #869.

@flavorjones
Copy link
Member

Specifically, could you show the output from nokogiri -v on each platform? Thanks. I'd like to make sure this isn't another namespace bug introduced in 1.5.{7,8}.

@jamlen
Copy link
Author

jamlen commented Mar 21, 2013

On Ubuntu 12.10

# Nokogiri (1.5.5)
    ---
    warnings: []
    nokogiri: 1.5.5
    ruby:
      version: 1.9.3
      platform: x86_64-linux
      description: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
      engine: ruby
    libxml:
      binding: extension
      compiled: 2.8.0
      loaded: 2.8.0

After bundle update

# Nokogiri (1.5.8)
    ---
    warnings: []
    nokogiri: 1.5.8
    ruby:
      version: 1.9.3
      platform: x86_64-linux
      description: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
      engine: ruby
    libxml:
      binding: extension
      compiled: 2.8.0
      loaded: 2.8.0

On Windows 7 x64

# Nokogiri (1.5.5)
    ---
    warnings: []
    nokogiri: 1.5.5
    ruby:
      version: 1.9.3
      platform: i386-mingw32
      description: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
      engine: ruby
    libxml:
      binding: extension
      compiled: 2.7.7
      loaded: 2.7.7

After bundle update

# Nokogiri (1.5.8)
    ---
    warnings: []
    nokogiri: 1.5.8
    ruby:
      version: 1.9.3
      platform: i386-mingw32
      description: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
      engine: ruby
    libxml:
      binding: extension
      compiled: 2.7.7
      loaded: 2.7.7

@flavorjones
Copy link
Member

Is the problem still reproducible when both platforms are running Nokogiri 1.5.8 (or now, 1.5.9)?

@jamlen
Copy link
Author

jamlen commented Mar 25, 2013

Yup verified to still be reproducible running Nokogiri 1.5.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants