Skip to content

Commit e6b1f2c

Browse files
committed
Move xmlns to constants class
1 parent a71e04b commit e6b1f2c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/XML/Constants.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class Constants
1616
*/
1717
public const NS_XML = 'http://www.w3.org/XML/1998/namespace';
1818

19+
/**
20+
* The namespace for XMLNS declarations.
21+
*/
22+
public const NS_XMLNS = 'http://www.w3.org/2000/xmlns/';
23+
1924
/**
2025
* The maximum amount of child nodes this library is willing to handle.
2126
* By specification, this limit is 150K, but that opens up for denial of service.

src/XPath/XPath.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public static function getXPath(DOMNode $node): DOMXPath
7171
*/
7272
private static function registerAncestorNamespaces(DOMXPath $xp, DOMNode $node): void
7373
{
74-
$xmlnsNs = 'http://www.w3.org/2000/xmlns/';
75-
7674
// Avoid re-binding while walking upwards.
7775
$registered = [
7876
'xml' => true,
@@ -87,7 +85,7 @@ private static function registerAncestorNamespaces(DOMXPath $xp, DOMNode $node):
8785
while ($current instanceof DOMElement) {
8886
if ($current->hasAttributes()) {
8987
foreach ($current->attributes as $attr) {
90-
if ($attr->namespaceURI !== $xmlnsNs) {
88+
if ($attr->namespaceURI !== C_XML::NS_XMLNS) {
9189
continue;
9290
}
9391
$prefix = $attr->localName; // e.g., 'slate' for xmlns:slate, 'xmlns' for default

0 commit comments

Comments
 (0)