lib/utils/xml.rb in metanorma-utils-1.3.0 vs lib/utils/xml.rb in metanorma-utils-1.3.1
- old
+ new
@@ -52,8 +52,15 @@
l.gsub(/>\n$/, ">").gsub(/\s*\n$/m, " ").gsub("–", "\u0096")
.gsub("—", "\u0097").gsub("–", "\u0096")
.gsub("—", "\u0097")
end
end
+
+ def ns(xpath)
+ xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
+ .gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
+ .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/-]* ?=)}, "[xmlns:\\1")
+ .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/-]*[/\[\]])}, "[xmlns:\\1")
+ end
end
end
end