2011-05-13 47 views
1

是否可以将XSL-FO转换为XHTML?我曾尝试RenderX样式表fo2html.xsl但输出完全中断。将xsl-fo转换为(x)html?

我想要实现的是让用户编辑Flash应用程序(AS2)中的XSL-FO内容;所以我想将它转换为HTML,让用户编辑它,然后转换回XSL-FO(最终转换为PDF)。

编辑:实际运行PHP 5.3.5瓦特/ 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; 

其中$看起来像这样:

<?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> 
+0

什么是renderX样式表输出的“完全破坏”?我之前使用过它们,它们工作得很好。 – 2011-05-14 00:22:48

+1

你可以发布你的Html输出吗? – kitensei 2011-05-18 09:02:18

+1

我认为从头开始很难做到。也许你的问题应该显示一点XSLT,否则你期望哪种类型的答案? – 2011-06-21 04:51:08

回答

0

XSL-FO为XML,所以使用以下命令: