Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/rexml/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2325,11 +2325,11 @@ def get_attribute( name )
return attr
end
end
element_document = @element.document
if element_document and element_document.doctype
doctype = @element.document&.doctype
if doctype
expn = @element.expanded_name
expn = element_document.doctype.name if expn.size == 0
attr_val = element_document.doctype.attribute_of(expn, name)
expn = doctype.name if expn.size == 0
attr_val = doctype.attribute_of(expn, name)
return Attribute.new( name, attr_val ) if attr_val
end
return nil
Expand Down Expand Up @@ -2371,8 +2371,9 @@ def []=( name, value )
end

unless value.kind_of? Attribute
if @element.document and @element.document.doctype
value = Text::normalize( value, @element.document.doctype )
doctype = @element.document&.doctype
if doctype
value = Text::normalize( value, doctype )
else
value = Text::normalize( value, nil )
end
Expand Down Expand Up @@ -2409,10 +2410,11 @@ def prefixes
each_attribute do |attribute|
ns << attribute.name if attribute.prefix == 'xmlns'
end
if @element.document and @element.document.doctype
doctype = @element.document&.doctype
if doctype
expn = @element.expanded_name
expn = @element.document.doctype.name if expn.size == 0
@element.document.doctype.attributes_of(expn).each {
expn = doctype.name if expn.size == 0
doctype.attributes_of(expn).each {
|attribute|
ns << attribute.name if attribute.prefix == 'xmlns'
}
Expand All @@ -2434,10 +2436,11 @@ def namespaces
each_attribute do |attribute|
namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
end
if @element.document and @element.document.doctype
doctype = @element.document&.doctype
if doctype
expn = @element.expanded_name
expn = @element.document.doctype.name if expn.size == 0
@element.document.doctype.attributes_of(expn).each {
expn = doctype.name if expn.size == 0
doctype.attributes_of(expn).each {
|attribute|
namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
}
Expand Down