Sha256: 4f2b62046f9a46df56f8ec084ef59959eaf6209716069c24bf965830592a5b33

Contents?: true

Size: 716 Bytes

Versions: 18

Compression:

Stored size: 716 Bytes

Contents

module Metanorma
  module Utils
    class << self
      # NOTE: It was used in methods of an eigenclass of Metanorma::Utils.
      #       Not sure if it's still used somewhere but could be.
      class Namespace
        def initialize(xmldoc)
          @namespace = xmldoc.root.namespace
        end

        def ns(path)
          return path if @namespace.nil?

          path.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

      def create_namespace(xmldoc)
        Namespace.new(xmldoc)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
metanorma-utils-1.10.2 lib/utils/namespace.rb
metanorma-utils-1.10.1 lib/utils/namespace.rb
metanorma-utils-1.10.0 lib/utils/namespace.rb
metanorma-utils-1.9.0 lib/utils/namespace.rb
metanorma-utils-1.8.5 lib/utils/namespace.rb
metanorma-utils-1.8.4 lib/utils/namespace.rb
metanorma-utils-1.8.3 lib/utils/namespace.rb
metanorma-utils-1.8.2 lib/utils/namespace.rb
metanorma-utils-1.8.1 lib/utils/namespace.rb
metanorma-utils-1.8.0 lib/utils/namespace.rb
metanorma-utils-1.7.7 lib/utils/namespace.rb
metanorma-utils-1.7.6 lib/utils/namespace.rb
metanorma-utils-1.7.5 lib/utils/namespace.rb
metanorma-utils-1.7.4 lib/utils/namespace.rb
metanorma-utils-1.7.3 lib/utils/namespace.rb
metanorma-utils-1.7.2 lib/utils/namespace.rb
metanorma-utils-1.7.1 lib/utils/namespace.rb
metanorma-utils-1.7.0 lib/utils/namespace.rb