php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47101 XSLT gives an error after putting a new namespace in the DOM
Submitted: 2009-01-14 15:35 UTC Modified: 2009-01-14 15:49 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at mycel dot nl Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.8 OS: Ubuntu 8.10, Windows XP
Private report: No CVE-ID: None
 [2009-01-14 15:35 UTC] php at mycel dot nl
Description:
------------
If you add a new namespace to the DOM Document then the XSLT gives an error "undefined namespace". And if you save the DOM and load again it works.

Reproduce code:
---------------
$oDOM = new DOMDocument();
$oDOM->load('random_file.xsl'); //Must be a valid XSL file with a <xsl:stylesheet> tag
$oDOM2 = new DOMDocument();
$oDOM2->load('random_file.xml'); //Must be a valid XML file

$oElement = $oDOM->getElementsbyTagNameNS('*', 'stylesheet')->item(0);
$oElement->setAttribute('xmlns:exsl', 'http://exslt.org/common');

$oXSLTransform = new XSLTProcessor();
$oXSLTransform->importStyleSheet($oDOM);
$oOutput = $oXSLTransform->transformToDoc($oDOM);

Expected result:
----------------
A transformed DOC document (without errors)

Actual result:
--------------
Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error: file file.xsl line 3 element stylesheet in file.php on line 13
Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsl:extension-element-prefix : undefined namespace exsl in file.php on line 13

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-14 15:49 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You need to use DOM Level 2 NS aware methods (setAttributeNS) and 
properly create the namespace declaration in the XMLNS namespace
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC