diff --git a/lib/odf-report/section.rb b/lib/odf-report/section.rb index 4b5970c..8920b23 100644 --- a/lib/odf-report/section.rb +++ b/lib/odf-report/section.rb @@ -26,11 +26,11 @@ def replace!(doc) private def find_section_node(doc) - @section_node = doc.at_css("text|section[@text|name='#{@name}']") + @section_node = doc.at_xpath("//text:section[@text:name='#{@name}']") end def deep_clone(node) - Nokogiri::XML(wrap_with_ns(node)).at("text|section") + Nokogiri::XML(wrap_with_ns(node)).at_xpath("//text:section") .tap { |n| n.attribute('name').content = SecureRandom.uuid } end diff --git a/lib/odf-report/table.rb b/lib/odf-report/table.rb index 5ffd674..98e988f 100644 --- a/lib/odf-report/table.rb +++ b/lib/odf-report/table.rb @@ -60,7 +60,6 @@ def get_next_row end return deep_clone(ret) - # return ret.dup end def get_start_node @@ -72,11 +71,11 @@ def template_length end def find_table_node(doc) - doc.at_css("table|table[@table|name='#{@name}']") + doc.at_xpath("//table:table[@table:name='#{@name}']") end def deep_clone(node) - Nokogiri::XML(wrap_with_ns(node)).at("table|table-row") + Nokogiri::XML(wrap_with_ns(node)).at_xpath("//table:table-row") end end diff --git a/spec/images_spec.rb b/spec/images_spec.rb index ca02808..a17daf6 100644 --- a/spec/images_spec.rb +++ b/spec/images_spec.rb @@ -116,8 +116,8 @@ end it "removes nil images in report" do - expect(@data.xml.at_css("draw|frame[@draw|name='IMAGE_01']")).to be - expect(@data.xml.at_css("draw|frame[@draw|name='IMAGE_02']")).to be_nil + expect(@data.xml.at_xpath(".//draw:frame[@draw:name='IMAGE_01']")).to be + expect(@data.xml.at_xpath(".//draw:frame[@draw:name='IMAGE_02']")).to be_nil end it "removes nil images in tables" do diff --git a/spec/sections_spec.rb b/spec/sections_spec.rb index 05018eb..623ec3a 100644 --- a/spec/sections_spec.rb +++ b/spec/sections_spec.rb @@ -38,12 +38,12 @@ end it "should remove section with empty collection" do - section = @data.xml.at_css("text|section[@text|name='SECTION_02']") + section = @data.xml.at_xpath("//text:section[@text:name='SECTION_02']") expect(section).to be_nil end it "should remove section with nil collection" do - section = @data.xml.at_css("text|section[@text|name='SECTION_03']") + section = @data.xml.at_xpath("//text:section[@text:name='SECTION_03']") expect(section).to be_nil end