简体   繁体   English

<br>xsl-fo fop 处理器无法识别换行符

[英]<br> line breaks are not recognised by xsl-fo fop processor

I have the following code of xml:我有以下xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="XSL properties.xsl"?>
<ent>
<firstname>George</firstname>
<lastname>Smith</lastname>
</ent>

and the following code of xsl file:以及以下 xsl 文件的代码:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="A4-portrait"
              page-height="29.7cm" page-width="21.0cm" margin="2cm">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="A4-portrait">
        <fo:flow flow-name="xsl-region-body">
          <fo:block>
            <xsl:value-of select="ent/firstname"/><br/>
<xsl:value-of select="ent/lastname"/>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>
</xsl:stylesheet>

When I am trying to execute D:\fop-2.7\fop>fop -xml file.xml -xsl file2fo.xsl -pdf file.pdf in command line, it gives me this error: ьр 10, 2022 1:52:22 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Unknown formatting object "{}br" encountered (a child of fo:block}. (No context info available).当我试图在命令行中执行 D:\fop-2.7\fop>fop -xml file.xml -xsl file2fo.xsl -pdf file.pdf 时,它给了我这个错误:ьр 10, 2022 1:52:22 PM org.apache.fop.events.LoggingEventListener processEvent 警告:遇到未知格式对象“{}br”(fo:block} 的子级。(没有可用的上下文信息)。

How to get line breaks working?如何让换行符工作?

I would use an empty <fo:block/> :我会使用一个空的<fo:block/>

<fo:block>
  <xsl:value-of select="ent/firstname"/>
  <fo:block/>
  <xsl:value-of select="ent/lastname"/>
</fo:block>

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

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