[eluser]St0neyx[/eluser]
Hi,
I'm trying get some sort of xsl templating in CI.
First idea was to put all the xsl files in the view folder as views but the thing is when you do that you can't get the source from it.
Code:
$contentXsl = $this->load->view('templates/content.xsl');
$contentXml = $this->get->content() // returns xml for content
echo $this->xlsparser->parse($contentXml, $contentXsl); //outputs xhtml
(simple example of the idea)
I now got a model that parses the xml and xsl to a nice xhtml, but it now needs the template and source both as string, which isn't acceptable because then i have to define all the templates myself, and the idea is that one of the designers can make xls templates, my models deliver the xml for that template and the parser makes the xhtml.
Code:
// Load the XML source
$xml = new DOMDocument;
$xml->loadxml($source); // or load() if it's a file
// Load the XSL source
$xsl = new DOMDocument;
$xsl->loadxml($template); // or load() if it's a file
// Configure the transformer
$proc = new XSLTProcessor;
// Enable ability to use php functions
$proc->registerPHPFunctions();
// attach the xsl rules
$proc->importStyleSheet($xsl);
// output result
return $proc->transformToXML($xml);
What is the best place for storing those xsl files?
Or better yet, can someone point me in a direction to make something like this work?