Nori 2 doesn't parse whole XML but only the first root tag
inossidabile opened this issue ยท comments
xml = <<-XML
<request>
<entities href="#id1">
</entities>
</request>
<entity id="id1">
<foo><bar>1</bar></foo>
<sub href="#id2" />
</entity>
<ololo id="id2">
<foo>1</foo>
</ololo>
XML
Nori.new.parse xml # {"request"=>{"entities"=>{"@href"=>"#id1"}}}
i'll be gone for a few hours, but will take a look at this later today.
seems like this is not a regression. nori 1.x only parses a single root node as well.
i can probably change that, but are you sure this is your problem?
wow. no. actually, 1.x produces some pretty weird stuff:
{
"request" => {
"entities" => { "@href" => "#id1" },
"entity" => { "foo" => { "bar" => "1" }, "sub" => { "@href" => "#id2" }, "@id" => "id1" },
"ololo" => { "foo" => "1", "@id" => "id2" }
}
}
didn't expect that. do you depend on this behavior? i don't think there's a spec for that.
Which is incorrect too but at least it's in there.
In this particular case the fact I can find it inside is the most important part since I seek it recursively for "@id". I think if you modify behavior at 2.x โ let's break it to the correct one at least ๐
yeah that's what i thought. so you would be ok with nori returning the following instead, right?
{
"request" => { "entities" => { "@href" => "#id1" } },
"entity" => { "foo" => { "bar" => "1" }, "sub" => { "@href" => "#id2" }, "@id" => "id1" },
"ololo" => { "foo" => "1", "@id" => "id2" }
}
Absolutely
great. i'll fix it.
๐
not happy with this workaround, but it passes the specs. released v2.0.1.
Actually I thought it gonna be way worse. Thank you! ๐
yanked v2.0.1 due to savonrb/savon#352.
@inossidabile you can use v2.0.0 with the rexml parser for now. it behaves just like it did in 1.x.
@inossidabile how badly do you need this? i don't really think manipulating the xml is a good solution and
both nokogiri and rexml don't support this. so it seems weird to add a workaround for this.
could you maybe simply wrap your xml in a root tag?
I did that already actually. I think I should close it.
thanks!