@@ -2325,11 +2325,11 @@ def get_attribute( name )
2325
2325
return attr
2326
2326
end
2327
2327
end
2328
- element_document = @element . document
2329
- if element_document and element_document . doctype
2328
+ doctype = @element . document &. doctype
2329
+ if doctype
2330
2330
expn = @element . expanded_name
2331
- expn = element_document . doctype . name if expn . size == 0
2332
- attr_val = element_document . doctype . attribute_of ( expn , name )
2331
+ expn = doctype . name if expn . size == 0
2332
+ attr_val = doctype . attribute_of ( expn , name )
2333
2333
return Attribute . new ( name , attr_val ) if attr_val
2334
2334
end
2335
2335
return nil
@@ -2371,8 +2371,9 @@ def []=( name, value )
2371
2371
end
2372
2372
2373
2373
unless value . kind_of? Attribute
2374
- if @element . document and @element . document . doctype
2375
- value = Text ::normalize ( value , @element . document . doctype )
2374
+ doctype = @element . document &.doctype
2375
+ if doctype
2376
+ value = Text ::normalize ( value , doctype )
2376
2377
else
2377
2378
value = Text ::normalize ( value , nil )
2378
2379
end
@@ -2409,10 +2410,11 @@ def prefixes
2409
2410
each_attribute do |attribute |
2410
2411
ns << attribute . name if attribute . prefix == 'xmlns'
2411
2412
end
2412
- if @element . document and @element . document . doctype
2413
+ doctype = @element . document &.doctype
2414
+ if doctype
2413
2415
expn = @element . expanded_name
2414
- expn = @element . document . doctype . name if expn . size == 0
2415
- @element . document . doctype . attributes_of ( expn ) . each {
2416
+ expn = doctype . name if expn . size == 0
2417
+ doctype . attributes_of ( expn ) . each {
2416
2418
|attribute |
2417
2419
ns << attribute . name if attribute . prefix == 'xmlns'
2418
2420
}
@@ -2434,10 +2436,11 @@ def namespaces
2434
2436
each_attribute do |attribute |
2435
2437
namespaces [ attribute . name ] = attribute . value if attribute . prefix == 'xmlns' or attribute . name == 'xmlns'
2436
2438
end
2437
- if @element . document and @element . document . doctype
2439
+ doctype = @element . document &.doctype
2440
+ if doctype
2438
2441
expn = @element . expanded_name
2439
- expn = @element . document . doctype . name if expn . size == 0
2440
- @element . document . doctype . attributes_of ( expn ) . each {
2442
+ expn = doctype . name if expn . size == 0
2443
+ doctype . attributes_of ( expn ) . each {
2441
2444
|attribute |
2442
2445
namespaces [ attribute . name ] = attribute . value if attribute . prefix == 'xmlns' or attribute . name == 'xmlns'
2443
2446
}
0 commit comments