[php-src] Issue #21357: XSLTProcessor works with \DOMDocument, but fails with \Dom\XMLDocument
[email protected] (jacekkow)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <g1yvARaCRYXzDr9g6ur5qT5EFXvl0CzHWDndSZOT35U@main.internal.php.net> |
Issue: https://github.com/php/php-src/issues/21357
Author: jacekkow
### Description
The following code:
```php
<?php
$dom = \Dom\XMLDocument::createFromFile("http://crd.gov.pl/wzor/2025/06/25/13775/styl.xsl");
var_dump(new \XSLTProcessor()->importStylesheet($dom));
```
Resulted in this output:
```
PHP Warning: XSLTProcessor::importStylesheet(): error in /tmp/xmldocument.php on line 3
PHP Warning: XSLTProcessor::importStylesheet(): xsltCompileStepPattern : no namespace bound to prefix tns in /tmp/xmldocument.php on line 3
PHP Warning: XSLTProcessor::importStylesheet(): compilation error: file http://crd.gov.pl/wzor/2025/06/25/13775/styl.xsl line 34 element template in /tmp/xmldocument.php on line 3
PHP Warning: XSLTProcessor::importStylesheet(): xsltCompilePattern : failed to compile 'tns:Faktura' in /tmp/xmldocument.php on line 3
bool(false)
```
But I expected this output instead:
```
bool(true)
```
Which is what `\DOMDocument` version outputs:
```php
<?php
$dom = new \DOMDocument;
$dom->load("http://crd.gov.pl/wzor/2025/06/25/13775/styl.xsl");
var_dump(new \XSLTProcessor()->importStylesheet($dom)); // works!
```
### PHP Version
```plain
PHP 8.5.3 (cli) (built: Feb 13 2026 15:50:47) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
```
### Operating System
Debian 13