Skip to content

Commit f531b70

Browse files
committed
Make "xml:" namespace a constant
1 parent f98d418 commit f531b70

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/rexml/parsers/baseparser.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class BaseParser
140140
"apos" => [/'/, "'", "'", /'/]
141141
}
142142

143+
XML_PREFIXED_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
144+
143145
module Private
144146
PEREFERENCE_PATTERN = /#{PEREFERENCE}/um
145147
TAG_PATTERN = /((?>#{QNAME_STR}))\s*/um
@@ -185,7 +187,7 @@ def stream=( source )
185187
@tags = []
186188
@stack = []
187189
@entities = []
188-
@namespaces = {"xml" => "http://www.w3.org/XML/1998/namespace"}
190+
@namespaces = {"xml" => XML_PREFIXED_NAMESPACE}
189191
@namespaces_restore_stack = []
190192
end
191193

@@ -790,7 +792,7 @@ def parse_attributes(prefixes)
790792
@source.match(/\s*/um, true)
791793
if prefix == "xmlns"
792794
if local_part == "xml"
793-
if value != "http://www.w3.org/XML/1998/namespace"
795+
if value != XML_PREFIXED_NAMESPACE
794796
msg = "The 'xml' prefix must not be bound to any other namespace "+
795797
"(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
796798
raise REXML::ParseException.new( msg, @source, self )

0 commit comments

Comments
 (0)