Class: Nokogiri::XML::Element

Inherits:
Object
  • Object
show all
Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-xsd-ec78ebe10f85/lib/rdf/xsd/extensions.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/jsonld_reader.rb

Instance Method Summary collapse

Instance Method Details

#baseObject

Get any xml:base in effect for this element



223
224
225
226
227
228
229
230
231
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/jsonld_reader.rb', line 223

def base
  if @base.nil?
    @base = attributes['xml:base'] ||
    (parent && parent.element? && parent.base) ||
    false
  end

  @base == false ? nil : @base
end

#c14nxl(options = {}) ⇒ Object

Canonicalize the Element. Return a new instance of this node which is canonicalized and marked as such.

Apply namespaces either passed as an option, or that are in scope.

Parameters:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-xsd-ec78ebe10f85/lib/rdf/xsd/extensions.rb', line 60

def c14nxl(options = {})
  options[:namespaces] ||= self.namespace_scopes.compact.inject({}) do |memo, ns|
    memo[ns.prefix] = ns.href.to_s
    memo
  end
  element = self.clone

  # Add in-scope namespace definitions
  options[:namespaces].each do |prefix, href|
    if prefix.to_s.empty?
      element.default_namespace = href unless element.namespace
    else
      element.add_namespace(prefix.to_s, href) unless element.namespaces[prefix.to_s]
    end
  end

  # Add language
  element["xml:lang"] = options[:language].to_s if
    options[:language] &&
    element.attribute_with_ns("lang", "http://www.w3.org/XML/1998/namespace").to_s.empty? &&
    element.attribute("lang").to_s.empty?

  element
end

#languageObject

Get any xml:lang or lang in effect for this element



236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-microdata-14cc40c62067/lib/rdf/microdata/jsonld_reader.rb', line 236

def language
  if @language.nil?
    language = case
    when self["xml:lang"]
      self["xml:lang"].to_s
    when self["lang"]
      self["lang"].to_s
    else
      parent && parent.element? && parent.language
    end
  end
  @language == false ? nil : @language
end