function on_populate_xslt ($data) { $format = coren::get_xsl_format(); if ($format == '') return; $files = array(); if (file_exists($filename = "{$this->dir}.xsl" )) $files[] = $filename; if (file_exists($filename = "{$this->dir}${format}/.xsl")) $files[] = $filename; foreach (coren::names() as $identifier) if ($identifier != '') { //???todo: normalize identifier to filename here: all special chars to "_". if (file_exists($filename = "{$this->dir}{$identifier}.xsl" )) $files[] = $filename; if (file_exists($filename = "{$this->dir}${format}/{$identifier}.xsl")) $files[] = $filename; } foreach ($files as $file) { $xslf = new DOMDocument(); $xslf->load($file); $xslt = coren::xsl(); //todo: optimize this: remove fragment, append immediately: $frag = $xslt->createDocumentFragment(); for ($i = 0; $i < $xslf->documentElement->childNodes->length; $i++) $frag->appendChild($xslt->importNode($xslf->documentElement->childNodes->item($i), true)); $xslt->documentElement->appendChild($frag); } }