I\'m trying to combine two xml-files and with a XSLT-file transform them into a XHTML-page. I have not done this before and can´t figure out how to do it. This is what I hav
This might be an answer to part of your question.
With regard to using two XML files, you have a couple of options. You could combine the two XML files into one larger one, then apply a transform to that. Alternatively, you could use the XSLT document()
function to load one of the XML files from within an XSLT.
1. Make one large XML document
loadXML("$x1 $x2 ");
// XSL
$xsl_doc = new DOMDocument();
$xsl_doc->load("file.xsl");
// Proc
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl_doc);
$newdom = $proc->transformToDoc($xml_doc);
print $newdom->saveXML();
?>
2. Use the XSTL document()
function
load("file1.xml");
// XSL
$xsl_doc = new DOMDocument();
$xsl_doc->load("file.xsl");
// Proc
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl_doc);
$newdom = $proc->transformToDoc($xml_doc);
print $newdom->saveXML();
?>
I tend to use the first technique more than the second. I don't like hardcoding filenames into XSLT templates. When I do use the second method, I would usually pass in the filename as an external parameter to avoid having it hardcoded in the XSLT.