繁体   English   中英

将xsl-fo转换为(x)html?

[英]converting xsl-fo to (x)html?

是否可以将XSL-FO转换为XHTML? 我已经尝试过RenderX样式表fo2html.xsl,但是输出已完全损坏。

我要实现的目标是让用户在Flash应用程序(AS2)中编辑XSL-FO内容。 因此我想将其转换为HTML,让用户对其进行编辑,然后再转换回XSL-FO(最后转换为PDF)。

编辑:实际运行php 5.3.5 w / apache 2.2

实际上,这就是我要做的:

$in = '.\\files\\in.fo';
$out = '.\\files\\out.fo';

// transform
$xp = new XSLTProcessor();
$xml = new DOMDocument();
$xml->loadXML(file_get_contents($in));
$style = new DOMDocument();
$style->load('D:\\apache\\htdocs\\mv\\last\\myvisit\\outils\\xslt\\stylesheets\\fo2html\\fo2html.xsl');
$xp->importStylesheet($style);
// XML > HTML
$html = $xp->transformToXML($xml);
echo $html;

其中$ in看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master margin-bottom="35.4pt" margin-left="70.85pt" margin-right="70.85pt" margin-top="35.4pt" master-name="pm0" page-height="841.9pt" page-width="595.3pt">
            <fo:region-body margin-bottom="35.45pt" margin-top="35.45pt" 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:inline font-family="Times Roman, serif" font-size="12pt">%%patient.identite%%</fo:inline>
            </fo:block>
            <fo:block line-height="13.7pt">
                <fo:leader line-height="13.7pt"/>
            </fo:block>
            <fo:block end-indent="0pt" line-height="13.7pt" start-indent="0pt" text-align="start" text-indent="0pt">
                <fo:inline font-family="Times Roman, serif" font-size="12pt">%%listePrescriptions[withCompoDecomposee,withLastAdmin]%%</fo:inline>
            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

并输出HTML如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>XSL FO Document</title>
        <meta http-equiv="Content-Style-Type" content="text/css"/>
        <style type="text/css">
        <![CDATA[
            a { color: black; border: none; text-decoration: none; }
            img { border: none; } 
        ]]>
        </style>
    </head>
    <body bgcolor="white" marginwidth="6" marginheight="6" leftmargin="6" topmargin="6">
        <div>
        </div>
    </body>
</html>

XSL-FO是XML,因此请使用以下命令:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM