druser
Новичок
компиляция xml+xslt в html в php - #1
Поиск результатов не дал, в одноименном топике тоже ничего хорошего...
написал простой скриптик, но вот появилась проблемка... может кто поскажет?
xmlxsl.php
В общем на выходе следующие ошибки:
Warning: XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: compilation error: element xsl:stylesheet in E:\Home\localhost\www\My\xmlxsl.php on line 26
Warning: XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: xsltParseStylesheetProcess : document is not a stylesheet in E:\Home\localhost\www\My\xmlxsl.php on line 26
Warning: XSLTProcessor::transformToXml() [function.XSLTProcessor-transformToXml]: No stylesheet associated to this object in E:\Home\localhost\www\My\xmlxsl.php on line 27
Жду конструктивных предложений и замечаний по коду! Заранее спасибо!![Smile :) :)](/talk/styles/default/xenforo/smilies/smile.png)
ps Там где output = $root->appendChild($domxsl->createElement()) в createElement параметр NS .
utput ![Wink ;) ;)](/talk/styles/default/xenforo/smilies/wink.png)
Поиск результатов не дал, в одноименном топике тоже ничего хорошего...
написал простой скриптик, но вот появилась проблемка... может кто поскажет?
xmlxsl.php
PHP:
$domxml = new domDocument('1.0', 'WINDOWS-1251');
$domxml->appendChild($domxml->createElement('xhtml'));
$domxml->save('xhtml.xml');
define('NS', 'xsl');
$domxsl = new domDocument('1.0', 'WINDOWS-1251');
$domxsl->preserveWhiteSpace = FALSE;
$domxsl->formatOutput = TRUE;
$root = $domxsl->appendChild($domxsl->createElement(NS . ':stylesheet'));
$root->setAttribute('version', '1.0');
$root->setAttribute(NS, 'http://www.w3.org/1999/XSL/Transform');
$output = $root->appendChild($domxsl->createElement(NS . ':output'));
$output->setAttribute('method', 'xml');
$output->setAttribute('encoding', 'WINDOWS-1251');
$output->setAttribute('ident', 'yes');
$template = $root->appendChild($domxsl->createElement(NS . ':template'));
$template->setAttribute('match', '/');
$html = $template->appendChild($domxsl->createElement('html'));
$head = $html->appendChild($domxsl->createElement('head'));
$title = $head->appendChild($domxsl->createElement('title'));
$title->appendChild($domxsl->createTextNode(iconv('WINDOWS-1251', 'UTF-8', 'страница #1')));
$domxsl->save('xhtml.xsl');
$xsl = new xsltProcessor();
$xsl->importStylesheet($domxsl);
echo $xsl->transformtoXML($domxml);
Warning: XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: compilation error: element xsl:stylesheet in E:\Home\localhost\www\My\xmlxsl.php on line 26
Warning: XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: xsltParseStylesheetProcess : document is not a stylesheet in E:\Home\localhost\www\My\xmlxsl.php on line 26
Warning: XSLTProcessor::transformToXml() [function.XSLTProcessor-transformToXml]: No stylesheet associated to this object in E:\Home\localhost\www\My\xmlxsl.php on line 27
Жду конструктивных предложений и замечаний по коду! Заранее спасибо!
![Smile :) :)](/talk/styles/default/xenforo/smilies/smile.png)
ps Там где output = $root->appendChild($domxsl->createElement()) в createElement параметр NS .
![Eek! :eek: :eek:](/talk/styles/default/xenforo/smilies/eek.png)
![Wink ;) ;)](/talk/styles/default/xenforo/smilies/wink.png)