[英]Need to know how to process 1 XML file with 2 XSL files using PHP SimpleXML
I am very new to XSL. 我对XSL非常陌生。 I need to process the same XML file with 2 XSL files using PHP SimpleXML.
我需要使用PHP SimpleXML使用2个XSL文件处理相同的XML文件。 I have tried a few different approaches with no luck.
我尝试了几种不同的方法,但是没有运气。
$xmlfile = 'media/xml_files/article.xml';
if (file_exists($xmlfile)) {
$xml = simplexml_load_file($xmlfile) or die("Error: Cannot create object");}
$xslfile = media/xsl_files/jats-html.xsl;
$xsl = simplexml_load_file($xslfile);
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);
I need to process the XML with jats-PMCcit.xsl before it goes through the jats-html.xsl transform. 在通过jats-html.xsl转换之前,我需要使用jats-PMCcit.xsl处理XML。 Can somebody please point me in the right direction?
有人能指出我正确的方向吗? I can't seem to find an answer online anywhere.
我似乎无法在任何地方在线找到答案。
You can try using XSLTProcessor::transformToDoc()
to process the first transformation and get intermediate transformation result in a DOMDocument
object type. 您可以尝试使用
XSLTProcessor::transformToDoc()
处理第一个转换并获得DOMDocument
对象类型的中间转换结果。 Then you can pass the DOMDocument
object to transformToXML()
to get the final transformation result. 然后,您可以将
DOMDocument
对象传递给transformToXML()
以获得最终的转换结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.