Oleg
Oleg

Reputation: 43

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

I have the following code of 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:

<?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).

How to get line breaks working?

Upvotes: 0

Views: 303

Answers (1)

Siebe Jongebloed
Siebe Jongebloed

Reputation: 4834

I would use an empty <fo:block/>:

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

Upvotes: 0

Related Questions