Skip to content

XSLTProcessor works with \DOMDocument, but fails with \Dom\XMLDocument #21357

@jacekkow

Description

@jacekkow

Description

The following code:

<?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
$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

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions