Portál AbcLinuxu, 9. května 2025 21:39
$xsl=DOMDocument::load("style.xsl");Po nacitani pridavam include
$inc =$xsl->createElement("xsl:include"); $stylesheet = $xsl->getElementsByTagName('stylesheet')->item(0); $inc->setAttribute("href","modules/XSL/style.xsl"); $stylesheet->appendChild($inc);Transformacia prebieha vo funkcii transform, vyzera asi takto:
function transform(&$DOMxml,&$DOMxsl,&$out) { $xsl = new XSLTProcessor(); $xsl->importStyleSheet($DOMxsl); $out=$xsl->transformToXML($DOMxml); }PHP mi vyhadzuje chybu Warning XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: Found a top-level element xsl:include with null namespace URI.
function transform(&$DOMxml,&$DOMxsl,&$out) { $xsl = new XSLTProcessor(); $DOMxsl = DOMDocument::loadXML($DOMxsl->saveXML()); $xsl->importStyleSheet($DOMxsl); $out=$xsl->transformToXML($DOMxml); }Da sa to obist aj elegantnejsim sposobom ako prevadzat cele xml do stringu a potom ho znovu nacitavat a prevadzat do xml?
$inc =$xsl->createElement("xsl:include");na
$inc =$xsl->createElementNS("http://www.w3.org/1999/XSL/Transform","xsl:include");
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.