0

我正在尝试使用 Php XSLTProcessor将 XSL-FO 文件转换为 HTML 。我在这里做什么:

public static function toHTML($xml)
{
 // init
 $xp    = new XSLTProcessor();
 $xmlDoc   = new Mv_Dom_Document();
 $xmlDoc->loadXML($xml);
 $dirXslt  = $GLOBALS['G_config']['XSLT_STYLESHEETS'].'fo2html/';
 $aXsltSS  = GestionFichiers::getDirContent($dirXslt);

 // chargement des feuilles de styles XSLT pour la conversion
 foreach ($aXsltSS AS $stylesheet) {
  $xslDoc  = new Mv_Dom_Document($stylesheet->getRealPath());
  $xp->importStylesheet($xslDoc);
  unset($xslDoc);
 }

 // transformation HTML > XML
 return $xp->transformToXML($xmlDoc);
}

但我在转换时收到以下错误:

ERREUR - XSLTProcessor::transformToXml() [<a href='xsltprocessor.transformtoxml'>xsltprocessor.transformtoxml</a>]: xsltApplySequenceConstructor: apply-templates was not compiled
ERREUR - XSLTProcessor::transformToXml() [<a href='xsltprocessor.transformtoxml'>xsltprocessor.transformtoxml</a>]: xsltApplySequenceConstructor: apply-templates was not compiled
ERREUR - XSLTProcessor::transformToXml() [<a href='xsltprocessor.transformtoxml'>xsltprocessor.transformtoxml</a>]: xsltApplySequenceConstructor: if was not compiled

当我尝试直接使用 apache fop 扩展来转换我的 XSL-FO 时,转换成功,那么为什么 php 失败了?

PS:当我尝试使用 XSLTProcessor 将其他东西转换为具有正确样式表的 HTML2FO 时,我没有遇到任何问题。

之前谢谢。

编辑:样式表已从http://svn.apache.org/repos/asf/db/derby/docs/trunk/lib/fo2html.xsl上的 apache svn 下载,这里是我一直使用的输入示例测试:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" line-stacking-strategy="font-height">
    <fo:layout-master-set>
        <fo:simple-page-master margin-bottom="35.4pt" margin-left="27pt" margin-right="19.3pt" margin-top="35.4pt" master-name="pm0" page-height="841.9pt" page-width="595.3pt">
            <fo:region-body margin-bottom="-17.4pt" margin-top="-17.4pt" overflow="visible" region-name="body"/>
            <fo:region-before extent="771.1pt" overflow="visible" region-name="header"/>
            <fo:region-after display-align="after" extent="771.1pt" overflow="visible" region-name="footer"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="pm0" orphans="2" white-space-collapse="false" widows="2">
        <fo:flow flow-name="body">
            <fo:block end-indent="0pt" line-height="13.7pt" start-indent="0pt" text-align="start" text-indent="0pt">
                <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" role="html:body" font-family="Times Roman, serif" font-size="12pt">
                    <fo:inline role="html:span" font-weight="bold">
                        <fo:inline text-decoration="underline" role="html:u">Informations sur le patient</fo:inline>
                    </fo:inline>
                </fo:block>
            </fo:block>
            <fo:block line-height="13.7pt">
                <fo:leader line-height="13.7pt"/>
            </fo:block>
            <fo:block line-height="13.7pt">
                <fo:leader line-height="13.7pt"/>
            </fo:block>
            <fo:block end-indent="0pt" line-height="11.4pt" start-indent="0pt" text-align="start" text-indent="0pt">
                <fo:inline font-family="Times Roman, serif" font-size="10pt">
                    <fo:inline role="html:body" font-weight="bold">
                        idPATIENT :
                    </fo:inline>
                    <fo:inline role="html:body">
                        1
                    </fo:inline>
                </fo:inline>
            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>
4

0 回答 0